CMS 3D CMS Logo

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)
 
 ~CastorShowerLibraryMaker () override
 
- 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 (CaloG4HitCollection *, 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)
 
void GetKinematics (int, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
 
void GetMissingEnergy (CaloG4HitCollection *, double &, double &)
 
std::vector< G4PrimaryParticle * > GetPrimary (const G4Event *)
 
void InitSLHolder (ShowerLib &)
 
bool IsSLReady ()
 
void KillSecondaries (const G4Step *step)
 
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) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

bool DeActivatePhysicsProcess
 
bool DoEmSL
 
bool DoHadSL
 
CastorShowerLibraryInfoemInfo
 
CastorShowerEventemShower
 
ShowerLib emSLHolder
 
int eventIndex
 
std::string eventNtFileName
 
CastorShowerLibraryInfohadInfo
 
CastorShowerEventhadShower
 
ShowerLib hadSLHolder
 
bool InsideCastor
 
std::map< int, std::set< int > > MapOfSecondaries
 
double MaxEta
 
double MaxPhi
 
unsigned int NPGParticle
 
std::vector< int > PGParticleIDs
 
std::map< int, G4ThreeVector > PrimaryMomentum
 
std::map< int, G4ThreeVector > PrimaryPosition
 
ShowerLibSLShowerptr
 
int stepIndex
 
TFile * theFile
 
std::vector< G4PrimaryParticle * > thePrims
 
TTree * theTree
 
int verbosity
 

Additional Inherited Members

Detailed Description

Definition at line 82 of file CastorShowerLibraryMaker.h.

Member Typedef Documentation

typedef int CastorShowerLibraryMaker::ebin
private

Definition at line 94 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::etabin
private

Definition at line 95 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::phibin
private

Definition at line 96 of file CastorShowerLibraryMaker.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file CastorShowerLibraryMaker.cc.

References funct::abs(), gather_cfg::cout, DeActivatePhysicsProcess, DoEmSL, DoHadSL, emInfo, emSLHolder, eventNtFileName, edm::ParameterSet::getParameter(), hadInfo, hadSLHolder, mps_fire::i, InitSLHolder(), MapOfSecondaries, MaxEta, MaxPhi, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinE, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinEta, CastorShowerLibraryMaker::ShowerLib::nEvtPerBinPhi, NPGParticle, PGParticleIDs, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, CastorShowerLibraryMaker::ShowerLib::SLPhiBins, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity.

39  : NPGParticle(0),
40  DoHadSL(false),
41  DoEmSL(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 }
T getParameter(std::string const &) const
std::map< int, std::set< int > > MapOfSecondaries
CastorShowerLibraryInfo * hadInfo
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CastorShowerLibraryInfo * emInfo
CastorShowerLibraryMaker::~CastorShowerLibraryMaker ( )
override

Definition at line 141 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, and Finish().

141  {
142  Finish();
143 
144  std::cout << "CastorShowerLibraryMaker: End of process" << std::endl;
145 }

Member Function Documentation

bool CastorShowerLibraryMaker::FillShowerEvent ( CaloG4HitCollection theCAFI,
CastorShowerEvent shower,
int  ipart 
)
private

Definition at line 883 of file CastorShowerLibraryMaker.cc.

References end, mps_splice::entry, 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::setTime(), ntuplemaker::time, CastorNumberingScheme::unpackIndex(), verbosity, and ecaldqm::zside().

Referenced by update().

