16#include "CLHEP/Units/PhysicalConstants.h"
18#include "Identifier/Identifier.h"
19#include "GaudiKernel/IService.h"
49 ATH_MSG_ERROR(
"Could not find TRT_CalDbTool => cannot use t0 of data.");
62 for (
unsigned int iRing = 0; iRing < timeShiftForBarrelStraw.size(); ++iRing) {
64 for (
unsigned int iLayer = 0; iLayer < timeShiftForBarrelStraw[iRing].size(); ++iLayer) {
65 if (
m_detmgr->getBarrelElement(0,iRing,0,iLayer)) {
66 unsigned int nstraws_in_layer =
m_detmgr->getBarrelElement(0,iRing,0,iLayer)->nStraws();
67 timeShiftForBarrelStraw[iRing][iLayer].assign(nstraws_in_layer,
m_notInitVal);
77 for (
unsigned int iWheel = 0; iWheel < timeShiftForEndCapPlane.size(); ++iWheel) {
118 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iWheel,iLayer) = ("
119 << iWheel <<
", " << iLayer <<
") out of bounds! Returning 0.");
121 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iPhi,iWheel,iLayer) = ("
122 << iPhi <<
", " << iWheel <<
", " << iLayer <<
") out of bounds! Returning 0.");
148 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iRing,iLayer,iStraw) = ("
149 << iRing <<
", " << iLayer <<
", " << iStraw
150 <<
") out of bounds! Returning 0.");
152 ATH_MSG_ERROR(
"TimeCorrection::TimeShift: (iPhi,iRing,iLayer,iStraw) = ("
153 << iPhi <<
", " << iRing <<
", " << iLayer <<
", " << iStraw
154 <<
") out of bounds! Returning 0.");
174 const unsigned int& iRing,
175 const unsigned int& iLayer,
176 const unsigned int& iStraw,
181 iRing, iPhi, iLayer ));
184 if (!barrel_element) {
185 ATH_MSG_ERROR(
"calculateTimeShift_Barrel: Could not get element for iRing = "
186 << iRing <<
" and iLayer = "<<iLayer<<
". Timeshift becomes 0.");
190 if (iStraw >= barrel_element->
nStraws()) {
191 ATH_MSG_ERROR(
"calculateTimeShift_Barrel: Trying to access iStraw "
192 << iStraw <<
" in an element with "<<barrel_element->
nStraws()<<
" straws (iRing="
193 << iRing <<
",iLayer="<<iLayer<<
"). Timeshift becomes 0.");
211 const unsigned int& iWheel,
212 const unsigned int& iLayer,
217 iWheel, iLayer, iPhi ));
221 ATH_MSG_ERROR(
"calculateTimeShift_EndCap: Could not get element for iWheel = "
222 << iWheel <<
" and iLayer = "<<iLayer<<
". Timeshift becomes 0.");
241 const int strawID ) {
254 const double mindisttoend1(std::min((strawend1_globalcoord-vertexExtension1).
mag(),
255 (strawend1_globalcoord-vertexExtension2).
mag()));
258 const double mindisttoend2(std::min((strawend2_globalcoord-vertexExtension1).
mag(),
259 (strawend2_globalcoord-vertexExtension2).
mag()));
262 if ( (mindisttoend2<mindisttoend1) ==
m_settings->electronicsAreAtFarEnd() ) {
263 ATH_MSG_WARNING(
"It would seem that the local z-coordinate of a test straw grows TOWARDS"
264 <<
" the electronics ends. This will give trouble elsewhere!!");
277 ATH_MSG_ERROR(
"Attempt to use t0 from data failed: TRTCalDbSvc was not able to supply t0 for straw with identifier: "
278 << idStraw <<
". Please set getT0FromData=false in jobOptions and run again");
283 return std::max(mindisttoend1,mindisttoend2) / (
m_settings->distanceToTimeFactor() * CLHEP::c_light) - shift;
285 return std::min(mindisttoend1,mindisttoend2) / (
m_settings->distanceToTimeFactor() * CLHEP::c_light) - shift;
291 double& propagationTime1,
double& propagationTime2) {
293 double direct_distance, reflect_distance;
338 double& direct_dist,
double& reflect_dist )
const {
362 double& reflect_dist )
const {
384 const int mask(0x0000001F);
385 const int word_shift(5);
386 int trtID, ringID, moduleID, layerID, strawID;
387 int wheelID, planeID, sectorID;
392 if ( !(hitID & 0x00200000) ) {
393 strawID = hitID & mask;
394 hitID >>= word_shift;
395 layerID = hitID & mask;
396 hitID >>= word_shift;
397 moduleID = hitID & mask;
398 hitID >>= word_shift;
399 ringID = hitID & mask;
400 trtID = hitID >> word_shift;
403 m_detmgr->getBarrelElement(trtID, ringID, moduleID, layerID);
404 if ( barrelElement ) {
406 IdLayer = barrelElement->
identify();
407 IdStraw =
m_trt_id->straw_id(IdLayer, strawID);
409 ATH_MSG_ERROR(
"Could not find detector element for barrel identifier with "
410 <<
"(ipos,iring,imod,ilayer,istraw) = ("
411 << trtID <<
", " << ringID <<
", " << moduleID <<
", "
412 << layerID <<
", " << strawID <<
")");
416 strawID = hitID & mask;
417 hitID >>= word_shift;
418 planeID = hitID & mask;
419 hitID >>= word_shift;
420 sectorID = hitID & mask;
421 hitID >>= word_shift;
422 wheelID = hitID & mask;
423 trtID = hitID >> word_shift;
426 if (trtID == 3) trtID = 0;
430 m_detmgr->getEndcapElement(trtID, wheelID, planeID, sectorID);
432 if ( endcapElement ) {
433 IdLayer = endcapElement->
identify();
434 IdStraw =
m_trt_id->straw_id(IdLayer, strawID);
436 ATH_MSG_ERROR(
"Could not find detector element for endcap identifier with "
437 <<
"(ipos,iwheel,isector,iplane,istraw) = ("
438 << trtID <<
", " << wheelID <<
", " << sectorID <<
", "
439 << planeID <<
", " << strawID <<
")");
440 ATH_MSG_ERROR(
"If this happens very rarely, don't be alarmed (it is a Geant4 'feature')");
441 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.
Class to hold different TRT detector elements structures.
const TRT_EndcapElement * getEndcapDetElement(unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex) const
const TRT_BarrelElement * getBarrelDetElement(unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex) const
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
double calculateTimeShift_Barrel(const unsigned int &iPhi, const unsigned int &iRing, const unsigned int &iLayer, const unsigned int &iStraw, const int strawID, const InDetDD::TRT_DetElementContainer *detElements)
Time shift for barrel straws.
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
double TimeShift(const int &strawID, const InDetDD::TRT_DetElementContainer *detElements)
Returns the time it would take to travel at light-speed from (0,0,0) to the farthest end of the wire ...
Identifier getIdentifier(int hitID, bool &statusok)
double m_lengthDeadRegion
double m_maxVertexDisplacement
double calculateTimeShift_EndCap(const unsigned int &iPhi, const unsigned int &iWheel, const unsigned int &iLayer, const int strawID, const InDetDD::TRT_DetElementContainer *detElements)
Time shift for end cap straws.
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
const InDetDD::TRT_DetectorManager * m_detmgr
This is an Identifier helper class for the TRT subdetector.
Eigen::Matrix< double, 3, 1 > Vector3D