CMS 3D CMS Logo

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

#include <HFShowerLibrary.h>

Classes

struct  Hit
 

Public Member Functions

std::vector< HitfillHits (const G4ThreeVector &p, const G4ThreeVector &v, int parCode, double parEnergy, bool &ok, double weight, double time, bool onlyLong=false)
 
std::vector< HitgetHits (const G4Step *aStep, bool &ok, double weight, bool onlyLong=false)
 
 HFShowerLibrary (const std::string &name, const HcalDDDSimConstants *hcons, const HcalSimulationParameters *hps, edm::ParameterSet const &p)
 
 ~HFShowerLibrary ()
 

Protected Member Functions

void extrapolate (int, double)
 
void getRecord (int, int)
 
void interpolate (int, double)
 
void loadEventInfo (TBranch *)
 
bool rInside (double r)
 
void storePhoton (int j)
 

Private Attributes

bool applyFidCut
 
double backProb
 
double dphi
 
TBranch * emBranch
 
int evtPerBin
 
std::unique_ptr< HFFibrefibre_
 
std::vector< double > gpar
 
TBranch * hadBranch
 
const HcalDDDSimConstantshcalConstant_
 
TFile * hf
 
float libVers
 
float listVersion
 
bool newForm
 
int nMomBin
 
int npe
 
HFShowerPhotonCollection pe
 
HFShowerPhotonCollectionphoto
 
HFShowerPhotonCollection photon
 
std::vector< double > pmom
 
double probMax
 
double rMax
 
double rMin
 
int totEvents
 
bool v3version
 
bool verbose
 

Detailed Description

Definition at line 28 of file HFShowerLibrary.h.

Constructor & Destructor Documentation

◆ HFShowerLibrary()

HFShowerLibrary::HFShowerLibrary ( const std::string &  name,
const HcalDDDSimConstants hcons,
const HcalSimulationParameters hps,
edm::ParameterSet const &  p 
)

Definition at line 23 of file HFShowerLibrary.cc.

27  : hcalConstant_(hcons), hf(nullptr), emBranch(nullptr), hadBranch(nullptr), npe(0) {
28  edm::ParameterSet m_HF =
29  (p.getParameter<edm::ParameterSet>("HFShower")).getParameter<edm::ParameterSet>("HFShowerBlock");
30  probMax = m_HF.getParameter<double>("ProbMax");
31 
32  edm::ParameterSet m_HS =
33  (p.getParameter<edm::ParameterSet>("HFShowerLibrary")).getParameter<edm::ParameterSet>("HFLibraryFileBlock");
34  edm::FileInPath fp = m_HS.getParameter<edm::FileInPath>("FileName");
35  std::string pTreeName = fp.fullPath();
36  backProb = m_HS.getParameter<double>("BackProbability");
37  std::string emName = m_HS.getParameter<std::string>("TreeEMID");
38  std::string hadName = m_HS.getParameter<std::string>("TreeHadID");
39  std::string branchEvInfo = m_HS.getUntrackedParameter<std::string>(
40  "BranchEvt", "HFShowerLibraryEventInfos_hfshowerlib_HFShowerLibraryEventInfo");
41  std::string branchPre = m_HS.getUntrackedParameter<std::string>("BranchPre", "HFShowerPhotons_hfshowerlib_");
42  std::string branchPost = m_HS.getUntrackedParameter<std::string>("BranchPost", "_R.obj");
43  verbose = m_HS.getUntrackedParameter<bool>("Verbosity", false);
44  applyFidCut = m_HS.getParameter<bool>("ApplyFiducialCut");
45 
46  if (pTreeName.find('.') == 0)
47  pTreeName.erase(0, 2);
48  const char* nTree = pTreeName.c_str();
49  hf = TFile::Open(nTree);
50 
51  if (!hf->IsOpen()) {
52  edm::LogError("HFShower") << "HFShowerLibrary: opening " << nTree << " failed";
53  throw cms::Exception("Unknown", "HFShowerLibrary") << "Opening of " << pTreeName << " fails\n";
54  } else {
55  edm::LogVerbatim("HFShower") << "HFShowerLibrary: opening " << nTree << " successfully";
56  }
57 
58  newForm = (branchEvInfo.empty());
59  TTree* event(nullptr);
60  if (newForm)
61  event = (TTree*)hf->Get("HFSimHits");
62  else
63  event = (TTree*)hf->Get("Events");
64  if (event) {
65  TBranch* evtInfo(nullptr);
66  if (!newForm) {
67  std::string info = branchEvInfo + branchPost;
68  evtInfo = event->GetBranch(info.c_str());
69  }
70  if (evtInfo || newForm) {
71  loadEventInfo(evtInfo);
72  } else {
73  edm::LogError("HFShower") << "HFShowerLibrary: HFShowerLibrayEventInfo"
74  << " Branch does not exist in Event";
75  throw cms::Exception("Unknown", "HFShowerLibrary") << "Event information absent\n";
76  }
77  } else {
78  edm::LogError("HFShower") << "HFShowerLibrary: Events Tree does not "
79  << "exist";
80  throw cms::Exception("Unknown", "HFShowerLibrary") << "Events tree absent\n";
81  }
82 
83 #ifdef EDM_ML_DEBUG
84  std::stringstream ss;
85  ss << "HFShowerLibrary: Library " << libVers << " ListVersion " << listVersion << " Events Total " << totEvents
86  << " and " << evtPerBin << " per bin\n";
87  ss << "HFShowerLibrary: Energies (GeV) with " << nMomBin << " bins\n";
88  for (int i = 0; i < nMomBin; ++i) {
89  if (i / 10 * 10 == i && i > 0) {
90  ss << "\n";
91  }
92  ss << " " << pmom[i] / CLHEP::GeV;
93  }
94  edm::LogVerbatim("HFShower") << ss.str();
95 #endif
96  std::string nameBr = branchPre + emName + branchPost;
97  emBranch = event->GetBranch(nameBr.c_str());
98  if (verbose)
99  emBranch->Print();
100  nameBr = branchPre + hadName + branchPost;
101  hadBranch = event->GetBranch(nameBr.c_str());
102  if (verbose)
103  hadBranch->Print();
104 
105  v3version = false;
106  if (emBranch->GetClassName() == std::string("vector<float>")) {
107  v3version = true;
108  }
109 
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("HFShower") << " HFShowerLibrary:Branch " << emName << " has " << emBranch->GetEntries()
112  << " entries and Branch " << hadName << " has " << hadBranch->GetEntries() << " entries"
113  << "\n HFShowerLibrary::No packing information -"
114  << " Assume x, y, z are not in packed form"
115  << "\n Maximum probability cut off " << probMax << " Back propagation of light prob. "
116  << backProb;
117 #endif
118  fibre_ = std::make_unique<HFFibre>(name, hcalConstant_, hps, p);
120 
121  //Radius (minimum and maximum)
122  std::vector<double> rTable = hcalConstant_->getRTableHF();
123  rMin = rTable[0];
124  rMax = rTable[rTable.size() - 1];
125 
126  //Delta phi
127  std::vector<double> phibin = hcalConstant_->getPhiTableHF();
128  dphi = phibin[0];
129 #ifdef EDM_ML_DEBUG
130  edm::LogVerbatim("HFShower") << "HFShowerLibrary: rMIN " << rMin / CLHEP::cm << " cm and rMax " << rMax / CLHEP::cm
131  << " (Half) Phi Width of wedge " << dphi / CLHEP::deg;
132 #endif
133  //Special Geometry parameters
135 }

