ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::PartonJetAugmentationTool Class Reference

#include <PartonJetAugmentationTool.h>

Inheritance diagram for DerivationFramework::PartonJetAugmentationTool:
Collaboration diagram for DerivationFramework::PartonJetAugmentationTool:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode addBranches (const EventContext &ctx) const override

Private Member Functions

bool extrajet (const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &lj, TLorentzVector &slj, TLorentzVector &tlj, const std::vector< TLorentzVector > &ttbarDecayProducts, const std::vector< int > &decayProduct_pdgID, double Rparam, double pt_min) const
bool isLastBeforeHadronization (const xAOD::TruthParticle *p) const

Private Attributes

SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthKey
SG::WriteHandleKey< xAOD::JetContainerm_partonJetsKey

Detailed Description

Definition at line 18 of file PartonJetAugmentationTool.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::PartonJetAugmentationTool::addBranches ( const EventContext & ctx) const
overridevirtual

Definition at line 34 of file PartonJetAugmentationTool.cxx.

35 {
36
37 // Get truth particles
38 //const xAOD::TruthParticleContainer* truth = nullptr;
39 //ATH_CHECK(evtStore()->retrieve(truth, "TruthParticles"));
40 SG::ReadHandle<xAOD::TruthParticleContainer> truth(m_truthKey, ctx);
41 if (!truth.isValid()) {
42 ATH_MSG_ERROR("Failed to retrieve TruthParticles");
43 return StatusCode::FAILURE;
44 }
45
46
47 // Create output jet container
48 auto jets = std::make_unique<xAOD::JetContainer>();
49 auto jetsAux = std::make_unique<xAOD::JetAuxContainer>();
50 jets->setStore(jetsAux.get());
51
52 TLorentzVector lj, slj, tlj;
53
54 double jet_radius = 0.4;
55 double min_pT = 20;
56
57 std::vector<TLorentzVector> ttbarDecayProducts;
58 std::vector<int> decayProduct_pdgID;
59
60 for(const auto* p : *truth){
61
62 int pdg = p->pdgId();
63
64 // Only consider W bosons and b quarks
65 if(abs(pdg) != 5 && abs(pdg) != 24)
66 continue;
67
68 bool fromTop = false;
69
70 // check parents
71 for(unsigned int ip = 0; ip < p->nParents(); ++ip){
72 const xAOD::TruthParticle* parent = p->parent(ip);
73
74 if(parent && parent->absPdgId() == 6){
75 fromTop = true;
76 break;
77 }
78 }
79
80 if(!fromTop) continue;
81 TLorentzVector vec;
82 vec.SetPtEtaPhiM(p->pt(), p->eta(), p->phi(), p->m());
83
84 ttbarDecayProducts.push_back(vec);
85 decayProduct_pdgID.push_back(pdg);
86 }
87
88 bool ok = extrajet(truth.cptr(), lj, slj, tlj, ttbarDecayProducts, decayProduct_pdgID, jet_radius, min_pT);
89
90
91 auto saveJet = [&](const TLorentzVector& v) {
92 if(v.Pt() <= 0) return; // skip empty jets
93 xAOD::Jet* jet = new xAOD::Jet();
94 jets->push_back(jet);
95 jet->setJetP4(xAOD::JetFourMom_t(v.Pt(), v.Eta(), v.Phi(), v.M()));
96 };
97
98 if(ok){
99 saveJet(lj);
100 saveJet(slj);
101 saveJet(tlj);
102 }
103
104 // Store in output DAOD
105 //ATH_CHECK(evtStore()->record(std::move(jets), "PartonJets"));
106 // ATH_CHECK(evtStore()->record(std::move(jetsAux), "PartonJetsAux."));
107 SG::WriteHandle<xAOD::JetContainer> jetsHandle(m_partonJetsKey, ctx);
108 ATH_CHECK(jetsHandle.record(std::move(jets), std::move(jetsAux)));
109
110
111
112 return StatusCode::SUCCESS;
113 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
std::vector< size_t > vec
SG::WriteHandleKey< xAOD::JetContainer > m_partonJetsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthKey
bool extrajet(const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &lj, TLorentzVector &slj, TLorentzVector &tlj, const std::vector< TLorentzVector > &ttbarDecayProducts, const std::vector< int > &decayProduct_pdgID, double Rparam, double pt_min) const
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:182
Jet_v1 Jet
Definition of the current "jet version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ extrajet()

bool DerivationFramework::PartonJetAugmentationTool::extrajet ( const xAOD::TruthParticleContainer * truthParticles,
TLorentzVector & lj,
TLorentzVector & slj,
TLorentzVector & tlj,
const std::vector< TLorentzVector > & ttbarDecayProducts,
const std::vector< int > & decayProduct_pdgID,
double Rparam,
double pt_min ) const
private

Definition at line 154 of file PartonJetAugmentationTool.cxx.

162 {
163
164 // if true, decay products of the top quark and their children are removed from clustering
165 const bool exclude_topdecay = true;
166 std::vector<fastjet::PseudoJet> vec_status62; //partons just before top decay
167
168 for (const xAOD::TruthParticle* particle : *truthParticles) {
169 // particles with status 81-100 are for internal MC only and are not to be used in clustering
170 // particles with status > 100 are hadrons or other unstable particle
171 // They're not relevant for parton jets
172 if (particle->absPdgId() > 80 || (particle->absPdgId() > 22 && particle->absPdgId() < 38)) continue; //exclude bosons which are not gluons or photons
173
174 // Find last parton before hadronization (corresponding to status 62 in pythia)
175 //satus 11 is Pythia, status 71 is Herwig - we want to run for both
176 if((particle->status()==11 || particle->status()==71) && particle->absPdgId()!=6 ){
177
178 const xAOD::TruthParticle* topParent = particle;
179 bool exclude=false;
180
181 if (!isLastBeforeHadronization(particle))
182 {
183 continue;
184 }
185
186 //Remove all partons that come from the top quark decay
187 if (exclude_topdecay)
188 {
189 while(topParent->nParents()>0 )
190 {
191 topParent = topParent->parent(0);
192 if (topParent->nChildren() > 0 )
193 {
194 if( ( topParent->absPdgId()==24 && topParent->nParents()>0 && topParent->parent(0)->absPdgId()==6 ) ||
195 ( topParent->absPdgId()==5 && topParent->nParents()>0 && topParent->parent(0)->absPdgId()==6 ) ) exclude=true;
196 }
197 if (exclude) break;
198 }//while
199 }// if (exclude_topdecay)
200
201
202 if(!exclude){
203 fastjet::PseudoJet tmp(particle->px(), particle->py(), particle->pz(), particle->e());
204 vec_status62.push_back(tmp);
205 } //if(!exclude)
206
207 }
208 }
209
210 // Fastjet analysis - select algorithm and parameters
211 fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, Rparam, fastjet::E_scheme, fastjet::Best);
212
213 std::vector <fastjet::PseudoJet> inclusivePertJet62, sortedPertJet62;
214
215 fastjet::ClusterSequence clustSeqPertJet62(vec_status62, jetDef);
216 // Extract inclusive jets sorted by pT, and ask for Pt>pt_min
217 inclusivePertJet62 = clustSeqPertJet62.inclusive_jets(pt_min * 1000.); //GeV
218 sortedPertJet62 = fastjet::sorted_by_pt(inclusivePertJet62);
219 // std::cout<<"containers size: "<<inclusivePertJet22.size()<<" "<<inclusivePertJet22.size()<<"\n";
220
221 if(inclusivePertJet62.size()==0){
222 // std::cout<<"Extrajet containers are empty! No partonic extrajet!\n";
223 return false;
224 }
225
226 if (inclusivePertJet62.size()!=0)
227 {
228 // remove jets that are in deltaR <= 0.4 to one of the top decay products
229 for (long unsigned int i = 0; i < ttbarDecayProducts.size(); ++i)
230 {
231 for (long unsigned int j = 0; j < sortedPertJet62.size(); ++j)
232 {
233 if (sortedPertJet62[j].delta_R(ttbarDecayProducts[i]) <= 0.4
234 && abs(decayProduct_pdgID[i]) != 11 // electron
235 && abs(decayProduct_pdgID[i]) != 12 // electron neutrino
236 && abs(decayProduct_pdgID[i]) != 13 // muon
237 && abs(decayProduct_pdgID[i]) != 14 // muon neutrino
238 // do not veto tau leptons since they also decay hadronically
239 && abs(decayProduct_pdgID[i]) != 16 // tau neutrino
240 )
241 {
242
243 sortedPertJet62.erase(sortedPertJet62.begin() + j);
244
245 --j;
246 }
247 }//for
248
249 }//for
250
251 bool leading_jet_found = false;
252 bool subleading_jet_found = false;
253 bool third_jet_found = false;
254
255 for (std::vector<fastjet::PseudoJet>::iterator jet = sortedPertJet62.begin(); jet != sortedPertJet62.end(); ++jet)
256 {
257 if(!leading_jet_found){
258 lj.SetPxPyPzE(jet->px(),jet->py(),jet->pz(),jet->e()); //only saves leading jet
259 leading_jet_found = true;
260 }
261 else if(leading_jet_found && !subleading_jet_found){
262 slj.SetPxPyPzE(jet->px(),jet->py(),jet->pz(),jet->e()); //only saves leading jet
263 subleading_jet_found = true;
264 break;
265 }
266 else if(leading_jet_found && subleading_jet_found && !third_jet_found){
267 tlj.SetPxPyPzE(jet->px(),jet->py(),jet->pz(),jet->e()); //only saves leading jet
268 third_jet_found = true;
269 break;
270 }
271 } //for
272 }
273
274
275 if (lj.Pt() >= pt_min*1000.) return true;
276
277 return false;
278
279 }
bool isLastBeforeHadronization(const xAOD::TruthParticle *p) const
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
int absPdgId() const
Absolute PDG ID code (often useful).
size_t nParents() const
Number of parents of this particle.
size_t nChildren() const
Number of children of this particle.
std::set< std::string > exclude
list of directories to be excluded
Definition hcg.cxx:100
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
delta_R(eta1, phi1, eta2, phi2)
Definition eFEXNTuple.py:20

