8 #include <HepMC/GenVertex.h>
9 #include <HepMC/IteratorRange.h>
10 #include <HepMC/SimpleVector.h>
18 #include <g4jets/FastJetAlgo.h>
20 #include <g4jets/JetMap.h>
21 #include <g4jets/Jetv1.h>
23 #include <g4vertex/GlobalVertex.h>
24 #include <g4vertex/GlobalVertexMap.h>
26 #include <calobase/RawTowerContainer.h>
27 #include <calobase/RawTower.h>
28 #include <calobase/RawTowerGeomContainer.h>
29 #include <calobase/RawTowerGeom.h>
30 #include <calobase/TowerInfoContainer.h>
31 #include <calobase/TowerInfo.h>
43 #include <fastjet/ClusterSequence.hh>
44 #include <fastjet/JetDefinition.hh>
45 #include <fastjet/PseudoJet.hh>
56 #include <TLorentzVector.h>
69 double_t dPhi_temp = phi1 - phi2;
80 :
SubsysReco(
"MyJetAnalysis_" + recojetname +
"_" + truthjetname)
81 , m_recoJetName(recojetname)
83 , m_outputFileName(outputfilename)
84 , m_etaRange(-1.1, 1.1)
86 , m_trackJetMatchingRadius(.7)
87 , m_hInclusiveE(nullptr)
88 , m_hInclusiveEta(nullptr)
89 , m_hInclusivePhi(nullptr)
92 , _caloevalstackHCALIN(nullptr)
93 , _caloevalstackHCALOUT(nullptr)
94 , _caloevalstackCEMC(nullptr)
115 , m_nMatchedTrack(-1)
118 m_trackdR.fill(numeric_limits<float>::signaling_NaN());
119 m_trackpT.fill(numeric_limits<float>::signaling_NaN());
120 m_trackPID.fill(numeric_limits<float>::signaling_NaN());
140 TString(
m_recoJetName) +
" inclusive jet E;Total jet energy (GeV)", 100, 0, 100);
145 TString(
m_recoJetName) +
" inclusive jet #eta;#eta;Jet energy density", 50, -1, 1);
149 TString(
m_recoJetName) +
" inclusive jet #phi;#phi;Jet energy density", 50, -M_PI, M_PI);
172 cout <<
"MyJetAnalysis::process_event() entered" << endl;
175 if( (
m_event % 10) == 0 ) cout <<
"Event number = "<<
m_event << endl;
178 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
186 RawTowerContainer *ihcal_towers_sub = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN_SUB1");
187 RawTowerContainer *ihcal_towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN");
188 RawTowerContainer *cemc_towers_sub = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC_RETOWER_SUB1");
189 RawTowerContainer *cemc_towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
190 RawTowerContainer *ohcal_towers_sub = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT_SUB1");
191 RawTowerContainer *ohcal_towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT");
200 RawTowerGeomContainer *geomIH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
201 RawTowerGeomContainer *geomOH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
202 RawTowerGeomContainer *geomEC = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
204 if (!geomIH || !geomOH ){
205 cout <<
"Cannot find Tower Geom Nodes" << endl;
211 cout <<
"Error cant find G4 Truth Info" << endl;
215 CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode,
"CentralityInfo");
217 cout <<
"Error can't find CentralityInfo" << endl;
221 float cent_mbd = cent_node->
get_centile(CentralityInfo::PROP::mbd_NS);
222 m_cent.push_back(cent_mbd);
249 if (vtx) vtxz = vtx->
get_z();
251 std::vector<fastjet::PseudoJet> pseudojet_reco;
252 std::vector<fastjet::PseudoJet> pseudojet_reco_truth;
259 for (ICB_rtiter = ICB_begin_end.first; ICB_rtiter != ICB_begin_end.second; ++ICB_rtiter){
260 float Tower_Embedded = 0;
261 RawTower *towerB = ICB_rtiter->second;
272 else Tower_Embedded = -10;
279 for (IC_rtiter = IC_begin_end.first; IC_rtiter != IC_begin_end.second; ++IC_rtiter){
284 float HCALIN_Embedded = -2;
296 double z = z0 - vtxz;
298 double eta = asinh(z/r);
300 double px = pt*cos(phi);
301 double py = pt*sin(phi);
302 double pz = pt*sinh(eta);
307 fastjet::PseudoJet pseudojet(px, py, pz, tower->
get_energy());
308 pseudojet.set_user_index(HCALIN_Embedded);
309 pseudojet_reco.push_back(pseudojet);
310 if (HCALIN_Embedded == -10 || HCALIN_Embedded == 1)
continue;
311 pseudojet_reco_truth.push_back(pseudojet);
321 for (EC_rtiter = EC_begin_end.first; EC_rtiter != EC_begin_end.second; ++EC_rtiter){
326 int this_ECetabin = geomIH->get_etabin(tower_geom->
get_eta());
327 int this_ECphibin = geomIH->get_phibin(tower_geom->
get_phi());
328 float HCEMC_Embedded = -2;
329 float Tower_Energy = 0;
330 for (ECB_rtiter = ECB_begin_end.first; ECB_rtiter != ECB_begin_end.second; ++ECB_rtiter){
331 RawTower *towerB = ECB_rtiter->second;
333 int this_ECBetabin = geomIH->get_etabin(towerB_geom->
get_eta());
334 int this_ECBphibin = geomIH->get_phibin(towerB_geom->
get_phi());
335 if (this_ECBetabin != this_ECetabin && this_ECBphibin != this_ECphibin)
continue;
336 if(towerB->
get_energy() < Tower_Energy)
continue;
347 HCEMC_Embedded = -11;
356 double z = z0 - vtxz;
358 double eta = asinh(z/r);
360 double px = pt*cos(phi);
361 double py = pt*sin(phi);
362 double pz = pt*sinh(eta);
367 fastjet::PseudoJet pseudojet(px, py, pz, tower->
get_energy());
368 pseudojet.set_user_index(HCEMC_Embedded);
369 pseudojet_reco.push_back(pseudojet);
370 if(HCEMC_Embedded == -11 || HCEMC_Embedded == 3)
continue;
371 pseudojet_reco_truth.push_back(pseudojet);
376 for (OCB_rtiter = OCB_begin_end.first; OCB_rtiter != OCB_begin_end.second; ++OCB_rtiter){
377 float Tower_Embedded = 0;
378 RawTower *towerB = OCB_rtiter->second;
389 else Tower_Embedded = -12;
396 for (OC_rtiter = OC_begin_end.first; OC_rtiter != OC_begin_end.second; ++OC_rtiter){
401 float HCALOUT_Embedded = -1;
409 double z = z0 - vtxz;
411 double eta = asinh(z/r);
413 double px = pt*cos(phi);
414 double py = pt*sin(phi);
415 double pz = pt*sinh(eta);
420 fastjet::PseudoJet pseudojet(px, py, pz, tower->
get_energy());
421 pseudojet.set_user_index(HCALOUT_Embedded);
422 pseudojet_reco.push_back(pseudojet);
423 if (HCALOUT_Embedded == -12 || HCALOUT_Embedded == 5)
continue;
424 pseudojet_reco_truth.push_back(pseudojet);
431 fastjet::ClusterSequence jetFinder_reco_truth(pseudojet_reco_truth, jetDef);
432 fastjet::ClusterSequence jetFinder_reco(pseudojet_reco, jetDef);
433 std::vector<fastjet::PseudoJet> fastjets_reco_truth = jetFinder_reco_truth.inclusive_jets();
434 std::vector<fastjet::PseudoJet> fastjets_reco = jetFinder_reco.inclusive_jets();
436 pseudojet_reco_truth.clear();
437 pseudojet_reco.clear();
440 for (
JetMap::Iter iter = jetsMC->begin(); iter != jetsMC->end(); ++iter){
442 Jet* truthjet = iter->second;
445 if (not eta_cut)
continue;
474 for (
int j = 0;
j < (int)fastjets_reco_truth.size(); ++
j){
476 vector<fastjet::PseudoJet> consts_reco_truth = jetFinder_reco_truth.constituents(fastjets_reco_truth[
j]);
490 for (
int j = 0;
j < (int)fastjets_reco.size(); ++
j)
492 vector<fastjet::PseudoJet> consts = jetFinder_reco.constituents(fastjets_reco[
j]);
510 for (
int i = 0;
i < (int)consts.size();
i++){
511 m_CAL_ID.push_back(consts[
i].user_index());
561 m_eta.push_back(fastjets_reco[j].
eta());
562 m_phi.push_back(fastjets_reco[j].phi_std());
563 m_pt.push_back(fastjets_reco[j].
perp());
564 m_px.push_back(fastjets_reco[j].px());
565 m_py.push_back(fastjets_reco[j].py());
566 m_pz.push_back(fastjets_reco[j].pz());
567 m_e.push_back(fastjets_reco[j].
e());
581 float m_Loop_dR = 100000;
584 for(std::size_t
i = 0, max = (
int)
m_truthPhi.size();
i != max; ++
i){
587 double dEta_temp = fastjets_reco[
j].eta() -
m_truthEta.at(
i);
593 float dR_temp = sqrt(dEta_temp * dEta_temp + dPhi_temp * dPhi_temp);
594 if(dR_temp > m_Loop_dR)
continue;
612 m_dR.push_back(m_Loop_dR);
691 m_T =
new TTree(
"T",
"MyJetAnalysis Tree");