References applyFidCut, backProb, dphi, emBranch, edmPickEvents::event, evtPerBin, Exception, fibre_, personalPlayback::fp, HcalDDDSimConstants::getGparHF(), edm::ParameterSet::getParameter(), HcalDDDSimConstants::getPhiTableHF(), HcalDDDSimConstants::getRTableHF(), GeV, gpar, hadBranch, hcalConstant_, hf, mps_fire::i, info(), libVers, listVersion, loadEventInfo(), Skims_PA_cff::name, newForm, nMomBin, AlCaHLTBitMon_ParallelJobs::p, photo, pmom, probMax, rMax, rMin, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, totEvents, v3version, and verbose.

◆ ~HFShowerLibrary()

HFShowerLibrary::~HFShowerLibrary ( )

Definition at line 137 of file HFShowerLibrary.cc.

137  {
138  if (hf)
139  hf->Close();
140  delete photo;
141 }

References hf, and photo.

Member Function Documentation

◆ extrapolate()

void HFShowerLibrary::extrapolate ( int  type,
double  pin 
)
protected

Definition at line 513 of file HFShowerLibrary.cc.

513  {
514  int nrec = int(pin / pmom[nMomBin - 1]);
515  double w = (pin - pmom[nMomBin - 1] * nrec) / pmom[nMomBin - 1];
516  nrec++;
517 #ifdef EDM_ML_DEBUG
518  edm::LogVerbatim("HFShower") << "HFShowerLibrary:: Extrapolate for Energy " << pin << " GeV with " << nMomBin
519  << " momentum bins and " << evtPerBin << " entries/bin -- "
520  << "total " << totEvents << " using " << nrec << " records";
521 #endif
522  std::vector<int> irc(nrec);
523 
524  for (int ir = 0; ir < nrec; ir++) {
525  double r = G4UniformRand();
526  irc[ir] = int(evtPerBin * 0.5 * r) + (nMomBin - 1) * evtPerBin + 1;
527  if (irc[ir] < 1) {
528  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir << "] = " << irc[ir] << " now set to 1";
529  irc[ir] = 1;
530  } else if (irc[ir] > totEvents) {
531  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir << "] = " << irc[ir] << " now set to "
532  << totEvents;
533  irc[ir] = totEvents;
534 #ifdef EDM_ML_DEBUG
535  } else {
536  edm::LogVerbatim("HFShower") << "HFShowerLibrary::Extrapolation use irc[" << ir << "] = " << irc[ir];
537 #endif
538  }
539  }
540 
541  pe.clear();
542  npe = 0;
543  int npold = 0;
544  for (int ir = 0; ir < nrec; ir++) {
545  if (irc[ir] > 0) {
546  getRecord(type, irc[ir]);
547  int nPhoton = (newForm) ? photo->size() : photon.size();
548  npold += nPhoton;
549  for (int j = 0; j < nPhoton; j++) {
550  double r = G4UniformRand();
551  if (ir != nrec - 1 || r < w) {
552  storePhoton(j);
553  }
554  }
555 #ifdef EDM_ML_DEBUG
556  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Record [" << ir << "] = " << irc[ir] << " npold = " << npold;
557 #endif
558  }
559  }
560 #ifdef EDM_ML_DEBUG
561  edm::LogVerbatim("HFShower") << "HFShowerLibrary:: uses " << npold << " photons";
562 #endif
563 
564  if (npe > npold || npold == 0)
565  edm::LogWarning("HFShower") << "HFShowerLibrary: Extrapolation Warning == " << nrec << " records " << irc[0] << ", "
566  << irc[1] << ", ... gives a buffer of " << npold << " photons and fills " << npe
567  << " *****";
568 #ifdef EDM_ML_DEBUG
569  else
570  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Extrapolation == " << nrec << " records " << irc[0] << ", "
571  << irc[1] << ", ... gives a buffer of " << npold << " photons and fills " << npe
572  << " PE";
573  for (int j = 0; j < npe; j++)
574  edm::LogVerbatim("HFShower") << "Photon " << j << " " << pe[j];
575 #endif
576 }

