Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TempInfoUnpackPRDF.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TempInfoUnpackPRDF.cc
1 #include "TempInfoUnpackPRDF.h"
2 
3 #include "PROTOTYPE4_FEM.h"
4 #include "RawTower_Temperature.h"
5 
6 #include <calobase/RawTower.h> // for RawTower
7 #include <calobase/RawTowerContainer.h>
8 #include <calobase/RawTowerDefs.h> // for CEMC, HCALIN, HCALOUT
9 
10 #include <fun4all/Fun4AllBase.h> // for Fun4AllBase::VERBOSITY_SOME
12 #include <fun4all/SubsysReco.h> // for SubsysReco
13 
14 #include <phool/PHCompositeNode.h>
15 #include <phool/PHIODataNode.h> // for PHIODataNode
16 #include <phool/PHNodeIterator.h> // for PHNodeIterator
17 #include <phool/PHObject.h> // for PHObject
18 #include <phool/getClass.h>
19 
20 #include <Event/Event.h>
21 #include <Event/EventTypes.h>
22 #include <Event/packet.h>
23 
24 #include <iostream>
25 
26 using namespace std;
27 
28 //____________________________________
30  : SubsysReco("TempInfoUnpackPRDF")
31  , hcalin_temperature(nullptr)
32  , hcalout_temperature(nullptr)
33  , emcal_temperature(nullptr)
34 {
35 }
36 
37 //_____________________________________
39 {
40  CreateNodeTree(topNode);
42 }
43 
44 //____________________________________
46 {
47  Event *event = findNode::getClass<Event>(topNode, "PRDF");
48  if (!event)
49  {
50  if (Verbosity() >= VERBOSITY_SOME)
51  cout << "TempInfoUnpackPRDF::Process_Event - Event not found" << endl;
53  }
54 
55  Packet *p_hcalin;
56  Packet *p_hcalout;
57  Packet *p_emcal;
58 
59  // if (Verbosity() >= VERBOSITY_SOME)
60  // {
61  // cout << "TempInfoUnpackPRDF::process_event - ";
62  // event->identify();
63  // }
64 
65  if (event->getEvtType() == BEGRUNEVENT)
66  {
67  p_hcalin = event->getPacket(974);
68  p_hcalout = event->getPacket(975);
69  p_emcal = event->getPacket(982);
70  }
71  else
72  {
73  p_hcalin = event->getPacket(1074);
74  p_hcalout = event->getPacket(1075);
75  p_emcal = event->getPacket(1082);
76  }
77 
78  time_t etime = event->getTime();
79  int evtnr = event->getEvtSequence();
80 
81  if (Verbosity() >= VERBOSITY_SOME && (p_hcalin || p_hcalout || p_emcal))
82  {
83  cout << "TempInfoUnpackPRDF::found temperature packet in Event - ";
84  event->identify();
85  }
86 
87  if (p_hcalin)
88  {
89  addPacketInfo(p_hcalin, topNode, etime, evtnr);
90  if (Verbosity() > VERBOSITY_SOME)
91  p_hcalin->dump();
92  delete p_hcalin;
93  }
94 
95  if (p_hcalout)
96  {
97  addPacketInfo(p_hcalout, topNode, etime, evtnr);
98  if (Verbosity() > VERBOSITY_SOME)
99  p_hcalout->dump();
100  delete p_hcalout;
101  }
102 
103  if (p_emcal)
104  {
105  addPacketInfo(p_emcal, topNode, etime, evtnr);
106  if (Verbosity() > VERBOSITY_SOME)
107  p_emcal->dump();
108  delete p_emcal;
109  }
110 
112 }
113 
114 //____________________________________
116  const time_t etime, const int evtnr)
117 {
118  int packetid = p->getIdentifier();
119 
121 
122  if (packetid == 974 || packetid == 1074) // Inner Hcal
123  {
124  for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_IHCAL_ROWS; ibinz++)
125  {
126  for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_IHCAL_COLUMNS;
127  ibinphi++)
128  {
129  tower = dynamic_cast<RawTower_Temperature *>(
130  hcalin_temperature->getTower(ibinz, ibinphi));
131  if (!tower)
132  {
133  tower = new RawTower_Temperature();
134  hcalin_temperature->AddTower(ibinz, ibinphi, tower);
135  }
136  tower->add_entry(
137  evtnr, etime,
138  p->iValue(ibinz * PROTOTYPE4_FEM::NCH_IHCAL_COLUMNS + ibinphi) /
139  1000.);
140  }
141  }
142  }
143 
144  else if (packetid == 975 || packetid == 1075) // outer Hcal
145  {
146  for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_OHCAL_ROWS; ibinz++)
147  {
148  for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_OHCAL_COLUMNS;
149  ibinphi++)
150  {
151  tower = dynamic_cast<RawTower_Temperature *>(
152  hcalout_temperature->getTower(ibinz, ibinphi));
153  if (!tower)
154  {
155  tower = new RawTower_Temperature();
156  hcalout_temperature->AddTower(ibinz, ibinphi, tower);
157  }
158  tower->add_entry(
159  evtnr, etime,
160  p->iValue(ibinz * PROTOTYPE4_FEM::NCH_OHCAL_COLUMNS + ibinphi) /
161  1000.);
162  }
163  }
164  }
165 
166  else if (packetid == 982 || packetid == 1082) // emcal
167  {
168  for (int ibinz = 0; ibinz < PROTOTYPE4_FEM::NCH_EMCAL_ROWS; ibinz++)
169  {
170  for (int ibinphi = 0; ibinphi < PROTOTYPE4_FEM::NCH_EMCAL_COLUMNS;
171  ibinphi++)
172  {
173  tower = dynamic_cast<RawTower_Temperature *>(
174  emcal_temperature->getTower(ibinz, ibinphi));
175  if (!tower)
176  {
177  tower = new RawTower_Temperature();
178  emcal_temperature->AddTower(ibinz, ibinphi, tower);
179  }
180  // this takes care of the newly found "reverse" mapping. (0,0) is module
181  // 7, (0,7) is module 0, and the 63 - (...) takes care of the reversed
182  // vector.
183  tower->add_entry(
184  evtnr, etime,
185  p->iValue(63 - (ibinz * PROTOTYPE4_FEM::NCH_EMCAL_COLUMNS +
186  (7 - ibinphi)) /
187  1000.));
188  }
189  }
190  }
191  return 0;
192 }
193 
194 //_______________________________________
196 {
197  PHNodeIterator nodeItr(topNode);
198  // DST node
199  PHCompositeNode *run_node = static_cast<PHCompositeNode *>(
200  nodeItr.findFirst("PHCompositeNode", "RUN"));
201  if (!run_node)
202  {
203  run_node = new PHCompositeNode("RUN");
204  topNode->addNode(run_node);
205  cout << "PHComposite node created: RUN" << endl;
206  }
207 
208  // HCAL Towers
211  hcalin_temperature, "TOWER_TEMPERATURE_HCALIN", "PHObject");
212  run_node->addNode(tower_node);
213 
215  tower_node = new PHIODataNode<PHObject>(
216  hcalout_temperature, "TOWER_TEMPERATURE_HCALOUT", "PHObject");
217  run_node->addNode(tower_node);
218 
220  tower_node = new PHIODataNode<PHObject>(
221  emcal_temperature, "TOWER_TEMPERATURE_EMCAL", "PHObject");
222  run_node->addNode(tower_node);
223 }