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

#include <TBXMLCaloCellWriterTool.h>

Inheritance diagram for TBXMLCaloCellWriterTool:
Collaboration diagram for TBXMLCaloCellWriterTool:

Public Member Functions

 TBXMLCaloCellWriterTool (const std::string &type, const std::string &name, const IInterface *parent)
 tool constructor
 ~TBXMLCaloCellWriterTool ()
virtual StatusCode initialize () override
virtual StatusCode writeOut (std::ostream &outStream, std::string_view entryTag=" ")
virtual StatusCode finalize () override
virtual StatusCode finalize (std::ostream &outStream)
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

Protected Member Functions

virtual StatusCode writeRunFiles (const std::string &fileDir, unsigned int runNumber) override
virtual StatusCode writeEvent (std::ostream &outFile, std::string_view) override
virtual StatusCode convertProperties ()
virtual void openDictionary (std::ostream &outStream, const std::string &dictName, const std::vector< std::string > &listOfElements)
virtual void openDictionary (std::ostream &outStream, const std::string &dictName)
virtual void closeDictionary (std::ostream &outStream)
virtual void addDictElement (std::ostream &outStream, const std::string &theElement, const std::vector< std::string > &listOfElements)
virtual void addAttributes (std::ostream &outStream, const std::string &theElement, const std::vector< std::string > &listOfAttributes)
virtual void openElement (std::ostream &outStream, std::string_view theElement, const std::vector< std::string > &listOfAttr, const std::vector< std::string > &listOfValues)
virtual void closeElement (std::ostream &outStream, const std::string &theElement)
virtual void closeElement (std::ostream &outStream)
virtual void closeAllElements (std::ostream &outStream)
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

std::vector< std::string > m_elementList
std::string m_dictionary

Static Protected Attributes

static const std::string m_doubleQuote = "\042"

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::vector< std::string > m_includedCalos
std::vector< std::string > m_includedSamplings
double m_etaMin
double m_etaMax
double m_phiMin
double m_phiMax
bool m_firstEvent
std::vector< CaloCell_ID::SUBCALOm_caloIndices
std::vector< CaloSampling::CaloSamplem_caloSamplings
std::string m_cellContainer
const CaloCell_IDm_idHelper {}
const TBXMLWriterm_mother {}
std::unordered_set< EventIDBase::number_type > m_runNumbers
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey
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

Static Private Attributes

static const unsigned int m_nCols = 2

Detailed Description

Definition at line 27 of file TBXMLCaloCellWriterTool.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

◆ TBXMLCaloCellWriterTool()

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

tool constructor

Definition at line 42 of file TBXMLCaloCellWriterTool.cxx.

45 : TBXMLWriterToolBase(type,name,parent)
46 , m_etaMin(-5.0)
47 , m_etaMax(5.0)
48 , m_phiMin(0.*deg)
49 , m_phiMax(360.*deg)
50 , m_firstEvent(true)
51 , m_idHelper(0)
52{
53 declareProperty("InputCellContainer", m_cellContainer);
54 declareProperty("IncludedCalos", m_includedCalos);
55 declareProperty("IncludedSamplings", m_includedSamplings);
56 declareProperty("EtaMin", m_etaMin);
57 declareProperty("EtaMax", m_etaMax);
58 declareProperty("PhiMin", m_phiMin);
59 declareProperty("PhiMax", m_phiMax);
60 // save pointer to algorithm
61 m_mother = dynamic_cast<const TBXMLWriter*>(parent);
62}
#define deg
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< std::string > m_includedSamplings
std::vector< std::string > m_includedCalos
TBXMLWriterToolBase(const std::string &type, const std::string &name, const IInterface *parent)

◆ ~TBXMLCaloCellWriterTool()

TBXMLCaloCellWriterTool::~TBXMLCaloCellWriterTool ( )

Definition at line 64 of file TBXMLCaloCellWriterTool.cxx.

65{ }

Member Function Documentation

◆ addAttributes()

void TBXMLWriterToolBase::addAttributes ( std::ostream & outStream,
const std::string & theElement,
const std::vector< std::string > & listOfAttributes )
protectedvirtualinherited

