ATLAS Offline Software
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 {
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 
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 
87  if (m_useToTCorrection) {
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 
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;
138  cov = Trk::ErrorScalingCast<TRTRIO_OnTrackErrorScaling>(*error_scaling)
139  ->getScaledCovariance(std::move(cov), endcap, mu);
140  }
141 
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 
Trk::LocalParameters
Definition: LocalParameters.h:98
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
InDetDD::TRT_BaseElement::strawLength
virtual const double & strawLength() const =0
Active straw length.
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::locX
@ locX
Definition: ParamDefs.h:37
InDet::TRT_DriftCircleOnTrackRecalibrateTool::TRT_DriftCircleOnTrackRecalibrateTool
TRT_DriftCircleOnTrackRecalibrateTool(const std::string &, const std::string &, const IInterface *)
Definition: TRT_DriftCircleOnTrackRecalibrateTool.cxx:26
DMTest::P
P_v1 P
Definition: P.h:23
InDet::TRT_DriftCircle::timeOverThreshold
double timeOverThreshold() const
returns Time over threshold in ns
initialize
void initialize()
Definition: run_EoverP.cxx:894
Trk::PrepRawData::localCovariance
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
InDet::TRT_DriftCircle::detectorElement
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
return the detector element corresponding to this PRD
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
InDetDD::TRT_EndcapElement
Definition: TRT_EndcapElement.h:44
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
InDet::TRT_DriftCircle::driftTimeBin
int driftTimeBin() const
returns the leading edge bin defined as in TRT_LoLumRawData to be the first 0-1 transition
keylayer_zslicemap.se
se
Definition: keylayer_zslicemap.py:194
InDet::TRT_DriftCircleOnTrack
Definition: TRT_DriftCircleOnTrack.h:53
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Trk::DefinedParameter
std::pair< double, ParamDefs > DefinedParameter
Definition: DefinedParameter.h:27
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_lumiDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:66
TRT_EndcapElement.h
InDet::TRT_DriftCircleOnTrackRecalibrateTool::initialize
virtual StatusCode initialize() override
Definition: TRT_DriftCircleOnTrackRecalibrateTool.cxx:42
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_drifttool
ToolHandle< ITRT_DriftFunctionTool > m_drifttool
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:62
InDet::TRT_DriftCircleOnTrackRecalibrateTool::correct
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...
Definition: TRT_DriftCircleOnTrackRecalibrateTool.cxx:75
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT_DriftCircleOnTrack.h
InDetDD::TRT_BaseElement::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::DECIDED
@ DECIDED
sign of drift radius has been determined
Definition: DriftCircleStatus.h:18
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_useToTCorrection
BooleanProperty m_useToTCorrection
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:72
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
TRT_DriftCircleOnTrackRecalibrateTool.h
LuminosityCondData::lbAverageInteractionsPerCrossing
float lbAverageInteractionsPerCrossing() const
Definition: LuminosityCondData.cxx:26
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDet::TRT_DriftCircleOnTrackRecalibrateTool::finalize
virtual StatusCode finalize() override
Definition: TRT_DriftCircleOnTrackRecalibrateTool.cxx:65
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
LocalParameters.h
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_scalefactor
DoubleProperty m_scalefactor
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:74
ErrorScalingCast.h
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_riontrackTube
ToolHandle< Trk::IRIO_OnTrackCreator > m_riontrackTube
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:60
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
InDet::TRT_DriftCircleOnTrackRecalibrateTool::m_trtErrorScalingKey
SG::ReadCondHandleKey< RIO_OnTrackErrorScaling > m_trtErrorScalingKey
Definition: TRT_DriftCircleOnTrackRecalibrateTool.h:70
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
error
Definition: IImpactPoint3dEstimator.h:70
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
InDet::TRT_DriftCircleOnTrackRecalibrateTool::~TRT_DriftCircleOnTrackRecalibrateTool
virtual ~TRT_DriftCircleOnTrackRecalibrateTool()
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57