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 *theParticleTable)
 
 ~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 verbose
 

Detailed Description

Definition at line 28 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 DDFilteredView::addFilter(), anuePDG, anumuPDG, anutauPDG, applyFidCut, backProb, dphi, emBranch, emPDG, epPDG, equals, etaPDG, event(), evtPerBin, edm::hlt::Exception, fibre, alcazmumu_cfi::filter, DDFilteredView::firstChild(), gammaPDG, geantinoPDG, getDDDArray(), edm::ParameterSet::getParameter(), GeV, gpar, hadBranch, hf, i, info(), libVers, listVersion, loadEventInfo(), DDFilteredView::mergedSpecifics(), mergeVDriftHistosByStation::name, HLT_25ns14e33_v1_cff::nEta, newForm, nMomBin, HLT_25ns14e33_v1_cff::nPhi, nuePDG, numuPDG, nutauPDG, photo, pi0PDG, pmom, probMax, rMax, rMin, DDSpecificsFilter::setCriteria(), AlCaHLTBitMon_QueryRunRegistry::string, totEvents, and relativeConstraints::value.

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  edm::LogInfo("HFShower") << "HFShowerLibrary:Branch " << emName
102  << " has " << emBranch->GetEntries()
103  << " entries and Branch " << hadName
104  << " has " << hadBranch->GetEntries()
105  << " entries";
106  edm::LogInfo("HFShower") << "HFShowerLibrary::No packing information -"
107  << " Assume x, y, z are not in packed form";
108 
109  edm::LogInfo("HFShower") << "HFShowerLibrary: Maximum probability cut off "
110  << probMax << " Back propagation of light prob. "
111  << backProb ;
112 
113  G4String attribute = "ReadOutName";
114  G4String value = name;
116  DDValue ddv(attribute,value,0);
117  filter.setCriteria(ddv,DDCompOp::equals);
118  DDFilteredView fv(cpv);
119  fv.addFilter(filter);
120  bool dodet = fv.firstChild();
121  if (dodet) {
122  DDsvalues_type sv(fv.mergedSpecifics());
123 
124  //Radius (minimum and maximum)
125  int nR = -1;
126  std::vector<double> rTable = getDDDArray("rTable",sv,nR);
127  rMin = rTable[0];
128  rMax = rTable[nR-1];
129  edm::LogInfo("HFShower") << "HFShowerLibrary: rMIN " << rMin/cm
130  << " cm and rMax " << rMax/cm;
131 
132  //Delta phi
133  int nEta = -1;
134  std::vector<double> etaTable = getDDDArray("etaTable",sv,nEta);
135  int nPhi = nEta + nR - 2;
136  std::vector<double> phibin = getDDDArray("phibin",sv,nPhi);
137  dphi = phibin[nEta-1];
138  edm::LogInfo("HFShower") << "HFShowerLibrary: (Half) Phi Width of wedge "
139  << dphi/deg;
140 
141  //Special Geometry parameters
142  int ngpar = 7;
143  gpar = getDDDArray("gparHF",sv,ngpar);
144  edm::LogInfo("HFShower") << "HFShowerLibrary: " << ngpar << " gpar (cm)";
145  for (int ig=0; ig<ngpar; ig++)
146  edm::LogInfo("HFShower") << "HFShowerLibrary: gpar[" << ig << "] = "
147  << gpar[ig]/cm << " cm";
148  } else {
149  edm::LogError("HFShower") << "HFShowerLibrary: cannot get filtered "
150  << " view for " << attribute << " matching "
151  << name;
152  throw cms::Exception("Unknown", "HFShowerLibrary")
153  << "cannot match " << attribute << " to " << name <<"\n";
154  }
155 
156  fibre = new HFFibre(name, cpv, p);
158  emPDG = epPDG = gammaPDG = 0;
159  pi0PDG = etaPDG = nuePDG = numuPDG = nutauPDG= 0;
161 }
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
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
void loadEventInfo(TBranch *)
std::vector< double > gpar
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &)
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
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
TBranch * hadBranch
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32
HFShowerLibrary::~HFShowerLibrary ( )

Definition at line 163 of file HFShowerLibrary.cc.

References fibre, hf, and photo.

163  {
164  if (hf) hf->Close();
165  if (fibre) delete fibre; fibre = 0;
166  if (photo) delete photo;
167 }
HFShowerPhotonCollection * photo

