ATLAS Offline Software
MDT_Response.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MDT_RESPONSE_MDT_RESPONSE_H
6 #define MDT_RESPONSE_MDT_RESPONSE_H
7 
8 #include <vector>
9 
10 #include "MDT_Response/Amplifier.h"
11 #include "CLHEP/Vector/ThreeVector.h"
12 #include "CLHEP/Random/RandPoisson.h"
13 #include "CLHEP/Random/RandGaussZiggurat.h"
14 #include "CLHEP/Random/RandFlat.h"
15 // Add support for CLHEP 1.9 by replacing forward declarations by inclusion
16 // of equivalent header file.
17 #include "CLHEP/Random/RandomEngine.h"
18 
19 
20 class MDT_Response {
21 
22  public:
23  typedef std::vector<double> clusterVec;
24 
25  MDT_Response();
26  MDT_Response(double timewindow, double binsize); // time window in which to look for threshold
27  ~MDT_Response();
28 
29  // set segment
30  void SetSegment(double r, double x);
31 
32  // set parameters
33  void SetTubeRadius(double radius);
34  void SetClusterDensity(double dens);
35  void SetAttLength(double len);
36  void SetRtMode(unsigned int mode);
37  void SetDifRMS(double rms);
38  void SetTriggerElectron(double el);
39  void SetIntegrationWindow(double win);
40  void SetRtParameters(int npar,double *par);
41 
42  // get functions
43  bool GetSignal(CLHEP::HepRandomEngine *rndmEngine); // processes hit, returns true if amplifier passed threshold
44  bool GetSignal(double ParticleCharge,double ParticleGamma,CLHEP::HepRandomEngine *rndmEngine); // processes hit, returns true if amplifier passed threshold
45 
46  // acces to amplifier
47  double DriftTime() const;
48  double TThreshold() const;
49  double TFirst() const;
50  double T0() const;
51  double AdcResponse() const;
52  double Charge() const;
53  double V_r(double r);
54  double DoStep(CLHEP::HepRandomEngine *rndmEngine) const;
55  double DampingFactor(double x);
56  double PropagationDelay(double x);
57  double RtoT(double r);
58  double Diffusion(double r, CLHEP::HepRandomEngine *rndmEngine) const;
59  double SigmaDiffusion(double r) const;
60  int GenerateQ(CLHEP::HepRandomEngine *rndmEngine) const;
61 
62  const double* RtParameters() const;
63  private:
64  void InitTubeParameters();
65  void InitClusters(double timewindow, double binsize);
66  void InitRt();
67  void InitdEdxTable();
68  void DoStepping(CLHEP::HepRandomEngine *rndmEngine);
69  void DoStepping(double ParticleCharge,double ParticleGamma, CLHEP::HepRandomEngine *rndmEngine);
70  void Reset();
71 
72  double m_radius = 0.0; // radius of the tube
73 
74  double m_rhit; // radius of the current hit
75  double m_xhit; // position along the tube of the current hit
76  double m_pathLength; // path length of particle in tube
77 
78  double m_clusterDensity = 0.0; // clusters per mm
79  std::vector<double> m_gammaFactorVec; // gamma
80  std::vector<double> m_numberOfClustersPerCmVec; // clusters per cm
81 
82  double m_attLength = 0.0; // attenuation length of tube
83  double m_signalSpeed = 0.0; // propagation speed along wire
84 
85  int m_rtMode = 0; // choose rt mode
86  unsigned int m_rtNpar = 0U;
87  double* m_rtParameters;
88 
89  double m_difSmearing = 0.0; // width of gaussian smearing
90 
91  double m_triggerElectron = 0.0;
92  double m_integrationWindow = 0.0;
93  double m_binsize = 0.0;
94  double m_timeWindow = 0.0;
95  int m_offset = 0;
96  int m_bins = 0;
97 
98  Amplifier m_amplifier; // amplifier
99  clusterVec m_clusters; // produced clusters
100 
101  double m_t0;
102 };
103 
104 inline
105 void MDT_Response::SetSegment(double r, double x)
106 {
107  m_rhit = r;
108  m_xhit = x;
109  m_pathLength = sqrt(m_radius*m_radius - r*r);
110  Reset();
111 }
112 
113 inline
114 double MDT_Response::DoStep(CLHEP::HepRandomEngine *rndmEngine) const
115 {
116  return (-1./m_clusterDensity)*log( CLHEP::RandFlat::shoot(rndmEngine) );
117 }
118 
119 inline
120 int MDT_Response::GenerateQ(CLHEP::HepRandomEngine *rndmEngine) const
121 {
122  double v = CLHEP::RandFlat::shoot(rndmEngine);
123  double p;
124  if(v<0.08){
125  p = CLHEP::RandPoisson::shoot(rndmEngine,13.);
126  }else if(v<0.28){
127  double v1 = CLHEP::RandFlat::shoot(rndmEngine);
128  p = (1./(v1+1.e-7));
129  }else{
130  p = 1+CLHEP::RandPoisson::shoot(rndmEngine,0.05);
131  }
132  return (int)p;
133 }
134 
135 inline
136 double MDT_Response::DampingFactor(double x) { return exp(-1.*x/m_attLength); }
137 
138 inline
140 
141 inline
142 double MDT_Response::RtoT(double r)
143 {
144  int j = m_rtNpar-1;
145  double time = m_rtParameters[j];
146  while(j>0) { --j; time = time*r + m_rtParameters[j]; }
147  return time;
148 }
149 
150 inline
151 double MDT_Response::V_r(double r)
152 {
153  int j = m_rtNpar-1;
154  double p = m_rtParameters[j];
155  double dp = 0.;
156  while(j>0) {dp = dp*r + p;--j;p=p*r+m_rtParameters[j]; }
157  return 1./dp;
158 }
159 
160 inline
161 double MDT_Response::Diffusion(double r, CLHEP::HepRandomEngine *rndmEngine) const
162 {
163  // Smearing with maximum of three sigma
164  double sigma = SigmaDiffusion(r);
165  double t = CLHEP::RandGaussZiggurat::shoot(rndmEngine,0.,sigma);
166  if(fabs(t) > 3*sigma) {
167  t = Diffusion(r, rndmEngine);
168  }
169  return t;
170 }
171 
172 inline
173 double MDT_Response::SigmaDiffusion(double r) const
174 {
175  return m_difSmearing*r/m_radius;
176 }
177 
178 // access to amplifier response
179 inline double MDT_Response::DriftTime() const
180 { return m_t0 + m_amplifier.TThreshold() - m_offset*m_binsize; }
181 
182 inline double MDT_Response::TThreshold() const
184 
185 inline double MDT_Response::TFirst() const
186 { return m_amplifier.TFirst(); }
187 
188 inline double MDT_Response::T0() const
189 { return m_t0; }
190 
191 inline double MDT_Response::AdcResponse() const
192 { return m_amplifier.AdcResponse(); }
193 
194 inline double MDT_Response::Charge() const
195 { return m_amplifier.Charge(); }
196 
198 { m_radius = radius ; }
199 
200 
201 inline void MDT_Response::SetClusterDensity(double dens)
202 { m_clusterDensity = dens ; }
203 
204 inline void MDT_Response::SetAttLength(double len)
205 { m_attLength = len ; }
206 
207 inline void MDT_Response::SetRtMode(unsigned int mode)
208 { m_rtMode = mode; InitRt(); }
209 
210 inline void MDT_Response::SetDifRMS(double rms)
212 
215 
216 inline void MDT_Response::SetIntegrationWindow(double win)
218 
219 inline void MDT_Response::SetRtParameters(int npar,double *par)
220 {
221  m_rtNpar = npar;
222  if(m_rtParameters) delete m_rtParameters;
223  m_rtParameters = new double[m_rtNpar];
224  for(unsigned int i=0;i<m_rtNpar;++i)
225  m_rtParameters[i] = par[i];
226 }
227 inline const double* MDT_Response::RtParameters() const
228 {
229  return m_rtParameters;
230 }
231 
232 #endif
Amplifier
Definition: Amplifier.h:11
MDT_Response::TThreshold
double TThreshold() const
Definition: MDT_Response.h:182
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
Amplifier.h
MDT_Response::m_signalSpeed
double m_signalSpeed
Definition: MDT_Response.h:83
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
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
pdg_comparison.sigma
sigma
Definition: pdg_comparison.py:324
MDT_Response::SetTubeRadius
void SetTubeRadius(double radius)
Definition: MDT_Response.h:197
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
MDT_Response::DriftTime
double DriftTime() const
Definition: MDT_Response.h:179
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::SetAttLength
void SetAttLength(double len)
Definition: MDT_Response.h:204
Amplifier::TFirst
double TFirst() const
Definition: Amplifier.h:84
MDT_Response::DoStepping
void DoStepping(CLHEP::HepRandomEngine *rndmEngine)
Definition: MDT_Response.cxx:152
Amplifier::Charge
double Charge() const
Definition: Amplifier.h:93
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::SetTriggerElectron
void SetTriggerElectron(double el)
Definition: Amplifier.h:97
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
MDT_Response::m_triggerElectron
double m_triggerElectron
Definition: MDT_Response.h:91
MDT_Response::SetRtMode
void SetRtMode(unsigned int mode)
Definition: MDT_Response.h:207
MDT_Response::Charge
double Charge() const
Definition: MDT_Response.h:194
MDT_Response::SigmaDiffusion
double SigmaDiffusion(double r) const
Definition: MDT_Response.h:173
MDT_Response::PropagationDelay
double PropagationDelay(double x)
Definition: MDT_Response.h:139
MDT_Response::m_pathLength
double m_pathLength
Definition: MDT_Response.h:76
MDT_Response::Reset
void Reset()
Definition: MDT_Response.cxx:246
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MDT_Response::T0
double T0() const
Definition: MDT_Response.h:188
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
Amplifier::TThreshold
double TThreshold() const
Definition: Amplifier.h:81
MDT_Response::MDT_Response
MDT_Response()
Definition: MDT_Response.cxx:8
MDT_Response::RtParameters
const double * RtParameters() const
Definition: MDT_Response.h:227
MDT_Response::DampingFactor
double DampingFactor(double x)
Definition: MDT_Response.h:136
MDT_Response::SetRtParameters
void SetRtParameters(int npar, double *par)
Definition: MDT_Response.h:219
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
MDT_Response::V_r
double V_r(double r)
Definition: MDT_Response.h:151
Preparation.mode
mode
Definition: Preparation.py:94
MDT_Response::m_t0
double m_t0
Definition: MDT_Response.h:101
MDT_Response::SetTriggerElectron
void SetTriggerElectron(double el)
Definition: MDT_Response.h:213
MDT_Response::InitTubeParameters
void InitTubeParameters()
Definition: MDT_Response.cxx:48
MDT_Response::m_rtParameters
double * m_rtParameters
Definition: MDT_Response.h:87
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MDT_Response::clusterVec
std::vector< double > clusterVec
Definition: MDT_Response.h:23
MDT_Response::SetIntegrationWindow
void SetIntegrationWindow(double win)
Definition: MDT_Response.h:216
python.PyAthena.v
v
Definition: PyAthena.py:154
MDT_Response::m_attLength
double m_attLength
Definition: MDT_Response.h:82
MDT_Response
Definition: MDT_Response.h:20
Amplifier::AdcResponse
double AdcResponse() const
Definition: Amplifier.h:90
Amplifier::SetIntegrationWindow
void SetIntegrationWindow(double win)
Definition: Amplifier.h:102
MDT_Response::AdcResponse
double AdcResponse() const
Definition: MDT_Response.h:191
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
MDT_Response::m_rtMode
int m_rtMode
Definition: MDT_Response.h:85
MDT_Response::m_timeWindow
double m_timeWindow
Definition: MDT_Response.h:94
MDT_Response::SetClusterDensity
void SetClusterDensity(double dens)
Definition: MDT_Response.h:201
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
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
MDT_Response::InitRt
void InitRt()
Definition: MDT_Response.cxx:96
MDT_Response::RtoT
double RtoT(double r)
Definition: MDT_Response.h:142
MDT_Response::SetSegment
void SetSegment(double r, double x)
Definition: MDT_Response.h:105
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
MDT_Response::SetDifRMS
void SetDifRMS(double rms)
Definition: MDT_Response.h:210
MDT_Response::TFirst
double TFirst() const
Definition: MDT_Response.h:185