CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
ZdcShowerLibrary Class Reference

#include <ZdcShowerLibrary.h>

Classes

struct  Hit
 

Public Member Functions

int getEnergyFromLibrary (const G4ThreeVector &posHit, const G4ThreeVector &momDir, double energy, G4int parCode, HcalZDCDetId::Section section, bool side, int channel)
 
std::vector< Hit > & getHits (const G4Step *aStep, bool &ok)
 
int photonFluctuation (double eav, double esig, double edis)
 
 ZdcShowerLibrary (const std::string &name, edm::ParameterSet const &p)
 
 ~ZdcShowerLibrary ()
 

Private Attributes

std::vector< ZdcShowerLibrary::Hithits
 
int npe
 
bool verbose
 

Detailed Description

Definition at line 21 of file ZdcShowerLibrary.h.

Constructor & Destructor Documentation

◆ ZdcShowerLibrary()

ZdcShowerLibrary::ZdcShowerLibrary ( const std::string &  name,
edm::ParameterSet const &  p 
)

Definition at line 20 of file ZdcShowerLibrary.cc.

References edm::ParameterSet::getUntrackedParameter(), hits, npe, AlCaHLTBitMon_ParallelJobs::p, and verbose.

20  {
21  edm::ParameterSet m_HS = p.getParameter<edm::ParameterSet>("ZdcShowerLibrary");
22  verbose = m_HS.getUntrackedParameter<int>("Verbosity", 0);
23 
24  npe = 9; // number of channels or fibers where the energy will be deposited
25  hits.reserve(npe);
26 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ZdcShowerLibrary::Hit > hits

◆ ~ZdcShowerLibrary()

ZdcShowerLibrary::~ZdcShowerLibrary ( )

Definition at line 28 of file ZdcShowerLibrary.cc.

28 {}

Member Function Documentation

◆ getEnergyFromLibrary()

int ZdcShowerLibrary::getEnergyFromLibrary ( const G4ThreeVector &  posHit,
const G4ThreeVector &  momDir,
double  energy,
G4int  parCode,
HcalZDCDetId::Section  section,
bool  side,
int  channel 
)

Definition at line 131 of file ZdcShowerLibrary.cc.

References HCALHighEnergyHPDFilter_cfi::energy, fact, createfilelist::int, G4TrackToParticleID::isGammaElectronPositron(), HMesonGammaMonitor_cff::nphotons, photonFluctuation(), funct::pow(), hgcalPlots::section, theXChannelBoundaries, and ecalPiZeroTask_cfi::X0.

Referenced by getHits().

137  {
138  int nphotons = -1;
139 
140  energy = energy / GeV;
141 
142  edm::LogVerbatim("ZdcShower") << "\n ZdcShowerLibrary::getEnergyFromLibrary input/output variables:"
143  << " phi: " << 59.2956 * momDir.phi() << " theta: " << 59.2956 * momDir.theta()
144  << " xin : " << hitPoint.x() << " yin : " << hitPoint.y() << " zin : " << hitPoint.z()
145  << " track en: " << energy << "(GeV)"
146  << " section: " << section << " side: " << side << " channel: " << channel
147  << " partID: " << parCode;
148 
149  double eav = 0.;
150  double esig = 0.;
151  double edis = 0.;
152 
153  float xin = hitPoint.x();
154  float yin = hitPoint.y();
155  float fact = 0.;
156 
158 
159  if (section == 1 && !isEM) {
160  if (channel < 5)
161  if (((theXChannelBoundaries[channel - 1]) < (xin + X0)) && ((xin + X0) <= theXChannelBoundaries[channel]))
162  fact = 0.18;
163  if (channel == 5)
164  if (theXChannelBoundaries[channel - 1] < xin + X0)
165  fact = 0.18;
166  }
167 
168  if (section == 2 && !isEM) {
169  if (channel == 1)
170  fact = 0.34;
171  if (channel == 2)
172  fact = 0.24;
173  if (channel == 3)
174  fact = 0.17;
175  if (channel == 4)
176  fact = 0.07;
177  }
178  if (section == 1 && isEM) {
179  if (channel < 5)
180  if (((theXChannelBoundaries[channel - 1]) < (xin + X0)) && ((xin + X0) <= theXChannelBoundaries[channel]))
181  fact = 1.;
182  if (channel == 5)
183  if (theXChannelBoundaries[channel - 1] < xin + X0)
184  fact = 1.0;
185  }
186 
187  //change to cm for parametrization
188  yin = yin / cm;
189  xin = xin / cm;
190 
191  if (isEM) {
192  eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
193  1.0028) *
194  (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 * pow((energy / 300.0), 0.99); // EM
195  esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
196  (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 30.0 * pow((energy / 300.0), 0.54); // EM
197  edis = 1.0;
198  } else {
199  eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
200  1.0028) *
201  (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 * pow((energy / 300.0), 1.12); // HD
202  esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
203  (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 54.0 * pow((energy / 300.0), 0.93); //HD
204  edis = 3.0;
205  }
206 
207  if (eav < 0. || esig < 0.) {
208  edm::LogVerbatim("ZdcShower") << " Negative everage energy or esigma from parametrization \n"
209  << " xin: " << xin << "(cm)"
210  << " yin: " << yin << "(cm)"
211  << " track en: " << energy << "(GeV)"
212  << " eaverage: " << eav << " (GeV)"
213  << " esigma: " << esig << " (GeV)"
214  << " edist: " << edis << " (GeV)";
215  return 0;
216  }
217 
218  // Convert from GeV to MeV for the code
219  eav = eav * GeV;
220  esig = esig * GeV;
221 
222  while (nphotons == -1 || nphotons > int(eav + 5. * esig))
223  nphotons = (int)(fact * photonFluctuation(eav, esig, edis));
224 
225  edm::LogVerbatim("ZdcShower") << " track en: " << energy << "(GeV)"
226  << " eaverage: " << eav / GeV << " (GeV)"
227  << " esigma: " << esig / GeV << " (GeV)"
228  << " edist: " << edis << " (GeV)"
229  << " dE hit: " << nphotons / GeV << " (GeV)";
230 
231  return nphotons;
232 }
Log< level::Info, true > LogVerbatim
static const double theXChannelBoundaries[]
int photonFluctuation(double eav, double esig, double edis)
const double fact
static bool isGammaElectronPositron(int pdgCode)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ getHits()

std::vector< ZdcShowerLibrary::Hit > & ZdcShowerLibrary::getHits ( const G4Step *  aStep,
bool &  ok 
)

Definition at line 30 of file ZdcShowerLibrary.cc.

References funct::abs(), ZdcShowerLibrary::Hit::DeEM, ZdcShowerLibrary::Hit::DeHad, ZdcShowerLibrary::Hit::depth, LEDCalibrationChannels::depth, ZdcShowerLibrary::Hit::detID, HcalZDCDetId::EM, HCALHighEnergyHPDFilter_cfi::energy, ZdcShowerLibrary::Hit::entryLocal, getEnergyFromLibrary(), HcalZDCDetId::HAD, hits, mps_fire::i, G4TrackToParticleID::isGammaElectronPositron(), G4TrackToParticleID::isStableHadronIon(), npe, convertSQLiteXML::ok, ZdcShowerLibrary::Hit::position, hgcalPlots::section, theXChannelBoundaries, theZHadChannelBoundaries, theZSectionBoundaries, ZdcShowerLibrary::Hit::time, HLT_2022v15_cff::track, funct::true, ecalPiZeroTask_cfi::X0, geometryCSVtoXML::xx, Y0, geometryCSVtoXML::yy, Z0, and geometryCSVtoXML::zz.

30  {
31  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
32  const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
33  const G4Track* track = aStep->GetTrack();
34 
35  const G4DynamicParticle* aParticle = track->GetDynamicParticle();
36  const G4ThreeVector& momDir = aParticle->GetMomentumDirection();
37  double energy = preStepPoint->GetKineticEnergy();
38  G4ThreeVector hitPoint = preStepPoint->GetPosition();
39  const G4ThreeVector& hitPointOrig = preStepPoint->GetPosition();
40  G4int parCode = track->GetDefinition()->GetPDGEncoding();
41 
42  hits.clear();
43 
44  ok = false;
47  if (!isEM && !isHad)
48  return hits;
49  ok = true;
50 
51  G4ThreeVector pos;
52  G4ThreeVector posLocal;
53  double tSlice = (postStepPoint->GetGlobalTime()) / nanosecond;
54 
55  int nHit = 0;
57  bool side = false;
58  int channel = 0;
59  double xx, yy, zz;
60  double xxlocal, yylocal, zzlocal;
61 
62  ZdcShowerLibrary::Hit oneHit;
63  side = (hitPointOrig.z() > 0.) ? true : false;
64 
65  float xWidthEM = std::abs(theXChannelBoundaries[0] - theXChannelBoundaries[1]);
66  float zWidthEM = std::abs(theZSectionBoundaries[0] - theZSectionBoundaries[1]);
68 
69  for (int i = 0; i < npe; i++) {
70  if (i < 5) {
72  channel = i + 1;
73  xxlocal = theXChannelBoundaries[i] + (xWidthEM / 2.);
74  xx = xxlocal + X0;
75  yy = 0.0;
76  yylocal = yy + Y0;
77  zzlocal = theZSectionBoundaries[0] + (zWidthEM / 2.);
78  zz = (hitPointOrig.z() > 0.) ? zzlocal + Z0 : zzlocal - Z0;
79  pos = G4ThreeVector(xx, yy, zz);
80  posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
81  }
82  if (i > 4) {
84  channel = i - 4;
85  xxlocal = 0.0;
86  xx = xxlocal + X0;
87  yylocal = 0;
88  yy = yylocal + Y0;
89  zzlocal = (hitPointOrig.z() > 0.) ? theZHadChannelBoundaries[i - 5] + (zWidthHAD / 2.)
90  : theZHadChannelBoundaries[i - 5] - (zWidthHAD / 2.);
91  zz = (hitPointOrig.z() > 0.) ? zzlocal + Z0 : zzlocal - Z0;
92  pos = G4ThreeVector(xx, yy, zz);
93  posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
94  }
95 
96  oneHit.position = pos;
97  oneHit.entryLocal = posLocal;
98  oneHit.depth = channel;
99  oneHit.time = tSlice;
100  oneHit.detID = HcalZDCDetId(section, side, channel);
101 
102  // Note: coodinates of hit are relative to center of detector (X0,Y0,Z0)
103  hitPoint.setX(hitPointOrig.x() - X0);
104  hitPoint.setY(hitPointOrig.y() - Y0);
105  double setZ = (hitPointOrig.z() > 0.) ? hitPointOrig.z() - Z0 : fabs(hitPointOrig.z()) - Z0;
106  hitPoint.setZ(setZ);
107 
108  int dE = getEnergyFromLibrary(hitPoint, momDir, energy, parCode, section, side, channel);
109 
110  if (isEM) {
111  oneHit.DeEM = dE;
112  oneHit.DeHad = 0.;
113  } else {
114  oneHit.DeEM = 0;
115  oneHit.DeHad = dE;
116  }
117 
118  hits.push_back(oneHit);
119 
120  edm::LogVerbatim("ZdcShower") << "\nZdcShowerLibrary:Generated Hit " << nHit << " orig hit pos " << hitPointOrig
121  << " orig hit pos local coord" << hitPoint << " new position "
122  << (hits[nHit].position) << " Channel " << (hits[nHit].depth) << " side " << side
123  << " Time " << (hits[nHit].time) << " DetectorID " << (hits[nHit].detID)
124  << " Had Energy " << (hits[nHit].DeHad) << " EM Energy " << (hits[nHit].DeEM)
125  << "\n";
126  nHit++;
127  }
128  return hits;
129 }
Log< level::Info, true > LogVerbatim
G4ThreeVector entryLocal
static const double theXChannelBoundaries[]
int getEnergyFromLibrary(const G4ThreeVector &posHit, const G4ThreeVector &momDir, double energy, G4int parCode, HcalZDCDetId::Section section, bool side, int channel)
static const double theZHadChannelBoundaries[]
std::vector< ZdcShowerLibrary::Hit > hits
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isStableHadronIon(const G4Track *)
static const double Z0
static bool isGammaElectronPositron(int pdgCode)
static const double Y0
static const double theZSectionBoundaries[]

◆ photonFluctuation()

int ZdcShowerLibrary::photonFluctuation ( double  eav,
double  esig,
double  edis 
)

Definition at line 234 of file ZdcShowerLibrary.cc.

References createfilelist::int.

Referenced by getEnergyFromLibrary().

234  {
235  int nphot = 0;
236  double efluct = 0.;
237  if (edis == 1.0)
238  efluct = eav + esig * CLHEP::RandGaussQ::shoot();
239  if (edis == 3.0)
240  efluct = eav + esig * CLHEP::RandLandau::shoot();
241  nphot = int(efluct);
242  if (nphot < 0)
243  nphot = 0;
244  return nphot;
245 }

Member Data Documentation

◆ hits

std::vector<ZdcShowerLibrary::Hit> ZdcShowerLibrary::hits
private

Definition at line 53 of file ZdcShowerLibrary.h.

Referenced by getHits(), and ZdcShowerLibrary().

◆ npe

int ZdcShowerLibrary::npe
private

Definition at line 52 of file ZdcShowerLibrary.h.

Referenced by getHits(), and ZdcShowerLibrary().

◆ verbose

bool ZdcShowerLibrary::verbose
private

Definition at line 50 of file ZdcShowerLibrary.h.

Referenced by ZdcShowerLibrary().