ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TRT_StrawAlignDbSvc Class Reference

#include <TRT_StrawAlignDbSvc.h>

Inheritance diagram for TRT_StrawAlignDbSvc:
Collaboration diagram for TRT_StrawAlignDbSvc:

Public Member Functions

 TRT_StrawAlignDbSvc (const std::string &name, ISvcLocator *pSvcLocator)
 constructor More...
 
virtual ~TRT_StrawAlignDbSvc ()
 destructor More...
 
virtual StatusCode initialize ()
 tool initialize More...
 
virtual StatusCode finalize ()
 tool finalize More...
 
TRTCond::ExpandedIdentifier trtcondid (const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const
 create an TRTCond::ExpandedIdentifier from a TRTID identifier More...
 
void setDx (const TRTCond::ExpandedIdentifier &id, float dx1, float dx2, float dxerr)
 set endpoints for a TRTCond::ExpandedIdentifier More...
 
StatusCode writeTextFile (const std::string &file) const
 write calibration constants to flat text file More...
 
virtual StatusCode readTextFile (const std::string &file)
 read calibration from text file into TDS More...
 
StatusCode readTextFile (StrawDxContainer *dxcontainer, const std::string &file)
 
StatusCode streamOutObjects () const
 write the calibration objects to output, after cleaning More...
 
StatusCode registerObjects (std::string tag, int run1, int event1, int run2, int event2) const
 register calibration objects with the IoV service More...
 
StrawDxContainer * getDxContainer () const
 access to containers More...
 
const StrawDxContainer * getConstDxContainer () const
 
StatusCode IOVCallBack (IOVSVC_CALLBACK_ARGS)
 IOV call back for dx objects. normally this doesn't do anything. More...
 
float getDx1 (const Identifier &id) const
 get shift near electronics More...
 
float getDx2 (const Identifier &id) const
 get shift far from electronics More...
 
float getDxErr (const Identifier &id) const
 get error on shift More...
 
void setDx (const Identifier &id, float dx1, float dx2, float dxerr)
 set shifts More...
 

Private Attributes

ServiceHandle< StoreGateSvcm_detStore
 
std::string m_par_dxcontainerkey
 
std::string m_par_strawtextfile
 

folder name

More...
 
bool m_par_forcecallback
 

input text file

More...
 
const TRT_IDm_trtid
 

force callback to manager

More...
 
const InDetDD::TRT_DetectorManagerm_trtman
 

id helper

More...
 
const DataHandle< StrawDxContainer > m_dxcontainer
 

detector manager

More...
 
ToolHandle< IAthenaOutputStreamToolm_streamer
 

persistifiable container

More...
 

Detailed Description

interface to TRT straw alignment constants

Definition at line 33 of file TRT_StrawAlignDbSvc.h.

Constructor & Destructor Documentation

◆ TRT_StrawAlignDbSvc()

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

constructor

Definition at line 27 of file TRT_StrawAlignDbSvc.cxx.

29  : base_class(name,pSvcLocator),
30  m_detStore("DetectorStore",name),
31  m_par_dxcontainerkey("/TRT/Calib/DX"),
33  m_par_forcecallback(false),
34  m_trtid(nullptr),
35  m_trtman(nullptr),
36  m_streamer("AthenaOutputStreamTool/CondStream1")
37 {
38  declareProperty("StrawTextFile",m_par_strawtextfile);
39  declareProperty("ForceCallback",m_par_forcecallback);
40  declareProperty("StreamTool",m_streamer);
41  declareProperty("DetectorStore",m_detStore);
42 }

◆ ~TRT_StrawAlignDbSvc()

TRT_StrawAlignDbSvc::~TRT_StrawAlignDbSvc ( )
virtualdefault

destructor

Member Function Documentation

◆ finalize()

StatusCode TRT_StrawAlignDbSvc::finalize ( )
virtual

tool finalize

Definition at line 83 of file TRT_StrawAlignDbSvc.cxx.

84 {
85  ATH_MSG_INFO ("TRT_StrawAlignDbSvc finalize method called");
86  return StatusCode::SUCCESS;
87 }

◆ getConstDxContainer()

const TRT_StrawAlignDbSvc::StrawDxContainer * TRT_StrawAlignDbSvc::getConstDxContainer ( ) const
inline

Definition at line 118 of file TRT_StrawAlignDbSvc.h.

119 {
120  const StrawDxContainer* rc = nullptr;
121  if (m_dxcontainer.isValid())
122  rc = m_dxcontainer.cptr();
123  else {
124  if (m_detStore->retrieve (rc, m_par_dxcontainerkey).isFailure()) {
125  ATH_MSG_ERROR("Cannot retrieve " << m_par_dxcontainerkey);
126  }
127  }
128  return rc;
129  return const_cast<StrawDxContainer*>(rc) ;
130 }

◆ getDx1()

float TRT_StrawAlignDbSvc::getDx1 ( const Identifier id) const
inline

get shift near electronics

Definition at line 149 of file TRT_StrawAlignDbSvc.h.

150 {
152 }

◆ getDx2()

float TRT_StrawAlignDbSvc::getDx2 ( const Identifier id) const
inline

get shift far from electronics

Definition at line 155 of file TRT_StrawAlignDbSvc.h.

156 {
158 }

◆ getDxContainer()

TRT_StrawAlignDbSvc::StrawDxContainer * TRT_StrawAlignDbSvc::getDxContainer ( ) const
inline

access to containers

Definition at line 112 of file TRT_StrawAlignDbSvc.h.

112  {
113  const StrawDxContainer* rc = getConstDxContainer();
114  return const_cast<StrawDxContainer*>(rc) ;
115 }

◆ getDxErr()

float TRT_StrawAlignDbSvc::getDxErr ( const Identifier id) const
inline

get error on shift

Definition at line 161 of file TRT_StrawAlignDbSvc.h.

162 {
164 }

◆ initialize()

StatusCode TRT_StrawAlignDbSvc::initialize ( )
virtual

tool initialize

Definition at line 49 of file TRT_StrawAlignDbSvc.cxx.

50 {
51  ATH_MSG_INFO ("TRT_StrawAlignDbSvc initialize method called");
52 
53  ATH_CHECK( m_detStore->retrieve(m_trtid,"TRT_ID") );
54  ATH_CHECK( m_detStore->retrieve(m_trtman,"TRT") );
55 
56 
57  bool dxcontainerexists = m_detStore->StoreGateSvc::contains<StrawDxContainer>(m_par_dxcontainerkey) ;
58 
59  if( dxcontainerexists ) {
60  ATH_MSG_INFO (" dx container exists - reg callback ");
62  ATH_MSG_ERROR ("Could not register IOV callback for key: " << m_par_dxcontainerkey);
63 
64  } else {
65 
66  // create, record and update data handle
67  ATH_MSG_INFO ("Creating new dx container");
68  auto dxcontainer = std::make_unique<StrawDxContainer>();
69 
70  // reading from file
71  if( !m_par_strawtextfile.empty() ) {
72  ATH_CHECK( this->readTextFile(dxcontainer.get(),
74  }
75 
76  ATH_CHECK( m_detStore->record(std::move(dxcontainer), m_par_dxcontainerkey) );
77  }
78 
79  return StatusCode::SUCCESS;
80 }

◆ IOVCallBack()

StatusCode TRT_StrawAlignDbSvc::IOVCallBack ( IOVSVC_CALLBACK_ARGS  )

IOV call back for dx objects. normally this doesn't do anything.

Definition at line 206 of file TRT_StrawAlignDbSvc.cxx.

207 {
208  for (std::list<std::string>::const_iterator
209  itr=keys.begin(); itr!=keys.end(); ++itr)
210  ATH_MSG_INFO (" IOVCALLBACK for key " << *itr << " number " << I);
211 
212  // if constants need to be read from textfile, we use the call back routine to refill the IOV objects
214 
215  return StatusCode::SUCCESS;
216 }

◆ readTextFile() [1/2]

StatusCode TRT_StrawAlignDbSvc::readTextFile ( const std::string &  file)
virtual

read calibration from text file into TDS

Definition at line 124 of file TRT_StrawAlignDbSvc.cxx.

125 {
126  return readTextFile( getDxContainer(), filename );
127 }

◆ readTextFile() [2/2]

StatusCode TRT_StrawAlignDbSvc::readTextFile ( StrawDxContainer *  dxcontainer,
const std::string &  file 
)

Definition at line 130 of file TRT_StrawAlignDbSvc.cxx.

132 {
133  ATH_MSG_INFO ("Reading straw alignment data from text file " << filename);
134 
135  if(!dxcontainer) {
136  ATH_MSG_WARNING (" Could not find the container ");
137  return StatusCode::FAILURE;
138  }
139  dxcontainer->clear() ;
140  std::ifstream infile(filename.c_str()) ;
142  float dx1,dx2,dxerr;
143  int nentries(0) ;
144  while ((infile >> id >> dx1 >> dx2 >> dxerr ) ) {
145  setDx(id,dx1,dx2,dxerr) ;
146  ATH_MSG_DEBUG (" read from file: dx1 " << dx1 << " dx2 " << dx2 << " dxerr " << dxerr);
147  ++nentries ;
148  }
149  size_t dxfootprint = dxcontainer->footprint() ;
150  ATH_MSG_INFO (" read " << nentries << " from file. ");
151  ATH_MSG_INFO (" dx footprints " << dxfootprint);
152  ATH_MSG_INFO (" (no compression) ");
153 
154  // force a call back in the geometry
155  int i(0);
156  std::list<std::string> keys ;
157  (const_cast<InDetDD::TRT_DetectorManager*>(m_trtman))->align(i,keys).ignore() ;
158 
159  return StatusCode::SUCCESS ;
160 }

◆ registerObjects()

StatusCode TRT_StrawAlignDbSvc::registerObjects ( std::string  tag,
int  run1,
int  event1,
int  run2,
int  event2 
) const

register calibration objects with the IoV service

Definition at line 186 of file TRT_StrawAlignDbSvc.cxx.

187 {
188  ATH_MSG_INFO ("registerObjects with IOV ");
189  ATH_MSG_INFO ("Run/evt1 [" << run1 << "," << event1 << "]");
190  ATH_MSG_INFO ("Run/evt2 [" << run2 << "," << event2 << "]");
191 
192  // get pointer to registration svc
193  SmartIF<IIOVRegistrationSvc> regsvc{service("IOVRegistrationSvc")};
194  ATH_CHECK( regsvc.isValid() );
195 
196  if (StatusCode::SUCCESS==regsvc->registerIOV(StrawDxContainer::classname(),
197  m_par_dxcontainerkey,tag,run1,run2,event1,event2))
198  ATH_MSG_INFO ("Registered StrawDxContainer object with key " << m_par_dxcontainerkey);
199  else
200  ATH_MSG_ERROR ("Could not register StrawDxContainer object with key " << m_par_dxcontainerkey);
201 
202  return( StatusCode::SUCCESS);
203 }

◆ setDx() [1/2]

void TRT_StrawAlignDbSvc::setDx ( const Identifier id,
float  dx1,
float  dx2,
float  dxerr 
)
inline

set shifts

Definition at line 167 of file TRT_StrawAlignDbSvc.h.

168 {
169  setDx( trtcondid(id,TRTCond::ExpandedIdentifier::STRAW), dx1, dx2, dxerr) ;
170 }

◆ setDx() [2/2]

void TRT_StrawAlignDbSvc::setDx ( const TRTCond::ExpandedIdentifier id,
float  dx1,
float  dx2,
float  dxerr 
)
inline

set endpoints for a TRTCond::ExpandedIdentifier

Definition at line 142 of file TRT_StrawAlignDbSvc.h.

143 {
144  //std::cout << " Setting the dx1 to " << dx1 << " dx2 to " << dx2 << std::endl;
145  getDxContainer()->setDx( id, dx1, dx2, dxerr);
146 }

◆ streamOutObjects()

StatusCode TRT_StrawAlignDbSvc::streamOutObjects ( ) const

write the calibration objects to output, after cleaning

Definition at line 163 of file TRT_StrawAlignDbSvc.cxx.

164 {
165  ATH_MSG_INFO ("entering streamOutObjects ");
166 
167  // Get Output Stream tool for writing
168  ATH_CHECK( m_streamer.retrieve() );
169 
170  IAthenaOutputStreamTool* streamer=const_cast<IAthenaOutputStreamTool*>(&(*m_streamer));
171 
172  ATH_CHECK( streamer->connectOutput() );
173 
175  typeKeys.push_back( IAthenaOutputStreamTool::TypeKeyPair(StrawDxContainer::classname(),m_par_dxcontainerkey)) ;
176  getDxContainer()->crunch() ;
177 
178  ATH_CHECK( streamer->streamObjects(typeKeys) );
179  ATH_CHECK( streamer->commitOutput() );
180 
181  ATH_MSG_INFO (" Streamed out and committed " << typeKeys.size() << " objects ");
182  return StatusCode::SUCCESS;
183 }

◆ trtcondid()

TRTCond::ExpandedIdentifier TRT_StrawAlignDbSvc::trtcondid ( const Identifier id,
int  level = TRTCond::ExpandedIdentifier::STRAW 
) const
inline

create an TRTCond::ExpandedIdentifier from a TRTID identifier

Definition at line 133 of file TRT_StrawAlignDbSvc.h.

134 {
137  m_trtid->straw(id),level ) ;
138 }

◆ writeTextFile()

StatusCode TRT_StrawAlignDbSvc::writeTextFile ( const std::string &  file) const

write calibration constants to flat text file

Definition at line 89 of file TRT_StrawAlignDbSvc.cxx.

90 {
91  ATH_MSG_INFO (" Write straw alignment data to text file " << filename);
92  std::ofstream outfile(filename.c_str());
93 
94 
95  // first reduce the container as much as possible
96  // getDxContainer()->crunch() ;
97 
98  StrawDxContainer::FlatContainer packedstrawdata ;
99  const StrawDxContainer* dxcontainer = getConstDxContainer();
100  dxcontainer->getall( packedstrawdata ) ;
101 
102  // now, we store the entries
103  ATH_MSG_INFO ("Number of entries in flatcontainer: "
104  << packedstrawdata.size());
105 
106  for(auto & it : packedstrawdata) {
107  const TRTCond::ExpandedIdentifier& calid = it.first ;
108  // get the end point corrections. if not the right type, store zeros.
109  float dx1=dxcontainer->getDx1(calid) ;
110  float dx2=dxcontainer->getDx2(calid) ;
111  float dxerr=dxcontainer->getDxErr(calid) ;
112  outfile << calid << " "
113  << std::setprecision(5)
114  << std::setw(12) << dx1 << " "
115  << std::setw(12) << dx2 << " "
116  << std::setw(12) << dxerr << std::endl ;
117  }
118  outfile.close() ;
119  return StatusCode::SUCCESS ;
120 }

Member Data Documentation

◆ m_detStore

ServiceHandle<StoreGateSvc> TRT_StrawAlignDbSvc::m_detStore
private

Definition at line 94 of file TRT_StrawAlignDbSvc.h.

◆ m_dxcontainer

const DataHandle<StrawDxContainer> TRT_StrawAlignDbSvc::m_dxcontainer
private

detector manager

Definition at line 102 of file TRT_StrawAlignDbSvc.h.

◆ m_par_dxcontainerkey

std::string TRT_StrawAlignDbSvc::m_par_dxcontainerkey
private

Definition at line 95 of file TRT_StrawAlignDbSvc.h.

◆ m_par_forcecallback

bool TRT_StrawAlignDbSvc::m_par_forcecallback
private

input text file

Definition at line 97 of file TRT_StrawAlignDbSvc.h.

◆ m_par_strawtextfile

std::string TRT_StrawAlignDbSvc::m_par_strawtextfile
private

folder name

Definition at line 96 of file TRT_StrawAlignDbSvc.h.

◆ m_streamer

ToolHandle<IAthenaOutputStreamTool> TRT_StrawAlignDbSvc::m_streamer
private

persistifiable container

Definition at line 104 of file TRT_StrawAlignDbSvc.h.

◆ m_trtid

const TRT_ID* TRT_StrawAlignDbSvc::m_trtid
private

force callback to manager

Definition at line 98 of file TRT_StrawAlignDbSvc.h.

◆ m_trtman

const InDetDD::TRT_DetectorManager* TRT_StrawAlignDbSvc::m_trtman
private

id helper

Definition at line 99 of file TRT_StrawAlignDbSvc.h.


The documentation for this class was generated from the following files:
TRT_StrawAlignDbSvc::m_trtman
const InDetDD::TRT_DetectorManager * m_trtman
id helper
Definition: TRT_StrawAlignDbSvc.h:99
TRT_StrawAlignDbSvc::getConstDxContainer
const StrawDxContainer * getConstDxContainer() const
Definition: TRT_StrawAlignDbSvc.h:118
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:100
TRT_StrawAlignDbSvc::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
persistifiable container
Definition: TRT_StrawAlignDbSvc.h:104
run.infile
string infile
Definition: run.py:13
TRT_StrawAlignDbSvc::setDx
void setDx(const TRTCond::ExpandedIdentifier &id, float dx1, float dx2, float dxerr)
set endpoints for a TRTCond::ExpandedIdentifier
Definition: TRT_StrawAlignDbSvc.h:142
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TRT_StrawAlignDbSvc::IOVCallBack
StatusCode IOVCallBack(IOVSVC_CALLBACK_ARGS)
IOV call back for dx objects. normally this doesn't do anything.
Definition: TRT_StrawAlignDbSvc.cxx:206
TRT_StrawAlignDbSvc::m_par_forcecallback
bool m_par_forcecallback
input text file
Definition: TRT_StrawAlignDbSvc.h:97
DataHandle::cptr
const_pointer_type cptr() const
safer explicit ptr accessor
IAthenaOutputStreamTool
This is a tool that allows streaming out of DataObjects. This has been factorized out from AthenaOutp...
Definition: IAthenaOutputStreamTool.h:69
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TRT_StrawAlignDbSvc::readTextFile
virtual StatusCode readTextFile(const std::string &file)
read calibration from text file into TDS
Definition: TRT_StrawAlignDbSvc.cxx:124
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
TRT_ID::straw
int straw(const Identifier &id) const
Definition: TRT_ID.h:902
TRT_StrawAlignDbSvc::m_dxcontainer
const DataHandle< StrawDxContainer > m_dxcontainer
detector manager
Definition: TRT_StrawAlignDbSvc.h:102
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
maskDeadModules.run1
run1
Definition: maskDeadModules.py:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT_StrawAlignDbSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: TRT_StrawAlignDbSvc.h:94
IAthenaOutputStreamTool::connectOutput
virtual StatusCode connectOutput(const std::string &outputName="")=0
Connect to the output stream Must connectOutput BEFORE streaming Only specify "outputName" if one wan...
IAthenaOutputStreamTool::TypeKeyPair
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
Definition: IAthenaOutputStreamTool.h:99
DataHandle::isValid
bool isValid() const
RETRIEVES the DO to check it is valid and unlocked.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:866
TRT_ID::straw_layer
int straw_layer(const Identifier &id) const
Definition: TRT_ID.h:893
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:884
ReadCellNoiseFromCoolCompare.run2
run2
Definition: ReadCellNoiseFromCoolCompare.py:53
TRT_StrawAlignDbSvc::m_par_strawtextfile
std::string m_par_strawtextfile
folder name
Definition: TRT_StrawAlignDbSvc.h:96
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TRT_StrawAlignDbSvc::trtcondid
TRTCond::ExpandedIdentifier trtcondid(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const
create an TRTCond::ExpandedIdentifier from a TRTID identifier
Definition: TRT_StrawAlignDbSvc.h:133
TRTCond::ExpandedIdentifier::STRAW
@ STRAW
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: TRT_ID.h:875
IAthenaOutputStreamTool::commitOutput
virtual StatusCode commitOutput(bool doCommit=false)=0
Commit the output stream after having streamed out objects Must commitOutput AFTER streaming.
InDetDD::TRT_DetectorManager
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
Definition: TRT_DetectorManager.h:69
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TRT_StrawAlignDbSvc::getDxContainer
StrawDxContainer * getDxContainer() const
access to containers
Definition: TRT_StrawAlignDbSvc.h:112
TRT_StrawAlignDbSvc::m_trtid
const TRT_ID * m_trtid
force callback to manager
Definition: TRT_StrawAlignDbSvc.h:98
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
I
#define I(x, y, z)
Definition: MD5.cxx:116
TRTCond::ExpandedIdentifier
Identifier for TRT detector elements in the conditions code.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:30
IAthenaOutputStreamTool::streamObjects
virtual StatusCode streamObjects(const TypeKeyPairs &typeKeys, const std::string &outputName="")=0
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
python.trfValidateRootFile.rc
rc
Definition: trfValidateRootFile.py:355
TRT_StrawAlignDbSvc::m_par_dxcontainerkey
std::string m_par_dxcontainerkey
Definition: TRT_StrawAlignDbSvc.h:95