ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_CalDbTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "TRT_CalDbTool.h"
11
12#include <fstream>
13#include <iostream>
14#include <iomanip>
15#include <sstream>
16
17#include "GaudiKernel/IToolSvc.h"
18#include "GaudiKernel/ThreadLocalContext.h"
20
21
22TRT_CalDbTool::TRT_CalDbTool( const std::string& type, const std::string& name, const IInterface* parent)
23 : base_class(type, name, parent),
24 m_trtId(nullptr)
25{}
26
27
29{
30 ATH_MSG_DEBUG( " in initialize " );
31
32
33 // Get the TRT ID helper
34 StatusCode sc = detStore()->retrieve(m_trtId,"TRT_ID");
35 if(sc.isFailure()) {
36 ATH_MSG_FATAL("Problem retrieving TRTID helper");
37 return StatusCode::FAILURE;
38 }
39
40 // Read keys
41
42 ATH_CHECK( m_rtReadKey.initialize() );
43 ATH_CHECK( m_errReadKey.initialize() );
44 ATH_CHECK( m_slopeReadKey.initialize() );
45 ATH_CHECK( m_t0ReadKey.initialize() );
46
47 ATH_MSG_DEBUG(" TRT_CalDbTool::initialized ");
48
49 return StatusCode::SUCCESS;
50}
51
52
53
55{
56 ATH_MSG_DEBUG("TRT_CalDbTool finalize method called");
57 return StatusCode::SUCCESS;
58}
59
60
61const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getRtContainer() const {
62
64 return *rtc;
65}
66
67const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getErrContainer() const {
68
70 return *rtc;
71}
72
73const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getSlopeContainer() const {
74
75 SG::ReadCondHandle<RtRelationContainer> rtc(m_slopeReadKey); // find the right conditions
76 return *rtc;
77}
78
79const TRT_CalDbTool::StrawT0Container* TRT_CalDbTool::getT0Container() const {
80
81 SG::ReadCondHandle<StrawT0Container> rtc(m_t0ReadKey); // find the right conditions
82 return *rtc;
83}
84
85
86
87double TRT_CalDbTool::driftRadius(const double& time, float& t0, const Identifier& ident,bool& found) const
88{
89 // Returns a drift radius, a t0 and a success indicator,
90 // given an identifier and a time given by (leading_edge_bin+0.5)*3.125ns
91 found=true;
92 t0 = this->getT0(ident);
93 const TRTCond::RtRelation* rtr = getRtRelation(ident) ;
94 double radius = 0;
95 if (rtr != nullptr)
96 radius = rtr->radius( time - t0 );
97 else
98 ATH_MSG_FATAL(" cannot find an rt-relation for TRT layer_or_wheel " << m_trtId->layer_or_wheel(ident) << " Please check IOV ranges ");
99
100 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " radius " << radius);
101 //
102 if( radius<0 ) radius=0 ;
103 else if( radius>2.) radius=2.;
104
105 // add protection for the turnover:
106 if (time - t0 > 55){
107 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " > 55, check Rt derivative");
108 // Check Second Derivative.
109 if (rtr != nullptr){
110 if (rtr->drdt( time - t0 ) < 0 ){
111 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " and rt derivative: " << rtr->drdt( time - t0 ));
112 radius=2.;
113 }
114 }
115 }
116 return radius;
117}
118
119double TRT_CalDbTool::driftError( const double& time, const Identifier& ident,bool& found) const
120{
121 // Returns an error on drift radius and a success indicator,
122 // given an identifier and a drift-time in ns
123 found=true;
124 const TRTCond::RtRelation* rtr = getErrors(ident) ;
125 double error=0.;
126 if(rtr) {
127 error = rtr->radius( time );
128 } else {
129 found=false;
130 return 0;
131 }
132 ATH_MSG_VERBOSE(" time " << time << " error on radius " << error);
133 return error;
134}
135
136double TRT_CalDbTool::driftSlope( const double& time, const Identifier& ident,bool& found) const
137{
138 // Returns an error on drift radius and a success indicator,
139 // given an identifier and a drift-time in ns
140 found=true;
141 const TRTCond::RtRelation* rtr = getSlopes(ident) ;
142 double slope=0.;
143 if(rtr) {
144 slope = rtr->radius( time );
145 } else {
146 found=false;
147 return 0;
148 }
149 ATH_MSG_VERBOSE(" time " << time << " slope on radius " << slope);
150 return slope;
151}
152
153
154
155
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
static Double_t t0
interface to TRT calibration constants
Base class for rt-relations in the TRT.
Definition RtRelation.h:27
virtual float drdt(float driftime) const =0
driftvelocity for given drifttime
virtual float radius(float driftime) const =0
radius for given drifttime
virtual const TRTCond::RtRelation * getErrors(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const override
get errors for an identifier
virtual const StrawT0Container * getT0Container() const override
SG::ReadCondHandleKey< RtRelationContainer > m_slopeReadKey
virtual const RtRelationContainer * getSlopeContainer() const override
virtual const TRTCond::RtRelation * getRtRelation(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const override
get an rtrelation for an identifier
virtual StatusCode initialize() override
tool initialize
virtual double driftError(const double &time, const Identifier &ident, bool &found) const override
get a drift radius error for a given drifttime
SG::ReadCondHandleKey< RtRelationContainer > m_errReadKey
virtual double driftSlope(const double &time, const Identifier &ident, bool &found) const override
get a drift radius error for a given drifttime
virtual const RtRelationContainer * getErrContainer() const override
const TRT_ID * m_trtId
id helper
SG::ReadCondHandleKey< RtRelationContainer > m_rtReadKey
ReadHandle keys.
virtual const RtRelationContainer * getRtContainer() const override
access to calibration constant containers
virtual float getT0(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const override
get T0 for an identifier
SG::ReadCondHandleKey< StrawT0Container > m_t0ReadKey
virtual StatusCode finalize() override
tool finalize
virtual double driftRadius(const double &time, float &t0, const Identifier &ident, bool &found) const override
get a drift radius for a given leading edge time
TRT_CalDbTool(const std::string &type, const std::string &name, const IInterface *parent)
typedefs, enums etc
virtual const TRTCond::RtRelation * getSlopes(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const override
get errors for an identifier