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< HitgetHits (G4Step *aStep, bool &ok, 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, DDSpecificsFilter::equals, etaPDG, event(), evtPerBin, edm::hlt::Exception, fibre, alcazmumu_cfi::filter, DDFilteredView::firstChild(), edm::FileInPath::fullPath(), gammaPDG, geantinoPDG, getDDDArray(), edm::ParameterSet::getParameter(), gpar, hadBranch, hf, i, info, libVers, listVersion, loadEventInfo(), DDFilteredView::mergedSpecifics(), mergeVDriftHistosByStation::name, newForm, nMomBin, nuePDG, numuPDG, nutauPDG, photo, pi0PDG, pmom, probMax, rMax, rMin, DDSpecificsFilter::setCriteria(), 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.getUntrackedParameter<bool>("ApplyFiducialCut",true);
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);
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
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, comp_op, log_op l=AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:285
std::string fullPath() const
Definition: FileInPath.cc:171
TBranch * hadBranch
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37
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 546 of file HFShowerLibrary.cc.

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

Referenced by getHits().

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

Definition at line 631 of file HFShowerLibrary.cc.

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

Referenced by HFShowerLibrary().

633  {
634 
635 #ifdef DebugLog
636  LogDebug("HFShower") << "HFShowerLibrary:getDDDArray called for " << str
637  << " with nMin " << nmin;
638 #endif
639  DDValue value(str);
640  if (DDfetch(&sv,value)) {
641 #ifdef DebugLog
642  LogDebug("HFShower") << value;
643 #endif
644  const std::vector<double> & fvec = value.doubles();
645  int nval = fvec.size();
646  if (nmin > 0) {
647  if (nval < nmin) {
648  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
649  << " bins " << nval << " < " << nmin
650  << " ==> illegal";
651  throw cms::Exception("Unknown", "HFShowerLibrary")
652  << "nval < nmin for array " << str << "\n";
653  }
654  } else {
655  if (nval < 2) {
656  edm::LogError("HFShower") << "HFShowerLibrary : # of " << str
657  << " bins " << nval << " < 2 ==> illegal"
658  << " (nmin=" << nmin << ")";
659  throw cms::Exception("Unknown", "HFShowerLibrary")
660  << "nval < 2 for array " << str << "\n";
661  }
662  }
663  nmin = nval;
664 
665  return fvec;
666  } else {
667  edm::LogError("HFShower") << "HFShowerLibrary : cannot get array " << str;
668  throw cms::Exception("Unknown", "HFShowerLibrary")
669  << "cannot get array " << str << "\n";
670  }
671 }
#define LogDebug(id)
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
std::vector< HFShowerLibrary::Hit > HFShowerLibrary::getHits ( G4Step *  aStep,
bool &  ok,
bool  onlyLong = false 
)

Definition at line 197 of file HFShowerLibrary.cc.

References abs, anuePDG, anumuPDG, anutauPDG, applyFidCut, HFFibre::attLength(), backProb, funct::cos(), HFShowerLibrary::Hit::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, pos, HFShowerLibrary::Hit::position, probMax, alignCSCRings::r, diffTwoXMLs::r1, diffTwoXMLs::r2, rInside(), funct::sin(), HFShowerLibrary::Hit::time, HFFibre::tShift(), detailsBasic3DVector::z, hit::z, and HFFibre::zShift().

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

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

Definition at line 398 of file HFShowerLibrary.cc.

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

Referenced by extrapolate(), and interpolate().

398  {
399 
400  int nrc = record-1;
401  photon.clear();
402  photo->clear();
403  if (type > 0) {
404  if (newForm) {
405  hadBranch->SetAddress(&photo);
406  hadBranch->GetEntry(nrc+totEvents);
407  } else {
408  hadBranch->SetAddress(&photon);
409  hadBranch->GetEntry(nrc);
410  }
411  } else {
412  if (newForm) {
413  emBranch->SetAddress(&photo);
414  } else {
415  emBranch->SetAddress(&photon);
416  }
417  emBranch->GetEntry(nrc);
418  }
419 #ifdef DebugLog
420  int nPhoton = (newForm) ? photo->size() : photon.size();
421  LogDebug("HFShower") << "HFShowerLibrary::getRecord: Record " << record
422  << " of type " << type << " with " << nPhoton
423  << " photons";
424  for (int j = 0; j < nPhoton; j++)
425  if (newForm) LogDebug("HFShower") << "Photon " << j << " " << photo->at(j);
426  else LogDebug("HFShower") << "Photon " << j << " " << photon[j];
427 #endif
428 }
#define LogDebug(id)
type
Definition: HCALResponse.h:22
JetCorrectorParameters::Record record
Definition: classes.h:11
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 459 of file HFShowerLibrary.cc.

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

Referenced by getHits().

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

Definition at line 430 of file HFShowerLibrary.cc.

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

Referenced by HFShowerLibrary().

