ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::GenParticleJetFinder Class Reference

Durham jet clustering algorithm for MC-truth tracks. More...

#include <GenParticleJetFinder.h>

Inheritance diagram for Trk::GenParticleJetFinder:
Collaboration diagram for Trk::GenParticleJetFinder:

Public Member Functions

 GenParticleJetFinder (const std::string &type, const std::string &name, const IInterface *parent)
 ~GenParticleJetFinder ()
virtual StatusCode initialize ()
 initialize
virtual StatusCode finalize ()
 finalize
virtual std::vector< Trk::GenParticleJet > * jetMCFinder (std::vector< HepMC::ConstGenParticlePtr > &) const
 main method returning vector of truth-jets
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

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Interface ID, declared here, and defined below.

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

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

float m_yijCut
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

Durham jet clustering algorithm for MC-truth tracks.

ycut value is a job option

Author
Loek Hooft van Huysduynen, Wolfgang Liebig

Definition at line 29 of file GenParticleJetFinder.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

◆ GenParticleJetFinder()

Trk::GenParticleJetFinder::GenParticleJetFinder ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 15 of file GenParticleJetFinder.cxx.

16 : AthAlgTool (type,name,parent),
17 m_yijCut (0.003)
18{
19 declareInterface<IGenParticleJetFinder>(this);
20
22}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~GenParticleJetFinder()

Trk::GenParticleJetFinder::~GenParticleJetFinder ( )
inline

Definition at line 35 of file GenParticleJetFinder.h.

35{}

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

◆ finalize()

StatusCode Trk::GenParticleJetFinder::finalize ( )
virtual

finalize

Definition at line 35 of file GenParticleJetFinder.cxx.

35 {
36 ATH_MSG_INFO ( "starting finalize() in " << name() );
37 return StatusCode::SUCCESS;
38}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode Trk::GenParticleJetFinder::initialize ( )
virtual

initialize

Definition at line 27 of file GenParticleJetFinder.cxx.

27 {
28 ATH_MSG_INFO ("initialise in " << name() );
29 return StatusCode::SUCCESS;
30}

◆ 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.

◆ interfaceID()

const InterfaceID & Trk::IGenParticleJetFinder::interfaceID ( )
inlinestaticinherited

Interface ID, declared here, and defined below.

Definition at line 54 of file IGenParticleJetFinder.h.

54 {
56}
static const InterfaceID IID_IGenParticleJetFinder("IGenParticleJetFinder", 1, 0)

◆ jetMCFinder()

std::vector< Trk::GenParticleJet > * Trk::GenParticleJetFinder::jetMCFinder ( std::vector< HepMC::ConstGenParticlePtr > & GenStableCharged) const
virtual

main method returning vector of truth-jets

jetMCFinder

Implements Trk::IGenParticleJetFinder.

Definition at line 43 of file GenParticleJetFinder.cxx.