References evtPerBin, getRecord(), createfilelist::int, dqmiolumiharvest::j, newForm, nMomBin, npe, pe, photo, photon, pmom, alignCSCRings::r, storePhoton(), totEvents, and w.

Referenced by fillHits().

◆ fillHits()

std::vector< HFShowerLibrary::Hit > HFShowerLibrary::fillHits ( const G4ThreeVector &  p,
const G4ThreeVector &  v,
int  parCode,
double  parEnergy,
bool &  ok,
double  weight,
double  time,
bool  onlyLong = false 
)

Definition at line 184 of file HFShowerLibrary.cc.

191  {
192  std::vector<HFShowerLibrary::Hit> hit;
193  ok = false;
195  // shower is built only for gamma, e+- and stable hadrons
196  if (!isEM && !G4TrackToParticleID::isStableHadron(parCode)) {
197  return hit;
198  }
199  ok = true;
200 
201  // remove low-energy component
202  const double threshold = 50 * MeV;
203  if (pin < threshold) {
204  return hit;
205  }
206 
207  double pz = momDir.z();
208  double zint = hitPoint.z();
209 
210  // if particle moves from interaction point or "backwards (halo)
211  bool backward = (pz * zint < 0.) ? true : false;
212 
213  double sphi = sin(momDir.phi());
214  double cphi = cos(momDir.phi());
215  double ctheta = cos(momDir.theta());
216  double stheta = sin(momDir.theta());
217 
218  if (isEM) {
219  if (pin < pmom[nMomBin - 1]) {
220  interpolate(0, pin);
221  } else {
222  extrapolate(0, pin);
223  }
224  } else {
225  if (pin < pmom[nMomBin - 1]) {
226  interpolate(1, pin);
227  } else {
228  extrapolate(1, pin);
229  }
230  }
231 
232  int nHit = 0;
233  HFShowerLibrary::Hit oneHit;
234  for (int i = 0; i < npe; ++i) {
235  double zv = std::abs(pe[i].z()); // abs local z
236 #ifdef EDM_ML_DEBUG
237  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Hit " << i << " " << pe[i] << " zv " << zv;
238 #endif
239  if (zv <= gpar[1] && pe[i].lambda() > 0 && (pe[i].z() >= 0 || (zv > gpar[0] && (!onlyLong)))) {
240  int depth = 1;
241  if (onlyLong) {
242  } else if (!backward) { // fully valid only for "front" particles
243  if (pe[i].z() < 0)
244  depth = 2; // with "front"-simulated shower lib.
245  } else { // for "backward" particles - almost equal
246  double r = G4UniformRand(); // share between L and S fibers
247  if (r > 0.5)
248  depth = 2;
249  }
250 
251  // Updated coordinate transformation from local
252  // back to global using two Euler angles: phi and theta
253  double pex = pe[i].x();
254  double pey = pe[i].y();
255 
256  double xx = pex * ctheta * cphi - pey * sphi + zv * stheta * cphi;
257  double yy = pex * ctheta * sphi + pey * cphi + zv * stheta * sphi;
258  double zz = -pex * stheta + zv * ctheta;
259 
260  G4ThreeVector pos = hitPoint + G4ThreeVector(xx, yy, zz);
261  zv = std::abs(pos.z()) - gpar[4] - 0.5 * gpar[1];
262  G4ThreeVector lpos = G4ThreeVector(pos.x(), pos.y(), zv);
263 
264  zv = fibre_->zShift(lpos, depth, 0); // distance to PMT !
265 
266  double r = pos.perp();
267  double p = fibre_->attLength(pe[i].lambda());
268  double fi = pos.phi();
269  if (fi < 0)
270  fi += CLHEP::twopi;
271  int isect = int(fi / dphi) + 1;
272  isect = (isect + 1) / 2;
273  double dfi = ((isect * 2 - 1) * dphi - fi);
274  if (dfi < 0)
275  dfi = -dfi;
276  double dfir = r * sin(dfi);
277 #ifdef EDM_ML_DEBUG
278  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Position shift " << xx << ", " << yy << ", " << zz << ": "
279  << pos << " R " << r << " Phi " << fi << " Section " << isect << " R*Dfi " << dfir
280  << " Dist " << zv;
281 #endif
282  zz = std::abs(pos.z());
283  double r1 = G4UniformRand();
284  double r2 = G4UniformRand();
285  double r3 = backward ? G4UniformRand() : -9999.;
286  if (!applyFidCut)
287  dfir += gpar[5];
288 
289 #ifdef EDM_ML_DEBUG
290  edm::LogVerbatim("HFShower") << "HFShowerLibrary: rLimits " << rInside(r) << " attenuation " << r1 << ":"
291  << exp(-p * zv) << " r2 " << r2 << " r3 " << r3 << " rDfi " << gpar[5] << " zz "
292  << zz << " zLim " << gpar[4] << ":" << gpar[4] + gpar[1] << "\n"
293  << " rInside(r) :" << rInside(r) << " r1 <= exp(-p*zv) :" << (r1 <= exp(-p * zv))
294  << " r2 <= probMax :" << (r2 <= probMax * weight)
295  << " r3 <= backProb :" << (r3 <= backProb)
296  << " dfir > gpar[5] :" << (dfir > gpar[5]) << " zz >= gpar[4] :" << (zz >= gpar[4])
297  << " zz <= gpar[4]+gpar[1] :" << (zz <= gpar[4] + gpar[1]);
298 #endif
299  if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax * weight && dfir > gpar[5] && zz >= gpar[4] &&
300  zz <= gpar[4] + gpar[1] && r3 <= backProb && (depth != 2 || zz >= gpar[4] + gpar[0])) {
301  oneHit.position = pos;
302  oneHit.depth = depth;
303  oneHit.time = (tSlice + (pe[i].t()) + (fibre_->tShift(lpos, depth, 1)));
304  hit.push_back(oneHit);
305 #ifdef EDM_ML_DEBUG
306  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit << " position " << (hit[nHit].position)
307  << " Depth " << (hit[nHit].depth) << " Time " << tSlice << ":" << pe[i].t() << ":"
308  << fibre_->tShift(lpos, depth, 1) << ":" << (hit[nHit].time);
309 #endif
310  ++nHit;
311  }
312 #ifdef EDM_ML_DEBUG
313  else
314  edm::LogVerbatim("HFShower") << "HFShowerLibrary: REJECTED !!!";
315 #endif
316  if (onlyLong && zz >= gpar[4] + gpar[0] && zz <= gpar[4] + gpar[1]) {
317  r1 = G4UniformRand();
318  r2 = G4UniformRand();
319  if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax && dfir > gpar[5]) {
320  oneHit.position = pos;
321  oneHit.depth = 2;
322  oneHit.time = (tSlice + (pe[i].t()) + (fibre_->tShift(lpos, 2, 1)));
323  hit.push_back(oneHit);
324 #ifdef EDM_ML_DEBUG
325  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit << " position " << (hit[nHit].position)
326  << " Depth " << (hit[nHit].depth) << " Time " << tSlice << ":" << pe[i].t()
327  << ":" << fibre_->tShift(lpos, 2, 1) << ":" << (hit[nHit].time);
328 #endif
329  ++nHit;
330  }
331  }
332  }
333  }
334 
335 #ifdef EDM_ML_DEBUG
336  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Total Hits " << nHit << " out of " << npe << " PE";
337 #endif
338  if (nHit > npe && !onlyLong) {
339  edm::LogWarning("HFShower") << "HFShowerLibrary: Hit buffer " << npe << " smaller than " << nHit << " Hits";
340  }
341  return hit;
342 }

