4 #include <calobase/RawCluster.h>
5 #include <calobase/RawClusterContainer.h>
6 #include <calobase/RawClusterUtility.h>
7 #include <calobase/RawTower.h>
8 #include <calobase/RawTowerContainer.h>
9 #include <calobase/RawTowerGeom.h>
10 #include <calobase/RawTowerGeomContainer.h>
11 #include <calotrigger/CaloTriggerInfo.h>
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
32 #include <HepMC/GenEvent.h>
33 #include <HepMC/GenVertex.h>
34 #pragma GCC diagnostic pop
73 , m_outfilename(filename)
77 , m_analyzeTracks(
true)
78 , m_analyzeClusters(
true)
80 , m_analyzeTruth(
false)
107 std::cout <<
"Beginning Init in AnaTutorial" << std::endl;
112 m_phi_h =
new TH1D(
"phi_h",
";Counts;#phi [rad]", 50, -6, 6);
113 m_eta_phi_h =
new TH2F(
"phi_eta_h",
";#eta;#phi [rad]", 10, -1, 1, 50, -6, 6);
126 std::cout <<
"Beginning process_event in AnaTutorial" << std::endl;
164 std::cout <<
"Ending AnaTutorial analysis package" << std::endl;
209 std::cout <<
"Finished AnaTutorial analysis package" << std::endl;
224 PHHepMCGenEventMap *hepmceventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
230 <<
"HEPMC event map node is missing, can't collected HEPMC truth particles"
238 std::cout <<
"Getting HEPMC truth particles " << std::endl;
244 eventIter != hepmceventmap->
end();
253 HepMC::GenEvent *truthevent = hepmcevent->
getEvent();
257 <<
"no evt pointer under phhepmvgeneventmap found "
263 HepMC::PdfInfo *pdfinfo = truthevent->pdf_info();
268 m_x1 = pdfinfo->x1();
269 m_x2 = pdfinfo->x2();
272 m_mpi = truthevent->mpi();
279 std::cout <<
" Iterating over an event" << std::endl;
282 for (HepMC::GenEvent::particle_const_iterator iter = truthevent->particles_begin();
283 iter != truthevent->particles_end();
290 m_trutheta = (*iter)->momentum().pseudoRapidity();
319 <<
"PHG4TruthInfoContainer node is missing, can't collect G4 truth particles"
329 iter != range.second;
367 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
372 <<
"SvtxTrackMap node is missing, can't collect tracks"
394 std::cout <<
"Get the SVTX tracks" << std::endl;
396 for (
auto &iter : *trackmap)
451 std::cout <<
"get the truth jets" << std::endl;
455 JetMap *truth_jets = findNode::getClass<JetMap>(topNode,
"AntiKt_Truth_r04");
458 JetMap *reco_jets = findNode::getClass<JetMap>(topNode,
"AntiKt_Tower_r04");
470 <<
"Truth jet node is missing, can't collect truth jets"
477 iter != truth_jets->
end();
480 Jet *truthJet = iter->second;
484 std::set<PHG4Particle *> truthjetcomp =
486 int ntruthconstituents = 0;
488 for (
auto truthpart : truthjetcomp)
493 std::cout <<
"no truth particles in the jet??" << std::endl;
497 ntruthconstituents++;
500 if (ntruthconstituents < 3)
527 float closestjet = 9999;
529 for (
auto &reco_jet : *reco_jets)
531 const Jet *recoJet = reco_jet.second;
543 std::cout <<
"matching by distance jet" << std::endl;
551 if (dphi < -1 * M_PI)
559 m_dR = std::sqrt(pow(dphi, 2.) + pow(deta, 2.));
563 if (m_dR < truth_jets->get_par() &&
m_dR < closestjet)
587 JetMap *reco_jets = findNode::getClass<JetMap>(topNode,
"AntiKt_Tower_r04");
589 JetMap *truth_jets = findNode::getClass<JetMap>(topNode,
"AntiKt_Truth_r04");
601 <<
"Reconstructed jet node is missing, can't collect reconstructed jets"
608 std::cout <<
"Get all Reco Jets" << std::endl;
613 recoIter != reco_jets->
end();
616 Jet *recoJet = recoIter->second;
636 std::cout <<
"matching by distance jet" << std::endl;
669 float closestjet = 9999;
670 for (
auto &truth_jet : *truth_jets)
672 const Jet *truthJet = truth_jet.second;
674 float thisjetpt = truthJet->
get_pt();
680 float thisjeteta = truthJet->
get_eta();
681 float thisjetphi = truthJet->
get_phi();
688 if (dphi < -1. * M_PI)
696 m_dR = sqrt(pow(dphi, 2.) + pow(deta, 2.));
700 if (m_dR < reco_jets->get_par() &&
m_dR < closestjet)
735 <<
"EMCal cluster node is missing, can't collect EMCal clusters"
741 GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
744 std::cout <<
"AnaTutorial::getEmcalClusters - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << std::endl;
750 if (vertexmap->
empty())
752 std::cout <<
"AnaTutorial::getEmcalClusters - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << std::endl;
758 for(
auto iter = vertexmap->
begin(); iter!= vertexmap->
end(); ++iter)
772 CaloTriggerInfo *trigger = findNode::getClass<CaloTriggerInfo>(topNode,
"CaloTriggerInfo");
783 for (clusIter = begin_end.first;
784 clusIter != begin_end.second;
797 m_cluseta = E_vec_cluster.pseudoRapidity();
822 m_recojettree =
new TTree(
"jettree",
"A tree with reconstructed jets");
842 m_truthjettree =
new TTree(
"truthjettree",
"A tree with truth jets");
861 m_tracktree =
new TTree(
"tracktree",
"A tree with svtx tracks");
887 m_hepmctree =
new TTree(
"hepmctree",
"A tree with hepmc truth particles");
904 m_truthtree =
new TTree(
"truthg4tree",
"A tree with truth g4 particles");
915 m_clustertree =
new TTree(
"clustertree",
"A tree with emcal clusters");