ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_SimDriftTimeTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Class: TRT_SimDriftTimeTool //
8// //
9// Author: Thomas Kittelmann //
10// //
11// First Version: January 2006 //
12// //
14
17#include "GaudiKernel/MsgStream.h"
18#include "CLHEP/Units/SystemOfUnits.h"
19#include "GaudiKernel/ServiceHandle.h"
21#include <stdexcept>
22
24 const std::string& name,
25 const IInterface* parent )
26 : AthAlgTool( type, name, parent )
27 , m_minDistance( 0*CLHEP::mm )
28 , m_maxDistance( 2.0001*CLHEP::mm )
29 , m_maxField ( -999 )
32 , m_nTabulatedDistances(4000)//4000 means resolution of 0.5micron and 96KB of memory.
34{
35 // declare my special interface
36 declareInterface<ITRT_SimDriftTimeTool>(this);
37}
38
39//__________________________________________________________________________
41{
42
43 ATH_MSG_INFO("Initializing TRT_SimDriftTimeTool.");
44
47 // Get dig. version through //
48 // the TRT Detector Manager //
51
52 // Get the TRT Detector Manager
53 const InDetDD::TRT_DetectorManager * detmgr;
54 ATH_CHECK(detStore()->retrieve(detmgr,"TRT"));
55 ATH_MSG_INFO("Retrieved TRT_DetectorManager with version " << detmgr->getVersion().majorNum());
56
59 // Select DriftTime Data //
60 // ( based on dig. version ) //
63
64 std::vector<std::unique_ptr<ITRT_DriftTimeData>> pDTData;
65 pDTData.emplace_back(std::make_unique<TRT_BarrelDriftTimeData>(0)); // Xe straws
66 pDTData.emplace_back(std::make_unique<TRT_BarrelDriftTimeData>(1)); // Kr straws
67 pDTData.emplace_back(std::make_unique<TRT_BarrelDriftTimeData>(2)); // Ar straws
68
71 // Make lookup tables of the data //
74
75 m_maxField = pDTData[0]->MaxTabulatedField();
78
79 for (auto & i : pDTData)
80 {
81
82 // Tabulate mean drifttimes at no and max field.
83 // Fill different tables for Xe, Kr and Ar-based gas mixtures
84 std::vector<double> table_of_dist2meanDT_at_noField;
85 std::vector<double> table_of_dist2meanDT_at_maxField;
86
87 table_of_dist2meanDT_at_noField.resize(m_nTabulatedDistances);
88 table_of_dist2meanDT_at_maxField.resize(m_nTabulatedDistances);
89
90 for (unsigned int distIndex = 0; distIndex < m_nTabulatedDistances; distIndex++)
91 {
92 double distance = ((m_maxDistance-m_minDistance)*distIndex)/(m_nTabulatedDistances-1.0)+m_minDistance;
93 if (distIndex == m_nTabulatedDistances-1) distance = m_maxDistance;//to avoid a numerical mistake.
94 table_of_dist2meanDT_at_noField[distIndex] = i->DriftTimeAtNoField(distance);
95 table_of_dist2meanDT_at_maxField[distIndex] = i->DriftTimeAtMaxField(distance);
96 }
97
98 m_table_of_dist2meanDT_at_noField.push_back(table_of_dist2meanDT_at_noField);
99 m_table_of_dist2meanDT_at_maxField.push_back(table_of_dist2meanDT_at_maxField);
100
101 }
102
105
106 return StatusCode::SUCCESS;
107
108}
109
110//__________________________________________________________________________
111// Don't worry; physical checks on "dist" and "effectivefield_squared" are already performed in TRTProcessingOfStraw.cxx
113 const double& effectivefield_squared,
114 int strawGasType) const
115{
116
117 if (effectivefield_squared>m_maxFieldSquaredLimit)
118 { //a little extrapolation is ok
119 ATH_MSG_WARNING ("Extrapolation from tabulated field values greater than 10% (at "
120 << std::sqrt(effectivefield_squared)/CLHEP::tesla<<" Tesla)");
121 }
122
123 const unsigned int distIndex(static_cast<int>( m_invDeltaTabulatedDistances*(dist-m_minDistance) ));
124
125 if ( distIndex >= m_nTabulatedDistances)
126 {
127 ATH_MSG_FATAL("getAverageDriftTime: Somehow distIndex (" << distIndex << " ) is out of bounds ("
128 << m_nTabulatedDistances << "). The job will die now.");
129 throw std::runtime_error("getAverageDriftTime distIndex out of bounds");
130 }
131
132 const double C(m_table_of_dist2meanDT_at_noField[strawGasType][distIndex]);
133 const double A((m_table_of_dist2meanDT_at_maxField[strawGasType][distIndex] - C) * m_invMaxFieldSquared);
134
135 return (A * effectivefield_squared) + C;
136
137}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
const Version & getVersion() const
Get version information.
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
int majorNum() const
Major version number.
Definition Version.cxx:62
const double m_invDeltaTabulatedDistances
virtual double getAverageDriftTime(const double &distIndex, const double &effectivefield_squared, int strawGasType) const
TRT_SimDriftTimeTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize()
std::vector< std::vector< double > > m_table_of_dist2meanDT_at_noField
std::vector< std::vector< double > > m_table_of_dist2meanDT_at_maxField
const unsigned int m_nTabulatedDistances
struct color C
hold the test vectors and ease the comparison