Back to home page

sPhenix code displayed by LXR

 
 

    


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 * /*topNode*/)
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);  // 40 bit intt bco
0057                                                           //  inttcont->identify();
0058   std::set<uint64_t> inttbcoset;
0059   std::set<int64_t> diffgl1;
0060   //  std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> clocktuplemap;
0061   for (unsigned int i = 0; i < inttcont->get_nhits(); i++)
0062   {
0063     InttRawHit *inh = inttcont->get_hit(i);
0064     //      int64_t diffbck = inh->get_bco() - gl1bco;
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     //      int bco_diff = (inh->get_FPHX_BCO() - (inh->get_bco() & 0x7fU) + 128) % 128;
0074     // std::cout << "gl1 bco: 0x" << std::hex << gl1bco
0075     //      << ", intt: 0x" << inh->get_bco()
0076     //      << ", fphx: 0x" << fphxbco
0077     //      << ", intt corr: 0x" << inttgl1
0078     //      << ", diff: 0x" << diffbck
0079     //      << ", bcodiff: 0x" << bco_diff
0080     //      << std::dec << std::endl;
0081     diffcnt[diffbck]++;
0082     // std::cout << "b_intt: " << b_intt << std::endl;
0083     // std::cout << "b_cntt: " << b_cntt << std::endl;
0084     // std::cout << "b_fphx: " << b_fphx<< std::endl;
0085     // std::cout << "b_sums: " << b_inttgl1 << std::endl;
0086     //      clocktuplemap[gl1bco] = std::make_tuple(inh->get_bco(), chopbco, fphxbco,
0087     //      std::cout << "diffgl1: 0x" << std::hex << diffbck << std::dec << std::endl;
0088     inttbcoset.insert(inh->get_bco());
0089   }
0090   // for (auto &iter : diffgl1)
0091   // {
0092   //   std::cout << "diff with gl1: 0x" << std::hex << iter << std::dec << std::endl;
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   // for (auto &iter : diffs)
0108   // {
0109   //   std::cout << "diff: 0x" << std::hex <<  iter << std::dec << std::endl;
0110   // }
0111   // for (auto &iter : diffcnt)
0112   // {
0113   //   std::cout << "diff " << iter.first << " count " << iter.second << std::endl;
0114   // }
0115   return Fun4AllReturnCodes::EVENT_OK;
0116 }
0117 
0118 int InttGl1Check::End(PHCompositeNode * /*topNode*/)
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 }