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

#include <BoostedHadTopAndTopPairFilterTool.h>

Inheritance diagram for DerivationFramework::BoostedHadTopAndTopPairFilterTool:
Collaboration diagram for DerivationFramework::BoostedHadTopAndTopPairFilterTool:

Public Member Functions

 BoostedHadTopAndTopPairFilterTool (const std::string &t, const std::string &n, const IInterface *p)
virtual ~BoostedHadTopAndTopPairFilterTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
int filterFlag (double, double) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

const xAOD::TruthParticlefindInitial (const xAOD::TruthParticle *part) const
bool isFromTop (const xAOD::TruthParticle *part) const
bool isHadronic (const xAOD::TruthParticle *part) const
bool isFinalParticle (const xAOD::TruthParticle *part) const
double PxBofW (const xAOD::TruthParticle *part) const
double PyBofW (const xAOD::TruthParticle *part) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_mcName
int m_cutPtOf
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 23 of file BoostedHadTopAndTopPairFilterTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ BoostedHadTopAndTopPairFilterTool()

DerivationFramework::BoostedHadTopAndTopPairFilterTool::BoostedHadTopAndTopPairFilterTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 11 of file BoostedHadTopAndTopPairFilterTool.cxx.

12 : AthAlgTool(t,n,p)
13{
14
15 declareProperty("MCCollectionName",m_mcName ="TruthEvents");
16 declareProperty("cutPtOf", m_cutPtOf = 0);
17 // use values directly in filterFlag to make tool more flexible for now...
18 //declareProperty("tHadPtCut", m_tHadPtCut = 500000.0);
19 //declareProperty("tPairPtCut", m_tPairPtCut = 350000.0);
20
21}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~BoostedHadTopAndTopPairFilterTool()

DerivationFramework::BoostedHadTopAndTopPairFilterTool::~BoostedHadTopAndTopPairFilterTool ( )
virtual

Definition at line 24 of file BoostedHadTopAndTopPairFilterTool.cxx.

24{}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ filterFlag()

int DerivationFramework::BoostedHadTopAndTopPairFilterTool::filterFlag ( double tHadPtCut,
double tPairPtCut ) const

Definition at line 33 of file BoostedHadTopAndTopPairFilterTool.cxx.

