ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DriftCircleOnTrackRecalibrateTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Implementation file for class TRT_DriftCircleOnTrackRecalibrateTool
8// (c) ATLAS Detector software
10// AlgTool used for TRT_DriftCircleOnTrack object production
12
13
19
20
22// Constructor
24
26(const std::string& ty,const std::string& na,const IInterface* pa)
27 : AthAlgTool(ty,na,pa)
28{
29 declareInterface<IRIO_OnTrackCreator>(this);
30}
31
33// Destructor
35
37
39// Initialisation
41
43{
44 StatusCode sc = AlgTool::initialize();
45
46 if(m_drifttool.retrieve().isFailure()){
47 msg(MSG::FATAL) << "Failed to retrieve tool " << m_drifttool << endmsg;
48 return StatusCode::FAILURE;
49 }
50
51 if(m_riontrackTube.retrieve().isFailure()){
52 msg(MSG::FATAL) << "Failed to retrieve tool " << m_riontrackTube << endmsg;
53 return StatusCode::FAILURE;
54 }
55
56 ATH_CHECK(m_trtErrorScalingKey.initialize(!m_trtErrorScalingKey.key().empty()));
57 ATH_CHECK(m_lumiDataKey.initialize ( !m_lumiDataKey.key().empty() && !m_trtErrorScalingKey.key().empty()));
58 return sc;
59}
60
62// Finalize
64
66{
67 StatusCode sc = AlgTool::finalize(); return sc;
68}
69
71// Trk::TRT_DriftCircleOnTrack production
73
75(const Trk::PrepRawData& rio,const Trk::TrackParameters& TP,const EventContext& ctx) const
76{
77 const InDet::TRT_DriftCircle* DC = dynamic_cast<const InDet::TRT_DriftCircle*>(&rio);
78 if(!DC) return nullptr;
79
80 Trk::RIO_OnTrack *rot=nullptr;
81
82 //recalculate driftradius using the new calibration constants
83 bool isOK=false;
84 double t0=0.;
85 double rawtime = m_drifttool->rawTime(DC->driftTimeBin());
86
88 rawtime -= m_drifttool->driftTimeToTCorrection(DC->timeOverThreshold(), DC->identify());
89 }
90
91 double driftradius = m_drifttool->driftRadius(rawtime,DC->identify(),t0,isOK);
92 double error = m_drifttool->errorOfDriftRadius(rawtime-t0,DC->identify());
93
94 double distance=fabs(fabs(TP.parameters()[0])-driftradius);
95
96
97 msg(MSG::VERBOSE)<<"Old radius: "<< DC->localPosition()[Trk::driftRadius]<<" -> new radius: "<<driftradius<<endmsg;
98
99 if(distance>error*m_scalefactor){
100
101 //tube hit
102 //
103 rot=m_riontrackTube->correct(rio,TP,ctx);
104 }
105 else {
106 // precision hit
107 //
108 const InDetDD::TRT_BaseElement* pE = DC->detectorElement(); if(!pE) return nullptr;
109 IdentifierHash iH = pE->identifyHash();
110 const Amg::VectorX& P = TP.parameters();
111 double se = sin(P[3]);
112 Amg::Vector3D dir(cos(P[2])*se,sin(P[2])*se,cos(P[3]));
113
114 double predictedLocZ=P[1];
115
116 double sign = (TP.parameters()[0] < 0.) ? -1. : 1.;
117
118 // only create objects within the active area
119 //
120 double sl = pE->strawLength()*.5;
121 if (predictedLocZ > sl) predictedLocZ = sl;
122 else if(predictedLocZ <-sl) predictedLocZ =-sl;
123
124
126 Amg::MatrixX cov(DC->localCovariance()*escale2);
127
128 if (!m_trtErrorScalingKey.key().empty()) {
129 double mu=0.;
130 if (!m_lumiDataKey.empty()) {
132 mu = lumiData->lbAverageInteractionsPerCrossing();
133 }
134
135 bool endcap = false;
136 if(dynamic_cast<const InDetDD::TRT_EndcapElement*>(pE)) endcap = true;
139 ->getScaledCovariance(std::move(cov), endcap, mu);
140 }
141
142 Trk::DefinedParameter radius(sign*driftradius,Trk::locX);
143 Trk::LocalParameters lp(radius);
144
145 rot=new InDet::TRT_DriftCircleOnTrack(DC,std::move(lp),std::move(cov),iH,predictedLocZ,dir,Trk::DECIDED);
146 }
147 return rot;
148}
149
150
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t P(Double_t *tt, Double_t *par)
static Double_t sc
static Double_t t0
int sign(int a)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
MsgStream & msg() const
This is a "hash" representation of an Identifier.
Virtual base class of TRT readout elements.
virtual const double & strawLength() const =0
Active straw length.
virtual IdentifierHash identifyHash() const override final
identifier hash
Extended class of a TRT_BaseElement to describe a readout elment in the endcap.
virtual Trk::RIO_OnTrack * correct(const Trk::PrepRawData &, const Trk::TrackParameters &, const EventContext &ctx=Gaudi::Hive::currentContext()) const override
abstract base method for the creation of RIO_OnTrack it takes a RIO (PrepRawData) and the given Track...
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
SG::ReadCondHandleKey< RIO_OnTrackErrorScaling > m_trtErrorScalingKey
TRT_DriftCircleOnTrackRecalibrateTool(const std::string &, const std::string &, const IInterface *)
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
int driftTimeBin() const
returns the leading edge bin defined as in TRT_LoLumRawData to be the first 0-1 transition
double timeOverThreshold() const
returns Time over threshold in ns
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
return the detector element corresponding to this PRD
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
@ DECIDED
sign of drift radius has been determined
@ driftRadius
trt, straws
Definition ParamDefs.h:53
@ locX
Definition ParamDefs.h:37
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...
ParametersBase< TrackParametersDim, Charged > TrackParameters
const T_res * ErrorScalingCast(const T_src *src)