ATLAS Offline Software
MDT_Response.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CLHEP/Random/RanluxEngine.h"
7 
9  m_rhit(0.0),
10  m_xhit(0.0),
11  m_pathLength(0.0),
12  m_rtParameters(nullptr),
13  m_t0(0.0)
14 {
16  InitClusters(200.,0.2);
17  InitdEdxTable();
18 }
19 
20 MDT_Response::MDT_Response(double timewindow, double binsize) :
21  m_rhit(0.0),
22  m_xhit(0.0),
23  m_pathLength(0.0),
24  m_rtParameters(nullptr),
25  m_t0(0.0)
26 {
28  InitClusters(timewindow,binsize);
29  InitdEdxTable();
30 }
31 
33 {
34  delete[] m_rtParameters; m_rtParameters=nullptr;
35 }
36 
37 void MDT_Response::InitClusters(double timewindow, double binsize)
38 {
39  m_binsize = binsize;
40  m_timeWindow = timewindow;
43  m_clusters.resize(m_bins);
45  //std::cout << "MDT_Response Initialize: new cluster vector with " << m_clusters.size() << " bins " << m_bins << std::endl;
46 }
47 
49 {
50  m_radius = 14.6275; // tube radius in atlas
51  m_clusterDensity = 8.5; // clusters per mm
52  m_attLength = 30000.; // mm
53  m_signalSpeed = 300.; // mm/ns
54  m_rtMode = 2;
55  m_difSmearing = 10.;
56  m_integrationWindow = 20.;
57  m_triggerElectron = 20.;
60  InitRt();
61 
62 }
63 
65 {
66 
67  // initialize number of clusters per mm vs gamma table
68 
69  double gammaFactor[] = {0.10110E+01,0.10133E+01,0.10162E+01,0.10196E+01,0.10237E+01,0.10287E+01,0.10348E+01,0.10422E+01,0.10511E+01,
70  0.10619E+01,0.10750E+01,0.10909E+01,0.11101E+01,0.11334E+01,0.11616E+01,0.11957E+01,0.12371E+01,0.12873E+01,
71  0.13481E+01,0.14217E+01,0.15109E+01,0.16190E+01,0.17499E+01,0.19085E+01,0.21007E+01,0.23335E+01,0.26156E+01,
72  0.29573E+01,0.33714E+01,0.38730E+01,0.44807E+01,0.52170E+01,0.61090E+01,0.71897E+01,0.84989E+01,0.10085E+02,
73  0.12007E+02,0.14335E+02,0.17156E+02,0.20573E+02,0.24714E+02,0.29730E+02,0.35807E+02,0.43170E+02,0.52090E+02,
74  0.62897E+02,0.75989E+02,0.91852E+02,0.11107E+03,0.13435E+03,0.16256E+03,0.19673E+03,0.23814E+03,0.28830E+03,
75  0.34907E+03,0.42270E+03,0.51190E+03,0.61997E+03,0.75089E+03,0.90952E+03,0.11017E+04,0.13345E+04,0.16166E+04,
76  0.19583E+04,0.23724E+04,0.28740E+04,0.34817E+04,0.42180E+04,0.51100E+04,0.61907E+04,0.74999E+04,0.90862E+04,
77  0.11008E+05,0.13336E+05,0.16157E+05,0.19574E+05,0.23715E+05,0.28731E+05,0.34808E+05,0.42171E+05,0.51091E+05,
78  0.61898E+05,0.74990E+05,0.90853E+05,0.11007E+06,0.13335E+06,0.16156E+06,0.19574E+06,0.23714E+06,0.28730E+06,
79  0.34807E+06,0.42170E+06,0.51090E+06,0.61897E+06,0.74990E+06,0.90852E+06};
80 
81  double numberOfClustersPerCm[] = {720.157,611.293,518.910,440.579,374.222,318.055,270.554,230.415,196.530,167.949,143.867,123.598,106.560,
82  92.259,80.277,70.258,61.904,54.960,49.215,44.488,40.626,37.503,35.009,33.054,31.558,30.455,29.686,29.200,
83  28.954,28.908,29.030,29.288,29.658,30.119,30.653,31.245,31.885,32.563,33.274,34.014,34.781,35.593,36.502,
84  37.371,38.065,38.606,39.024,39.347,39.600,39.800,39.960,40.090,40.197,40.285,40.359,40.419,40.469,40.509,
85  40.540,40.564,40.582,40.596,40.606,40.614,40.620,40.624,40.627,40.629,40.631,40.632,40.633,40.634,40.635,
86  40.635,40.635,40.635,40.635,40.636,40.636,40.636,40.636,40.636,40.636,40.636,40.636,40.636,40.636,40.636,
87  40.636,40.636,40.636,40.636,40.636,40.636,40.636,40.636};
88 
89  for( int ik = 0; ik < 96; ++ik ) {
90  m_gammaFactorVec.push_back( gammaFactor[ik] );
91  m_numberOfClustersPerCmVec.push_back( numberOfClustersPerCm[ik] );
92  }
93 }
94 
95 
97  //std::cout << "Setting rt-relation" << std::endl;
98  if(m_rtParameters) delete m_rtParameters;
99  switch(m_rtMode){
100  case 0: /* linear rt */
101  m_rtNpar = 1;
102  m_rtParameters = new double[m_rtNpar];
103  m_rtParameters[0] = 700./m_radius;
104  break;
105  case 1: /* used for work presented in muonsw nov 2003 */
106  m_rtNpar = 4;
107  m_rtParameters = new double[m_rtNpar];
108  m_rtParameters[0] = 0.;
109  m_rtParameters[1] = 16.4;
110  m_rtParameters[2] = 0.43;
111  m_rtParameters[3] = 0.102;
112  break;
113  case 2: // garfield rt-relation
114  m_rtNpar = 10;
115  m_rtParameters = new double[m_rtNpar];
116  m_rtParameters[0] = -1.79390e-01;
117  m_rtParameters[1] = 2.04417e+01;
118  m_rtParameters[2] = 4.96576e+00;
119  m_rtParameters[3] = -2.59002e+00;
120  m_rtParameters[4] = 5.45522e-01;
121  m_rtParameters[5] = -4.66626e-02;
122  m_rtParameters[6] = 5.66214e-04;
123  m_rtParameters[7] = 1.89740e-04;
124  m_rtParameters[8] = -1.30073e-05;
125  m_rtParameters[9] = 2.68995e-07;
126  break;
127  case 3: // output rt-relation
128  m_rtNpar = 10;
129  m_rtParameters = new double[m_rtNpar];
130  m_rtParameters[0] = 2.31708e+01;
131  m_rtParameters[1] = 4.55828;
132  m_rtParameters[2] = 1.41878e+01;
133  m_rtParameters[3] = -5.99392;
134  m_rtParameters[4] = 1.34392;
135  m_rtParameters[5] = -1.65248e-01;
136  m_rtParameters[6] = 1.15960e-02;
137  m_rtParameters[7] = -4.29922e-04;
138  m_rtParameters[8] = 6.14201e-06;
139  m_rtParameters[9] = 2.00429e-08;
140  break;
141  default:
142  std::cout << "MDT_Response: Wrong rt-mode" << std::endl;
143  m_rtNpar = 0;
144  m_rtParameters = nullptr;
145  break;
146  }
147 // std::cout << "MDT_Response: RT-relation -> Polynomial" << std::endl;
148 // for(unsigned int i=0;i<m_rtNpar;++i)
149 // std::cout << " Par[" << i << "] = " << m_rtParameters[i] << std::endl;
150 }
151 
152 void MDT_Response::DoStepping(CLHEP::HepRandomEngine *rndmEngine)
153 {
154  //double propDelay = PropagationDelay(m_xhit);
155  double damping = DampingFactor(m_xhit);
156  double r2(m_rhit*m_rhit);
157  m_t0 = RtoT(m_rhit);
158 
159  for(int i=0;i<2;++i){ // splite track into to segments
160  double cl(0.); // current position along track
161  while(cl < m_pathLength){
162  cl += DoStep(rndmEngine); // Do step along track
163  double r = sqrt(cl*cl + r2); // calculate corresponding r
164  int q = GenerateQ(rndmEngine);// generate cluster size
165  double t = RtoT(r);
166  // check if value lies within window
167  if(t-m_t0 > m_bins*m_binsize + 3.*SigmaDiffusion(r) ) {
168  break;
169  }
170  double tc = t + Diffusion(r, rndmEngine) - m_t0;
171  int bin( (int)(tc/m_binsize+m_offset) );
172 
173  // fill value into corresponding bin
174  if(bin < (int)m_clusters.size() && bin >=0 ){
175  m_clusters[bin] += q*damping;
176  }else if(bin < 0) {
177  std::cout << "out of range " << tc << " bin " << bin << std::endl;
178  }
179  }
180  }
181 }
182 
183 
184 void MDT_Response::DoStepping(double ParticleCharge,double ParticleGamma, CLHEP::HepRandomEngine *rndmEngine)
185 {
186 // extract Cluster Density for the given value of particle gamma from the vector gammaFactorVec()
187  double correctedClusterDensity;
188  int km=0;
189  int kmm=0;
190  if(ParticleGamma<0.90852E+06){
191  while(ParticleGamma>m_gammaFactorVec.at(km)){
192  ++km;
193  }
194  int mm=km-1;
195  if(km!=0){
196  double deltagamma=fabs(m_gammaFactorVec.at(km)-m_gammaFactorVec.at(mm))/2.;
197  kmm=km-1;
198  if(ParticleGamma > (m_gammaFactorVec.at(mm)+deltagamma)){
199  kmm=km;
200  }
201  }
202  correctedClusterDensity=(8.5/40.636)*(m_numberOfClustersPerCmVec.at(kmm));
203  }else{
204  correctedClusterDensity=8.5;
205  }
206 
207  //double propDelay = PropagationDelay(m_xhit);
208  double damping = DampingFactor(m_xhit);
209  double r2(m_rhit*m_rhit);
210  m_t0 = RtoT(m_rhit);
211 
212  for(int i=0;i<2;++i){ // splite track into to segments
213  double cl(0.); // current position along track
214  while(cl < m_pathLength){
215 
216  if(fabs(ParticleCharge)!=1.){
217  cl += 8.5/(correctedClusterDensity*pow(ParticleCharge,2))*DoStep(rndmEngine); // Do step along track
218  }else{
219  cl += 8.5/(correctedClusterDensity)*DoStep(rndmEngine); // Do step along track
220  }
221 
222  double r = sqrt(cl*cl + r2); // calculate corresponding r
223  int q = GenerateQ(rndmEngine); // generate cluster size
224  double t = RtoT(r);
225  // check if value lies within window
226  if(t-m_t0 > m_bins*m_binsize + 3.*SigmaDiffusion(r) ) {
227  break;
228  }
229  double tc = t + Diffusion(r, rndmEngine) - m_t0;
230  int bin( (int)(tc/m_binsize+m_offset) );
231 
232  // fill value into corresponding bin
233  if(bin < (int)m_clusters.size() && bin >=0 ){
234  m_clusters[bin] += q*damping;
235  }else if(bin < 0) {
236  std::cout << "out of range " << tc << " bin " << bin << std::endl;
237  }
238  }
239  }
240 }
241 
242 
243 
244 
245 
247 {
248  clusterVec::iterator cit = m_clusters.begin();
249  for( ; cit != m_clusters.end() ; ++cit)
250  *cit = 0;
251  m_amplifier.Reset();
252 }
253 
254 bool MDT_Response::GetSignal(CLHEP::HepRandomEngine *rndmEngine)
255 {
256  // generate and propagate clusters
257  DoStepping(rndmEngine);
258 
259  // get amplifier response and see if it passed threshold
260  bool hasSignal = m_amplifier.AddClusters(m_clusters);
261  return hasSignal;
262 }
263 
264 
265 bool MDT_Response::GetSignal(double ParticleCharge,double ParticleGamma,CLHEP::HepRandomEngine *rndmEngine)
266 {
267  // generate and propagate clusters
268  DoStepping(ParticleCharge,ParticleGamma,rndmEngine);
269 
270  // get amplifier response and see if it passed threshold
271  bool hasSignal = m_amplifier.AddClusters(m_clusters);
272  return hasSignal;
273 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MDT_Response::GenerateQ
int GenerateQ(CLHEP::HepRandomEngine *rndmEngine) const
Definition: MDT_Response.h:120
MDT_Response::m_integrationWindow
double m_integrationWindow
Definition: MDT_Response.h:92
beamspotman.r
def r
Definition: beamspotman.py:676
MDT_Response::m_bins
int m_bins
Definition: MDT_Response.h:96
MDT_Response::m_signalSpeed
double m_signalSpeed
Definition: MDT_Response.h:83
MDT_Response::m_clusters
clusterVec m_clusters
Definition: MDT_Response.h:99
MDT_Response::InitdEdxTable
void InitdEdxTable()
Definition: MDT_Response.cxx:64
MDT_Response::m_difSmearing
double m_difSmearing
Definition: MDT_Response.h:89
MDT_Response::m_numberOfClustersPerCmVec
std::vector< double > m_numberOfClustersPerCmVec
Definition: MDT_Response.h:80
MDT_Response::m_gammaFactorVec
std::vector< double > m_gammaFactorVec
Definition: MDT_Response.h:79
MDT_Response::m_offset
int m_offset
Definition: MDT_Response.h:95
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MDT_Response::m_radius
double m_radius
Definition: MDT_Response.h:72
MDT_Response::m_xhit
double m_xhit
Definition: MDT_Response.h:75
MDT_Response::DoStepping
void DoStepping(CLHEP::HepRandomEngine *rndmEngine)
Definition: MDT_Response.cxx:152
bin
Definition: BinsDiffFromStripMedian.h:43
MDT_Response::InitClusters
void InitClusters(double timewindow, double binsize)
Definition: MDT_Response.cxx:37
MDT_Response::m_amplifier
Amplifier m_amplifier
Definition: MDT_Response.h:98
Amplifier::AddClusters
bool AddClusters(const cluster_vec &clusters)
Definition: Amplifier.cxx:132
Amplifier::SetTriggerElectron
void SetTriggerElectron(double el)
Definition: Amplifier.h:97
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MDT_Response.h
MDT_Response::m_triggerElectron
double m_triggerElectron
Definition: MDT_Response.h:91
MDT_Response::SigmaDiffusion
double SigmaDiffusion(double r) const
Definition: MDT_Response.h:173
Amplifier::InitResponse
void InitResponse(unsigned int bins, double binsize)
Definition: Amplifier.cxx:97
MDT_Response::m_pathLength
double m_pathLength
Definition: MDT_Response.h:76
MDT_Response::Reset
void Reset()
Definition: MDT_Response.cxx:246
MDT_Response::Diffusion
double Diffusion(double r, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MDT_Response.h:161
MDT_Response::m_binsize
double m_binsize
Definition: MDT_Response.h:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
MDT_Response::MDT_Response
MDT_Response()
Definition: MDT_Response.cxx:8
MDT_Response::DampingFactor
double DampingFactor(double x)
Definition: MDT_Response.h:136
MDT_Response::m_t0
double m_t0
Definition: MDT_Response.h:101
MDT_Response::InitTubeParameters
void InitTubeParameters()
Definition: MDT_Response.cxx:48
MDT_Response::m_rtParameters
double * m_rtParameters
Definition: MDT_Response.h:87
Amplifier::Reset
void Reset()
Definition: Amplifier.cxx:122
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
MDT_Response::m_attLength
double m_attLength
Definition: MDT_Response.h:82
Amplifier::SetIntegrationWindow
void SetIntegrationWindow(double win)
Definition: Amplifier.h:102
MDT_Response::m_rtMode
int m_rtMode
Definition: MDT_Response.h:85
MDT_Response::m_timeWindow
double m_timeWindow
Definition: MDT_Response.h:94
extractSporadic.q
list q
Definition: extractSporadic.py:98
MDT_Response::m_clusterDensity
double m_clusterDensity
Definition: MDT_Response.h:78
MDT_Response::DoStep
double DoStep(CLHEP::HepRandomEngine *rndmEngine) const
Definition: MDT_Response.h:114
MDT_Response::~MDT_Response
~MDT_Response()
Definition: MDT_Response.cxx:32
MDT_Response::m_rtNpar
unsigned int m_rtNpar
Definition: MDT_Response.h:86
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
MDT_Response::InitRt
void InitRt()
Definition: MDT_Response.cxx:96
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
python.SystemOfUnits.km
int km
Definition: SystemOfUnits.py:95
MDT_Response::RtoT
double RtoT(double r)
Definition: MDT_Response.h:142
MDT_Response::GetSignal
bool GetSignal(CLHEP::HepRandomEngine *rndmEngine)
Definition: MDT_Response.cxx:254
MDT_Response::m_rhit
double m_rhit
Definition: MDT_Response.h:74