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

#include <ClusterDumper.h>

Inheritance diagram for ClusterDumper:
Collaboration diagram for ClusterDumper:

Public Member Functions

 ClusterDumper (const std::string &name, ISvcLocator *svcLoc)
 Regular algorithm constructor.
virtual StatusCode initialize ()
 Function initialising the algorithm.
virtual StatusCode execute ()
 Function executing the algorithm.
virtual StatusCode finalize ()
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

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

SG::ReadHandleKey< xAOD::CaloClusterContainerm_containerName {this,"ContainerName","CaloCalTopoClusters"}
 The key for the output xAOD::CaloClusterContainer.
std::string m_fileName
std::ostream * m_out
std::ofstream m_fileOut
std::mutex m_fileMutex
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

Definition at line 22 of file ClusterDumper.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

◆ ClusterDumper()

ClusterDumper::ClusterDumper ( const std::string & name,
ISvcLocator * svcLoc )

Regular algorithm constructor.

Definition at line 16 of file ClusterDumper.cxx.

18 : AthAlgorithm( name, svcLoc ),
19 m_out(&std::cout)
20{
21 declareProperty( "FileName",m_fileName);
22
23}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::ostream * m_out
std::string m_fileName

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 }

◆ 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 ClusterDumper::execute ( )
virtual

Function executing the algorithm.

Definition at line 56 of file ClusterDumper.cxx.

56 {
57
58 //const xAOD::CaloClusterContainer* clustercontainer = nullptr;
59 SG::ReadHandle<xAOD::CaloClusterContainer> clustercontainer{m_containerName};
60 ATH_MSG_DEBUG( "Retrieved clusters with key: " << m_containerName.key() );
61
62 const CaloClusterCellLinkContainer* cclptr=nullptr;
64 CHECK(evtStore()->retrieve(cclptr,m_containerName.key()+"_links"));
65 ATH_MSG_INFO("Found corresponding cell-link container with size " << cclptr->size());
66 }
67 else
68 ATH_MSG_INFO("Did not find corresponding cell-link container");
69
70 std::lock_guard<std::mutex> fileLock{m_fileMutex};
71 for (const auto itr: *clustercontainer) {
72 const xAOD::CaloCluster& cluster=*itr;
73 (*m_out) << "Kinematics :" << std::endl;
74 (*m_out) << "E=" << cluster.e() << ", eta=" << cluster.eta() << ", phi=" << cluster.phi() << ", m=" << cluster.m() << ", pt=" << cluster.pt() << std::endl;
75 (*m_out) << "Eta0=" << cluster.eta0() << ", Phi0=" << cluster.phi0() << std::endl;
76
77 (*m_out) << "TLorentzVector :" << std::endl;
78 const xAOD::CaloCluster::FourMom_t& p4=cluster.p4();
79 (*m_out) << " p4.E=" << p4.E() << ", x=" << p4.X() << ", y=" << p4.Y() << ", z=" << p4.Z() << ", m=" << p4.M() << ", pt=" << p4.Pt() << std::endl;
80
81 (*m_out) << "Sampling variables :" << std::endl;
82 for (unsigned iSamp=0;iSamp<CaloSampling::Unknown;++iSamp) {
84 if (cluster.hasSampling(s)) {
85 (*m_out) << " Sampling #" << s << ": E=" << cluster.eSample(s) << ", eta=" << cluster.etaSample(s) << ", phi=" << cluster.phiSample(s) << std::endl;
86 }
87 }
88
89
90
91 //(*m_out) << "Auxiliary variables: " << std::endl;
92 // const SG::auxid_set_t& auxIds=cluster.container()->getAuxIDs(); //->getDynamicAuxIDs();
93 // const size_t idx= cluster.index();
94 // for (auto ai: auxIds) {
95 // const std::string& auxName=SG::AuxTypeRegistry::instance().getName(ai);
96 // const std::type_info* ti=SG::AuxTypeRegistry::instance().getType (ai);
97 // if ((*ti)==typeid(float)) {
98 // const float v=clustercontainer->getData<float>(ai,idx);
99 // (*m_out) << " Index=" <<idx << ", Auxid=" << ai << ", Name=" << auxName << " value=" << v << std::endl;
100 // }
101 // else
102 // (*m_out) << " Index=" <<idx << ", Auxid=" << ai << ", Name=" << auxName << ", unknown type" << ti->name() << std::endl;
103 // }
104
105 constexpr auto allMoments=std::to_array<const char*>({"FIRST_PHI","FIRST_ETA","SECOND_R","SECOND_LAMBDA","DELTA_PHI","DELTA_THETA","DELTA_ALPHA","CENTER_X","CENTER_Y","CENTER_Z","CENTER_MAG","CENTER_LAMBDA","LATERAL","LONGITUDINAL","ENG_FRAC_EM","ENG_FRAC_MAX","ENG_FRAC_CORE","FIRST_ENG_DENS","SECOND_ENG_DENS","ISOLATION","ENG_BAD_CELLS","N_BAD_CELLS","N_BAD_CELLS_CORR","BAD_CELLS_CORR_E","BADLARQ_FRAC","ENG_POS","SIGNIFICANCE","CELL_SIGNIFICANCE","CELL_SIG_SAMPLING","AVG_LAR_Q","AVG_TILE_Q","EM_PROBABILITY","HAD_WEIGHT","OOC_WEIGHT","DM_WEIGHT","TILE_CONFIDENCE_LEVEL","VERTEX_FRACTION","NVERTEX_FRACTION","ENG_CALIB_TOT","ENG_CALIB_OUT_L","ENG_CALIB_OUT_M","ENG_CALIB_OUT_T","ENG_CALIB_DEAD_L","ENG_CALIB_DEAD_M","ENG_CALIB_DEAD_T","ENG_CALIB_EMB0","ENG_CALIB_EME0","ENG_CALIB_TILEG3","ENG_CALIB_DEAD_TOT","ENG_CALIB_DEAD_EMB0","ENG_CALIB_DEAD_TILE0","ENG_CALIB_DEAD_TILEG3","ENG_CALIB_DEAD_EME0","ENG_CALIB_DEAD_HEC0","ENG_CALIB_DEAD_FCAL","ENG_CALIB_DEAD_LEAKAGE","ENG_CALIB_DEAD_UNCLASS","ENG_CALIB_FRAC_EM","ENG_CALIB_FRAC_HAD","ENG_CALIB_FRAC_REST", "ENERGY_Truth"});
106 (*m_out) << "Cluster Moments" << std::endl;
107 for (const auto& momName : allMoments) {
108 SG::AuxElement::Accessor<float> a(momName);
109 if (a.isAvailable(cluster)) {
110 float v = a(cluster);
111 (*m_out) << " " << momName << ": " << v << std::endl;
112 }
113 }
114
116 if (a.isAvailable(cluster)) {
117 (*m_out) << "Bad Channel data: " << std::endl;
118 for (const auto& bc : cluster.badChannelList()) {
119 (*m_out) << " eta=" << bc.eta() << ", phi=" << bc.phi() << ", layer=" << bc.layer() << ", word=" << bc.badChannel() << std::endl;
120 }
121 }
122
123 (*m_out) << "Cell-links:" << std::endl;
124 const CaloClusterCellLink* cellLinks=cluster.getCellLinks();
125 if (cellLinks) {
126// (*m_out) << " Total: " << cellLinks->size() << std::endl;
127 CaloClusterCellLink::const_iterator lnk_it=cellLinks->begin();
128 CaloClusterCellLink::const_iterator lnk_it_e=cellLinks->end();
129 for (;lnk_it!=lnk_it_e;++lnk_it) {
130 const CaloCell* cell=*lnk_it;
131 (*m_out) << " ID=" << std::hex << cell->ID() << std::dec << ", E=" << cell->e() << ", weight=" << lnk_it.weight() << std::endl;
132 }
133 }
134 else
135 (*m_out) << " No Cell Links found" << std::endl;
136
137 }//end loop over clusters
138
139 return StatusCode::SUCCESS;
140}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current CaloClusterCellLinkContainer
Definition CaloTPCnv.cxx:95
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t a
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_containerName
The key for the output xAOD::CaloClusterContainer.
std::mutex m_fileMutex
size_type size() const noexcept
Returns the number of elements in the collection.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters)
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
float eSample(const CaloSample sampling) const
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
flt_t eta0() const
Returns raw of cluster seed.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
CaloSampling::CaloSample CaloSample
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
const CaloClusterBadChannelList & badChannelList() const
flt_t phi0() const
Returns raw of cluster seed.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ 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