44{
45 if (GenStableCharged.empty()) {
46 ATH_MSG_INFO ("no selected charged particles!");
47 return nullptr;
48 }
49 std::vector< Trk::GenParticleJet >* myJets
50 = new std::vector< Trk::GenParticleJet >;
51 ATH_MSG_DEBUG ( "start jetMCFinder() with input GenParticle-vector "
52 << "of size " << GenStableCharged.size() );
53
54 myJets->clear();
55 double totalEnergyFromTracks=0.;
56 int partIterations=0;
57 double yijmin=100.;
58 bool combineParticles = false;
59
60 std::vector<Trk::GenParticleJet>::iterator iAtMin, jAtMin;
61
62 for( auto i = GenStableCharged.begin() ; i < GenStableCharged.end(); ++i){
63 totalEnergyFromTracks = totalEnergyFromTracks + (*i)->momentum().e();
64 Trk::GenParticleJet tempPJ;
65 tempPJ.addParticle( *i, int(i - GenStableCharged.begin()) );
66 myJets->push_back(tempPJ);
67 }
68
69 int numParts = myJets->size();
70 do {
71 combineParticles = false;
72 yijmin=100.;
73 for( std::vector<Trk::GenParticleJet>::iterator i = myJets->begin() ; i<myJets->end(); ++i) {
74
75 for( std::vector<Trk::GenParticleJet>::iterator j = myJets->begin() ; j<myJets->end(); ++j) {
76
77 if (i!=j) {
78
79 double yij=0;
80 double absI= sqrt((i->getMomentum()).dot(i->getMomentum()));
81 double absJ= sqrt(((*j).getMomentum()).dot((*j).getMomentum()));
82 double IdotJ= (((*i).getMomentum()).dot((*j).getMomentum()));
83 if (fabs(absI*absJ)<0.000001 || fabs(totalEnergyFromTracks)<0.00001) {
84
85 ATH_MSG_WARNING ("JetMCFinder: momenta / total energy is 0, "
86 << "can't continue calculations." );
87 delete myJets;
88 return nullptr;
89
90 } else {
91 yij=2*(i->getEnergy())*(j->getEnergy())/pow(totalEnergyFromTracks,2)*(1-(IdotJ/(absI*absJ)));
92 if (yij<yijmin) {
93
94 combineParticles=true;
95 yijmin=yij;
96 iAtMin=i;
97 jAtMin=j;
98
99 };
100 };
101 }
102 }
103 }
104 partIterations++;
105
106 /* If one pair of particles are found which have the required minimal */
107
108 if (combineParticles) {
109
110 ATH_MSG_VERBOSE ("combining: " << (*iAtMin).getNumParticles()
111 << " ("<<(*iAtMin).getIndicesInEvent().size()<<")"
112 << " and "<< (*jAtMin).getNumParticles()
113 << " ("<<(*jAtMin).getIndicesInEvent().size()<<")" );
114 if((*iAtMin).getNumParticles()>(*jAtMin).getNumParticles()) {
115
116 auto partsTemp = (*jAtMin).getParticles();
117 std::vector<int> indexTemp = (*jAtMin).getIndicesInEvent();
118 // int partsTempSize = partsTemp.size();
119 if (!partsTemp.empty()) {
120
121 std::vector<int>::iterator ki=indexTemp.begin();
122 for (auto k =partsTemp.begin(); k!=partsTemp.end(); ++k, ++ki) {
123 (*iAtMin).addParticle(*k,*ki);
124 }
125 } else {
126
127 ATH_MSG_WARNING ("No particles in this jet, logic failed, stop finder." );
128 delete myJets;
129 return nullptr;
130 }
131 myJets->erase(jAtMin);
132 }
133 else {
134
135 auto partsTemp = (*iAtMin).getParticles();
136 std::vector<int> indexTemp = (*iAtMin).getIndicesInEvent();
137 if (!partsTemp.empty()) {
138
139 std::vector<int>::iterator ki=indexTemp.begin();
140 for (auto k =partsTemp.begin(); k!=partsTemp.end(); ++k, ++ki) {
141 // tempPartJet.addParticle(*k);
142 (*jAtMin).addParticle(*k,*ki);
143 }
144 }
145 else {
146 ATH_MSG_WARNING ( "No particles in this jet, logic failed, stop finder." );
147 delete myJets;
148 return nullptr;
149 }
150 myJets->erase(iAtMin);
151 }
152 }
153 int currentNumParts = 0;
154 for(std::vector<Trk::GenParticleJet>::iterator k = myJets->begin(); k<myJets->end(); ++k)
155 currentNumParts = currentNumParts + k->getNumParticles();
156
157 if(numParts != currentNumParts){
158 ATH_MSG_WARNING ( "Losing particles in jets!!" );
159 delete myJets;
160 return nullptr;
161 }
162 if(partIterations==999)
163 ATH_MSG_INFO ( "JetMCFinder cut off because of too many (1000) iterations");
164
165 } while (yijmin<m_yijCut && partIterations<1000);
166 return myJets;
167}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
constexpr int pow(int base, int exp) noexcept
void addParticle(HepMC::ConstGenParticlePtr part, int indexInEvent=-1)
dot(G, fn, nodesToHighlight=[])
Definition dot.py:5

◆ 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.

◆ 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_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_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.

◆ m_yijCut

float Trk::GenParticleJetFinder::m_yijCut
private

Definition at line 44 of file GenParticleJetFinder.h.


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