Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:04

0001 #include "RunTowerInfo.h"
0002 
0003 #include <calobase/TowerInfoContainerv1.h>
0004 #include <calobase/TowerInfov1.h>
0005 
0006 #include <phool/getClass.h>
0007 #include <phool/PHCompositeNode.h>
0008 #include <phool/phool.h>
0009 
0010 /// Fun4All includes
0011 #include <fun4all/Fun4AllReturnCodes.h>
0012 
0013 /// C++ includes
0014 #include <cassert>
0015 #include <sstream>
0016 #include <string>
0017 
0018 using namespace std;
0019 
0020 /**
0021  * RunTowerInfo is a class developed to reconstruct jets containing a D-meson
0022  * The class can be adapted to tag jets using any kind of particle
0023  * Author: Antonio Silva (antonio.sphenix@gmail.com)
0024  */
0025 
0026 /**
0027  * Constructor of module
0028  */
0029 RunTowerInfo::RunTowerInfo(const std::string &name)
0030   : SubsysReco(name)
0031   , m_EMCalTowerContainer(0)
0032 {
0033   /// Initialize variables and trees so we don't accidentally access
0034   /// memory that was never allocated
0035 }
0036 
0037 /**
0038  * Destructor of module
0039  */
0040 RunTowerInfo::~RunTowerInfo()
0041 {
0042 
0043 }
0044 
0045 /**
0046  * Initialize the module and prepare looping over events
0047  */
0048 int RunTowerInfo::Init(PHCompositeNode * /*topNode*/)
0049 {
0050   if (Verbosity() > 5)
0051   {
0052     cout << "Beginning Init in RunTowerInfo" << endl;
0053   }
0054 
0055   return 0;
0056 }
0057 
0058 /**
0059  * Main workhorse function where each event is looped over and
0060  * data from each event is collected from the node tree for analysis
0061  */
0062 int RunTowerInfo::process_event(PHCompositeNode *topNode)
0063 {
0064   if (Verbosity() > 5)
0065   {
0066     cout << "Beginning process_event in AnaTutorial" << endl;
0067   }
0068 
0069   m_EMCalTowerContainer = findNode::getClass<TowerInfoContainerv1>(topNode, "TOWERS_CEMC");
0070 
0071   if(!m_EMCalTowerContainer)
0072   {
0073     return Fun4AllReturnCodes::DISCARDEVENT;
0074   }
0075 
0076   std::cout << "********************" << std::endl;
0077 
0078   TowerInfoContainerv1::Range tower_range = m_EMCalTowerContainer->getTowers();
0079   for (TowerInfoContainerv1::ConstIterator citer = tower_range.first; citer != tower_range.second; citer++)
0080   {
0081     //You can get the TowerInfo object from the map and use it to get time and amplitude
0082     TowerInfov1 *towerInfo = (TowerInfov1*)citer->second;
0083     std::cout << "Time: " << towerInfo->get_time() << std::endl;
0084     std::cout << "Energy (Amplitude): " << towerInfo->get_energy() << std::endl;
0085     //Or just directly get time and amplitude from the object in the map
0086     std::cout << "Time: " << citer->second->get_time() << std::endl;
0087     std::cout << "Energy (Amplitude): " << citer->second->get_energy() << std::endl;
0088     //The encripted key can be use to get the tower eta-phi bin form the TowerInfoContainer
0089     std::cout << "PhiBin: " << m_EMCalTowerContainer->getTowerPhiBin(citer->first) << std::endl;
0090     std::cout << "EtaBin: " << m_EMCalTowerContainer->getTowerEtaBin(citer->first) << std::endl;
0091   }
0092 
0093   return Fun4AllReturnCodes::EVENT_OK;
0094 }
0095 
0096 /**
0097  * End the module and finish any data collection. Clean up any remaining
0098  * loose ends
0099  */
0100 int RunTowerInfo::End(PHCompositeNode * /*topNode*/)
0101 {
0102   if (Verbosity() > 1)
0103   {
0104     cout << "Ending RunTowerInfo analysis package" << endl;
0105   }
0106 
0107 
0108   if (Verbosity() > 1)
0109   {
0110     cout << "Finished RunTowerInfo analysis package" << endl;
0111   }
0112 
0113   return 0;
0114 }