References funct::abs(), applyFidCut, backProb, funct::cos(), HFShowerLibrary::Hit::depth, LEDCalibrationChannels::depth, dphi, JetChargeProducer_cfi::exp, extrapolate(), fibre_, gpar, mps_fire::i, createfilelist::int, interpolate(), G4TrackToParticleID::isGammaElectronPositron(), G4TrackToParticleID::isStableHadron(), MeV, nMomBin, npe, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, pe, pmom, HFShowerLibrary::Hit::position, probMax, alignCSCRings::r, diffTwoXMLs::r1, diffTwoXMLs::r2, rInside(), funct::sin(), remoteMonitoring_LED_IterMethod_cfg::threshold, HFShowerLibrary::Hit::time, funct::true, geometryCSVtoXML::xx, geometryCSVtoXML::yy, z, hit::z, gpuVertexFinder::zv, and geometryCSVtoXML::zz.

Referenced by getHits().

◆ getHits()

std::vector< HFShowerLibrary::Hit > HFShowerLibrary::getHits ( const G4Step *  aStep,
bool &  ok,
double  weight,
bool  onlyLong = false 
)

Definition at line 143 of file HFShowerLibrary.cc.

146  {
147  auto const preStepPoint = aStep->GetPreStepPoint();
148  auto const postStepPoint = aStep->GetPostStepPoint();
149  auto const track = aStep->GetTrack();
150  // Get Z-direction
151  auto const aParticle = track->GetDynamicParticle();
152  const G4ThreeVector& momDir = aParticle->GetMomentumDirection();
153  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
154  int parCode = track->GetDefinition()->GetPDGEncoding();
155 
156  // VI: for ions use internally pdg code of alpha in order to keep
157  // consistency with previous simulation
158  if (track->GetDefinition()->IsGeneralIon()) {
159  parCode = 1000020040;
160  }
161 
162 #ifdef EDM_ML_DEBUG
163  G4String partType = track->GetDefinition()->GetParticleName();
164  const G4ThreeVector localPos = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
165  double zoff = localPos.z() + 0.5 * gpar[1];
166 
167  edm::LogVerbatim("HFShower") << "HFShowerLibrary::getHits " << partType << " of energy "
168  << track->GetKineticEnergy() / GeV << " GeV weight= " << weight
169  << " onlyLong: " << onlyLong << " dir.orts " << momDir.x() << ", " << momDir.y() << ", "
170  << momDir.z() << " Pos x,y,z = " << hitPoint.x() << "," << hitPoint.y() << ","
171  << hitPoint.z() << " (" << zoff << ") sphi,cphi,stheta,ctheta = " << sin(momDir.phi())
172  << "," << cos(momDir.phi()) << ", " << sin(momDir.theta()) << "," << cos(momDir.theta());
173 #endif
174 
175  double tSlice = (postStepPoint->GetGlobalTime()) / CLHEP::nanosecond;
176 
177  // use kinetic energy for protons and ions
178  double pin = (track->GetDefinition()->GetBaryonNumber() > 0) ? preStepPoint->GetKineticEnergy()
179  : preStepPoint->GetTotalEnergy();
180 
181  return fillHits(hitPoint, momDir, parCode, pin, isKilled, weight, tSlice, onlyLong);
182 }

