ATLAS Offline Software
Loading...
Searching...
No Matches
BoostedHadTopAndTopPair.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// GeneratorFilters/BoostedHadTopAndTopPair
6//
7// Allows the user to search for both top had pT and top pair pT in a given range, in tt events (thad is the hadronically decaying top with the highest momentum in each even).
8//
9// Author:
10// Eloi Le Quilleuc 2014
11
13#include "GaudiKernel/MsgStream.h"
14#include <iostream>
15#include <cmath>
16
17BoostedHadTopAndTopPair::BoostedHadTopAndTopPair(const std::string& name, ISvcLocator* pSvcLocator)
18 : GenFilter(name,pSvcLocator)
19{
20 // pT min et pT max :
21 declareProperty("tHadPtMin", m_tHadPtMin = 0.0);
22 declareProperty("tHadPtMax", m_tHadPtMax = 4000000.0);
23 declareProperty("tPairPtMin", m_tPairPtMin = 0.0);
24 declareProperty("tPairPtMax", m_tPairPtMax = 4000000.0);
25 declareProperty("cutPtOf", m_cutPtOf = 0);
26}
27
28
30 // if true, the event pass the filter :
31 bool pass = false;
32 bool passTopHad = false;
33 bool passTopPair = false;
34
35 HepMC::FourVector topListMomentum(0,0,0,0);
36 HepMC::FourVector topbListMomentum(0,0,0,0);
37 HepMC::FourVector topChildrenMomentum(0,0,0,0);
38 HepMC::FourVector topbChildrenMomentum(0,0,0,0);
39
40 double pTHadTopList = -1;
41 double pTHadTopChildren = -1;
42 const HepMC::FourVector b(0,0,0,0);
43
44 // Loop over all events in McEventCollection and extract the top pt
46 for (itr = events()->begin(); itr != events()->end(); ++itr) {
47 const HepMC::GenEvent* genEvt = *itr;
48
49
50 for (const auto& part: *genEvt){
51 int pdgId = part->pdg_id();
52
53 // pdgId t quark = 6
54 if ( pdgId == 6 && isFinalParticle(part) ){
55 if ( part->momentum().perp() > topListMomentum.perp() ) topListMomentum = part->momentum();
56 }
57
58 if ( pdgId == -6 && isFinalParticle(part) ){
59 if ( part->momentum().perp() > topbListMomentum.perp() ) topbListMomentum = part->momentum();
60 }
61
62 // pdgId W boson = 24
63 if ( std::abs(pdgId) != 24 || !isFinalParticle(part) ) continue;
64
65 if (isFromTop(part)){
66 if (pdgId > 0) topChildrenMomentum.set(part->momentum().px() + momentumBofW(part).px(), part->momentum().py() + momentumBofW(part).py(), part->momentum().pz() + momentumBofW(part).pz(), part->momentum().e() + momentumBofW(part).e());
67 else topbChildrenMomentum.set(part->momentum().px() + momentumBofW(part).px(), part->momentum().py() + momentumBofW(part).py(), part->momentum().pz() + momentumBofW(part).pz(), part->momentum().e() + momentumBofW(part).e());
68
69 if (isHadronic(part)){
70 double pT = std::sqrt( std::pow( part->momentum().px() + momentumBofW(part).px(),2) + std::pow( part->momentum().py() + momentumBofW(part).py(),2));
71 if (pT > pTHadTopChildren){
72 pTHadTopChildren = pT;
73 if (pdgId > 0) pTHadTopList = topListMomentum.perp();
74 else pTHadTopList = topbListMomentum.perp();
75 }
76 }
77 }
78 } // particle loop
79 } // event loop
80
81 double pTPairList = std::sqrt( std::pow( topListMomentum.px() + topbListMomentum.px() , 2 ) + std::pow( topListMomentum.py() + topbListMomentum.py() , 2 ));
82 double pTPairChildren = std::sqrt( std::pow( topChildrenMomentum.px() + topbChildrenMomentum.px() , 2 ) + std::pow( topChildrenMomentum.py() + topbChildrenMomentum.py() , 2 ));
83
84 if (m_cutPtOf == 0){ // cut on the pT of top on the truth list
85 if (pTHadTopList >= m_tHadPtMin && pTHadTopList < m_tHadPtMax ) passTopHad = true;
86 if (pTPairList >= m_tPairPtMin && pTPairList < m_tPairPtMax ) passTopPair = true;
87 }else if( m_cutPtOf == 1){ // cut on the pT of top decay products (b, q, qbar') on the truth list
88 if (pTHadTopChildren >= m_tHadPtMin && pTHadTopChildren < m_tHadPtMax ) passTopHad = true;
89 if (pTPairChildren >= m_tPairPtMin && pTPairChildren < m_tPairPtMax ) passTopPair = true;
90 }
91
92 if ( passTopPair && passTopHad ) pass = true;
93 setFilterPassed(pass);
94
95 return StatusCode::SUCCESS;
96}
97
98
100
101 auto initpart = findInitial(part);
102 auto prod = initpart->production_vertex();
103
104 if(!prod) return false;
105
106#ifdef HEPMC3
107 for (const auto& p: prod->particles_in()) if (std::abs(p->pdg_id()) == 6) return true;
108#else
109 HepMC::GenVertex::particle_iterator firstParent = prod->particles_begin(HepMC::parents);
110 HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::parents);
111 for(;firstParent!=endParent; ++firstParent){
112 if( std::abs( (*firstParent)->pdg_id() ) == 6 ) return true;
113 }
114#endif
115 return false;
116}
117
118
120
121 auto prod = part->production_vertex();
122
123 if(!prod) return part;
124
125#ifdef HEPMC3
126 for (const auto& p: prod->particles_in()) if (part->pdg_id() == p->pdg_id()) return findInitial(part);
127#else
128 HepMC::GenVertex::particle_iterator firstParent = prod->particles_begin(HepMC::parents);
129 HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::parents);
130 for(;firstParent!=endParent; ++firstParent){
131 if( part->pdg_id() == (*firstParent)->pdg_id() ) return findInitial(*firstParent);
132 }
133#endif
134 return part;
135}
136
137
139
140 auto end = part->end_vertex();
141 if (end) {
142 for(const auto& firstChild: *end){
143 if( std::abs(firstChild->pdg_id()) <= 5 ) return true;
144 }
145 }
146 return false;
147}
148
149
151
152 auto end = part->end_vertex();
153 if(end){
154 int type = part->pdg_id();
155 for(const auto& firstChild: *end){
156 if( firstChild->pdg_id() == type ) return false;
157 }
158 }
159 return true;
160}
161
162
164
165 auto initpart = findInitial(part);
166 auto prod = initpart->production_vertex();
167
168 HepMC::FourVector b(0,0,0,0);
169if (prod) {
170 for(const auto& firstChild: *prod){
171 if( std::abs( firstChild->pdg_id() ) == 5 ){
172 b.set(firstChild->momentum().x(), firstChild->momentum().y(), firstChild->momentum().z(), firstChild->momentum().t());
173 }
174 }
175}
176 return b;
177}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
BoostedHadTopAndTopPair(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
HepMC::ConstGenParticlePtr findInitial(const HepMC::ConstGenParticlePtr &part) const
HepMC::FourVector momentumBofW(const HepMC::ConstGenParticlePtr &part) const
bool isFinalParticle(const HepMC::ConstGenParticlePtr &part) const
bool isHadronic(const HepMC::ConstGenParticlePtr &part) const
virtual StatusCode filterEvent()
Do the filtering.
bool isFromTop(const HepMC::ConstGenParticlePtr &part) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
GenFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition GenFilter.cxx:8
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38