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, const std::string &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, const std::string &) 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, const std::string &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 26 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 45 of file TBXMLCaloCellWriterTool.cxx.

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

68{ }

Member Function Documentation

◆ addAttributes()

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

Definition at line 93 of file TBXMLWriterToolBase.cxx.

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

◆ addDictElement()

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

Definition at line 59 of file TBXMLWriterToolBase.cxx.

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

◆ closeAllElements()

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

Definition at line 161 of file TBXMLWriterToolBase.cxx.

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

◆ closeDictionary()

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

Definition at line 52 of file TBXMLWriterToolBase.cxx.

53{
54 outStream << "]>" << std::endl;
55}

◆ closeElement() [1/2]

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

Definition at line 132 of file TBXMLWriterToolBase.cxx.

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

◆ closeElement() [2/2]

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

Definition at line 141 of file TBXMLWriterToolBase.cxx.

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

◆ convertProperties()

StatusCode TBXMLCaloCellWriterTool::convertProperties ( )
protectedvirtual

Definition at line 437 of file TBXMLCaloCellWriterTool.cxx.

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

◆ 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 51 of file TBXMLWriterToolBase.h.

52 {
53 return StatusCode::SUCCESS;
54 }

◆ finalize() [2/2]

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

Definition at line 56 of file TBXMLWriterToolBase.h.

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

◆ initialize()

StatusCode TBXMLCaloCellWriterTool::initialize ( )
overridevirtual

Reimplemented from TBXMLWriterToolBase.

Definition at line 70 of file TBXMLCaloCellWriterTool.cxx.

71{
73 ATH_CHECK(m_caloMgrKey.initialize());
74 return StatusCode::SUCCESS;
75}
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 43 of file TBXMLWriterToolBase.cxx.

45{
46 std::vector<std::string> emptyList;
47 this->openDictionary(outStream,dictName, emptyList);
48}
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 20 of file TBXMLWriterToolBase.cxx.

24{
25 // clean up
26 m_elementList.clear();
27 m_dictionary = dictName;
28
29 // write header
30 outStream << "<?XML version=" << m_doubleQuote
31 << "1" << m_doubleQuote << "?>" << std::endl;
32
33 // write begin of dictionary
34 outStream << "<!DOCTYPE " << dictName
35 << " [" << std::endl;
36
37 // add doctype as element
38 this->addDictElement(outStream,dictName,listOfElements);
39}
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,
const std::string & theElement,
const std::vector< std::string > & listOfAttr,
const std::vector< std::string > & listOfValues )
protectedvirtualinherited

Definition at line 108 of file TBXMLWriterToolBase.cxx.

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

◆ 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,
const std::string &  )
overrideprotectedvirtual

Implements TBXMLWriterToolBase.

Definition at line 82 of file TBXMLCaloCellWriterTool.cxx.

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

◆ writeOut()

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

Definition at line 45 of file TBXMLWriterToolBase.h.

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

◆ writeRunFiles()

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

Implements TBXMLWriterToolBase.

Definition at line 294 of file TBXMLCaloCellWriterTool.cxx.

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

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

◆ m_caloSamplings

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

Definition at line 69 of file TBXMLCaloCellWriterTool.h.

◆ m_cellContainer

std::string TBXMLCaloCellWriterTool::m_cellContainer
private

Definition at line 70 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 107 of file TBXMLWriterToolBase.h.

◆ m_doubleQuote

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

Definition at line 109 of file TBXMLWriterToolBase.h.

◆ m_elementList

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

Definition at line 106 of file TBXMLWriterToolBase.h.

◆ m_etaMax

double TBXMLCaloCellWriterTool::m_etaMax
private

Definition at line 64 of file TBXMLCaloCellWriterTool.h.

◆ m_etaMin

double TBXMLCaloCellWriterTool::m_etaMin
private

Definition at line 64 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 66 of file TBXMLCaloCellWriterTool.h.

◆ m_idHelper

const CaloCell_ID* TBXMLCaloCellWriterTool::m_idHelper
private

Definition at line 72 of file TBXMLCaloCellWriterTool.h.

◆ m_includedCalos

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

Definition at line 61 of file TBXMLCaloCellWriterTool.h.

◆ m_includedSamplings

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

Definition at line 62 of file TBXMLCaloCellWriterTool.h.

◆ m_mother

const TBXMLWriter* TBXMLCaloCellWriterTool::m_mother
private

Definition at line 74 of file TBXMLCaloCellWriterTool.h.

◆ m_nCols

const unsigned int TBXMLCaloCellWriterTool::m_nCols = 2
staticprivate

Definition at line 59 of file TBXMLCaloCellWriterTool.h.

◆ m_phiMax

double TBXMLCaloCellWriterTool::m_phiMax
private

Definition at line 64 of file TBXMLCaloCellWriterTool.h.

◆ m_phiMin

double TBXMLCaloCellWriterTool::m_phiMin
private

Definition at line 64 of file TBXMLCaloCellWriterTool.h.

◆ m_runNumbers

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

Definition at line 76 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: