CMS 3D CMS Logo

ZdcShowerLibrary.cc
Go to the documentation of this file.
1 // File: ZdcShowerLibrary.cc
3 // Description: Shower library for the Zero Degree Calorimeter
4 // E. Garcia June 2008
6 
12 
13 #include "G4VPhysicalVolume.hh"
14 #include "G4Step.hh"
15 #include "G4Track.hh"
16 #include "Randomize.hh"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
20  edm::ParameterSet m_HS = p.getParameter<edm::ParameterSet>("ZdcShowerLibrary");
21  verbose = m_HS.getUntrackedParameter<int>("Verbosity", 0);
22 
23  npe = 9; // number of channels or fibers where the energy will be deposited
24  hits.reserve(npe);
25 }
26 
28 
29 std::vector<ZdcShowerLibrary::Hit>& ZdcShowerLibrary::getHits(const G4Step* aStep, bool& ok) {
30  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
31  const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
32  const G4Track* track = aStep->GetTrack();
33 
34  const G4DynamicParticle* aParticle = track->GetDynamicParticle();
35  const G4ThreeVector& momDir = aParticle->GetMomentumDirection();
36  double energy = preStepPoint->GetKineticEnergy();
37  G4ThreeVector hitPoint = preStepPoint->GetPosition();
38  const G4ThreeVector& hitPointOrig = preStepPoint->GetPosition();
39  G4int parCode = track->GetDefinition()->GetPDGEncoding();
40 
41  hits.clear();
42 
43  ok = false;
46  if (!isEM && !isHad)
47  return hits;
48  ok = true;
49 
50  G4ThreeVector pos;
51  G4ThreeVector posLocal;
52  double tSlice = (postStepPoint->GetGlobalTime()) / nanosecond;
53 
54  int nHit = 0;
56  bool side = false;
57  int channel = 0;
58  double xx, yy, zz;
59  double xxlocal, yylocal, zzlocal;
60 
61  ZdcShowerLibrary::Hit oneHit;
62  side = (hitPointOrig.z() > 0.) ? true : false;
63 
64  float xWidthEM = std::abs(theXChannelBoundaries[0] - theXChannelBoundaries[1]);
65  float zWidthEM = std::abs(theZSectionBoundaries[0] - theZSectionBoundaries[1]);
67 
68  for (int i = 0; i < npe; i++) {
69  if (i < 5) {
71  channel = i + 1;
72  xxlocal = theXChannelBoundaries[i] + (xWidthEM / 2.);
73  xx = xxlocal + X0;
74  yy = 0.0;
75  yylocal = yy + Y0;
76  zzlocal = theZSectionBoundaries[0] + (zWidthEM / 2.);
77  zz = (hitPointOrig.z() > 0.) ? zzlocal + Z0 : zzlocal - Z0;
78  pos = G4ThreeVector(xx, yy, zz);
79  posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
80  }
81  if (i > 4) {
83  channel = i - 4;
84  xxlocal = 0.0;
85  xx = xxlocal + X0;
86  yylocal = 0;
87  yy = yylocal + Y0;
88  zzlocal = (hitPointOrig.z() > 0.) ? theZHadChannelBoundaries[i - 5] + (zWidthHAD / 2.)
89  : theZHadChannelBoundaries[i - 5] - (zWidthHAD / 2.);
90  zz = (hitPointOrig.z() > 0.) ? zzlocal + Z0 : zzlocal - Z0;
91  pos = G4ThreeVector(xx, yy, zz);
92  posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
93  }
94 
95  oneHit.position = pos;
96  oneHit.entryLocal = posLocal;
97  oneHit.depth = channel;
98  oneHit.time = tSlice;
99  oneHit.detID = HcalZDCDetId(section, side, channel);
100 
101  // Note: coodinates of hit are relative to center of detector (X0,Y0,Z0)
102  hitPoint.setX(hitPointOrig.x() - X0);
103  hitPoint.setY(hitPointOrig.y() - Y0);
104  double setZ = (hitPointOrig.z() > 0.) ? hitPointOrig.z() - Z0 : fabs(hitPointOrig.z()) - Z0;
105  hitPoint.setZ(setZ);
106 
107  int dE = getEnergyFromLibrary(hitPoint, momDir, energy, parCode, section, side, channel);
108 
109  if (isEM) {
110  oneHit.DeEM = dE;
111  oneHit.DeHad = 0.;
112  } else {
113  oneHit.DeEM = 0;
114  oneHit.DeHad = dE;
115  }
116 
117  hits.push_back(oneHit);
118 
119  LogDebug("ZdcShower") << "\nZdcShowerLibrary:Generated Hit " << nHit << " orig hit pos " << hitPointOrig
120  << " orig hit pos local coord" << hitPoint << " new position " << (hits[nHit].position)
121  << " Channel " << (hits[nHit].depth) << " side " << side << " Time " << (hits[nHit].time)
122  << " DetectorID " << (hits[nHit].detID) << " Had Energy " << (hits[nHit].DeHad)
123  << " EM Energy " << (hits[nHit].DeEM) << "\n";
124  nHit++;
125  }
126  return hits;
127 }
128 
129 int ZdcShowerLibrary::getEnergyFromLibrary(const G4ThreeVector& hitPoint,
130  const G4ThreeVector& momDir,
131  double energy,
132  G4int parCode,
134  bool side,
135  int channel) {
136  int nphotons = -1;
137 
138  energy = energy / GeV;
139 
140  LogDebug("ZdcShower") << "\n ZdcShowerLibrary::getEnergyFromLibrary input/output variables:"
141  << " phi: " << 59.2956 * momDir.phi() << " theta: " << 59.2956 * momDir.theta()
142  << " xin : " << hitPoint.x() << " yin : " << hitPoint.y() << " zin : " << hitPoint.z()
143  << " track en: " << energy << "(GeV)"
144  << " section: " << section << " side: " << side << " channel: " << channel
145  << " partID: " << parCode;
146 
147  double eav = 0.;
148  double esig = 0.;
149  double edis = 0.;
150 
151  float xin = hitPoint.x();
152  float yin = hitPoint.y();
153  float fact = 0.;
154 
156 
157  if (section == 1 && !isEM) {
158  if (channel < 5)
159  if (((theXChannelBoundaries[channel - 1]) < (xin + X0)) && ((xin + X0) <= theXChannelBoundaries[channel]))
160  fact = 0.18;
161  if (channel == 5)
162  if (theXChannelBoundaries[channel - 1] < xin + X0)
163  fact = 0.18;
164  }
165 
166  if (section == 2 && !isEM) {
167  if (channel == 1)
168  fact = 0.34;
169  if (channel == 2)
170  fact = 0.24;
171  if (channel == 3)
172  fact = 0.17;
173  if (channel == 4)
174  fact = 0.07;
175  }
176  if (section == 1 && isEM) {
177  if (channel < 5)
178  if (((theXChannelBoundaries[channel - 1]) < (xin + X0)) && ((xin + X0) <= theXChannelBoundaries[channel]))
179  fact = 1.;
180  if (channel == 5)
181  if (theXChannelBoundaries[channel - 1] < xin + X0)
182  fact = 1.0;
183  }
184 
185  //change to cm for parametrization
186  yin = yin / cm;
187  xin = xin / cm;
188 
189  if (isEM) {
190  eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
191  1.0028) *
192  (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 * pow((energy / 300.0), 0.99); // EM
193  esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
194  (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 30.0 * pow((energy / 300.0), 0.54); // EM
195  edis = 1.0;
196  } else {
197  eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
198  1.0028) *
199  (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 * pow((energy / 300.0), 1.12); // HD
200  esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
201  (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 54.0 * pow((energy / 300.0), 0.93); //HD
202  edis = 3.0;
203  }
204 
205  if (eav < 0. || esig < 0.) {
206  LogDebug("ZdcShower") << " Negative everage energy or esigma from parametrization \n"
207  << " xin: " << xin << "(cm)"
208  << " yin: " << yin << "(cm)"
209  << " track en: " << energy << "(GeV)"
210  << " eaverage: " << eav << " (GeV)"
211  << " esigma: " << esig << " (GeV)"
212  << " edist: " << edis << " (GeV)";
213  return 0;
214  }
215 
216  // Convert from GeV to MeV for the code
217  eav = eav * GeV;
218  esig = esig * GeV;
219 
220  while (nphotons == -1 || nphotons > int(eav + 5. * esig))
221  nphotons = (int)(fact * photonFluctuation(eav, esig, edis));
222 
223  LogDebug("ZdcShower")
224  //std::cout
225  << " 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 }
233 
234 int ZdcShowerLibrary::photonFluctuation(double eav, double esig, double edis) {
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 }
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
HcalZDCDetId::HAD
Definition: HcalZDCDetId.h:23
HcalZDCDetId::Section
Section
Definition: HcalZDCDetId.h:23
ZdcShowerLibrary::hits
std::vector< ZdcShowerLibrary::Hit > hits
Definition: ZdcShowerLibrary.h:53
RandomNumberGenerator.h
ZdcShowerLibrary::Hit::DeHad
double DeHad
Definition: ZdcShowerLibrary.h:35
pos
Definition: PixelAliasList.h:18
ZdcShowerLibrary::verbose
bool verbose
Definition: ZdcShowerLibrary.h:50
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ZdcShowerLibrary::npe
int npe
Definition: ZdcShowerLibrary.h:52
ZdcShowerLibrary::getHits
std::vector< Hit > & getHits(const G4Step *aStep, bool &ok)
Definition: ZdcShowerLibrary.cc:29
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
G4TrackToParticleID::isGammaElectronPositron
static bool isGammaElectronPositron(int pdgCode)
Definition: G4TrackToParticleID.cc:17
ZdcShowerLibrary::~ZdcShowerLibrary
~ZdcShowerLibrary()
Definition: ZdcShowerLibrary.cc:27
HMesonGammaMonitor_cff.nphotons
nphotons
Definition: HMesonGammaMonitor_cff.py:12
HcalZDCDetId
Definition: HcalZDCDetId.h:16
Service.h
ZdcShowerLibrary.h
theXChannelBoundaries
static const double theXChannelBoundaries[]
Definition: CastorGeometryData.h:41
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
theZSectionBoundaries
static const double theZSectionBoundaries[]
Definition: CastorGeometryData.h:40
theZHadChannelBoundaries
static const double theZHadChannelBoundaries[]
Definition: CastorGeometryData.h:42
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
ZdcShowerLibrary::Hit::depth
int depth
Definition: ZdcShowerLibrary.h:32
funct::true
true
Definition: Factorize.h:173
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ZdcShowerLibrary::Hit::detID
int detID
Definition: ZdcShowerLibrary.h:34
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
ZdcShowerLibrary::Hit
Definition: ZdcShowerLibrary.h:28
GeV
const double GeV
Definition: MathUtil.h:16
fact
const double fact
Definition: NuclearInteractionFTFSimulator.cc:74
createfilelist.int
int
Definition: createfilelist.py:10
MonitorAlCaEcalPi0_cfi.X0
X0
Definition: MonitorAlCaEcalPi0_cfi.py:77
ZdcShowerLibrary::Hit::DeEM
double DeEM
Definition: ZdcShowerLibrary.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Y0
static const double Y0
Definition: CastorGeometryData.h:33
G4TrackToParticleID.h
G4TrackToParticleID::isStableHadronIon
static bool isStableHadronIon(const G4Track *)
Definition: G4TrackToParticleID.cc:40
hgcalPlots.section
section
Definition: hgcalPlots.py:2679
ZdcShowerLibrary::Hit::time
double time
Definition: ZdcShowerLibrary.h:33
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ZdcShowerLibrary::Hit::position
G4ThreeVector position
Definition: ZdcShowerLibrary.h:31
ZdcShowerLibrary::ZdcShowerLibrary
ZdcShowerLibrary(const std::string &name, edm::ParameterSet const &p)
Definition: ZdcShowerLibrary.cc:19
HcalZDCDetId::EM
Definition: HcalZDCDetId.h:23
ZdcShowerLibrary::getEnergyFromLibrary
int getEnergyFromLibrary(const G4ThreeVector &posHit, const G4ThreeVector &momDir, double energy, G4int parCode, HcalZDCDetId::Section section, bool side, int channel)
Definition: ZdcShowerLibrary.cc:129
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
Z0
static const double Z0
Definition: CastorGeometryData.h:32
ZdcShowerLibrary::photonFluctuation
int photonFluctuation(double eav, double esig, double edis)
Definition: ZdcShowerLibrary.cc:234
ZdcShowerLibrary::Hit::entryLocal
G4ThreeVector entryLocal
Definition: ZdcShowerLibrary.h:30