References funct::cos(), fillHits(), GeV, gpar, funct::sin(), and HLT_FULL_cff::track.

◆ getRecord()

void HFShowerLibrary::getRecord ( int  type,
int  record 
)
protected

Definition at line 346 of file HFShowerLibrary.cc.

346  {
347  int nrc = record - 1;
348  photon.clear();
349  photo->clear();
350  if (type > 0) {
351  if (newForm) {
352  if (!v3version) {
353  hadBranch->SetAddress(&photo);
354  hadBranch->GetEntry(nrc + totEvents);
355  } else {
356  std::vector<float> t;
357  std::vector<float>* tp = &t;
358  hadBranch->SetAddress(&tp);
359  hadBranch->GetEntry(nrc + totEvents);
360  unsigned int tSize = t.size() / 5;
361  photo->reserve(tSize);
362  for (unsigned int i = 0; i < tSize; i++) {
363  photo->push_back(
364  HFShowerPhoton(t[i], t[1 * tSize + i], t[2 * tSize + i], t[3 * tSize + i], t[4 * tSize + i]));
365  }
366  }
367  } else {
368  hadBranch->SetAddress(&photon);
369  hadBranch->GetEntry(nrc);
370  }
371  } else {
372  if (newForm) {
373  if (!v3version) {
374  emBranch->SetAddress(&photo);
375  emBranch->GetEntry(nrc);
376  } else {
377  std::vector<float> t;
378  std::vector<float>* tp = &t;
379  emBranch->SetAddress(&tp);
380  emBranch->GetEntry(nrc);
381  unsigned int tSize = t.size() / 5;
382  photo->reserve(tSize);
383  for (unsigned int i = 0; i < tSize; i++) {
384  photo->push_back(
385  HFShowerPhoton(t[i], t[1 * tSize + i], t[2 * tSize + i], t[3 * tSize + i], t[4 * tSize + i]));
386  }
387  }
388  } else {
389  emBranch->SetAddress(&photon);
390  emBranch->GetEntry(nrc);
391  }
392  }
393 #ifdef EDM_ML_DEBUG
394  int nPhoton = (newForm) ? photo->size() : photon.size();
395  edm::LogVerbatim("HFShower") << "HFShowerLibrary::getRecord: Record " << record << " of type " << type << " with "
396  << nPhoton << " photons";
397  for (int j = 0; j < nPhoton; j++)
398  if (newForm)
399  edm::LogVerbatim("HFShower") << "Photon " << j << " " << photo->at(j);
400  else
401  edm::LogVerbatim("HFShower") << "Photon " << j << " " << photon[j];
402 #endif
403 }

References emBranch, hadBranch, mps_fire::i, dqmiolumiharvest::j, newForm, photo, photon, GlobalPosition_Frontier_DevDB_cff::record, submitPVValidationJobs::t, totEvents, cmsswSequenceInfo::tp, and v3version.

Referenced by extrapolate(), and interpolate().

◆ interpolate()

void HFShowerLibrary::interpolate ( int  type,
double  pin 
)
protected

