12 #include "GaudiKernel/ITHistSvc.h"
13 #include "GaudiKernel/ISvcLocator.h"
24 #include <TGraphAsymmErrors.h>
35 m_numberOfTreeEntries(0),
38 m_genParticleLinkIndex(
nullptr),
39 m_mc_trackToJetAngle(
nullptr),
40 m_mc_jetMultiplicity{},
46 declareInterface<IJetTruthNtupleTool>(
this);
49 declareProperty(
"NtupleFileName", m_ntupleFileName =
"TRKVAL/Validation",
"Ntuple file handle");
50 declareProperty(
"NtupleTreeName", m_ntupleTreeName =
"TruthJets",
"Name of the ntuple tree");
63 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
68 m_nt =
new TTree(TString(m_ntupleTreeName),
"Track Validation JetTruth");
70 std::string fullNtupleName =
"/"+m_ntupleFileName+
"/"+m_ntupleTreeName;
71 ATH_CHECK( tHistSvc->regTree(fullNtupleName, m_nt) );
76 m_nt->Branch(
"RunNumber", &m_runNumber );
77 m_nt->Branch(
"EventNumber", &m_eventNumber );
79 m_nt->Branch(
"truth_jetMultiplicity", &m_mc_jetMultiplicity );
80 m_nt->Branch(
"truth_jetSphericity", &m_mc_jetSphericity );
81 m_nt->Branch(
"truth_jetThrust", &m_mc_jetThrust );
82 m_nt->Branch(
"truth_jetEnergy", &m_mc_jetEnergy );
83 m_nt->Branch(
"truth_jetMomentum", &m_mc_jetMomentum );
85 m_genParticleLinkIndex =
new std::vector<unsigned int>();
86 m_nt->Branch(
"GenParticleLinkIndex", &m_genParticleLinkIndex);
87 m_mc_trackToJetAngle =
new std::vector<float>();
88 m_nt->Branch(
"truth_trackToJetAngle", &m_mc_trackToJetAngle);
92 return StatusCode::SUCCESS;
103 delete m_genParticleLinkIndex;
104 delete m_mc_trackToJetAngle;
106 return StatusCode::SUCCESS;
113 const std::vector< Trk::GenParticleJet >&
jets,
114 const int& nTruthRecordsAtCurrentEvent
122 if (!
evt.isValid()) {
124 return StatusCode::FAILURE;
126 m_runNumber=
evt->runNumber();
127 m_eventNumber=
evt->eventNumber();
129 for (std::vector<Trk::GenParticleJet>::const_iterator itJet =
jets.begin();
130 itJet <
jets.end(); ++itJet ) {
132 m_mc_jetMultiplicity = itJet->getNumParticles();
133 m_mc_jetMomentum = itJet->getMomentum().mag();
134 m_mc_jetEnergy = itJet->getEnergy();
135 m_mc_jetSphericity = itJet->getSphericity();
136 m_mc_jetThrust = itJet->getThrust();
139 m_mc_trackToJetAngle->reserve(
particles.size());
140 m_genParticleLinkIndex->reserve(
particles.size());
141 std::vector<int>
indices = itJet->getIndicesInEvent();
143 m_genParticleLinkIndex->clear();
144 m_mc_trackToJetAngle->clear();
146 itPrt <
particles.end(); ++itPrt, ++itIdx) {
148 HepGeom::Vector3D<double> tempMomentum((*itPrt)->momentum().px(),
149 (*itPrt)->momentum().py(),
150 (*itPrt)->momentum().pz());
152 m_mc_trackToJetAngle->push_back((
float)tempMomentum.angle(itJet->getMomentum()));
153 m_genParticleLinkIndex->push_back(nTruthRecordsAtCurrentEvent+1+(
unsigned int)(*itIdx));
156 m_numberOfTreeEntries++;
158 return StatusCode::SUCCESS;
163 return m_numberOfTreeEntries;