Definition at line 91 of file TBXMLWriterToolBase.cxx.

95{
96 outStream << " <!ATTLIST " << theElement << std::endl;
97 for ( unsigned int i=0; i<listOfAttr.size(); i++ )
98 {
99 outStream << " " << listOfAttr[i] << std::endl;
100 }
101 outStream << ">" << std::endl;
102}

◆ addDictElement()

void TBXMLWriterToolBase::addDictElement ( std::ostream & outStream,
const std::string & theElement,
const std::vector< std::string > & listOfElements )
protectedvirtualinherited

Definition at line 57 of file TBXMLWriterToolBase.cxx.

61{
62 outStream << "<!ELEMENT " << theElement;
63 // add document as element
64 if ( listOfElements.size() == 0 )
65 {
66 outStream << ">" << std::endl;
67 }
68 else
69 {
70 // store elements
71 if ( listOfElements[0] == "ANY" ||
72 listOfElements[0] == "EMPTY" ||
73 listOfElements[0] == "ALL" )
74 {
75 outStream << " " << listOfElements[0] << " >" << std::endl;
76 }
77 else
78 {
79 outStream << " (" << listOfElements[0];
80 for ( unsigned int i=1; i<listOfElements.size(); i++ )
81 {
82 outStream << "," << listOfElements[i];
83 }
84 outStream << ") >" << std::endl;
85 }
86 }
87}

◆ closeAllElements()

void TBXMLWriterToolBase::closeAllElements ( std::ostream & outStream)
protectedvirtualinherited

Definition at line 159 of file TBXMLWriterToolBase.cxx.

160{
161 for ( int i=m_elementList.size()-1; i>=0; i-- )
162 {
163 outStream << "</" << m_elementList[i] << ">" << std::endl;
164 }
165 m_elementList.clear();
166}
std::vector< std::string > m_elementList

◆ closeDictionary()

void TBXMLWriterToolBase::closeDictionary ( std::ostream & outStream)
protectedvirtualinherited

Definition at line 50 of file TBXMLWriterToolBase.cxx.

51{
52 outStream << "]>" << std::endl;
53}

◆ closeElement() [1/2]

void TBXMLWriterToolBase::closeElement ( std::ostream & outStream)
protectedvirtualinherited

Definition at line 130 of file TBXMLWriterToolBase.cxx.

131{
132 unsigned int thisSize = m_elementList.size() - 1;
133 outStream << "</" << m_elementList[thisSize] << ">" << std::endl;
134 m_elementList.resize(thisSize);
135}

◆ closeElement() [2/2]

void TBXMLWriterToolBase::closeElement ( std::ostream & outStream,
const std::string & theElement )
protectedvirtualinherited

Definition at line 139 of file TBXMLWriterToolBase.cxx.

141{
142 std::vector<std::string>::iterator inVec =
143 find( m_elementList.begin(), m_elementList.end(), theElement);
144 if ( inVec != m_elementList.end() )
145 {
146 outStream << "</" << (*inVec) << ">" << std::endl;
147 m_elementList.erase(inVec);
148 }
149 else
150 {
151 outStream << "<!-- XML Structural Problem! \n\n"
152 << " cannot find an element " << theElement << "!\n\n"
153 << "-->" << std::endl;
154 }
155}
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140

◆ convertProperties()

StatusCode TBXMLCaloCellWriterTool::convertProperties ( )
protectedvirtual

Definition at line 417 of file TBXMLCaloCellWriterTool.cxx.

