CMS 3D CMS Logo

CastorShowerLibraryMaker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ShowerLibraryProducer
4 // Class : CastorShowerLibraryMaker
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: P. Katsas
10 // Created: 02/2007
11 //
12 // Adapted by W. Carvalho , 02/2009
13 //
22 
25 
27 
28 #include "CLHEP/Units/GlobalSystemOfUnits.h"
29 #include "CLHEP/Units/GlobalPhysicalConstants.h"
30 
31 #include "TFile.h"
32 #include <cmath>
33 #include <iostream>
34 #include <sstream>
35 #include <iomanip>
36 #include <cstdlib>
37 
39  : NPGParticle(0),
40  DoHadSL(false),
41  DoEmSL(false),
42  DeActivatePhysicsProcess(false),
43  emShower(nullptr),
44  hadShower(nullptr) {
45  MapOfSecondaries.clear();
46  hadInfo = nullptr;
47  emInfo = nullptr;
48  edm::ParameterSet p_SLM = p.getParameter<edm::ParameterSet>("CastorShowerLibraryMaker");
49  verbosity = p_SLM.getParameter<int>("Verbosity");
50  eventNtFileName = p_SLM.getParameter<std::string>("EventNtupleFileName");
51  hadSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nhadEvents");
52  emSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nemEvents");
53  hadSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLhadEnergyBins");
54  hadSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLhadEtaBins");
55  hadSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLhadPhiBins");
56  emSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLemEnergyBins");
57  emSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLemEtaBins");
58  emSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLemPhiBins");
59  PGParticleIDs = p_SLM.getParameter<std::vector<int> >("PartID");
60  DeActivatePhysicsProcess = p_SLM.getParameter<bool>("DeActivatePhysicsProcess");
61  MaxPhi = p_SLM.getParameter<double>("SLMaxPhi");
62  MaxEta = p_SLM.getParameter<double>("SLMaxEta");
63  //
64  NPGParticle = PGParticleIDs.size();
65  for (unsigned int i = 0; i < PGParticleIDs.size(); i++) {
66  switch (std::abs(PGParticleIDs.at(i))) {
67  case 11:
68  case 22:
69  DoEmSL = true;
70  break;
71  default:
72  DoHadSL = true;
73  }
74  }
79 
80  std::cout << "============================================================================" << std::endl;
81  std::cout << "CastorShowerLibraryMaker:: Initialized as observer" << std::endl;
82  std::cout << " Event Ntuple will be created" << std::endl;
83  std::cout << " Event Ntuple file: " << eventNtFileName << std::endl;
84  std::cout << " Number of Hadronic events in E bins: " << hadSLHolder.nEvtPerBinE << std::endl;
85  std::cout << " Number of Hadronic events in Eta bins: " << hadSLHolder.nEvtPerBinEta << std::endl;
86  std::cout << " Number of Hadronic events in Phi bins: " << hadSLHolder.nEvtPerBinPhi << std::endl;
87  std::cout << " Number of Electromag. events in E bins: " << emSLHolder.nEvtPerBinE << std::endl;
88  std::cout << " Number of Electromag. events in Eta bins: " << emSLHolder.nEvtPerBinEta << std::endl;
89  std::cout << " Number of Electromag. events in Phi bins: " << emSLHolder.nEvtPerBinPhi << std::endl;
90  std::cout << "============================================================================" << std::endl;
91  std::cout << std::endl;
92 
93  // Initializing the SL collections
96 }
98  int nBinsE, nBinsEta, nBinsPhi, nEvtPerBinPhi;
99  nBinsE = showerholder.SLEnergyBins.size();
100  nBinsEta = showerholder.SLEtaBins.size();
101  nBinsPhi = showerholder.SLPhiBins.size();
102  nEvtPerBinPhi = showerholder.nEvtPerBinPhi;
103  //
104  // Info
105  //
106  showerholder.SLInfo.Energy.setNEvts(nEvtPerBinPhi * nBinsPhi * nBinsEta * nBinsE);
107  showerholder.SLInfo.Energy.setNEvtPerBin(nEvtPerBinPhi * nBinsPhi * nBinsEta);
108  showerholder.SLInfo.Energy.setNBins(nBinsE);
109  showerholder.SLInfo.Energy.setBin(showerholder.SLEnergyBins);
110  //
111  showerholder.SLInfo.Eta.setNEvts(nEvtPerBinPhi * nBinsPhi * nBinsEta);
112  showerholder.SLInfo.Eta.setNEvtPerBin(nEvtPerBinPhi * nBinsPhi);
113  showerholder.SLInfo.Eta.setNBins(nBinsEta);
114  showerholder.SLInfo.Eta.setBin(showerholder.SLEtaBins);
115  //
116  showerholder.SLInfo.Phi.setNEvts(nEvtPerBinPhi * nBinsPhi);
117  showerholder.SLInfo.Phi.setNEvtPerBin(nEvtPerBinPhi);
118  showerholder.SLInfo.Phi.setNBins(nBinsPhi);
119  showerholder.SLInfo.Phi.setBin(showerholder.SLPhiBins);
120  //
121  // Shower
122  showerholder.SLCollection.assign(nBinsE, std::vector<std::vector<std::vector<CastorShowerEvent> > >());
123  showerholder.nEvtInBinE.assign(nBinsE, 0);
124  showerholder.nEvtInBinEta.assign(nBinsE, std::vector<int>(0));
125  showerholder.nEvtInBinPhi.assign(nBinsE, std::vector<std::vector<int> >());
126  for (int i = 0; i < nBinsE; i++) {
127  showerholder.SLCollection.at(i).assign(nBinsEta, std::vector<std::vector<CastorShowerEvent> >());
128  showerholder.nEvtInBinEta.at(i).assign(nBinsEta, 0);
129  showerholder.nEvtInBinPhi.at(i).assign(nBinsEta, std::vector<int>(0));
130  for (int j = 0; j < nBinsEta; j++) {
131  showerholder.SLCollection.at(i).at(j).assign(nBinsPhi, std::vector<CastorShowerEvent>());
132  showerholder.nEvtInBinPhi.at(i).at(j).assign(nBinsPhi, 0);
133  for (int k = 0; k < nBinsPhi; k++)
134  showerholder.SLCollection.at(i).at(j).at(k).assign(nEvtPerBinPhi, CastorShowerEvent());
135  }
136  }
137 }
138 
139 //===============================================================================================
140 
142  Finish();
143 
144  std::cout << "CastorShowerLibraryMaker: End of process" << std::endl;
145 }
146 
147 //=================================================================== per EVENT
149  std::cout << " CastorShowerLibraryMaker::Starting new job " << std::endl;
150 }
151 
152 //==================================================================== per RUN
154  std::cout << std::endl << "CastorShowerLibraryMaker: Starting Run" << std::endl;
155 
156  std::cout << "CastorShowerLibraryMaker: output event root file created" << std::endl;
157 
158  TString eventfilename = eventNtFileName;
159  theFile = new TFile(eventfilename, "RECREATE");
160  theTree = new TTree("CastorCherenkovPhotons", "Cherenkov Photons");
161 
162  Int_t split = 1;
163  Int_t bsize = 64000;
165  emShower = new CastorShowerEvent();
168  // Create Branchs
169  theTree->Branch("emShowerLibInfo.", "CastorShowerLibraryInfo", &emInfo, bsize, split);
170  theTree->Branch("emParticles.", "CastorShowerEvent", &emShower, bsize, split);
171  theTree->Branch("hadShowerLibInfo.", "CastorShowerLibraryInfo", &hadInfo, bsize, split);
172  theTree->Branch("hadParticles.", "CastorShowerEvent", &hadShower, bsize, split);
173 
174  // set the Info for electromagnetic shower
175  // set the energy bins info
180  // set the eta bins info
185  // set the eta bins info
190  // The same for the hadronic shower
191  // set the energy bins info
196  // set the eta bins info
201  // set the eta bins info
206  // int flag = theTree->GetBranch("CastorShowerLibInfo")->Fill();
207  // Loop on all leaves of this branch to fill Basket buffer.
208  // The function returns the number of bytes committed to the memory basket.
209  // If a write error occurs, the number of bytes returned is -1.
210  // If no data are written, because e.g. the branch is disabled,
211  // the number of bytes returned is 0.
212  // if(flag==-1) {
213  // edm::LogInfo("CastorAnalyzer") << " WARNING: Error writing to Branch \"CastorShowerLibInfo\" \n" ;
214  // } else
215  // if(flag==0) {
216  // edm::LogInfo("CastorAnalyzer") << " WARNING: No data written to Branch \"CastorShowerLibInfo\" \n" ;
217  // }
218 
219  // Initialize "accounting" variables
220 
221  eventIndex = 0;
222 }
223 
224 //=================================================================== per EVENT
226  eventIndex++;
227  stepIndex = 0;
228  InsideCastor = false;
229  PrimaryMomentum.clear();
230  PrimaryPosition.clear();
231  int NAccepted = 0;
232  // reset the pointers to the shower objects
233  SLShowerptr = nullptr;
234  MapOfSecondaries.clear();
235  thePrims.clear();
236  G4EventManager* e_mgr = G4EventManager::GetEventManager();
237  if (IsSLReady()) {
238  printSLstatus(-1, -1, -1);
239  update((EndOfRun*)nullptr);
240  return;
241  }
242 
243  thePrims = GetPrimary((*evt)());
244  for (unsigned int i = 0; i < thePrims.size(); i++) {
245  G4PrimaryParticle* thePrim = thePrims.at(i);
246  int particleType = thePrim->GetPDGcode();
247 
248  std::string SLType("");
249  if (particleType == 11) {
251  SLType = "Electromagnetic";
252  } else {
254  SLType = "Hadronic";
255  }
256  double px = 0., py = 0., pz = 0., pInit = 0., eta = 0., phi = 0.;
257  GetKinematics(thePrim, px, py, pz, pInit, eta, phi);
258  int ebin = FindEnergyBin(pInit);
259  int etabin = FindEtaBin(eta);
260  int phibin = FindPhiBin(phi);
261  if (verbosity)
262  std::cout << "\n========================================================================"
263  << "\nBeginOfEvent: E : " << pInit << "\t bin : " << ebin << "\n Eta : " << eta
264  << "\t bin : " << etabin << "\n Phi : " << phi << "\t bin : " << phibin
265  << "\n========================================================================" << std::endl;
266 
267  if (ebin < 0 || etabin < 0 || phibin < 0)
268  continue;
269  bool accept = false;
270  if (!(SLacceptEvent(ebin, etabin, phibin))) {
271  /*
272 // To increase the chance of a particle arriving at CASTOR inside a not full bin,
273 // check if there is available phase space in the neighboring bins
274  unsigned int ebin_min = std::max(0,ebin-3);
275  unsigned int eta_bin_min = std::max(0,etabin-2);
276  unsigned int eta_bin_max = std::min(etabin,etabin+2);
277  unsigned int phi_bin_min = std::max(0,phibin-2);
278  unsigned int phi_bin_max = std::min(phibin,phibin+2);
279  for(unsigned int i_ebin=ebin_min;i_ebin<=(unsigned int)ebin;i_ebin++) {
280  for (unsigned int i_etabin=eta_bin_min;i_etabin<=eta_bin_max;i_etabin++) {
281  for (unsigned int i_phibin=phi_bin_min;i_phibin<=phi_bin_max;i_phibin++) {
282  if (SLacceptEvent((int)i_ebin,(int)i_etabin,(int)i_phibin)) {accept=true;break;}
283  }
284  if (accept) break;
285  }
286  if (accept) break;
287  }
288 */
289  if (!accept)
290  edm::LogInfo("CastorShowerLibraryMaker")
291  << "Event not accepted for ebin=" << ebin << ",etabin=" << etabin << ",phibin=" << phibin << std::endl;
292  } else {
293  accept = true;
294  }
295  if (accept)
296  NAccepted++;
297  }
298 
299  if (NAccepted == 0) {
300  const_cast<G4Event*>((*evt)())->SetEventAborted();
301  const_cast<G4Event*>((*evt)())->KeepTheEvent((G4bool) false);
302  e_mgr->AbortCurrentEvent();
303  }
304  SLShowerptr = nullptr;
305  //
306  std::cout << "CastorShowerLibraryMaker: Processing Event Number: " << eventIndex << std::endl;
307 }
308 
309 //=================================================================== per STEP
310 void CastorShowerLibraryMaker::update(const G4Step* aStep) {
311  static thread_local int CurrentPrimary = 0;
312  G4Track* trk = aStep->GetTrack();
313  int pvec_size;
314  if (trk->GetCurrentStepNumber() == 1) {
315  if (trk->GetParentID() == 0) {
316  CurrentPrimary = (int)trk->GetDynamicParticle()->GetPDGcode();
317  if (CurrentPrimary == 0)
318  SimG4Exception("CastorShowerLibraryMaker::update(G4Step) -> Primary particle undefined");
319  InsideCastor = false;
320  // Deactivate the physics process
322  G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
323  G4ProcessVector* pvec = p_mgr->GetProcessList();
324  pvec_size = pvec->size();
325  for (int i = 0; i < pvec_size; i++) {
326  G4VProcess* proc = (*pvec)(i);
327  if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
328  std::cout << "DeActivating process: " << proc->GetProcessName() << std::endl;
329  p_mgr->SetProcessActivation(proc, false);
330  }
331  }
332  }
333  // move track to z of CASTOR
334  G4ThreeVector pos;
335  pos.setZ(-14390);
336  double t = std::abs((pos.z() - trk->GetPosition().z())) / trk->GetVelocity();
337  double r = (pos.z() - trk->GetPosition().z()) / trk->GetMomentum().cosTheta();
338  pos.setX(r * sin(trk->GetMomentum().theta()) * cos(trk->GetMomentum().phi()) + trk->GetPosition().x());
339  pos.setY(r * sin(trk->GetMomentum().theta()) * sin(trk->GetMomentum().phi()) + trk->GetPosition().y());
340  trk->SetPosition(pos);
341  trk->SetGlobalTime(trk->GetGlobalTime() + t);
342  trk->AddTrackLength(r);
343  } else if (!InsideCastor) {
344  std::cout << "CastorShowerLibraryMaker::update(G4Step) -> Killing spurious track" << std::endl;
345  trk->SetTrackStatus(fKillTrackAndSecondaries);
346  return;
347  }
348  MapOfSecondaries[CurrentPrimary].insert((int)trk->GetTrackID());
349  }
350  // Checks if primary already inside CASTOR
351  std::string CurVolume = trk->GetVolume()->GetName();
352  if (!InsideCastor && (
353  //CurVolume=="C3EF"||CurVolume=="C4EF"||CurVolume=="CAEL"||
354  //CurVolume=="CAHL"||CurVolume=="C3HF"||CurVolume=="C4HF")) {
355  //CurVolume=="CastorB"||
356  CurVolume == "CAST")) {
357  //CurVolume=="CAIR")) {
358  InsideCastor = true;
359  // Activate the physics process
360  if (trk->GetParentID() == 0 && DeActivatePhysicsProcess) {
361  G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
362  G4ProcessVector* pvec = p_mgr->GetProcessList();
363  pvec_size = pvec->size();
364  for (int i = 0; i < pvec_size; i++) {
365  G4VProcess* proc = (*pvec)(i);
366  if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
367  std::cout << " Activating process: " << proc->GetProcessName() << std::endl;
368  p_mgr->SetProcessActivation(proc, true);
369  }
370  }
371  }
372  //PrimaryMomentum[CurrentPrimary]=aStep->GetPreStepPoint()->GetMomentum();
373  // check fiducial eta and phi
374  if (trk->GetMomentum().phi() > MaxPhi || trk->GetMomentum().eta() > MaxEta) {
375  trk->SetTrackStatus(fKillTrackAndSecondaries);
376  InsideCastor = false;
377  return;
378  }
379  PrimaryMomentum[CurrentPrimary] = trk->GetMomentum();
380  PrimaryPosition[CurrentPrimary] = trk->GetPosition();
381  KillSecondaries(aStep);
382  return;
383  }
384  // Kill the secondaries if they have been produced before entering castor
385  if (CurrentPrimary != 0 && trk->GetParentID() == 0 && !InsideCastor) {
386  KillSecondaries(aStep);
387  if (verbosity) {
388  double pre_phi = aStep->GetPreStepPoint()->GetMomentum().phi();
389  double cur_phi = trk->GetMomentum().phi();
390  if (pre_phi != cur_phi) {
391  std::cout << "Primary track phi : " << pre_phi << " changed in current step: " << cur_phi
392  << " by processes:" << std::endl;
393  const G4VProcess* proc = aStep->GetPreStepPoint()->GetProcessDefinedStep();
394  std::cout << " " << proc->GetProcessName() << " In volume " << CurVolume << std::endl;
395  }
396  }
397  }
398 
399  //==============================================
400  /*
401 */
402  /*
403  if(aStep->IsFirstStepInVolume()) {
404  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::update(const G4Step * aStep):"
405  << "\n IsFirstStepInVolume , "
406  << "time = " << aStep->GetTrack()->GetGlobalTime() ;
407  }
408  stepIndex++;
409 */
410 }
411 
412 //================= End of EVENT ===============
414  // check if the job is done!
415  if ((*evt)()->IsAborted()) {
416  std::cout << "\n========================================================================"
417  << "\nEndOfEvent: EVENT ABORTED"
418  << "\n========================================================================" << std::endl;
419  return;
420  }
421  //DynamicRangeFlatRandomEGunProducer* pgun = edm::DynamicRangeFlatRandomEGunKernel::get_instance();
422  //std::cout << pgun->EGunMaxE() << std::endl;
423  /*
424  std::cout << "Minimum energy in Particle Gun : " << pgun->EGunMinE() << "\n"
425  << "Maximum energy in Particle Gun : " << pgun->EGunMaxE() << std::endl;
426 */
427  if (verbosity)
428  std::cout << "CastorShowerLibraryMaker: End of Event: " << eventIndex << std::endl;
429  // Get the pointer to the primary particle
430  if (thePrims.empty()) {
431  edm::LogInfo("CastorShowerLibraryMaker") << "No valid primary particle found. Skipping event" << std::endl;
432  return;
433  }
434  // access to the G4 hit collections
435  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
436  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
437  CaloG4HitCollection* theCAFI = (CaloG4HitCollection*)allHC->GetHC(CAFIid);
438  if (verbosity)
439  edm::LogInfo("CastorShowerLibraryMaker") << " update(*evt) --> accessed all HC ";
440  edm::LogInfo("CastorShowerLibraryMaker") << "Found " << theCAFI->entries() << " hits in G4HitCollection";
441  if (theCAFI->entries() == 0) {
442  edm::LogInfo("CastorShowerLibraryMaker") << "\n Empty G4HitCollection";
443  return;
444  }
445 
446  // Loop over primaries
447  int NEvtAccepted = 0;
448  int NHitInEvent = 0;
449  for (unsigned int i = 0; i < thePrims.size(); i++) {
450  G4PrimaryParticle* thePrim = thePrims.at(i);
451  if (!thePrim) {
452  edm::LogInfo("CastorShowerLibraryMaker") << "nullptr Pointer to the primary" << std::endl;
453  continue;
454  }
455  // Check primary particle type
456  int particleType = thePrim->GetPDGcode();
457 
458  // set the pointer to the shower collection
459  std::string SLType("");
460  if (particleType == 11) {
462  SLType = "Electromagnetic";
463  } else {
465  SLType = "Hadronic";
466  }
467  edm::LogInfo("CastorShowerLibraryMaker") << "\n Primary (thePrim) trackID is " << thePrim->GetTrackID() << "\n";
468 
469  // Obtain primary particle's initial momentum (pInit)
470  double px = 0., py = 0., pz = 0., pInit = 0., eta = 0., phi = 0.;
471  GetKinematics(particleType, px, py, pz, pInit, eta, phi);
472  // Check if current event falls into any bin
473  // first: energy
474  if (pInit == 0) {
475  edm::LogInfo("CastorShowerLibraryMaker") << "Primary did not hit CASTOR" << std::endl;
476  continue;
477  }
478  int ebin = FindEnergyBin(pInit);
479  int etabin = FindEtaBin(eta);
480  int phibin = FindPhiBin(phi);
481  std::cout << SLType << std::endl;
483  if (!SLacceptEvent(ebin, etabin, phibin)) {
484  edm::LogInfo("CastorShowerLibraryMaker")
485  << "Event not accepted for ebin=" << ebin << ",etabin=" << etabin << ",phibin=" << phibin << "(" << pInit
486  << "," << eta << "," << phi << ")" << std::endl;
487  continue;
488  }
489  //
490  // event passed. Fill the vector accordingly
491  //
492  // Look for the Hit Collection
493  edm::LogInfo("CastorShowerLibraryMaker")
494  << "\n CastorShowerLibraryMaker::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID();
495 
496  /*
497  std::cout << "Number of collections : " << allHC->GetNumberOfCollections() << std::endl;
498  for(int ii = 0;ii<allHC->GetNumberOfCollections();ii++)
499  std::cout << "Name of collection " << ii << " : " << allHC->GetHC(ii)->GetName() << std::endl;
500 */
501 
502  CastorShowerEvent* shower = nullptr;
503  int cur_evt_idx = SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
504  shower = &(SLShowerptr->SLCollection.at(ebin).at(etabin).at(phibin).at(cur_evt_idx));
505 
506  // Get Hit information
507  if (FillShowerEvent(theCAFI, shower, particleType)) {
508  // Primary particle information
509  /*
510  edm::LogInfo("CastorShowerLibraryMaker") << "New SL event: Primary = " << particleType
511  << "; Energy = " << pInit << "; Eta = " << eta << "; Phi = " << phi
512  << "; Nhits = " << shower->getNhit() << std::endl;
513 */
514  shower->setPrimE(pInit);
515  shower->setPrimEta(eta);
516  shower->setPrimPhi(phi);
520  SLnEvtInBinE(ebin)++;
523  NHitInEvent += shower->getNhit();
524  NEvtAccepted++;
525  } else {
526  shower->Clear();
527  }
528  }
529  // Check for unassociated energy
530  int thecafi_entries = theCAFI->entries();
531  if (NEvtAccepted == int(thePrims.size()) && thecafi_entries != NHitInEvent) {
532  std::cout << "WARNING: Inconsistent Number of Hits -> Hits in collection: " << theCAFI->entries()
533  << " Hits in the showers: " << NHitInEvent << std::endl;
534  double miss_energy = 0;
535  double tot_energy = 0;
536  GetMissingEnergy(theCAFI, miss_energy, tot_energy);
537  if (miss_energy > 0) {
538  std::cout << "Total missing energy: " << miss_energy << " for an incident energy: " << tot_energy << std::endl;
539  }
540  }
541 
542  /*
543  for (int i=emSLHolder.SLEnergyBins.size()-1;i>0;i--) {
544  if (emSLHolder.nEvtInBinE.at(i)==(int)emSLHolder.nEvtPerBinE) {
545  std::ostringstream out;
546  out << emSLHolder.SLEnergyBins.at(i);
547  cout << "Bin Limit: " << out.str() << std::endl;
548  setenv("CASTOR_SL_PG_MAXE",out.str().c_str(),1);
549  }
550  break;
551  }
552 */
553  //int iEvt = (*evt)()->GetEventID();
554  //double xint;
555  /*
556  if (modf(log10(iEvt),&xint)==0)
557  std::cout << " CastorShowerLibraryMaker Event " << iEvt << std::endl;
558 */
559  // std::cout << std::endl << "===>>> Done writing user histograms " << std::endl;
560 }
561 
562 //========================= End of RUN ======================
564  // Fill the tree with the collected objects
565  if (!IsSLReady())
566  SimG4Exception("\n\nShower Library NOT READY.\n\n");
567 
568  unsigned int ibine, ibineta, ibinphi, ievt; // indexes for em shower
569  unsigned int jbine, jbineta, jbinphi, jevt; // indexes for had shower
570 
571  ibine = ibineta = ibinphi = ievt = jbine = jbineta = jbinphi = jevt = 0;
572 
573  int nEvtInTree = 0;
574  int nEMevt = emSLHolder.nEvtPerBinE * emSLHolder.SLEnergyBins.size();
575  int nHadevt = hadSLHolder.nEvtPerBinE * hadSLHolder.SLEnergyBins.size();
576  int maxEvtInTree = std::max(nEMevt, nHadevt);
577 
580 
581  while (nEvtInTree < maxEvtInTree) {
582  if (emShower)
583  emShower->Clear();
584  if (hadShower)
585  hadShower->Clear();
586  while (ibine < emSLHolder.SLEnergyBins.size() && nEMevt > 0) {
587  emShower = &(emSLHolder.SLCollection.at(ibine).at(ibineta).at(ibinphi).at(ievt));
588  ievt++;
589  if (ievt == emSLHolder.nEvtPerBinPhi) {
590  ievt = 0;
591  ibinphi++;
592  }
593  if (ibinphi == emSLHolder.SLPhiBins.size()) {
594  ibinphi = 0;
595  ibineta++;
596  }
597  if (ibineta == emSLHolder.SLEtaBins.size()) {
598  ibineta = 0;
599  ibine++;
600  }
601  break;
602  }
603  while (jbine < hadSLHolder.SLEnergyBins.size() && nHadevt > 0) {
604  hadShower = &(hadSLHolder.SLCollection.at(jbine).at(jbineta).at(jbinphi).at(jevt));
605  jevt++;
606  if (jevt == hadSLHolder.nEvtPerBinPhi) {
607  jevt = 0;
608  jbinphi++;
609  }
610  if (jbinphi == hadSLHolder.SLPhiBins.size()) {
611  jbinphi = 0;
612  jbineta++;
613  }
614  if (jbineta == hadSLHolder.SLEtaBins.size()) {
615  jbineta = 0;
616  jbine++;
617  }
618  break;
619  }
620  theTree->Fill();
621  nEvtInTree++;
622  if (nEvtInTree == 1) {
623  theTree->SetBranchStatus("emShowerLibInfo.", false);
624  theTree->SetBranchStatus("hadShowerLibInfo.", false);
625  }
626  }
627  // check if run is nullptr and exit
628  if (run == nullptr)
629  throw SimG4Exception("\n\nNumber of needed trigger events reached in CastorShowerLibraryMaker\n\n");
630 }
631 
632 //============================================================
634  // if (doNTcastorevent) {
635 
636  theFile->cd();
637  theTree->Write("", TObject::kOverwrite);
638  std::cout << "CastorShowerLibraryMaker: Ntuple event written" << std::endl;
639  theFile->Close();
640  std::cout << "CastorShowerLibraryMaker: Event file closed" << std::endl;
641 
642  // Delete pointers to objects, now that TTree has been written and TFile closed
643  // delete info;
644  // delete emShower;
645  // delete hadShower;
646  // }
647 }
649  //
650  // returns the integer index of the energy bin, taken from SLenergies vector
651  // returns -1 if ouside valid range
652  //
653  if (!SLShowerptr) {
654  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEnergyBin can be called only after BeginOfEvent\n\n";
655  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
656  }
657  const std::vector<double>& SLenergies = SLShowerptr->SLEnergyBins;
658  if (energy >= SLenergies.back())
659  return SLenergies.size() - 1;
660 
661  unsigned int i = 0;
662  for (; i < SLenergies.size() - 1; i++)
663  if (energy >= SLenergies.at(i) && energy < SLenergies.at(i + 1))
664  return (int)i;
665 
666  // now i points to the last but 1 bin
667  if (energy >= SLenergies.at(i))
668  return (int)i;
669  // energy outside bin range
670  return -1;
671 }
673  //
674  // returns the integer index of the eta bin, taken from SLetas vector
675  // returns -1 if ouside valid range
676  //
677  if (!SLShowerptr) {
678  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEtaBin can be called only after BeginOfEvent\n\n";
679  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
680  }
681  const std::vector<double>& SLetas = SLShowerptr->SLEtaBins;
682  if (eta >= SLetas.back())
683  return SLetas.size() - 1;
684  unsigned int i = 0;
685  for (; i < SLetas.size() - 1; i++)
686  if (eta >= SLetas.at(i) && eta < SLetas.at(i + 1))
687  return (int)i;
688  // now i points to the last but 1 bin
689  if (eta >= SLetas.at(i))
690  return (int)i;
691  // eta outside bin range
692  return -1;
693 }
695  //
696  // returns the integer index of the phi bin, taken from SLphis vector
697  // returns -1 if ouside valid range
698  //
699  // needs protection in case phi is outside range -pi,pi
700  //
701  if (!SLShowerptr) {
702  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindPhiBin can be called only after BeginOfEvent\n\n";
703  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
704  }
705  const std::vector<double>& SLphis = SLShowerptr->SLPhiBins;
706  if (phi >= SLphis.back())
707  return SLphis.size() - 1;
708  unsigned int i = 0;
709  for (; i < SLphis.size() - 1; i++)
710  if (phi >= SLphis.at(i) && phi < SLphis.at(i + 1))
711  return (int)i;
712  // now i points to the last but 1 bin
713  if (phi >= SLphis.at(i))
714  return (int)i;
715  // phi outside bin range
716  return -1;
717 }
719  // at this point, the pointer to the shower library should be nullptr
720  if (SLShowerptr) {
721  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nIsSLReady must be called when a new event starts.\n\n";
722  throw SimG4Exception("\n\nNOT nullptr Pointer to the shower library.\n\n");
723  }
724  // it is enough to check if all the energy bin is filled
725  if (DoEmSL) {
727  for (unsigned int i = 0; i < SLShowerptr->SLEnergyBins.size(); i++) {
728  if (!SLisEBinFilled(i)) {
729  SLShowerptr = nullptr;
730  return false;
731  }
732  }
733  }
734  if (DoHadSL) {
736  for (unsigned int i = 0; i < SLShowerptr->SLEnergyBins.size(); i++) {
737  if (!SLisEBinFilled(i)) {
738  SLShowerptr = nullptr;
739  return false;
740  }
741  }
742  }
743  SLShowerptr = nullptr;
744  return true;
745 }
747  int thePrim, double& px, double& py, double& pz, double& pInit, double& eta, double& phi) {
748  if (thePrim == 0)
749  return;
750  if (PrimaryMomentum.find(thePrim) == PrimaryMomentum.end())
751  return;
752  px = PrimaryMomentum[thePrim].x() / GeV;
753  py = PrimaryMomentum[thePrim].y() / GeV;
754  pz = PrimaryMomentum[thePrim].z() / GeV;
755  pInit = PrimaryMomentum[thePrim].mag() / GeV;
756  if (pInit == 0)
757  return;
758  double costheta = pz / pInit;
759  double theta = acos(std::min(std::max(costheta, double(-1.)), double(1.)));
760  eta = -log(tan(theta / 2.0));
761  phi = (px == 0 && py == 0) ? 0 : atan2(py, px); // the recommended way of calculating phi
762  phi = PrimaryMomentum[thePrim].phi();
763 }
765  G4PrimaryParticle* thePrim, double& px, double& py, double& pz, double& pInit, double& eta, double& phi) {
766  px = py = pz = phi = eta = 0.0;
767  if (thePrim == nullptr)
768  return;
769  px = thePrim->GetMomentum().x() / GeV;
770  py = thePrim->GetMomentum().y() / GeV;
771  pz = thePrim->GetMomentum().z() / GeV;
772  pInit = thePrim->GetMomentum().mag() / GeV;
773  //pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
774  if (pInit == 0)
775  return;
776  double costheta = pz / pInit;
777  double theta = acos(std::min(std::max(costheta, double(-1.)), double(1.)));
778  eta = -log(tan(theta / 2.0));
779  phi = (px == 0 && py == 0) ? 0 : atan2(py, px); // the recommended way of calculating phi
780  phi = thePrim->GetMomentum().phi();
781  //if (px!=0) phi=atan(py/px);
782 }
783 std::vector<G4PrimaryParticle*> CastorShowerLibraryMaker::GetPrimary(const G4Event* evt) {
784  // Find Primary info:
785  int trackID = 0;
786  std::vector<G4PrimaryParticle*> thePrims;
787  G4PrimaryParticle* thePrim = nullptr;
788  G4int nvertex = evt->GetNumberOfPrimaryVertex();
789  edm::LogInfo("CastorShowerLibraryMaker") << "Event has " << nvertex << " vertex";
790  if (nvertex != 1) {
791  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: no vertex";
792  return thePrims;
793  }
794 
795  for (int i = 0; i < nvertex; i++) {
796  G4PrimaryVertex* avertex = evt->GetPrimaryVertex(i);
797  if (avertex == nullptr) {
798  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: pointer to vertex = 0";
799  continue;
800  }
801  unsigned int npart = avertex->GetNumberOfParticle();
802  if (npart != NPGParticle)
803  continue;
804  for (unsigned int j = 0; j < npart; j++) {
805  unsigned int k = 0;
806  //int test_pID = 0;
807  trackID = j;
808  thePrim = avertex->GetPrimary(trackID);
809  while (k < NPGParticle && PGParticleIDs.at(k++) != thePrim->GetPDGcode()) {
810  ;
811  };
812  if (k > NPGParticle)
813  continue; // ID not found in the requested particles
814  thePrims.push_back(thePrim);
815  }
816  }
817  return thePrims;
818 }
820  if (!SLShowerptr) {
821  edm::LogInfo("CastorShowerLibraryInfo") << "nullptr shower pointer. Printing both";
822  std::cout << "Electromagnetic" << std::endl;
824  this->printSLstatus(ebin, etabin, phibin);
825  std::cout << "Hadronic" << std::endl;
827  this->printSLstatus(ebin, etabin, phibin);
828  SLShowerptr = nullptr;
829  return;
830  }
831  int nBinsE = SLShowerptr->SLEnergyBins.size();
832  int nBinsEta = SLShowerptr->SLEtaBins.size();
833  int nBinsPhi = SLShowerptr->SLPhiBins.size();
834  std::vector<double> SLenergies = SLShowerptr->SLEnergyBins;
835  for (int n = 0; n < 11 + (nBinsEta * nBinsPhi); n++)
836  std::cout << "=";
837  std::cout << std::endl;
838  for (int i = 0; i < nBinsE; i++) {
839  std::cout << "E bin " << std::setw(6) << SLenergies.at(i) << " : ";
840  for (int j = 0; j < nBinsEta; j++) {
841  for (int k = 0; k < nBinsPhi; k++) {
842  (SLisPhiBinFilled(i, j, k)) ? std::cout << "1" : std::cout << "-";
843  }
844  if (j < nBinsEta - 1)
845  std::cout << "|";
846  }
847  std::cout << " (" << SLnEvtInBinE(i) << " events)";
848  std::cout << std::endl;
849  if (ebin != i)
850  continue;
851  std::cout << " ";
852  for (int j = 0; j < nBinsEta; j++) {
853  for (int k = 0; k < nBinsPhi; k++) {
854  (ebin == i && etabin == j && phibin == k) ? std::cout << "^" : std::cout << " ";
855  }
856  if (j < nBinsEta - 1)
857  std::cout << " ";
858  }
859  std::cout << std::endl;
860  }
861  for (int n = 0; n < 11 + (nBinsEta * nBinsPhi); n++)
862  std::cout << "=";
863  std::cout << std::endl;
864 }
866  if (SLShowerptr == nullptr) {
867  edm::LogInfo("CastorShowerLibraryMaker::SLacceptEvent:") << "Error. nullptr pointer to CastorShowerEvent";
868  return false;
869  }
870  if (ebin < 0 || ebin >= int(SLShowerptr->SLEnergyBins.size()))
871  return false;
872  if (SLisEBinFilled(ebin))
873  return false;
874 
875  if (etabin < 0 || etabin >= int(SLShowerptr->SLEtaBins.size()))
876  return false;
878  return false;
879 
880  if (phibin < 0 || phibin >= int(SLShowerptr->SLPhiBins.size()))
881  return false;
883  return false;
884  return true;
885 }
887  unsigned int volumeID = 0;
888  double en_in_fi = 0.;
889  //double totalEnergy = 0;
890 
891  int nentries = theCAFI->entries();
892 
893  // Compute Total Energy in CastorFI volume
894  /*
895  for(int ihit = 0; ihit < nentries; ihit++) {
896  CaloG4Hit* aHit = (*theCAFI)[ihit];
897  totalEnergy += aHit->getEnergyDeposit();
898  }
899 */
900  if (!shower) {
901  edm::LogInfo("CastorShowerLibraryMaker") << "Error. nullptr pointer to CastorShowerEvent";
902  return false;
903  }
904 
905  CastorNumberingScheme* theCastorNumScheme = new CastorNumberingScheme();
906  // Hit position
909  int nHits;
910  nHits = 0;
911  for (int ihit = 0; ihit < nentries; ihit++) {
912  CaloG4Hit* aHit = (*theCAFI)[ihit];
913  int hit_particleID = aHit->getTrackID();
914  if (MapOfSecondaries[ipart].find(hit_particleID) == MapOfSecondaries[ipart].end()) {
915  if (verbosity)
916  edm::LogInfo("CastorShowerLibraryMaker") << "Skipping hit from trackID " << hit_particleID;
917  continue;
918  }
919  volumeID = aHit->getUnitID();
920  double hitEnergy = aHit->getEnergyDeposit();
921  en_in_fi += aHit->getEnergyDeposit();
922  float time = aHit->getTimeSlice();
923  int zside, sector, zmodule;
924  theCastorNumScheme->unpackIndex(volumeID, zside, sector, zmodule);
925  entry = aHit->getEntry();
926  position = aHit->getPosition();
927  if (verbosity)
928  edm::LogInfo("CastorShowerLibraryMaker") << "\n side , sector , module = " << zside << " , " << sector << " , "
929  << zmodule << "\n nphotons = " << hitEnergy;
930 
931  if (verbosity)
932  edm::LogInfo("CastorShowerLibraryMaker")
933  << "\n packIndex = " << theCastorNumScheme->packIndex(zside, sector, zmodule);
934 
935  if (verbosity && time > 100.) {
936  edm::LogInfo("CastorShowerLibraryMaker")
937  << "\n nentries = " << nentries << "\n time[" << ihit << "] = " << time << "\n trackID[" << ihit
938  << "] = " << aHit->getTrackID() << "\n volumeID[" << ihit << "] = " << volumeID << "\n nphotons[" << ihit
939  << "] = " << hitEnergy << "\n side, sector, module = " << zside << ", " << sector << ", " << zmodule
940  << "\n packIndex " << theCastorNumScheme->packIndex(zside, sector, zmodule) << "\n X,Y,Z = " << entry.x()
941  << "," << entry.y() << "," << entry.z();
942  }
943  if (verbosity)
944  edm::LogInfo("CastorShowerLibraryMaker") << "\n Incident Energy = " << aHit->getIncidentEnergy() << " \n";
945 
946  // CaloG4Hit information
947  shower->setDetID(volumeID);
948  shower->setHitPosition(position);
949  shower->setNphotons(hitEnergy);
950  shower->setTime(time);
951  nHits++;
952  }
953  // Write number of hits to CastorShowerEvent instance
954  if (nHits == 0) {
955  edm::LogInfo("CastorShowerLibraryMaker") << "No hits found for this track (trackID=" << ipart << ")." << std::endl;
956  if (theCastorNumScheme)
957  delete theCastorNumScheme;
958  return false;
959  }
960  shower->setNhit(nHits);
961 
962  // update the event counters
963  if (theCastorNumScheme)
964  delete theCastorNumScheme;
965  return true;
966 }
968  if (!SLShowerptr) {
969  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinE can be called only after BeginOfEvent\n\n";
970  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
971  }
972  return SLShowerptr->nEvtInBinE.at(ebin);
973 }
974 
976  if (!SLShowerptr) {
977  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinEta can be called only after BeginOfEvent\n\n";
978  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
979  }
980  return SLShowerptr->nEvtInBinEta.at(ebin).at(etabin);
981 }
982 
984  if (!SLShowerptr) {
985  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinPhi can be called only after BeginOfEvent\n\n";
986  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
987  }
988  return SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
989 }
991  if (!SLShowerptr) {
992  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEBinFilled can be called only after BeginOfEvent\n\n";
993  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
994  }
996  return false;
997  return true;
998 }
1000  if (!SLShowerptr) {
1001  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEtaBinFilled can be called only after BeginOfEvent\n\n";
1002  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
1003  }
1005  return false;
1006  return true;
1007 }
1009  if (!SLShowerptr) {
1010  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisPhiBinFilled can be called only after BeginOfEvent\n\n";
1011  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
1012  }
1014  return false;
1015  return true;
1016 }
1018  const G4TrackVector* p_sec = aStep->GetSecondary();
1019  for (int i = 0; i < int(p_sec->size()); i++) {
1020  /*if (verbosity)*/ std::cout << "Killing track ID " << p_sec->at(i)->GetTrackID() << " and its secondaries"
1021  << " Produced by Process " << p_sec->at(i)->GetCreatorProcess()->GetProcessName()
1022  << " in the volume " << aStep->GetTrack()->GetVolume()->GetName() << std::endl;
1023  p_sec->at(i)->SetTrackStatus(fKillTrackAndSecondaries);
1024  }
1025 }
1026 
1027 void CastorShowerLibraryMaker::GetMissingEnergy(CaloG4HitCollection* theCAFI, double& miss_energy, double& tot_energy) {
1028  // Get the total deposited energy and the one from hit not associated to a primary
1029  miss_energy = 0;
1030  tot_energy = 0;
1031  int nhits = theCAFI->entries();
1032  for (int ihit = 0; ihit < nhits; ihit++) {
1033  int id = (*theCAFI)[ihit]->getTrackID();
1034  tot_energy += (*theCAFI)[ihit]->getEnergyDeposit();
1035  int hit_prim = 0;
1036  for (unsigned int i = 0; i < thePrims.size(); i++) {
1037  int particleType = thePrims.at(i)->GetPDGcode();
1039  hit_prim = particleType;
1040  }
1041  if (hit_prim == 0) {
1042  std::cout << "Track ID " << id << " produced a hit which is not associated with a primary." << std::endl;
1043  miss_energy += (*theCAFI)[ihit]->getEnergyDeposit();
1044  }
1045  }
1046 }
CastorShowerEvent::setHitPosition
void setHitPosition(const Point &p)
Definition: CastorShowerEvent.h:39
CastorShowerLibraryMaker::thePrims
std::vector< G4PrimaryParticle * > thePrims
Definition: CastorShowerLibraryMaker.h:133
CastorShowerEvent::setTime
void setTime(float t)
Definition: CastorShowerEvent.h:41
DDAxes::y
CastorShowerLibraryMaker::PGParticleIDs
std::vector< int > PGParticleIDs
Definition: CastorShowerLibraryMaker.h:128
CaloG4Hit::getTrackID
int getTrackID() const
Definition: CaloG4Hit.h:64
mps_fire.i
i
Definition: mps_fire.py:428
CastorShowerLibraryMaker::FillShowerEvent
bool FillShowerEvent(CaloG4HitCollection *, CastorShowerEvent *, int)
Definition: CastorShowerLibraryMaker.cc:886
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE
unsigned int nEvtPerBinE
Definition: CastorShowerLibraryMaker.h:104
CastorShowerLibraryMaker::etabin
int etabin
Definition: CastorShowerLibraryMaker.h:95
CastorShowerLibraryMaker::SLShowerptr
ShowerLib * SLShowerptr
Definition: CastorShowerLibraryMaker.h:142
CastorShowerEvent::getNhit
unsigned int getNhit()
Definition: CastorShowerEvent.h:50
CastorShowerLibraryMaker::SLnEvtInBinPhi
int & SLnEvtInBinPhi(int ebin, int etabin, int phibin)
Definition: CastorShowerLibraryMaker.cc:983
min
T min(T a, T b)
Definition: MathUtil.h:58
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
CaloG4HitCollection.h
CaloG4Hit::getUnitID
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
CastorShowerLibraryMaker::ShowerLib::nEvtPerBinEta
unsigned int nEvtPerBinEta
Definition: CastorShowerLibraryMaker.h:105
mps_splice.entry
entry
Definition: mps_splice.py:68
CastorShowerEvent::setPrimEta
void setPrimEta(float eta)
Definition: CastorShowerEvent.h:43
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
SimG4Exception
Definition: SimG4Exception.h:13
CastorShowerEvent::setPrimZ
void setPrimZ(float z)
Definition: CastorShowerEvent.h:47
CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi
unsigned int nEvtPerBinPhi
Definition: CastorShowerLibraryMaker.h:106
CastorNumberingScheme::packIndex
static uint32_t packIndex(int z, int sector, int zmodule)
Definition: CastorNumberingScheme.cc:178
CastorShowerLibraryMaker::printSLstatus
void printSLstatus(int, int, int)
Definition: CastorShowerLibraryMaker.cc:819
CastorShowerLibraryMaker::ebin
int ebin
Definition: CastorShowerLibraryMaker.h:94
CastorShowerLibraryMaker::~CastorShowerLibraryMaker
~CastorShowerLibraryMaker() override
Definition: CastorShowerLibraryMaker.cc:141
protons_cff.time
time
Definition: protons_cff.py:35
SLBin::setBin
void setBin(double val)
Definition: CastorShowerLibraryInfo.h:24
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
CastorShowerLibraryMaker::IsSLReady
bool IsSLReady()
Definition: CastorShowerLibraryMaker.cc:718
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
CaloG4Hit::getTimeSlice
double getTimeSlice() const
Definition: CaloG4Hit.h:67
CastorShowerLibraryMaker::InsideCastor
bool InsideCastor
Definition: CastorShowerLibraryMaker.h:131
CastorShowerLibraryMaker::eventNtFileName
std::string eventNtFileName
Definition: CastorShowerLibraryMaker.h:125
CastorShowerEvent::setDetID
void setDetID(unsigned int id)
Definition: CastorShowerEvent.h:38
CastorShowerLibraryMaker::GetKinematics
void GetKinematics(G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
Definition: CastorShowerLibraryMaker.cc:764
npart
double npart
Definition: HydjetWrapper.h:46
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CastorShowerLibraryMaker::emSLHolder
ShowerLib emSLHolder
Definition: CastorShowerLibraryMaker.h:140
CastorShowerLibraryMaker::hadSLHolder
ShowerLib hadSLHolder
Definition: CastorShowerLibraryMaker.h:141
CastorShowerLibraryMaker::SLnEvtInBinEta
int & SLnEvtInBinEta(int ebin, int etabin)
Definition: CastorShowerLibraryMaker.cc:975
EDMException.h
CastorShowerLibraryMaker::SLisEBinFilled
bool SLisEBinFilled(int ebin)
Definition: CastorShowerLibraryMaker.cc:990
CastorNumberingScheme.h
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
CastorShowerLibraryInfo
Definition: CastorShowerLibraryInfo.h:41
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
CastorShowerLibraryMaker::stepIndex
int stepIndex
Definition: CastorShowerLibraryMaker.h:178
SLBin::setNEvtPerBin
void setNEvtPerBin(unsigned int n)
Definition: CastorShowerLibraryInfo.h:23
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
CastorShowerLibraryMaker::MaxPhi
double MaxPhi
Definition: CastorShowerLibraryMaker.h:149
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
PVValHelper::eta
Definition: PVValidationHelpers.h:70
hgcalTowerMapProducer_cfi.nBinsEta
nBinsEta
Definition: hgcalTowerMapProducer_cfi.py:10
CaloG4Hit::getEnergyDeposit
double getEnergyDeposit() const
Definition: CaloG4Hit.h:78
CastorShowerLibraryMaker::KillSecondaries
void KillSecondaries(const G4Step *step)
Definition: CastorShowerLibraryMaker.cc:1017
mps_fire.end
end
Definition: mps_fire.py:242
DDAxes::z
CastorShowerLibraryMaker::verbosity
int verbosity
Definition: CastorShowerLibraryMaker.h:124
CastorShowerLibraryMaker::ShowerLib::SLInfo
CastorShowerLibraryInfo SLInfo
Definition: CastorShowerLibraryMaker.h:99
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
BeginOfJob
Definition: BeginOfJob.h:8
dqmdumpme.k
k
Definition: dqmdumpme.py:60
CastorShowerLibraryMaker::update
void update(const BeginOfJob *run) override
This routine will be called when the appropriate signal arrives.
Definition: CastorShowerLibraryMaker.cc:148
CastorShowerLibraryMaker::SLisEtaBinFilled
bool SLisEtaBinFilled(int ebin, int etabin)
Definition: CastorShowerLibraryMaker.cc:999
nhits
Definition: HIMultiTrackSelector.h:42
EndOfEvent
Definition: EndOfEvent.h:6
CastorShowerLibraryMaker::hadInfo
CastorShowerLibraryInfo * hadInfo
Definition: CastorShowerLibraryMaker.h:137
CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
Definition: CastorShowerLibraryMaker.h:109
SimG4Exception.h
CastorShowerLibraryMaker::emInfo
CastorShowerLibraryInfo * emInfo
Definition: CastorShowerLibraryMaker.h:136
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ValidateTausOnZEEFastSim_cff.proc
proc
Definition: ValidateTausOnZEEFastSim_cff.py:6
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CastorNumberingScheme
Definition: CastorNumberingScheme.h:30
PVValHelper::phi
Definition: PVValidationHelpers.h:69
CastorShowerLibraryMaker::FindEnergyBin
int FindEnergyBin(double e)
Definition: CastorShowerLibraryMaker.cc:648
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
CastorShowerLibraryMaker::MapOfSecondaries
std::map< int, std::set< int > > MapOfSecondaries
Definition: CastorShowerLibraryMaker.h:143
CastorShowerLibraryMaker::ShowerLib::nEvtInBinEta
std::vector< std::vector< int > > nEvtInBinEta
Definition: CastorShowerLibraryMaker.h:108
CastorShowerLibraryMaker::ShowerLib
Definition: CastorShowerLibraryMaker.h:98
CastorShowerEvent
Definition: CastorShowerEvent.h:15
CastorNumberingScheme::unpackIndex
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
Definition: CastorNumberingScheme.cc:193
CastorShowerEvent::setPrimY
void setPrimY(float y)
Definition: CastorShowerEvent.h:46
GeV
const double GeV
Definition: MathUtil.h:16
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
CastorShowerLibraryMaker::PrimaryPosition
std::map< int, G4ThreeVector > PrimaryPosition
Definition: CastorShowerLibraryMaker.h:147
CastorShowerLibraryMaker::PrimaryMomentum
std::map< int, G4ThreeVector > PrimaryMomentum
Definition: CastorShowerLibraryMaker.h:146
CastorShowerLibraryMaker::hadShower
CastorShowerEvent * hadShower
Definition: CastorShowerLibraryMaker.h:139
CastorShowerLibraryMaker::DeActivatePhysicsProcess
bool DeActivatePhysicsProcess
Definition: CastorShowerLibraryMaker.h:132
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
CastorShowerLibraryMaker::theTree
TTree * theTree
Definition: CastorShowerLibraryMaker.h:175
createfilelist.int
int
Definition: createfilelist.py:10
SLBin::setNEvts
void setNEvts(unsigned int n)
Definition: CastorShowerLibraryInfo.h:21
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
BeginOfEvent
Definition: BeginOfEvent.h:6
CastorShowerLibraryMaker::emShower
CastorShowerEvent * emShower
Definition: CastorShowerLibraryMaker.h:138
BeginOfRun
Definition: BeginOfRun.h:6
EndOfRun
Definition: EndOfRun.h:6
CastorShowerLibraryMaker::eventIndex
int eventIndex
Definition: CastorShowerLibraryMaker.h:177
CastorShowerLibraryMaker::SLacceptEvent
bool SLacceptEvent(int, int, int)
Definition: CastorShowerLibraryMaker.cc:865
CaloG4Hit
Definition: CaloG4Hit.h:32
CaloG4Hit::getPosition
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
CastorShowerLibraryMaker::FindEtaBin
int FindEtaBin(double eta)
Definition: CastorShowerLibraryMaker.cc:672
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CastorShowerLibraryMaker::ShowerLib::SLPhiBins
std::vector< double > SLPhiBins
Definition: CastorShowerLibraryMaker.h:103
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CastorShowerEvent::setPrimX
void setPrimX(float x)
Definition: CastorShowerEvent.h:45
DDAxes::phi
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
CastorShowerLibraryInfo::Phi
SLBin Phi
Definition: CastorShowerLibraryInfo.h:51
CastorShowerLibraryMaker::SLisPhiBinFilled
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
Definition: CastorShowerLibraryMaker.cc:1008
CastorShowerEvent::setNphotons
void setNphotons(float np)
Definition: CastorShowerEvent.h:40
writedatasetfile.run
run
Definition: writedatasetfile.py:27
CastorShowerLibraryMaker::ShowerLib::SLEtaBins
std::vector< double > SLEtaBins
Definition: CastorShowerLibraryMaker.h:102
CastorShowerLibraryMaker::GetMissingEnergy
void GetMissingEnergy(CaloG4HitCollection *, double &, double &)
Definition: CastorShowerLibraryMaker.cc:1027
CastorShowerLibraryMaker::NPGParticle
unsigned int NPGParticle
Definition: CastorShowerLibraryMaker.h:127
CastorShowerLibraryMaker::DoEmSL
bool DoEmSL
Definition: CastorShowerLibraryMaker.h:130
CastorShowerEvent::setPrimE
void setPrimE(float e)
Definition: CastorShowerEvent.h:42
CastorShowerLibraryMaker::FindPhiBin
int FindPhiBin(double phi)
Definition: CastorShowerLibraryMaker.cc:694
CaloG4Hit::getIncidentEnergy
double getIncidentEnergy() const
Definition: CaloG4Hit.h:61
CastorShowerLibraryMaker::theFile
TFile * theFile
Definition: CastorShowerLibraryMaker.h:174
CastorShowerLibraryMaker::MaxEta
double MaxEta
Definition: CastorShowerLibraryMaker.h:148
CastorShowerLibraryMaker::InitSLHolder
void InitSLHolder(ShowerLib &)
Definition: CastorShowerLibraryMaker.cc:97
Point3D.h
CastorShowerLibraryMaker::GetPrimary
std::vector< G4PrimaryParticle * > GetPrimary(const G4Event *)
Definition: CastorShowerLibraryMaker.cc:783
CastorShowerLibraryMaker::CastorShowerLibraryMaker
CastorShowerLibraryMaker(const edm::ParameterSet &p)
Definition: CastorShowerLibraryMaker.cc:38
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CaloG4HitCollection
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
Definition: CaloG4HitCollection.h:11
Exception.h
Phase1L1TJetProducer_cfi.nBinsPhi
nBinsPhi
Definition: Phase1L1TJetProducer_cfi.py:23
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
CastorShowerEvent::Clear
void Clear(Option_t *option="") override
Definition: CastorShowerEvent.cc:11
CastorShowerLibraryInfo::Eta
SLBin Eta
Definition: CastorShowerLibraryInfo.h:50
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CastorShowerEvent::setNhit
void setNhit(unsigned int i)
Definition: CastorShowerEvent.h:37
CastorShowerLibraryMaker::SLnEvtInBinE
int & SLnEvtInBinE(int ebin)
Definition: CastorShowerLibraryMaker.cc:967
CastorShowerLibraryMaker::DoHadSL
bool DoHadSL
Definition: CastorShowerLibraryMaker.h:129
PbPb_ZMuSkimMuonDPG_cff.particleType
particleType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:27
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CastorShowerLibraryMaker::ShowerLib::SLEnergyBins
std::vector< double > SLEnergyBins
Definition: CastorShowerLibraryMaker.h:101
CastorShowerLibraryMaker.h
CastorShowerLibraryMaker::ShowerLib::SLCollection
SLBin3D SLCollection
Definition: CastorShowerLibraryMaker.h:100
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
CastorShowerLibraryMaker::ShowerLib::nEvtInBinE
std::vector< int > nEvtInBinE
Definition: CastorShowerLibraryMaker.h:107
CaloG4Hit.h
CastorShowerLibraryInfo::Energy
SLBin Energy
Definition: CastorShowerLibraryInfo.h:49
CastorShowerLibraryMaker::Finish
void Finish()
Definition: CastorShowerLibraryMaker.cc:633
CaloG4Hit::getEntry
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:46
CastorShowerLibraryMaker::phibin
int phibin
Definition: CastorShowerLibraryMaker.h:96
CastorShowerEvent.h
SLBin::setNBins
void setNBins(unsigned int n)
Definition: CastorShowerLibraryInfo.h:22
CastorShowerEvent::setPrimPhi
void setPrimPhi(float phi)
Definition: CastorShowerEvent.h:44