ATLAS Offline Software
Loading...
Searching...
No Matches
BoostedHadTopAndTopPair.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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"
15#include <iostream>
16#include <cmath>
17
18BoostedHadTopAndTopPair::BoostedHadTopAndTopPair(const std::string& name, ISvcLocator* pSvcLocator)
19 : GenFilter(name,pSvcLocator)
20{
21 // pT min et pT max :
22 declareProperty("tHadPtMin", m_tHadPtMin = 0.0);
23 declareProperty("tHadPtMax", m_tHadPtMax = 4000000.0);
24 declareProperty("tPairPtMin", m_tPairPtMin = 0.0);
25 declareProperty("tPairPtMax", m_tPairPtMax = 4000000.0);
26 declareProperty("cutPtOf", m_cutPtOf = 0);
27}
28
29
30StatusCode BoostedHadTopAndTopPair::filterEvent(const EventContext& ctx) {
31 // if true, the event pass the filter :
32 bool pass = false;
33 bool passTopHad = false;
34 bool passTopPair = false;
35
36 HepMC::FourVector topListMomentum(0,0,0,0);
37 HepMC::FourVector topbListMomentum(0,0,0,0);
38 HepMC::FourVector topChildrenMomentum(0,0,0,0);
39 HepMC::FourVector topbChildrenMomentum(0,0,0,0);
40
41 double pTHadTopList = -1;
42 double pTHadTopChildren = -1;
43 const HepMC::FourVector b(0,0,0,0);
44
45 // Loop over all events in McEventCollection and extract the top pt
47 for (itr = events()->begin(); itr != events()->end(); ++itr) {
48 const HepMC::GenEvent* genEvt = *itr;
49
50
51 for (const auto& part: *genEvt){
52 int pdgId = part->pdg_id();
53
54 // pdgId t quark = 6
55 if ( pdgId == MC::TQUARK && isFinalParticle(part) ){
56 if ( part->momentum().perp() > topListMomentum.perp() ) topListMomentum = part->momentum();
57 }
58
59 if ( pdgId == -MC::TQUARK && isFinalParticle(part) ){
60 if ( part->momentum().perp() > topbListMomentum.perp() ) topbListMomentum = part->momentum();
61 }
62
63 // pdgId W boson = 24
64 if ( MC::isW(pdgId) || !isFinalParticle(part) ) continue;
65
66 if (isFromTop(part)){
67 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());
68 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());
69
70 if (isHadronic(part)){
71 double pT = std::sqrt( std::pow( part->momentum().px() + momentumBofW(part).px(),2) + std::pow( part->momentum().py() + momentumBofW(part).py(),2));
72 if (pT > pTHadTopChildren){
73 pTHadTopChildren = pT;
74 if (pdgId > 0) pTHadTopList = topListMomentum.perp();
75 else pTHadTopList = topbListMomentum.perp();
76 }
77 }
78 }
79 } // particle loop
80 } // event loop
81
82 double pTPairList = std::sqrt( std::pow( topListMomentum.px() + topbListMomentum.px() , 2 ) + std::pow( topListMomentum.py() + topbListMomentum.py() , 2 ));
83 double pTPairChildren = std::sqrt( std::pow( topChildrenMomentum.px() + topbChildrenMomentum.px() , 2 ) + std::pow( topChildrenMomentum.py() + topbChildrenMomentum.py() , 2 ));
84
85 if (m_cutPtOf == 0){ // cut on the pT of top on the truth list
86 if (pTHadTopList >= m_tHadPtMin && pTHadTopList < m_tHadPtMax ) passTopHad = true;
87 if (pTPairList >= m_tPairPtMin && pTPairList < m_tPairPtMax ) passTopPair = true;
88 }else if( m_cutPtOf == 1){ // cut on the pT of top decay products (b, q, qbar') on the truth list
89 if (pTHadTopChildren >= m_tHadPtMin && pTHadTopChildren < m_tHadPtMax ) passTopHad = true;
90 if (pTPairChildren >= m_tPairPtMin && pTPairChildren < m_tPairPtMax ) passTopPair = true;
91 }
92
93 if ( passTopPair && passTopHad ) pass = true;
94 setFilterPassed(pass, ctx);
95
96 return StatusCode::SUCCESS;
97}
98
99
101
102 auto initpart = findInitial(part);
103 auto prod = initpart->production_vertex();
104
105 if(!prod) return false;
106
107 for (const auto& p: prod->particles_in()) if (MC::isTop(p)) return true;
108 return false;
109}
110
111
113
114 auto prod = part->production_vertex();
115
116 if(!prod) return part;
117
118 for (const auto& p: prod->particles_in()) if (part->pdg_id() == p->pdg_id()) return findInitial(part);
119 return part;
120}
121
122
124
125 auto end = part->end_vertex();
126 if (end) {
127 for(const auto& firstChild: *end){
128 if( std::abs(firstChild->pdg_id()) <= 5 ) return true;
129 }
130 }
131 return false;
132}
133
134
136
137 auto end = part->end_vertex();
138 if(end){
139 int type = part->pdg_id();
140 for(const auto& firstChild: *end){
141 if( firstChild->pdg_id() == type ) return false;
142 }
143 }
144 return true;
145}
146
147
149
150 auto initpart = findInitial(part);
151 auto prod = initpart->production_vertex();
152
153 HepMC::FourVector b(0,0,0,0);
154if (prod) {
155 for(const auto& firstChild: *prod){
156 if( std::abs( firstChild->pdg_id() ) == 5 ){
157 b.set(firstChild->momentum().x(), firstChild->momentum().y(), firstChild->momentum().z(), firstChild->momentum().t());
158 }
159 }
160}
161 return b;
162}
ATLAS-specific HepMC functions.
virtual void setFilterPassed(bool state, const EventContext &ctx) const
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
virtual StatusCode filterEvent(const EventContext &ctx)
Do the filtering.
bool isFinalParticle(const HepMC::ConstGenParticlePtr &part) const
bool isHadronic(const HepMC::ConstGenParticlePtr &part) const
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
HepMC3::FourVector FourVector
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
bool isW(const T &p)
static const int TQUARK
bool isTop(const T &p)