418{
419 // messaging
420 MsgStream log(msgSvc(),name());
421
422 // get calo id helper
423 ATH_CHECK( detStore()->retrieve (m_idHelper, "CaloCell_ID") );
424
426 // Get Calo Indices //
428
429 std::vector<std::string>::iterator firstCalo = m_includedCalos.begin();
430 std::vector<std::string>::iterator lastCalo = m_includedCalos.end();
431 while ( firstCalo != lastCalo )
432 {
433 if ( *firstCalo == "LAREM" )
434 {
436 ++firstCalo;
437 }
438 else if ( *firstCalo == "LARHEC" )
439 {
441 ++firstCalo;
442 }
443 else if ( *firstCalo == "LARFCAL" )
444 {
446 ++firstCalo;
447 }
448 else if ( *firstCalo == "TILE" )
449 {
451 ++firstCalo;
452 }
453 else
454 {
455 firstCalo = m_includedCalos.erase(firstCalo);
456 }
457 }
458
460 // Get CaloSamplings //
462
463 // nasty (no switch on string types...)
464 for (const std::string& sample : m_includedSamplings)
465 {
466 // H8 calos
467 if ( sample == "PreSamplerB" )
468 m_caloSamplings.push_back(CaloSampling::PreSamplerB);
469 if ( sample == "EMB0" )
470 m_caloSamplings.push_back(CaloSampling::EMB1);
471 if ( sample == "EMB1" )
472 m_caloSamplings.push_back(CaloSampling::EMB2);
473 if ( sample == "EMB2" )
474 m_caloSamplings.push_back(CaloSampling::EMB3);
475 if ( sample == "TileBar0" )
476 m_caloSamplings.push_back(CaloSampling::TileBar0);
477 if ( sample == "TileBar1" )
478 m_caloSamplings.push_back(CaloSampling::TileBar0);
479 if ( sample == "TileBar2" )
480 m_caloSamplings.push_back(CaloSampling::TileBar0);
481 if ( sample == "TileExt0" )
482 m_caloSamplings.push_back(CaloSampling::TileExt0);
483 if ( sample == "TileExt1" )
484 m_caloSamplings.push_back(CaloSampling::TileExt1);
485 if ( sample == "TileExt2" )
486 m_caloSamplings.push_back(CaloSampling::TileExt2);
487
488 // H6 calos
489 if ( sample == "EME1" )
490 m_caloSamplings.push_back(CaloSampling::EME1);
491 if ( sample == "EME2" )
492 m_caloSamplings.push_back(CaloSampling::EME2);
493 if ( sample == "HEC0" )
494 m_caloSamplings.push_back(CaloSampling::HEC0);
495 if ( sample == "HEC1" )
496 m_caloSamplings.push_back(CaloSampling::HEC1);
497 if ( sample == "HEC2" )
498 m_caloSamplings.push_back(CaloSampling::HEC2);
499 if ( sample == "HEC3" )
500 m_caloSamplings.push_back(CaloSampling::HEC3);
501 if ( sample == "FCAL0" )
502 m_caloSamplings.push_back(CaloSampling::FCAL0);
503 if ( sample == "FCAL1" )
504 m_caloSamplings.push_back(CaloSampling::FCAL1);
505 if ( sample == "FCAL2" )
506 m_caloSamplings.push_back(CaloSampling::FCAL2);
507 }
508
509 return m_caloSamplings.size() == 0 && m_caloIndices.size() == 0
510 ? StatusCode::FAILURE
511 : StatusCode::SUCCESS;
512}
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
std::vector< CaloCell_ID::SUBCALO > m_caloIndices
std::vector< CaloSampling::CaloSample > m_caloSamplings

◆ 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() [1/2]

virtual StatusCode TBXMLWriterToolBase::finalize ( )
inlineoverridevirtualinherited

Definition at line 52 of file TBXMLWriterToolBase.h.

53 {
54 return StatusCode::SUCCESS;
55 }

◆ finalize() [2/2]

virtual StatusCode TBXMLWriterToolBase::finalize ( std::ostream & outStream)
inlinevirtualinherited

Definition at line 57 of file TBXMLWriterToolBase.h.

58 {
59 this->closeAllElements(outStream);
60 return this->finalize();
61 }
virtual void closeAllElements(std::ostream &outStream)
virtual StatusCode finalize() override

◆ initialize()

StatusCode TBXMLCaloCellWriterTool::initialize ( )
overridevirtual

Reimplemented from TBXMLWriterToolBase.

Definition at line 67 of file TBXMLCaloCellWriterTool.cxx.