33 {
34
35
36 // if true, the event pass the filter :
37 int filterCode = 0;
38 bool passTopHad = false;
39 bool passTopPair = false;
40
41 double topPt=0.0;
42 double topPx=0.0;
43 double topPy=0.0;
44 double topbarPt=0.0;
45 double topbarPx=0.0;
46 double topbarPy=0.0;
47
48 double topChildrenPx=0.0;
49 double topChildrenPy=0.0;
50 double topbarChildrenPx=0.0;
51 double topbarChildrenPy=0.0;
52
53 double hadtopPt = -1;
54 double hadtopbarPt = -1;
55 double hadtopChildrenPt = -1;
56
57 double bPx=0.0;
58 double bPy=0.0;
59
60 const xAOD::TruthEventContainer* xTruthEventContainer = 0;
61 if (evtStore()->retrieve(xTruthEventContainer,m_mcName).isFailure()) {
62 ATH_MSG_WARNING("could not retrieve TruthEventContainer " <<m_mcName);
63 return -1;
64 }
65 for ( const auto* truthevent : *xTruthEventContainer ) {
66
67 // Loop over all truth particles in the event
68 for(unsigned int i = 0; i < truthevent->nTruthParticles(); i++){
69
70 const xAOD::TruthParticle* part = truthevent->truthParticle(i);
71 // In release 21 we'll have a thinned truth record in the AODs.
72 // Specifically, geant particle are removed in most cases. The subsequent
73 // nullptr check is supposed to catch these truth particles,
74 // unfortunately however, there's no way to check whether this truth
75 // particle would have had an impact on what we do further down.
76 if (not part){
77 // We could possibly also use break since the thinned truth particles
78 // in principle should have no simulated particles.
79 continue;
80 }
81
82 if(HepMC::is_simulation_particle(part)) break;
83 int pdgId = part->pdgId();
84
85 // pdgId t quark = 6
86 if ( pdgId == MC::TQUARK && isFinalParticle(part) ){
87 if ( part->pt() > topPt ){
88 topPx = part->px();
89 topPy = part->py();
90 topPt = part->pt();}
91 }
92
93 if ( pdgId == -MC::TQUARK && isFinalParticle(part) ){
94 if ( part->pt() > topbarPt ){
95 topbarPx = part->px();
96 topbarPy = part->py();
97 topbarPt = part->pt();}
98 }
99
100 // pdgId W boson = 24
101 if ( !MC::isW(pdgId) || !isFinalParticle(part) ) continue;
102
103 // "part" is now a W boson
104 bPx=PxBofW(part);
105 bPy=PyBofW(part);
106 if (isFromTop(part)){
107 if (pdgId > 0) {
108 topChildrenPx=( part->px() + bPx );
109 topChildrenPy=( part->py() + bPy );
110 }
111 else {
112 topbarChildrenPx=( part->px() + bPx );
113 topbarChildrenPy=( part->py() + bPy );
114 }
115
116 if (isHadronic(part)){
117 double pT = sqrt( pow( part->px() + bPx,2) + pow( part->py() + bPy,2));
118 if (pT > hadtopChildrenPt){
119 hadtopChildrenPt = pT;
120 if (pdgId > 0) hadtopPt = topPt;
121 else hadtopbarPt = topbarPt;
122 }
123 } // isHadronic
124 } // isFromTop
125 } // particle loop
126 } // event loop
127
128
129 double TTBarSysPt = sqrt( pow( topPx + topbarPx , 2 ) + pow( topPy + topbarPy , 2 ));
130 double TTBarChildrenSysPt = sqrt( pow( topChildrenPx + topbarChildrenPx , 2 ) + pow( topChildrenPy + topbarChildrenPy , 2 ));
131
132 if (m_cutPtOf == 0){ // cut on the pT of top on the truth list
133 if (hadtopPt >= tHadPtCut || hadtopbarPt >= tHadPtCut ) passTopHad = true;
134 if (TTBarSysPt >= tPairPtCut ) passTopPair = true;
135 }
136 else if( m_cutPtOf == 1){ // cut on the pT of top decay products (b, q, qbar') on the truth list
137 if (hadtopChildrenPt >= tHadPtCut ) passTopHad = true;
138 if (TTBarChildrenSysPt >= tPairPtCut ) passTopPair = true;
139 }
140
141
142 //return which flags were passed
143 if ( !passTopPair && !passTopHad) filterCode = 0;
144 if ( passTopPair && !passTopHad) filterCode = 1;
145 if ( !passTopPair && passTopHad ) filterCode = 2;
146 if ( passTopPair && passTopHad ) filterCode = 3;
147 return filterCode;
148}
#define ATH_MSG_WARNING(x)
constexpr int pow(int base, int exp) noexcept
ServiceHandle< StoreGateSvc > & evtStore()
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool isW(const T &p)
static const int TQUARK
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
TruthEventContainer_v1 TruthEventContainer
Declare the latest version of the truth event container.
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ finalize()

StatusCode DerivationFramework::BoostedHadTopAndTopPairFilterTool::finalize ( )
virtual

Definition at line 30 of file BoostedHadTopAndTopPairFilterTool.cxx.

30{return StatusCode::SUCCESS;}

◆ findInitial()

const xAOD::TruthParticle * DerivationFramework::BoostedHadTopAndTopPairFilterTool::findInitial ( const xAOD::TruthParticle * part) const
private

Definition at line 150 of file BoostedHadTopAndTopPairFilterTool.cxx.

150 {
151
152 if(!part->nParents()) return part;
153
154 for(unsigned int i=0; i<part->nParents(); ++i){
155 const xAOD::TruthParticle* parent = part->parent(i);
156 if( part->pdgId() == parent->pdgId() ) return findInitial(parent);
157 }
158
159 return part;
160}
const xAOD::TruthParticle * findInitial(const xAOD::TruthParticle *part) const

