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

#include <LArClusterCollisionTimeAlg.h>

Inheritance diagram for LArClusterCollisionTimeAlg:
Collaboration diagram for LArClusterCollisionTimeAlg:

Classes

struct  perSide_t

Public Member Functions

 ~LArClusterCollisionTimeAlg ()=default
StatusCode initialize () override final
 standard Athena-Algorithm method
StatusCode execute (const EventContext &ctx) const override final
 standard Athena-Algorithm method
StatusCode finalize () override final
 standard Athena-Algorithm method
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) 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 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

perSide_t analyseClustersPerSide (std::vector< const xAOD::CaloCluster * > &clusters) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::atomic< unsigned > m_nEvt {0}
std::atomic< unsigned > m_nCollEvt {0}
Gaudi::Property< float > m_timeCut { this, "timeDiffCut", 2., "max |A-C| time difference tu pass the filter" }
Gaudi::Property< size_t > m_maxClusters { this, "maxNClusters", 3, "how many clusters taken into sum" }
SG::ReadHandleKey< xAOD::CaloClusterContainerm_clusterContainerName {this, "InputName", "LArClusterEM"}
SG::WriteHandleKey< LArCollisionTimem_outputName {this, "OutputName", "LArClusterCollTime"}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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 19 of file LArClusterCollisionTimeAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~LArClusterCollisionTimeAlg()

LArClusterCollisionTimeAlg::~LArClusterCollisionTimeAlg ( )
default

Member Function Documentation

◆ analyseClustersPerSide()

LArClusterCollisionTimeAlg::perSide_t LArClusterCollisionTimeAlg::analyseClustersPerSide ( std::vector< const xAOD::CaloCluster * > & clusters) const
private

Definition at line 29 of file LArClusterCollisionTimeAlg.cxx.

29 {
30
32
33 //Sort clusters by Energy
34 std::sort(clusters.begin(),clusters.end(),[](const xAOD::CaloCluster* o1, const xAOD::CaloCluster* o2) {return o1->e() > o2->e();});
35
36 result.nClusters=std::min(m_maxClusters.value(),clusters.size());
37
38 if (result.nClusters>0) {
39 // Tell clang to optimize assuming that FP operations may trap.
41
42 for (size_t i=0;i<result.nClusters;++i) {
43 const xAOD::CaloCluster* clu=clusters[i];
44 result.time+=clu->time();
45 result.energy+=clu->e();
46 }
47
48 result.time/=(float)(result.nClusters);
49 result.energy/=(float)(result.nClusters);
50 }
51
52 return result;
53}
Gaudi::Property< size_t > m_maxClusters
flt_t time() const
Access cluster time.
virtual double e() const
The total energy of the particle.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
#define CXXUTILS_TRAPPING_FP
Definition trapping_fp.h:24

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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< Gaudi::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 LArClusterCollisionTimeAlg::execute ( const EventContext & ctx) const
finaloverride

standard Athena-Algorithm method

Definition at line 56 of file LArClusterCollisionTimeAlg.cxx.

