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 | Private Types | Private Member Functions | Private Attributes
CastorShowerLibraryMaker Class Reference

#include <CastorShowerLibraryMaker.h>

Inheritance diagram for CastorShowerLibraryMaker:
SimWatcher Observer< const BeginOfJob * > Observer< const BeginOfRun * > Observer< const EndOfRun * > Observer< const BeginOfEvent * > Observer< const EndOfEvent * > Observer< const G4Step * >

Classes

struct  ShowerLib
 

Public Member Functions

 CastorShowerLibraryMaker (const edm::ParameterSet &p)
 
virtual ~CastorShowerLibraryMaker ()
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfRun * >
 Observer ()
 
void slotForUpdate (const EndOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step *iT)
 
virtual ~Observer ()
 

Private Types

typedef int ebin
 
typedef int etabin
 
typedef int phibin
 

Private Member Functions

bool FillShowerEvent (G4HCofThisEvent *, CastorShowerEvent *, int)
 
int FindEnergyBin (double e)
 
int FindEtaBin (double eta)
 
int FindPhiBin (double phi)
 
void Finish ()
 
void GetKinematics (G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
 
std::vector< G4PrimaryParticle * > GetPrimary (const EndOfEvent *)
 
void InitSLHolder (ShowerLib &)
 
bool IsSLReady ()
 
void printSLstatus (int, int, int)
 
bool SLacceptEvent (int, int, int)
 
bool SLisEBinFilled (int ebin)
 
bool SLisEtaBinFilled (int ebin, int etabin)
 
bool SLisPhiBinFilled (int ebin, int etabin, int phibin)
 
int & SLnEvtInBinE (int ebin)
 
int & SLnEvtInBinEta (int ebin, int etabin)
 
int & SLnEvtInBinPhi (int ebin, int etabin, int phibin)
 
void update (const BeginOfJob *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfRun *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step)
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

bool DoEmSL
 
bool DoHadSL
 
CastorShowerLibraryInfoemInfo
 
CastorShowerEventemShower
 
ShowerLib emSLHolder
 
int eventIndex
 
std::string eventNtFileName
 
CastorShowerLibraryInfohadInfo
 
CastorShowerEventhadShower
 
ShowerLib hadSLHolder
 
std::map< int, std::set< int > > MapOfSecondaries
 
unsigned int NPGParticle
 
std::vector< int > PGParticleIDs
 
ShowerLibSLShowerptr
 
int stepIndex
 
TFile * theFile
 
TTree * theTree
 
int verbosity
 

Additional Inherited Members

Detailed Description

Definition at line 81 of file CastorShowerLibraryMaker.h.

Member Typedef Documentation

typedef int CastorShowerLibraryMaker::ebin
private

Definition at line 95 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::etabin
private

Definition at line 96 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::phibin
private

Definition at line 97 of file CastorShowerLibraryMaker.h.

Constructor & Destructor Documentation

CastorShowerLibraryMaker::CastorShowerLibraryMaker ( const edm::ParameterSet p)

Definition at line 31 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, DoEmSL, DoHadSL, emInfo, emSLHolder, eventNtFileName, edm::ParameterSet::getParameter(), hadInfo, hadSLHolder, i, InitSLHolder(), MapOfSecondaries, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinEta, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, NPGParticle, NULL, PGParticleIDs, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and verbosity.

31  :
32  NPGParticle(0),DoHadSL(false),DoEmSL(false),
34 
35  MapOfSecondaries.clear();
36  hadInfo = NULL;
37  emInfo = NULL;
38  edm::ParameterSet p_SLM = p.getParameter<edm::ParameterSet>("CastorShowerLibraryMaker");
39  verbosity = p_SLM.getParameter<int>("Verbosity");
40  eventNtFileName = p_SLM.getParameter<std::string>("EventNtupleFileName");
41  hadSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nhadEvents");
42  emSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nemEvents");
43  hadSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLhadEnergyBins");
44  hadSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLhadEtaBins");
45  hadSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLhadPhiBins");
46  emSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLemEnergyBins");
47  emSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLemEtaBins");
48  emSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLemPhiBins");
49  PGParticleIDs = p_SLM.getParameter<std::vector<int> >("PartID");
50  NPGParticle = PGParticleIDs.size();
51 //
52  for(unsigned int i=0;i<PGParticleIDs.size();i++) {
53  switch (int(fabs(PGParticleIDs.at(i)))) {
54  case 11:
55  case 22:
56  DoEmSL = true;
57  break;
58  default:
59  DoHadSL = true;
60  }
61  }
66 
67  std::cout << "============================================================================"<<std::endl;
68  std::cout << "CastorShowerLibraryMaker:: Initialized as observer" << std::endl;
69  std::cout << " Event Ntuple will be created" << std::endl;
70  std::cout << " Event Ntuple file: " << eventNtFileName << std::endl;
71  std::cout << " Number of Hadronic events in E bins: " << hadSLHolder.nEvtPerBinE << std::endl;
72  std::cout << " Number of Hadronic events in Eta bins: " << hadSLHolder.nEvtPerBinEta << std::endl;
73  std::cout << " Number of Hadronic events in Phi bins: " << hadSLHolder.nEvtPerBinPhi << std::endl;
74  std::cout << " Number of Electromag. events in E bins: " << emSLHolder.nEvtPerBinE << std::endl;
75  std::cout << " Number of Electromag. events in Eta bins: " << emSLHolder.nEvtPerBinEta << std::endl;
76  std::cout << " Number of Electromag. events in Phi bins: " << emSLHolder.nEvtPerBinPhi << std::endl;
77  std::cout << "============================================================================"<<std::endl;
78  std::cout << std::endl;
79 
80  // Initializing the SL collections
83 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
CastorShowerLibraryInfo * hadInfo
std::map< int, std::set< int > > MapOfSecondaries
CastorShowerLibraryInfo * emInfo
tuple cout
Definition: gather_cfg.py:41
CastorShowerLibraryMaker::~CastorShowerLibraryMaker ( )
virtual

Definition at line 129 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, and Finish().

129  {
130 
131  Finish();
132 
133  std::cout << "CastorShowerLibraryMaker: End of process" << std::endl;
134 
135 }
tuple cout
Definition: gather_cfg.py:41

Member Function Documentation

bool CastorShowerLibraryMaker::FillShowerEvent ( G4HCofThisEvent *  allHC,
CastorShowerEvent shower,
int  ipart 
)
private

Definition at line 597 of file CastorShowerLibraryMaker.cc.

References end, spr::find(), CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getEntry(), CaloG4Hit::getIncidentEnergy(), CaloG4Hit::getPosition(), CaloG4Hit::getTimeSlice(), CaloG4Hit::getTrackID(), CaloG4Hit::getUnitID(), MapOfSecondaries, CastorNumberingScheme::packIndex(), position, CastorShowerEvent::setDetID(), CastorShowerEvent::setHitPosition(), CastorShowerEvent::setNhit(), CastorShowerEvent::setNphotons(), CastorShowerEvent::setPrimX(), CastorShowerEvent::setPrimY(), CastorShowerEvent::setPrimZ(), CastorShowerEvent::setTime(), cond::rpcobgas::time, CastorNumberingScheme::unpackIndex(), and verbosity.

Referenced by update().

598 {
599  // int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorPL"); // Trick to get CASTPL
600  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
601 
602  CaloG4HitCollection* theCAFI = (CaloG4HitCollection*) allHC->GetHC(CAFIid);
603 
604  CastorNumberingScheme *theCastorNumScheme = new CastorNumberingScheme();
605 
606  unsigned int volumeID=0;
607  double en_in_fi = 0.;
608  //double totalEnergy = 0;
609 
610  int nentries = theCAFI->entries();
611  edm::LogInfo("CastorShowerLibraryMaker") << "Found "<<nentries << " hits in G4HitCollection";
612  if (nentries == 0) {
613  edm::LogInfo("CastorShowerLibraryMaker") << "\n Empty G4HitCollection";
614  return false;
615  }
616 
617 // Compute Total Energy in CastorFI volume
618 /*
619  for(int ihit = 0; ihit < nentries; ihit++) {
620  CaloG4Hit* aHit = (*theCAFI)[ihit];
621  totalEnergy += aHit->getEnergyDeposit();
622  }
623 */
624  if (!shower) {
625  edm::LogInfo("CastorShowerLibraryMaker") << "Error. NULL pointer to CastorShowerEvent";
626  return false;
627  }
628 
629 // Hit position
632  int nHits;
633  nHits=0;
634  for (int ihit = 0; ihit < nentries; ihit++) {
635  CaloG4Hit* aHit = (*theCAFI)[ihit];
636  int hit_particleID = aHit->getTrackID();
637  if (MapOfSecondaries[ipart].find(hit_particleID)==MapOfSecondaries[ipart].end()) {
638  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker") << "Skipping hit from trackID " << hit_particleID;
639  continue;
640  }
641  volumeID = aHit->getUnitID();
642  double hitEnergy = aHit->getEnergyDeposit();
643  en_in_fi += aHit->getEnergyDeposit();
644  float time = aHit->getTimeSlice();
645  int zside, sector, zmodule;
646  theCastorNumScheme->unpackIndex(volumeID, zside, sector,zmodule);
647  entry = aHit->getEntry();
648  position = aHit->getPosition();
649  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker")
650  << "\n side , sector , module = " << zside << " , "
651  << sector << " , " << zmodule
652  << "\n nphotons = " << hitEnergy ;
653 
654  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker")
655  << "\n packIndex = "
656  << theCastorNumScheme->packIndex(zside, sector,zmodule);
657 
658  if(time>100.) {
659  edm::LogInfo("CastorShowerLibraryMaker")
660  << "\n nentries = " << nentries
661  << "\n time[" << ihit << "] = " << time
662  << "\n trackID[" << ihit << "] = " << aHit->getTrackID()
663  << "\n volumeID[" << ihit << "] = " << volumeID
664  << "\n nphotons[" << ihit << "] = " << hitEnergy
665  << "\n side, sector, module = " << zside <<", " << sector<<", " << zmodule
666  << "\n packIndex " << theCastorNumScheme->packIndex(zside,sector,zmodule)
667  << "\n X,Y,Z = " << entry.x() << ","<< entry.y() << "," << entry.z();
668  }
669  if(nHits==0) {
670 /*
671  edm::LogInfo("CastorShowerLibraryMaker")
672  << "\n entry(x,y,z) = (" << entry.x() << ","
673  << entry.y() << "," << entry.z() << ") \n"
674  << "\n entry(eta,phi,z) = (" << entry.eta() << ","
675  << entry.phi() << "," << entry.z() << ") \n"
676  << "\n eta , phi = "
677  << eta << " , " << phi << " \n" ;
678 */
679  shower->setPrimX(entry.x());
680  shower->setPrimY(entry.y());
681  shower->setPrimZ(entry.z());
682  }
683  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker") << "\n Incident Energy = "
684  << aHit->getIncidentEnergy() << " \n" ;
685 
686 
687 // CaloG4Hit information
688  shower->setDetID(volumeID);
689  shower->setHitPosition(position);
690  shower->setNphotons(hitEnergy);
691  shower->setTime(time);
692  nHits++;
693  }
694 // Write number of hits to CastorShowerEvent instance
695  if (nHits==0) {
696  edm::LogInfo("CastorShowerLibraryMaker") << "No hits found for this track (trackID=" << ipart << ")." << std::endl;
697  return false;
698  }
699  shower->setNhit(nHits);
700 
701  edm::LogInfo("CastorShowerLibraryMaker") << "Filling the SL vector with new element ("<<nHits<<" hits)";
702 // update the event counters
703  return true;
704 }
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
void setTime(float t)
void setPrimZ(float z)
void setDetID(unsigned int id)
double getIncidentEnergy() const
Definition: CaloG4Hit.h:65
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
#define end
Definition: vmac.h:38
std::map< int, std::set< int > > MapOfSecondaries
void setPrimY(float y)
void setPrimX(float x)
int getTrackID() const
Definition: CaloG4Hit.h:68
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void setHitPosition(Point p)
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
double getTimeSlice() const
Definition: CaloG4Hit.h:70
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:50
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
static uint32_t packIndex(int z, int sector, int zmodule)
void setNphotons(float np)
void setNhit(unsigned int i)
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
int CastorShowerLibraryMaker::FindEnergyBin ( double  e)
private

Definition at line 412 of file CastorShowerLibraryMaker.cc.

References i, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, and SLShowerptr.

Referenced by update().

412  {
413  //
414  // returns the integer index of the energy bin, taken from SLenergies vector
415  // returns -1 if ouside valid range
416  //
417  if (!SLShowerptr) {
418  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEnergyBin can be called only after BeginOfEvent\n\n";
419  throw SimG4Exception("\n\nNULL Pointer to the shower library.\n\n");
420  }
421  const std::vector<double>& SLenergies = SLShowerptr->SLEnergyBins;
422  if (energy >= SLenergies.back()) return SLenergies.size()-1;
423 
424  unsigned int i = 0;
425  for(;i<SLenergies.size()-1;i++)
426  if (energy >= SLenergies.at(i) && energy < SLenergies.at(i+1)) return (int)i;
427 
428  // now i points to the last but 1 bin
429  if (energy>=SLenergies.at(i)) return (int)i;
430  // energy outside bin range
431  return -1;
432 }
int i
Definition: DBlmapReader.cc:9
int CastorShowerLibraryMaker::FindEtaBin ( double  eta)
private

Definition at line 433 of file CastorShowerLibraryMaker.cc.

References i, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, and SLShowerptr.

Referenced by update().

433  {
434  //
435  // returns the integer index of the eta bin, taken from SLetas vector
436  // returns -1 if ouside valid range
437  //
438  if (!SLShowerptr) {
439  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEtaBin can be called only after BeginOfEvent\n\n";
440  throw SimG4Exception("\n\nNULL Pointer to the shower library.\n\n");
441  }
442  const std::vector<double>& SLetas = SLShowerptr->SLEtaBins;
443  if (eta>=SLetas.back()) return SLetas.size()-1;
444  unsigned int i = 0;
445  for(;i<SLetas.size()-1;i++)
446  if (eta >= SLetas.at(i) && eta < SLetas.at(i+1)) return (int)i;
447  // now i points to the last but 1 bin
448  if (eta>=SLetas.at(i)) return (int)i;
449  // eta outside bin range
450  return -1;
451 }
int i
Definition: DBlmapReader.cc:9
T eta() const
int CastorShowerLibraryMaker::FindPhiBin ( double  phi)
private

Definition at line 452 of file CastorShowerLibraryMaker.cc.

References i, CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and SLShowerptr.

Referenced by update().

452  {
453  //
454  // returns the integer index of the phi bin, taken from SLphis vector
455  // returns -1 if ouside valid range
456  //
457  // needs protection in case phi is outside range -pi,pi
458  //
459  if (!SLShowerptr) {
460  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindPhiBin can be called only after BeginOfEvent\n\n";
461  throw SimG4Exception("\n\nNULL Pointer to the shower library.\n\n");
462  }
463  const std::vector<double>& SLphis = SLShowerptr->SLPhiBins;
464  if (phi>=SLphis.back()) return SLphis.size()-1;
465  unsigned int i = 0;
466  for(;i<SLphis.size()-1;i++)
467  if (phi >= SLphis.at(i) && phi < SLphis.at(i+1)) return (int)i;
468  // now i points to the last but 1 bin
469  if (phi>=SLphis.at(i)) return (int)i;
470  // phi outside bin range
471  return -1;
472 }
int i
Definition: DBlmapReader.cc:9
Definition: DDAxes.h:10
void CastorShowerLibraryMaker::Finish ( )
private

Definition at line 396 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, theFile, and theTree.

Referenced by ~CastorShowerLibraryMaker().

396  {
397 
398  // if (doNTcastorevent) {
399 
400  theFile->cd();
401  theTree->Write("",TObject::kOverwrite);
402  std::cout << "CastorShowerLibraryMaker: Ntuple event written" << std::endl;
403  theFile->Close();
404  std::cout << "CastorShowerLibraryMaker: Event file closed" << std::endl;
405 
406  // Delete pointers to objects, now that TTree has been written and TFile closed
407 // delete info;
408 // delete emShower;
409 // delete hadShower;
410  // }
411 }
tuple cout
Definition: gather_cfg.py:41
void CastorShowerLibraryMaker::GetKinematics ( G4PrimaryParticle *  thePrim,
double &  px,
double &  py,
double &  pz,
double &  pInit,
double &  eta,
double &  phi 
)
private

Definition at line 502 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, funct::log(), max(), min, funct::pow(), mathSSE::sqrt(), funct::tan(), and theta().

Referenced by update().

503 {
504  px=py=pz=phi=eta=0.0;
505  if (thePrim==0) return;
506  px = thePrim->GetPx()/GeV;
507  py = thePrim->GetPy()/GeV;
508  pz = thePrim->GetPz()/GeV;
509  pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
510  if (pInit==0) {
511  std::cout << "CastorShowerLibraryMaker::GetKinematics: ERROR: primary has p=0 " << std::endl;
512  return;
513  }
514  double costheta = pz/pInit;
515  double theta = acos(std::min(std::max(costheta,double(-1.)),double(1.)));
516  eta = -log(tan(theta/2.0));
517  phi = (px==0 && py==0) ? 0 : atan2(py,px); // the recommended way of calculating phi
518  //if (px!=0) phi=atan(py/px);
519 }
Geom::Theta< T > theta() const
#define min(a, b)
Definition: mlp_lapack.h:161
T eta() const
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:28
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Log< T >::type log(const T &t)
Definition: Log.h:22
tuple cout
Definition: gather_cfg.py:41
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: DDAxes.h:10
std::vector< G4PrimaryParticle * > CastorShowerLibraryMaker::GetPrimary ( const EndOfEvent evt)
private

Definition at line 520 of file CastorShowerLibraryMaker.cc.

References i, j, gen::k, npart, NPGParticle, and PGParticleIDs.

Referenced by update().

521 {
522  // Find Primary info:
523  int trackID = 0;
524  std::vector<G4PrimaryParticle*> thePrims;
525  G4PrimaryParticle* thePrim = 0;
526  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
527  edm::LogInfo("CastorShowerLibraryMaker") << "Event has " << nvertex << " vertex";
528  if (nvertex!=1) {
529  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: no vertex";
530  return thePrims;
531  }
532 
533  for (int i = 0 ; i<nvertex; i++) {
534  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
535  if (avertex == 0) {
536  edm::LogInfo("CastorShowerLibraryMaker")
537  << "CastorShowerLibraryMaker::GetPrimary ERROR: pointer to vertex = 0";
538  continue;
539  }
540  unsigned int npart = avertex->GetNumberOfParticle();
541  if (npart!=NPGParticle) continue;
542  for (unsigned int j=0;j<npart;j++) {
543  unsigned int k = 0;
544  //int test_pID = 0;
545  trackID = j;
546  thePrim=avertex->GetPrimary(trackID);
547  while(k<NPGParticle&&PGParticleIDs.at(k++)!=thePrim->GetPDGcode()){;};
548  if (k>NPGParticle) continue; // ID not found in the requested particles
549  thePrims.push_back(thePrim);
550  }
551  }
552  return thePrims;
553 }
int i
Definition: DBlmapReader.cc:9
double npart
Definition: HydjetWrapper.h:45
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
void CastorShowerLibraryMaker::InitSLHolder ( ShowerLib showerholder)
private

Definition at line 84 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryInfo::Energy, CastorShowerLibraryInfo::Eta, i, j, gen::k, CastorShowerLibraryMaker::ShowerLib::nEvtInBinE, CastorShowerLibraryMaker::ShowerLib::nEvtInBinEta, CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, CastorShowerLibraryInfo::Phi, SLBin::setBin(), SLBin::setNBins(), SLBin::setNEvtPerBin(), SLBin::setNEvts(), CastorShowerLibraryMaker::ShowerLib::SLCollection, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, CastorShowerLibraryMaker::ShowerLib::SLInfo, and CastorShowerLibraryMaker::ShowerLib::SLPhiBins.

Referenced by CastorShowerLibraryMaker().

85 {
86  int nBinsE,nBinsEta,nBinsPhi,nEvtPerBinPhi;
87  nBinsE = showerholder.SLEnergyBins.size();
88  nBinsEta = showerholder.SLEtaBins.size();
89  nBinsPhi = showerholder.SLPhiBins.size();
90  nEvtPerBinPhi=showerholder.nEvtPerBinPhi;
91 //
92 // Info
93 //
94  showerholder.SLInfo.Energy.setNEvts(nEvtPerBinPhi*nBinsPhi*nBinsEta*nBinsE);
95  showerholder.SLInfo.Energy.setNEvtPerBin(nEvtPerBinPhi*nBinsPhi*nBinsEta);
96  showerholder.SLInfo.Energy.setNBins(nBinsE);
97  showerholder.SLInfo.Energy.setBin(showerholder.SLEnergyBins);
98 //
99  showerholder.SLInfo.Eta.setNEvts(nEvtPerBinPhi*nBinsPhi*nBinsEta);
100  showerholder.SLInfo.Eta.setNEvtPerBin(nEvtPerBinPhi*nBinsPhi);
101  showerholder.SLInfo.Eta.setNBins(nBinsEta);
102  showerholder.SLInfo.Eta.setBin(showerholder.SLEtaBins);
103 //
104  showerholder.SLInfo.Phi.setNEvts(nEvtPerBinPhi*nBinsPhi);
105  showerholder.SLInfo.Phi.setNEvtPerBin(nEvtPerBinPhi);
106  showerholder.SLInfo.Phi.setNBins(nBinsPhi);
107  showerholder.SLInfo.Phi.setBin(showerholder.SLPhiBins);
108 //
109 // Shower
110  showerholder.SLCollection.assign(nBinsE,std::vector<std::vector<std::vector<CastorShowerEvent> > >());
111  showerholder.nEvtInBinE.assign(nBinsE,0);
112  showerholder.nEvtInBinEta.assign(nBinsE,std::vector<int>(0));
113  showerholder.nEvtInBinPhi.assign(nBinsE,std::vector<std::vector<int> >());
114  for(int i=0;i<nBinsE;i++) {
115  showerholder.SLCollection.at(i).assign(nBinsEta,std::vector<std::vector<CastorShowerEvent> >());
116  showerholder.nEvtInBinEta.at(i).assign(nBinsEta,0);
117  showerholder.nEvtInBinPhi.at(i).assign(nBinsEta,std::vector<int>(0));
118  for(int j=0;j<nBinsEta;j++) {
119  showerholder.SLCollection.at(i).at(j).assign(nBinsPhi,std::vector<CastorShowerEvent>());
120  showerholder.nEvtInBinPhi.at(i).at(j).assign(nBinsPhi,0);
121  for(int k=0;k<nBinsPhi;k++)
122  showerholder.SLCollection.at(i).at(j).at(k).assign(nEvtPerBinPhi,CastorShowerEvent());
123  }
124  }
125 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
bool CastorShowerLibraryMaker::IsSLReady ( )
private

Definition at line 473 of file CastorShowerLibraryMaker.cc.

References DoEmSL, DoHadSL, emSLHolder, hadSLHolder, i, NULL, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, SLisEBinFilled(), and SLShowerptr.

Referenced by update().

474 {
475 // at this point, the pointer to the shower library should be NULL
476  if (SLShowerptr) {
477  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nIsSLReady must be called when a new event starts.\n\n";
478  throw SimG4Exception("\n\nNOT NULL Pointer to the shower library.\n\n");
479  }
480 // it is enough to check if all the energy bin is filled
481  if (DoEmSL) {
483  for(unsigned int i=0;i<SLShowerptr->SLEnergyBins.size();i++) {
484  if (!SLisEBinFilled(i)) {
486  return false;
487  }
488  }
489  }
490  if (DoHadSL) {
492  for(unsigned int i=0;i<SLShowerptr->SLEnergyBins.size();i++) {
493  if (!SLisEBinFilled(i)) {
495  return false;
496  }
497  }
498  }
500  return true;
501 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
void CastorShowerLibraryMaker::printSLstatus ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 554 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, i, j, gen::k, n, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, SLisPhiBinFilled(), SLnEvtInBinE(), CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and SLShowerptr.

Referenced by update().

555 {
556  int nBinsE =SLShowerptr->SLEnergyBins.size();
557  int nBinsEta=SLShowerptr->SLEtaBins.size();
558  int nBinsPhi=SLShowerptr->SLPhiBins.size();
559  std::vector<double> SLenergies = SLShowerptr->SLEnergyBins;
560  for(int n=0;n<11+(nBinsEta*nBinsPhi);n++) std::cout << "=";
561  std::cout << std::endl;
562  for(int i=0;i<nBinsE;i++) {
563  std::cout << "E bin " << SLenergies.at(i) << " : ";
564  for(int j=0;j<nBinsEta;j++) {
565  for(int k=0;k<nBinsPhi;k++) {
566  (SLisPhiBinFilled(i,j,k))?std::cout << "1":std::cout << "-";
567  }
568  if (j<nBinsEta-1) std::cout << "|";
569  }
570  std::cout << " (" << SLnEvtInBinE(i) << " events)";
571  std::cout << std::endl;
572  if (ebin!=i) continue;
573  std::cout << " ";
574  for(int j=0;j<nBinsEta;j++) {
575  for(int k=0;k<nBinsPhi;k++) {
576  (ebin==i&&etabin==j&&phibin==k)?std::cout << "^":std::cout << " ";
577  }
578  if (j<nBinsEta-1) std::cout << " ";
579  }
580  std::cout << std::endl;
581  }
582  for(int n=0;n<11+(nBinsEta*nBinsPhi);n++) std::cout << "=";
583  std::cout << std::endl;
584 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
tuple cout
Definition: gather_cfg.py:41
bool CastorShowerLibraryMaker::SLacceptEvent ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 585 of file CastorShowerLibraryMaker.cc.

References SLisEBinFilled(), SLisEtaBinFilled(), and SLisPhiBinFilled().

Referenced by update().

586 {
587  if (ebin<0) return false;
588  if (SLisEBinFilled(ebin)) return false;
589 
590  if (etabin<0) return false;
591  if (SLisEtaBinFilled(ebin,etabin)) return false;
592 
593  if (phibin<0) return false;
594  if (SLisPhiBinFilled(ebin,etabin,phibin)) return false;
595  return true;
596 }
bool SLisEtaBinFilled(int ebin, int etabin)
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
bool CastorShowerLibraryMaker::SLisEBinFilled ( int  ebin)
private

Definition at line 731 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinE, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE, and SLShowerptr.

Referenced by IsSLReady(), and SLacceptEvent().

732 {
733  if (!SLShowerptr) {
734  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEBinFilled can be called only after BeginOfEvent\n\n";
735  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
736  }
737  if (SLShowerptr->nEvtInBinE.at(ebin)<(int)SLShowerptr->nEvtPerBinE) return false;
738  return true;
739 }
bool CastorShowerLibraryMaker::SLisEtaBinFilled ( int  ebin,
int  etabin 
)
private

Definition at line 740 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinEta, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinEta, and SLShowerptr.

Referenced by SLacceptEvent().

741 {
742  if (!SLShowerptr) {
743  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEtaBinFilled can be called only after BeginOfEvent\n\n";
744  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
745  }
746  if (SLShowerptr->nEvtInBinEta.at(ebin).at(etabin)<(int)SLShowerptr->nEvtPerBinEta) return false;
747  return true;
748 }
std::vector< std::vector< int > > nEvtInBinEta
bool CastorShowerLibraryMaker::SLisPhiBinFilled ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 749 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, and SLShowerptr.

Referenced by printSLstatus(), and SLacceptEvent().

750 {
751  if (!SLShowerptr) {
752  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisPhiBinFilled can be called only after BeginOfEvent\n\n";
753  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
754  }
755  if (SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin)<(int)SLShowerptr->nEvtPerBinPhi) return false;
756  return true;
757 }
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
int & CastorShowerLibraryMaker::SLnEvtInBinE ( int  ebin)
private

Definition at line 705 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinE, and SLShowerptr.

Referenced by printSLstatus(), and update().

706 {
707  if (!SLShowerptr) {
708  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinE can be called only after BeginOfEvent\n\n";
709  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
710  }
711  return SLShowerptr->nEvtInBinE.at(ebin);
712 }
int & CastorShowerLibraryMaker::SLnEvtInBinEta ( int  ebin,
int  etabin 
)
private

Definition at line 714 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinEta, and SLShowerptr.

Referenced by update().

715 {
716  if (!SLShowerptr) {
717  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinEta can be called only after BeginOfEvent\n\n";
718  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
719  }
720  return SLShowerptr->nEvtInBinEta.at(ebin).at(etabin);
721 }
std::vector< std::vector< int > > nEvtInBinEta
int & CastorShowerLibraryMaker::SLnEvtInBinPhi ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 723 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi, and SLShowerptr.

Referenced by update().

724 {
725  if (!SLShowerptr) {
726  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinPhi can be called only after BeginOfEvent\n\n";
727  throw SimG4Exception("\n\nNULL Pointer to the shower library.");
728  }
729  return SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
730 }
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
void CastorShowerLibraryMaker::update ( const BeginOfJob )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 138 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), update(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

138  {
139 
140  std::cout << " CastorShowerLibraryMaker::Starting new job " << std::endl;
141 }
tuple cout
Definition: gather_cfg.py:41
void CastorShowerLibraryMaker::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 144 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, emInfo, emShower, emSLHolder, CastorShowerLibraryInfo::Energy, CastorShowerLibraryInfo::Eta, eventIndex, eventNtFileName, hadInfo, hadShower, hadSLHolder, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinEta, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, CastorShowerLibraryInfo::Phi, SLBin::setBin(), SLBin::setNBins(), SLBin::setNEvtPerBin(), SLBin::setNEvts(), CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, CastorShowerLibraryMaker::ShowerLib::SLPhiBins, split, theFile, and theTree.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

144  {
145 
146  std::cout << std::endl << "CastorShowerLibraryMaker: Starting Run"<< std::endl;
147 
148  std::cout << "CastorShowerLibraryMaker: output event root file created" << std::endl;
149 
150  TString eventfilename = eventNtFileName;
151  theFile = new TFile(eventfilename,"RECREATE");
152  theTree = new TTree("CastorCherenkovPhotons", "Cherenkov Photons");
153 
154  Int_t split = 1;
155  Int_t bsize = 64000;
157  emShower = new CastorShowerEvent();
160  // Create Branchs
161  theTree->Branch("emShowerLibInfo.", "CastorShowerLibraryInfo", &emInfo, bsize, split);
162  theTree->Branch("emParticles.", "CastorShowerEvent", &emShower, bsize, split);
163  theTree->Branch("hadShowerLibInfo.", "CastorShowerLibraryInfo", &hadInfo, bsize, split);
164  theTree->Branch("hadParticles.", "CastorShowerEvent", &hadShower, bsize, split);
165 
166 // set the Info for electromagnetic shower
167 // set the energy bins info
172 // set the eta bins info
177 // set the eta bins info
182 // The same for the hadronic shower
183 // set the energy bins info
188 // set the eta bins info
193 // set the eta bins info
198  // int flag = theTree->GetBranch("CastorShowerLibInfo")->Fill();
199  // Loop on all leaves of this branch to fill Basket buffer.
200  // The function returns the number of bytes committed to the memory basket.
201  // If a write error occurs, the number of bytes returned is -1.
202  // If no data are written, because e.g. the branch is disabled,
203  // the number of bytes returned is 0.
204  // if(flag==-1) {
205  // edm::LogInfo("CastorAnalyzer") << " WARNING: Error writing to Branch \"CastorShowerLibInfo\" \n" ;
206  // } else
207  // if(flag==0) {
208  // edm::LogInfo("CastorAnalyzer") << " WARNING: No data written to Branch \"CastorShowerLibInfo\" \n" ;
209  // }
210 
211  // Initialize "accounting" variables
212 
213  eventIndex = 0;
214 
215 }
void setNBins(unsigned int n)
void setBin(double val)
void setNEvtPerBin(unsigned int n)
CastorShowerLibraryInfo * hadInfo
CastorShowerLibraryInfo * emInfo
void setNEvts(unsigned int n)
tuple cout
Definition: gather_cfg.py:41
double split
Definition: MVATrainer.cc:139
void CastorShowerLibraryMaker::update ( const EndOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 348 of file CastorShowerLibraryMaker.cc.

References CastorShowerEvent::Clear(), emInfo, emShower, emSLHolder, hadInfo, hadShower, hadSLHolder, IsSLReady(), max(), CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, NULL, CastorShowerLibraryMaker::ShowerLib::SLCollection, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, CastorShowerLibraryMaker::ShowerLib::SLInfo, CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and theTree.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

349 {
350 // Fill the tree with the collected objects
351  if (!IsSLReady()) SimG4Exception("\n\nShower Library NOT READY.\n\n");
352 
353  unsigned int ibine,ibineta,ibinphi,ievt; // indexes for em shower
354  unsigned int jbine,jbineta,jbinphi,jevt;// indexes for had shower
355 
356  ibine=ibineta=ibinphi=ievt=jbine=jbineta=jbinphi=jevt=0;
357 
358  int nEvtInTree = 0;
359  int maxEvtInTree=std::max(hadSLHolder.nEvtPerBinE*hadSLHolder.SLEnergyBins.size(),
361 
364 
365  while(nEvtInTree<maxEvtInTree) {
366  if (emShower) emShower->Clear();
367  if (hadShower) hadShower->Clear();
368  while(ibine<emSLHolder.SLEnergyBins.size()){
369  emShower = &(emSLHolder.SLCollection.at(ibine).at(ibineta).at(ibinphi).at(ievt));
370  ievt++;
371  if (ievt==emSLHolder.nEvtPerBinPhi) {ievt=0;ibinphi++;}
372  if (ibinphi==emSLHolder.SLPhiBins.size()) {ibinphi=0;ibineta++;}
373  if (ibineta==emSLHolder.SLEtaBins.size()) {ibineta=0;ibine++;}
374  break;
375  }
376  while(jbine<hadSLHolder.SLEnergyBins.size()){
377  hadShower = &(hadSLHolder.SLCollection.at(jbine).at(jbineta).at(jbinphi).at(jevt));
378  jevt++;
379  if (jevt==hadSLHolder.nEvtPerBinPhi) {jevt=0;jbinphi++;}
380  if (jbinphi==hadSLHolder.SLPhiBins.size()) {jbinphi=0;jbineta++;}
381  if (jbineta==hadSLHolder.SLEtaBins.size()) {jbineta=0;jbine++;}
382  break;
383  }
384  theTree->Fill();
385  nEvtInTree++;
386  if (nEvtInTree==1) {
387  theTree->SetBranchStatus("emShowerLibInfo.",0);
388  theTree->SetBranchStatus("hadShowerLibInfo.",0);
389  }
390  }
391 // check if run is NULL and exit
392  if (run==NULL) throw SimG4Exception("\n\nNumber of needed trigger events reached in CastorShowerLibraryMaker\n\n");
393 }
#define NULL
Definition: scimark2.h:8
CastorShowerLibraryInfo * hadInfo
const T & max(const T &a, const T &b)
CastorShowerLibraryInfo * emInfo
void CastorShowerLibraryMaker::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 218 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, eventIndex, MapOfSecondaries, NULL, SLShowerptr, and stepIndex.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

218  {
219 
220  eventIndex++;
221  stepIndex = 0;
222 // reset the pointers to the shower objects
223  SLShowerptr = NULL;
224  MapOfSecondaries.clear();
225 //
226  std::cout << "CastorShowerLibraryMaker: Processing Event Number: " << eventIndex << std::endl;
227 }
#define NULL
Definition: scimark2.h:8
std::map< int, std::set< int > > MapOfSecondaries
tuple cout
Definition: gather_cfg.py:41
void CastorShowerLibraryMaker::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 250 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, emSLHolder, eta(), eventIndex, FillShowerEvent(), FindEnergyBin(), FindEtaBin(), FindPhiBin(), GetKinematics(), GetPrimary(), hadSLHolder, i, IsSLReady(), CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi, NULL, ExpressReco_HICollisions_FallBack::particleType, phi, printSLstatus(), CastorShowerEvent::setPrimE(), CastorShowerEvent::setPrimEta(), CastorShowerEvent::setPrimPhi(), SLacceptEvent(), CastorShowerLibraryMaker::ShowerLib::SLCollection, SLnEvtInBinE(), SLnEvtInBinEta(), SLnEvtInBinPhi(), SLShowerptr, and update().

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

250  {
251 
252 // check if the job is done!
253  if (IsSLReady()) update((EndOfRun*)NULL);
254 
255  std::cout << "CastorShowerLibraryMaker: End of Event: " << eventIndex << std::endl;
256 // Get the pointer to the primary particle
257  std::vector<G4PrimaryParticle*> thePrims = GetPrimary(evt);
258  if (thePrims.size() == 0) {
259  edm::LogInfo("CastorShowerLibraryMaker") << "No valid primary particle found. Skipping event" << std::endl;
260  return;
261  }
262 
263 // Loop over primaries
264  for(unsigned int i=0;i<thePrims.size();i++) {
265  G4PrimaryParticle* thePrim = thePrims.at(i);
266  if (!thePrim) {
267  edm::LogInfo("CastorShowerLibraryMaker") << "NULL Pointer to the primary" << std::endl;
268  continue;
269  }
270 // Check primary particle type
271  int particleType = thePrim->GetPDGcode();
272 
273 // set the pointer to the shower collection
274  std::string SLType("");
275  if (particleType==11) {
277  SLType = "Electromagnetic";
278  }
279  else {
281  SLType = "Hadronic";
282  }
283 
284 // Obtain primary particle's initial momentum (pInit)
285  double px=0., py=0., pz=0., pInit = 0., eta = 0., phi = 0.;
286 
287  GetKinematics(thePrim,px,py,pz,pInit,eta,phi);
288  edm::LogInfo("CastorShowerLibraryMaker") << "\n Primary (thePrim) trackID is " << thePrim->GetTrackID() << "\n" ;
289 
290 // Check if current event falls into any bin
291 // first: energy
292  int ebin = FindEnergyBin(pInit);
293  int etabin= FindEtaBin(eta);
294  int phibin = FindPhiBin(phi);
295  std::cout << SLType << std::endl;
296  printSLstatus(ebin,etabin,phibin);
297  if (!SLacceptEvent(ebin,etabin,phibin)) {
298  edm::LogInfo("CastorShowerLibraryMaker") << "Event not accepted for ebin="
299  << ebin<<",etabin="<<etabin<<",phibin="<<phibin<<std::endl;
300  continue;
301  }
302 //
303 // event passed. Fill the vector accordingly
304 //
305 // Look for the Hit Collection
306  edm::LogInfo("CastorShowerLibraryMaker")
307  << "\n CastorShowerLibraryMaker::update(EndOfEvent * evt) - event #"
308  << (*evt)()->GetEventID() ;
309 
310  // access to the G4 hit collections
311  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
312 /*
313  std::cout << "Number of collections : " << allHC->GetNumberOfCollections() << std::endl;
314  for(int ii = 0;ii<allHC->GetNumberOfCollections();ii++)
315  std::cout << "Name of collection " << ii << " : " << allHC->GetHC(ii)->GetName() << std::endl;
316 */
317  edm::LogInfo("CastorShowerLibraryMaker") << " update(*evt) --> accessed all HC ";
318 
319  CastorShowerEvent* shower=NULL;
320  int cur_evt_idx = SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
321  shower = &(SLShowerptr->SLCollection.at(ebin).at(etabin).at(phibin).at(cur_evt_idx));
322 
323 // Get Hit information
324  if (FillShowerEvent(allHC,shower,particleType)) {
325 // Primary particle information
326  shower->setPrimE(pInit);
327  shower->setPrimEta(eta);
328  shower->setPrimPhi(phi);
329  //shower->setPrimX(entry.x());
330  //shower->setPrimY(entry.y());
331  //shower->setPrimZ(entry.z());
332  SLnEvtInBinE(ebin)++;
333  SLnEvtInBinEta(ebin,etabin)++;
334  SLnEvtInBinPhi(ebin,etabin,phibin)++;
335  }
336  }
337 
338  //int iEvt = (*evt)()->GetEventID();
339  //double xint;
340 /*
341  if (modf(log10(iEvt),&xint)==0)
342  std::cout << " CastorShowerLibraryMaker Event " << iEvt << std::endl;
343 */
344  // std::cout << std::endl << "===>>> Done writing user histograms " << std::endl;
345 }
int i
Definition: DBlmapReader.cc:9
void setPrimEta(float eta)
int & SLnEvtInBinEta(int ebin, int etabin)
void setPrimPhi(float phi)
#define NULL
Definition: scimark2.h:8
T eta() const
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
void setPrimE(float e)
void GetKinematics(G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
int & SLnEvtInBinPhi(int ebin, int etabin, int phibin)
std::vector< G4PrimaryParticle * > GetPrimary(const EndOfEvent *)
void update(const BeginOfJob *run)
This routine will be called when the appropriate signal arrives.
bool FillShowerEvent(G4HCofThisEvent *, CastorShowerEvent *, int)
tuple cout
Definition: gather_cfg.py:41
Definition: DDAxes.h:10
void CastorShowerLibraryMaker::update ( const G4Step *  )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 230 of file CastorShowerLibraryMaker.cc.

References MapOfSecondaries.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

230  {
231  static int CurrentPrimary = 0;
232  G4Track *trk = aStep->GetTrack();
233  if (trk->GetCurrentStepNumber()==1) {
234  if (trk->GetParentID()==0) CurrentPrimary = trk->GetDynamicParticle()->GetPDGcode();
235  if (CurrentPrimary==0)
236  SimG4Exception("CastorShowerLibraryMaker::update(G4Step) -> Primary particle undefined");
237  MapOfSecondaries[CurrentPrimary].insert((int)trk->GetTrackID());
238  }
239 /*
240  if(aStep->IsFirstStepInVolume()) {
241  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::update(const G4Step * aStep):"
242  << "\n IsFirstStepInVolume , "
243  << "time = " << aStep->GetTrack()->GetGlobalTime() ;
244  }
245  stepIndex++;
246 */
247 }
std::map< int, std::set< int > > MapOfSecondaries

Member Data Documentation

bool CastorShowerLibraryMaker::DoEmSL
private

Definition at line 132 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

bool CastorShowerLibraryMaker::DoHadSL
private

Definition at line 131 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::emInfo
private

Definition at line 135 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::emShower
private

Definition at line 137 of file CastorShowerLibraryMaker.h.

Referenced by update().

ShowerLib CastorShowerLibraryMaker::emSLHolder
private

Definition at line 139 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), IsSLReady(), and update().

int CastorShowerLibraryMaker::eventIndex
private

Definition at line 170 of file CastorShowerLibraryMaker.h.

Referenced by update().

std::string CastorShowerLibraryMaker::eventNtFileName
private

Definition at line 127 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::hadInfo
private

Definition at line 136 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::hadShower
private

Definition at line 138 of file CastorShowerLibraryMaker.h.

Referenced by update().

ShowerLib CastorShowerLibraryMaker::hadSLHolder
private

Definition at line 140 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), IsSLReady(), and update().

std::map<int,std::set<int> > CastorShowerLibraryMaker::MapOfSecondaries
private

Definition at line 142 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), FillShowerEvent(), and update().

unsigned int CastorShowerLibraryMaker::NPGParticle
private

Definition at line 129 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

std::vector<int> CastorShowerLibraryMaker::PGParticleIDs
private

Definition at line 130 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

ShowerLib* CastorShowerLibraryMaker::SLShowerptr
private
int CastorShowerLibraryMaker::stepIndex
private

Definition at line 171 of file CastorShowerLibraryMaker.h.

Referenced by update().

TFile* CastorShowerLibraryMaker::theFile
private

Definition at line 167 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

TTree* CastorShowerLibraryMaker::theTree
private

Definition at line 168 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

int CastorShowerLibraryMaker::verbosity
private

Definition at line 126 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and FillShowerEvent().