7 #include <CLHEP/GenericFunctions/IncompleteGamma.hh> 8 #include <CLHEP/GenericFunctions/LogGamma.hh> 9 #include <CLHEP/Random/RandGaussQ.h> 10 #include <CLHEP/Random/RandPoissonQ.h> 11 #include <CLHEP/Random/Randomize.h> 12 #include <CLHEP/Units/PhysicalConstants.h> 13 #include <CLHEP/Units/SystemOfUnits.h> 46 double showerDepthR50 = 0.0;
47 bool firstHcalHit =
true;
52 double deltaStep = 0.0;
53 double showerDepth = 0.0;
61 while (stepLengthLeft > 0.0) {
64 deltaStep = stepLengthLeft;
68 stepLengthLeft -= deltaStep;
71 showerDepth += deltaStep;
72 showerDepthR50 += deltaStep;
78 double heightProfile = 0.;
79 double deltaEnergy = 0.;
90 if (heightProfile < 1.00
e-08)
98 double hadronicFraction = 1.0;
99 double fluctuatedEnergy = deltaEnergy;
103 double sampleSpotEnergy = hadronicFraction * fluctuatedEnergy / nSpotsInStep;
108 firstHcalHit =
false;
116 double hitEnergy = sampleSpotEnergy * CLHEP::GeV;
121 for (
int ispot = 0; ispot < nSpotsInStep; ispot++) {
125 double incrementPath =
140 hitPosition *= CLHEP::cm;
156 double r0 = CLHEP::HepUniformRand();
162 if (r0 < nonzeroProb && leftoverE > 0.0) {
173 while (stepLengthLeft > 0.0) {
176 deltaStep = stepLengthLeft;
177 stepLengthLeft = 0.0;
180 stepLengthLeft -= deltaStep;
183 showerDepth += deltaStep;
190 double heightProfile = 0.;
191 double deltaEnergy = 0.;
205 double hoFraction = 1.00;
206 double poissonProb = CLHEP::RandPoissonQ::shoot(1.0);
208 double fluctuatedEnergy = deltaEnergy * poissonProb;
209 double sampleSpotEnergy = hoFraction * fluctuatedEnergy / nSpotsInStep;
216 double hitEnergy = sampleSpotEnergy * CLHEP::GeV;
219 for (
int ispot = 0; ispot < nSpotsInStep; ispot++) {
220 double incrementPath =
229 hitPosition *= CLHEP::cm;
248 edm::LogInfo(
"SimGeneralGFlash") <<
"GflashHadronShowerProfile::loadParameters() " 249 <<
"should be implimented for each particle type";
253 double lateralArm = 0.0;
262 double sigmaSq =
std::log(varinanceR50 / (R50 * R50) + 1.0);
264 double meanR50 =
std::log(R50) - (sigmaSq / 2.);
266 lateralArm =
std::exp(meanR50 + sigmaR50 * CLHEP::RandGaussQ::shoot());
274 double rnunif = CLHEP::HepUniformRand();
275 double rxPDF =
std::sqrt(rnunif / (1. - rnunif));
276 double rShower = lateralArm * rxPDF;
282 double azimuthalAngle = CLHEP::twopi * CLHEP::HepUniformRand();
286 rShower *
std::sin(azimuthalAngle) *
point.getCrossUnitVector();
300 double heightProfile = 0.0;
316 if (showerType == 0 || showerType == 4) {
318 if (shiftDepth > 0) {
325 }
else if (showerType == 1 || showerType == 5) {
332 }
else if (showerType == 2 || showerType == 6) {
334 if ((showerDepth - transDepth) > 0.0) {
338 }
else if (showerType == 3 || showerType == 7) {
343 return heightProfile;
347 double heightProfile = 0;
353 heightProfile =
std::exp(-1.0 * refDepth / dint);
355 return heightProfile;
361 double **
xr =
new double *[dim];
362 double **xrho =
new double *[dim];
364 for (
int j = 0;
j < dim;
j++) {
365 xr[
j] =
new double[dim];
366 xrho[
j] =
new double[dim];
369 for (
int i = 0;
i < dim;
i++) {
370 for (
int j = 0;
j <
i + 1;
j++) {
374 xrho[
i][
j] = lowTriangle[
i * (
i - 1) / 2 +
j];
375 xrho[
j][
i] = xrho[
i][
j];
382 for (
int i = 0;
i < dim;
i++) {
383 for (
int j = 0;
j <
i + 1;
j++) {
384 correlationVector[
i * (
i + 1) / 2 +
j] =
xr[
i][
j];
388 for (
int j = 0;
j < dim;
j++)
391 for (
int j = 0;
j < dim;
j++)
403 for (
int j = 1;
j < ndim;
j++) {
404 cc[
j][0] = vv[
j][0] /
cc[0][0];
407 for (
int j = 1;
j < ndim;
j++) {
409 for (
int k = 0;
k <
j;
k++)
410 sumCjkSquare +=
cc[
j][
k] *
cc[
j][
k];
412 vjjLess = vv[
j][
j] - sumCjkSquare;
417 for (
int i =
j + 1;
i < ndim;
i++) {
419 for (
int k = 0;
k <
j;
k++)
434 int numberOfSpots = 0;
438 if (showerType == 0 || showerType == 1 || showerType == 4 || showerType == 5) {
440 nmean = 10000 + 5000 *
log(einc);
444 nmean = 5000 + 2500 *
log(einc);
447 }
else if (showerType == 2 || showerType == 3 || showerType == 6 || showerType == 7) {
449 nmean = 5000 + 2500 *
log(einc);
460 numberOfSpots =
std::max(500, static_cast<int>(nmean + nsigma * CLHEP::RandGaussQ::shoot()));
465 numberOfSpots =
static_cast<int>(numberOfSpots / 100);
467 numberOfSpots =
static_cast<int>(numberOfSpots / 3.0);
470 return numberOfSpots;
497 if (showerDepth > 0.0) {
498 Genfun::LogGamma lgam;
499 double x = showerDepth * (
beta / lengthUnit);
506 double twoGamma = 0.0;
508 longPar[0] =
std::min(1.0, longPar[0]);
509 longPar[0] =
std::max(0.0, longPar[0]);
511 if (longPar[3] > 4.0 || longPar[4] > 4.0) {
512 double rfactor = 2.0 /
std::max(longPar[3], longPar[4]);
513 longPar[3] = rfactor * (longPar[3] + 1.0);
514 longPar[4] *= rfactor;
Gflash3Vector locateHitPosition(GflashTrajectoryPoint &point, double lateralArm)
double fTanh(double einc, const double *par)
double longHcal[Gflash::NPar]
static GflashHistogram * instance()
void setEnergy(const double energy)
T getParameter(std::string const &) const
double longitudinalProfile()
const double divisionStep
void tanh(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
double lateralPar[Gflash::kNumberCalorimeter][Gflash::Nrpar]
const double Zmax[kNumberCalorimeter]
double twoGammaProfile(double *par, double depth, Gflash::CalorimeterNumber kIndex)
Gflash3Vector & getPosition()
GflashTrajectory * getHelix()
GflashShowino * theShowino
double medianLateralArm(double depth, Gflash::CalorimeterNumber kCalor)
uint32_t cc[maxCellsPerHit]
Sin< T >::type sin(const T &t)
void setPosition(const Gflash3Vector &pos)
const double EtaMax[kNumberCalorimeter]
virtual ~GflashHadronShowerProfile()
GflashHistogram * theHisto
void doCholeskyReduction(double **cc, double **vv, const int ndim)
void addEnergyDeposited(double energy)
double getStepLengthToHcal()
void setTime(const double time)
const double ho_nonzero[5]
double longEcal[Gflash::NPar]
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector &position)
double getPathLengthAtRhoEquals(double rho) const
double getPathLengthAtShower()
virtual void loadParameters()
double fLnE1(double einc, const double *par)
double getEnergyDeposited()
Cos< T >::type cos(const T &t)
const double MinEnergyCutOffForHO
void setPathLength(double pathLength)
double gammaProfile(double alpha, double beta, double depth, double lengthUnit)
Gflash3Vector & getPositionAtShower()
const double intLength[kNumberCalorimeter]
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
Log< level::Info, false > LogInfo
std::vector< GflashHit > theGflashHitList
void hadronicParameterization()
const double maxShowerDepthforR50
const double radLength[kNumberCalorimeter]
GflashHadronShowerProfile(const edm::ParameterSet &parSet)
CLHEP::Hep3Vector Gflash3Vector
double getPathLengthOnEcal()
Gflash3Vector & getPosition()
static int position[264][3]
const double maxLateralArmforR50
void getFluctuationVector(double *lowTriangle, double *correlationVector)
double depthScale(double ssp, double ssp0, double length)
const double Rmax[kNumberCalorimeter]
int getNumberOfSpots(Gflash::CalorimeterNumber kCalor)
double hoProfile(double pathLength, double refDepth)
double getStepLengthToOut()
const double Rmin[kNumberCalorimeter]
Power< A, B >::type pow(const A &a, const B &b)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum)
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum, double magneticField)
double energyScale[Gflash::kNumberCalorimeter]
void updateShowino(double deltaStep)