430  {
431 
432  if (branch) {
433  std::vector<HFShowerLibraryEventInfo> eventInfoCollection;
434  branch->SetAddress(&eventInfoCollection);
435  branch->GetEntry(0);
436  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
437  << " EventInfo Collection of size "
438  << eventInfoCollection.size() << " records";
439  totEvents = eventInfoCollection[0].totalEvents();
440  nMomBin = eventInfoCollection[0].numberOfBins();
441  evtPerBin = eventInfoCollection[0].eventsPerBin();
442  libVers = eventInfoCollection[0].showerLibraryVersion();
443  listVersion = eventInfoCollection[0].physListVersion();
444  pmom = eventInfoCollection[0].energyBins();
445  } else {
446  edm::LogInfo("HFShower") << "HFShowerLibrary::loadEventInfo loads "
447  << " EventInfo from hardwired numbers";
448  nMomBin = 16;
449  evtPerBin = 5000;
451  libVers = 1.1;
452  listVersion = 3.6;
453  pmom = {2,3,5,7,10,15,20,30,50,75,100,150,250,350,500,1000};
454  }
455  for (int i=0; i<nMomBin; i++)
456  pmom[i] *= GeV;
457 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > pmom
bool HFShowerLibrary::rInside ( double  r)
protected

Definition at line 392 of file HFShowerLibrary.cc.

References rMax, and rMin.

Referenced by getHits().

392  {
393 
394  if (r >= rMin && r <= rMax) return true;
395  else return false;
396 }
void HFShowerLibrary::storePhoton ( int  j)
protected

Definition at line 620 of file HFShowerLibrary.cc.

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

Referenced by extrapolate(), and interpolate().

620  {
621 
622  if (newForm) pe.push_back(photo->at(j));
623  else pe.push_back(photon[j]);
624 #ifdef DebugLog
625  LogDebug("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe "
626  << npe << " " << pe[npe];
627 #endif
628  npe++;
629 }
#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 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anumuPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

int HFShowerLibrary::anutauPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::applyFidCut
private

Definition at line 68 of file HFShowerLibrary.h.

Referenced by getHits(), and HFShowerLibrary().

double HFShowerLibrary::backProb
private

Definition at line 73 of file HFShowerLibrary.h.

Referenced by getHits(), and HFShowerLibrary().

double HFShowerLibrary::dphi
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by getHits(), and HFShowerLibrary().

TBranch* HFShowerLibrary::emBranch
private

Definition at line 66 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

int HFShowerLibrary::emPDG
private

Definition at line 77 of file HFShowerLibrary.h.

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

int HFShowerLibrary::epPDG
private

Definition at line 77 of file HFShowerLibrary.h.

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

int HFShowerLibrary::etaPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::evtPerBin
private

Definition at line 69 of file HFShowerLibrary.h.

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

HFFibre* HFShowerLibrary::fibre
private

Definition at line 64 of file HFShowerLibrary.h.

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

int HFShowerLibrary::gammaPDG
private

Definition at line 77 of file HFShowerLibrary.h.

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

int HFShowerLibrary::geantinoPDG
private

Definition at line 79 of file HFShowerLibrary.h.

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

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

Definition at line 75 of file HFShowerLibrary.h.

Referenced by getHits(), and HFShowerLibrary().

TBranch * HFShowerLibrary::hadBranch
private

Definition at line 66 of file HFShowerLibrary.h.

Referenced by getRecord(), and HFShowerLibrary().

TFile* HFShowerLibrary::hf
private

Definition at line 65 of file HFShowerLibrary.h.

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

float HFShowerLibrary::libVers
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

float HFShowerLibrary::listVersion
private

Definition at line 70 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and loadEventInfo().

bool HFShowerLibrary::newForm
private

Definition at line 68 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nMomBin
private

Definition at line 69 of file HFShowerLibrary.h.

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

int HFShowerLibrary::npe
private

Definition at line 81 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nuePDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::numuPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

int HFShowerLibrary::nutauPDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

HFShowerPhotonCollection HFShowerLibrary::pe
private

Definition at line 82 of file HFShowerLibrary.h.

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

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

Definition at line 84 of file HFShowerLibrary.h.

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

int HFShowerLibrary::pi0PDG
private

Definition at line 78 of file HFShowerLibrary.h.

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

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

Definition at line 71 of file HFShowerLibrary.h.

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

double HFShowerLibrary::probMax
private

Definition at line 73 of file HFShowerLibrary.h.

Referenced by getHits(), and HFShowerLibrary().

double HFShowerLibrary::rMax
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

double HFShowerLibrary::rMin
private

Definition at line 74 of file HFShowerLibrary.h.

Referenced by HFShowerLibrary(), and rInside().

int HFShowerLibrary::totEvents
private

Definition at line 69 of file HFShowerLibrary.h.

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

bool HFShowerLibrary::verbose
private

Definition at line 68 of file HFShowerLibrary.h.