Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:21

0001 #include "PHG4HitReadBack.h"
0002 
0003 #include "PHG4Hit.h"
0004 #include "PHG4HitContainer.h"
0005 
0006 #include <fun4all/Fun4AllReturnCodes.h>
0007 
0008 #include <phool/getClass.h>
0009 
0010 #include <iostream>
0011 #include <map>      // for _Rb_tree_const_iterator
0012 #include <utility>  // for pair
0013 
0014 class PHCompositeNode;
0015 
0016 using namespace std;
0017 
0018 PHG4HitReadBack::PHG4HitReadBack(const string &name)
0019   : SubsysReco(name)
0020 {
0021   return;
0022 }
0023 
0024 int PHG4HitReadBack::InitRun(PHCompositeNode * /*topNode*/)
0025 {
0026   return 0;
0027 }
0028 
0029 int PHG4HitReadBack::process_event(PHCompositeNode *topNode)
0030 {
0031   PHG4HitContainer *phc = findNode::getClass<PHG4HitContainer>(topNode, "PHG4Hit");
0032   if (!phc)
0033   {
0034     cout << "No PHG4Hit found" << endl;
0035     return Fun4AllReturnCodes::ABORTEVENT;
0036   }
0037   phc->identify();
0038   std::pair<PHG4HitContainer::ConstIterator, PHG4HitContainer::ConstIterator> hititer = phc->getHits(1);
0039   PHG4HitContainer::ConstIterator begin, end, it;
0040   begin = hititer.first;
0041   end = hititer.second;
0042   for (it = begin; it != end; ++it)
0043   {
0044     cout << "key: 0x" << hex << it->first << dec << endl;
0045     cout << "x: " << it->second->get_x(0) << endl;
0046   }
0047   cout << "detid: 2" << endl;
0048   hititer = phc->getHits(2);
0049   begin = hititer.first;
0050   end = hititer.second;
0051   for (it = begin; it != end; ++it)
0052   {
0053     cout << "key: 0x" << hex << it->first << dec << endl;
0054     cout << "x: " << it->second->get_x(0) << endl;
0055   }
0056   cout << "detid: 3" << endl;
0057   hititer = phc->getHits(3);
0058   begin = hititer.first;
0059   end = hititer.second;
0060   for (it = begin; it != end; ++it)
0061   {
0062     cout << "key: 0x" << hex << it->first << dec << endl;
0063     cout << "x: " << it->second->get_x(0) << endl;
0064   }
0065   //   phc = findNode::getClass<PHG4HitContainer>(topNode,"PHG4Hit2");
0066   //   if (!phc)
0067   //     {
0068   //       cout << "No PHG4Hit found" << endl;
0069   //       return ABORTEVENT;
0070   //     }
0071   //   phc->identify();
0072   return Fun4AllReturnCodes::EVENT_OK;
0073 }