21 #include <TLorentzVector.h>
25 #include <calobase/RawCluster.h>
26 #include <calobase/RawClusterContainer.h>
27 #include <calobase/RawClusterUtility.h>
28 #include <calobase/RawTowerGeomContainer.h>
31 #include <calobase/TowerInfoContainer.h>
32 #include <calobase/TowerInfo.h>
33 #include <calobase/TowerInfoDefs.h>
36 #include <CLHEP/Geometry/Point3D.h>
42 const int eventNumber,
44 const float tow_cemc_min,
45 const float tow_hcalin_min,
46 const float tow_hcalout_min):
53 ,eventNumber(eventNumber)
55 ,tow_cemc_min(tow_cemc_min)
56 ,tow_hcalin_min(tow_hcalin_min)
57 ,tow_hcalout_min(tow_hcalout_min) {
59 std::cout <<
"caloTreeGen::caloTreeGen(const std::string &name) Calling ctor" << std::endl;
64 std::cout <<
"caloTreeGen::~caloTreeGen() Calling dtor" << std::endl;
74 T =
new TTree(
"T",
"T");
96 se ->
Print(
"NODETREE");
100 \"runid\": " <<
runid <<
",\n \
103 \"type\": \"Collision\",\n \
110 \"INNERTRACKER\": {\n \
111 \"type\": \"3D\",\n \
114 \"color\": 16777215\n \
118 \"type\": \"PROJECTIVE\",\n \
124 \"color\": 16766464,\n \
125 \"transparent\": 0.6,\n \
126 \"scaleminmax\": false\n \
130 \"type\": \"PROJECTIVE\",\n \
132 \"rmin\": 117.27,\n \
136 \"color\": 4290445312,\n \
137 \"transparent\": 0.6,\n \
138 \"scaleminmax\": false\n \
142 \"type\": \"PROJECTIVE\",\n \
145 \"rmax\": 274.317,\n \
148 \"color\": 24773,\n \
149 \"transparent\": 0.6,\n \
150 \"scaleminmax\": false\n \
157 std::cout <<
"caloTreeGen::Init(PHCompositeNode *topNode) Initializing" << std::endl;
163 std::cout <<
"caloTreeGen::InitRun(PHCompositeNode *topNode) Initializing for Run " <<
runid << std::endl;
175 else std::cout <<
"Processing Event: " <<
iEvent << std::endl;
178 TowerInfoContainer *emcTowerContainer = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_CEMC");
181 if(!emcTowerContainer) {
182 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERS_CEMC" << std::endl;
188 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
192 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERGEOM_CEMC" << std::endl;
199 unsigned int tower_range = emcTowerContainer->
size();
202 bool first_entry =
true;
204 for(
unsigned int iter = 0; iter < tower_range; iter++) {
205 unsigned int towerkey = emcTowerContainer->
encode_key(iter);
211 double energy = emcTowerContainer -> get_tower_at_channel(iter) -> get_energy()/calib;
213 double time = emcTowerContainer -> get_tower_at_channel(iter) -> get_time();
215 double eta = towergeom -> get_etacenter(ieta);
216 double phi = towergeom -> get_phicenter(iphi);
225 eventOutput <<
"\"CEMC\": [{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
228 else eventOutput <<
",{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
230 if(tower_range == 0)
eventOutput <<
"\"CEMC\": [{}],\n";
236 TowerInfoContainer *ohcTowerContainer = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_HCALOUT");
237 if(!ohcTowerContainer) {
238 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERINFO_CALIB_OHCAL" << std::endl;
243 towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
246 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERGEOM_HCALOUT" << std::endl;
250 tower_range = ohcTowerContainer->
size();
252 for(
unsigned int iter = 0; iter < tower_range; iter++) {
253 unsigned int towerkey = ohcTowerContainer->
encode_key(iter);
261 double eta = towergeom -> get_etacenter(ieta);
262 double phi = towergeom -> get_phicenter(iphi);
264 double energy = ohcTowerContainer -> get_tower_at_channel(iter) -> get_energy();
270 eventOutput <<
"\"HCALOUT\": [{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
273 else eventOutput <<
",{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
276 if(tower_range == 0)
eventOutput <<
"\"HCALOUT\": [{}],\n";
281 TowerInfoContainer *ihcTowerContainer = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_HCALIN");
282 if(!ihcTowerContainer) {
283 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERINFO_CALIB_HCALIN" << std::endl;
288 towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
291 std::cout <<
PHWHERE <<
"caloTreeGen::process_event Could not find node TOWERGEOM_HCALIN" << std::endl;
295 tower_range = ihcTowerContainer->
size();
297 for(
unsigned int iter = 0; iter < tower_range; iter++) {
298 unsigned int towerkey = ihcTowerContainer->
encode_key(iter);
306 double eta = towergeom -> get_etacenter(ieta);
307 double phi = towergeom -> get_phicenter(iphi);
309 double energy = ihcTowerContainer -> get_tower_at_channel(iter) -> get_energy();
315 eventOutput <<
"\"HCALIN\": [{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
318 else eventOutput <<
",{ \"eta\": " << eta <<
", \"phi\": " << phi <<
" , \"e\": " << energy <<
"}\n";
321 if(tower_range == 0)
eventOutput <<
"\"HCALIN\": [{}]\n";
353 std::cout <<
"caloTreeGen::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
360 std::cout <<
"caloTreeGen::End(PHCompositeNode *topNode) This is the End..." << std::endl;
369 \"INNERTRACKER\": []\n \
379 std::cout <<
"caloTreeGen::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
386 std::cout <<
"caloTreeGen::Print(const std::string &what) const Printing info for " << what << std::endl;
392 unsigned int etabin = key >> 16U;
393 unsigned int phibin = key - (etabin << 16U);
401 unsigned int etabin = key >> 16U;
411 for(toweriter = towers.first; toweriter != towers.second; toweriter++)
413 float towE = toweriter -> second;
415 if( towE > maxEnergy) maxEnergy = towE;
425 std::vector<int> towerIDsEta;
426 for(toweriter = towers.first; toweriter != towers.second; toweriter++) towerIDsEta.push_back(
RawTowerDefs::decode_index1(toweriter -> first));
436 std::vector<int> towerIDsPhi;
437 for(toweriter = towers.first; toweriter != towers.second; toweriter++) towerIDsPhi.push_back(
RawTowerDefs::decode_index2(toweriter -> first));
446 std::vector<float> towerE;
447 for(toweriter = towers.first; toweriter != towers.second; toweriter++) towerE.push_back(toweriter -> second);