Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:06

0001 #include "BcoRangeCheck.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 #include <ffarawobjects/MicromegasRawHit.h>
0011 #include <ffarawobjects/MicromegasRawHitContainer.h>
0012 #include <ffarawobjects/MvtxRawHit.h>
0013 #include <ffarawobjects/MvtxRawHitContainer.h>
0014 #include <ffarawobjects/TpcRawHit.h>
0015 #include <ffarawobjects/TpcRawHitContainer.h>
0016 
0017 #include <phool/PHCompositeNode.h>
0018 #include <phool/PHDataNode.h>
0019 #include <phool/PHNode.h>          // for PHNode
0020 #include <phool/PHNodeIterator.h>  // for PHNodeIterator
0021 #include <phool/getClass.h>
0022 
0023 #include <Event/packet.h>
0024 
0025 #include <TSystem.h>
0026 
0027 #include <bitset>
0028 #include <iostream>  // for operator<<, endl, basic_ost...
0029 #include <ranges>
0030 #include <set>
0031 #include <utility>  // for pair
0032 #include <vector>   // for vector
0033 
0034 //____________________________________________________________________________..
0035 BcoRangeCheck::BcoRangeCheck(const std::string &name)
0036   : SubsysReco(name)
0037 {
0038 }
0039 
0040 //____________________________________________________________________________..
0041 int BcoRangeCheck::Init(PHCompositeNode * /*topNode*/)
0042 {
0043   return Fun4AllReturnCodes::EVENT_OK;
0044 }
0045 
0046 //____________________________________________________________________________..
0047 int BcoRangeCheck::process_event(PHCompositeNode *topNode)
0048 {
0049   Gl1Packet *gl1cont = findNode::getClass<Gl1Packet>(topNode, "GL1RAWHIT");
0050   if (!gl1cont)
0051   {
0052     std::cout << "could not find GL1RAWHIT node" << std::endl;
0053     return Fun4AllReturnCodes::ABORTEVENT;
0054   }
0055   InttRawHitContainer *inttcont = findNode::getClass<InttRawHitContainer>(topNode, "INTTRAWHIT");
0056   if (!inttcont)
0057   {
0058     std::cout << "could not find INTTRAWHIT node " << std::endl;
0059     return Fun4AllReturnCodes::ABORTEVENT;
0060   }
0061   MvtxRawHitContainer *mvtxcont = findNode::getClass<MvtxRawHitContainer>(topNode, "MVTXRAWHIT");
0062   if (!mvtxcont)
0063   {
0064     std::cout << "could not find MVTXRAWHIT node " << std::endl;
0065     return Fun4AllReturnCodes::ABORTEVENT;
0066   }
0067   TpcRawHitContainer *tpccont = findNode::getClass<TpcRawHitContainer>(topNode, "TPCRAWHIT");
0068   if (!tpccont)
0069   {
0070     std::cout << "could not find TPCRAWHIT node " << std::endl;
0071     return Fun4AllReturnCodes::ABORTEVENT;
0072   }
0073   MicromegasRawHitContainer *micromegascont = findNode::getClass<MicromegasRawHitContainer>(topNode, "MICROMEGASRAWHIT");
0074   if (!micromegascont)
0075   {
0076     std::cout << "could not find TPOTRAWHIT node " << std::endl;
0077     return Fun4AllReturnCodes::ABORTEVENT;
0078   }
0079 
0080   uint64_t gl1bco = (gl1cont->getBCO() & 0xFFFFFFFFFFU);  // 40 bit intt bco
0081                                                           //  inttcont->identify();
0082   std::set<uint64_t> inttbcoset;
0083   for (unsigned int i = 0; i < inttcont->get_nhits(); i++)
0084   {
0085     InttRawHit *inh = inttcont->get_hit(i);
0086     inttbcoset.insert(inh->get_bco());
0087   }
0088   std::set<uint64_t> mvtxbcoset;
0089   for (unsigned int i = 0; i < mvtxcont->get_nhits(); i++)
0090   {
0091     MvtxRawHit *inh = mvtxcont->get_hit(i);
0092     mvtxbcoset.insert(inh->get_bco());
0093   }
0094   std::set<uint64_t> tpcbcoset;
0095   for (unsigned int i = 0; i < tpccont->get_nhits(); i++)
0096   {
0097     TpcRawHit *inh = tpccont->get_hit(i);
0098     if (inh->get_bco() > 0)
0099     {
0100       tpcbcoset.insert(inh->get_bco());
0101     }
0102   }
0103   std::set<uint64_t> micromegasbcoset;
0104   for (unsigned int i = 0; i < micromegascont->get_nhits(); i++)
0105   {
0106     MicromegasRawHit *inh = micromegascont->get_hit(i);
0107     micromegasbcoset.insert(inh->get_bco());
0108   }
0109   if (!inttbcoset.empty())
0110   {
0111     std::cout << "inttrange: 0x" << std::hex << *inttbcoset.rbegin() << " to 0x" << *inttbcoset.begin()
0112               << std::dec << " diff: " << *inttbcoset.rbegin() - *inttbcoset.begin() << std::endl;
0113   }
0114   if (!mvtxbcoset.empty())
0115   {
0116     std::cout << "mvtxrange: 0x" << std::hex << *mvtxbcoset.rbegin() << " to 0x" << *mvtxbcoset.begin()
0117               << std::dec << " diff: " << *mvtxbcoset.rbegin() - *mvtxbcoset.begin() << std::endl;
0118   }
0119   if (!tpcbcoset.empty())
0120   {
0121     std::cout << "tpcrange: 0x" << std::hex << *tpcbcoset.rbegin() << " to 0x" << *tpcbcoset.begin()
0122               << std::dec << " diff: " << *tpcbcoset.rbegin() - *tpcbcoset.begin() << std::endl;
0123   }
0124   if (!micromegasbcoset.empty())
0125   {
0126     std::cout << "micromegasrange: 0x" << std::hex << *micromegasbcoset.rbegin() << " to 0x" << *micromegasbcoset.begin()
0127               << std::dec << " diff: " << *micromegasbcoset.rbegin() - *micromegasbcoset.begin() << std::endl;
0128   }
0129   std::cout << "Gl1: 0x" << std::hex << gl1bco << std::dec << std::endl;
0130   return Fun4AllReturnCodes::EVENT_OK;
0131 }
0132 
0133 int BcoRangeCheck::End(PHCompositeNode * /*topNode*/)
0134 {
0135   std::multimap<int, uint64_t> scoremap;
0136   for (auto &iter : diffcnt)
0137   {
0138     std::cout << "diff " << iter.first << " count " << iter.second << std::endl;
0139     scoremap.insert(std::make_pair(iter.second, iter.first));
0140   }
0141   int i = 0;
0142   for (auto &iter : std::ranges::reverse_view(scoremap))
0143   {
0144     std::cout << "high score " << iter.first << " for diff " << iter.second
0145               << std::endl;
0146     i++;
0147     if (i > 3)
0148     {
0149       break;
0150     }
0151   }
0152   return Fun4AllReturnCodes::EVENT_OK;
0153 }