ATLAS Offline Software
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 
17 BoostedHadTopAndTopPair::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);
169 if (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 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
test_pyathena.px
px
Definition: test_pyathena.py:18
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
BoostedHadTopAndTopPair::filterEvent
virtual StatusCode filterEvent()
Do the filtering.
Definition: BoostedHadTopAndTopPair.cxx:29
BoostedHadTopAndTopPair::m_tHadPtMin
double m_tHadPtMin
Definition: BoostedHadTopAndTopPair.h:52
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
BoostedHadTopAndTopPair::isHadronic
bool isHadronic(const HepMC::ConstGenParticlePtr &part) const
Definition: BoostedHadTopAndTopPair.cxx:138
BoostedHadTopAndTopPair::BoostedHadTopAndTopPair
BoostedHadTopAndTopPair(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: BoostedHadTopAndTopPair.cxx:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BoostedHadTopAndTopPair::isFinalParticle
bool isFinalParticle(const HepMC::ConstGenParticlePtr &part) const
Definition: BoostedHadTopAndTopPair.cxx:150
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
BoostedHadTopAndTopPair::m_tPairPtMax
double m_tPairPtMax
Definition: BoostedHadTopAndTopPair.h:55
BoostedHadTopAndTopPair::momentumBofW
HepMC::FourVector momentumBofW(const HepMC::ConstGenParticlePtr &part) const
Definition: BoostedHadTopAndTopPair.cxx:163
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
BoostedHadTopAndTopPair::isFromTop
bool isFromTop(const HepMC::ConstGenParticlePtr &part) const
Definition: BoostedHadTopAndTopPair.cxx:99
BoostedHadTopAndTopPair::m_cutPtOf
int m_cutPtOf
Definition: BoostedHadTopAndTopPair.h:56
BoostedHadTopAndTopPair::m_tHadPtMax
double m_tHadPtMax
Definition: BoostedHadTopAndTopPair.h:53
BoostedHadTopAndTopPair::findInitial
HepMC::ConstGenParticlePtr findInitial(const HepMC::ConstGenParticlePtr &part) const
Definition: BoostedHadTopAndTopPair.cxx:119
BoostedHadTopAndTopPair::m_tPairPtMin
double m_tPairPtMin
Definition: BoostedHadTopAndTopPair.h:54
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
BoostedHadTopAndTopPair.h