00001 #include "GeneratorInterface/CosmicMuonGenerator/interface/SingleParticleEvent.h"
00002
00003 void SingleParticleEvent::create(int id, double px, double py, double pz, double e, double m, double vx, double vy, double vz, double t0){
00004 ID = id;
00005 Px = px; Py = py; Pz = pz; E = e; M = m;
00006 Vx = vx; Vy = vy; Vz = vz; T0 = t0;
00007 HitTarget = false;
00008 }
00009
00010 void SingleParticleEvent::propagate(double ElossScaleFac, double RadiusTarget, double Z_DistTarget, double Z_CentrTarget, bool TrackerOnly, bool MTCCHalf){
00011 MTCC=MTCCHalf;
00012
00013 dX = Px/absmom();
00014 dY = Py/absmom();
00015 dZ = Pz/absmom();
00016
00017 tmpVx = Vx;
00018 tmpVy = Vy;
00019 tmpVz = Vz;
00020 double RadiusTargetEff = RadiusTarget;
00021 double Z_DistTargetEff = Z_DistTarget;
00022 double Z_CentrTargetEff = Z_CentrTarget;
00023
00024 if(TrackerOnly==true){
00025 RadiusTargetEff = RadiusTracker;
00026 Z_DistTargetEff = Z_DistTracker;
00027 }
00028 HitTarget = true;
00029 if (HitTarget == true){
00030 HitTarget = false;
00031 double stepSize = MinStepSize*100000.;
00032 double acceptR = RadiusTargetEff + stepSize;
00033 double acceptZ = Z_DistTargetEff + stepSize;
00034
00035 bool continuePropagation = true;
00036 while (continuePropagation){
00037 if (tmpVy < -acceptR) continuePropagation = false;
00038
00039 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00040 HitTarget = true;
00041 continuePropagation = false;
00042 }
00043 if (continuePropagation) updateTmp(stepSize);
00044 }
00045 }
00046 if (HitTarget == true){
00047 HitTarget = false;
00048 double stepSize = MinStepSize*10000.;
00049 double acceptR = RadiusTargetEff + stepSize;
00050 double acceptZ = Z_DistTargetEff + stepSize;
00051 bool continuePropagation = true;
00052 while (continuePropagation){
00053 if (tmpVy < -acceptR) continuePropagation = false;
00054
00055 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00056 HitTarget = true;
00057 continuePropagation = false;
00058 }
00059 if (continuePropagation) updateTmp(stepSize);
00060 }
00061 }
00062 if (HitTarget == true){
00063 HitTarget = false;
00064 double stepSize = MinStepSize*1000.;
00065 double acceptR = RadiusTargetEff + stepSize;
00066 double acceptZ = Z_DistTargetEff + stepSize;
00067 bool continuePropagation = true;
00068 while (continuePropagation){
00069 if (tmpVy < -acceptR) continuePropagation = false;
00070
00071 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00072 HitTarget = true;
00073 continuePropagation = false;
00074 }
00075 if (continuePropagation) updateTmp(stepSize);
00076 }
00077 }
00078 if (HitTarget == true){
00079 HitTarget = false;
00080 double stepSize = MinStepSize*100.;
00081 double acceptR = RadiusTargetEff + stepSize;
00082 double acceptZ = Z_DistTargetEff + stepSize;
00083 bool continuePropagation = true;
00084 while (continuePropagation){
00085 if (tmpVy < -acceptR) continuePropagation = false;
00086
00087 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00088 HitTarget = true;
00089 continuePropagation = false;
00090 }
00091 if (continuePropagation) updateTmp(stepSize);
00092 }
00093 }
00094 if (HitTarget == true){
00095 HitTarget = false;
00096 double stepSize = MinStepSize*10.;
00097 double acceptR = RadiusTargetEff + stepSize;
00098 double acceptZ = Z_DistTargetEff + stepSize;
00099 bool continuePropagation = true;
00100 while (continuePropagation){
00101 if (tmpVy < -acceptR) continuePropagation = false;
00102
00103 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00104 HitTarget = true;
00105 continuePropagation = false;
00106 }
00107 if (continuePropagation) updateTmp(stepSize);
00108 }
00109 }
00110 if (HitTarget == true){
00111 HitTarget = false;
00112 double stepSize = MinStepSize*1.;
00113 double acceptR = RadiusTargetEff + stepSize;
00114 double acceptZ = Z_DistTargetEff + stepSize;
00115 bool continuePropagation = true;
00116 while (continuePropagation){
00117 if (tmpVy < -acceptR) continuePropagation = false;
00118 if (0 < absVzTmp()){
00119
00120 if (fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR){
00121 HitTarget = true;
00122 continuePropagation = false;
00123 }
00124 }
00125 if (continuePropagation) updateTmp(stepSize);
00126 }
00127 }
00128
00129 if (HitTarget == true){
00130 HitTarget = false;
00131
00132 int nMat[6] = {0, 0, 0, 0, 0, 0};
00133 double stepSize = MinStepSize*1.;
00134 double acceptR = RadiusCMS + stepSize;
00135 double acceptZ = Z_DistCMS + stepSize;
00136 if(TrackerOnly==true){
00137 acceptR = RadiusTracker + stepSize;
00138 acceptZ = Z_DistTracker + stepSize;
00139 }
00140 bool continuePropagation = true;
00141 while (continuePropagation){
00142 if (Vy < -acceptR) continuePropagation = false;
00143
00144 if (fabs(Vz - Z_CentrTargetEff) < acceptZ && rVxy() < acceptR){
00145 HitTarget = true;
00146 continuePropagation = false;
00147 }
00148 if (continuePropagation) update(stepSize);
00149
00150 int Mat = inMat(Vx,Vy,Vz, PlugVx, PlugVz);
00151
00152 nMat[Mat]++;
00153 }
00154
00155 if (HitTarget){
00156 double lPlug = double(nMat[Plug])*stepSize;
00157 double lWall = double(nMat[Wall])*stepSize;
00158 double lAir = double(nMat[Air])*stepSize;
00159 double lClay = double(nMat[Clay])*stepSize;
00160 double lRock = double(nMat[Rock])*stepSize;
00161
00162
00163 double waterEquivalents = (lAir*RhoAir + lWall*RhoWall + lRock*RhoRock
00164 + lClay*RhoClay + lPlug*RhoPlug) *ElossScaleFac/10.;
00165 subtractEloss(waterEquivalents);
00166 if (E < MuonMass) HitTarget = false;
00167 }
00168 }
00169
00170 }
00171
00172 void SingleParticleEvent::update(double stepSize){
00173 Vx += stepSize*dX;
00174 Vy += stepSize*dY;
00175 Vz += stepSize*dZ;
00176 }
00177
00178 void SingleParticleEvent::updateTmp(double stepSize){
00179 tmpVx += stepSize*dX;
00180 tmpVy += stepSize*dY;
00181 tmpVz += stepSize*dZ;
00182 }
00183
00184 void SingleParticleEvent::subtractEloss(double waterEquivalents){
00185 double L10E = log10(E);
00186
00187 double A = (1.91514 + 0.254957*L10E)/1000.;
00188 double B = (0.379763 + 1.69516*L10E - 0.175026*L10E*L10E)/1000000.;
00189 double EPS = A/B;
00190 E = (E + EPS)*exp(-B*waterEquivalents) - EPS;
00191 double oldAbsMom = absmom();
00192 double newAbsMom = sqrt(E*E - MuonMass*MuonMass);
00193 Px = Px*newAbsMom/oldAbsMom;
00194 Py = Py*newAbsMom/oldAbsMom;
00195 Pz = Pz*newAbsMom/oldAbsMom;
00196 }
00197
00198 double SingleParticleEvent::absVzTmp(){
00199 if(MTCC==true){
00200 return tmpVz;
00201 }else{
00202 return fabs(tmpVz);
00203 }
00204 }
00205
00206 double SingleParticleEvent::rVxyTmp(){
00207 return sqrt(tmpVx*tmpVx + tmpVy*tmpVy);
00208 }
00209
00210 bool SingleParticleEvent::hitTarget(){ return HitTarget; }
00211
00212 int SingleParticleEvent::id(){ return ID; }
00213
00214 double SingleParticleEvent::px(){ return Px; }
00215
00216 double SingleParticleEvent::py(){ return Py; }
00217
00218 double SingleParticleEvent::pz(){ return Pz; }
00219
00220 double SingleParticleEvent::e(){ return E; }
00221
00222 double SingleParticleEvent::m(){ return M; }
00223
00224 double SingleParticleEvent::vx(){ return Vx; }
00225
00226 double SingleParticleEvent::vy(){ return Vy; }
00227
00228 double SingleParticleEvent::vz(){ return Vz; }
00229
00230 double SingleParticleEvent::t0(){ return T0; }
00231
00232 double SingleParticleEvent::phi(){
00233 double phiXZ = atan2(Px,Pz);
00234 if (phiXZ < 0.) phiXZ = phiXZ + TwoPi;
00235 return phiXZ;
00236 }
00237
00238 double SingleParticleEvent::theta(){
00239 return atan2(sqrt(Px*Px+Pz*Pz),-Py);
00240 }
00241
00242 double SingleParticleEvent::absmom(){
00243 return sqrt(Px*Px + Py*Py + Pz*Pz);
00244 }
00245
00246 double SingleParticleEvent::absVz(){
00247 return fabs(Vz);
00248 }
00249
00250 double SingleParticleEvent::rVxy(){
00251 return sqrt(Vx*Vx + Vy*Vy);
00252 }