883  {
884  unsigned int volumeID = 0;
885  double en_in_fi = 0.;
886  //double totalEnergy = 0;
887 
888  int nentries = theCAFI->entries();
889 
890  // Compute Total Energy in CastorFI volume
891  /*
892  for(int ihit = 0; ihit < nentries; ihit++) {
893  CaloG4Hit* aHit = (*theCAFI)[ihit];
894  totalEnergy += aHit->getEnergyDeposit();
895  }
896 */
897  if (!shower) {
898  edm::LogInfo("CastorShowerLibraryMaker") << "Error. nullptr pointer to CastorShowerEvent";
899  return false;
900  }
901 
902  CastorNumberingScheme* theCastorNumScheme = new CastorNumberingScheme();
903  // Hit position
906  int nHits;
907  nHits = 0;
908  for (int ihit = 0; ihit < nentries; ihit++) {
909  CaloG4Hit* aHit = (*theCAFI)[ihit];
910  int hit_particleID = aHit->getTrackID();
911  if (MapOfSecondaries[ipart].find(hit_particleID) == MapOfSecondaries[ipart].end()) {
912  if (verbosity)
913  edm::LogInfo("CastorShowerLibraryMaker") << "Skipping hit from trackID " << hit_particleID;
914  continue;
915  }
916  volumeID = aHit->getUnitID();
917  double hitEnergy = aHit->getEnergyDeposit();
918  en_in_fi += aHit->getEnergyDeposit();
919  float time = aHit->getTimeSlice();
920  int zside, sector, zmodule;
921  theCastorNumScheme->unpackIndex(volumeID, zside, sector, zmodule);
922  entry = aHit->getEntry();
923  position = aHit->getPosition();
924  if (verbosity)
925  edm::LogInfo("CastorShowerLibraryMaker") << "\n side , sector , module = " << zside << " , " << sector << " , "
926  << zmodule << "\n nphotons = " << hitEnergy;
927 
928  if (verbosity)
929  edm::LogInfo("CastorShowerLibraryMaker")
930  << "\n packIndex = " << theCastorNumScheme->packIndex(zside, sector, zmodule);
931 
932  if (verbosity && time > 100.) {
933  edm::LogInfo("CastorShowerLibraryMaker")
934  << "\n nentries = " << nentries << "\n time[" << ihit << "] = " << time << "\n trackID[" << ihit
935  << "] = " << aHit->getTrackID() << "\n volumeID[" << ihit << "] = " << volumeID << "\n nphotons[" << ihit
936  << "] = " << hitEnergy << "\n side, sector, module = " << zside << ", " << sector << ", " << zmodule
937  << "\n packIndex " << theCastorNumScheme->packIndex(zside, sector, zmodule) << "\n X,Y,Z = " << entry.x()
938  << "," << entry.y() << "," << entry.z();
939  }
940  if (verbosity)
941  edm::LogInfo("CastorShowerLibraryMaker") << "\n Incident Energy = " << aHit->getIncidentEnergy() << " \n";
942 
943  // CaloG4Hit information
944  shower->setDetID(volumeID);
945  shower->setHitPosition(position);
946  shower->setNphotons(hitEnergy);
947  shower->setTime(time);
948  nHits++;
949  }
950  // Write number of hits to CastorShowerEvent instance
951  if (nHits == 0) {
952  edm::LogInfo("CastorShowerLibraryMaker") << "No hits found for this track (trackID=" << ipart << ")." << std::endl;
953  if (theCastorNumScheme)
954  delete theCastorNumScheme;
955  return false;
956  }
957  shower->setNhit(nHits);
958 
959  // update the event counters
960  if (theCastorNumScheme)
961  delete theCastorNumScheme;
962  return true;
963 }
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
void setTime(float t)
void setDetID(unsigned int id)
double getIncidentEnergy() const
Definition: CaloG4Hit.h:61
int zside(DetId const &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
std::map< int, std::set< int > > MapOfSecondaries
#define end
Definition: vmac.h:39
int getTrackID() const
Definition: CaloG4Hit.h:64
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
static int position[264][3]
Definition: ReadPGInfo.cc:289
double getTimeSlice() const
Definition: CaloG4Hit.h:66
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:46
uint32_t getUnitID() const
Definition: CaloG4Hit.h:65
static uint32_t packIndex(int z, int sector, int zmodule)
void setNphotons(float np)
void setNhit(unsigned int i)
void setHitPosition(const Point &p)
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
int CastorShowerLibraryMaker::FindEnergyBin ( double  e)
private

Definition at line 645 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

645  {
646  //
647  // returns the integer index of the energy bin, taken from SLenergies vector
648  // returns -1 if ouside valid range
649  //
650  if (!SLShowerptr) {
651  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEnergyBin can be called only after BeginOfEvent\n\n";
652  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
653  }
654  const std::vector<double>& SLenergies = SLShowerptr->SLEnergyBins;
655  if (energy >= SLenergies.back())
656  return SLenergies.size() - 1;
657 
658  unsigned int i = 0;
659  for (; i < SLenergies.size() - 1; i++)
660  if (energy >= SLenergies.at(i) && energy < SLenergies.at(i + 1))
661  return (int)i;
662 
663  // now i points to the last but 1 bin
664  if (energy >= SLenergies.at(i))
665  return (int)i;
666  // energy outside bin range
667  return -1;
668 }
int CastorShowerLibraryMaker::FindEtaBin ( double  eta)
private

Definition at line 669 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

669  {
670  //
671  // returns the integer index of the eta bin, taken from SLetas vector
672  // returns -1 if ouside valid range
673  //
674  if (!SLShowerptr) {
675  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEtaBin can be called only after BeginOfEvent\n\n";
676  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
677  }
678  const std::vector<double>& SLetas = SLShowerptr->SLEtaBins;
679  if (eta >= SLetas.back())
680  return SLetas.size() - 1;
681  unsigned int i = 0;
682  for (; i < SLetas.size() - 1; i++)
683  if (eta >= SLetas.at(i) && eta < SLetas.at(i + 1))
684  return (int)i;
685  // now i points to the last but 1 bin
686  if (eta >= SLetas.at(i))
687  return (int)i;
688  // eta outside bin range
689  return -1;
690 }
int CastorShowerLibraryMaker::FindPhiBin ( double  phi)
private

Definition at line 691 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

691  {
692  //
693  // returns the integer index of the phi bin, taken from SLphis vector
694  // returns -1 if ouside valid range
695  //
696  // needs protection in case phi is outside range -pi,pi
697  //
698  if (!SLShowerptr) {
699  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindPhiBin can be called only after BeginOfEvent\n\n";
700  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
701  }
702  const std::vector<double>& SLphis = SLShowerptr->SLPhiBins;
703  if (phi >= SLphis.back())
704  return SLphis.size() - 1;
705  unsigned int i = 0;
706  for (; i < SLphis.size() - 1; i++)
707  if (phi >= SLphis.at(i) && phi < SLphis.at(i + 1))
708  return (int)i;
709  // now i points to the last but 1 bin
710  if (phi >= SLphis.at(i))
711  return (int)i;
712  // phi outside bin range
713  return -1;
714 }
void CastorShowerLibraryMaker::Finish ( )
private

Definition at line 630 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, theFile, and theTree.

Referenced by ~CastorShowerLibraryMaker().

630  {
631  // if (doNTcastorevent) {
632 
633  theFile->cd();
634  theTree->Write("", TObject::kOverwrite);
635  std::cout << "CastorShowerLibraryMaker: Ntuple event written" << std::endl;
636  theFile->Close();
637  std::cout << "CastorShowerLibraryMaker: Event file closed" << std::endl;
638 
639  // Delete pointers to objects, now that TTree has been written and TFile closed
640  // delete info;
641  // delete emShower;
642  // delete hadShower;
643  // }
644 }
void CastorShowerLibraryMaker::GetKinematics ( G4PrimaryParticle *  thePrim,
double &  px,
double &  py,
double &  pz,
double &  pInit,
double &  eta,
double &  phi 
)
private

Definition at line 761 of file CastorShowerLibraryMaker.cc.

References GeV, dqm-mbProfile::log, SiStripPI::max, min(), funct::tan(), and theta().

Referenced by update().

762  {
763  px = py = pz = phi = eta = 0.0;
764  if (thePrim == nullptr)
765  return;
766  px = thePrim->GetMomentum().x() / GeV;
767  py = thePrim->GetMomentum().y() / GeV;
768  pz = thePrim->GetMomentum().z() / GeV;
769  pInit = thePrim->GetMomentum().mag() / GeV;
770  //pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
771  if (pInit == 0)
772  return;
773  double costheta = pz / pInit;
774  double theta = acos(std::min(std::max(costheta, double(-1.)), double(1.)));
775  eta = -log(tan(theta / 2.0));
776  phi = (px == 0 && py == 0) ? 0 : atan2(py, px); // the recommended way of calculating phi
777  phi = thePrim->GetMomentum().phi();
778  //if (px!=0) phi=atan(py/px);
779 }
const double GeV
Definition: MathUtil.h:16
Geom::Theta< T > theta() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
void CastorShowerLibraryMaker::GetKinematics ( int  thePrim,
double &  px,
double &  py,
double &  pz,
double &  pInit,
double &  eta,
double &  phi 
)
private

Definition at line 743 of file CastorShowerLibraryMaker.cc.

References GeV, dqm-mbProfile::log, SiStripPI::max, min(), PrimaryMomentum, funct::tan(), and theta().

744  {
745  if (thePrim == 0)
746  return;
747  if (PrimaryMomentum.find(thePrim) == PrimaryMomentum.end())
748  return;
749  px = PrimaryMomentum[thePrim].x() / GeV;
750  py = PrimaryMomentum[thePrim].y() / GeV;
751  pz = PrimaryMomentum[thePrim].z() / GeV;
752  pInit = PrimaryMomentum[thePrim].mag() / GeV;
753  if (pInit == 0)
754  return;
755  double costheta = pz / pInit;
756  double theta = acos(std::min(std::max(costheta, double(-1.)), double(1.)));
757  eta = -log(tan(theta / 2.0));
758  phi = (px == 0 && py == 0) ? 0 : atan2(py, px); // the recommended way of calculating phi
759  phi = PrimaryMomentum[thePrim].phi();
760 }
const double GeV
Definition: MathUtil.h:16
Geom::Theta< T > theta() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
std::map< int, G4ThreeVector > PrimaryMomentum
void CastorShowerLibraryMaker::GetMissingEnergy ( CaloG4HitCollection theCAFI,
double &  miss_energy,
double &  tot_energy 
)
private

Definition at line 1024 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, end, spr::find(), mps_fire::i, MapOfSecondaries, PbPb_ZMuSkimMuonDPG_cff::particleType, and thePrims.

Referenced by update().

1024  {
1025  // Get the total deposited energy and the one from hit not associated to a primary
1026  miss_energy = 0;
1027  tot_energy = 0;
1028  for (int ihit = 0; ihit < theCAFI->entries(); ihit++) {
1029  int id = (*theCAFI)[ihit]->getTrackID();
1030  tot_energy += (*theCAFI)[ihit]->getEnergyDeposit();
1031  int hit_prim = 0;
1032  for (unsigned int i = 0; i < thePrims.size(); i++) {
1033  int particleType = thePrims.at(i)->GetPDGcode();
1034  if (MapOfSecondaries[particleType].find(id) != MapOfSecondaries[particleType].end())
1035  hit_prim = particleType;
1036  }
1037  if (hit_prim == 0) {
1038  std::cout << "Track ID " << id << " produced a hit which is not associated with a primary." << std::endl;
1039  miss_energy += (*theCAFI)[ihit]->getEnergyDeposit();
1040  }
1041  }
1042 }
std::vector< G4PrimaryParticle * > thePrims
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< int, std::set< int > > MapOfSecondaries
#define end
Definition: vmac.h:39
std::vector< G4PrimaryParticle * > CastorShowerLibraryMaker::GetPrimary ( const G4Event *  evt)
private

Definition at line 780 of file CastorShowerLibraryMaker.cc.

References mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, npart, NPGParticle, PGParticleIDs, and thePrims.

Referenced by update().

780  {
781  // Find Primary info:
782  int trackID = 0;
783  std::vector<G4PrimaryParticle*> thePrims;
784  G4PrimaryParticle* thePrim = nullptr;
785  G4int nvertex = evt->GetNumberOfPrimaryVertex();
786  edm::LogInfo("CastorShowerLibraryMaker") << "Event has " << nvertex << " vertex";
787  if (nvertex != 1) {
788  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: no vertex";
789  return thePrims;
790  }
791 
792  for (int i = 0; i < nvertex; i++) {
793  G4PrimaryVertex* avertex = evt->GetPrimaryVertex(i);
794  if (avertex == nullptr) {
795  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: pointer to vertex = 0";
796  continue;
797  }
798  unsigned int npart = avertex->GetNumberOfParticle();
799  if (npart != NPGParticle)
800  continue;
801  for (unsigned int j = 0; j < npart; j++) {
802  unsigned int k = 0;
803  //int test_pID = 0;
804  trackID = j;
805  thePrim = avertex->GetPrimary(trackID);
806  while (k < NPGParticle && PGParticleIDs.at(k++) != thePrim->GetPDGcode()) {
807  ;
808  };
809  if (k > NPGParticle)
810  continue; // ID not found in the requested particles
811  thePrims.push_back(thePrim);
812  }
813  }
814  return thePrims;
815 }
std::vector< G4PrimaryParticle * > thePrims
double npart
Definition: HydjetWrapper.h:46
void CastorShowerLibraryMaker::InitSLHolder ( ShowerLib showerholder)
private

Definition at line 97 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryInfo::Energy, CastorShowerLibraryInfo::Eta, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, hgcalTowerMapProducer_cfi::nBinsEta, hgcalTowerMapProducer_cfi::nBinsPhi, 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().

97  {
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 }
bool CastorShowerLibraryMaker::IsSLReady ( )
private

Definition at line 715 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

715  {
716  // at this point, the pointer to the shower library should be nullptr
717  if (SLShowerptr) {
718  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nIsSLReady must be called when a new event starts.\n\n";
719  throw SimG4Exception("\n\nNOT nullptr Pointer to the shower library.\n\n");
720  }
721  // it is enough to check if all the energy bin is filled
722  if (DoEmSL) {
724  for (unsigned int i = 0; i < SLShowerptr->SLEnergyBins.size(); i++) {
725  if (!SLisEBinFilled(i)) {
726  SLShowerptr = nullptr;
727  return false;
728  }
729  }
730  }
731  if (DoHadSL) {
733  for (unsigned int i = 0; i < SLShowerptr->SLEnergyBins.size(); i++) {
734  if (!SLisEBinFilled(i)) {
735  SLShowerptr = nullptr;
736  return false;
737  }
738  }
739  }
740  SLShowerptr = nullptr;
741  return true;
742 }
void CastorShowerLibraryMaker::KillSecondaries ( const G4Step *  step)
private

Definition at line 1014 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, mps_fire::i, and createfilelist::int.

Referenced by update().

1014  {
1015  const G4TrackVector* p_sec = aStep->GetSecondary();
1016  for (int i = 0; i < int(p_sec->size()); i++) {
1017  /*if (verbosity)*/ std::cout << "Killing track ID " << p_sec->at(i)->GetTrackID() << " and its secondaries"
1018  << " Produced by Process " << p_sec->at(i)->GetCreatorProcess()->GetProcessName()
1019  << " in the volume " << aStep->GetTrack()->GetVolume()->GetName() << std::endl;
1020  p_sec->at(i)->SetTrackStatus(fKillTrackAndSecondaries);
1021  }
1022 }
void CastorShowerLibraryMaker::printSLstatus ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 816 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, emSLHolder, hadSLHolder, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, dqmiodumpmetadata::n, hgcalTowerMapProducer_cfi::nBinsEta, hgcalTowerMapProducer_cfi::nBinsPhi, CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, SLisPhiBinFilled(), SLnEvtInBinE(), CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and SLShowerptr.

Referenced by update().

816  {
817  if (!SLShowerptr) {
818  edm::LogInfo("CastorShowerLibraryInfo") << "nullptr shower pointer. Printing both";
819  std::cout << "Electromagnetic" << std::endl;
821  this->printSLstatus(ebin, etabin, phibin);
822  std::cout << "Hadronic" << std::endl;
824  this->printSLstatus(ebin, etabin, phibin);
825  SLShowerptr = nullptr;
826  return;
827  }
828  int nBinsE = SLShowerptr->SLEnergyBins.size();
829  int nBinsEta = SLShowerptr->SLEtaBins.size();
830  int nBinsPhi = SLShowerptr->SLPhiBins.size();
831  std::vector<double> SLenergies = SLShowerptr->SLEnergyBins;
832  for (int n = 0; n < 11 + (nBinsEta * nBinsPhi); n++)
833  std::cout << "=";
834  std::cout << std::endl;
835  for (int i = 0; i < nBinsE; i++) {
836  std::cout << "E bin " << std::setw(6) << SLenergies.at(i) << " : ";
837  for (int j = 0; j < nBinsEta; j++) {
838  for (int k = 0; k < nBinsPhi; k++) {
839  (SLisPhiBinFilled(i, j, k)) ? std::cout << "1" : std::cout << "-";
840  }
841  if (j < nBinsEta - 1)
842  std::cout << "|";
843  }
844  std::cout << " (" << SLnEvtInBinE(i) << " events)";
845  std::cout << std::endl;
846  if (ebin != i)
847  continue;
848  std::cout << " ";
849  for (int j = 0; j < nBinsEta; j++) {
850  for (int k = 0; k < nBinsPhi; k++) {
851  (ebin == i && etabin == j && phibin == k) ? std::cout << "^" : std::cout << " ";
852  }
853  if (j < nBinsEta - 1)
854  std::cout << " ";
855  }
856  std::cout << std::endl;
857  }
858  for (int n = 0; n < 11 + (nBinsEta * nBinsPhi); n++)
859  std::cout << "=";
860  std::cout << std::endl;
861 }
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
bool CastorShowerLibraryMaker::SLacceptEvent ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 862 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryMaker::ShowerLib::SLEnergyBins, CastorShowerLibraryMaker::ShowerLib::SLEtaBins, SLisEBinFilled(), SLisEtaBinFilled(), SLisPhiBinFilled(), CastorShowerLibraryMaker::ShowerLib::SLPhiBins, and SLShowerptr.

Referenced by update().

862  {
863  if (SLShowerptr == nullptr) {
864  edm::LogInfo("CastorShowerLibraryMaker::SLacceptEvent:") << "Error. nullptr pointer to CastorShowerEvent";
865  return false;
866  }
867  if (ebin < 0 || ebin >= int(SLShowerptr->SLEnergyBins.size()))
868  return false;
869  if (SLisEBinFilled(ebin))
870  return false;
871 
872  if (etabin < 0 || etabin >= int(SLShowerptr->SLEtaBins.size()))
873  return false;
875  return false;
876 
877  if (phibin < 0 || phibin >= int(SLShowerptr->SLPhiBins.size()))
878  return false;
880  return false;
881  return true;
882 }
bool SLisEtaBinFilled(int ebin, int etabin)
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
bool CastorShowerLibraryMaker::SLisEBinFilled ( int  ebin)
private

Definition at line 987 of file CastorShowerLibraryMaker.cc.

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

Referenced by IsSLReady(), and SLacceptEvent().

987  {
988  if (!SLShowerptr) {
989  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEBinFilled can be called only after BeginOfEvent\n\n";
990  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
991  }
993  return false;
994  return true;
995 }
bool CastorShowerLibraryMaker::SLisEtaBinFilled ( int  ebin,
int  etabin 
)
private

Definition at line 996 of file CastorShowerLibraryMaker.cc.

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

Referenced by SLacceptEvent().

996  {
997  if (!SLShowerptr) {
998  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEtaBinFilled can be called only after BeginOfEvent\n\n";
999  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
1000  }
1002  return false;
1003  return true;
1004 }
std::vector< std::vector< int > > nEvtInBinEta
bool CastorShowerLibraryMaker::SLisPhiBinFilled ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 1005 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and SLacceptEvent().

1005  {
1006  if (!SLShowerptr) {
1007  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisPhiBinFilled can be called only after BeginOfEvent\n\n";
1008  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
1009  }
1011  return false;
1012  return true;
1013 }
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
int & CastorShowerLibraryMaker::SLnEvtInBinE ( int  ebin)
private

Definition at line 964 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and update().

964  {
965  if (!SLShowerptr) {
966  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinE can be called only after BeginOfEvent\n\n";
967  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
968  }
969  return SLShowerptr->nEvtInBinE.at(ebin);
970 }
int & CastorShowerLibraryMaker::SLnEvtInBinEta ( int  ebin,
int  etabin 
)
private

Definition at line 972 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

972  {
973  if (!SLShowerptr) {
974  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinEta can be called only after BeginOfEvent\n\n";
975  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
976  }
977  return SLShowerptr->nEvtInBinEta.at(ebin).at(etabin);
978 }
std::vector< std::vector< int > > nEvtInBinEta
int & CastorShowerLibraryMaker::SLnEvtInBinPhi ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 980 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

980  {
981  if (!SLShowerptr) {
982  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinPhi can be called only after BeginOfEvent\n\n";
983  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
984  }
985  return SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
986 }
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
void CastorShowerLibraryMaker::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 148 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), update(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

148  {
149  std::cout << " CastorShowerLibraryMaker::Starting new job " << std::endl;
150 }
void CastorShowerLibraryMaker::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 153 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, cms::dd::split(), theFile, and theTree.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

153  {
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 }
std::vector< std::string_view > split(std::string_view, const char *)
void setNBins(unsigned int n)
void setBin(double val)
void setNEvtPerBin(unsigned int n)
CastorShowerLibraryInfo * hadInfo
CastorShowerLibraryInfo * emInfo
void setNEvts(unsigned int n)
void CastorShowerLibraryMaker::update ( const EndOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 560 of file CastorShowerLibraryMaker.cc.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

560  {
561  // Fill the tree with the collected objects
562  if (!IsSLReady())
563  SimG4Exception("\n\nShower Library NOT READY.\n\n");
564 
565  unsigned int ibine, ibineta, ibinphi, ievt; // indexes for em shower
566  unsigned int jbine, jbineta, jbinphi, jevt; // indexes for had shower
567 
568  ibine = ibineta = ibinphi = ievt = jbine = jbineta = jbinphi = jevt = 0;
569 
570  int nEvtInTree = 0;
571  int nEMevt = emSLHolder.nEvtPerBinE * emSLHolder.SLEnergyBins.size();
572  int nHadevt = hadSLHolder.nEvtPerBinE * hadSLHolder.SLEnergyBins.size();
573  int maxEvtInTree = std::max(nEMevt, nHadevt);
574 
577 
578  while (nEvtInTree < maxEvtInTree) {
579  if (emShower)
580  emShower->Clear();
581  if (hadShower)
582  hadShower->Clear();
583  while (ibine < emSLHolder.SLEnergyBins.size() && nEMevt > 0) {
584  emShower = &(emSLHolder.SLCollection.at(ibine).at(ibineta).at(ibinphi).at(ievt));
585  ievt++;
586  if (ievt == emSLHolder.nEvtPerBinPhi) {
587  ievt = 0;
588  ibinphi++;
589  }
590  if (ibinphi == emSLHolder.SLPhiBins.size()) {
591  ibinphi = 0;
592  ibineta++;
593  }
594  if (ibineta == emSLHolder.SLEtaBins.size()) {
595  ibineta = 0;
596  ibine++;
597  }
598  break;
599  }
600  while (jbine < hadSLHolder.SLEnergyBins.size() && nHadevt > 0) {
601  hadShower = &(hadSLHolder.SLCollection.at(jbine).at(jbineta).at(jbinphi).at(jevt));
602  jevt++;
603  if (jevt == hadSLHolder.nEvtPerBinPhi) {
604  jevt = 0;
605  jbinphi++;
606  }
607  if (jbinphi == hadSLHolder.SLPhiBins.size()) {
608  jbinphi = 0;
609  jbineta++;
610  }
611  if (jbineta == hadSLHolder.SLEtaBins.size()) {
612  jbineta = 0;
613  jbine++;
614  }
615  break;
616  }
617  theTree->Fill();
618  nEvtInTree++;
619  if (nEvtInTree == 1) {
620  theTree->SetBranchStatus("emShowerLibInfo.", false);
621  theTree->SetBranchStatus("hadShowerLibInfo.", false);
622  }
623  }
624  // check if run is nullptr and exit
625  if (run == nullptr)
626  throw SimG4Exception("\n\nNumber of needed trigger events reached in CastorShowerLibraryMaker\n\n");
627 }
void Clear(Option_t *option="") override
CastorShowerLibraryInfo * hadInfo
CastorShowerLibraryInfo * emInfo
void CastorShowerLibraryMaker::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 225 of file CastorShowerLibraryMaker.cc.

References accept(), gather_cfg::cout, emSLHolder, PVValHelper::eta, eventIndex, FindEnergyBin(), FindEtaBin(), FindPhiBin(), GetKinematics(), GetPrimary(), hadSLHolder, mps_fire::i, InsideCastor, IsSLReady(), MapOfSecondaries, PbPb_ZMuSkimMuonDPG_cff::particleType, phi, PrimaryMomentum, PrimaryPosition, printSLstatus(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, SLacceptEvent(), SLShowerptr, stepIndex, AlCaHLTBitMon_QueryRunRegistry::string, thePrims, update(), and verbosity.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

225  {
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 }
std::vector< G4PrimaryParticle * > thePrims
std::map< int, G4ThreeVector > PrimaryPosition
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::map< int, std::set< int > > MapOfSecondaries
std::vector< G4PrimaryParticle * > GetPrimary(const G4Event *)
void GetKinematics(G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
std::map< int, G4ThreeVector > PrimaryMomentum
void update(const BeginOfJob *run) override
This routine will be called when the appropriate signal arrives.
void CastorShowerLibraryMaker::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 410 of file CastorShowerLibraryMaker.cc.

References CastorShowerEvent::Clear(), gather_cfg::cout, emSLHolder, PVValHelper::eta, eventIndex, FillShowerEvent(), FindEnergyBin(), FindEtaBin(), FindPhiBin(), GetKinematics(), GetMissingEnergy(), CastorShowerEvent::getNhit(), hadSLHolder, mps_fire::i, CastorShowerLibraryMaker::ShowerLib::nEvtInBinPhi, PbPb_ZMuSkimMuonDPG_cff::particleType, phi, PrimaryPosition, printSLstatus(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, CastorShowerEvent::setPrimE(), CastorShowerEvent::setPrimEta(), CastorShowerEvent::setPrimPhi(), CastorShowerEvent::setPrimX(), CastorShowerEvent::setPrimY(), CastorShowerEvent::setPrimZ(), SLacceptEvent(), CastorShowerLibraryMaker::ShowerLib::SLCollection, SLnEvtInBinE(), SLnEvtInBinEta(), SLnEvtInBinPhi(), SLShowerptr, AlCaHLTBitMon_QueryRunRegistry::string, thePrims, verbosity, x, y, and z.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

410  {
411  // check if the job is done!
412  if ((*evt)()->IsAborted()) {
413  std::cout << "\n========================================================================"
414  << "\nEndOfEvent: EVENT ABORTED"
415  << "\n========================================================================" << std::endl;
416  return;
417  }
418  //DynamicRangeFlatRandomEGunProducer* pgun = edm::DynamicRangeFlatRandomEGunKernel::get_instance();
419  //std::cout << pgun->EGunMaxE() << std::endl;
420  /*
421  std::cout << "Minimum energy in Particle Gun : " << pgun->EGunMinE() << "\n"
422  << "Maximum energy in Particle Gun : " << pgun->EGunMaxE() << std::endl;
423 */
424  if (verbosity)
425  std::cout << "CastorShowerLibraryMaker: End of Event: " << eventIndex << std::endl;
426  // Get the pointer to the primary particle
427  if (thePrims.empty()) {
428  edm::LogInfo("CastorShowerLibraryMaker") << "No valid primary particle found. Skipping event" << std::endl;
429  return;
430  }
431  // access to the G4 hit collections
432  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
433  int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI");
434  CaloG4HitCollection* theCAFI = (CaloG4HitCollection*)allHC->GetHC(CAFIid);
435  if (verbosity)
436  edm::LogInfo("CastorShowerLibraryMaker") << " update(*evt) --> accessed all HC ";
437  edm::LogInfo("CastorShowerLibraryMaker") << "Found " << theCAFI->entries() << " hits in G4HitCollection";
438  if (theCAFI->entries() == 0) {
439  edm::LogInfo("CastorShowerLibraryMaker") << "\n Empty G4HitCollection";
440  return;
441  }
442 
443  // Loop over primaries
444  int NEvtAccepted = 0;
445  int NHitInEvent = 0;
446  for (unsigned int i = 0; i < thePrims.size(); i++) {
447  G4PrimaryParticle* thePrim = thePrims.at(i);
448  if (!thePrim) {
449  edm::LogInfo("CastorShowerLibraryMaker") << "nullptr Pointer to the primary" << std::endl;
450  continue;
451  }
452  // Check primary particle type
453  int particleType = thePrim->GetPDGcode();
454 
455  // set the pointer to the shower collection
456  std::string SLType("");
457  if (particleType == 11) {
459  SLType = "Electromagnetic";
460  } else {
462  SLType = "Hadronic";
463  }
464  edm::LogInfo("CastorShowerLibraryMaker") << "\n Primary (thePrim) trackID is " << thePrim->GetTrackID() << "\n";
465 
466  // Obtain primary particle's initial momentum (pInit)
467  double px = 0., py = 0., pz = 0., pInit = 0., eta = 0., phi = 0.;
468  GetKinematics(particleType, px, py, pz, pInit, eta, phi);
469  // Check if current event falls into any bin
470  // first: energy
471  if (pInit == 0) {
472  edm::LogInfo("CastorShowerLibraryMaker") << "Primary did not hit CASTOR" << std::endl;
473  continue;
474  }
475  int ebin = FindEnergyBin(pInit);
476  int etabin = FindEtaBin(eta);
477  int phibin = FindPhiBin(phi);
478  std::cout << SLType << std::endl;
479  printSLstatus(ebin, etabin, phibin);
480  if (!SLacceptEvent(ebin, etabin, phibin)) {
481  edm::LogInfo("CastorShowerLibraryMaker")
482  << "Event not accepted for ebin=" << ebin << ",etabin=" << etabin << ",phibin=" << phibin << "(" << pInit
483  << "," << eta << "," << phi << ")" << std::endl;
484  continue;
485  }
486  //
487  // event passed. Fill the vector accordingly
488  //
489  // Look for the Hit Collection
490  edm::LogInfo("CastorShowerLibraryMaker")
491  << "\n CastorShowerLibraryMaker::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID();
492 
493  /*
494  std::cout << "Number of collections : " << allHC->GetNumberOfCollections() << std::endl;
495  for(int ii = 0;ii<allHC->GetNumberOfCollections();ii++)
496  std::cout << "Name of collection " << ii << " : " << allHC->GetHC(ii)->GetName() << std::endl;
497 */
498 
499  CastorShowerEvent* shower = nullptr;
500  int cur_evt_idx = SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
501  shower = &(SLShowerptr->SLCollection.at(ebin).at(etabin).at(phibin).at(cur_evt_idx));
502 
503  // Get Hit information
504  if (FillShowerEvent(theCAFI, shower, particleType)) {
505  // Primary particle information
506  /*
507  edm::LogInfo("CastorShowerLibraryMaker") << "New SL event: Primary = " << particleType
508  << "; Energy = " << pInit << "; Eta = " << eta << "; Phi = " << phi
509  << "; Nhits = " << shower->getNhit() << std::endl;
510 */
511  shower->setPrimE(pInit);
512  shower->setPrimEta(eta);
513  shower->setPrimPhi(phi);
514  shower->setPrimX(PrimaryPosition[particleType].x());
515  shower->setPrimY(PrimaryPosition[particleType].y());
516  shower->setPrimZ(PrimaryPosition[particleType].z());
517  SLnEvtInBinE(ebin)++;
518  SLnEvtInBinEta(ebin, etabin)++;
519  SLnEvtInBinPhi(ebin, etabin, phibin)++;
520  NHitInEvent += shower->getNhit();
521  NEvtAccepted++;
522  } else {
523  shower->Clear();
524  }
525  }
526  // Check for unassociated energy
527 
528  if (NEvtAccepted == int(thePrims.size()) && theCAFI->entries() != NHitInEvent) {
529  std::cout << "WARNING: Inconsistent Number of Hits -> Hits in collection: " << theCAFI->entries()
530  << " Hits in the showers: " << NHitInEvent << std::endl;
531  double miss_energy = 0;
532  double tot_energy = 0;
533  GetMissingEnergy(theCAFI, miss_energy, tot_energy);
534  if (miss_energy > 0) {
535  std::cout << "Total missing energy: " << miss_energy << " for an incident energy: " << tot_energy << std::endl;
536  }
537  }
538 
539  /*
540  for (int i=emSLHolder.SLEnergyBins.size()-1;i>0;i--) {
541  if (emSLHolder.nEvtInBinE.at(i)==(int)emSLHolder.nEvtPerBinE) {
542  std::ostringstream out;
543  out << emSLHolder.SLEnergyBins.at(i);
544  cout << "Bin Limit: " << out.str() << std::endl;
545  setenv("CASTOR_SL_PG_MAXE",out.str().c_str(),1);
546  }
547  break;
548  }
549 */
550  //int iEvt = (*evt)()->GetEventID();
551  //double xint;
552  /*
553  if (modf(log10(iEvt),&xint)==0)
554  std::cout << " CastorShowerLibraryMaker Event " << iEvt << std::endl;
555 */
556  // std::cout << std::endl << "===>>> Done writing user histograms " << std::endl;
557 }
void Clear(Option_t *option="") override
void setPrimEta(float eta)
void setPrimZ(float z)
int & SLnEvtInBinEta(int ebin, int etabin)
void setPrimPhi(float phi)
std::vector< G4PrimaryParticle * > thePrims
bool FillShowerEvent(CaloG4HitCollection *, CastorShowerEvent *, int)
std::map< int, G4ThreeVector > PrimaryPosition
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
void setPrimE(float e)
void setPrimY(float y)
void GetMissingEnergy(CaloG4HitCollection *, double &, double &)
void GetKinematics(G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
void setPrimX(float x)
int & SLnEvtInBinPhi(int ebin, int etabin, int phibin)
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
unsigned int getNhit()
void CastorShowerLibraryMaker::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 310 of file CastorShowerLibraryMaker.cc.

References funct::abs(), funct::cos(), gather_cfg::cout, DeActivatePhysicsProcess, mps_fire::i, InsideCastor, createfilelist::int, KillSecondaries(), MapOfSecondaries, MaxEta, MaxPhi, PrimaryMomentum, PrimaryPosition, ValidateTausOnZEEFastSim_cff::proc, alignCSCRings::r, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, OrderedSet::t, and verbosity.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

310  {
311  static thread_local int CurrentPrimary = 0;
312  G4Track* trk = aStep->GetTrack();
313  if (trk->GetCurrentStepNumber() == 1) {
314  if (trk->GetParentID() == 0) {
315  CurrentPrimary = (int)trk->GetDynamicParticle()->GetPDGcode();
316  if (CurrentPrimary == 0)
317  SimG4Exception("CastorShowerLibraryMaker::update(G4Step) -> Primary particle undefined");
318  InsideCastor = false;
319  // Deactivate the physics process
321  G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
322  G4ProcessVector* pvec = p_mgr->GetProcessList();
323  for (int i = 0; i < pvec->size(); i++) {
324  G4VProcess* proc = (*pvec)(i);
325  if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
326  std::cout << "DeActivating process: " << proc->GetProcessName() << std::endl;
327  p_mgr->SetProcessActivation(proc, false);
328  }
329  }
330  }
331  // move track to z of CASTOR
332  G4ThreeVector pos;
333  pos.setZ(-14390);
334  double t = std::abs((pos.z() - trk->GetPosition().z())) / trk->GetVelocity();
335  double r = (pos.z() - trk->GetPosition().z()) / trk->GetMomentum().cosTheta();
336  pos.setX(r * sin(trk->GetMomentum().theta()) * cos(trk->GetMomentum().phi()) + trk->GetPosition().x());
337  pos.setY(r * sin(trk->GetMomentum().theta()) * sin(trk->GetMomentum().phi()) + trk->GetPosition().y());
338  trk->SetPosition(pos);
339  trk->SetGlobalTime(trk->GetGlobalTime() + t);
340  trk->AddTrackLength(r);
341  } else if (!InsideCastor) {
342  std::cout << "CastorShowerLibraryMaker::update(G4Step) -> Killing spurious track" << std::endl;
343  trk->SetTrackStatus(fKillTrackAndSecondaries);
344  return;
345  }
346  MapOfSecondaries[CurrentPrimary].insert((int)trk->GetTrackID());
347  }
348  // Checks if primary already inside CASTOR
349  std::string CurVolume = trk->GetVolume()->GetName();
350  if (!InsideCastor && (
351  //CurVolume=="C3EF"||CurVolume=="C4EF"||CurVolume=="CAEL"||
352  //CurVolume=="CAHL"||CurVolume=="C3HF"||CurVolume=="C4HF")) {
353  //CurVolume=="CastorB"||
354  CurVolume == "CAST")) {
355  //CurVolume=="CAIR")) {
356  InsideCastor = true;
357  // Activate the physics process
358  if (trk->GetParentID() == 0 && DeActivatePhysicsProcess) {
359  G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
360  G4ProcessVector* pvec = p_mgr->GetProcessList();
361  for (int i = 0; i < pvec->size(); i++) {
362  G4VProcess* proc = (*pvec)(i);
363  if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
364  std::cout << " Activating process: " << proc->GetProcessName() << std::endl;
365  p_mgr->SetProcessActivation(proc, true);
366  }
367  }
368  }
369  //PrimaryMomentum[CurrentPrimary]=aStep->GetPreStepPoint()->GetMomentum();
370  // check fiducial eta and phi
371  if (trk->GetMomentum().phi() > MaxPhi || trk->GetMomentum().eta() > MaxEta) {
372  trk->SetTrackStatus(fKillTrackAndSecondaries);
373  InsideCastor = false;
374  return;
375  }
376  PrimaryMomentum[CurrentPrimary] = trk->GetMomentum();
377  PrimaryPosition[CurrentPrimary] = trk->GetPosition();
378  KillSecondaries(aStep);
379  return;
380  }
381  // Kill the secondaries if they have been produced before entering castor
382  if (CurrentPrimary != 0 && trk->GetParentID() == 0 && !InsideCastor) {
383  KillSecondaries(aStep);
384  if (verbosity) {
385  double pre_phi = aStep->GetPreStepPoint()->GetMomentum().phi();
386  double cur_phi = trk->GetMomentum().phi();
387  if (pre_phi != cur_phi) {
388  std::cout << "Primary track phi : " << pre_phi << " changed in current step: " << cur_phi
389  << " by processes:" << std::endl;
390  const G4VProcess* proc = aStep->GetPreStepPoint()->GetProcessDefinedStep();
391  std::cout << " " << proc->GetProcessName() << " In volume " << CurVolume << std::endl;
392  }
393  }
394  }
395 
396  //==============================================
397  /*
398 */
399  /*
400  if(aStep->IsFirstStepInVolume()) {
401  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::update(const G4Step * aStep):"
402  << "\n IsFirstStepInVolume , "
403  << "time = " << aStep->GetTrack()->GetGlobalTime() ;
404  }
405  stepIndex++;
406 */
407 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< int, G4ThreeVector > PrimaryPosition
void KillSecondaries(const G4Step *step)
std::map< int, std::set< int > > MapOfSecondaries
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< int, G4ThreeVector > PrimaryMomentum

Member Data Documentation

bool CastorShowerLibraryMaker::DeActivatePhysicsProcess
private

Definition at line 132 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

bool CastorShowerLibraryMaker::DoEmSL
private

Definition at line 130 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

bool CastorShowerLibraryMaker::DoHadSL
private

Definition at line 129 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::emInfo
private

Definition at line 136 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::emShower
private

Definition at line 138 of file CastorShowerLibraryMaker.h.

Referenced by update().

ShowerLib CastorShowerLibraryMaker::emSLHolder
private
int CastorShowerLibraryMaker::eventIndex
private

Definition at line 177 of file CastorShowerLibraryMaker.h.

Referenced by update().

std::string CastorShowerLibraryMaker::eventNtFileName
private

Definition at line 125 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::hadInfo
private

Definition at line 137 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::hadShower
private

Definition at line 139 of file CastorShowerLibraryMaker.h.

Referenced by update().

ShowerLib CastorShowerLibraryMaker::hadSLHolder
private
bool CastorShowerLibraryMaker::InsideCastor
private

Definition at line 131 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 148 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

double CastorShowerLibraryMaker::MaxPhi
private

Definition at line 149 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

unsigned int CastorShowerLibraryMaker::NPGParticle
private

Definition at line 127 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

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

Definition at line 128 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

std::map<int, G4ThreeVector> CastorShowerLibraryMaker::PrimaryMomentum
private

Definition at line 146 of file CastorShowerLibraryMaker.h.

Referenced by GetKinematics(), and update().

std::map<int, G4ThreeVector> CastorShowerLibraryMaker::PrimaryPosition
private

Definition at line 147 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 178 of file CastorShowerLibraryMaker.h.

Referenced by update().

TFile* CastorShowerLibraryMaker::theFile
private

Definition at line 174 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

std::vector<G4PrimaryParticle*> CastorShowerLibraryMaker::thePrims
private

Definition at line 133 of file CastorShowerLibraryMaker.h.

Referenced by GetMissingEnergy(), GetPrimary(), and update().

TTree* CastorShowerLibraryMaker::theTree
private

Definition at line 175 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

int CastorShowerLibraryMaker::verbosity
private

Definition at line 124 of file CastorShowerLibraryMaker.h.

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