Member Function Documentation

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

Definition at line 553 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().

553  {
554 
555  int nrec = int(pin/pmom[nMomBin-1]);
556  double w = (pin - pmom[nMomBin-1]*nrec)/pmom[nMomBin-1];
557  nrec++;
558 #ifdef DebugLog
559  LogDebug("HFShower") << "HFShowerLibrary:: Extrapolate for Energy " << pin
560  << " GeV with " << nMomBin << " momentum bins and "
561  << evtPerBin << " entries/bin -- total " << totEvents
562  << " using " << nrec << " records";
563 #endif
564  std::vector<int> irc(nrec);
565 
566  for (int ir=0; ir<nrec; ir++) {
567  double r = G4UniformRand();
568  irc[ir] = int(evtPerBin*0.5*r) +(nMomBin-1)*evtPerBin + 1;
569  if (irc[ir]<1) {
570  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir
571  << "] = " << irc[ir] << " now set to 1";
572  irc[ir] = 1;
573  } else if (irc[ir] > totEvents) {
574  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir
575  << "] = " << irc[ir] << " now set to "
576  << totEvents;
577  irc[ir] = totEvents;
578 #ifdef DebugLog
579  } else {
580  LogDebug("HFShower") << "HFShowerLibrary::Extrapolation use irc["
581  << ir << "] = " << irc[ir];
582 #endif
583  }
584  }
585 
586  pe.clear();
587  npe = 0;
588  int npold = 0;
589  for (int ir=0; ir<nrec; ir++) {
590  if (irc[ir]>0) {
591  getRecord (type, irc[ir]);
592  int nPhoton = (newForm) ? photo->size() : photon.size();
593  npold += nPhoton;
594  for (int j=0; j<nPhoton; j++) {
595  double r = G4UniformRand();
596  if (ir != nrec-1 || r < w) {
597  storePhoton (j);
598  }
599  }
600 #ifdef DebugLog
601  LogDebug("HFShower") << "HFShowerLibrary: Record [" << ir << "] = "
602  << irc[ir] << " npold = " << npold;
603 #endif
604  }
605  }
606 #ifdef DebugLog
607  LogDebug("HFShower") << "HFShowerLibrary:: uses " << npold << " photons";
608 #endif
609 
610  if (npe > npold || npold == 0)
611  edm::LogWarning("HFShower") << "HFShowerLibrary: Extrapolation Warning == "
612  << nrec << " records " << irc[0] << ", "
613  << irc[1] << ", ... gives a buffer of " <<npold
614  << " photons and fills " << npe
615  << " *****";
616 #ifdef DebugLog
617  else
618  LogDebug("HFShower") << "HFShowerLibrary: Extrapolation == " << nrec
619  << " records " << irc[0] << ", " << irc[1]
620  << ", ... gives a buffer of " << npold
621  << " photons and fills " << npe << " PE";
622  for (int j=0; j<npe; j++)
623  LogDebug("HFShower") << "Photon " << j << " " << pe[j];
624 #endif
625 }
#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 235 of file HFShowerLibrary.cc.

References funct::abs(), anuePDG, anumuPDG, anutauPDG, applyFidCut, HFFibre::attLength(), backProb, funct::cos(), HFShowerLibrary::Hit::depth, HLT_25ns14e33_v1_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().

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

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

Referenced by HFShowerLibrary().

640  {
641 
642 #ifdef DebugLog
643  LogDebug("HFShower") << "HFShowerLibrary:getDDDArray called for " << str
644  << " with nMin " << nmin;
645 #endif
646  DDValue value(str);
647  if (DDfetch(&sv,value)) {
648 #ifdef DebugLog
649  LogDebug("HFShower") << value;
650 #endif
651  const std::vector<double> & fvec = value.doubles();
652  int nval = fvec.size();
653  if (nmin > 0) {
654  if (nval < nmin) {
655  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
656  << " bins " << nval << " < " << nmin
657  << " ==> illegal";
658  throw cms::Exception("Unknown", "HFShowerLibrary")
659  << "nval < nmin for array " << str << "\n";
660  }
661  } else {
662  if (nval < 2) {
663  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
664  << " bins " << nval << " < 2 ==> illegal"
665  << " (nmin=" << nmin << ")";
666  throw cms::Exception("Unknown", "HFShowerLibrary")
667  << "nval < 2 for array " << str << "\n";
668  }
669  }
670  nmin = nval;
671 
672  return fvec;
673  } else {
674  edm::LogError("HFShower") << "HFShowerLibrary : cannot get array " << str;
675  throw cms::Exception("Unknown", "HFShowerLibrary")
676  << "cannot get array " << str << "\n";
677  }
678 }
#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 197 of file HFShowerLibrary.cc.

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

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

