15#include "CLHEP/Units/PhysicalConstants.h"
17#include "Identifier/Identifier.h"
18#include "GaudiKernel/IService.h"
48 ATH_MSG_ERROR(
"Could not find TRT_CalDbTool => cannot use t0 of data.");
61 for (
unsigned int iRing = 0; iRing < timeShiftForBarrelStraw.size(); ++iRing) {
63 for (
unsigned int iLayer = 0; iLayer < timeShiftForBarrelStraw[iRing].size(); ++iLayer) {
64 if (
m_detmgr->getBarrelElement(0,iRing,0,iLayer)) {
65 unsigned int nstraws_in_layer =
m_detmgr->getBarrelElement(0,iRing,0,iLayer)->nStraws();
66 timeShiftForBarrelStraw[iRing][iLayer].assign(nstraws_in_layer,
m_notInitVal);
76 for (
unsigned int iWheel = 0; iWheel < timeShiftForEndCapPlane.size(); ++iWheel) {
117 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iWheel,iLayer) = ("
118 << iWheel <<
", " << iLayer <<
") out of bounds! Returning 0.");
120 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iPhi,iWheel,iLayer) = ("
121 << iPhi <<
", " << iWheel <<
", " << iLayer <<
") out of bounds! Returning 0.");
147 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iRing,iLayer,iStraw) = ("
148 << iRing <<
", " << iLayer <<
", " << iStraw
149 <<
") out of bounds! Returning 0.");
151 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iPhi,iRing,iLayer,iStraw) = ("
152 << iPhi <<
", " << iRing <<
", " << iLayer <<
", " << iStraw
153 <<
") out of bounds! Returning 0.");
173 const unsigned int& iRing,
174 const unsigned int& iLayer,
175 const unsigned int& iStraw,
179 iRing, iPhi, iLayer ));
182 if (!barrel_element) {
183 ATH_MSG_ERROR(
"calculateTimeShift_Barrel: Could not get element for iRing = "
184 << iRing <<
" and iLayer = "<<iLayer<<
". Timeshift becomes 0.");
188 if (iStraw >= barrel_element->
nStraws()) {
189 ATH_MSG_ERROR(
"calculateTimeShift_Barrel: Trying to access iStraw "
190 << iStraw <<
" in an element with "<<barrel_element->
nStraws()<<
" straws (iRing="
191 << iRing <<
",iLayer="<<iLayer<<
"). Timeshift becomes 0.");
209 const unsigned int& iWheel,
210 const unsigned int& iLayer,
214 iWheel, iLayer, iPhi ));
218 ATH_MSG_ERROR(
"calculateTimeShift_EndCap: Could not get element for iWheel = "
219 << iWheel <<
" and iLayer = "<<iLayer<<
". Timeshift becomes 0.");
238 const int strawID ) {
251 const double mindisttoend1(std::min((strawend1_globalcoord-vertexExtension1).
mag(),
252 (strawend1_globalcoord-vertexExtension2).
mag()));
255 const double mindisttoend2(std::min((strawend2_globalcoord-vertexExtension1).
mag(),
256 (strawend2_globalcoord-vertexExtension2).
mag()));
259 if ( (mindisttoend2<mindisttoend1) ==
m_settings->electronicsAreAtFarEnd() ) {
260 ATH_MSG_WARNING(
"It would seem that the local z-coordinate of a test straw grows TOWARDS"
261 <<
" the electronics ends. This will give trouble elsewhere!!");
274 ATH_MSG_ERROR(
"Attempt to use t0 from data failed: TRTCalDbSvc was not able to supply t0 for straw with identifier: "
275 << idStraw <<
". Please set getT0FromData=false in jobOptions and run again");
280 return std::max(mindisttoend1,mindisttoend2) / (
m_settings->distanceToTimeFactor() * CLHEP::c_light) - shift;
282 return std::min(mindisttoend1,mindisttoend2) / (
m_settings->distanceToTimeFactor() * CLHEP::c_light) - shift;
288 double& propagationTime1,
double& propagationTime2) {
290 double direct_distance, reflect_distance;
335 double& direct_dist,
double& reflect_dist )
const {
359 double& reflect_dist )
const {
381 const int mask(0x0000001F);
382 const int word_shift(5);
383 int trtID, ringID, moduleID, layerID, strawID;
384 int wheelID, planeID, sectorID;
389 if ( !(hitID & 0x00200000) ) {
390 strawID = hitID & mask;
391 hitID >>= word_shift;
392 layerID = hitID & mask;
393 hitID >>= word_shift;
394 moduleID = hitID & mask;
395 hitID >>= word_shift;
396 ringID = hitID & mask;
397 trtID = hitID >> word_shift;
400 m_detmgr->getBarrelElement(trtID, ringID, moduleID, layerID);
401 if ( barrelElement ) {
403 IdLayer = barrelElement->
identify();
404 IdStraw =
m_trt_id->straw_id(IdLayer, strawID);
406 ATH_MSG_ERROR(
"Could not find detector element for barrel identifier with "
407 <<
"(ipos,iring,imod,ilayer,istraw) = ("
408 << trtID <<
", " << ringID <<
", " << moduleID <<
", "
409 << layerID <<
", " << strawID <<
")");
413 strawID = hitID & mask;
414 hitID >>= word_shift;
415 planeID = hitID & mask;
416 hitID >>= word_shift;
417 sectorID = hitID & mask;
418 hitID >>= word_shift;
419 wheelID = hitID & mask;
420 trtID = hitID >> word_shift;
423 if (trtID == 3) trtID = 0;
427 m_detmgr->getEndcapElement(trtID, wheelID, planeID, sectorID);
429 if ( endcapElement ) {
430 IdLayer = endcapElement->
identify();
431 IdStraw =
m_trt_id->straw_id(IdLayer, strawID);
433 ATH_MSG_ERROR(
"Could not find detector element for endcap identifier with "
434 <<
"(ipos,iwheel,isector,iplane,istraw) = ("
435 << trtID <<
", " << wheelID <<
", " << sectorID <<
", "
436 << planeID <<
", " << strawID <<
")");
437 ATH_MSG_ERROR(
"If this happens very rarely, don't be alarmed (it is a Geant4 'feature')");
438 ATH_MSG_ERROR(
"If it happens a lot, you probably have misconfigured geometry in the sim. job.");
Scalar mag() const
mag method
#define ATH_MSG_WARNING(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Extended TRT_BaseElement to describe a TRT readout element, this is a planar layer with n ( order of ...
virtual const double & strawLength() const override final
Get the length of the straws (active length):
unsigned int nStraws() const
Number of straws in the element.
virtual Identifier identify() const override final
identifier of this detector element:
const Amg::Transform3D & strawTransform(unsigned int straw) const
Straw transform - fast access in array, in Tracking frame: Amg.
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
Extended class of a TRT_BaseElement to describe a readout elment in the endcap.
virtual const double & strawLength() const override
Active straw length.
Helper class to organize the straw elements on TRT readout elements.
unsigned int getNEndcapWheels() const
unsigned int getNEndcapPhi() const
unsigned int getNBarrelPhi() const
unsigned int getNBarrelRings() const
unsigned int getNBarrelLayers(unsigned int iMod) const
unsigned int getNEndcapLayers(unsigned int iWheel) const
Class containing parameters and settings used by TRT digitization.
TRTTimeCorrection(const TRTDigSettings *digset, const InDetDD::TRT_DetectorManager *detmgr, const TRT_ID *, const ITRT_CalDbTool *)
std::vector< std::vector< double > > m_directDistsForBarrelLayers
Cached distances.
void calculateSignalDists_EndCap(const unsigned int &iWheel, double &direct_dist, double &reflect_dist) const
Calculate the distance along the wire the signal travels before reaching the electronics.
const unsigned int m_subdetectorMask
std::vector< std::vector< double > > m_reflectedDistsForBarrelLayers
Cached distances.
const TRTDigSettings * m_settings
std::vector< double > m_directDistsForEndCapWheels
Cached distances.
std::vector< std::vector< std::vector< double > > > m_timeShiftForEndCapPlanes
Cached timeshifts.
bool m_timeShiftPhiSectSymmetry
const unsigned int m_shift10Bits
const double m_notInitVal
Value used to denote an uninitialized value.
const unsigned int m_right5Bits
void PropagationTime(const int &strawID, const double &meanZ, double &propagationTime1, double &propagationTime2)
Calculates the time between the signal reaching the wire and when it reaches the electronics.
std::vector< double > m_reflectedDistsForEndCapWheels
Cached distances.
void calculateSignalDists_Barrel(const unsigned int &iRing, const unsigned int &iLayer, double &direct_dist, double &reflect_dist) const
Calculate the distance along the wire the signal travels before reaching the electronics.
const ITRT_CalDbTool * m_trtcaldbtool
Identifier getIdentifier(int hitID, bool &statusok)
double m_lengthDeadRegion
double calculateTimeShift_EndCap(const unsigned int &iPhi, const unsigned int &iWheel, const unsigned int &iLayer, const int strawID)
Time shift for end cap straws.
double calculateTimeShift_Barrel(const unsigned int &iPhi, const unsigned int &iRing, const unsigned int &iLayer, const unsigned int &iStraw, const int strawID)
Time shift for barrel straws.
double m_maxVertexDisplacement
const unsigned int m_shift5Bits
double calculateTimeShiftFromStrawEnds(const Amg::Vector3D &strawend1_globalcoord, const Amg::Vector3D &strawend2_globalcoord, const int strawID)
Time shift from straw endpoints in global system.
const unsigned int m_shift15Bits
std::vector< std::vector< std::vector< std::vector< double > > > > m_timeShiftForBarrelStraws
Cached timeshifts.
double m_signalPropagationSpeed
double TimeShift(const int &strawID)
Returns the time it would take to travel at light-speed from (0,0,0) to the farthest end of the wire ...
const InDetDD::TRT_DetectorManager * m_detmgr
This is an Identifier helper class for the TRT subdetector.
Eigen::Matrix< double, 3, 1 > Vector3D