68{
70 ATH_CHECK(m_caloMgrKey.initialize());
71 return StatusCode::SUCCESS;
72}
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode initialize() override

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

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

◆ openDictionary() [1/2]

void TBXMLWriterToolBase::openDictionary ( std::ostream & outStream,
const std::string & dictName )
protectedvirtualinherited

Definition at line 41 of file TBXMLWriterToolBase.cxx.

43{
44 std::vector<std::string> emptyList;
45 this->openDictionary(outStream,dictName, emptyList);
46}
virtual void openDictionary(std::ostream &outStream, const std::string &dictName, const std::vector< std::string > &listOfElements)

◆ openDictionary() [2/2]

void TBXMLWriterToolBase::openDictionary ( std::ostream & outStream,
const std::string & dictName,
const std::vector< std::string > & listOfElements )
protectedvirtualinherited

Definition at line 18 of file TBXMLWriterToolBase.cxx.

22{
23 // clean up
24 m_elementList.clear();
25 m_dictionary = dictName;
26
27 // write header
28 outStream << "<?XML version=" << m_doubleQuote
29 << "1" << m_doubleQuote << "?>" << std::endl;
30
31 // write begin of dictionary
32 outStream << "<!DOCTYPE " << dictName
33 << " [" << std::endl;
34
35 // add doctype as element
36 this->addDictElement(outStream,dictName,listOfElements);
37}
virtual void addDictElement(std::ostream &outStream, const std::string &theElement, const std::vector< std::string > &listOfElements)
static const std::string m_doubleQuote

◆ openElement()

void TBXMLWriterToolBase::openElement ( std::ostream & outStream,
std::string_view theElement,
const std::vector< std::string > & listOfAttr,
const std::vector< std::string > & listOfValues )
protectedvirtualinherited

Definition at line 106 of file TBXMLWriterToolBase.cxx.

112{
113 m_elementList.emplace_back(theElement);
114 outStream << "<" << theElement;
115 if ( listOfAttr.size() > 0 && listOfValues.size() == listOfAttr.size() )
116 {
117 for ( unsigned int i=0; i<listOfAttr.size(); i++ )
118 {
119 outStream << " " << listOfAttr[i] << "="
120 << m_doubleQuote
121 << listOfValues[i]
122 << m_doubleQuote;
123 }
124 }
125 outStream << ">" << std::endl;
126}

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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

◆ writeEvent()

StatusCode TBXMLCaloCellWriterTool::writeEvent ( std::ostream & outFile,
std::string_view  )
overrideprotectedvirtual

Implements TBXMLWriterToolBase.

Definition at line 79 of file TBXMLCaloCellWriterTool.cxx.

