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"
19
20
21TRT_CalDbTool::TRT_CalDbTool( const std::string& type, const std::string& name, const IInterface* parent)
22 : base_class(type, name, parent),
23 m_trtId(nullptr)
24{}
25
26
28{
29 ATH_MSG_DEBUG( " in initialize " );
30
31
32 // Get the TRT ID helper
33 StatusCode sc = detStore()->retrieve(m_trtId,"TRT_ID");
34 if(sc.isFailure()) {
35 ATH_MSG_FATAL("Problem retrieving TRTID helper");
36 return StatusCode::FAILURE;
37 }
38
39 // Read keys
40
41 ATH_CHECK( m_rtReadKey.initialize() );
42 ATH_CHECK( m_errReadKey.initialize() );
43 ATH_CHECK( m_slopeReadKey.initialize() );
44 ATH_CHECK( m_t0ReadKey.initialize() );
45
46 ATH_MSG_DEBUG(" TRT_CalDbTool::initialized ");
47
48 return StatusCode::SUCCESS;
49}
50
51
52
54{
55 ATH_MSG_DEBUG("TRT_CalDbTool finalize method called");
56 return StatusCode::SUCCESS;
57}
58
59
60const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getRtContainer() const {
61
63 return *rtc;
64}
65
66const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getErrContainer() const {
67
69 return *rtc;
70}
71
72const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getSlopeContainer() const {
73
74 SG::ReadCondHandle<RtRelationContainer> rtc(m_slopeReadKey); // find the right conditions
75 return *rtc;
76}
77
78const TRT_CalDbTool::StrawT0Container* TRT_CalDbTool::getT0Container() const {
79
80 SG::ReadCondHandle<StrawT0Container> rtc(m_t0ReadKey); // find the right conditions
81 return *rtc;
82}
83
84
85
86double TRT_CalDbTool::driftRadius(const double& time, float& t0, const Identifier& ident,bool& found) const
87{
88 // Returns a drift radius, a t0 and a success indicator,
89 // given an identifier and a time given by (leading_edge_bin+0.5)*3.125ns
90 found=true;
91 t0 = this->getT0(ident);
92 const TRTCond::RtRelation* rtr = getRtRelation(ident) ;
93 double radius = 0;
94 if (rtr != nullptr)
95 radius = rtr->radius( time - t0 );
96 else
97 ATH_MSG_FATAL(" cannot find an rt-relation for TRT layer_or_wheel " << m_trtId->layer_or_wheel(ident) << " Please check IOV ranges ");
98
99 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " radius " << radius);
100 //
101 if( radius<0 ) radius=0 ;
102 else if( radius>2.) radius=2.;
103
104 // add protection for the turnover:
105 if (time - t0 > 55){
106 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " > 55, check Rt derivative");
107 // Check Second Derivative.
108 if (rtr != nullptr){
109 if (rtr->drdt( time - t0 ) < 0 ){
110 ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " and rt derivative: " << rtr->drdt( time - t0 ));
111 radius=2.;
112 }
113 }
114 }
115 return radius;
116}
117
118double TRT_CalDbTool::driftError( const double& time, const Identifier& ident,bool& found) const
119{
120 // Returns an error on drift radius and a success indicator,
121 // given an identifier and a drift-time in ns
122 found=true;
123 const TRTCond::RtRelation* rtr = getErrors(ident) ;
124 double error=0.;
125 if(rtr) {
126 error = rtr->radius( time );
127 } else {
128 found=false;
129 return 0;
130 }
131 ATH_MSG_VERBOSE(" time " << time << " error on radius " << error);
132 return error;
133}
134
135double TRT_CalDbTool::driftSlope( const double& time, const Identifier& ident,bool& found) const
136{
137 // Returns an error on drift radius and a success indicator,
138 // given an identifier and a drift-time in ns
139 found=true;
140 const TRTCond::RtRelation* rtr = getSlopes(ident) ;
141 double slope=0.;
142 if(rtr) {
143 slope = rtr->radius( time );
144 } else {
145 found=false;
146 return 0;
147 }
148 ATH_MSG_VERBOSE(" time " << time << " slope on radius " << slope);
149 return slope;
150}
151
152
153
154
#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