File indexing completed on 2025-08-05 08:12:22
0001 #include "TempInfoUnpackPRDF.h"
0002
0003 #include "PROTOTYPE4_FEM.h"
0004 #include "RawTower_Temperature.h"
0005
0006 #include <calobase/RawTower.h> // for RawTower
0007 #include <calobase/RawTowerContainer.h>
0008 #include <calobase/RawTowerDefs.h> // for CEMC, HCALIN, HCALOUT
0009
0010 #include <fun4all/Fun4AllBase.h> // for Fun4AllBase::VERBOSITY_SOME
0011 #include <fun4all/Fun4AllReturnCodes.h>
0012 #include <fun4all/SubsysReco.h> // for SubsysReco
0013
0014 #include <phool/PHCompositeNode.h>
0015 #include <phool/PHIODataNode.h> // for PHIODataNode
0016 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0017 #include <phool/PHObject.h> // for PHObject
0018 #include <phool/getClass.h>
0019
0020 #include <Event/Event.h>
0021 #include <Event/EventTypes.h>
0022 #include <Event/packet.h>
0023
0024 #include <iostream>
0025
0026 using namespace std;
0027
0028
0029 TempInfoUnpackPRDF::TempInfoUnpackPRDF()
0030 : SubsysReco("TempInfoUnpackPRDF")
0031 , hcalin_temperature(nullptr)
0032 , hcalout_temperature(nullptr)
0033 , emcal_temperature(nullptr)
0034 {
0035 }
0036
0037
0038 int TempInfoUnpackPRDF::InitRun(PHCompositeNode *topNode)
0039 {
0040 CreateNodeTree(topNode);
0041 return Fun4AllReturnCodes::EVENT_OK;
0042 }
0043
0044
0045 int TempInfoUnpackPRDF::process_event(PHCompositeNode *topNode)
0046 {
0047 Event *event = findNode::getClass<Event>(topNode, "PRDF");
0048 if (!event)
0049 {
0050 if (Verbosity() >= VERBOSITY_SOME)
0051 cout << "TempInfoUnpackPRDF::Process_Event - Event not found" << endl;
0052 return Fun4AllReturnCodes::DISCARDEVENT;
0053 }
0054
0055 Packet *p_hcalin;
0056 Packet *p_hcalout;
0057 Packet *p_emcal;
0058
0059
0060
0061
0062
0063
0064
0065 if (event->getEvtType() == BEGRUNEVENT)
0066 {
0067 p_hcalin = event->getPacket(974);
0068 p_hcalout = event->getPacket(975);
0069 p_emcal = event->getPacket(982);
0070 }
0071 else
0072 {
0073 p_hcalin = event->getPacket(1074);
0074 p_hcalout = event->getPacket(1075);
0075 p_emcal = event->getPacket(1082);
0076 }
0077
0078 time_t etime = event->getTime();
0079 int evtnr = event->getEvtSequence();
0080
0081 if (Verbosity() >= VERBOSITY_SOME && (p_hcalin || p_hcalout || p_emcal))
0082 {
0083 cout << "TempInfoUnpackPRDF::found temperature packet in Event - ";
0084 event->identify();
0085 }
0086
0087 if (p_hcalin)
0088 {
0089 addPacketInfo(p_hcalin, topNode, etime, evtnr);
0090 if (Verbosity() > VERBOSITY_SOME)
0091 p_hcalin->dump();
0092 delete p_hcalin;
0093 }
0094
0095 if (p_hcalout)
0096 {
0097 addPacketInfo(p_hcalout, topNode, etime, evtnr);
0098 if (Verbosity() > VERBOSITY_SOME)
0099 p_hcalout->dump();
0100 delete p_hcalout;
0101 }
0102
0103 if (p_emcal)
0104 {
0105 addPacketInfo(p_emcal, topNode, etime, evtnr);
0106 if (Verbosity() > VERBOSITY_SOME)
0107 p_emcal->dump();
0108 delete p_emcal;
0109 }
0110
0111 return Fun4AllReturnCodes::EVENT_OK;
0112 }
0113
0114
0115 int TempInfoUnpackPRDF::addPacketInfo(Packet *p, PHCompositeNode *topNode,
0116 const time_t etime, const int evtnr)
0117 {
0118 int packetid = p->getIdentifier();
0119
0120 RawTower_Temperature *tower;
0121
0122 if (packetid == 974 || packetid == 1074)
0123 {
0124 for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_IHCAL_ROWS; ibinz++)
0125 {
0126 for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_IHCAL_COLUMNS;
0127 ibinphi++)
0128 {
0129 tower = dynamic_cast<RawTower_Temperature *>(
0130 hcalin_temperature->getTower(ibinz, ibinphi));
0131 if (!tower)
0132 {
0133 tower = new RawTower_Temperature();
0134 hcalin_temperature->AddTower(ibinz, ibinphi, tower);
0135 }
0136 tower->add_entry(
0137 evtnr, etime,
0138 p->iValue(ibinz * PROTOTYPE4_FEM::NCH_IHCAL_COLUMNS + ibinphi) /
0139 1000.);
0140 }
0141 }
0142 }
0143
0144 else if (packetid == 975 || packetid == 1075)
0145 {
0146 for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_OHCAL_ROWS; ibinz++)
0147 {
0148 for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_OHCAL_COLUMNS;
0149 ibinphi++)
0150 {
0151 tower = dynamic_cast<RawTower_Temperature *>(
0152 hcalout_temperature->getTower(ibinz, ibinphi));
0153 if (!tower)
0154 {
0155 tower = new RawTower_Temperature();
0156 hcalout_temperature->AddTower(ibinz, ibinphi, tower);
0157 }
0158 tower->add_entry(
0159 evtnr, etime,
0160 p->iValue(ibinz * PROTOTYPE4_FEM::NCH_OHCAL_COLUMNS + ibinphi) /
0161 1000.);
0162 }
0163 }
0164 }
0165
0166 else if (packetid == 982 || packetid == 1082)
0167 {
0168 for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_EMCAL_ROWS; ibinz++)
0169 {
0170 for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_EMCAL_COLUMNS;
0171 ibinphi++)
0172 {
0173 tower = dynamic_cast<RawTower_Temperature *>(
0174 emcal_temperature->getTower(ibinz, ibinphi));
0175 if (!tower)
0176 {
0177 tower = new RawTower_Temperature();
0178 emcal_temperature->AddTower(ibinz, ibinphi, tower);
0179 }
0180
0181
0182
0183 tower->add_entry(
0184 evtnr, etime,
0185 p->iValue(63 - (ibinz * PROTOTYPE4_FEM::NCH_EMCAL_COLUMNS +
0186 (7 - ibinphi)) /
0187 1000.));
0188 }
0189 }
0190 }
0191 return 0;
0192 }
0193
0194
0195 void TempInfoUnpackPRDF::CreateNodeTree(PHCompositeNode *topNode)
0196 {
0197 PHNodeIterator nodeItr(topNode);
0198
0199 PHCompositeNode *run_node = static_cast<PHCompositeNode *>(
0200 nodeItr.findFirst("PHCompositeNode", "RUN"));
0201 if (!run_node)
0202 {
0203 run_node = new PHCompositeNode("RUN");
0204 topNode->addNode(run_node);
0205 cout << "PHComposite node created: RUN" << endl;
0206 }
0207
0208
0209 hcalin_temperature = new RawTowerContainer(RawTowerDefs::HCALIN);
0210 PHIODataNode<PHObject> *tower_node = new PHIODataNode<PHObject>(
0211 hcalin_temperature, "TOWER_TEMPERATURE_HCALIN", "PHObject");
0212 run_node->addNode(tower_node);
0213
0214 hcalout_temperature = new RawTowerContainer(RawTowerDefs::HCALOUT);
0215 tower_node = new PHIODataNode<PHObject>(
0216 hcalout_temperature, "TOWER_TEMPERATURE_HCALOUT", "PHObject");
0217 run_node->addNode(tower_node);
0218
0219 emcal_temperature = new RawTowerContainer(RawTowerDefs::CEMC);
0220 tower_node = new PHIODataNode<PHObject>(
0221 emcal_temperature, "TOWER_TEMPERATURE_EMCAL", "PHObject");
0222 run_node->addNode(tower_node);
0223 }