81{
82 // messaging
83 MsgStream log(msgSvc(),name());
84
86 // On the Fly Initialization //
88
89 if ( m_firstEvent )
90 {
91 // check pointer
92 if ( m_mother == 0 )
93 {
94 log << MSG::ERROR
95 << "tool does not hang off the TBXMLWriter algorithm."
96 << endmsg;
97 return StatusCode::FAILURE;
98 }
99
100 // convert poperties
101 StatusCode checkOut = this->convertProperties();
102 if ( checkOut.isFailure() )
103 {
104 log << MSG::ERROR
105 << "cannot convert properties correctly!"
106 << endmsg;
107 return StatusCode::FAILURE;
108 }
109 m_firstEvent = false;
110
111 // print out configuration
112 log << MSG::INFO
113 << "list of included calo samplings:"
114 << endmsg;
115 for ( unsigned int i=0; i<m_caloSamplings.size(); i++ )
116 {
117 log << MSG::INFO
118 << "Sampling \042"
120 << "\042 with SubCalo index "
121 << (int)m_caloSamplings[i]
122 << endmsg;
123 }
124 }
125
127 // Check On Begin Run //
129
130 const EventContext& ctx = Gaudi::Hive::currentContext();
131 EventIDBase::number_type run_number = ctx.eventID().run_number();
132 if (m_runNumbers.insert (run_number).second) {
133 StatusCode checkOut = this->writeRunFiles(m_mother->getFileDir(),
134 run_number);
135 if ( checkOut.isFailure() )
136 {
137 log << MSG::ERROR
138 << "cannot produce run XML files."
139 << endmsg;
140 return StatusCode::FAILURE;
141 }
142 }
143
144
146 // Retrieve Data from StoreGate //
148
149 const CaloCellContainer* theContainer = 0;
150 ATH_CHECK( evtStore()->retrieve(theContainer,m_cellContainer) );
151
153 // Loop Individual Calorimeters //
155
156 for ( unsigned int i=0; i<m_caloIndices.size(); i++ )
157 {
158 // write container tag
159 outStream << "<!-- TBXMLCaloCellWriterTool: begin write cell container "
160 << m_includedCalos[i] << " -->" << '\n';
161
162 std::vector<std::string> theCellAttrNames;
163 theCellAttrNames.push_back("name");
164 theCellAttrNames.push_back("ncols");
165 theCellAttrNames.push_back("nrows");
166 theCellAttrNames.push_back("idtype");
167 theCellAttrNames.push_back("etype");
168 std::vector<std::string> theCellAttrValues;
169 theCellAttrValues.push_back(m_includedCalos[i]);
170
171 // get data size
172 unsigned int dataSize = theContainer->nCellsCalo(m_caloIndices[i]);
173 unsigned int nRows =
174 (unsigned int)ceil( (double)dataSize / (double)m_nCols );
175 theCellAttrValues.push_back(std::to_string(m_nCols));
176 theCellAttrValues.push_back(std::to_string(nRows));
177 theCellAttrValues.push_back("uint");
178 theCellAttrValues.push_back("double");
179 this->openElement(outStream,"CaloCellContainer",
180 theCellAttrNames,theCellAttrValues);
181
182 // loop on cells
184 theContainer->beginConstCalo(m_caloIndices[i]);
186 theContainer->endConstCalo(m_caloIndices[i]);
187
188 // baseline index
189 IdentifierHash baseIndex, lastIndex;
190 m_idHelper->calo_cell_hash_range((int)m_caloIndices[i],
191 baseIndex, lastIndex);
192
193 unsigned int theCtr = 0;
194 bool isTerminated = false;
195 for ( ; firstCell != lastCell; ++firstCell )
196 {
197 // check if cell in requested layer and range
198 double eta = (*firstCell)->eta();
199 double phi = (*firstCell)->phi();
200 const CaloDetDescrElement * theCaloDDE= (*firstCell)->caloDDE();
202 if (theCaloDDE) {
203 theLayer = (CaloSampling::CaloSample) theCaloDDE->getSampling();
204 }else{
205 theLayer = CaloSampling::Unknown;
206 }
207 if ( ( std::find(m_caloSamplings.begin(),
208 m_caloSamplings.end(),
209 theLayer) != m_caloSamplings.end() ) &&
210 ( ( eta > m_etaMin && eta < m_etaMax ) &&
211 ( phi > m_phiMin && phi < m_phiMax ) )
212 )
213 {
214 // get calorimeter hash index
215 IdentifierHash theIndex =
216 (*firstCell)->caloDDE()->calo_hash();
217 // get eta, phi, region
218 int etaIndex = m_idHelper->eta((*firstCell)->ID());
219 int phiIndex = m_idHelper->phi((*firstCell)->ID());
220 int regIndex = m_idHelper->region((*firstCell)->ID());
221 // int subIndex = m_idHelper->sub_calo((*firstCell)->ID());
222 int lyrIndex = m_idHelper->sampling((*firstCell)->ID());
223 int subIndex = -1;
224 // get subIndex
225 if ( m_idHelper->is_em_barrel((*firstCell)->ID()) )
226 {
227 subIndex = 0;
228 }
229 else if ( m_idHelper->is_em_endcap((*firstCell)->ID()) )
230 {
231 subIndex = 1;
232 }
233 else if ( m_idHelper->is_tile_barrel((*firstCell)->ID()) )
234 {
235 subIndex = 2;
236 }
237 else if ( m_idHelper->is_tile_extbarrel((*firstCell)->ID()) )
238 {
239 subIndex = 3;
240 }
241 else if ( m_idHelper->is_hec((*firstCell)->ID()) )
242 {
243 subIndex = 4;
244 }
245 else if ( m_idHelper->is_fcal((*firstCell)->ID()) )
246 {
247 subIndex = 5;
248 }
249 // get signal
250 double theEnergy = (*firstCell)->e();
251 if ( theCtr == 0 || ( theCtr % m_nCols ) == 0 )
252 {
253 outStream << " ";
254 }
255 theIndex -= (int)baseIndex;
256 //coverity[RW.CONSTEVAL_CALL_NONCONSTANT:FALSE]
257 outStream << std::format("{:>10} {:>3} {:>3} {:>3} {:>3} {:>3} {:>10.5g}",
258 theIndex.value(),
259 subIndex,
260 lyrIndex,
261 regIndex,
262 etaIndex,
263 phiIndex,
264 theEnergy);
265 theCtr++;
266 if ( (isTerminated = ( theCtr % m_nCols )) == 0 )
267 {
268 outStream << '\n';
269 }
270 }
271 }
272 if ( ! isTerminated ) outStream << '\n';
273 this->closeElement(outStream);
274 // write container tag
275 outStream << "<!-- TBXMLCaloCellWriterTool: end write cell container "
276 << m_includedCalos[i] << " -->" << '\n';
277 }
278
279 return StatusCode::SUCCESS;
280}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
ServiceHandle< StoreGateSvc > & evtStore()
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
CaloCell_ID::CaloSample getSampling() const
cell sampling
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
constexpr value_type value() const
virtual StatusCode writeRunFiles(const std::string &fileDir, unsigned int runNumber) override
static const unsigned int m_nCols
std::unordered_set< EventIDBase::number_type > m_runNumbers
virtual StatusCode convertProperties()
virtual void closeElement(std::ostream &outStream, const std::string &theElement)
virtual void openElement(std::ostream &outStream, std::string_view theElement, const std::vector< std::string > &listOfAttr, const std::vector< std::string > &listOfValues)
::StatusCode StatusCode
StatusCode definition for legacy code.
constexpr size_t dataSize(TDA::PayloadIterator start)
Size in bytes of the buffer that is needed to decode next fragment data content.
unsigned int constexpr nRows
Definition RPDUtils.h:24
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition EtaPhiLUT.cxx:23