Definition at line 436 of file HFShowerLibrary.cc.

436  {
437 #ifdef EDM_ML_DEBUG
438  edm::LogVerbatim("HFShower") << "HFShowerLibrary:: Interpolate for Energy " << pin / GeV << " GeV with " << nMomBin
439  << " momentum bins and " << evtPerBin << " entries/bin -- total " << totEvents;
440 #endif
441  int irc[2] = {0, 0};
442  double w = 0.;
443  double r = G4UniformRand();
444 
445  if (pin < pmom[0]) {
446  w = pin / pmom[0];
447  irc[1] = int(evtPerBin * r) + 1;
448  irc[0] = 0;
449  } else {
450  for (int j = 0; j < nMomBin - 1; j++) {
451  if (pin >= pmom[j] && pin < pmom[j + 1]) {
452  w = (pin - pmom[j]) / (pmom[j + 1] - pmom[j]);
453  if (j == nMomBin - 2) {
454  irc[1] = int(evtPerBin * 0.5 * r);
455  } else {
456  irc[1] = int(evtPerBin * r);
457  }
458  irc[1] += (j + 1) * evtPerBin + 1;
459  r = G4UniformRand();
460  irc[0] = int(evtPerBin * r) + 1 + j * evtPerBin;
461  if (irc[0] < 0) {
462  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " << irc[0] << " now set to 0";
463  irc[0] = 0;
464  } else if (irc[0] > totEvents) {
465  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " << irc[0] << " now set to " << totEvents;
466  irc[0] = totEvents;
467  }
468  }
469  }
470  }
471  if (irc[1] < 1) {
472  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " << irc[1] << " now set to 1";
473  irc[1] = 1;
474  } else if (irc[1] > totEvents) {
475  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " << irc[1] << " now set to " << totEvents;
476  irc[1] = totEvents;
477  }
478 
479 #ifdef EDM_ML_DEBUG
480  edm::LogVerbatim("HFShower") << "HFShowerLibrary:: Select records " << irc[0] << " and " << irc[1] << " with weights "
481  << 1 - w << " and " << w;
482 #endif
483  pe.clear();
484  npe = 0;
485  int npold = 0;
486  for (int ir = 0; ir < 2; ir++) {
487  if (irc[ir] > 0) {
488  getRecord(type, irc[ir]);
489  int nPhoton = (newForm) ? photo->size() : photon.size();
490  npold += nPhoton;
491  for (int j = 0; j < nPhoton; j++) {
492  r = G4UniformRand();
493  if ((ir == 0 && r > w) || (ir > 0 && r < w)) {
494  storePhoton(j);
495  }
496  }
497  }
498  }
499 
500  if ((npe > npold || (npold == 0 && irc[0] > 0)) && !(npe == 0 && npold == 0))
501  edm::LogWarning("HFShower") << "HFShowerLibrary: Interpolation Warning =="
502  << " records " << irc[0] << " and " << irc[1] << " gives a buffer of " << npold
503  << " photons and fills " << npe << " *****";
504 #ifdef EDM_ML_DEBUG
505  else
506  edm::LogVerbatim("HFShower") << "HFShowerLibrary: Interpolation == records " << irc[0] << " and " << irc[1]
507  << " gives a buffer of " << npold << " photons and fills " << npe << " PE";
508  for (int j = 0; j < npe; j++)
509  edm::LogVerbatim("HFShower") << "Photon " << j << " " << pe[j];
510 #endif
511 }

References evtPerBin, getRecord(), GeV, createfilelist::int, dqmiolumiharvest::j, newForm, nMomBin, npe, pe, photo, photon, pmom, alignCSCRings::r, storePhoton(), totEvents, and w.

Referenced by fillHits().

◆ loadEventInfo()

void HFShowerLibrary::loadEventInfo ( TBranch *  branch)
protected

Definition at line 405 of file HFShowerLibrary.cc.

405  {
406  if (branch) {
407  std::vector<HFShowerLibraryEventInfo> eventInfoCollection;
408  branch->SetAddress(&eventInfoCollection);
409  branch->GetEntry(0);
410 #ifdef EDM_ML_DEBUG
411  edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads EventInfo Collection of size "
412  << eventInfoCollection.size() << " records";
413 #endif
414  totEvents = eventInfoCollection[0].totalEvents();
415  nMomBin = eventInfoCollection[0].numberOfBins();
416  evtPerBin = eventInfoCollection[0].eventsPerBin();
417  libVers = eventInfoCollection[0].showerLibraryVersion();
418  listVersion = eventInfoCollection[0].physListVersion();
419  pmom = eventInfoCollection[0].energyBins();
420  } else {
421 #ifdef EDM_ML_DEBUG
422  edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads EventInfo from hardwired"
423  << " numbers";
424 #endif
425  nMomBin = 16;
426  evtPerBin = 5000;
428  libVers = 1.1;
429  listVersion = 3.6;
430  pmom = {2, 3, 5, 7, 10, 15, 20, 30, 50, 75, 100, 150, 250, 350, 500, 1000};
431  }
432  for (int i = 0; i < nMomBin; i++)
433  pmom[i] *= GeV;
434 }