200  {
201 
202  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
203  G4StepPoint * postStepPoint = aStep->GetPostStepPoint();
204  G4Track * track = aStep->GetTrack();
205  // Get Z-direction
206  const G4DynamicParticle *aParticle = track->GetDynamicParticle();
207  G4ThreeVector momDir = aParticle->GetMomentumDirection();
208  // double mom = aParticle->GetTotalMomentum();
209 
210  G4ThreeVector hitPoint = preStepPoint->GetPosition();
211  G4String partType = track->GetDefinition()->GetParticleName();
212  int parCode = track->GetDefinition()->GetPDGEncoding();
213 
214 #ifdef DebugLog
215  G4ThreeVector localPos = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
216  double zoff = localPos.z() + 0.5*gpar[1];
217  // if (zoff < 0) zoff = 0;
218  edm::LogInfo("HFShower") << "HFShowerLibrary: getHits " << partType
219  << " of energy " << pin/GeV << " GeV"
220  << " dir.orts " << momDir.x() << ", " <<momDir.y()
221  << ", " << momDir.z() << " Pos x,y,z = "
222  << hitPoint.x() << "," << hitPoint.y() << ","
223  << hitPoint.z() << " (" << zoff
224  << ") sphi,cphi,stheta,ctheta = " << sin(momDir.phi())
225  << "," << cos(momDir.phi()) << ", " << sin(momDir.theta())
226  << "," << cos(momDir.theta());
227 #endif
228 
229  double tSlice = (postStepPoint->GetGlobalTime())/nanosecond;
230  double pin = preStepPoint->GetTotalEnergy();
231 
232  return fillHits(hitPoint,momDir,parCode,pin,ok,weight,tSlice,onlyLong);
233 }
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 405 of file HFShowerLibrary.cc.

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

Referenced by extrapolate(), and interpolate().

405  {
406 
407  int nrc = record-1;
408  photon.clear();
409  photo->clear();
410  if (type > 0) {
411  if (newForm) {
412  hadBranch->SetAddress(&photo);
413  hadBranch->GetEntry(nrc+totEvents);
414  } else {
415  hadBranch->SetAddress(&photon);
416  hadBranch->GetEntry(nrc);
417  }
418  } else {
419  if (newForm) {
420  emBranch->SetAddress(&photo);
421  } else {
422  emBranch->SetAddress(&photon);
423  }
424  emBranch->GetEntry(nrc);
425  }
426 #ifdef DebugLog
427  int nPhoton = (newForm) ? photo->size() : photon.size();
428  LogDebug("HFShower") << "HFShowerLibrary::getRecord: Record " << record
429  << " of type " << type << " with " << nPhoton
430  << " photons";
431  for (int j = 0; j < nPhoton; j++)
432  if (newForm) LogDebug("HFShower") << "Photon " << j << " " << photo->at(j);
433  else LogDebug("HFShower") << "Photon " << j << " " << photon[j];
434 #endif
435 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
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)

Definition at line 169 of file HFShowerLibrary.cc.

References anuePDG, anumuPDG, anutauPDG, emPDG, epPDG, etaPDG, gammaPDG, geantinoPDG, nuePDG, numuPDG, nutauPDG, and pi0PDG.

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