◆ writeOut()

virtual StatusCode TBXMLWriterToolBase::writeOut ( std::ostream & outStream,
std::string_view entryTag = " " )
inlinevirtualinherited

Definition at line 46 of file TBXMLWriterToolBase.h.

48 {
49 return this->writeEvent(outStream,entryTag);
50 }
virtual StatusCode writeEvent(std::ostream &theFile, std::string_view entryTag)=0

◆ writeRunFiles()

StatusCode TBXMLCaloCellWriterTool::writeRunFiles ( const std::string & fileDir,
unsigned int runNumber )
overrideprotectedvirtual

Implements TBXMLWriterToolBase.

Definition at line 287 of file TBXMLCaloCellWriterTool.cxx.

289{
290
292 // Write Dictionary //
294
295 std::ofstream thisFileStream(std::format("{}/geom.{:06}.xml", fileDir, runNumber));
296
297 // Document type
298 std::vector<std::string> theRunElements;
299 theRunElements.push_back("FCalGeomTable*");
300 this->openDictionary(thisFileStream,"FCalGeomTable",theRunElements);
301 std::vector<std::string> theRunAttr;
302 theRunAttr.push_back("name CDATA #REQUIRED");
303 this->addAttributes(thisFileStream,"FCalGeomTable",theRunAttr);
304
305 // FCal geometry table
306 std::vector<std::string> anyData;
307 anyData.push_back("ANY");
308 this->addDictElement(thisFileStream,"FCalGeomTable",anyData);
309 std::vector<std::string> theGeomAttr;
310 theGeomAttr.push_back("name CDATA #REQUIRED");
311 this->addAttributes(thisFileStream,"FCalGeomTable",theGeomAttr);
312
313 // close dictionary
314 this->closeDictionary(thisFileStream);
315
317 // Write Run Geometry //
319
320 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey};
321 const CaloDetDescrManager* caloDetMgr = *caloMgrHandle;
322 ATH_CHECK( detStore()->retrieve (caloDetMgr, "CaloMgr") );
323
324 IdentifierHash firstIndex, lastIndex, safeIndex;
325 m_idHelper->calo_cell_hash_range((int)CaloCell_ID::LARFCAL,
326 firstIndex, lastIndex);
327 safeIndex = firstIndex;
328
329 // open element
330 std::vector<std::string> theRunValues(theRunAttr.size());
331 for ( unsigned int i=0; i<theRunAttr.size(); i++ )
332 {
333 if ( (theRunAttr[i]).find("name") != std::string::npos )
334 {
335 theRunValues[i] = "FCalMod0";
336 theRunAttr[i] =
337 theRunAttr[i].substr(0,theRunAttr[i].find_first_of(' '));
338 }
339 }
340 this->openElement(thisFileStream,"FCalGeomTable",theRunAttr,theRunValues);
341 theRunValues[0] = "FCalCells";
342 this->openElement(thisFileStream,"FCalGeomTable",theRunAttr,theRunValues);
343 thisFileStream << "<!-- 32-bit Id"
344 << " Module# "
345 << " EtaIndex "
346 << " PhiIndex "
347 << " X [cm] "
348 << " Y [cm] "
349 << " Z [cm] "
350 << " TileSize "
351 << "-->\n";
352
353 // find big/small tile indicator -> to be replaced
354 std::unordered_map<int, double> smallestDx;
355 smallestDx.reserve(8); // usually only 3-4 sub-calos
356
357 for (unsigned int iCtr = safeIndex; iCtr <= lastIndex; ++iCtr)
358 {
359 const Identifier theId = m_idHelper->cell_id(IdentifierHash(iCtr));
360 const int theCalo = m_idHelper->sub_calo(theId);
361
362 const CaloDetDescrElement* theElement = caloDetMgr->get_element(IdentifierHash(iCtr));
363 const double dx = theElement->dx();
364
365 // One-lookup minimum update (very fast)
366 auto [it, inserted] = smallestDx.try_emplace(theCalo, dx);
367 if (!inserted && dx < it->second)
368 it->second = dx;
369 }
370
371 // get geometry
372 for (unsigned int iCtr=(unsigned int)firstIndex;
373 iCtr<=(unsigned int)lastIndex; iCtr++ )
374 {
375 IdentifierHash theIndex(iCtr);
376 // get identifiers
377 Identifier theId = m_idHelper->cell_id(theIndex);
378 int theModule = m_idHelper->sampling(theId);
379 int theEta = m_idHelper->eta(theId);
380 int thePhi = m_idHelper->phi(theId);
381 int theCalo = m_idHelper->sub_calo(theId);
382 // get geometry
383 const CaloDetDescrElement* theElement =
384 caloDetMgr->get_element(theIndex);
385 double theX = theElement->x();
386 double theY = theElement->y();
387 double theZ = theElement->z();
388 // check tile size
389 double dx = theElement->dx();
390 int tileSize = dx > 1.1*smallestDx[theCalo] ? 1 : 0;
391
392 // write out
393 thisFileStream << " "
394 << std::setw(10)
395 << std::setfill(' ') << iCtr-(unsigned int)firstIndex
396 << " "
397 << std::setw(2) << std::setfill(' ') << theModule
398 << " "
399 << std::setw(2) << std::setfill(' ') << theEta
400 << " "
401 << std::setw(2) << std::setfill(' ') << thePhi
402 << " "
403 << std::setw(10) << std::setprecision(5) << theX << " "
404 << std::setw(10) << std::setprecision(5) << theY << " "
405 << std::setw(10) << std::setprecision(5) << theZ << " "
406 << " "
407 << std::setw(2) << std::setfill(' ') << tileSize
408 << '\n';
409 }
410 ATH_CHECK(this->finalize(thisFileStream));
411 thisFileStream.close();
412
413 return StatusCode::SUCCESS;
414}
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
virtual void closeDictionary(std::ostream &outStream)
virtual void addAttributes(std::ostream &outStream, const std::string &theElement, const std::vector< std::string > &listOfAttributes)

