Go to the documentation of this file.00001 #include "SimGeneral/GFlash/interface/GflashShowino.h"
00002 #include <CLHEP/Random/Randomize.h>
00003
00004 GflashShowino::GflashShowino()
00005 : theShowerType(-1), theEnergy(0), thePositionAtShower(0,0,0), thePathLengthAtShower(0),
00006 thePathLengthOnEcal(0), theStepLengthToHcal(0), theStepLengthToOut(0),
00007 thePathLength(0), theGlobalTime(0), thePosition(0,0,0), theEnergyDeposited(0)
00008 {
00009 theHelix = new GflashTrajectory;;
00010 }
00011
00012 GflashShowino::~GflashShowino()
00013 {
00014 delete theHelix;
00015 }
00016
00017 void GflashShowino::initialize(int showerType, double energy, double globalTime, double charge,
00018 Gflash3Vector &position, Gflash3Vector &momentum,
00019 double magneticField) {
00020
00021 theEnergy = energy;
00022 theGlobalTime = globalTime;
00023 theEnergyDeposited = 0.0;
00024
00025
00026 theHelix->initializeTrajectory(momentum,position,charge,magneticField);
00027
00028 if(showerType<100) {
00029 thePositionAtShower = position;
00030 thePosition = thePositionAtShower;
00031 theShowerType = showerType;
00032
00033 }
00034 else {
00035
00036
00037 thePositionAtShower = simulateFirstInteractionPoint(showerType,position);
00038 thePosition = thePositionAtShower;
00039
00040
00041 theShowerType = Gflash::findShowerType(thePositionAtShower);
00042
00043 }
00044
00045 evaluateLengths();
00046
00047 }
00048
00049 void GflashShowino::updateShowino(double deltaStep)
00050 {
00051 thePathLength += deltaStep;
00052
00053 GflashTrajectoryPoint trajectoryShowino;
00054 theHelix->getGflashTrajectoryPoint(trajectoryShowino,thePathLength);
00055
00056 thePosition = trajectoryShowino.getPosition();
00057
00058 theGlobalTime += (theEnergy/100.0)*deltaStep/30.0;
00059 }
00060
00061 void GflashShowino::evaluateLengths() {
00062
00063
00064
00065 double eta = thePosition.getEta();
00066
00067 if (std::fabs(eta) < Gflash::EtaMax[Gflash::kESPM]) {
00068 thePathLengthOnEcal = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB);
00069 thePathLengthAtShower = theHelix->getPathLengthAtRhoEquals(thePosition.getRho());
00070 double pathLengthAtHcalBack = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
00071 if (pathLengthAtHcalBack>0) {
00072 theStepLengthToOut = std::min(300.,pathLengthAtHcalBack - thePathLengthAtShower);
00073 }
00074 else {
00075 theStepLengthToOut = 200.;
00076 }
00077 theStepLengthToHcal = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]) - thePathLengthAtShower;
00078
00079 }
00080 else if (std::fabs(eta) < Gflash::EtaMax[Gflash::kENCA] ) {
00081 double zsign = (eta > 0) ? 1.0 : -1.0 ;
00082 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign*Gflash::ZFrontCrystalEE);
00083 thePathLengthAtShower = theHelix->getPathLengthAtZ(thePosition.getZ());
00084 theStepLengthToOut = std::min(300.,theHelix->getPathLengthAtZ(zsign*Gflash::Zmax[Gflash::kHE]) - thePathLengthAtShower);
00085 theStepLengthToHcal = theHelix->getPathLengthAtZ(zsign*Gflash::Zmin[Gflash::kHE]) - thePathLengthAtShower;
00086 }
00087 else {
00088
00089 theStepLengthToOut = 200.0;
00090 }
00091
00092 thePathLength = thePathLengthAtShower;
00093
00094 }
00095
00096 Gflash3Vector& GflashShowino::simulateFirstInteractionPoint(int fastSimShowerType, Gflash3Vector &position) {
00097
00098
00099
00100
00101 double depthAtShower = 0.0;
00102
00103
00104
00105
00106 double effectiveLambda = 0.0;
00107 if(theEnergy > 0.0 && theEnergy < 15) {
00108 effectiveLambda = 24.6+2.6*std::tanh(3.0*(std::log(theEnergy)-1.43));
00109 }
00110 else {
00111 effectiveLambda = 28.4+1.20*std::tanh(1.5*(std::log(theEnergy)-4.3));
00112 }
00113
00114
00115
00116 double frac_ssp2 = 2.8310e+00+2.6766e+00*tanh(-4.8068e-01*(std::log(theEnergy)+3.4857e+00));
00117
00118 if(fastSimShowerType == 100 ) {
00119
00120
00121 double rhoTemp = Gflash::LengthCrystalEB*std::sin(position.getTheta());
00122 thePathLengthOnEcal = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB);
00123 double pathLengthAt2 = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB + rhoTemp );
00124 double pathLengthAt3 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]);
00125
00127
00128
00129
00130
00131
00132
00133
00134
00135 depthAtShower = - effectiveLambda*log(CLHEP::HepUniformRand());
00136
00137 if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
00138
00139 if(CLHEP::HepUniformRand() < frac_ssp2 ) {
00140 depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3-pathLengthAt2)*CLHEP::HepUniformRand();
00141 }
00142
00143 else {
00144 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda*log(CLHEP::HepUniformRand());
00145
00146 double pathLengthAt4 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
00147 if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
00148 depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
00149 }
00150 }
00151 }
00152
00153 }
00154 else if(fastSimShowerType == 101 ) {
00155
00156 double zTemp = Gflash::LengthCrystalEE;
00157 double zsign = (position.getEta() > 0) ? 1.0 : -1.0 ;
00158
00159 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign*Gflash::ZFrontCrystalEE);
00160 double pathLengthAt2 = theHelix->getPathLengthAtZ(zsign*(Gflash::ZFrontCrystalEE + zTemp));
00161 double pathLengthAt3 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmin[Gflash::kHE]);
00162
00163
00164
00165
00166
00167
00168
00169
00170 depthAtShower = -effectiveLambda*std::log(CLHEP::HepUniformRand());
00171
00172 if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
00173 if(CLHEP::HepUniformRand() < frac_ssp2 ) {
00174 depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) +(pathLengthAt3 - pathLengthAt2)*CLHEP::HepUniformRand();
00175 }
00176 else {
00177 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal)-effectiveLambda*std::log(CLHEP::HepUniformRand());
00178
00179 double pathLengthAt4 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmax[Gflash::kHE]);
00180 if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
00181 depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
00182 }
00183 }
00184 }
00185
00186 }
00187 else {
00188 depthAtShower = 0.0;
00189 }
00190
00191 double pathLength = thePathLengthOnEcal + depthAtShower;
00192 GflashTrajectoryPoint trajectoryPoint;
00193 theHelix->getGflashTrajectoryPoint(trajectoryPoint,pathLength);
00194
00195
00196 return trajectoryPoint.getPosition();
00197
00198 }