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

436{
437 // messaging
438 MsgStream log(msgSvc(),name());
439
440 // get calo id helper
441 ATH_CHECK( detStore()->retrieve (m_idHelper, "CaloCell_ID") );
442
444 // Get Calo Indices //
446
447 std::vector<std::string>::iterator firstCalo = m_includedCalos.begin();
448 std::vector<std::string>::iterator lastCalo = m_includedCalos.end();
449 while ( firstCalo != lastCalo )
450 {
451 if ( *firstCalo == "LAREM" )
452 {
454 ++firstCalo;
455 }
456 else if ( *firstCalo == "LARHEC" )
457 {
459 ++firstCalo;
460 }
461 else if ( *firstCalo == "LARFCAL" )
462 {
464 ++firstCalo;
465 }
466 else if ( *firstCalo == "TILE" )
467 {
469 ++firstCalo;
470 }
471 else
472 {
473 firstCalo = m_includedCalos.erase(firstCalo);
474 }
475 }
476
478 // Get CaloSamplings //
480
481 // nasty (no switch on string types...)
482 for (const std::string& sample : m_includedSamplings)
483 {
484 // H8 calos
485 if ( sample == "PreSamplerB" )
486 m_caloSamplings.push_back(CaloSampling::PreSamplerB);
487 if ( sample == "EMB0" )
488 m_caloSamplings.push_back(CaloSampling::EMB1);
489 if ( sample == "EMB1" )
490 m_caloSamplings.push_back(CaloSampling::EMB2);
491 if ( sample == "EMB2" )
492 m_caloSamplings.push_back(CaloSampling::EMB3);
493 if ( sample == "TileBar0" )
494 m_caloSamplings.push_back(CaloSampling::TileBar0);
495 if ( sample == "TileBar1" )
496 m_caloSamplings.push_back(CaloSampling::TileBar0);
497 if ( sample == "TileBar2" )
498 m_caloSamplings.push_back(CaloSampling::TileBar0);
499 if ( sample == "TileExt0" )
500 m_caloSamplings.push_back(CaloSampling::TileExt0);
501 if ( sample == "TileExt1" )
502 m_caloSamplings.push_back(CaloSampling::TileExt1);
503 if ( sample == "TileExt2" )
504 m_caloSamplings.push_back(CaloSampling::TileExt2);
505
506 // H6 calos
507 if ( sample == "EME1" )
508 m_caloSamplings.push_back(CaloSampling::EME1);
509 if ( sample == "EME2" )
510 m_caloSamplings.push_back(CaloSampling::EME2);
511 if ( sample == "HEC0" )
512 m_caloSamplings.push_back(CaloSampling::HEC0);
513 if ( sample == "HEC1" )
514 m_caloSamplings.push_back(CaloSampling::HEC1);
515 if ( sample == "HEC2" )
516 m_caloSamplings.push_back(CaloSampling::HEC2);
517 if ( sample == "HEC3" )
518 m_caloSamplings.push_back(CaloSampling::HEC3);
519 if ( sample == "FCAL0" )
520 m_caloSamplings.push_back(CaloSampling::FCAL0);
521 if ( sample == "FCAL1" )
522 m_caloSamplings.push_back(CaloSampling::FCAL1);
523 if ( sample == "FCAL2" )
524 m_caloSamplings.push_back(CaloSampling::FCAL2);
525 }
526
527 return m_caloSamplings.size() == 0 && m_caloIndices.size() == 0
528 ? StatusCode::FAILURE
529 : StatusCode::SUCCESS;
530}
#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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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] << " -->" << std::endl;
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 std::ostringstream theCols;
172 theCols << m_nCols << std::ends;
173
174 // get data size
175 unsigned int dataSize = theContainer->nCellsCalo(m_caloIndices[i]);
176 unsigned int nRows =
177 (unsigned int)ceil( (double)dataSize / (double)m_nCols );
178 std::ostringstream theRows;
179 theRows << nRows << std::ends;
180 theCellAttrValues.push_back(theCols.str());
181 theCellAttrValues.push_back(theRows.str());
182 theCellAttrValues.push_back("uint");
183 theCellAttrValues.push_back("double");
184 this->openElement(outStream,"CaloCellContainer",
185 theCellAttrNames,theCellAttrValues);
186
187 // loop on cells
189 theContainer->beginConstCalo(m_caloIndices[i]);
191 theContainer->endConstCalo(m_caloIndices[i]);
192
193 // baseline index
194 IdentifierHash baseIndex, lastIndex;
195 m_idHelper->calo_cell_hash_range((int)m_caloIndices[i],
196 baseIndex, lastIndex);
197
198 unsigned int theCtr = 0;
199 bool isTerminated = false;
200 for ( ; firstCell != lastCell; ++firstCell )
201 {
202 // check if cell in requested layer and range
203 double eta = (*firstCell)->eta();
204 double phi = (*firstCell)->phi();
205 const CaloDetDescrElement * theCaloDDE= (*firstCell)->caloDDE();
207 if (theCaloDDE) {
208 theLayer = (CaloSampling::CaloSample) theCaloDDE->getSampling();
209 }else{
210 theLayer = CaloSampling::Unknown;
211 }
212 if ( ( std::find(m_caloSamplings.begin(),
213 m_caloSamplings.end(),
214 theLayer) != m_caloSamplings.end() ) &&
215 ( ( eta > m_etaMin && eta < m_etaMax ) &&
216 ( phi > m_phiMin && phi < m_phiMax ) )
217 )
218 {
219 // get calorimeter hash index
220 IdentifierHash theIndex =
221 (*firstCell)->caloDDE()->calo_hash();
222 // get eta, phi, region
223 int etaIndex = m_idHelper->eta((*firstCell)->ID());
224 int phiIndex = m_idHelper->phi((*firstCell)->ID());
225 int regIndex = m_idHelper->region((*firstCell)->ID());
226 // int subIndex = m_idHelper->sub_calo((*firstCell)->ID());
227 int lyrIndex = m_idHelper->sampling((*firstCell)->ID());
228 int subIndex = -1;
229 // get subIndex
230 if ( m_idHelper->is_em_barrel((*firstCell)->ID()) )
231 {
232 subIndex = 0;
233 }
234 else if ( m_idHelper->is_em_endcap((*firstCell)->ID()) )
235 {
236 subIndex = 1;
237 }
238 else if ( m_idHelper->is_tile_barrel((*firstCell)->ID()) )
239 {
240 subIndex = 2;
241 }
242 else if ( m_idHelper->is_tile_extbarrel((*firstCell)->ID()) )
243 {
244 subIndex = 3;
245 }
246 else if ( m_idHelper->is_hec((*firstCell)->ID()) )
247 {
248 subIndex = 4;
249 }
250 else if ( m_idHelper->is_fcal((*firstCell)->ID()) )
251 {
252 subIndex = 5;
253 }
254 // get signal
255 double theEnergy = (*firstCell)->e();
256 if ( theCtr == 0 || ( theCtr % m_nCols ) == 0 )
257 {
258 outStream << " ";
259 }
260 theIndex -= (int)baseIndex;
261 boost::io::ios_base_all_saver streamsave (outStream);
262 outStream
263 << std::setw(10) << std::setfill(' ') << theIndex << " "
264 << std::setw(3) << std::setfill(' ') << subIndex << " "
265 << std::setw(3) << std::setfill(' ') << lyrIndex << " "
266 << std::setw(3) << std::setfill(' ') << regIndex << " "
267 << std::setw(3) << std::setfill(' ') << etaIndex << " "
268 << std::setw(3) << std::setfill(' ') << phiIndex << " "
269 << std::setw(10) << std::setprecision(5) << theEnergy;
270 theCtr++;
271 if ( (isTerminated = ( theCtr % m_nCols )) == 0 )
272 {
273 outStream << std::endl;
274 }
275 }
276 }
277 if ( ! isTerminated ) outStream << std::endl;
278 this->closeElement(outStream);
279 // write container tag
280 outStream << "<!-- TBXMLCaloCellWriterTool: end write cell container "
281 << m_includedCalos[i] << " -->" << std::endl;
282 }
283
284 return StatusCode::SUCCESS;
285}
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 292 of file TBXMLCaloCellWriterTool.cxx.

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

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

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