ATLAS Offline Software
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 
16 #include "InDetIdentifier/TRT_ID.h"
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 
36 {}
37 
38 
39 //================ Initialisation =================================================
40 
42  ATH_CHECK(m_caldbtool.retrieve());
43  // Read key
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 }
InDet::InDetFixedWindowTrackTimeTool::m_useNewEP
bool m_useNewEP
Definition: InDetFixedWindowTrackTimeTool.h:63
InDet::InDetFixedWindowTrackTimeTool::m_windowCenter
double m_windowCenter
Definition: InDetFixedWindowTrackTimeTool.h:64
InDet::TRT_DriftCircleOnTrack::prepRawData
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
Definition: TRT_DriftCircleOnTrack.h:202
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDet::InDetFixedWindowTrackTimeTool::findPhase
double findPhase(const Trk::Track *track) const
finds event phase of a track from the leading edge
Definition: InDetFixedWindowTrackTimeTool.cxx:58
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
RtRelation.h
abstract base class for rt-relations
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
BasicRtRelation.h
InDet::TRT_DriftCircleOnTrack
Definition: TRT_DriftCircleOnTrack.h:53
InDet::InDetFixedWindowTrackTimeTool::m_caldbtool
ToolHandle< ITRT_CalDbTool > m_caldbtool
TRT Calibration DB tool.
Definition: InDetFixedWindowTrackTimeTool.h:60
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
ReadCondHandle.h
TRTCond::RtRelation
Definition: RtRelation.h:27
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
InDet::InDetFixedWindowTrackTimeTool::finalize
virtual StatusCode finalize()
standard Athena-Algorithm method
Definition: InDetFixedWindowTrackTimeTool.cxx:51
InDet::TRT_DriftCircle::isNoise
bool isNoise() const
returns true if the hit is caused by noise with a high probability.
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
TRTCond::RtRelation::drifttime
virtual float drifttime(float radius) const =0
drifttime for given radius
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
Trk::Segment
Definition: Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::MeasurementBase::type
virtual bool type(MeasurementBaseType::Type type) const =0
Interface method checking the type.
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT_DriftCircleOnTrack.h
InDet::TRT_DriftCircle::trailingEdge
int trailingEdge() const
returns the trailing edge bin
InDet::InDetFixedWindowTrackTimeTool::InDetFixedWindowTrackTimeTool
InDetFixedWindowTrackTimeTool(const std::string &, const std::string &, const IInterface *)
Definition: InDetFixedWindowTrackTimeTool.cxx:20
InDet::InDetFixedWindowTrackTimeTool::~InDetFixedWindowTrackTimeTool
virtual ~InDetFixedWindowTrackTimeTool()
default destructor
Definition: InDetFixedWindowTrackTimeTool.cxx:35
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
InDet::TRT_DriftCircle::lastBinHigh
bool lastBinHigh() const
returns true if the last bin is high
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
InDet::InDetFixedWindowTrackTimeTool::findPhaseFromTE
double findPhaseFromTE(const Trk::Track *track) const
finds event phase of a track from the trailing edge
Definition: InDetFixedWindowTrackTimeTool.cxx:165
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
InDet::InDetFixedWindowTrackTimeTool::m_windowSize
double m_windowSize
Definition: InDetFixedWindowTrackTimeTool.h:65
InDet::InDetFixedWindowTrackTimeTool::initialize
virtual StatusCode initialize()
standard Athena-Algorithm method
Definition: InDetFixedWindowTrackTimeTool.cxx:41
InDet::TRT_DriftCircle::driftTimeValid
bool driftTimeValid() const
return true if the corrected drift time is OK
InDetFixedWindowTrackTimeTool.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
InDet::InDetFixedWindowTrackTimeTool::m_T0ReadKey
SG::ReadCondHandleKey< TRTCond::AverageT0 > m_T0ReadKey
Definition: InDetFixedWindowTrackTimeTool.h:59
InDet::TRT_DriftCircle::rawDriftTime
double rawDriftTime() const
returns the raw driftTime
AthAlgTool
Definition: AthAlgTool.h:26
TRTCond::AverageT0
Definition: AverageT0.h:10
InDet::TRT_DriftCircle::firstBinHigh
bool firstBinHigh() const
returns true if the first bin is high
InDet::InDetFixedWindowTrackTimeTool::m_globalOffset
double m_globalOffset
Definition: InDetFixedWindowTrackTimeTool.h:62
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
Identifier
Definition: IdentifierFieldParser.cxx:14