00001
00002
00003
00004
00005
00007 #include "SimRomanPot/SimFP420/interface/HitDigitizerFP420.h"
00008
00009
00010
00011 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00012 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00013 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00014 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00015
00016 #include "SimRomanPot/SimFP420/interface/ChargeDrifterFP420.h"
00017 #include "SimRomanPot/SimFP420/interface/ChargeDividerFP420.h"
00018 #include "SimRomanPot/SimFP420/interface/InduceChargeFP420.h"
00019
00020 using namespace std;
00021 #include<vector>
00022
00023 #define CBOLTZ (1.38E-23)
00024 #define e_SI (1.6E-19)
00025
00026
00027
00028
00029
00030 HitDigitizerFP420::HitDigitizerFP420(float in,float ild,float ildx,float ildy,float in0,float in2,float in3){
00031 moduleThickness =in;
00032 double bz420 = in0;
00033 double bzD2 = in2;
00034 double bzD3 = in3;
00035
00036
00037
00038 double ldrift =ild;
00039 double ldriftX =ildx;
00040 double ldriftY =ildy;
00041
00042
00043
00044
00045
00046 theCDividerFP420 = new ChargeDividerFP420(moduleThickness, bz420, bzD2, bzD3);
00047
00048 depletionVoltage=20.0;
00049 appliedVoltage=25.0;
00050
00051
00052 chargeMobility=1350.0;
00053
00054
00055 temperature=263.;
00056 double diffusionConstant = CBOLTZ/e_SI * chargeMobility * temperature;
00057
00058 noDiffusion=false;
00059 if (noDiffusion) diffusionConstant *= 1.0e-3;
00060
00061 chargeDistributionRMS=6.5e-10;
00062
00063
00064 tanLorentzAnglePerTesla = 0. ;
00065
00066
00067
00068
00069 double timeNormalisation = pow(ldrift,2)/(2.*depletionVoltage*chargeMobility);
00070
00071 timeNormalisation = timeNormalisation*0.01;
00072
00073
00074
00075
00076 double clusterWidth=5.;
00077 gevperelectron= 3.61e-09;
00078
00079
00080 #ifdef mydigidebug2
00081 std::cout << "HitDigitizerFP420: constructor pitch= " << pitch << std::endl;
00082 std::cout << "pitchX= " << pitchX << "pitchY= " << pitchY << std::endl;
00083 std::cout << "depletionVoltage" << depletionVoltage << "appliedVoltage" << appliedVoltage << "chargeMobility" << chargeMobility << "temperature" << temperature << "diffusionConstant" << diffusionConstant << "chargeDistributionRMS" << chargeDistributionRMS << "moduleThickness" << moduleThickness << "timeNormalisation" << timeNormalisation << "gevperelectron" << gevperelectron << std::endl;
00084 #endif
00085
00086 theCDrifterFP420 =
00087 new ChargeDrifterFP420(moduleThickness,
00088 timeNormalisation,
00089 diffusionConstant,
00090 temperature,
00091 chargeDistributionRMS,
00092 depletionVoltage,
00093 appliedVoltage,
00094 ldriftX,
00095 ldriftY);
00096
00097
00098
00099 theIChargeFP420 = new InduceChargeFP420(clusterWidth,gevperelectron);
00100 }
00101
00102
00103 HitDigitizerFP420::~HitDigitizerFP420(){
00104 delete theCDividerFP420;
00105 delete theCDrifterFP420;
00106 delete theIChargeFP420;
00107 }
00108
00109
00110
00111 HitDigitizerFP420::hit_map_type HitDigitizerFP420::processHit(const PSimHit& hit, G4ThreeVector bfield, int zside,int numStrips, double pitch, int numStripsW, double pitchW, double moduleThickness){
00112
00113
00114
00115
00116 float middlex = (hit.exitPoint().x() + hit.entryPoint().x() )/2.;
00117 float middley = (hit.exitPoint().y() + hit.entryPoint().y() )/2.;
00118
00119
00120 float chargePosition= -100.;
00121
00122 if(zside == 1) {
00123
00124
00125
00126
00127
00128 chargePosition = 0.5*(numStrips-1) + middlex/pitch ;
00129
00130
00131 }
00132
00133 else if(zside == 2) {
00134
00135
00136
00137
00138
00139 chargePosition = 0.5*(numStrips-1) + middley/pitch ;
00140
00141
00142 }
00143 else {
00144 std::cout <<"================================================================"<<std::endl;
00145 std::cout << "**** HitDigitizerFP420: !!! ERROR: you have not to be here !!! zside=" << zside << std::endl;
00146
00147
00148
00149
00150 }
00151
00152 if(chargePosition > numStrips-1 || chargePosition < 1-1) {
00153 std::cout << "**** HitDigitizerFP420: !!! ERROR: check correspondence of XY detector dimensions in XML and here !!! chargePosition = " << chargePosition << std::endl;
00154
00155 }
00156
00157 #ifdef mydigidebug2
00158 std::cout << " ====== **** HitDigitizerFP420: !!! processHit !!! : input: zside=" << zside << " numStrips= " << numStrips << " pitch= " << pitch << " Calculated chargePosition= " << chargePosition << std::endl;
00159 std::cout << "The middle of hit point on input was: middlex = " << middlex << std::endl;
00160 std::cout << "The middle of hit point on input was: middley = " << middley << std::endl;
00161
00162 std::cout << " ====== **** HitDigitizerFP420:processHit: start CDrifterFP420 divide" << std::endl;
00163 #endif
00164
00165
00166
00167
00168
00169 CDrifterFP420::ionization_type ion = theCDividerFP420->divide(hit,moduleThickness);
00170
00171
00172
00173
00174
00175 G4ThreeVector driftDir = DriftDirection(bfield,zside);
00176 #ifdef mydigidebug2
00177 std::cout << " ====== **** HitDigitizerFP420:processHit: driftDir= " << driftDir << std::endl;
00178 std::cout << " ====== **** HitDigitizerFP420:processHit: start induce , CDrifterFP420 drift " << std::endl;
00179 #endif
00180
00181
00182
00183
00184 return theIChargeFP420->induce(theCDrifterFP420->drift(ion,driftDir,zside), numStrips, pitch, numStripsW, pitchW, zside);
00185
00186 }
00187
00188
00189
00190 G4ThreeVector HitDigitizerFP420::DriftDirection(G4ThreeVector _bfield, int zside){
00191
00192
00193
00194
00195
00196 G4ThreeVector Bfield=_bfield;
00197 float dir_x, dir_y, dir_z;
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 if(zside == 2) {
00210 dir_x = 1.;
00211 dir_y = +tanLorentzAnglePerTesla * Bfield.z();
00212 dir_z = -tanLorentzAnglePerTesla * Bfield.y();
00213 }
00214
00215
00216 else if(zside == 1) {
00217 dir_x = +tanLorentzAnglePerTesla * Bfield.z();
00218 dir_y = 1.;
00219 dir_z = -tanLorentzAnglePerTesla * Bfield.x();
00220 }
00221 else{
00222 dir_x = 0.;
00223 dir_y = 0.;
00224 dir_z = 0.;
00225 std::cout << "HitDigitizerFP420: ERROR - wrong zside=" << zside << std::endl;
00226 }
00227
00228
00229
00230 G4ThreeVector theDriftDirection(dir_x,dir_y,dir_z);
00231
00232 #ifdef mydigidebug2
00233 std::cout << "HitDigitizerFP420:DriftDirection tanLorentzAnglePerTesla= " << tanLorentzAnglePerTesla << std::endl;
00234 std::cout << "HitDigitizerFP420:DriftDirection The drift direction in local coordinate is " << theDriftDirection << std::endl;
00235 #endif
00236
00237 return theDriftDirection;
00238
00239 }