Member Data Documentation

◆ m_caloIndices

std::vector<CaloCell_ID::SUBCALO> TBXMLCaloCellWriterTool::m_caloIndices
private

Definition at line 69 of file TBXMLCaloCellWriterTool.h.

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> TBXMLCaloCellWriterTool::m_caloMgrKey
private
Initial value:
{ this
, "CaloDetDescrManager"
, "CaloDetDescrManager"
, "SG Key for CaloDetDescrManager in the Condition Store" }

Definition at line 79 of file TBXMLCaloCellWriterTool.h.

79 { this
80 , "CaloDetDescrManager"
81 , "CaloDetDescrManager"
82 , "SG Key for CaloDetDescrManager in the Condition Store" };

◆ m_caloSamplings

std::vector<CaloSampling::CaloSample> TBXMLCaloCellWriterTool::m_caloSamplings
private

Definition at line 70 of file TBXMLCaloCellWriterTool.h.

◆ m_cellContainer

std::string TBXMLCaloCellWriterTool::m_cellContainer
private

Definition at line 71 of file TBXMLCaloCellWriterTool.h.

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

std::string TBXMLWriterToolBase::m_dictionary
protectedinherited

Definition at line 108 of file TBXMLWriterToolBase.h.

◆ m_doubleQuote

const std::string TBXMLWriterToolBase::m_doubleQuote = "\042"
staticprotectedinherited

