Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:13

0001 #include "TpcCheck.h"
0002 
0003 #include <fun4all/Fun4AllInputManager.h>
0004 #include <fun4all/Fun4AllReturnCodes.h>
0005 #include <fun4all/SubsysReco.h>  // for SubsysReco
0006 
0007 #include <ffarawobjects/TpcRawHit.h>
0008 #include <ffarawobjects/TpcRawHitContainer.h>
0009 
0010 #include <phool/PHCompositeNode.h>
0011 #include <phool/PHDataNode.h>
0012 #include <phool/PHNode.h>          // for PHNode
0013 #include <phool/PHNodeIterator.h>  // for PHNodeIterator
0014 #include <phool/getClass.h>
0015 
0016 #include <Event/packet.h>
0017 
0018 #include <TSystem.h>
0019 
0020 #include <iostream>  // for operator<<, endl, basic_ost...
0021 #include <set>
0022 #include <utility>  // for pair
0023 #include <vector>   // for vector
0024 
0025 //____________________________________________________________________________..
0026 TpcCheck::TpcCheck(const std::string &name)
0027   : SubsysReco(name)
0028 {
0029 }
0030 
0031 //____________________________________________________________________________..
0032 int TpcCheck::Init(PHCompositeNode * /*topNode*/)
0033 {
0034   return Fun4AllReturnCodes::EVENT_OK;
0035 }
0036 
0037 //____________________________________________________________________________..
0038 int TpcCheck::process_event(PHCompositeNode *topNode)
0039 {
0040   TpcRawHitContainer *tpccont = findNode::getClass<TpcRawHitContainer>(topNode, m_EvtNodeName);
0041   if (!tpccont)
0042   {
0043     std::cout << "could not find node " << m_EvtNodeName << std::endl;
0044   }
0045   else
0046   {
0047     tpccont->identify();
0048     std::set<uint64_t> refbco;
0049     bool ifirst = true;
0050     for (unsigned int i = 0; i < tpccont->get_nhits(); i++)
0051     {
0052       TpcRawHit *inh = tpccont->get_hit(i);
0053       if (ifirst)
0054       {
0055         refbco.insert(inh->get_bco());
0056         if (Verbosity() > 0)
0057         {
0058           std::cout << "current bco: 0x" << std::hex << *refbco.begin()
0059                     << std::dec << std::endl;
0060         }
0061         if (bclk_seen.find(*refbco.begin()) != bclk_seen.end())
0062         {
0063           std::cout << "bco 0x" << std::hex << *refbco.begin() << std::dec
0064                     << " seen before" << std::endl;
0065         }
0066         bclk_seen.insert(*refbco.begin());
0067         ifirst = false;
0068       }
0069       else
0070       {
0071         if (refbco.find(inh->get_bco()) == refbco.end())
0072         {
0073           if (*refbco.begin() <= inh->get_bco() + bcorange)
0074           {
0075             refbco.insert(inh->get_bco());
0076           }
0077           else
0078           {
0079             std::cout << "scream, refbco: 0x" << std::hex << *refbco.begin()
0080                       << " current bco: 0x" << inh->get_bco()
0081                       << std::dec
0082                       << ", diff: " << inh->get_bco() - *refbco.begin()
0083                       << ", allowed diff: " << bcorange
0084                       << std::endl;
0085           }
0086         }
0087       }
0088     }
0089   }
0090   return Fun4AllReturnCodes::EVENT_OK;
0091 }