56 {
57 ATH_MSG_DEBUG ("LArClusterCollisionTimeAlg execute()");
58
59 m_nEvt++;
60
61 // Get the cluster container
62 SG::ReadHandle<xAOD::CaloClusterContainer> cluster_container (m_clusterContainerName,ctx);
63 if( !cluster_container.isValid()) { // record empty object
64 ATH_MSG_WARNING ("Could not get ClusterContainer with key " << m_clusterContainerName);
65 // Construct the output object
66 SG::WriteHandle<LArCollisionTime> larTime (m_outputName,ctx);
67 ATH_CHECK( larTime.record (std::make_unique<LArCollisionTime>()) );
68 return StatusCode::SUCCESS;
69 }
70
71 std::vector<const xAOD::CaloCluster*> clustersEMECA,clustersEMECC;
72
73 const unsigned barrelPattern=CaloSampling::barrelPattern();
74
75 for(const xAOD::CaloCluster* pCluster : *cluster_container) {
76 if ((pCluster->samplingPattern() & barrelPattern) == 0 ) { //Take only clusters that have only endcap samplings, ignore barrel
77 if (pCluster->eta()>0.)
78 clustersEMECA.push_back(pCluster);
79 else
80 clustersEMECC.push_back(pCluster);
81 }
82 } //End loop over clusters
83
84 const perSide_t sideA=analyseClustersPerSide(clustersEMECA);
85 const perSide_t sideC=analyseClustersPerSide(clustersEMECC);
86
87 auto tmplarTime = std::make_unique<LArCollisionTime>(sideA.nClusters,sideC.nClusters,sideA.energy,sideC.energy,sideA.time,sideC.time);
88 // Construct the output object
89 SG::WriteHandle<LArCollisionTime> larTime (m_outputName,ctx);
90 if (! larTime.put (std::move (tmplarTime)) ) {
91 ATH_MSG_WARNING( "Could not record the LArCollisionTime object with key "<<m_outputName );
92 }
93
94 ATH_MSG_DEBUG("Number/Time/Energy, Side A: " << sideA.nClusters << "/" << sideA.time << "/" << sideA.energy);
95 ATH_MSG_DEBUG("Number/Time/Energy, Side C: " << sideC.nClusters << "/" << sideC.time << "/" << sideC.energy);
96
97 if ( sideA.nClusters>0 && sideC.nClusters>0 && std::fabs(sideA.time-sideC.time)<m_timeCut) {
98 setFilterPassed(true,ctx);
99 m_nCollEvt++;
100 }
101 else {
102 setFilterPassed(false,ctx);
103 }
104
105
106 return StatusCode::SUCCESS;
107}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
virtual void setFilterPassed(bool state, const EventContext &ctx) const
static constexpr unsigned int barrelPattern()
Get the bit-pattern for barrel samplings.
perSide_t analyseClustersPerSide(std::vector< const xAOD::CaloCluster * > &clusters) const
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterContainerName
SG::WriteHandleKey< LArCollisionTime > m_outputName
unsigned int constexpr sideC
Definition RPDUtils.h:15
unsigned int constexpr sideA
Definition RPDUtils.h:16

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::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 & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ finalize()

StatusCode LArClusterCollisionTimeAlg::finalize ( )
finaloverride

standard Athena-Algorithm method

Definition at line 21 of file LArClusterCollisionTimeAlg.cxx.

22 {
23
24 ATH_MSG_INFO( m_nCollEvt << "/" << m_nEvt << " Events found to be collision events with at least one cluster in each EM endcap." );
25 ATH_MSG_DEBUG ("LArClusterCollisionTimeAlg finalize()");
26 return StatusCode::SUCCESS;
27 }
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode LArClusterCollisionTimeAlg::initialize ( )
finaloverride

standard Athena-Algorithm method

Definition at line 11 of file LArClusterCollisionTimeAlg.cxx.

12 {
13 ATH_MSG_DEBUG ("LArClusterCollisionTimeAlg initialize()");
14 ATH_CHECK( m_clusterContainerName.initialize() );
15 ATH_CHECK( m_outputName.initialize() );
16 return StatusCode::SUCCESS;
17
18 }

◆ inputHandles()

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

◆ isClonable()

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::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< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
#define ATH_MSG_ERROR(x)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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 }

Member Data Documentation

◆ m_clusterContainerName

SG::ReadHandleKey<xAOD::CaloClusterContainer> LArClusterCollisionTimeAlg::m_clusterContainerName {this, "InputName", "LArClusterEM"}
private

Definition at line 61 of file LArClusterCollisionTimeAlg.h.

61{this, "InputName", "LArClusterEM"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_maxClusters

Gaudi::Property<size_t> LArClusterCollisionTimeAlg::m_maxClusters { this, "maxNClusters", 3, "how many clusters taken into sum" }
private

Definition at line 59 of file LArClusterCollisionTimeAlg.h.

59{ this, "maxNClusters", 3, "how many clusters taken into sum" };

◆ m_nCollEvt

std::atomic<unsigned> LArClusterCollisionTimeAlg::m_nCollEvt {0}
mutableprivate

Definition at line 53 of file LArClusterCollisionTimeAlg.h.

53{0};

◆ m_nEvt

std::atomic<unsigned> LArClusterCollisionTimeAlg::m_nEvt {0}
mutableprivate

Definition at line 52 of file LArClusterCollisionTimeAlg.h.

52{0};

◆ m_outputName

SG::WriteHandleKey<LArCollisionTime> LArClusterCollisionTimeAlg::m_outputName {this, "OutputName", "LArClusterCollTime"}
private

Definition at line 62 of file LArClusterCollisionTimeAlg.h.

62{this, "OutputName", "LArClusterCollTime"};

◆ m_timeCut

Gaudi::Property<float> LArClusterCollisionTimeAlg::m_timeCut { this, "timeDiffCut", 2., "max |A-C| time difference tu pass the filter" }
private

Definition at line 58 of file LArClusterCollisionTimeAlg.h.

58{ this, "timeDiffCut", 2., "max |A-C| time difference tu pass the filter" };

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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