169  {
170 
171  G4String parName;
172  emPDG = theParticleTable->FindParticle(parName="e-")->GetPDGEncoding();
173  epPDG = theParticleTable->FindParticle(parName="e+")->GetPDGEncoding();
174  gammaPDG = theParticleTable->FindParticle(parName="gamma")->GetPDGEncoding();
175  pi0PDG = theParticleTable->FindParticle(parName="pi0")->GetPDGEncoding();
176  etaPDG = theParticleTable->FindParticle(parName="eta")->GetPDGEncoding();
177  nuePDG = theParticleTable->FindParticle(parName="nu_e")->GetPDGEncoding();
178  numuPDG = theParticleTable->FindParticle(parName="nu_mu")->GetPDGEncoding();
179  nutauPDG= theParticleTable->FindParticle(parName="nu_tau")->GetPDGEncoding();
180  anuePDG = theParticleTable->FindParticle(parName="anti_nu_e")->GetPDGEncoding();
181  anumuPDG= theParticleTable->FindParticle(parName="anti_nu_mu")->GetPDGEncoding();
182  anutauPDG= theParticleTable->FindParticle(parName="anti_nu_tau")->GetPDGEncoding();
183  geantinoPDG= theParticleTable->FindParticle(parName="geantino")->GetPDGEncoding();
184 #ifdef DebugLog
185  edm::LogInfo("HFShower") << "HFShowerLibrary: Particle codes for e- = "
186  << emPDG << ", e+ = " << epPDG << ", gamma = "
187  << gammaPDG << ", pi0 = " << pi0PDG << ", eta = "
188  << etaPDG << ", geantino = " << geantinoPDG
189  << "\n nu_e = " << nuePDG << ", nu_mu = "
190  << numuPDG << ", nu_tau = " << nutauPDG
191  << ", anti_nu_e = " << anuePDG << ", anti_nu_mu = "
192  << anumuPDG << ", anti_nu_tau = " << anutauPDG;
193 #endif
194 }
void HFShowerLibrary::interpolate ( int  type,
double  pin 
)
protected

Definition at line 466 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().

466  {
467 
468 #ifdef DebugLog
469  LogDebug("HFShower") << "HFShowerLibrary:: Interpolate for Energy " <<pin/GeV
470  << " GeV with " << nMomBin << " momentum bins and "
471  << evtPerBin << " entries/bin -- total " << totEvents;
472 #endif
473  int irc[2];
474  double w = 0.;
475  double r = G4UniformRand();
476 
477  if (pin<pmom[0]) {
478  w = pin/pmom[0];
479  irc[1] = int(evtPerBin*r) + 1;
480  irc[0] = 0;
481  } else {
482  for (int j=0; j<nMomBin-1; j++) {
483  if (pin >= pmom[j] && pin < pmom[j+1]) {
484  w = (pin-pmom[j])/(pmom[j+1]-pmom[j]);
485  if (j == nMomBin-2) {
486  irc[1] = int(evtPerBin*0.5*r);
487  } else {
488  irc[1] = int(evtPerBin*r);
489  }
490  irc[1] += (j+1)*evtPerBin + 1;
491  r = G4UniformRand();
492  irc[0] = int(evtPerBin*r) + 1 + j*evtPerBin;
493  if (irc[0]<0) {
494  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = "
495  << irc[0] << " now set to 0";
496  irc[0] = 0;
497  } else if (irc[0] > totEvents) {
498  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = "
499  << irc[0] << " now set to "<< totEvents;
500  irc[0] = totEvents;
501  }
502  }
503  }
504  }
505  if (irc[1]<1) {
506  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = "
507  << irc[1] << " now set to 1";
508  irc[1] = 1;
509  } else if (irc[1] > totEvents) {
510  edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = "
511  << irc[1] << " now set to "<< totEvents;
512  irc[1] = totEvents;
513  }
514 
515 #ifdef DebugLog
516  LogDebug("HFShower") << "HFShowerLibrary:: Select records " << irc[0]
517  << " and " << irc[1] << " with weights " << 1-w
518  << " and " << w;
519 #endif
520  pe.clear();
521  npe = 0;
522  int npold = 0;
523  for (int ir=0; ir < 2; ir++) {
524  if (irc[ir]>0) {
525  getRecord (type, irc[ir]);
526  int nPhoton = (newForm) ? photo->size() : photon.size();
527  npold += nPhoton;
528  for (int j=0; j<nPhoton; j++) {
529  r = G4UniformRand();
530  if ((ir==0 && r > w) || (ir > 0 && r < w)) {
531  storePhoton (j);
532  }
533  }
534  }
535  }
536 
537  if ((npe > npold || (npold == 0 && irc[0] > 0)) && !(npe == 0 && npold == 0))
538  edm::LogWarning("HFShower") << "HFShowerLibrary: Interpolation Warning =="
539  << " records " << irc[0] << " and " << irc[1]
540  << " gives a buffer of " << npold
541  << " photons and fills " << npe << " *****";
542 #ifdef DebugLog
543  else
544  LogDebug("HFShower") << "HFShowerLibrary: Interpolation == records "
545  << irc[0] << " and " << irc[1] << " gives a "
546  << "buffer of " << npold << " photons and fills "
547  << npe << " PE";
548  for (int j=0; j<npe; j++)
549  LogDebug("HFShower") << "Photon " << j << " " << pe[j];
550 #endif
551 }
#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 437 of file HFShowerLibrary.cc.

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

