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 43 of file TBXMLCaloCellWriterTool.cxx.

46 : TBXMLWriterToolBase(type,name,parent)
47 , m_etaMin(-5.0)
48 , m_etaMax(5.0)
49 , m_phiMin(0.*deg)
50 , m_phiMax(360.*deg)
51 , m_firstEvent(true)
52 , m_idHelper(0)
53{
54 declareProperty("InputCellContainer", m_cellContainer);
55 declareProperty("IncludedCalos", m_includedCalos);
56 declareProperty("IncludedSamplings", m_includedSamplings);
57 declareProperty("EtaMin", m_etaMin);
58 declareProperty("EtaMax", m_etaMax);
59 declareProperty("PhiMin", m_phiMin);
60 declareProperty("PhiMax", m_phiMax);
61 // save pointer to algorithm
62 m_mother = dynamic_cast<const TBXMLWriter*>(parent);
63}
#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 65 of file TBXMLCaloCellWriterTool.cxx.

66{ }

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 418 of file TBXMLCaloCellWriterTool.cxx.

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

69{
71 ATH_CHECK(m_caloMgrKey.initialize());
72 return StatusCode::SUCCESS;
73}
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 80 of file TBXMLCaloCellWriterTool.cxx.

82{
83 // messaging
84 MsgStream log(msgSvc(),name());
85
87 // On the Fly Initialization //
89
90 if ( m_firstEvent )
91 {
92 // check pointer
93 if ( m_mother == 0 )
94 {
95 log << MSG::ERROR
96 << "tool does not hang off the TBXMLWriter algorithm."
97 << endmsg;
98 return StatusCode::FAILURE;
99 }
100
101 // convert poperties
102 StatusCode checkOut = this->convertProperties();
103 if ( checkOut.isFailure() )
104 {
105 log << MSG::ERROR
106 << "cannot convert properties correctly!"
107 << endmsg;
108 return StatusCode::FAILURE;
109 }
110 m_firstEvent = false;
111
112 // print out configuration
113 log << MSG::INFO
114 << "list of included calo samplings:"
115 << endmsg;
116 for ( unsigned int i=0; i<m_caloSamplings.size(); i++ )
117 {
118 log << MSG::INFO
119 << "Sampling \042"
121 << "\042 with SubCalo index "
122 << (int)m_caloSamplings[i]
123 << endmsg;
124 }
125 }
126
128 // Check On Begin Run //
130
131 const EventContext& ctx = Gaudi::Hive::currentContext();
132 EventIDBase::number_type run_number = ctx.eventID().run_number();
133 if (m_runNumbers.insert (run_number).second) {
134 StatusCode checkOut = this->writeRunFiles(m_mother->getFileDir(),
135 run_number);
136 if ( checkOut.isFailure() )
137 {
138 log << MSG::ERROR
139 << "cannot produce run XML files."
140 << endmsg;
141 return StatusCode::FAILURE;
142 }
143 }
144
145
147 // Retrieve Data from StoreGate //
149
150 const CaloCellContainer* theContainer = 0;
151 ATH_CHECK( evtStore()->retrieve(theContainer,m_cellContainer) );
152
154 // Loop Individual Calorimeters //
156
157 for ( unsigned int i=0; i<m_caloIndices.size(); i++ )
158 {
159 // write container tag
160 outStream << "<!-- TBXMLCaloCellWriterTool: begin write cell container "
161 << m_includedCalos[i] << " -->" << '\n';
162
163 std::vector<std::string> theCellAttrNames;
164 theCellAttrNames.push_back("name");
165 theCellAttrNames.push_back("ncols");
166 theCellAttrNames.push_back("nrows");
167 theCellAttrNames.push_back("idtype");
168 theCellAttrNames.push_back("etype");
169 std::vector<std::string> theCellAttrValues;
170 theCellAttrValues.push_back(m_includedCalos[i]);
171
172 // get data size
173 unsigned int dataSize = theContainer->nCellsCalo(m_caloIndices[i]);
174 unsigned int nRows =
175 (unsigned int)ceil( (double)dataSize / (double)m_nCols );
176 theCellAttrValues.push_back(std::to_string(m_nCols));
177 theCellAttrValues.push_back(std::to_string(nRows));
178 theCellAttrValues.push_back("uint");
179 theCellAttrValues.push_back("double");
180 this->openElement(outStream,"CaloCellContainer",
181 theCellAttrNames,theCellAttrValues);
182
183 // loop on cells
185 theContainer->beginConstCalo(m_caloIndices[i]);
187 theContainer->endConstCalo(m_caloIndices[i]);
188
189 // baseline index
190 IdentifierHash baseIndex, lastIndex;
191 m_idHelper->calo_cell_hash_range((int)m_caloIndices[i],
192 baseIndex, lastIndex);
193
194 unsigned int theCtr = 0;
195 bool isTerminated = false;
196 for ( ; firstCell != lastCell; ++firstCell )
197 {
198 // check if cell in requested layer and range
199 double eta = (*firstCell)->eta();
200 double phi = (*firstCell)->phi();
201 const CaloDetDescrElement * theCaloDDE= (*firstCell)->caloDDE();
203 if (theCaloDDE) {
204 theLayer = (CaloSampling::CaloSample) theCaloDDE->getSampling();
205 }else{
206 theLayer = CaloSampling::Unknown;
207 }
208 if ( ( std::find(m_caloSamplings.begin(),
209 m_caloSamplings.end(),
210 theLayer) != m_caloSamplings.end() ) &&
211 ( ( eta > m_etaMin && eta < m_etaMax ) &&
212 ( phi > m_phiMin && phi < m_phiMax ) )
213 )
214 {
215 // get calorimeter hash index
216 IdentifierHash theIndex =
217 (*firstCell)->caloDDE()->calo_hash();
218 // get eta, phi, region
219 int etaIndex = m_idHelper->eta((*firstCell)->ID());
220 int phiIndex = m_idHelper->phi((*firstCell)->ID());
221 int regIndex = m_idHelper->region((*firstCell)->ID());
222 // int subIndex = m_idHelper->sub_calo((*firstCell)->ID());
223 int lyrIndex = m_idHelper->sampling((*firstCell)->ID());
224 int subIndex = -1;
225 // get subIndex
226 if ( m_idHelper->is_em_barrel((*firstCell)->ID()) )
227 {
228 subIndex = 0;
229 }
230 else if ( m_idHelper->is_em_endcap((*firstCell)->ID()) )
231 {
232 subIndex = 1;
233 }
234 else if ( m_idHelper->is_tile_barrel((*firstCell)->ID()) )
235 {
236 subIndex = 2;
237 }
238 else if ( m_idHelper->is_tile_extbarrel((*firstCell)->ID()) )
239 {
240 subIndex = 3;
241 }
242 else if ( m_idHelper->is_hec((*firstCell)->ID()) )
243 {
244 subIndex = 4;
245 }
246 else if ( m_idHelper->is_fcal((*firstCell)->ID()) )
247 {
248 subIndex = 5;
249 }
250 // get signal
251 double theEnergy = (*firstCell)->e();
252 if ( theCtr == 0 || ( theCtr % m_nCols ) == 0 )
253 {
254 outStream << " ";
255 }
256 theIndex -= (int)baseIndex;
257 boost::io::ios_base_all_saver streamsave (outStream);
258 outStream
259 << std::setw(10) << std::setfill(' ') << theIndex << " "
260 << std::setw(3) << std::setfill(' ') << subIndex << " "
261 << std::setw(3) << std::setfill(' ') << lyrIndex << " "
262 << std::setw(3) << std::setfill(' ') << regIndex << " "
263 << std::setw(3) << std::setfill(' ') << etaIndex << " "
264 << std::setw(3) << std::setfill(' ') << phiIndex << " "
265 << std::setw(10) << std::setprecision(5) << theEnergy;
266 theCtr++;
267 if ( (isTerminated = ( theCtr % m_nCols )) == 0 )
268 {
269 outStream << '\n';
270 }
271 }
272 }
273 if ( ! isTerminated ) outStream << '\n';
274 this->closeElement(outStream);
275 // write container tag
276 outStream << "<!-- TBXMLCaloCellWriterTool: end write cell container "
277 << m_includedCalos[i] << " -->" << '\n';
278 }
279
280 return StatusCode::SUCCESS;
281}
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
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 288 of file TBXMLCaloCellWriterTool.cxx.

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