CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ChargeDrifterFP420.cc
Go to the documentation of this file.
1 // File: ChargeDrifterFP420
3 // Date: 08.2008
4 // Description: ChargeDrifterFP420 for FP420
5 // Modifications:
8 using namespace std;
9 
11  double tn,
12  double dc,
13  double tm,
14  double cdr,
15  double dv,
16  double av,
17  double ptx,
18  double pty, int verbosity) {
19  //
20  //
21  verbo=verbosity;
22  modulePath = mt;
23  constTe = tn;
24  constDe = dc;
25  temperature = tm;// keep just in case
26  startT0 = cdr;
27  depV = dv;
28  appV = av;
29 
30  ldriftcurrX = ptx;
31  ldriftcurrY = pty;
32  //
33  //
34 
35 
36 
37  // edm::LogInfo("ChargeDrifterFP420") << "call constructor";
38  if(verbo>0) {
39  std::cout << "ChargeDrifterFP420: call constructor" << std::endl;
40  std::cout << "ldriftcurrX= " << ldriftcurrX << "ldriftcurrY= " << ldriftcurrY << std::endl;
41  std::cout << "modulePath= " << modulePath << "constTe= " << constTe << std::endl;
42  std::cout << "ChargeDrifterFP420:----------------------" << std::endl;
43  }
44 }
45 
46 
47 
48 CDrifterFP420::collection_type ChargeDrifterFP420::drift(const CDrifterFP420::ionization_type& ion, const G4ThreeVector& driftDir,const int& xytype){
49  //
50  //
51  if(verbo>0) {
52  std::cout << "ChargeDrifterFP420: collection_type call drift" << std::endl;
53  }
54  //
55  //
56  collection_type _temp;
57  _temp.resize(ion.size());
58 
59  for (unsigned int i=0; i<ion.size(); i++){
60  _temp[i] = drift(ion[i], driftDir, xytype);
61  }
62  return _temp;
63 }
64 
66 (const EnergySegmentFP420& edu, const G4ThreeVector& drift, const int& xytype){
67  //
68  //
69  // sliX sliY sliZ are LOCALl(!) coordinates coming from ...hit.getEntryLocalP()...
70  //
71  //
72  // Exchange xytype 1 <-> 2
73  double sliX = (edu).x();
74  double sliY = (edu).y();
75  double sliZ = (edu).z();
76 
77  double currX = sliX;
78  double currY = sliY;
79  double currZ = sliZ;
80 
81  double pathFraction=0., pathValue=0.;
82  double tanShiftAngleX=0.,tanShiftAngleY=0.,tanShiftAngleZ=0.;
83  double xDriftDueToField=0.,yDriftDueToField=0.,zDriftDueToField=0.;
84  if(verbo>0) {
85  std::cout << "=================================================================== " << std::endl;
86  std::cout << "ChargeDrifterFP420: xytype= " << xytype << std::endl;
87  std::cout << "constTe= " << constTe << "ldriftcurrX= " << ldriftcurrX << "ldriftcurrY= " << ldriftcurrY << std::endl;
88  std::cout << "1currX = " << currX << " 1currY = " << currY << " 1currZ = " << currZ << std::endl;
89  std::cout << "drift.x() = " << drift.x() << " drift.y() = " << drift.y() << " drift.z() = " << drift.z() << std::endl;
90  }
91 
92  // Yglobal Xlocal:
93  //
94  //
95  // will define drift time of electrons along Xlocal or Ygobal with ldriftcurrY from Yglobal
96  // change of ldriftcurrX to ldriftcurrY is done in intialization of ChargeDrifterFP420, so use old names for ldriftcurres
97  if(xytype == 2) {
98  tanShiftAngleY = drift.y()/drift.x();
99  tanShiftAngleZ = drift.z()/drift.x();
100 
101  // pathValue = fabs(sliX-ldriftcurrX*int(sliX/ldriftcurrX));
102  pathValue = fabs(sliX)-int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX);
103  pathValue = fabs(pathValue);
104  pathFraction = pathValue/ldriftcurrX;
105  if(verbo>0) {
106  std::cout << "==================================" << std::endl;
107  std::cout << "fabs(sliX)= " << fabs(sliX) << "ldriftcurrX= " << ldriftcurrX << std::endl;
108  std::cout << "fabs(sliX/(2*ldriftcurrX))+0.5= " << fabs(sliX/(2*ldriftcurrX))+0.5 << std::endl;
109  std::cout << "int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX)= " << int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX) << std::endl;
110  std::cout << "pathValue= " << pathValue << std::endl;
111  std::cout << "pathFraction= " << pathFraction << std::endl;
112  std::cout << "==================================" << std::endl;
113  }
114 
115  pathFraction = pathFraction>0. ? pathFraction : 0. ;
116  pathFraction = pathFraction<1. ? pathFraction : 1. ;
117 
118  yDriftDueToField // Drift along Y due to BField
119  = pathValue*tanShiftAngleY;
120  zDriftDueToField // Drift along Z due to BField
121  = pathValue*tanShiftAngleZ;
122  // will define Y and Z ccordinates (E along X)
123  currY = sliY + yDriftDueToField;
124  currZ = sliZ + zDriftDueToField;
125  }
126 
127  // Xglobal Ylocal:
128  // will define drift time of electrons along Ylocal
129  else if(xytype == 1) {
130  tanShiftAngleX = drift.x()/drift.y();
131  tanShiftAngleZ = drift.z()/drift.y();
132 
133  //pathValue = fabs(sliY-ldriftcurrY*int(sliY/ldriftcurrY));
134  pathValue = fabs(sliY)-int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY);
135  pathValue = fabs(pathValue);
136  pathFraction = pathValue/ldriftcurrY;
137  //
138  //
139 
140  if(verbo>0) {
141  std::cout << "==================================" << std::endl;
142  std::cout << "fabs(sliY)= " << fabs(sliY) << "ldriftcurrY= " << ldriftcurrY << std::endl;
143  std::cout << "fabs(sliY/(2*ldriftcurrY))+0.5= " << fabs(sliY/(2*ldriftcurrY))+0.5 << std::endl;
144  std::cout << "int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY)= " << int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY) << std::endl;
145  std::cout << "pathValue= " << pathValue << std::endl;
146  std::cout << "pathFraction= " << pathFraction << std::endl;
147  std::cout << "==================================" << std::endl;
148  }
149 
150  if(pathFraction<0. || pathFraction>1.) std::cout << "ChargeDrifterFP420: ERROR:pathFraction=" << pathFraction << std::endl;
151  pathFraction = pathFraction>0. ? pathFraction : 0. ;
152  pathFraction = pathFraction<1. ? pathFraction : 1. ;
153  xDriftDueToField // Drift along X due to BField
154  = pathValue*tanShiftAngleX;
155  // = (ldriftcurrY-sliY)*tanShiftAngleX;
156  zDriftDueToField // Drift along Z due to BField
157  = pathValue*tanShiftAngleZ;
158  // will define X and Z ccordinates (E along Y)
159  currX = sliX + xDriftDueToField;
160  currZ = sliZ + zDriftDueToField;
161  }
162  // double tanShiftAngleX = drift.x()/drift.z();
163  // double tanShiftAngleY = drift.y()/drift.z();
164  // double pathFraction = (modulePath/2.-sliZ)/modulePath ;
165  // pathFraction = pathFraction>0. ? pathFraction : 0. ;
166  // pathFraction = pathFraction<1. ? pathFraction : 1. ;
167 
168  //uble xDriftDueToField // Drift along X due to BField
169  //= (modulePath/2. - sliZ)*tanShiftAngleX;
170  //uble yDriftDueToField // Drift along Y due to BField
171  //= (modulePath/2. - sliZ)*tanShiftAngleY;
172  //uble currX = sliX + xDriftDueToField;
173  //uble currY = sliY + yDriftDueToField;
174  //
175  //
176  // log is a ln
177  // std::cout << "ChargeDrifterFP420: depV=" <<depV << " appV=" << appV << " startT0 =" <<startT0 << " 1.-2*depV*pathFraction/(depV+appV) =" <<1.-2*depV*pathFraction/(depV+appV) << " log(1.-2*depV*pathFraction/(depV+appV)) =" <<log(1.-2*depV*pathFraction/(depV+appV)) << std::endl;
178  double bbb = 1.-2*depV*pathFraction/(depV+appV);
179  if(bbb<0.) std::cout << "ChargeDrifterFP420:ERROR: check your Voltage for log(bbb) bbb=" << bbb << std::endl;
180  double driftTime = -constTe*log(bbb) + startT0;
181  // log(1.-2*depV*pathFraction/(depV+appV)) + startT0;
182  // since no magnetic field the Sigma_x, Sigma_y are the same = sigma !!!!!!!!!!!!!!!!!
183  double sigma = sqrt(2.*constDe*driftTime*100.); // * 100. - since constDe is [cm2/sec], but i want [mm2/sec]
184 
185  // std::cout << "ChargeDrifterFP420: driftTime= " << driftTime << " pathFraction= " << pathFraction << " constTe= " << constTe << " sigma= " << sigma << std::endl;
186  if(verbo>0) {
187  std::cout << "ChargeDrifterFP420: drift: xytype=" << xytype << "pathFraction=" << pathFraction << std::endl;
188  std::cout << " constTe= " << constTe << " driftTime = " << driftTime << " startT0 = " << startT0 << std::endl;
189  std::cout << " log = " << log(1.-2*depV*pathFraction/(depV+appV)) << std::endl;
190  std::cout << " negativ inside log = " << -2*depV*pathFraction/(depV+appV) << std::endl;
191  std::cout << " constDe = " << constDe << " sigma = " << sigma << std::endl;
192 
193  std::cout << "ChargeDrifterFP420: drift: xytype=" << xytype << "pathValue=" << pathValue << std::endl;
194  std::cout << " tanShiftAngleX = " << tanShiftAngleX << " tanShiftAngleY = " << tanShiftAngleY << " tanShiftAngleZ = " << tanShiftAngleZ << std::endl;
195  std::cout << "sliX = " << sliX << " sliY = " << sliY << " sliZ = " << sliZ << std::endl;
196  std::cout << "pathFraction = " << pathFraction << " driftTime = " << driftTime << std::endl;
197  std::cout << "sigma = " << sigma << std::endl;
198  std::cout << "xDriftDueToField = " << xDriftDueToField << " yDriftDueToField = " << yDriftDueToField << " zDriftDueToField = " << zDriftDueToField << std::endl;
199  std::cout << "2currX = " << currX << " 2currY = " << currY << " 2currZ = " << currZ << std::endl;
200  std::cout << "ChargeDrifterFP420: drift; finally, rETURN AmplitudeSlimentFP420" << std::endl;
201  std::cout << "===================================================================" << std::endl;
202  std::cout << " (edu).energy()= " << (edu).energy() << std::endl;
203  std::cout << "==" << std::endl;
204  }
205  // std::cout << "ChargeDrifterFP420: (edu).energy()= " << (edu).energy() << std::endl;
206  return AmplitudeSegmentFP420(currX,currY,currZ,sigma,
207  (edu).energy());
208 }
209 
int i
Definition: DBlmapReader.cc:9
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:39
CDrifterFP420::collection_type drift(const CDrifterFP420::ionization_type &, const G4ThreeVector &, const int &)
ChargeDrifterFP420(double, double, double, double, double, double, double, double, double, int)
T x() const
Cartesian x coordinate.
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< AmplitudeSegmentFP420 > collection_type
Definition: CDrifterFP420.h:14
std::vector< EnergySegmentFP420 > ionization_type
Definition: CDrifterFP420.h:15
tuple cout
Definition: gather_cfg.py:121