Referenced by HFShowerLibrary().

437  {
438 
439  if (branch) {
440  std::vector<HFShowerLibraryEventInfo> eventInfoCollection;
441  branch->SetAddress(&eventInfoCollection);
442  branch->GetEntry(0);
443  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
444  << " EventInfo Collection of size "
445  << eventInfoCollection.size() << " records";
446  totEvents = eventInfoCollection[0].totalEvents();
447  nMomBin = eventInfoCollection[0].numberOfBins();
448  evtPerBin = eventInfoCollection[0].eventsPerBin();
449  libVers = eventInfoCollection[0].showerLibraryVersion();
450  listVersion = eventInfoCollection[0].physListVersion();
451  pmom = eventInfoCollection[0].energyBins();
452  } else {
453  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
454  << " EventInfo from hardwired numbers";
455  nMomBin = 16;
456  evtPerBin = 5000;
458  libVers = 1.1;
459  listVersion = 3.6;
460  pmom = {2,3,5,7,10,15,20,30,50,75,100,150,250,350,500,1000};
461  }
462  for (int i=0; i<nMomBin; i++)
463  pmom[i] *= GeV;
464 }
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 399 of file HFShowerLibrary.cc.

References rMax, and rMin.

Referenced by fillHits().

399  {
400 
401  if (r >= rMin && r <= rMax) return true;
402  else return false;
403 }
void HFShowerLibrary::storePhoton ( int  j)
protected

Definition at line 627 of file HFShowerLibrary.cc.

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

Referenced by extrapolate(), and interpolate().

627  {
628 
629  if (newForm) pe.push_back(photo->at(j));
630  else pe.push_back(photon[j]);
631 #ifdef DebugLog
632  LogDebug("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe "
633  << npe << " " << pe[npe];
634 #endif
635  npe++;
636 }
#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 80 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anumuPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anutauPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::applyFidCut
private

Definition at line 69 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::backProb
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::dphi
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

TBranch* HFShowerLibrary::emBranch
private

Definition at line 67 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

int HFShowerLibrary::emPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::epPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::etaPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::evtPerBin
private

Definition at line 70 of file HFShowerLibrary.h.

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

HFFibre* HFShowerLibrary::fibre
private

Definition at line 65 of file HFShowerLibrary.h.

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

int HFShowerLibrary::gammaPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::geantinoPDG
private

Definition at line 80 of file HFShowerLibrary.h.

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

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

Definition at line 76 of file HFShowerLibrary.h.

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

TBranch * HFShowerLibrary::hadBranch
private

Definition at line 67 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

TFile* HFShowerLibrary::hf
private

Definition at line 66 of file HFShowerLibrary.h.

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

float HFShowerLibrary::libVers
private

Definition at line 71 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

float HFShowerLibrary::listVersion
private

Definition at line 71 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

bool HFShowerLibrary::newForm
private

Definition at line 69 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nMomBin
private

Definition at line 70 of file HFShowerLibrary.h.

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

int HFShowerLibrary::npe
private

Definition at line 82 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nuePDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::numuPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nutauPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

HFShowerPhotonCollection HFShowerLibrary::pe
private

Definition at line 83 of file HFShowerLibrary.h.

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

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

Definition at line 85 of file HFShowerLibrary.h.

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

int HFShowerLibrary::pi0PDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

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

Definition at line 72 of file HFShowerLibrary.h.

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

double HFShowerLibrary::probMax
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by fillHits(), and HFShowerLibrary().

double HFShowerLibrary::rMax
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

double HFShowerLibrary::rMin
private

Definition at line 75 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

int HFShowerLibrary::totEvents
private

Definition at line 70 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::verbose
private

Definition at line 69 of file HFShowerLibrary.h.