39 return StatusCode::FAILURE;
44 ATH_MSG_FATAL(
" No input text file supplied. Nothing can be done. ");
45 return StatusCode::FAILURE;
51 return StatusCode::FAILURE;
54 return StatusCode::SUCCESS;
59 StatusCode sc = StatusCode::SUCCESS;
65 StatusCode sc = StatusCode::SUCCESS;
72 StatusCode sc=StatusCode::SUCCESS ;
73 std::ifstream infile(filename) ;
76 sc=StatusCode::FAILURE;
81 infile.getline(line,512) ;
82 std::string linestring(line) ;
83 size_t pos = linestring.find(
"Fileformat") ;
84 if(pos != std::string::npos) {
85 sscanf(line,
"# Fileformat=%d",&format) ;
87 ATH_MSG_WARNING(
"Input file has no Fileformat identifier. Assuming format=0.");
91 infile.open(filename) ;
101 StatusCode sc=StatusCode::SUCCESS ;
102 std::ifstream infile(filename) ;
109 infile.getline(line,512) ;
110 std::string linestring(line) ;
111 size_t pos = linestring.find(
"Fileformat") ;
112 if(pos != std::string::npos) {
113 sscanf(line,
"# Fileformat=%d",&format) ;
115 ATH_MSG_WARNING(
"Input file has no Fileformat identifier. Assuming format=1");
119 infile.open(filename) ;
121 ATH_MSG_INFO(
"Reading calibration data from text file " << filename <<
" format " << format ) ;
139 enum ReadMode { ReadingRtRelation, ReadingStrawT0, ReadingGarbage } ;
140 ReadMode readmode =ReadingGarbage ;
148 int nrtrelations(0), nstrawt0(0) ;
149 while( infile.getline(line,512) ) {
152 std::string linestring(line) ;
153 if(linestring.find(
"RtRelation") != std::string::npos) {
154 readmode = ReadingRtRelation ;
157 }
else if (linestring.find(
"StrawT0") != std::string::npos) {
158 readmode = ReadingStrawT0 ;
161 }
else readmode = ReadingGarbage ;
162 }
else if( readmode != ReadingGarbage) {
163 std::istringstream is(line) ;
172 if( readmode == ReadingRtRelation ) {
177 rtContainer->
set(
id,rt);
180 }
else if( readmode == ReadingStrawT0 ) {
182 float t0(0), t0err(0) ;
188 t0Container->
setT0(
id, t0, t0err );
199 size_t t0footprint = t0Container->
footprint() ;
200 size_t rtfootprint = rtContainer->
footprint() ;
203 ATH_MSG_INFO(
"read " << nstrawt0 <<
" t0 and " << nrtrelations <<
" rt from file. "
204 <<
" t0/rt footprints " << t0footprint <<
" / " << rtfootprint ) ;
213 return StatusCode::FAILURE;
216 ATH_MSG_FATAL(
"Could not retrieve data handle for StrawT0Container " );
217 return StatusCode::FAILURE ;
227 return StatusCode::FAILURE;
230 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
231 return StatusCode::FAILURE ;
238 return StatusCode::SUCCESS ;
245 enum ReadMode { ReadingRtRelation, ReadingErrors, ReadingStrawT0, ReadingGarbage } ;
246 ReadMode readmode =ReadingGarbage ;
248 int nrtrelations(0), nerrors(0), nstrawt0(0) ;
256 while( infile.getline(line,512) ) {
259 std::string linestring(line) ;
260 if( linestring.find(
"RtRelation") != std::string::npos) {
261 readmode = ReadingRtRelation ;
263 rtContainer->
clear() ;
264 }
else if(linestring.find(
"StrawT0") != std::string::npos) {
265 readmode = ReadingStrawT0 ;
267 t0Container->
clear() ;
268 }
else if(linestring.find(
"RtErrors") != std::string::npos) {
269 readmode = ReadingErrors ;
271 errContainer->
clear() ;
272 }
else { readmode = ReadingGarbage ; }
273 }
else if( readmode != ReadingGarbage) {
274 std::istringstream is(line) ;
282 if( readmode == ReadingRtRelation ) {
286 rtContainer->
set(
id,rt);
290 }
else if( readmode == ReadingErrors ) {
294 errContainer->
set(
id,err);
298 }
else if( readmode == ReadingStrawT0 ) {
300 float t0(0), t0err(0) ;
303 t0Container->
setT0(
id, t0, t0err );
310 size_t t0footprint = t0Container->
footprint() ;
311 size_t rtfootprint = rtContainer->
footprint() ;
312 size_t errfootprint = errContainer->
footprint() ;
314 ATH_MSG_INFO(
"read " << nstrawt0 <<
" t0 and " << nerrors <<
" errors and " << nrtrelations <<
" rt relations "
315 <<
" t0/rt/err footprints " << t0footprint <<
" / " << rtfootprint <<
" / " << errfootprint ) ;
322 return StatusCode::FAILURE;
325 ATH_MSG_FATAL(
"Could not retrieve data handle for StrawT0Container " );
326 return StatusCode::FAILURE ;
336 return StatusCode::FAILURE;
339 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
340 return StatusCode::FAILURE ;
349 return StatusCode::FAILURE;
352 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
353 return StatusCode::FAILURE ;
359 return StatusCode::SUCCESS ;
373 enum ReadMode { ReadingRtRelation, ReadingErrors, ReadingSlopes, ReadingStrawT0, ReadingGarbage } ;
374 ReadMode readmode =ReadingGarbage ;
376 int nrtrelations(0), nerrors(0), nslopes(0), nstrawt0(0) ;
378 while( infile.getline(line,512) ) {
381 std::string linestring(line) ;
382 if( linestring.find(
"RtRelation") != std::string::npos) {
383 readmode = ReadingRtRelation ;
384 rtContainer->
clear() ;
386 }
else if(linestring.find(
"RtErrors") != std::string::npos) {
387 readmode = ReadingErrors ;
388 errContainer->
clear() ;
390 }
else if(linestring.find(
"RtSlopes") != std::string::npos) {
391 readmode = ReadingSlopes ;
392 slopeContainer->
clear() ;
394 }
else if(linestring.find(
"StrawT0") != std::string::npos) {
395 readmode = ReadingStrawT0 ;
396 t0Container->
clear() ;
398 }
else { readmode = ReadingGarbage ; }
399 }
else if( readmode != ReadingGarbage) {
400 std::istringstream is(line) ;
408 if( readmode == ReadingRtRelation ) {
412 rtContainer->
set(
id,rt);
416 }
else if( readmode == ReadingErrors ) {
420 errContainer->
set(
id,err);
424 }
else if( readmode == ReadingSlopes ) {
428 slopeContainer->
set(
id,slope);
432 }
else if( readmode == ReadingStrawT0 ) {
434 float t0(0), t0err(0) ;
437 t0Container->
setT0(
id, t0, t0err );
443 size_t t0footprint = t0Container->
footprint() ;
444 size_t rtfootprint = rtContainer->
footprint() ;
445 size_t errfootprint = errContainer->
footprint() ;
446 size_t slopefootprint = slopeContainer->
footprint() ;
448 ATH_MSG_INFO(
"read " << nstrawt0 <<
" t0 and " << nerrors <<
" errors and " << nrtrelations <<
" rt relations and " << nslopes <<
" error slopes "
449 <<
" t0/rt/err/slope footprints " << t0footprint <<
" / " << rtfootprint <<
" / " << errfootprint <<
" / " << slopefootprint) ;
457 return StatusCode::FAILURE;
460 ATH_MSG_FATAL(
"Could not retrieve data handle for StrawT0Container " );
461 return StatusCode::FAILURE ;
471 return StatusCode::FAILURE;
474 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
475 return StatusCode::FAILURE ;
484 return StatusCode::FAILURE;
487 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
488 return StatusCode::FAILURE ;
497 return StatusCode::FAILURE;
500 ATH_MSG_FATAL(
"Could not retrieve data handle for RtRelationContainer " );
501 return StatusCode::FAILURE ;
508 return StatusCode::SUCCESS ;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Algorithm to read TRT Conditions objects from text file and stream them to db.
This is an Identifier helper class for the TRT subdetector.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode readTextFile_Format3(std::istream &)
virtual StatusCode readTextFile(const std::string &file, int &format)
Gaudi::Property< std::string > m_par_slopecontainerkey
Gaudi::Property< std::string > m_par_errcontainerkey
virtual StatusCode finalize(void) override
TRTCondStoreText(const std::string &name, ISvcLocator *pSvcLocator)
constructor
Gaudi::Property< std::string > m_par_caltextfile
virtual StatusCode checkTextFile(const std::string &file, int &format)
read calibration from text file into TDS
Gaudi::Property< std::string > m_par_rtcontainerkey
virtual StatusCode initialize(void) override
virtual StatusCode readTextFile_Format2(std::istream &)
Gaudi::Property< std::string > m_par_t0containerkey
const TRT_ID * m_trtid
trt id helper
TRTCond::StrawT0MultChanContainer StrawT0Container
virtual StatusCode execute(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 readTextFile_Format1(std::istream &)
TRTCond::RtRelationMultChanContainer RtRelationContainer
Identifier for TRT detector elements in the conditions code.
void set(const ExpandedIdentifier &id, const typename DaughterContainer::value_type &t)
set a value
void clear()
clear all layercontainers
size_t footprint() const
return the memory allocated by the layercontainers.
StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
static RtRelation * readFromFile(std::istream &is)
read method
Multichannel container for RtRelation objects.
Base class for rt-relations in the TRT.
A COOL Multichannel container for StrawT0 objects.
void setT0(const ExpandedIdentifier &id, float t0, float t0err)
set t0