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

#include <CaloCellDumper.h>

Inheritance diagram for CaloCellDumper:
Collaboration diagram for CaloCellDumper:

Public Member Functions

 CaloCellDumper (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode execute () override
virtual StatusCode finalize () 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

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

std::ofstream m_outfile
std::ifstream m_reffile
SG::ReadHandleKey< CaloCellContainerm_key {this,"InputContainer","AllCalo","Input CaloCellContainer key"}
Gaudi::Property< std::string > m_fileName {this,"FileName","CaloCells.txt","Name of the output text file"}
Gaudi::Property< std::string > m_refName {this,"RefName","","Name of reference file to which cells are to be compared."}
Gaudi::Property< float > m_eCut {this,"EnergyCut",std::numeric_limits<float>::lowest(),"Energy cut for cell dumping"}
Gaudi::Property< bool > m_compact {this,"Compact",true,"compact or detailed cell identifer"}
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 15 of file CaloCellDumper.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

◆ CaloCellDumper()

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

Definition at line 23 of file CaloCellDumper.cxx.

23 :
24 AthAlgorithm(name,pSvcLocator) {}
AthAlgorithm()
Default constructor:

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 CaloCellDumper::execute ( )
overridevirtual

Definition at line 62 of file CaloCellDumper.cxx.

62 {
63
64 bool badCompare = false;
65 const EventContext& ctx = getContext();
66
67 SG::ReadHandle<CaloCellContainer> cells{m_key,ctx};
68
69 const unsigned evt=ctx.eventID().event_number();
70 m_outfile << "Event " << evt << " contains " << cells->size() << " CaloCells" << std::endl;
71 m_outfile << "ID\tEnergy\tTime\tQual\tprov" << std::endl;
72
73 if (m_reffile.is_open()) {
74 std::string Event, contains, CaloCells;
75 size_t evt_in, cells_size_in;
76 m_reffile >> Event >> evt_in >> contains >> cells_size_in >> CaloCells;
77 if (!m_reffile.good() || evt_in != evt || cells_size_in != cells->size())
78 {
79 ATH_MSG_ERROR ("Reference file miscompare. Read: " <<
80 Event << " " << evt_in << " " << contains << " "
81 << cells_size_in << " " << CaloCells <<
82 "; expected event number " << evt << " and cell count " <<
83 cells->size());
84 badCompare = true;
85 }
86
87 std::string ID, Energy, Time, Qual, prov;
88 m_reffile >> ID >> Energy >> Time >> Qual >> prov;
89 if (!m_reffile.good()) {
90 ATH_MSG_ERROR ("Bad read of reference file header: " <<
91 ID << " " << Energy << " " << Time << " " <<
92 Qual << " " << prov);
93 badCompare = true;
94 }
95 }
96
97 double remainingEne=0;
98 unsigned nRemaining=0;
99
100 for (const auto *cell : *cells) {
101 if (cell->e()>m_eCut.value()) {
102 std::stringstream id;
103 if (!m_compact.value()) {
104 const CaloDetDescrElement* dde=cell->caloDDE();
105 if (dde->is_lar_em_barrel()) {
106 id << "LAr Bar";
107 }
108 else if (dde->is_lar_em_endcap_inner()){
109 id << "LAR ECI";
110 }
111 else if (dde->is_lar_em_endcap_outer()){
112 id << "LAR ECO";
113 }
114 else if (dde->is_lar_hec()) {
115 id << "LAr_HEC";
116 }
117 else if (dde->is_lar_fcal()) {
118 id << "LAr_FCAL";
119 }
120 else if (dde->is_tile()) {
121 id << "TILE ";
122 }
123 else {
124 id << "UNKNOWN";
125 }
126 id << ", samp=" << dde->getSampling() << ", ";
127 }
128
129 m_outfile << id.str() << "0x" << std::hex << cell->ID().get_identifier32().get_compact() << std::dec
130 //m_outfile <<
131 << "\t" << cell->e() << "\t" << cell->time() << "\t" << cell->gain()
132 << "\t" << cell->quality() << "\t0x" << std::hex << cell->provenance() << std::dec << std::endl;
133 if (m_reffile.is_open()) {
134 unsigned id_in;
135 float energy_in, time_in;
136 int quality_in, provenance_in, gain_in;
137 if (!m_compact) {
138 std::string id, samp;
139 m_reffile >> id >> samp;
140 }
141 m_reffile >> std::hex >> id_in >> std::dec >> energy_in >> time_in >>
142 gain_in >> quality_in >> std::hex >> provenance_in >> std::dec;
143 if (!m_reffile.good() ||
144 !isEqual (energy_in, cell->e(), 1e-5) ||
145 !isEqual (time_in, cell->time(), 1e-5) ||
146 id_in != cell->ID().get_identifier32().get_compact() ||
147 gain_in != cell->gain() ||
148 quality_in != cell->quality() ||
149 provenance_in != cell->provenance())
150 {
151 ATH_MSG_ERROR ("Bad read of reference file: " <<
152 std::hex << "0x" << id_in << " " << std::dec <<
153 energy_in << " "
154 << time_in << " " <<
155 gain_in << " " << quality_in << " " <<
156 std::hex << "0x" << provenance_in << std::dec);
157 ATH_MSG_ERROR ("Expected " << id.str() << "0x" << std::hex <<
158 cell->ID().get_identifier32().get_compact() << std::dec << " " <<
159 cell->e() << " " << cell->time() << " "
160 << cell->gain() << " " <<
161 cell->quality() << " 0x" << std::hex << cell->provenance() << std::dec);
162 badCompare = true;
163 }
164 }
165 }
166 else {//not bigger that m_eCut
167 ++nRemaining;
168 remainingEne+=cell->e();
169 }
170 }
171 if (nRemaining) {
172 m_outfile << "Sum of " << nRemaining << " cell energies: " << remainingEne << std::endl;
173 if (m_reffile.is_open()) {
174 std::string Sum, Of, Cell, Energies;
175 unsigned nRemaining_in;
176 float remainingEne_in;
177 m_reffile >> Sum >> Of >> nRemaining_in >> Cell >> Energies >>
178 remainingEne_in;
179 if (!m_reffile.good() ||
180 nRemaining_in != nRemaining ||
181 !isEqual (remainingEne_in, remainingEne))
182 {
183 ATH_MSG_ERROR ("Bad read of reference file: " <<
184 Sum << Of << nRemaining_in << Cell << Energies <<
185 remainingEne_in);
186 ATH_MSG_ERROR ("Expected: " <<
187 "Sum of " << nRemaining << " cell energies: " << remainingEne);
188 badCompare = true;
189 }
190 }
191 }
192 if (badCompare) {
193 ATH_MSG_ERROR ("Reference file miscompare");
194 return StatusCode::FAILURE;
195 }
196 return StatusCode::SUCCESS;
197}
#define ATH_MSG_ERROR(x)
std::vector< Identifier > ID
std::vector< double > Energy
Gaudi::Property< bool > m_compact
Gaudi::Property< float > m_eCut
std::ifstream m_reffile
SG::ReadHandleKey< CaloCellContainer > m_key
std::ofstream m_outfile
CaloCell_ID::CaloSample getSampling() const
cell sampling
bool is_lar_em_endcap_outer() const
cell belongs to the outer wheel of EM end cap
bool is_lar_hec() const
cell belongs to HEC
bool is_lar_em_barrel() const
cell belongs to EM barrel
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap
bool is_lar_fcal() const
cell belongs to FCAL
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition FLOATassert.h:26
struct Event_t Event
list Energies
Definition makePlot.py:24

◆ 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 CaloCellDumper::finalize ( )
overridevirtual

Definition at line 52 of file CaloCellDumper.cxx.

52 {
53 m_outfile.close();
54 if (m_reffile.is_open()) {
55 m_reffile.close();
56 }
57 return StatusCode::SUCCESS;
58}

◆ initialize()

StatusCode CaloCellDumper::initialize ( )
overridevirtual

Definition at line 27 of file CaloCellDumper.cxx.

27 {
28 ATH_CHECK(m_key.initialize());
29 m_outfile.open(m_fileName,std::ios::out);
30
31 if (!m_outfile.good()) {
32 ATH_MSG_ERROR("Failed to open output text file " << m_fileName);
33 return StatusCode::FAILURE;
34 }
35
36 if (!m_refName.value().empty()) {
37 m_reffile.open(m_refName, std::ios::in);
38 if (!m_reffile.good()) {
39 ATH_MSG_ERROR("Failed to open reference file " << m_refName);
40 return StatusCode::FAILURE;
41 }
42 else {
43 ATH_MSG_INFO("Using reference file " << m_refName.value());
44 }
45 }
46
47 ATH_MSG_INFO("Cell energy cut=" << m_eCut.value());
48 return StatusCode::SUCCESS;
49}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Gaudi::Property< std::string > m_fileName
Gaudi::Property< std::string > m_refName

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

Gaudi::Property<bool> CaloCellDumper::m_compact {this,"Compact",true,"compact or detailed cell identifer"}
private

Definition at line 32 of file CaloCellDumper.h.

32{this,"Compact",true,"compact or detailed cell identifer"};

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

Gaudi::Property<float> CaloCellDumper::m_eCut {this,"EnergyCut",std::numeric_limits<float>::lowest(),"Energy cut for cell dumping"}
private

Definition at line 31 of file CaloCellDumper.h.

31{this,"EnergyCut",std::numeric_limits<float>::lowest(),"Energy cut for cell dumping"};

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

Gaudi::Property<std::string> CaloCellDumper::m_fileName {this,"FileName","CaloCells.txt","Name of the output text file"}
private

Definition at line 29 of file CaloCellDumper.h.

29{this,"FileName","CaloCells.txt","Name of the output text file"};

◆ m_key

SG::ReadHandleKey<CaloCellContainer> CaloCellDumper::m_key {this,"InputContainer","AllCalo","Input CaloCellContainer key"}
private

Definition at line 28 of file CaloCellDumper.h.

28{this,"InputContainer","AllCalo","Input CaloCellContainer key"};

◆ m_outfile

std::ofstream CaloCellDumper::m_outfile
private

Definition at line 26 of file CaloCellDumper.h.

◆ m_reffile

std::ifstream CaloCellDumper::m_reffile
private

Definition at line 27 of file CaloCellDumper.h.

◆ m_refName

Gaudi::Property<std::string> CaloCellDumper::m_refName {this,"RefName","","Name of reference file to which cells are to be compared."}
private

Definition at line 30 of file CaloCellDumper.h.

30{this,"RefName","","Name of reference file to which cells are to be compared."};

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