Definition at line 110 of file TBXMLWriterToolBase.h.

◆ m_elementList

std::vector<std::string> TBXMLWriterToolBase::m_elementList
protectedinherited

Definition at line 107 of file TBXMLWriterToolBase.h.

◆ m_etaMax

double TBXMLCaloCellWriterTool::m_etaMax
private

Definition at line 65 of file TBXMLCaloCellWriterTool.h.

◆ m_etaMin

double TBXMLCaloCellWriterTool::m_etaMin
private

Definition at line 65 of file TBXMLCaloCellWriterTool.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_firstEvent

bool TBXMLCaloCellWriterTool::m_firstEvent
private

Definition at line 67 of file TBXMLCaloCellWriterTool.h.

◆ m_idHelper

const CaloCell_ID* TBXMLCaloCellWriterTool::m_idHelper {}
private

Definition at line 73 of file TBXMLCaloCellWriterTool.h.

73{};

◆ m_includedCalos

std::vector<std::string> TBXMLCaloCellWriterTool::m_includedCalos
private

Definition at line 62 of file TBXMLCaloCellWriterTool.h.

◆ m_includedSamplings

std::vector<std::string> TBXMLCaloCellWriterTool::m_includedSamplings
private

Definition at line 63 of file TBXMLCaloCellWriterTool.h.

◆ m_mother

const TBXMLWriter* TBXMLCaloCellWriterTool::m_mother {}
private

Definition at line 75 of file TBXMLCaloCellWriterTool.h.

75{};

◆ m_nCols

const unsigned int TBXMLCaloCellWriterTool::m_nCols = 2
staticprivate

Definition at line 60 of file TBXMLCaloCellWriterTool.h.

◆ m_phiMax

double TBXMLCaloCellWriterTool::m_phiMax
private

Definition at line 65 of file TBXMLCaloCellWriterTool.h.

◆ m_phiMin

double TBXMLCaloCellWriterTool::m_phiMin
private

Definition at line 65 of file TBXMLCaloCellWriterTool.h.

◆ m_runNumbers

std::unordered_set<EventIDBase::number_type> TBXMLCaloCellWriterTool::m_runNumbers
private

Definition at line 77 of file TBXMLCaloCellWriterTool.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.


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