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

read TRT calibration constants from db and write text file More...

#include <TRTCondRead.h>

Inheritance diagram for TRTCondRead:
Collaboration diagram for TRTCondRead:

Public Types

typedef TRTCond::RtRelationMultChanContainer RtRelationContainer
typedef TRTCond::StrawT0MultChanContainer StrawT0Container

Public Member Functions

 TRTCondRead (const std::string &name, ISvcLocator *pSvcLocator)
 constructor
virtual ~TRTCondRead () override=default
virtual StatusCode initialize (void) override
virtual StatusCode execute (void) override
virtual StatusCode finalize (void) override
virtual TRTCond::ExpandedIdentifier trtcondid (const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const
 create an TRTCond::ExpandedIdentifier from a TRTID identifier
virtual StatusCode writeCalibTextFile (std::ostream &) const
 write calibration constants or errors to flat text file
virtual StatusCode writeErrorTextFile (std::ostream &) const
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< ITRT_CalDbToolm_TRTCalDbTool {this, "TRTCalDbTool", "CalDbTool", "Access to the folder of the calibration constants"}
Gaudi::Property< std::string > m_par_caloutputfile {this, "CalibOutputFile", "caliboutput.txt", ""}
const TRT_IDm_trtid {}
 trt id helper
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

read TRT calibration constants from db and write text file

Definition at line 31 of file TRTCondRead.h.

Member Typedef Documentation

◆ RtRelationContainer

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

◆ StrawT0Container

Constructor & Destructor Documentation

◆ TRTCondRead()

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

constructor

Definition at line 20 of file TRTCondRead.cxx.

21 : AthAlgorithm(name, pSvcLocator) {}
AthAlgorithm()
Default constructor:

◆ ~TRTCondRead()

virtual TRTCondRead::~TRTCondRead ( )
overridevirtualdefault

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode TRTCondRead::execute ( void )
overridevirtual

Definition at line 36 of file TRTCondRead.cxx.

37{
38
39 // Write text file.
40 if (!m_par_caloutputfile.empty())
41 {
42 ATH_MSG_INFO(" Writing calibration constants to text file " << m_par_caloutputfile);
43 std::ofstream outfile(m_par_caloutputfile);
44 // if ((m_par_caloutputfile.value()).contains("caliboutput")) TO BE CORRECTED when C++23
45 if (m_par_caloutputfile.value().find("caliboutput") != std::string::npos)
46 {
47 ATH_MSG_INFO("File name: "<< m_par_caloutputfile);
49 }
50 // else if ((m_par_caloutputfile.value()).contains("erroroutput")) TO BE CORRECTED when C++23
51 else if (m_par_caloutputfile.value().find("erroroutput") != std::string::npos)
52 {
53 ATH_MSG_INFO("File name: "<< m_par_caloutputfile);
55 }
56 else
57 {
58 ATH_MSG_WARNING("The file name must contain either 'caliboutput' or 'erroroutput' ");
59 }
60 outfile.close();
61 }
62
63 // Quick spot check of the T0s
64 ATH_MSG_INFO(" Spot check of T0 in every 10'th straw_layer in phi_modules 0, 10, 20 and 30");
65 for (std::vector<Identifier>::const_iterator it = m_trtid->straw_layer_begin(); it != m_trtid->straw_layer_end(); ++it)
66 {
67 Identifier id = m_trtid->straw_id(*it, 0);
68 if (m_trtid->phi_module(id) % 10 == 0 && m_trtid->straw_layer(id) % 10 == 0)
69 {
70 float t0 = m_TRTCalDbTool->getT0(id);
71 ATH_MSG_INFO(" bec: " << m_trtid->barrel_ec(id) << " lay: " << m_trtid->layer_or_wheel(id) << " phi: " << m_trtid->phi_module(id) << " slay: " << m_trtid->straw_layer(id) << " t0: " << t0);
72 }
73 }
74
75 ATH_MSG_INFO("");
76 ATH_MSG_INFO("List of straws with T0=0 :");
77
78 int nzeros = 0;
79 for (std::vector<Identifier>::const_iterator it = m_trtid->straw_layer_begin(); it != m_trtid->straw_layer_end(); ++it)
80 {
81 int nStrawsInLayer = m_trtid->straw_max(*it);
82 for (int i = 0; i <= nStrawsInLayer; i++)
83 {
84 Identifier strid = m_trtid->straw_id(*it, i);
85 if (m_TRTCalDbTool->getT0(strid) == 0)
86 {
87 ATH_MSG_INFO(" bec: " << m_trtid->barrel_ec(strid) << " lay: " << m_trtid->layer_or_wheel(strid)
88 << " phi: " << m_trtid->phi_module(strid) << " slay: " << m_trtid->straw_layer(strid) << " straw: " << m_trtid->straw(strid));
89 nzeros++;
90 }
91 }
92 }
93
94 if (nzeros > 10)
95 {
96 ATH_MSG_INFO(" Several cases of T0=0. Check the input text file and assign default T0 values instead of zero ");
97 }
98 ATH_MSG_INFO("");
99
100 return StatusCode::SUCCESS;
101}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static Double_t t0
ToolHandle< ITRT_CalDbTool > m_TRTCalDbTool
Definition TRTCondRead.h:56
const TRT_ID * m_trtid
trt id helper
Definition TRTCondRead.h:58
virtual StatusCode writeCalibTextFile(std::ostream &) const
write calibration constants or errors to flat text file
Gaudi::Property< std::string > m_par_caloutputfile
Definition TRTCondRead.h:57
virtual StatusCode writeErrorTextFile(std::ostream &) const

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode TRTCondRead::finalize ( void )
overridevirtual

Definition at line 103 of file TRTCondRead.cxx.

104{
105 return StatusCode::SUCCESS;
106}

◆ initialize()

StatusCode TRTCondRead::initialize ( void )
overridevirtual

Definition at line 23 of file TRTCondRead.cxx.

24{
25
26 ATH_MSG_DEBUG("TRTCondRead::initialize() called");
27
28 ATH_CHECK(m_TRTCalDbTool.retrieve());
29
30 // Get TRT ID helper
31 ATH_CHECK(detStore()->retrieve(m_trtid, "TRT_ID"));
32
33 return StatusCode::SUCCESS;
34}
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_ERROR(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ trtcondid()

TRTCond::ExpandedIdentifier TRTCondRead::trtcondid ( const Identifier & id,
int level = TRTCond::ExpandedIdentifier::STRAW ) const
virtual

create an TRTCond::ExpandedIdentifier from a TRTID identifier

Definition at line 177 of file TRTCondRead.cxx.

178{
179 return TRTCond::ExpandedIdentifier(m_trtid->barrel_ec(id), m_trtid->layer_or_wheel(id),
180 m_trtid->phi_module(id), m_trtid->straw_layer(id),
181 m_trtid->straw(id), level);
182}

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ writeCalibTextFile()

StatusCode TRTCondRead::writeCalibTextFile ( std::ostream & outfile) const
virtual

write calibration constants or errors to flat text file

Definition at line 108 of file TRTCondRead.cxx.

109{
110 const RtRelationContainer *rtContainer = m_TRTCalDbTool->getRtContainer();
111 const StrawT0Container *t0Container = m_TRTCalDbTool->getT0Container();
112
113 // first store rtrelations
114 outfile << "# Rtrelation" << std::endl;
116 rtContainer->getall(rtrelations);
117 for (RtRelationContainer::FlatContainer::iterator it = rtrelations.begin(); it != rtrelations.end(); ++it)
118 {
119 // write the identifier
120 outfile << it->first << " : ";
121 // write the rt-relation via the factory
122 TRTCond::RtRelationFactory::writeToFile(outfile, **(it->second));
123 outfile << std::endl;
124 }
125
126 // now store the t0s
127 outfile << "# StrawT0" << std::endl;
128 StrawT0Container::FlatContainer packedstrawdata;
129 t0Container->getall(packedstrawdata);
130 float t0(0), t0err(0);
131 for (TRTCond::StrawT0Container::FlatContainer::iterator it = packedstrawdata.begin(); it != packedstrawdata.end(); ++it)
132 {
133 const TRTCond::ExpandedIdentifier &calid = it->first;
134 t0Container->unpack(calid, *it->second, t0, t0err);
135 outfile << calid << " : " << t0 << " " << t0err << std::endl;
136 }
137
138 return StatusCode::SUCCESS;
139}
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
TRTCond::RtRelationMultChanContainer RtRelationContainer
Definition TRTCondRead.h:34
TRTCond::StrawT0MultChanContainer StrawT0Container
Definition TRTCondRead.h:35
static void writeToFile(std::ostream &os, const RtRelation &rt)
write method
RtRelationLayerContainer::FlatContainer FlatContainer
typedef
StrawT0ContainerTemplate< ExpandedIdentifier::LAYERWHEEL >::FlatContainer FlatContainer
typedefs

◆ writeErrorTextFile()

StatusCode TRTCondRead::writeErrorTextFile ( std::ostream & outfile) const
virtual

Definition at line 141 of file TRTCondRead.cxx.

142{
143 const RtRelationContainer *errContainer = m_TRTCalDbTool->getErrContainer();
144 const RtRelationContainer *slopeContainer = m_TRTCalDbTool->getSlopeContainer();
145
146 // then store errors2d
147 outfile << "# RtErrors" << std::endl;
149 errContainer->getall(errors);
151 it != errors.end(); ++it)
152 {
153 // write the identifier
154 outfile << it->first << " : ";
155 // write the errors via the factory
156 TRTCond::RtRelationFactory::writeToFile(outfile, **(it->second));
157 outfile << std::endl;
158 }
159
160 // then store slopes
161 outfile << "# RtSlopes" << std::endl;
163 slopeContainer->getall(slopes);
164 for (RtRelationContainer::FlatContainer::iterator it = slopes.begin();
165 it != slopes.end(); ++it)
166 {
167 // write the identifier
168 outfile << it->first << " : ";
169 // write the slopes via the factory
170 TRTCond::RtRelationFactory::writeToFile(outfile, **(it->second));
171 outfile << std::endl;
172 }
173
174 return StatusCode::SUCCESS;
175}

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_par_caloutputfile

Gaudi::Property<std::string> TRTCondRead::m_par_caloutputfile {this, "CalibOutputFile", "caliboutput.txt", ""}
private

Definition at line 57 of file TRTCondRead.h.

57{this, "CalibOutputFile", "caliboutput.txt", ""};

◆ m_TRTCalDbTool

ToolHandle<ITRT_CalDbTool> TRTCondRead::m_TRTCalDbTool {this, "TRTCalDbTool", "CalDbTool", "Access to the folder of the calibration constants"}
private

Definition at line 56 of file TRTCondRead.h.

56{this, "TRTCalDbTool", "CalDbTool", "Access to the folder of the calibration constants"};

◆ m_trtid

const TRT_ID* TRTCondRead::m_trtid {}
private

trt id helper

Definition at line 58 of file TRTCondRead.h.

58{};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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