References MicroEventContent_cff::branch, evtPerBin, GeV, mps_fire::i, libVers, listVersion, nMomBin, pmom, and totEvents.

Referenced by HFShowerLibrary().

◆ rInside()

bool HFShowerLibrary::rInside ( double  r)
protected

Definition at line 344 of file HFShowerLibrary.cc.

344 { return (r >= rMin && r <= rMax); }

References alignCSCRings::r, rMax, and rMin.

Referenced by fillHits().

◆ storePhoton()

void HFShowerLibrary::storePhoton ( int  j)
protected

Definition at line 578 of file HFShowerLibrary.cc.

578  {
579  if (newForm)
580  pe.push_back(photo->at(j));
581  else
582  pe.push_back(photon[j]);
583 #ifdef EDM_ML_DEBUG
584  edm::LogVerbatim("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe " << npe << " " << pe[npe];
585 #endif
586  npe++;
587 }

References dqmiolumiharvest::j, newForm, npe, pe, photo, and photon.

Referenced by extrapolate(), and interpolate().

Member Data Documentation

◆ applyFidCut

bool HFShowerLibrary::applyFidCut
private

Definition at line 69 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

◆ backProb

double HFShowerLibrary::backProb
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

◆ dphi

double HFShowerLibrary::dphi
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

◆ emBranch

TBranch* HFShowerLibrary::emBranch
private

Definition at line 67 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

◆ evtPerBin

int HFShowerLibrary::evtPerBin
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by extrapolate(), HFShowerLibrary(), interpolate(), and loadEventInfo().

◆ fibre_

std::unique_ptr<HFFibre> HFShowerLibrary::fibre_
private

Definition at line 65 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

◆ gpar

std::vector<double> HFShowerLibrary::gpar
private

Definition at line 76 of file HFShowerLibrary.h.

Referenced by fillHits(), getHits(), and HFShowerLibrary().

◆ hadBranch

TBranch * HFShowerLibrary::hadBranch
private

Definition at line 67 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

◆ hcalConstant_

const HcalDDDSimConstants* HFShowerLibrary::hcalConstant_
private

Definition at line 64 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary().

◆ hf

TFile* HFShowerLibrary::hf
private

Definition at line 66 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and ~HFShowerLibrary().

◆ libVers

float HFShowerLibrary::libVers
private

Definition at line 71 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

◆ listVersion

float HFShowerLibrary::listVersion
private

Definition at line 71 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

◆ newForm

bool HFShowerLibrary::newForm
private

Definition at line 69 of file HFShowerLibrary.h.

Referenced by extrapolate(), getRecord(), HFShowerLibrary(), interpolate(), and storePhoton().

◆ nMomBin

int HFShowerLibrary::nMomBin
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by extrapolate(), fillHits(), HFShowerLibrary(), interpolate(), and loadEventInfo().

◆ npe

int HFShowerLibrary::npe
private

Definition at line 78 of file HFShowerLibrary.h.

Referenced by extrapolate(), fillHits(), interpolate(), and storePhoton().

◆ pe

HFShowerPhotonCollection HFShowerLibrary::pe
private

Definition at line 79 of file HFShowerLibrary.h.

Referenced by extrapolate(), fillHits(), interpolate(), and storePhoton().

◆ photo

HFShowerPhotonCollection* HFShowerLibrary::photo
private

◆ photon

HFShowerPhotonCollection HFShowerLibrary::photon
private

Definition at line 81 of file HFShowerLibrary.h.

Referenced by extrapolate(), getRecord(), interpolate(), and storePhoton().

◆ pmom

std::vector<double> HFShowerLibrary::pmom
private

Definition at line 72 of file HFShowerLibrary.h.

Referenced by extrapolate(), fillHits(), HFShowerLibrary(), interpolate(), and loadEventInfo().

◆ probMax

double HFShowerLibrary::probMax
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

◆ rMax

double HFShowerLibrary::rMax
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

◆ rMin

double HFShowerLibrary::rMin
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

◆ totEvents

int HFShowerLibrary::totEvents
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by extrapolate(), getRecord(), HFShowerLibrary(), interpolate(), and loadEventInfo().

◆ v3version

bool HFShowerLibrary::v3version
private

Definition at line 69 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

◆ verbose

bool HFShowerLibrary::verbose
private

Definition at line 69 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary().

HFShowerLibrary::hf
TFile * hf
Definition: HFShowerLibrary.h:66
G4TrackToParticleID::isStableHadron
static bool isStableHadron(int pdgCode)
Definition: G4TrackToParticleID.cc:33
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:11713
HFShowerLibrary::nMomBin
int nMomBin
Definition: HFShowerLibrary.h:70
HcalDDDSimConstants::getRTableHF
const std::vector< double > & getRTableHF() const
Definition: HcalDDDSimConstants.h:61
HFShowerLibrary::Hit::depth
int depth
Definition: HFShowerLibrary.h:41
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:169
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
HcalDDDSimConstants::getGparHF
const std::vector< double > & getGparHF() const
Definition: HcalDDDSimConstants.h:45
HFShowerLibrary::gpar
std::vector< double > gpar
Definition: HFShowerLibrary.h:76
HFShowerLibrary::probMax
double probMax
Definition: HFShowerLibrary.h:74
HFShowerLibrary::photon
HFShowerPhotonCollection photon
Definition: HFShowerLibrary.h:81
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
MeV
const double MeV
personalPlayback.fp
fp
Definition: personalPlayback.py:523
gpuVertexFinder::zv
float *__restrict__ zv
Definition: gpuFitVertices.h:26
HFShowerLibrary::evtPerBin
int evtPerBin
Definition: HFShowerLibrary.h:70
HFShowerLibrary::npe
int npe
Definition: HFShowerLibrary.h:78
HFShowerLibrary::fibre_
std::unique_ptr< HFFibre > fibre_
Definition: HFShowerLibrary.h:65
HFShowerLibrary::v3version
bool v3version
Definition: HFShowerLibrary.h:69
HFShowerLibrary::storePhoton
void storePhoton(int j)
Definition: HFShowerLibrary.cc:578
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
G4TrackToParticleID::isGammaElectronPositron
static bool isGammaElectronPositron(int pdgCode)
Definition: G4TrackToParticleID.cc:17
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
HFShowerLibrary::emBranch
TBranch * emBranch
Definition: HFShowerLibrary.h:67
HFShowerLibrary::getRecord
void getRecord(int, int)
Definition: HFShowerLibrary.cc:346
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
w
const double w
Definition: UKUtility.cc:23
HFShowerLibrary::hcalConstant_
const HcalDDDSimConstants * hcalConstant_
Definition: HFShowerLibrary.h:64
DDAxes::z
HFShowerLibrary::dphi
double dphi
Definition: HFShowerLibrary.h:75
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HFShowerLibrary::totEvents
int totEvents
Definition: HFShowerLibrary.h:70
hit::z
double z
Definition: SiStripHitEffFromCalibTree.cc:91
HFShowerLibrary::hadBranch
TBranch * hadBranch
Definition: HFShowerLibrary.h:67
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HFShowerLibrary::extrapolate
void extrapolate(int, double)
Definition: HFShowerLibrary.cc:513
HFShowerLibrary::Hit::time
double time
Definition: HFShowerLibrary.h:42
funct::true
true
Definition: Factorize.h:173
HFShowerPhotonCollection
std::vector< HFShowerPhoton > HFShowerPhotonCollection
Definition: HFShowerPhoton.h:36
edm::ParameterSet
Definition: ParameterSet.h:47
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
GeV
const double GeV
Definition: MathUtil.h:16
edmPickEvents.event
event
Definition: edmPickEvents.py:273
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
createfilelist.int
int
Definition: createfilelist.py:10
HcalDDDSimConstants::getPhiTableHF
const std::vector< double > & getPhiTableHF() const
Definition: HcalDDDSimConstants.h:60
HFShowerLibrary::Hit::position
G4ThreeVector position
Definition: HFShowerLibrary.h:40
HFShowerLibrary::newForm
bool newForm
Definition: HFShowerLibrary.h:69
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HFShowerLibrary::pe
HFShowerPhotonCollection pe
Definition: HFShowerLibrary.h:79
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HFShowerLibrary::pmom
std::vector< double > pmom
Definition: HFShowerLibrary.h:72
HFShowerLibrary::fillHits
std::vector< Hit > fillHits(const G4ThreeVector &p, const G4ThreeVector &v, int parCode, double parEnergy, bool &ok, double weight, double time, bool onlyLong=false)
Definition: HFShowerLibrary.cc:184
HFShowerLibrary::rMin
double rMin
Definition: HFShowerLibrary.h:75
HFShowerLibrary::Hit
Definition: HFShowerLibrary.h:38
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
HFShowerLibrary::rInside
bool rInside(double r)
Definition: HFShowerLibrary.cc:344
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
HFShowerLibrary::libVers
float libVers
Definition: HFShowerLibrary.h:71
HFShowerLibrary::loadEventInfo
void loadEventInfo(TBranch *)
Definition: HFShowerLibrary.cc:405
HFShowerPhoton
Definition: HFShowerPhoton.h:13
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HFShowerLibrary::applyFidCut
bool applyFidCut
Definition: HFShowerLibrary.h:69
HFShowerLibrary::rMax
double rMax
Definition: HFShowerLibrary.h:75
HFShowerLibrary::photo
HFShowerPhotonCollection * photo
Definition: HFShowerLibrary.h:80
HFShowerLibrary::interpolate
void interpolate(int, double)
Definition: HFShowerLibrary.cc:436
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
event
Definition: event.py:1
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HFShowerLibrary::backProb
double backProb
Definition: HFShowerLibrary.h:74
edm::Log
Definition: MessageLogger.h:70
HFShowerLibrary::listVersion
float listVersion
Definition: HFShowerLibrary.h:71
HFShowerLibrary::verbose
bool verbose
Definition: HFShowerLibrary.h:69
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
weight
Definition: weight.py:1
hit
Definition: SiStripHitEffFromCalibTree.cc:88