◆ initialize()

StatusCode DerivationFramework::BoostedHadTopAndTopPairFilterTool::initialize ( )
virtual

Definition at line 27 of file BoostedHadTopAndTopPairFilterTool.cxx.

27{ATH_MSG_INFO("Initialize " ); return StatusCode::SUCCESS; }
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isFinalParticle()

bool DerivationFramework::BoostedHadTopAndTopPairFilterTool::isFinalParticle ( const xAOD::TruthParticle * part) const
private

Definition at line 186 of file BoostedHadTopAndTopPairFilterTool.cxx.

186 {
187 int type = part->pdgId();
188 for(unsigned j = 0; j < part->nChildren(); j++){
189 const xAOD::TruthParticle* child = part->child(j);
190 int childtype = child->pdgId();
191 if( childtype == type ) return false;
192 }
193
194 return true;
195
196}
int pdgId() const
PDG ID code.

◆ isFromTop()

bool DerivationFramework::BoostedHadTopAndTopPairFilterTool::isFromTop ( const xAOD::TruthParticle * part) const
private

Definition at line 163 of file BoostedHadTopAndTopPairFilterTool.cxx.

163 {
164
165 if(!part->nParents()) return false;
166
167 for(unsigned int i=0; i<part->nParents(); ++i){
168 const xAOD::TruthParticle* parent = part->parent(i);
169 if( MC::isTop(parent->pdgId()) ) return true;
170 }
171
172 return false;
173}
bool isTop(const T &p)

◆ isHadronic()

bool DerivationFramework::BoostedHadTopAndTopPairFilterTool::isHadronic ( const xAOD::TruthParticle * part) const
private

Definition at line 176 of file BoostedHadTopAndTopPairFilterTool.cxx.

176 {
177
178 for(unsigned j = 0; j < part->nChildren(); j++){
179 const xAOD::TruthParticle* child = part->child(j);
180 if( abs(child->pdgId()) <= MC::BQUARK ) return true;
181 }
182 return false;
183}
static const int BQUARK

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ PxBofW()

double DerivationFramework::BoostedHadTopAndTopPairFilterTool::PxBofW ( const xAOD::TruthParticle * part) const
private

Definition at line 200 of file BoostedHadTopAndTopPairFilterTool.cxx.

200 {
201
202 const xAOD::TruthParticle* initpart = findInitial(part);
203
204 double px=0.0;
205
206 for(unsigned j = 0; j < initpart->nChildren(); j++){
207 const xAOD::TruthParticle* child = initpart->child(j);
208 if( MC::isBottom(child->pdgId()) ){
209 px = child->px();
210 }
211 }
212 return px;
213}
const TruthParticle_v1 * child(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
float px() const
The x component of the particle's momentum.
size_t nChildren() const
Number of children of this particle.
bool isBottom(const T &p)

◆ PyBofW()

double DerivationFramework::BoostedHadTopAndTopPairFilterTool::PyBofW ( const xAOD::TruthParticle * part) const
private

Definition at line 216 of file BoostedHadTopAndTopPairFilterTool.cxx.

216 {
217
218 const xAOD::TruthParticle* initpart = findInitial(part);
219
220 double py=0.0;
221
222 for(unsigned j = 0; j < initpart->nChildren(); j++){
223 const xAOD::TruthParticle* child = initpart->child(j);
224 if( MC::isBottom( child->pdgId() ) ){
225 py = child->py();
226 }
227 }
228 return py;
229}
float py() const
The y component of the particle's momentum.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cutPtOf

int DerivationFramework::BoostedHadTopAndTopPairFilterTool::m_cutPtOf
private

Definition at line 39 of file BoostedHadTopAndTopPairFilterTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_mcName

std::string DerivationFramework::BoostedHadTopAndTopPairFilterTool::m_mcName
private

Definition at line 33 of file BoostedHadTopAndTopPairFilterTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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