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 (G4Step *aStep, bool &ok, double weight, bool onlyLong=false)
 
 HFShowerLibrary (const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p)
 
void initRun (G4ParticleTable *, HcalDDDSimConstants *)
 
 ~HFShowerLibrary ()
 

Protected Member Functions

void extrapolate (int, double)
 
std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &, int &)
 
void getRecord (int, int)
 
void interpolate (int, double)
 
void loadEventInfo (TBranch *)
 
bool rInside (double r)
 
void storePhoton (int j)
 

Private Attributes

int anuePDG
 
int anumuPDG
 
int anutauPDG
 
bool applyFidCut
 
double backProb
 
double dphi
 
TBranch * emBranch
 
int emPDG
 
int epPDG
 
int etaPDG
 
int evtPerBin
 
HFFibrefibre
 
int gammaPDG
 
int geantinoPDG
 
std::vector< double > gpar
 
TBranch * hadBranch
 
TFile * hf
 
float libVers
 
float listVersion
 
bool newForm
 
int nMomBin
 
int npe
 
int nuePDG
 
int numuPDG
 
int nutauPDG
 
HFShowerPhotonCollection pe
 
HFShowerPhotonCollectionphoto
 
HFShowerPhotonCollection photon
 
int pi0PDG
 
std::vector< double > pmom
 
double probMax
 
double rMax
 
double rMin
 
int totEvents
 
bool v3version
 
bool verbose
 

Detailed Description

Definition at line 29 of file HFShowerLibrary.h.

Constructor & Destructor Documentation

HFShowerLibrary::HFShowerLibrary ( const std::string &  name,
const DDCompactView cpv,
edm::ParameterSet const &  p 
)

Definition at line 24 of file HFShowerLibrary.cc.

References anuePDG, anumuPDG, anutauPDG, applyFidCut, backProb, emBranch, emPDG, epPDG, etaPDG, event(), evtPerBin, Exception, fibre, gammaPDG, geantinoPDG, edm::ParameterSet::getParameter(), GeV, hadBranch, hf, mps_fire::i, info(), libVers, listVersion, loadEventInfo(), newForm, nMomBin, nuePDG, numuPDG, nutauPDG, photo, pi0PDG, pmom, probMax, AlCaHLTBitMon_QueryRunRegistry::string, totEvents, and v3version.

25  : fibre(nullptr),hf(nullptr),
26  emBranch(nullptr),
27  hadBranch(nullptr),
28  npe(0) {
29 
30 
31  edm::ParameterSet m_HF = p.getParameter<edm::ParameterSet>("HFShower");
32  probMax = m_HF.getParameter<double>("ProbMax");
33 
34  edm::ParameterSet m_HS= p.getParameter<edm::ParameterSet>("HFShowerLibrary");
35  edm::FileInPath fp = m_HS.getParameter<edm::FileInPath>("FileName");
36  std::string pTreeName = fp.fullPath();
37  backProb = m_HS.getParameter<double>("BackProbability");
38  std::string emName = m_HS.getParameter<std::string>("TreeEMID");
39  std::string hadName = m_HS.getParameter<std::string>("TreeHadID");
40  std::string branchEvInfo = m_HS.getUntrackedParameter<std::string>("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) pTreeName.erase(0,2);
47  const char* nTree = pTreeName.c_str();
48  hf = TFile::Open(nTree);
49 
50  if (!hf->IsOpen()) {
51  edm::LogError("HFShower") << "HFShowerLibrary: opening " << nTree
52  << " failed";
53  throw cms::Exception("Unknown", "HFShowerLibrary")
54  << "Opening of " << pTreeName << " fails\n";
55  } else {
56  edm::LogInfo("HFShower") << "HFShowerLibrary: opening " << nTree
57  << " successfully";
58  }
59 
60  newForm = (branchEvInfo == "");
61  TTree* event(nullptr);
62  if (newForm) event = (TTree *) hf ->Get("HFSimHits");
63  else 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")
76  << "Event information absent\n";
77  }
78  } else {
79  edm::LogError("HFShower") << "HFShowerLibrary: Events Tree does not "
80  << "exist";
81  throw cms::Exception("Unknown", "HFShowerLibrary")
82  << "Events tree absent\n";
83  }
84 
85  edm::LogInfo("HFShower") << "HFShowerLibrary: Library " << libVers
86  << " ListVersion " << listVersion
87  << " Events Total " << totEvents << " and "
88  << evtPerBin << " per bin";
89  edm::LogInfo("HFShower") << "HFShowerLibrary: Energies (GeV) with "
90  << nMomBin << " bins";
91  for (int i=0; i<nMomBin; i++)
92  edm::LogInfo("HFShower") << "HFShowerLibrary: pmom[" << i << "] = "
93  << pmom[i]/GeV << " GeV";
94 
95  std::string nameBr = branchPre + emName + branchPost;
96  emBranch = event->GetBranch(nameBr.c_str());
97  if (verbose) emBranch->Print();
98  nameBr = branchPre + hadName + branchPost;
99  hadBranch = event->GetBranch(nameBr.c_str());
100  if (verbose) hadBranch->Print();
101 
102  v3version=false;
103  if ( emBranch->GetClassName() == std::string("vector<float>") ) {
104  v3version=true;
105  }
106 
107 
108  edm::LogInfo("HFShower") << "HFShowerLibrary:Branch " << emName
109  << " has " << emBranch->GetEntries()
110  << " entries and Branch " << hadName
111  << " has " << hadBranch->GetEntries()
112  << " entries";
113  edm::LogInfo("HFShower") << "HFShowerLibrary::No packing information -"
114  << " Assume x, y, z are not in packed form";
115 
116  edm::LogInfo("HFShower") << "HFShowerLibrary: Maximum probability cut off "
117  << probMax << " Back propagation of light prob. "
118  << backProb ;
119 
120  fibre = new HFFibre(name, cpv, p);
122  emPDG = epPDG = gammaPDG = 0;
123  pi0PDG = etaPDG = nuePDG = numuPDG = nutauPDG= 0;
125 }
T getParameter(std::string const &) const
static const TGPicture * info(bool iBackgroundIsBlack)
const double GeV
Definition: MathUtil.h:16
std::vector< HFShowerPhoton > HFShowerPhotonCollection
void loadEventInfo(TBranch *)
HFShowerPhotonCollection * photo
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
TBranch * emBranch
std::vector< double > pmom
Definition: event.py:1
TBranch * hadBranch
HFShowerLibrary::~HFShowerLibrary ( )