◆ initialize()

StatusCode DerivationFramework::PartonJetAugmentationTool::initialize ( )
overridevirtual

Definition at line 21 of file PartonJetAugmentationTool.cxx.

21 {
22 ATH_MSG_INFO("Initializing PartonJetAugmentationTool");
23
24 ATH_CHECK(m_truthKey.initialize());
25 ATH_CHECK(m_partonJetsKey.initialize());
26
27 return StatusCode::SUCCESS;
28 }
#define ATH_MSG_INFO(x)

◆ isLastBeforeHadronization()

bool DerivationFramework::PartonJetAugmentationTool::isLastBeforeHadronization ( const xAOD::TruthParticle * p) const
private

Definition at line 117 of file PartonJetAugmentationTool.cxx.

117 {
118
120 bool isLastBeforeHadronization = false;
121
122 if (particle->nChildren() > 0)
123 {
124 if (particle->child(0)->absPdgId() > 37)
125 {
127 }//if
128 if (particle->nChildren() > 1) //safety measure because some particles have only themselves as child
129 {
130 if (particle->child(1)->absPdgId() > 37)
131 {
133 }//if
134 }//if
135 }//if
136
137 // check if not after hadronization
138 while(parent->nParents()>0 && isLastBeforeHadronization == true)
139 {
140
141 parent = parent->parent(0);
142
143 if (parent->absPdgId() > 37 && parent->absPdgId() != 2212) //proton
144 {
146 }
147
148 }//while
149
151 }

Member Data Documentation

◆ m_partonJetsKey

SG::WriteHandleKey<xAOD::JetContainer> DerivationFramework::PartonJetAugmentationTool::m_partonJetsKey
private
Initial value:
{
this, "PartonJets", "PartonJets", "Output parton jets"
}

Definition at line 31 of file PartonJetAugmentationTool.h.

31 {
32 this, "PartonJets", "PartonJets", "Output parton jets"
33 };

◆ m_truthKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::PartonJetAugmentationTool::m_truthKey
private
Initial value:
{
this, "TruthParticles", "TruthParticles", "Input truth particles"
}

Definition at line 27 of file PartonJetAugmentationTool.h.

27 {
28 this, "TruthParticles", "TruthParticles", "Input truth particles"
29 };

The documentation for this class was generated from the following files: