ATLAS Offline Software
Loading...
Searching...
No Matches
TrackCaloClusterInfoAlg Class Reference

Builds a TrackCaloClusterInfo map which contains the weights needed to build TrackCaloCluster objects. More...

#include <TrackCaloClusterInfoAlg.h>

Inheritance diagram for TrackCaloClusterInfoAlg:
Collaboration diagram for TrackCaloClusterInfoAlg:

Public Member Functions

 TrackCaloClusterInfoAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~TrackCaloClusterInfoAlg ()
virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
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 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

virtual StatusCode fillInfo (SG::WriteHandle< TrackCaloClusterInfo > &tccInfo) const
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.

Protected Attributes

SG::WriteHandleKey< TrackCaloClusterInfom_tccInfoHandle {this, "TCCInfoName","TCCInfo","Name of TrackCaloClusterInfo to be created" }
 TrackCaloClusterInfo created by this alg.
SG::ReadHandleKey< xAOD::TrackParticleContainerm_inputTracksHandle {this, "InputTracks", "InDetTrackParticles", ""}
 Tracks used by this alg.
SG::ReadDecorHandleKey< xAOD::TrackParticleContainerm_assoClustersKey {this, "AssoClustersDecor", "", "Key to access clusters associated to a track. IMPORTANT must be consistent with TrackParticleContainer "}
 Decoration of tracks expected by this alg (set by TrackParticleClusterAssociationAlg)
SG::ReadHandleKey< xAOD::CaloClusterContainerm_inputClustersHandle {this, "InputClusters", "CaloCalTopoClusters","input calo clusters"}
 Original clusters from which the m_inputObjectName are build ()
SG::ReadHandleKey< xAOD::VertexContainerm_inputVertexHandle {this, "VertexContainer", "PrimaryVertices", "IMPORTANT : if blank all tracks will be considered, else only those from the PV[0] of VertexContainer"}
Gaudi::Property< bool > m_useEnergy {this, "UseEnergy", false,"wether to cut on E or pT"}
 use cluster energy or pt?

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

DataObjIDColl m_extendedExtraObjects
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

Builds a TrackCaloClusterInfo map which contains the weights needed to build TrackCaloCluster objects.

This TrackCaloClusterInfo is then expected to be used by a TrackCaloClusterAlg and its tools.

Authors
: Naomie Calace, P-A Delsart

Definition at line 32 of file TrackCaloClusterInfoAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrackCaloClusterInfoAlg()

TrackCaloClusterInfoAlg::TrackCaloClusterInfoAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 13 of file TrackCaloClusterInfoAlg.cxx.

13 :
14 AthAlgorithm( name, pSvcLocator ) {}
AthAlgorithm()
Default constructor:

◆ ~TrackCaloClusterInfoAlg()

virtual TrackCaloClusterInfoAlg::~TrackCaloClusterInfoAlg ( )
inlinevirtual

Definition at line 35 of file TrackCaloClusterInfoAlg.h.

35{}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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< Algorithm > >::evtStore ( )
inlineinherited

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

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode TrackCaloClusterInfoAlg::execute ( )
overridevirtual

Definition at line 30 of file TrackCaloClusterInfoAlg.cxx.

30 {
31 ATH_MSG_DEBUG ("Executing " << name() << "...");
32
33 // Prepare a TrackCaloClusterInfo map :
34 SG::WriteHandle<TrackCaloClusterInfo> tccInfo(m_tccInfoHandle);
35 ATH_CHECK( tccInfo.record( std::make_unique<TrackCaloClusterInfo>() ) );
36
37 // Retrieve the input containers
38 SG::ReadHandle<xAOD::CaloClusterContainer> clusterContainer(m_inputClustersHandle);
39 SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_inputTracksHandle);
40 SG::ReadHandle<xAOD::VertexContainer> vertices(m_inputVertexHandle);
41
42 tccInfo->allClusters = &*clusterContainer;
43 tccInfo->allTracks = &*tracks;
44
45 // retrieve PV0 if it exists
46 if(!vertices->empty()) {
47 tccInfo->pv0=(*vertices)[0]; // Hard code HS vertex as PV0 : WARNING we expect it is the same as was used for m_inputTrackCaloAssocName !!
48 } else {
49 ATH_MSG_ERROR ("Vertex container " << m_inputVertexHandle << " is empty! Can't perform TVA!");
50 return StatusCode::FAILURE;
51 }
52
53 // Fill the maps
54 ATH_CHECK( fillInfo(tccInfo) );
55
56 return StatusCode::SUCCESS;
57}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTracksHandle
Tracks used by this alg.
virtual StatusCode fillInfo(SG::WriteHandle< TrackCaloClusterInfo > &tccInfo) const
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClustersHandle
Original clusters from which the m_inputObjectName are build ()
SG::WriteHandleKey< TrackCaloClusterInfo > m_tccInfoHandle
TrackCaloClusterInfo created by this alg.
SG::ReadHandleKey< xAOD::VertexContainer > m_inputVertexHandle

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ fillInfo()

StatusCode TrackCaloClusterInfoAlg::fillInfo ( SG::WriteHandle< TrackCaloClusterInfo > & tccInfo) const
protectedvirtual

Reimplemented in TrackCaloClusterInfoUFOAlg.

Definition at line 60 of file TrackCaloClusterInfoAlg.cxx.