Definition at line 127 of file HFShowerLibrary.cc.

References fibre, hf, and photo.

127  {
128  if (hf) hf->Close();
129  if (fibre) delete fibre;
130  fibre = nullptr;
131  if (photo) delete photo;
132 }
HFShowerPhotonCollection * photo

Member Function Documentation

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

Definition at line 567 of file HFShowerLibrary.cc.

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

Referenced by fillHits().

567  {
568 
569  int nrec = int(pin/pmom[nMomBin-1]);
570  double w = (pin - pmom[nMomBin-1]*nrec)/pmom[nMomBin-1];
571  nrec++;
572 #ifdef DebugLog
573  LogDebug("HFShower") << "HFShowerLibrary:: Extrapolate for Energy " << pin
574  << " GeV with " << nMomBin << " momentum bins and "
575  << evtPerBin << " entries/bin -- total " << totEvents
576  << " using " << nrec << " records";
577 #endif
578  std::vector<int> irc(nrec);
579 
580  for (int ir=0; ir<nrec; ir++) {
581  double r = G4UniformRand();
582  irc[ir] = int(evtPerBin*0.5*r) +(nMomBin-1)*evtPerBin + 1;
583  if (irc[ir]<1) {
584  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir
585  << "] = " << irc[ir] << " now set to 1";
586  irc[ir] = 1;
587  } else if (irc[ir] > totEvents) {
588  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir
589  << "] = " << irc[ir] << " now set to "
590  << totEvents;
591  irc[ir] = totEvents;
592 #ifdef DebugLog
593  } else {
594  LogDebug("HFShower") << "HFShowerLibrary::Extrapolation use irc["
595  << ir << "] = " << irc[ir];
596 #endif
597  }
598  }
599 
600  pe.clear();
601  npe = 0;
602  int npold = 0;
603  for (int ir=0; ir<nrec; ir++) {
604  if (irc[ir]>0) {
605  getRecord (type, irc[ir]);
606  int nPhoton = (newForm) ? photo->size() : photon.size();
607  npold += nPhoton;
608  for (int j=0; j<nPhoton; j++) {
609  double r = G4UniformRand();
610  if (ir != nrec-1 || r < w) {
611  storePhoton (j);
612  }
613  }
614 #ifdef DebugLog
615  LogDebug("HFShower") << "HFShowerLibrary: Record [" << ir << "] = "
616  << irc[ir] << " npold = " << npold;
617 #endif
618  }
619  }
620 #ifdef DebugLog
621  LogDebug("HFShower") << "HFShowerLibrary:: uses " << npold << " photons";
622 #endif
623 
624  if (npe > npold || npold == 0)
625  edm::LogWarning("HFShower") << "HFShowerLibrary: Extrapolation Warning == "
626  << nrec << " records " << irc[0] << ", "
627  << irc[1] << ", ... gives a buffer of " <<npold
628  << " photons and fills " << npe
629  << " *****";
630 #ifdef DebugLog
631  else
632  LogDebug("HFShower") << "HFShowerLibrary: Extrapolation == " << nrec
633  << " records " << irc[0] << ", " << irc[1]
634  << ", ... gives a buffer of " << npold
635  << " photons and fills " << npe << " PE";
636  for (int j=0; j<npe; j++)
637  LogDebug("HFShower") << "Photon " << j << " " << pe[j];
638 #endif
639 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
void getRecord(int, int)
const double w
Definition: UKUtility.cc:23
HFShowerPhotonCollection pe
HFShowerPhotonCollection * photo
std::vector< double > pmom
void storePhoton(int j)
HFShowerPhotonCollection photon
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 222 of file HFShowerLibrary.cc.

References funct::abs(), anuePDG, anumuPDG, anutauPDG, applyFidCut, HFFibre::attLength(), backProb, funct::cos(), particleFlowClusterECALTimeSelected_cfi::depth, HFShowerLibrary::Hit::depth, dphi, emPDG, epPDG, etaPDG, JetChargeProducer_cfi::exp, extrapolate(), fibre, gammaPDG, geantinoPDG, gpar, mps_fire::i, createfilelist::int, interpolate(), LogDebug, nMomBin, npe, nuePDG, numuPDG, nutauPDG, AlCaHLTBitMon_ParallelJobs::p, pe, pi0PDG, pmom, HFShowerLibrary::Hit::position, probMax, alignCSCRings::r, diffTwoXMLs::r1, diffTwoXMLs::r2, rInside(), funct::sin(), HFShowerLibrary::Hit::time, HFFibre::tShift(), geometryCSVtoXML::xx, geometryCSVtoXML::yy, z, hit::z, HFFibre::zShift(), and geometryCSVtoXML::zz.

Referenced by getHits().

225  {
226 
227  std::vector<HFShowerLibrary::Hit> hit;
228  ok = false;
229  if (parCode == pi0PDG || parCode == etaPDG || parCode == nuePDG ||
230  parCode == numuPDG || parCode == nutauPDG || parCode == anuePDG ||
231  parCode == anumuPDG || parCode == anutauPDG || parCode == geantinoPDG)
232  return hit;
233  ok = true;
234 
235  double pz = momDir.z();
236  double zint = hitPoint.z();
237 
238  // if particle moves from interaction point or "backwards (halo)
239  int backward = 0;
240  if (pz * zint < 0.) backward = 1;
241 
242  double sphi = sin(momDir.phi());
243  double cphi = cos(momDir.phi());
244  double ctheta = cos(momDir.theta());
245  double stheta = sin(momDir.theta());
246 
247  if (parCode == emPDG || parCode == epPDG || parCode == gammaPDG ) {
248  if (pin<pmom[nMomBin-1]) {
249  interpolate(0, pin);
250  } else {
251  extrapolate(0, pin);
252  }
253  } else {
254  if (pin<pmom[nMomBin-1]) {
255  interpolate(1, pin);
256  } else {
257  extrapolate(1, pin);
258  }
259  }
260 
261  int nHit = 0;
262  HFShowerLibrary::Hit oneHit;
263  for (int i = 0; i < npe; i++) {
264  double zv = std::abs(pe[i].z()); // abs local z
265 #ifdef DebugLog
266  edm::LogInfo("HFShower") << "HFShowerLibrary: Hit " << i << " " << pe[i] << " zv " << zv;
267 #endif
268  if (zv <= gpar[1] && pe[i].lambda() > 0 &&
269  (pe[i].z() >= 0 || (zv > gpar[0] && (!onlyLong)))) {
270  int depth = 1;
271  if (onlyLong) {
272  } else if (backward == 0) { // fully valid only for "front" particles
273  if (pe[i].z() < 0) depth = 2;// with "front"-simulated shower lib.
274  } else { // for "backward" particles - almost equal
275  double r = G4UniformRand(); // share between L and S fibers
276  if (r > 0.5) depth = 2;
277  }
278 
279 
280  // Updated coordinate transformation from local
281  // back to global using two Euler angles: phi and theta
282  double pex = pe[i].x();
283  double pey = pe[i].y();
284 
285  double xx = pex*ctheta*cphi - pey*sphi + zv*stheta*cphi;
286  double yy = pex*ctheta*sphi + pey*cphi + zv*stheta*sphi;
287  double zz = -pex*stheta + zv*ctheta;
288 
289  G4ThreeVector pos = hitPoint + G4ThreeVector(xx,yy,zz);
290  zv = std::abs(pos.z()) - gpar[4] - 0.5*gpar[1];
291  G4ThreeVector lpos = G4ThreeVector(pos.x(),pos.y(),zv);
292 
293  zv = fibre->zShift(lpos,depth,0); // distance to PMT !
294 
295  double r = pos.perp();
296  double p = fibre->attLength(pe[i].lambda());
297  double fi = pos.phi();
298  if (fi < 0) fi += twopi;
299  int isect = int(fi/dphi) + 1;
300  isect = (isect + 1) / 2;
301  double dfi = ((isect*2-1)*dphi - fi);
302  if (dfi < 0) dfi = -dfi;
303  double dfir = r * sin(dfi);
304 #ifdef DebugLog
305  edm::LogInfo("HFShower") << "HFShowerLibrary: Position shift " << xx
306  << ", " << yy << ", " << zz << ": " << pos
307  << " R " << r << " Phi " << fi << " Section "
308  << isect << " R*Dfi " << dfir << " Dist " << zv;
309 #endif
310  zz = std::abs(pos.z());
311  double r1 = G4UniformRand();
312  double r2 = G4UniformRand();
313  double r3 = -9999.;
314  if (backward) r3 = G4UniformRand();
315  if (!applyFidCut) dfir += gpar[5];
316 
317 #ifdef DebugLog
318  edm::LogInfo("HFShower") << "HFShowerLibrary: rLimits " << rInside(r)
319  << " attenuation " << r1 <<":" << exp(-p*zv)
320  << " r2 " << r2 << " r3 " << r3 << " rDfi "
321  << gpar[5] << " zz "
322  << zz << " zLim " << gpar[4] << ":"
323  << gpar[4]+gpar[1] << "\n"
324  << " rInside(r) :" << rInside(r)
325  << " r1 <= exp(-p*zv) :" << (r1 <= exp(-p*zv))
326  << " r2 <= probMax :" << (r2 <= probMax*weight)
327  << " r3 <= backProb :" << (r3 <= backProb)
328  << " dfir > gpar[5] :" << (dfir > gpar[5])
329  << " zz >= gpar[4] :" << (zz >= gpar[4])
330  << " zz <= gpar[4]+gpar[1] :"
331  << (zz <= gpar[4]+gpar[1]);
332 #endif
333  if (rInside(r) && r1 <= exp(-p*zv) && r2 <= probMax*weight &&
334  dfir > gpar[5] && zz >= gpar[4] && zz <= gpar[4]+gpar[1] &&
335  r3 <= backProb && (depth != 2 || zz >= gpar[4]+gpar[0])) {
336  oneHit.position = pos;
337  oneHit.depth = depth;
338  oneHit.time = (tSlice+(pe[i].t())+(fibre->tShift(lpos,depth,1)));
339  hit.push_back(oneHit);
340 #ifdef DebugLog
341  edm::LogInfo("HFShower") << "HFShowerLibrary: Final Hit " << nHit
342  <<" position " << (hit[nHit].position)
343  << " Depth " << (hit[nHit].depth) <<" Time "
344  << tSlice << ":" << pe[i].t() << ":"
345  << fibre->tShift(lpos,depth,1) << ":"
346  << (hit[nHit].time);
347 #endif
348  nHit++;
349  }
350 #ifdef DebugLog
351  else LogDebug("HFShower") << "HFShowerLibrary: REJECTED !!!";
352 #endif
353  if (onlyLong && zz >= gpar[4]+gpar[0] && zz <= gpar[4]+gpar[1]) {
354  r1 = G4UniformRand();
355  r2 = G4UniformRand();
356  if (rInside(r) && r1 <= exp(-p*zv) && r2 <= probMax && dfir > gpar[5]){
357  oneHit.position = pos;
358  oneHit.depth = 2;
359  oneHit.time = (tSlice+(pe[i].t())+(fibre->tShift(lpos,2,1)));
360  hit.push_back(oneHit);
361 #ifdef DebugLog
362  edm::LogInfo("HFShower") << "HFShowerLibrary: Final Hit " << nHit
363  << " position " << (hit[nHit].position)
364  << " Depth " << (hit[nHit].depth) <<" Time "
365  << tSlice << ":" << pe[i].t() << ":"
366  << fibre->tShift(lpos,2,1) << ":"
367  << (hit[nHit].time);
368 #endif
369  nHit++;
370  }
371  }
372  }
373  }
374 
375 #ifdef DebugLog
376  edm::LogInfo("HFShower") << "HFShowerLibrary: Total Hits " << nHit
377  << " out of " << npe << " PE";
378 #endif
379  if (nHit > npe && !onlyLong)
380  edm::LogWarning("HFShower") << "HFShowerLibrary: Hit buffer " << npe
381  << " smaller than " << nHit << " Hits";
382  return hit;
383 
384 }
#define LogDebug(id)
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
Definition: HFFibre.cc:112
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double attLength(double lambda)
Definition: HFFibre.cc:94
HFShowerPhotonCollection pe
double zShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
Definition: HFFibre.cc:124
Definition: weight.py:1
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > gpar
std::vector< double > pmom
G4ThreeVector position
void extrapolate(int, double)
bool rInside(double r)
void interpolate(int, double)
std::vector< double > HFShowerLibrary::getDDDArray ( const std::string &  str,
const DDsvalues_type sv,
int &  nmin 
)
protected

Definition at line 652 of file HFShowerLibrary.cc.

References DDfetch(), DDValue::doubles(), Exception, LogDebug, harvestTrackValidationPlots::str, and relativeConstraints::value.

654  {
655 
656 #ifdef DebugLog
657  LogDebug("HFShower") << "HFShowerLibrary:getDDDArray called for " << str
658  << " with nMin " << nmin;
659 #endif
660  DDValue value(str);
661  if (DDfetch(&sv,value)) {
662 #ifdef DebugLog
663  LogDebug("HFShower") << value;
664 #endif
665  const std::vector<double> & fvec = value.doubles();
666  int nval = fvec.size();
667  if (nmin > 0) {
668  if (nval < nmin) {
669  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
670  << " bins " << nval << " < " << nmin
671  << " ==> illegal";
672  throw cms::Exception("Unknown", "HFShowerLibrary")
673  << "nval < nmin for array " << str << "\n";
674  }
675  } else {
676  if (nval < 2) {
677  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
678  << " bins " << nval << " < 2 ==> illegal"
679  << " (nmin=" << nmin << ")";
680  throw cms::Exception("Unknown", "HFShowerLibrary")
681  << "nval < 2 for array " << str << "\n";
682  }
683  }
684  nmin = nval;
685 
686  return fvec;
687  } else {
688  edm::LogError("HFShower") << "HFShowerLibrary : cannot get array " << str;
689  throw cms::Exception("Unknown", "HFShowerLibrary")
690  << "cannot get array " << str << "\n";
691  }
692 }
#define LogDebug(id)
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
Definition: value.py:1
std::vector< HFShowerLibrary::Hit > HFShowerLibrary::getHits ( G4Step *  aStep,
bool &  ok,
double  weight,
bool  onlyLong = false 
)

Definition at line 185 of file HFShowerLibrary.cc.

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

Referenced by HCalSD::getFromLibrary(), and HFShowerParam::getHits().

188  {
189 
190  const G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
191  const G4StepPoint * postStepPoint = aStep->GetPostStepPoint();
192  const G4Track * track = aStep->GetTrack();
193  // Get Z-direction
194  const G4DynamicParticle *aParticle = track->GetDynamicParticle();
195  const G4ThreeVector& momDir = aParticle->GetMomentumDirection();
196 
197  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
198  G4String partType = track->GetDefinition()->GetParticleName();
199  int parCode = track->GetDefinition()->GetPDGEncoding();
200 
201 #ifdef DebugLog
202  G4ThreeVector localPos = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
203  double zoff = localPos.z() + 0.5*gpar[1];
204  // if (zoff < 0) zoff = 0;
205  edm::LogInfo("HFShower") << "HFShowerLibrary: getHits " << partType
206  << " of energy " << pin/GeV << " GeV"
207  << " dir.orts " << momDir.x() << ", " <<momDir.y()
208  << ", " << momDir.z() << " Pos x,y,z = "
209  << hitPoint.x() << "," << hitPoint.y() << ","
210  << hitPoint.z() << " (" << zoff
211  << ") sphi,cphi,stheta,ctheta = " << sin(momDir.phi())
212  << "," << cos(momDir.phi()) << ", " << sin(momDir.theta())
213  << "," << cos(momDir.theta());
214 #endif
215 
216  double tSlice = (postStepPoint->GetGlobalTime())/nanosecond;
217  double pin = preStepPoint->GetTotalEnergy();
218 
219  return fillHits(hitPoint,momDir,parCode,pin,ok,weight,tSlice,onlyLong);
220 }
const double GeV
Definition: MathUtil.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: weight.py:1
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > gpar
std::vector< Hit > fillHits(const G4ThreeVector &p, const G4ThreeVector &v, int parCode, double parEnergy, bool &ok, double weight, double time, bool onlyLong=false)
void HFShowerLibrary::getRecord ( int  type,
int  record 
)
protected

Definition at line 392 of file HFShowerLibrary.cc.

References emBranch, hadBranch, mps_fire::i, LogDebug, newForm, photo, photon, lumiQTWidget::t, totEvents, and v3version.

Referenced by extrapolate(), and interpolate().

392  {
393 
394  int nrc = record-1;
395  photon.clear();
396  photo->clear();
397  if (type > 0) {
398  if (newForm) {
399  if ( !v3version ) {
400  hadBranch->SetAddress(&photo);
401  hadBranch->GetEntry(nrc+totEvents);
402  }
403  else{
404  std::vector<float> t;
405  std::vector<float> *tp=&t;
406  hadBranch->SetAddress(&tp);
407  hadBranch->GetEntry(nrc+totEvents);
408  unsigned int tSize=t.size()/5;
409  photo->reserve(tSize);
410  for ( unsigned int i=0; i<tSize; i++ ) {
411  photo->push_back( HFShowerPhoton( t[i], t[1*tSize+i], t[2*tSize+i], t[3*tSize+i], t[4*tSize+i] ) );
412  }
413  }
414  } else {
415  hadBranch->SetAddress(&photon);
416  hadBranch->GetEntry(nrc);
417  }
418  } else {
419  if (newForm) {
420  if (!v3version) {
421  emBranch->SetAddress(&photo);
422  emBranch->GetEntry(nrc);
423  }
424  else{
425  std::vector<float> t;
426  std::vector<float> *tp=&t;
427  emBranch->SetAddress(&tp);
428  emBranch->GetEntry(nrc);
429  unsigned int tSize=t.size()/5;
430  photo->reserve(tSize);
431  for ( unsigned int i=0; i<tSize; i++ ) {
432  photo->push_back( HFShowerPhoton( t[i], t[1*tSize+i], t[2*tSize+i], t[3*tSize+i], t[4*tSize+i] ) );
433  }
434  }
435  } else {
436  emBranch->SetAddress(&photon);
437  emBranch->GetEntry(nrc);
438  }
439  }
440 #ifdef DebugLog
441  int nPhoton = (newForm) ? photo->size() : photon.size();
442  LogDebug("HFShower") << "HFShowerLibrary::getRecord: Record " << record
443  << " of type " << type << " with " << nPhoton
444  << " photons";
445  for (int j = 0; j < nPhoton; j++)
446  if (newForm) LogDebug("HFShower") << "Photon " << j << " " << photo->at(j);
447  else LogDebug("HFShower") << "Photon " << j << " " << photon[j];
448 #endif
449 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
JetCorrectorParameters::Record record
Definition: classes.h:7
HFShowerPhotonCollection * photo
TBranch * emBranch
HFShowerPhotonCollection photon
TBranch * hadBranch
void HFShowerLibrary::initRun ( G4ParticleTable *  theParticleTable,
HcalDDDSimConstants hcons 
)

Definition at line 134 of file HFShowerLibrary.cc.

References anuePDG, anumuPDG, anutauPDG, dphi, emPDG, epPDG, etaPDG, fibre, gammaPDG, geantinoPDG, HcalDDDSimConstants::getGparHF(), HcalDDDSimConstants::getPhiTableHF(), HcalDDDSimConstants::getRTableHF(), gpar, HFFibre::initRun(), nuePDG, numuPDG, nutauPDG, pi0PDG, rMax, and rMin.

Referenced by HFShowerParam::initRun(), and HCalSD::initRun().

135  {
136 
137  if (fibre) fibre->initRun(hcons);
138 
139  G4String parName;
140  emPDG = theParticleTable->FindParticle(parName="e-")->GetPDGEncoding();
141  epPDG = theParticleTable->FindParticle(parName="e+")->GetPDGEncoding();
142  gammaPDG = theParticleTable->FindParticle(parName="gamma")->GetPDGEncoding();
143  pi0PDG = theParticleTable->FindParticle(parName="pi0")->GetPDGEncoding();
144  etaPDG = theParticleTable->FindParticle(parName="eta")->GetPDGEncoding();
145  nuePDG = theParticleTable->FindParticle(parName="nu_e")->GetPDGEncoding();
146  numuPDG = theParticleTable->FindParticle(parName="nu_mu")->GetPDGEncoding();
147  nutauPDG= theParticleTable->FindParticle(parName="nu_tau")->GetPDGEncoding();
148  anuePDG = theParticleTable->FindParticle(parName="anti_nu_e")->GetPDGEncoding();
149  anumuPDG= theParticleTable->FindParticle(parName="anti_nu_mu")->GetPDGEncoding();
150  anutauPDG= theParticleTable->FindParticle(parName="anti_nu_tau")->GetPDGEncoding();
151  geantinoPDG= theParticleTable->FindParticle(parName="geantino")->GetPDGEncoding();
152 #ifdef DebugLog
153  edm::LogInfo("HFShower") << "HFShowerLibrary: Particle codes for e- = "
154  << emPDG << ", e+ = " << epPDG << ", gamma = "
155  << gammaPDG << ", pi0 = " << pi0PDG << ", eta = "
156  << etaPDG << ", geantino = " << geantinoPDG
157  << "\n nu_e = " << nuePDG << ", nu_mu = "
158  << numuPDG << ", nu_tau = " << nutauPDG
159  << ", anti_nu_e = " << anuePDG << ", anti_nu_mu = "
160  << anumuPDG << ", anti_nu_tau = " << anutauPDG;
161 #endif
162 
163  //Radius (minimum and maximum)
164  std::vector<double> rTable = hcons->getRTableHF();
165  rMin = rTable[0];
166  rMax = rTable[rTable.size()-1];
167  edm::LogInfo("HFShower") << "HFShowerLibrary: rMIN " << rMin/cm
168  << " cm and rMax " << rMax/cm;
169 
170  //Delta phi
171  std::vector<double> phibin = hcons->getPhiTableHF();
172  dphi = phibin[0];
173  edm::LogInfo("HFShower") << "HFShowerLibrary: (Half) Phi Width of wedge "
174  << dphi/deg;
175 
176  //Special Geometry parameters
177  gpar = hcons->getGparHF();
178  edm::LogInfo("HFShower") << "HFShowerLibrary: " <<gpar.size() <<" gpar (cm)";
179  for (unsigned int ig=0; ig<gpar.size(); ig++)
180  edm::LogInfo("HFShower") << "HFShowerLibrary: gpar[" << ig << "] = "
181  << gpar[ig]/cm << " cm";
182 }
void initRun(HcalDDDSimConstants *)
Definition: HFFibre.cc:77
const std::vector< double > & getRTableHF() const
const std::vector< double > & getPhiTableHF() const
std::vector< double > gpar
const std::vector< double > & getGparHF() const
void HFShowerLibrary::interpolate ( int  type,
double  pin 
)
protected

Definition at line 480 of file HFShowerLibrary.cc.

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

Referenced by fillHits().

480  {
481 
482 #ifdef DebugLog
483  LogDebug("HFShower") << "HFShowerLibrary:: Interpolate for Energy " <<pin/GeV
484  << " GeV with " << nMomBin << " momentum bins and "
485  << evtPerBin << " entries/bin -- total " << totEvents;
486 #endif
487  int irc[2]={0,0};
488  double w = 0.;
489  double r = G4UniformRand();
490 
491  if (pin<pmom[0]) {
492  w = pin/pmom[0];
493  irc[1] = int(evtPerBin*r) + 1;
494  irc[0] = 0;
495  } else {
496  for (int j=0; j<nMomBin-1; j++) {
497  if (pin >= pmom[j] && pin < pmom[j+1]) {
498  w = (pin-pmom[j])/(pmom[j+1]-pmom[j]);
499  if (j == nMomBin-2) {
500  irc[1] = int(evtPerBin*0.5*r);
501  } else {
502  irc[1] = int(evtPerBin*r);
503  }
504  irc[1] += (j+1)*evtPerBin + 1;
505  r = G4UniformRand();
506  irc[0] = int(evtPerBin*r) + 1 + j*evtPerBin;
507  if (irc[0]<0) {
508  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = "
509  << irc[0] << " now set to 0";
510  irc[0] = 0;
511  } else if (irc[0] > totEvents) {
512  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = "
513  << irc[0] << " now set to "<< totEvents;
514  irc[0] = totEvents;
515  }
516  }
517  }
518  }
519  if (irc[1]<1) {
520  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = "
521  << irc[1] << " now set to 1";
522  irc[1] = 1;
523  } else if (irc[1] > totEvents) {
524  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = "
525  << irc[1] << " now set to "<< totEvents;
526  irc[1] = totEvents;
527  }
528 
529 #ifdef DebugLog
530  LogDebug("HFShower") << "HFShowerLibrary:: Select records " << irc[0]
531  << " and " << irc[1] << " with weights " << 1-w
532  << " and " << w;
533 #endif
534  pe.clear();
535  npe = 0;
536  int npold = 0;
537  for (int ir=0; ir < 2; ir++) {
538  if (irc[ir]>0) {
539  getRecord (type, irc[ir]);
540  int nPhoton = (newForm) ? photo->size() : photon.size();
541  npold += nPhoton;
542  for (int j=0; j<nPhoton; j++) {
543  r = G4UniformRand();
544  if ((ir==0 && r > w) || (ir > 0 && r < w)) {
545  storePhoton (j);
546  }
547  }
548  }
549  }
550 
551  if ((npe > npold || (npold == 0 && irc[0] > 0)) && !(npe == 0 && npold == 0))
552  edm::LogWarning("HFShower") << "HFShowerLibrary: Interpolation Warning =="
553  << " records " << irc[0] << " and " << irc[1]
554  << " gives a buffer of " << npold
555  << " photons and fills " << npe << " *****";
556 #ifdef DebugLog
557  else
558  LogDebug("HFShower") << "HFShowerLibrary: Interpolation == records "
559  << irc[0] << " and " << irc[1] << " gives a "
560  << "buffer of " << npold << " photons and fills "
561  << npe << " PE";
562  for (int j=0; j<npe; j++)
563  LogDebug("HFShower") << "Photon " << j << " " << pe[j];
564 #endif
565 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
const double GeV
Definition: MathUtil.h:16
void getRecord(int, int)
const double w
Definition: UKUtility.cc:23
HFShowerPhotonCollection pe
HFShowerPhotonCollection * photo
std::vector< double > pmom
void storePhoton(int j)
HFShowerPhotonCollection photon
void HFShowerLibrary::loadEventInfo ( TBranch *  branch)
protected

Definition at line 451 of file HFShowerLibrary.cc.

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

Referenced by HFShowerLibrary().

451  {
452 
453  if (branch) {
454  std::vector<HFShowerLibraryEventInfo> eventInfoCollection;
455  branch->SetAddress(&eventInfoCollection);
456  branch->GetEntry(0);
457  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
458  << " EventInfo Collection of size "
459  << eventInfoCollection.size() << " records";
460  totEvents = eventInfoCollection[0].totalEvents();
461  nMomBin = eventInfoCollection[0].numberOfBins();
462  evtPerBin = eventInfoCollection[0].eventsPerBin();
463  libVers = eventInfoCollection[0].showerLibraryVersion();
464  listVersion = eventInfoCollection[0].physListVersion();
465  pmom = eventInfoCollection[0].energyBins();
466  } else {
467  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
468  << " EventInfo from hardwired numbers";
469  nMomBin = 16;
470  evtPerBin = 5000;
472  libVers = 1.1;
473  listVersion = 3.6;
474  pmom = {2,3,5,7,10,15,20,30,50,75,100,150,250,350,500,1000};
475  }
476  for (int i=0; i<nMomBin; i++)
477  pmom[i] *= GeV;
478 }
const double GeV
Definition: MathUtil.h:16
std::vector< double > pmom
bool HFShowerLibrary::rInside ( double  r)
protected

Definition at line 386 of file HFShowerLibrary.cc.

References rMax, and rMin.

Referenced by fillHits().

386  {
387 
388  if (r >= rMin && r <= rMax) return true;
389  else return false;
390 }
void HFShowerLibrary::storePhoton ( int  j)
protected

Definition at line 641 of file HFShowerLibrary.cc.

References LogDebug, newForm, npe, pe, photo, and photon.

Referenced by extrapolate(), and interpolate().

641  {
642 
643  if (newForm) pe.push_back(photo->at(j));
644  else pe.push_back(photon[j]);
645 #ifdef DebugLog
646  LogDebug("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe "
647  << npe << " " << pe[npe];
648 #endif
649  npe++;
650 }
#define LogDebug(id)
HFShowerPhotonCollection pe
HFShowerPhotonCollection * photo
HFShowerPhotonCollection photon

Member Data Documentation

int HFShowerLibrary::anuePDG
private

Definition at line 81 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anumuPDG
private

Definition at line 81 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anutauPDG
private

Definition at line 81 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::applyFidCut
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::backProb
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::dphi
private

Definition at line 76 of file HFShowerLibrary.h.

Referenced by fillHits(), and initRun().

TBranch* HFShowerLibrary::emBranch
private

Definition at line 68 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

int HFShowerLibrary::emPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::epPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::etaPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

int HFShowerLibrary::evtPerBin
private

Definition at line 71 of file HFShowerLibrary.h.

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

HFFibre* HFShowerLibrary::fibre
private

Definition at line 66 of file HFShowerLibrary.h.

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

int HFShowerLibrary::gammaPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::geantinoPDG
private

Definition at line 81 of file HFShowerLibrary.h.

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

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

Definition at line 77 of file HFShowerLibrary.h.

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

TBranch * HFShowerLibrary::hadBranch
private

Definition at line 68 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

TFile* HFShowerLibrary::hf
private

Definition at line 67 of file HFShowerLibrary.h.

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

float HFShowerLibrary::libVers
private

Definition at line 72 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

float HFShowerLibrary::listVersion
private

Definition at line 72 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

bool HFShowerLibrary::newForm
private

Definition at line 70 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nMomBin
private

Definition at line 71 of file HFShowerLibrary.h.

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

int HFShowerLibrary::npe
private

Definition at line 83 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nuePDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

int HFShowerLibrary::numuPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nutauPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

HFShowerPhotonCollection HFShowerLibrary::pe
private

Definition at line 84 of file HFShowerLibrary.h.

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

HFShowerPhotonCollection* HFShowerLibrary::photo
private
HFShowerPhotonCollection HFShowerLibrary::photon
private

Definition at line 86 of file HFShowerLibrary.h.

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

int HFShowerLibrary::pi0PDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

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

Definition at line 73 of file HFShowerLibrary.h.

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

double HFShowerLibrary::probMax
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::rMax
private

Definition at line 76 of file HFShowerLibrary.h.

Referenced by initRun(), and rInside().

double HFShowerLibrary::rMin
private

Definition at line 76 of file HFShowerLibrary.h.

Referenced by initRun(), and rInside().

int HFShowerLibrary::totEvents
private

Definition at line 71 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::v3version
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

bool HFShowerLibrary::verbose
private

Definition at line 70 of file HFShowerLibrary.h.