ATLAS Offline Software
Loading...
Searching...
No Matches
InDetFixedWindowTrackTimeTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4
6// InDetFixedWindowTrackTimeTool.cxx, (c) ATLAS Detector software
8
10
12
15
18//================ Constructor =================================================
19
21 , std::string const& n
22 , IInterface const* p
23 ) : AthAlgTool(t, n, p)
24 , m_caldbtool("TRT_CalDbTool", this) {
25 declareInterface<IInDetCosmicsEventPhaseTool>(this);
26 declareProperty("TRTCalDbTool", m_caldbtool);
27 declareProperty("GlobalOffset", m_globalOffset = 10.);
28 declareProperty("UseNewEP", m_useNewEP = true);
29 declareProperty("WindowCenter", m_windowCenter = -8.5);
30 declareProperty("WindowSize", m_windowSize = 7.);
31}
32
33//================ Destructor =================================================
34
37
38
39//================ Initialisation =================================================
40
42 ATH_CHECK(m_caldbtool.retrieve());
43 // Read key
44 ATH_CHECK( m_T0ReadKey.initialize() );
45
46 return StatusCode::SUCCESS;
47}
48
49//================ Finalisation =================================================
50
52 return StatusCode::SUCCESS;
53}
54
55//============================================================================================
56
57
59 ATH_MSG_DEBUG("Finding phase...");
60
62 const TRTCond::AverageT0* avgT0{*rhl};
63
64 TRTCond::RtRelation const* rtr = nullptr;
65
66 double timeresidualsum = 0;
67 size_t ntrthits = 0;
68
69 for (const Trk::TrackStateOnSurface* state : *track->trackStateOnSurfaces()) {
70 Trk::MeasurementBase const* mesb = state->measurementOnTrack();
71 if (!mesb
73 ) continue;
74
75 InDet::TRT_DriftCircleOnTrack const* trtcirc = dynamic_cast<InDet::TRT_DriftCircleOnTrack const*>(mesb);
76
77 if (!trtcirc) continue;
78
79 InDet::TRT_DriftCircle const* rawhit = trtcirc->prepRawData();
80 if (!rawhit) continue;
81
82 if (!rawhit->driftTimeValid()
83 || rawhit->firstBinHigh()
84 ) continue;
85
86 Identifier const& ident = trtcirc->identify();
87 double rawdrifttime = rawhit->rawDriftTime();
88
89 double t0 = m_caldbtool->getT0(ident);
90 ATH_MSG_DEBUG("T0 : " << t0);
91 rtr = m_caldbtool->getRtRelation(ident);
92
93 Trk::TrackParameters const* tparp = state->trackParameters();
94 if (!tparp) continue;
95
96 double trkdistance = tparp->parameters()[Trk::driftRadius];
97 double trkdrifttime = rtr->drifttime(std::abs(trkdistance));
98 double timeresidual = rawdrifttime - t0 + avgT0->get() - trkdrifttime;
99
100 ATH_MSG_DEBUG("trkdistance=" << trkdistance
101 << " trkdrifttime=" << trkdrifttime
102 << " timeresidual=" << timeresidual
103 << " rawdrifttime=" << rawdrifttime);
104
105 if (std::abs(timeresidual - m_windowCenter) < m_windowSize
106 && std::abs(trkdistance) < 2.8) {
107 timeresidualsum += timeresidual;
108 ++ntrthits;
109 }
110 }
111
112 ATH_MSG_DEBUG("timeresidualsum = " << timeresidualsum);
113 ATH_MSG_DEBUG("ntrtrhits = " << ntrthits);
114
115 if (ntrthits > 1) return timeresidualsum / ntrthits + m_globalOffset;
116
117 return 0.;
118}
119
121
122 double sum_tr = 0.;
123 double sum_goodhits = 0.;
124
125 TRTCond::RtRelation const* rtr = nullptr;
126
127 int nhits = segment->numberOfMeasurementBases();
128 for (int i = 0; i < nhits; ++i) {
129 Trk::RIO_OnTrack const* rio = dynamic_cast<Trk::RIO_OnTrack const*>(segment->measurement(i));
130
131 InDet::TRT_DriftCircleOnTrack const* trtcirc = dynamic_cast<InDet::TRT_DriftCircleOnTrack const*>(rio);
132 if (!trtcirc) continue;
133
134 InDet::TRT_DriftCircle const* rawhit = trtcirc->prepRawData();
135 if (!rawhit) continue;
136
137 if (!rawhit->lastBinHigh() && !rawhit->isNoise()) {
138 Identifier const& ident = trtcirc->identify();
139 rtr = m_caldbtool->getRtRelation(ident);
140
141 if (not rtr) {
142 ATH_MSG_WARNING("Rt relation pointer is null!");
143 return 0.;
144 }
145 double full_drifttime = rtr->drifttime(2.0);
146
147 sum_tr += rawhit->trailingEdge() * 3.125 - full_drifttime;
148
149 ATH_MSG_VERBOSE("Hit " << sum_goodhits
150 << " : " << rawhit->trailingEdge() * 3.125
151 << " fulldrifttime=" << full_drifttime);
152
153 sum_goodhits += 1;
154 } else {
155 ATH_MSG_VERBOSE("Hit has lastbin high");
156 }
157 }
158
159
160 if (sum_goodhits > 1) return sum_tr / sum_goodhits + m_globalOffset;
161
162 return 0;
163}
164
166 ATH_MSG_DEBUG("Finding phase...");
167
169 const TRTCond::AverageT0* avgT0{*rhl};
170
171 double timeresidualsum = 0;
172 size_t ntrthits = 0;
173
174 for (const Trk::TrackStateOnSurface* state : *track->trackStateOnSurfaces()) {
175 Trk::MeasurementBase const* mesb = state->measurementOnTrack();
176 if (!mesb
178 ) continue;
179
180 InDet::TRT_DriftCircleOnTrack const* trtcirc = dynamic_cast<InDet::TRT_DriftCircleOnTrack const*>(mesb);
181 if (!trtcirc) continue;
182
183 InDet::TRT_DriftCircle const* rawhit = trtcirc->prepRawData();
184 if (!rawhit) continue;
185
186 Identifier const& ident = trtcirc->identify();
187 double rawtrailingedge = rawhit->trailingEdge() * 3.125;
188
189 double t0 = m_caldbtool->getT0(ident);
190
191 ATH_MSG_DEBUG("T0 : " << t0);
192
193 double timeresidual = rawtrailingedge - t0 + avgT0->get();
194
195 ATH_MSG_DEBUG("timeresidual=" << timeresidual);
196
197 if (timeresidual < 2000) {
198 timeresidualsum += timeresidual;
199 ++ntrthits;
200 }
201 }
202
203 if (ntrthits > 1) return timeresidualsum / ntrthits + m_globalOffset;
204
205 return 0.;
206}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t t0
abstract base class for rt-relations
This is an Identifier helper class for the TRT subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SG::ReadCondHandleKey< TRTCond::AverageT0 > m_T0ReadKey
virtual StatusCode initialize()
standard Athena-Algorithm method
InDetFixedWindowTrackTimeTool(const std::string &, const std::string &, const IInterface *)
double findPhaseFromTE(const Trk::Track *track) const
finds event phase of a track from the trailing edge
virtual StatusCode finalize()
standard Athena-Algorithm method
double findPhase(const Trk::Track *track) const
finds event phase of a track from the leading edge
ToolHandle< ITRT_CalDbTool > m_caldbtool
TRT Calibration DB tool.
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
bool driftTimeValid() const
return true if the corrected drift time is OK
bool isNoise() const
returns true if the hit is caused by noise with a high probability.
bool lastBinHigh() const
returns true if the last bin is high
bool firstBinHigh() const
returns true if the first bin is high
double rawDriftTime() const
returns the raw driftTime
int trailingEdge() const
returns the trailing edge bin
double get() const
Definition AverageT0.h:19
Base class for rt-relations in the TRT.
Definition RtRelation.h:27
virtual float drifttime(float radius) const =0
drifttime for given radius
This class is the pure abstract base class for all fittable tracking measurements.
virtual bool type(MeasurementBaseType::Type type) const =0
Interface method checking the type.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
Base class for all TrackSegment implementations, extends the common MeasurementBase.
const MeasurementBase * measurement(unsigned int) const
returns the Trk::MeasurementBase objects depending on the integer
unsigned int numberOfMeasurementBases() const
Return the number of contained Trk::MeasurementBase (s)
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ driftRadius
trt, straws
Definition ParamDefs.h:53
ParametersBase< TrackParametersDim, Charged > TrackParameters