60 {
61
62 std::multimap <const xAOD::IParticle*, const xAOD::TrackParticle*> clusterToTracksMap;
63
64 SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<ElementLink<xAOD::CaloClusterContainer>> > clusterLinks(m_assoClustersKey);
65 static const xAOD::IParticle::FourMom_t nullV(0,0,0,0);
66
67 for(const xAOD::TrackParticle* trk : *tccInfo->allTracks){
68 const auto & clustLinks = clusterLinks( *trk );
69 if(clustLinks.empty() ) continue;
70 // follow the link to the calorimeter clusters
71 for( const auto& clLink : clustLinks) {
72 const xAOD::IParticle* cluster = *clLink;
73 clusterToTracksMap.insert(std::make_pair(cluster, trk));
74 // find FourMom_t for trk or insert (0,0,0,0) if not yet in map :
75 xAOD::IParticle::FourMom_t & totalP4 = ( tccInfo->trackTotalClusterPt.insert( {trk, nullV} ) ).first->second;
76 totalP4 += cluster->p4(); // add the cluster p4 into the map.
77 }
78 }
79
80
81 // Create cluster-to-tracks weight map
82 for (std::pair<const xAOD::IParticle*, const xAOD::TrackParticle*> entry : clusterToTracksMap)
83 {
84 const xAOD::IParticle* cluster = entry.first;
85 double cluster_pt = m_useEnergy ? cluster->e() : cluster->pt();
86 double totalcluster_pt = m_useEnergy ? tccInfo->trackTotalClusterPt.at(entry.second).E() : tccInfo->trackTotalClusterPt.at(entry.second).Pt();
87
88 // find FourMom_t for trk or insert (0,0,0,0) if not yet in map :
89 xAOD::IParticle::FourMom_t & totalP4 = ( tccInfo->clusterToTracksWeightMap.insert( {cluster, nullV} ) ).first->second;
90 totalP4 += entry.second->p4() * (cluster_pt/totalcluster_pt); // add the track p4 into the map.
91 }
92
93
94 return StatusCode::SUCCESS;
95}
Gaudi::Property< bool > m_useEnergy
use cluster energy or pt?
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_assoClustersKey
Decoration of tracks expected by this alg (set by TrackParticleClusterAssociationAlg)
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
virtual double pt() const =0
The transverse momentum ( ) of the particle.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
virtual double e() const =0
The total energy of the particle.
bool first
Definition DeMoScan.py:534
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ initialize()

StatusCode TrackCaloClusterInfoAlg::initialize ( )
overridevirtual

Reimplemented in TrackCaloClusterInfoUFOAlg.

Definition at line 17 of file TrackCaloClusterInfoAlg.cxx.

17 {
18 ATH_MSG_DEBUG ("Initializing " << name() << "...");
19 ATH_CHECK(m_inputClustersHandle.initialize() );
20 ATH_CHECK(m_inputTracksHandle.initialize() );
21 ATH_CHECK(m_inputVertexHandle.initialize());
22 ATH_CHECK(m_tccInfoHandle.initialize());
23
24 ATH_CHECK(m_assoClustersKey.initialize());
25
26 return StatusCode::SUCCESS;
27}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::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.

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Algorithm >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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_assoClustersKey

SG::ReadDecorHandleKey<xAOD::TrackParticleContainer> TrackCaloClusterInfoAlg::m_assoClustersKey {this, "AssoClustersDecor", "", "Key to access clusters associated to a track. IMPORTANT must be consistent with TrackParticleContainer "}
protected

Decoration of tracks expected by this alg (set by TrackParticleClusterAssociationAlg)

Definition at line 52 of file TrackCaloClusterInfoAlg.h.

52{this, "AssoClustersDecor", "", "Key to access clusters associated to a track. IMPORTANT must be consistent with TrackParticleContainer "};

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_inputClustersHandle

SG::ReadHandleKey<xAOD::CaloClusterContainer> TrackCaloClusterInfoAlg::m_inputClustersHandle {this, "InputClusters", "CaloCalTopoClusters","input calo clusters"}
protected

Original clusters from which the m_inputObjectName are build ()

Definition at line 55 of file TrackCaloClusterInfoAlg.h.

55{this, "InputClusters", "CaloCalTopoClusters","input calo clusters"};

◆ m_inputTracksHandle

SG::ReadHandleKey< xAOD::TrackParticleContainer > TrackCaloClusterInfoAlg::m_inputTracksHandle {this, "InputTracks", "InDetTrackParticles", ""}
protected

Tracks used by this alg.

Definition at line 50 of file TrackCaloClusterInfoAlg.h.

50{this, "InputTracks", "InDetTrackParticles", ""};

◆ m_inputVertexHandle

SG::ReadHandleKey<xAOD::VertexContainer> TrackCaloClusterInfoAlg::m_inputVertexHandle {this, "VertexContainer", "PrimaryVertices", "IMPORTANT : if blank all tracks will be considered, else only those from the PV[0] of VertexContainer"}
protected

Definition at line 57 of file TrackCaloClusterInfoAlg.h.

57{this, "VertexContainer", "PrimaryVertices", "IMPORTANT : if blank all tracks will be considered, else only those from the PV[0] of VertexContainer"};

◆ m_tccInfoHandle

SG::WriteHandleKey<TrackCaloClusterInfo> TrackCaloClusterInfoAlg::m_tccInfoHandle {this, "TCCInfoName","TCCInfo","Name of TrackCaloClusterInfo to be created" }
protected

TrackCaloClusterInfo created by this alg.

Definition at line 45 of file TrackCaloClusterInfoAlg.h.

45{this, "TCCInfoName","TCCInfo","Name of TrackCaloClusterInfo to be created" };

◆ m_useEnergy

Gaudi::Property<bool> TrackCaloClusterInfoAlg::m_useEnergy {this, "UseEnergy", false,"wether to cut on E or pT"}
protected

use cluster energy or pt?

Definition at line 60 of file TrackCaloClusterInfoAlg.h.

60{this, "UseEnergy", false,"wether to cut on E or pT"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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