CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/SimRomanPot/SimFP420/src/ChargeDrifterFP420.cc

Go to the documentation of this file.
00001 
00002 // File: ChargeDrifterFP420
00003 // Date: 08.2008
00004 // Description: ChargeDrifterFP420 for FP420
00005 // Modifications: 
00007 #include "SimRomanPot/SimFP420/interface/ChargeDrifterFP420.h"
00008 using namespace std;
00009 
00010 ChargeDrifterFP420::ChargeDrifterFP420(                              double mt,
00011                                                                      double tn,
00012                                                                      double dc,
00013                                                                      double tm,
00014                                                                      double cdr,
00015                                                                      double dv,
00016                                                                      double av,
00017                                                                      double ptx,
00018                                                                      double pty, int verbosity) {
00019   //
00020   //
00021   verbo=verbosity; 
00022   modulePath = mt;
00023   constTe = tn;
00024   constDe = dc;
00025   temperature = tm;// keep just in case
00026   startT0 = cdr;
00027   depV = dv;
00028   appV = av;
00029   
00030   ldriftcurrX = ptx;
00031   ldriftcurrY = pty;
00032   //
00033   //
00034   
00035   
00036   
00037   //      edm::LogInfo("ChargeDrifterFP420") << "call constructor";
00038   if(verbo>0) {
00039     std::cout << "ChargeDrifterFP420: call constructor" << std::endl;
00040     std::cout << "ldriftcurrX= " << ldriftcurrX << "ldriftcurrY= " << ldriftcurrY << std::endl;
00041     std::cout << "modulePath= " << modulePath << "constTe= " << constTe << std::endl;
00042     std::cout << "ChargeDrifterFP420:----------------------" << std::endl;
00043   }
00044 }
00045 
00046 
00047 
00048 CDrifterFP420::collection_type ChargeDrifterFP420::drift(const CDrifterFP420::ionization_type ion, const G4ThreeVector& driftDir,const int& xytype){
00049   //
00050   //
00051   if(verbo>0) {
00052     std::cout << "ChargeDrifterFP420: collection_type call drift" << std::endl;
00053   }
00054   //
00055   //
00056   collection_type _temp;
00057   _temp.resize(ion.size());
00058   
00059   for (unsigned int i=0; i<ion.size(); i++){
00060     _temp[i] = drift(ion[i], driftDir, xytype);
00061   }
00062   return _temp;
00063 }
00064 
00065 AmplitudeSegmentFP420 ChargeDrifterFP420::drift
00066 (const EnergySegmentFP420& edu, const G4ThreeVector& drift, const int& xytype){
00067   //
00068   //
00069   //    sliX sliY sliZ are LOCALl(!) coordinates coming from ...hit.getEntryLocalP()...  
00070   //
00071   //
00072   //                Exchange xytype 1 <-> 2
00073   double sliX = (edu).x();
00074   double sliY = (edu).y();
00075   double sliZ = (edu).z();
00076   
00077   double currX = sliX;
00078   double currY = sliY;
00079   double currZ = sliZ;
00080   
00081   double pathFraction=0., pathValue=0.;
00082   double tanShiftAngleX=0.,tanShiftAngleY=0.,tanShiftAngleZ=0.;
00083   double xDriftDueToField=0.,yDriftDueToField=0.,zDriftDueToField=0.;
00084   if(verbo>0) {
00085     std::cout << "=================================================================== " << std::endl;
00086     std::cout << "ChargeDrifterFP420: xytype= " << xytype << std::endl;
00087     std::cout << "constTe= " <<  constTe << "ldriftcurrX= " <<  ldriftcurrX << "ldriftcurrY= " <<  ldriftcurrY << std::endl;
00088     std::cout << "1currX = " << currX  << "  1currY = " << currY  << "  1currZ = " << currZ  << std::endl;
00089     std::cout << "drift.x() = " << drift.x()  << "  drift.y() = " << drift.y()  << "  drift.z() = " << drift.z()  << std::endl;
00090   }
00091   
00092   // Yglobal Xlocal:
00093   //
00094   //
00095   // will define drift time of electrons along Xlocal or Ygobal with ldriftcurrY from Yglobal
00096   // change of ldriftcurrX to ldriftcurrY is done in intialization of ChargeDrifterFP420, so use old names for ldriftcurres
00097   if(xytype == 2) {
00098     tanShiftAngleY = drift.y()/drift.x();
00099     tanShiftAngleZ = drift.z()/drift.x();
00100     
00101     //    pathValue = fabs(sliX-ldriftcurrX*int(sliX/ldriftcurrX));
00102     pathValue = fabs(sliX)-int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX);
00103     pathValue = fabs(pathValue);
00104     pathFraction = pathValue/ldriftcurrX; 
00105     if(verbo>0) {
00106       std::cout << "==================================" << std::endl;
00107       std::cout << "fabs(sliX)= " << fabs(sliX) << "ldriftcurrX= " << ldriftcurrX << std::endl;
00108       std::cout << "fabs(sliX/(2*ldriftcurrX))+0.5= " << fabs(sliX/(2*ldriftcurrX))+0.5 << std::endl;
00109       std::cout << "int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX)= " << int(fabs(sliX/(2*ldriftcurrX))+0.5)*(2*ldriftcurrX) << std::endl;
00110       std::cout << "pathValue= " << pathValue << std::endl;
00111       std::cout << "pathFraction= " << pathFraction << std::endl;
00112       std::cout << "==================================" << std::endl;
00113     }
00114     
00115     pathFraction = pathFraction>0. ? pathFraction : 0. ;
00116     pathFraction = pathFraction<1. ? pathFraction : 1. ;
00117     
00118     yDriftDueToField // Drift along Y due to BField
00119       = pathValue*tanShiftAngleY;
00120     zDriftDueToField // Drift along Z due to BField
00121       = pathValue*tanShiftAngleZ;
00122     // will define Y and Z ccordinates (E along X)
00123     currY = sliY + yDriftDueToField;
00124     currZ = sliZ + zDriftDueToField;
00125   }
00126   
00127   // Xglobal Ylocal:
00128   // will define drift time of electrons along Ylocal
00129   else if(xytype == 1) {
00130     tanShiftAngleX = drift.x()/drift.y();
00131     tanShiftAngleZ = drift.z()/drift.y();
00132     
00133     //pathValue = fabs(sliY-ldriftcurrY*int(sliY/ldriftcurrY));
00134     pathValue = fabs(sliY)-int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY);
00135     pathValue = fabs(pathValue);
00136     pathFraction = pathValue/ldriftcurrY; 
00137     //
00138     //
00139     
00140     if(verbo>0) {
00141       std::cout << "==================================" << std::endl;
00142       std::cout << "fabs(sliY)= " << fabs(sliY) << "ldriftcurrY= " << ldriftcurrY << std::endl;
00143       std::cout << "fabs(sliY/(2*ldriftcurrY))+0.5= " << fabs(sliY/(2*ldriftcurrY))+0.5 << std::endl;
00144       std::cout << "int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY)= " << int(fabs(sliY/(2*ldriftcurrY))+0.5)*(2*ldriftcurrY) << std::endl;
00145       std::cout << "pathValue= " << pathValue << std::endl;
00146       std::cout << "pathFraction= " << pathFraction << std::endl;
00147       std::cout << "==================================" << std::endl;
00148     }
00149     
00150     if(pathFraction<0. || pathFraction>1.) std::cout << "ChargeDrifterFP420: ERROR:pathFraction=" << pathFraction << std::endl;
00151     pathFraction = pathFraction>0. ? pathFraction : 0. ;
00152     pathFraction = pathFraction<1. ? pathFraction : 1. ;
00153     xDriftDueToField // Drift along X due to BField
00154       = pathValue*tanShiftAngleX;
00155     //      = (ldriftcurrY-sliY)*tanShiftAngleX;
00156     zDriftDueToField // Drift along Z due to BField
00157       = pathValue*tanShiftAngleZ;
00158     // will define X and Z ccordinates (E along Y)
00159     currX = sliX + xDriftDueToField;
00160     currZ = sliZ + zDriftDueToField;
00161   }
00162   //  double tanShiftAngleX = drift.x()/drift.z();
00163   //  double tanShiftAngleY = drift.y()/drift.z();
00164   // double pathFraction = (modulePath/2.-sliZ)/modulePath ; 
00165   // pathFraction = pathFraction>0. ? pathFraction : 0. ;
00166   // pathFraction = pathFraction<1. ? pathFraction : 1. ;
00167   
00168   //uble xDriftDueToField // Drift along X due to BField
00169   //= (modulePath/2. - sliZ)*tanShiftAngleX;
00170   //uble yDriftDueToField // Drift along Y due to BField
00171   //= (modulePath/2. - sliZ)*tanShiftAngleY;
00172   //uble currX = sliX + xDriftDueToField;
00173   //uble currY = sliY + yDriftDueToField;
00174   //  
00175   //  
00176   // log is a ln 
00177   //  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;
00178   double bbb = 1.-2*depV*pathFraction/(depV+appV);
00179   if(bbb<0.) std::cout << "ChargeDrifterFP420:ERROR: check your Voltage for log(bbb) bbb=" << bbb << std::endl;
00180   double driftTime = -constTe*log(bbb) + startT0;  
00181   //    log(1.-2*depV*pathFraction/(depV+appV)) + startT0;  
00182   // since no magnetic field the Sigma_x, Sigma_y are the same =  sigma  !!!!!!!!!!!!!!!!! 
00183   double sigma = sqrt(2.*constDe*driftTime*100.);  //  * 100.  - since constDe is [cm2/sec], but i want [mm2/sec]
00184   
00185   //  std::cout << "ChargeDrifterFP420: driftTime=  " << driftTime << "  pathFraction=  " << pathFraction << "  constTe=  " << constTe << "  sigma=  " << sigma << std::endl;
00186   if(verbo>0) {
00187     std::cout << "ChargeDrifterFP420: drift: xytype=" << xytype << "pathFraction=" << pathFraction << std::endl;
00188     std::cout << "  constTe= " << constTe  << "  driftTime = " << driftTime << " startT0  = " << startT0 <<  std::endl;
00189     std::cout << " log = " << log(1.-2*depV*pathFraction/(depV+appV))  << std::endl;
00190     std::cout << " negativ inside log = " << -2*depV*pathFraction/(depV+appV)  << std::endl;
00191     std::cout << " constDe = " << constDe  << "  sigma = " << sigma << std::endl;
00192     
00193     std::cout << "ChargeDrifterFP420: drift: xytype=" << xytype << "pathValue=" << pathValue << std::endl;
00194     std::cout << " tanShiftAngleX = " << tanShiftAngleX  << "  tanShiftAngleY = " << tanShiftAngleY  << "  tanShiftAngleZ = " << tanShiftAngleZ  << std::endl;
00195     std::cout << "sliX = " << sliX  << "  sliY = " << sliY  << "  sliZ = " << sliZ  << std::endl;
00196     std::cout << "pathFraction = " << pathFraction  << "  driftTime = " << driftTime  << std::endl;
00197     std::cout << "sigma = " << sigma  << std::endl;
00198     std::cout << "xDriftDueToField = " << xDriftDueToField  << "  yDriftDueToField = " << yDriftDueToField  << "  zDriftDueToField = " << zDriftDueToField  << std::endl;
00199     std::cout << "2currX = " << currX  << "  2currY = " << currY  << "  2currZ = " << currZ  << std::endl;
00200     std::cout << "ChargeDrifterFP420: drift; finally, rETURN AmplitudeSlimentFP420" << std::endl;
00201     std::cout << "===================================================================" << std::endl;
00202     std::cout << " (edu).energy()= " << (edu).energy() << std::endl;
00203     std::cout << "==" << std::endl;
00204   }
00205   //  std::cout << "ChargeDrifterFP420: (edu).energy()= " << (edu).energy() << std::endl;
00206   return AmplitudeSegmentFP420(currX,currY,currZ,sigma,
00207                                (edu).energy());  
00208 }
00209