◆ finalize()

StatusCode ClusterDumper::finalize ( )
virtual

Definition at line 49 of file ClusterDumper.cxx.

49 {
50 if (m_fileOut.is_open()) {
51 m_fileOut.close();
52 }
53 return StatusCode::SUCCESS;
54}
std::ofstream m_fileOut

◆ initialize()

StatusCode ClusterDumper::initialize ( )
virtual

Function initialising the algorithm.

Definition at line 25 of file ClusterDumper.cxx.

25 {
26 ATH_MSG_INFO( "Initializing" );
27
28 std::lock_guard<std::mutex> fileLock{m_fileMutex};
29 if (!m_fileName.empty()) {
31 if (m_fileOut.is_open()) {
33 ATH_MSG_INFO("Writing to file " << m_fileName);
34 }
35 else {
36 msg(MSG::ERROR) << "Failed to open file " << m_fileName << endmsg;
37 return StatusCode::FAILURE;
38 }
39 }
40 else {
41 ATH_MSG_INFO("Writing to stdout");
42 }
43
44 ATH_CHECK(m_containerName.initialize());
45 return StatusCode::SUCCESS;
46}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
MsgStream & msg() const

◆ 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_ERROR(x)
#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_containerName

SG::ReadHandleKey<xAOD::CaloClusterContainer> ClusterDumper::m_containerName {this,"ContainerName","CaloCalTopoClusters"}
private

The key for the output xAOD::CaloClusterContainer.

Definition at line 39 of file ClusterDumper.h.

39{this,"ContainerName","CaloCalTopoClusters"};

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

std::mutex ClusterDumper::m_fileMutex
private

Definition at line 45 of file ClusterDumper.h.

◆ m_fileName

std::string ClusterDumper::m_fileName
private

Definition at line 40 of file ClusterDumper.h.

◆ m_fileOut

std::ofstream ClusterDumper::m_fileOut
private

Definition at line 43 of file ClusterDumper.h.

◆ m_out

std::ostream* ClusterDumper::m_out
private

Definition at line 42 of file ClusterDumper.h.

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