File indexing completed on 2024-04-06 12:30:35
0001 #include "SimGeneral/GFlash/interface/GflashShowino.h"
0002 #include <CLHEP/Random/Randomize.h>
0003
0004 GflashShowino::GflashShowino()
0005 : theShowerType(-1),
0006 theEnergy(0),
0007 thePositionAtShower(0, 0, 0),
0008 thePathLengthAtShower(0),
0009 thePathLengthOnEcal(0),
0010 theStepLengthToHcal(0),
0011 theStepLengthToOut(0),
0012 thePathLength(0),
0013 theGlobalTime(0),
0014 thePosition(0, 0, 0),
0015 theEnergyDeposited(0) {
0016 theHelix = new GflashTrajectory;
0017 }
0018
0019 GflashShowino::~GflashShowino() { delete theHelix; }
0020
0021 void GflashShowino::initialize(int showerType,
0022 double energy,
0023 double globalTime,
0024 double charge,
0025 Gflash3Vector &position,
0026 Gflash3Vector &momentum,
0027 double magneticField) {
0028 theEnergy = energy;
0029 theGlobalTime = globalTime;
0030 theEnergyDeposited = 0.0;
0031
0032
0033 theHelix->initializeTrajectory(momentum, position, charge, magneticField);
0034
0035 if (showerType < 100) {
0036 thePositionAtShower = position;
0037 thePosition = thePositionAtShower;
0038 theShowerType = showerType;
0039
0040 } else {
0041
0042
0043 thePositionAtShower = simulateFirstInteractionPoint(showerType, position);
0044 thePosition = thePositionAtShower;
0045
0046
0047 theShowerType = Gflash::findShowerType(thePositionAtShower);
0048 }
0049
0050 evaluateLengths();
0051 }
0052
0053 void GflashShowino::updateShowino(double deltaStep) {
0054 thePathLength += deltaStep;
0055
0056 GflashTrajectoryPoint trajectoryShowino;
0057 theHelix->getGflashTrajectoryPoint(trajectoryShowino, thePathLength);
0058
0059 thePosition = trajectoryShowino.getPosition();
0060
0061 theGlobalTime += (theEnergy / 100.0) * deltaStep / 30.0;
0062 }
0063
0064 void GflashShowino::evaluateLengths() {
0065
0066
0067
0068
0069
0070 double eta = thePosition.getEta();
0071
0072 if (std::fabs(eta) < Gflash::EtaMax[Gflash::kESPM]) {
0073 thePathLengthOnEcal = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB);
0074 thePathLengthAtShower = theHelix->getPathLengthAtRhoEquals(thePosition.getRho());
0075 double pathLengthAtHcalBack = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
0076 if (pathLengthAtHcalBack > 0) {
0077 theStepLengthToOut = std::min(300., pathLengthAtHcalBack - thePathLengthAtShower);
0078 } else {
0079 theStepLengthToOut = 200.;
0080 }
0081 theStepLengthToHcal = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]) - thePathLengthAtShower;
0082
0083 } else if (std::fabs(eta) < Gflash::EtaMax[Gflash::kENCA]) {
0084 double zsign = (eta > 0) ? 1.0 : -1.0;
0085 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign * Gflash::ZFrontCrystalEE);
0086 thePathLengthAtShower = theHelix->getPathLengthAtZ(thePosition.getZ());
0087 theStepLengthToOut =
0088 std::min(300., theHelix->getPathLengthAtZ(zsign * Gflash::Zmax[Gflash::kHE]) - thePathLengthAtShower);
0089 theStepLengthToHcal = theHelix->getPathLengthAtZ(zsign * Gflash::Zmin[Gflash::kHE]) - thePathLengthAtShower;
0090 } else {
0091
0092 theStepLengthToOut = 200.0;
0093 }
0094
0095 thePathLength = thePathLengthAtShower;
0096 }
0097
0098 Gflash3Vector &GflashShowino::simulateFirstInteractionPoint(int fastSimShowerType, Gflash3Vector &position) {
0099
0100
0101
0102
0103 double depthAtShower = 0.0;
0104
0105
0106
0107
0108
0109 double effectiveLambda = 0.0;
0110 if (theEnergy > 0.0 && theEnergy < 15) {
0111 effectiveLambda = 24.6 + 2.6 * std::tanh(3.0 * (std::log(theEnergy) - 1.43));
0112 } else {
0113 effectiveLambda = 28.4 + 1.20 * std::tanh(1.5 * (std::log(theEnergy) - 4.3));
0114 }
0115
0116
0117
0118
0119 double frac_ssp2 = 2.8310e+00 + 2.6766e+00 * tanh(-4.8068e-01 * (std::log(theEnergy) + 3.4857e+00));
0120
0121 if (fastSimShowerType == 100) {
0122
0123
0124
0125 double rhoTemp = Gflash::LengthCrystalEB * std::sin(position.getTheta());
0126 thePathLengthOnEcal = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB);
0127 double pathLengthAt2 = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB + rhoTemp);
0128 double pathLengthAt3 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]);
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 depthAtShower = -effectiveLambda * log(CLHEP::HepUniformRand());
0142
0143 if (depthAtShower > (pathLengthAt2 - thePathLengthOnEcal)) {
0144
0145 if (CLHEP::HepUniformRand() < frac_ssp2) {
0146 depthAtShower =
0147 (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3 - pathLengthAt2) * CLHEP::HepUniformRand();
0148 }
0149
0150 else {
0151 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda * log(CLHEP::HepUniformRand());
0152
0153 double pathLengthAt4 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
0154 if (depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
0155 depthAtShower = (pathLengthAt4 - pathLengthAt3) * CLHEP::HepUniformRand();
0156 }
0157 }
0158 }
0159
0160 } else if (fastSimShowerType == 101) {
0161
0162 double zTemp = Gflash::LengthCrystalEE;
0163 double zsign = (position.getEta() > 0) ? 1.0 : -1.0;
0164
0165 thePathLengthOnEcal = theHelix->getPathLengthAtZ(zsign * Gflash::ZFrontCrystalEE);
0166 double pathLengthAt2 = theHelix->getPathLengthAtZ(zsign * (Gflash::ZFrontCrystalEE + zTemp));
0167 double pathLengthAt3 = theHelix->getPathLengthAtZ(zsign * Gflash::Zmin[Gflash::kHE]);
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 depthAtShower = -effectiveLambda * std::log(CLHEP::HepUniformRand());
0179
0180 if (depthAtShower > (pathLengthAt2 - thePathLengthOnEcal)) {
0181 if (CLHEP::HepUniformRand() < frac_ssp2) {
0182 depthAtShower =
0183 (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3 - pathLengthAt2) * CLHEP::HepUniformRand();
0184 } else {
0185 depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda * std::log(CLHEP::HepUniformRand());
0186
0187 double pathLengthAt4 = theHelix->getPathLengthAtZ(zsign * Gflash::Zmax[Gflash::kHE]);
0188 if (depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
0189 depthAtShower = (pathLengthAt4 - pathLengthAt3) * CLHEP::HepUniformRand();
0190 }
0191 }
0192 }
0193
0194 } else {
0195 depthAtShower = 0.0;
0196 }
0197
0198 double pathLength = thePathLengthOnEcal + depthAtShower;
0199
0200 theHelix->getGflashTrajectoryPoint(theTrajectoryPoint, pathLength);
0201
0202
0203 return theTrajectoryPoint.getPosition();
0204 }