File indexing completed on 2025-08-05 08:16:07
0001 #include "InttGl1Check.h"
0002
0003 #include <fun4all/Fun4AllInputManager.h>
0004 #include <fun4all/Fun4AllReturnCodes.h>
0005 #include <fun4all/SubsysReco.h> // for SubsysReco
0006
0007 #include <ffarawobjects/Gl1Packet.h>
0008 #include <ffarawobjects/InttRawHit.h>
0009 #include <ffarawobjects/InttRawHitContainer.h>
0010
0011 #include <phool/PHCompositeNode.h>
0012 #include <phool/PHDataNode.h>
0013 #include <phool/PHNode.h> // for PHNode
0014 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0015 #include <phool/getClass.h>
0016
0017 #include <Event/packet.h>
0018
0019 #include <TSystem.h>
0020
0021 #include <bitset>
0022 #include <iostream> // for operator<<, endl, basic_ost...
0023 #include <ranges>
0024 #include <set>
0025 #include <utility> // for pair
0026 #include <vector> // for vector
0027
0028
0029 InttGl1Check::InttGl1Check(const std::string &name)
0030 : SubsysReco(name)
0031 {
0032 }
0033
0034
0035 int InttGl1Check::Init(PHCompositeNode * )
0036 {
0037 return Fun4AllReturnCodes::EVENT_OK;
0038 }
0039
0040
0041 int InttGl1Check::process_event(PHCompositeNode *topNode)
0042 {
0043 InttRawHitContainer *inttcont = findNode::getClass<InttRawHitContainer>(topNode, m_EvtNodeName);
0044 Gl1Packet *gl1cont = findNode::getClass<Gl1Packet>(topNode, "GL1RAWHIT");
0045 if (!gl1cont)
0046 {
0047 std::cout << "could not find GL1RAWHIT node" << std::endl;
0048 return Fun4AllReturnCodes::ABORTEVENT;
0049 }
0050 if (!inttcont)
0051 {
0052 std::cout << "could not find node " << m_EvtNodeName << std::endl;
0053 return Fun4AllReturnCodes::ABORTEVENT;
0054 }
0055
0056 uint64_t gl1bco = (gl1cont->getBCO() & 0xFFFFFFFFFFU);
0057
0058 std::set<uint64_t> inttbcoset;
0059 std::set<int64_t> diffgl1;
0060
0061 for (unsigned int i = 0; i < inttcont->get_nhits(); i++)
0062 {
0063 InttRawHit *inh = inttcont->get_hit(i);
0064
0065 uint64_t fphxbco = inh->get_FPHX_BCO();
0066 uint64_t inttgl1 = inh->get_bco() + fphxbco;
0067 int64_t diffbck = inttgl1 - gl1bco;
0068 if (diffbck < 0)
0069 {
0070 continue;
0071 }
0072 diffgl1.insert(diffbck);
0073
0074
0075
0076
0077
0078
0079
0080
0081 diffcnt[diffbck]++;
0082
0083
0084
0085
0086
0087
0088 inttbcoset.insert(inh->get_bco());
0089 }
0090
0091
0092
0093
0094 std::set<uint64_t> diffs;
0095 for (const auto &iter : inttbcoset)
0096 {
0097 uint64_t refbco = iter;
0098 for (const auto &iter1 : inttbcoset)
0099 {
0100 if (iter1 <= refbco)
0101 {
0102 continue;
0103 }
0104 diffs.insert(iter1 - refbco);
0105 }
0106 }
0107
0108
0109
0110
0111
0112
0113
0114
0115 return Fun4AllReturnCodes::EVENT_OK;
0116 }
0117
0118 int InttGl1Check::End(PHCompositeNode * )
0119 {
0120 std::multimap<int, uint64_t> scoremap;
0121 for (auto &iter : diffcnt)
0122 {
0123 std::cout << "diff " << iter.first << " count " << iter.second << std::endl;
0124 scoremap.insert(std::make_pair(iter.second, iter.first));
0125 }
0126 int i = 0;
0127 for (auto &iter : std::ranges::reverse_view(scoremap))
0128 {
0129 std::cout << "high score " << iter.first << " for diff " << iter.second
0130 << std::endl;
0131 i++;
0132 if (i > 3)
0133 {
0134 break;
0135 }
0136 }
0137 return Fun4AllReturnCodes::EVENT_OK;
0138 }