test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (G4ThreeVector &p, 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 (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 ( 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, personalPlayback::fp, gammaPDG, geantinoPDG, edm::ParameterSet::getParameter(), GeV, hadBranch, hf, i, info(), libVers, listVersion, loadEventInfo(), newForm, nMomBin, nuePDG, numuPDG, nutauPDG, photo, pi0PDG, pmom, probMax, AlCaHLTBitMon_QueryRunRegistry::string, totEvents, and v3version.

25  : fibre(0),hf(0),
26  emBranch(0),
27  hadBranch(0),
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(0);
62  if (newForm) event = (TTree *) hf ->Get("HFSimHits");
63  else event = (TTree *) hf ->Get("Events");
64  if (event) {
65  TBranch *evtInfo(0);
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
int i
Definition: DBlmapReader.cc:9
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
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 = 0;
131  if (photo) delete photo;
132 }
HFShowerPhotonCollection * photo

Member Function Documentation

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

Definition at line 568 of file HFShowerLibrary.cc.

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

Referenced by fillHits().

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

Definition at line 223 of file HFShowerLibrary.cc.

References funct::abs(), anuePDG, anumuPDG, anutauPDG, applyFidCut, HFFibre::attLength(), backProb, funct::cos(), HFShowerLibrary::Hit::depth, HLT_25ns10e33_v2_cff::depth, dphi, emPDG, epPDG, etaPDG, create_public_lumi_plots::exp, extrapolate(), fibre, gammaPDG, geantinoPDG, gpar, i, 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(), z, hit::z, and HFFibre::zShift().

Referenced by getHits().

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

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

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

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

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

Definition at line 393 of file HFShowerLibrary.cc.

References emBranch, hadBranch, i, j, LogDebug, newForm, photo, photon, t, totEvents, and v3version.

Referenced by extrapolate(), and interpolate().

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

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

Referenced by fillHits().

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

Definition at line 452 of file HFShowerLibrary.cc.

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

Referenced by HFShowerLibrary().

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

Definition at line 387 of file HFShowerLibrary.cc.

References rMax, and rMin.

Referenced by fillHits().

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

Definition at line 642 of file HFShowerLibrary.cc.

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

Referenced by extrapolate(), and interpolate().

642  {
643 
644  if (newForm) pe.push_back(photo->at(j));
645  else pe.push_back(photon[j]);
646 #ifdef DebugLog
647  LogDebug("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe "
648  << npe << " " << pe[npe];
649 #endif
650  npe++;
651 }
#define LogDebug(id)
HFShowerPhotonCollection pe
int j
Definition: DBlmapReader.cc:9
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.