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 theStepLengthToOut = std::min(300.,theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]) - thePathLengthAtShower);
00071 theStepLengthToHcal = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]) - thePathLengthAtShower;
00072 }
00073 else if (std::fabs(eta) < Gflash::EtaMax[Gflash::kENCA] ) {
00074 double zsign = (eta > 0) ? 1.0 : -1.0 ;
00075 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign*Gflash::ZFrontCrystalEE);
00076 thePathLengthAtShower = theHelix->getPathLengthAtZ(thePosition.getZ());
00077 theStepLengthToOut = std::min(300.,theHelix->getPathLengthAtZ(zsign*Gflash::Zmax[Gflash::kHE]) - thePathLengthAtShower);
00078 theStepLengthToHcal = theHelix->getPathLengthAtZ(zsign*Gflash::Zmin[Gflash::kHE]) - thePathLengthAtShower;
00079 }
00080 else {
00081
00082 theStepLengthToOut = 200.0;
00083 }
00084
00085 thePathLength = thePathLengthAtShower;
00086
00087 }
00088
00089
00090 Gflash3Vector& GflashShowino::simulateFirstInteractionPoint(int fastSimShowerType, Gflash3Vector &position) {
00091
00092
00093
00094
00095 double depthAtShower = 0.0;
00096
00097
00098
00099
00100 double effectiveLambda = 0.0;
00101 if(theEnergy > 0.0 && theEnergy < 15) {
00102 effectiveLambda = 24.6+2.6*std::tanh(3.0*(std::log(theEnergy)-1.43));
00103 }
00104 else {
00105 effectiveLambda = 28.4+1.20*std::tanh(1.5*(std::log(theEnergy)-4.3));
00106 }
00107
00108
00109
00110 double frac_ssp2 = 2.8310e+00+2.6766e+00*tanh(-4.8068e-01*(std::log(theEnergy)+3.4857e+00));
00111
00112 if(fastSimShowerType == 100 ) {
00113
00114
00115 double rhoTemp = Gflash::LengthCrystalEB*std::sin(position.getTheta());
00116 thePathLengthOnEcal = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB);
00117 double pathLengthAt2 = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB + rhoTemp );
00118 double pathLengthAt3 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]);
00119
00121
00122
00123
00124
00125
00126
00127
00128
00129 depthAtShower = - effectiveLambda*log(CLHEP::HepUniformRand());
00130
00131 if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
00132
00133 if(CLHEP::HepUniformRand() < frac_ssp2 ) {
00134 depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3-pathLengthAt2)*CLHEP::HepUniformRand();
00135 }
00136
00137 else {
00138 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda*log(CLHEP::HepUniformRand());
00139
00140 double pathLengthAt4 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
00141 if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
00142 depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
00143 }
00144 }
00145 }
00146
00147 }
00148 else if(fastSimShowerType == 101 ) {
00149
00150 double zTemp = Gflash::LengthCrystalEE;
00151 double zsign = (position.getEta() > 0) ? 1.0 : -1.0 ;
00152
00153 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign*Gflash::ZFrontCrystalEE);
00154 double pathLengthAt2 = theHelix->getPathLengthAtZ(zsign*(Gflash::ZFrontCrystalEE + zTemp));
00155 double pathLengthAt3 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmin[Gflash::kHE]);
00156
00157
00158
00159
00160
00161
00162
00163
00164 depthAtShower = -effectiveLambda*std::log(CLHEP::HepUniformRand());
00165
00166 if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
00167 if(CLHEP::HepUniformRand() < frac_ssp2 ) {
00168 depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) +(pathLengthAt3 - pathLengthAt2)*CLHEP::HepUniformRand();
00169 }
00170 else {
00171 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal)-effectiveLambda*std::log(CLHEP::HepUniformRand());
00172
00173 double pathLengthAt4 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmax[Gflash::kHE]);
00174 if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
00175 depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
00176 }
00177 }
00178 }
00179
00180 }
00181 else {
00182 depthAtShower = 0.0;
00183 }
00184
00185 double pathLength = thePathLengthOnEcal + depthAtShower;
00186 GflashTrajectoryPoint trajectoryPoint;
00187 theHelix->getGflashTrajectoryPoint(trajectoryPoint,pathLength);
00188
00189
00190 return trajectoryPoint.getPosition();
00191
00192 }