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 83 of file CastorShowerLibraryMaker.h.

Member Typedef Documentation

typedef int CastorShowerLibraryMaker::ebin
private

Definition at line 97 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::etabin
private

Definition at line 98 of file CastorShowerLibraryMaker.h.

typedef int CastorShowerLibraryMaker::phibin
private

Definition at line 99 of file CastorShowerLibraryMaker.h.

Constructor & Destructor Documentation

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

Definition at line 37 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.

37  :
38  NPGParticle(0),DoHadSL(false),DoEmSL(false),DeActivatePhysicsProcess(false),
39  emShower(nullptr) , hadShower(nullptr) {
40 
41  MapOfSecondaries.clear();
42  hadInfo = nullptr;
43  emInfo = nullptr;
44  edm::ParameterSet p_SLM = p.getParameter<edm::ParameterSet>("CastorShowerLibraryMaker");
45  verbosity = p_SLM.getParameter<int>("Verbosity");
46  eventNtFileName = p_SLM.getParameter<std::string>("EventNtupleFileName");
47  hadSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nhadEvents");
48  emSLHolder.nEvtPerBinPhi = p_SLM.getParameter<int>("nemEvents");
49  hadSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLhadEnergyBins");
50  hadSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLhadEtaBins");
51  hadSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLhadPhiBins");
52  emSLHolder.SLEnergyBins = p_SLM.getParameter<std::vector<double> >("SLemEnergyBins");
53  emSLHolder.SLEtaBins = p_SLM.getParameter<std::vector<double> >("SLemEtaBins");
54  emSLHolder.SLPhiBins = p_SLM.getParameter<std::vector<double> >("SLemPhiBins");
55  PGParticleIDs = p_SLM.getParameter<std::vector<int> >("PartID");
56  DeActivatePhysicsProcess = p_SLM.getParameter<bool>("DeActivatePhysicsProcess");
57  MaxPhi = p_SLM.getParameter<double>("SLMaxPhi");
58  MaxEta = p_SLM.getParameter<double>("SLMaxEta");
59 //
60  NPGParticle = PGParticleIDs.size();
61  for(unsigned int i=0;i<PGParticleIDs.size();i++) {
62  switch (std::abs(PGParticleIDs.at(i))) {
63  case 11:
64  case 22:
65  DoEmSL = true;
66  break;
67  default:
68  DoHadSL = true;
69  }
70  }
75 
76  std::cout << "============================================================================"<<std::endl;
77  std::cout << "CastorShowerLibraryMaker:: Initialized as observer" << std::endl;
78  std::cout << " Event Ntuple will be created" << std::endl;
79  std::cout << " Event Ntuple file: " << eventNtFileName << std::endl;
80  std::cout << " Number of Hadronic events in E bins: " << hadSLHolder.nEvtPerBinE << std::endl;
81  std::cout << " Number of Hadronic events in Eta bins: " << hadSLHolder.nEvtPerBinEta << std::endl;
82  std::cout << " Number of Hadronic events in Phi bins: " << hadSLHolder.nEvtPerBinPhi << std::endl;
83  std::cout << " Number of Electromag. events in E bins: " << emSLHolder.nEvtPerBinE << std::endl;
84  std::cout << " Number of Electromag. events in Eta bins: " << emSLHolder.nEvtPerBinEta << std::endl;
85  std::cout << " Number of Electromag. events in Phi bins: " << emSLHolder.nEvtPerBinPhi << std::endl;
86  std::cout << "============================================================================"<<std::endl;
87  std::cout << std::endl;
88 
89  // Initializing the SL collections
92 }
T getParameter(std::string const &) const
CastorShowerLibraryInfo * hadInfo
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< int, std::set< int > > MapOfSecondaries
CastorShowerLibraryInfo * emInfo
CastorShowerLibraryMaker::~CastorShowerLibraryMaker ( )
override

Definition at line 138 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, and Finish().

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

Member Function Documentation

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

Definition at line 851 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 HcalDigiParam_cfi::zside.

Referenced by update().

852 {
853  unsigned int volumeID=0;
854  double en_in_fi = 0.;
855  //double totalEnergy = 0;
856 
857  int nentries = theCAFI->entries();
858 
859 // Compute Total Energy in CastorFI volume
860 /*
861  for(int ihit = 0; ihit < nentries; ihit++) {
862  CaloG4Hit* aHit = (*theCAFI)[ihit];
863  totalEnergy += aHit->getEnergyDeposit();
864  }
865 */
866  if (!shower) {
867  edm::LogInfo("CastorShowerLibraryMaker") << "Error. nullptr pointer to CastorShowerEvent";
868  return false;
869  }
870 
871  CastorNumberingScheme *theCastorNumScheme = new CastorNumberingScheme();
872 // Hit position
875  int nHits;
876  nHits=0;
877  for (int ihit = 0; ihit < nentries; ihit++) {
878  CaloG4Hit* aHit = (*theCAFI)[ihit];
879  int hit_particleID = aHit->getTrackID();
880  if (MapOfSecondaries[ipart].find(hit_particleID)==MapOfSecondaries[ipart].end()) {
881  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker")
882  << "Skipping hit from trackID " << hit_particleID;
883  continue;
884  }
885  volumeID = aHit->getUnitID();
886  double hitEnergy = aHit->getEnergyDeposit();
887  en_in_fi += aHit->getEnergyDeposit();
888  float time = aHit->getTimeSlice();
889  int zside, sector, zmodule;
890  theCastorNumScheme->unpackIndex(volumeID, zside, sector,zmodule);
891  entry = aHit->getEntry();
892  position = aHit->getPosition();
893  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker")
894  << "\n side , sector , module = " << zside << " , "
895  << sector << " , " << zmodule
896  << "\n nphotons = " << hitEnergy ;
897 
898  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker")
899  << "\n packIndex = "
900  << theCastorNumScheme->packIndex(zside, sector,zmodule);
901 
902  if(verbosity&&time>100.) {
903  edm::LogInfo("CastorShowerLibraryMaker")
904  << "\n nentries = " << nentries
905  << "\n time[" << ihit << "] = " << time
906  << "\n trackID[" << ihit << "] = " << aHit->getTrackID()
907  << "\n volumeID[" << ihit << "] = " << volumeID
908  << "\n nphotons[" << ihit << "] = " << hitEnergy
909  << "\n side, sector, module = " << zside <<", " << sector<<", " << zmodule
910  << "\n packIndex " << theCastorNumScheme->packIndex(zside,sector,zmodule)
911  << "\n X,Y,Z = " << entry.x() << ","<< entry.y() << "," << entry.z();
912  }
913  if (verbosity) edm::LogInfo("CastorShowerLibraryMaker") << "\n Incident Energy = "
914  << aHit->getIncidentEnergy() << " \n" ;
915 
916 // CaloG4Hit information
917  shower->setDetID(volumeID);
918  shower->setHitPosition(position);
919  shower->setNphotons(hitEnergy);
920  shower->setTime(time);
921  nHits++;
922  }
923 // Write number of hits to CastorShowerEvent instance
924  if (nHits==0) {
925  edm::LogInfo("CastorShowerLibraryMaker") << "No hits found for this track (trackID=" << ipart << ")." << std::endl;
926  if (theCastorNumScheme) delete theCastorNumScheme;
927  return false;
928  }
929  shower->setNhit(nHits);
930 
931 // update the event counters
932  if (theCastorNumScheme) delete theCastorNumScheme;
933  return true;
934 }
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
void setTime(float t)
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:20
static void unpackIndex(const uint32_t &idx, int &z, int &sector, int &zmodule)
#define end
Definition: vmac.h:37
std::map< int, std::set< int > > MapOfSecondaries
int getTrackID() const
Definition: CaloG4Hit.h:68
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
static int position[264][3]
Definition: ReadPGInfo.cc:509
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)
void setHitPosition(const Point &p)
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
int CastorShowerLibraryMaker::FindEnergyBin ( double  e)
private

Definition at line 637 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

Definition at line 658 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

658  {
659  //
660  // returns the integer index of the eta bin, taken from SLetas vector
661  // returns -1 if ouside valid range
662  //
663  if (!SLShowerptr) {
664  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindEtaBin can be called only after BeginOfEvent\n\n";
665  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
666  }
667  const std::vector<double>& SLetas = SLShowerptr->SLEtaBins;
668  if (eta>=SLetas.back()) return SLetas.size()-1;
669  unsigned int i = 0;
670  for(;i<SLetas.size()-1;i++)
671  if (eta >= SLetas.at(i) && eta < SLetas.at(i+1)) return (int)i;
672  // now i points to the last but 1 bin
673  if (eta>=SLetas.at(i)) return (int)i;
674  // eta outside bin range
675  return -1;
676 }
int CastorShowerLibraryMaker::FindPhiBin ( double  phi)
private

Definition at line 677 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

677  {
678  //
679  // returns the integer index of the phi bin, taken from SLphis vector
680  // returns -1 if ouside valid range
681  //
682  // needs protection in case phi is outside range -pi,pi
683  //
684  if (!SLShowerptr) {
685  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nFindPhiBin can be called only after BeginOfEvent\n\n";
686  throw SimG4Exception("\n\nnullptr Pointer to the shower library.\n\n");
687  }
688  const std::vector<double>& SLphis = SLShowerptr->SLPhiBins;
689  if (phi>=SLphis.back()) return SLphis.size()-1;
690  unsigned int i = 0;
691  for(;i<SLphis.size()-1;i++)
692  if (phi >= SLphis.at(i) && phi < SLphis.at(i+1)) return (int)i;
693  // now i points to the last but 1 bin
694  if (phi>=SLphis.at(i)) return (int)i;
695  // phi outside bin range
696  return -1;
697 }
void CastorShowerLibraryMaker::Finish ( )
private

Definition at line 621 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, theFile, and theTree.

Referenced by ~CastorShowerLibraryMaker().

621  {
622 
623  // if (doNTcastorevent) {
624 
625  theFile->cd();
626  theTree->Write("",TObject::kOverwrite);
627  std::cout << "CastorShowerLibraryMaker: Ntuple event written" << std::endl;
628  theFile->Close();
629  std::cout << "CastorShowerLibraryMaker: Event file closed" << std::endl;
630 
631  // Delete pointers to objects, now that TTree has been written and TFile closed
632 // delete info;
633 // delete emShower;
634 // delete hadShower;
635  // }
636 }
void CastorShowerLibraryMaker::GetKinematics ( G4PrimaryParticle *  thePrim,
double &  px,
double &  py,
double &  pz,
double &  pInit,
double &  eta,
double &  phi 
)
private

Definition at line 742 of file CastorShowerLibraryMaker.cc.

References GeV, cmsBatch::log, SiStripPI::max, min(), funct::tan(), and theta().

Referenced by update().

743 {
744  px=py=pz=phi=eta=0.0;
745  if (thePrim==nullptr) return;
746  px = thePrim->GetMomentum().x()/GeV;
747  py = thePrim->GetMomentum().y()/GeV;
748  pz = thePrim->GetMomentum().z()/GeV;
749  pInit = thePrim->GetMomentum().mag()/GeV;
750  //pInit = sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
751  if (pInit==0) return;
752  double costheta = pz/pInit;
753  double theta = acos(std::min(std::max(costheta,double(-1.)),double(1.)));
754  eta = -log(tan(theta/2.0));
755  phi = (px==0 && py==0) ? 0 : atan2(py,px); // the recommended way of calculating phi
756  phi = thePrim->GetMomentum().phi();
757  //if (px!=0) phi=atan(py/px);
758 }
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 727 of file CastorShowerLibraryMaker.cc.

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

728 {
729  if (thePrim==0) return;
730  if (PrimaryMomentum.find(thePrim)==PrimaryMomentum.end()) return;
731  px = PrimaryMomentum[thePrim].x()/GeV;
732  py = PrimaryMomentum[thePrim].y()/GeV;
733  pz = PrimaryMomentum[thePrim].z()/GeV;
734  pInit=PrimaryMomentum[thePrim].mag()/GeV;
735  if (pInit==0) return;
736  double costheta = pz/pInit;
737  double theta = acos(std::min(std::max(costheta,double(-1.)),double(1.)));
738  eta = -log(tan(theta/2.0));
739  phi = (px==0 && py==0) ? 0 : atan2(py,px); // the recommended way of calculating phi
740  phi = PrimaryMomentum[thePrim].phi();
741 }
const double GeV
Definition: MathUtil.h:16
Geom::Theta< T > theta() const
std::map< int, G4ThreeVector > PrimaryMomentum
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
void CastorShowerLibraryMaker::GetMissingEnergy ( CaloG4HitCollection theCAFI,
double &  miss_energy,
double &  tot_energy 
)
private

Definition at line 999 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

999  {
1000 // Get the total deposited energy and the one from hit not associated to a primary
1001  miss_energy = 0;
1002  tot_energy = 0;
1003  for (int ihit = 0; ihit < theCAFI->entries(); ihit++) {
1004  int id = (*theCAFI)[ihit]->getTrackID();
1005  tot_energy+=(*theCAFI)[ihit]->getEnergyDeposit();
1006  int hit_prim = 0;
1007  for(unsigned int i=0;i<thePrims.size();i++) {
1008  int particleType = thePrims.at(i)->GetPDGcode();
1009  if (MapOfSecondaries[particleType].find(id)!=MapOfSecondaries[particleType].end())
1010  hit_prim = particleType;
1011  }
1012  if (hit_prim==0) {
1013  std::cout << "Track ID " << id << " produced a hit which is not associated with a primary."
1014  << std::endl;
1015  miss_energy+=(*theCAFI)[ihit]->getEnergyDeposit();
1016  }
1017  }
1018 }
std::vector< G4PrimaryParticle * > thePrims
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
#define end
Definition: vmac.h:37
std::map< int, std::set< int > > MapOfSecondaries
std::vector< G4PrimaryParticle * > CastorShowerLibraryMaker::GetPrimary ( const G4Event *  evt)
private

Definition at line 759 of file CastorShowerLibraryMaker.cc.

References mps_fire::i, gen::k, npart, NPGParticle, PGParticleIDs, and thePrims.

Referenced by update().

760 {
761  // Find Primary info:
762  int trackID = 0;
763  std::vector<G4PrimaryParticle*> thePrims;
764  G4PrimaryParticle* thePrim = nullptr;
765  G4int nvertex = evt->GetNumberOfPrimaryVertex();
766  edm::LogInfo("CastorShowerLibraryMaker") << "Event has " << nvertex << " vertex";
767  if (nvertex!=1) {
768  edm::LogInfo("CastorShowerLibraryMaker") << "CastorShowerLibraryMaker::GetPrimary ERROR: no vertex";
769  return thePrims;
770  }
771 
772  for (int i = 0 ; i<nvertex; i++) {
773  G4PrimaryVertex* avertex = evt->GetPrimaryVertex(i);
774  if (avertex == nullptr) {
775  edm::LogInfo("CastorShowerLibraryMaker")
776  << "CastorShowerLibraryMaker::GetPrimary ERROR: pointer to vertex = 0";
777  continue;
778  }
779  unsigned int npart = avertex->GetNumberOfParticle();
780  if (npart!=NPGParticle) continue;
781  for (unsigned int j=0;j<npart;j++) {
782  unsigned int k = 0;
783  //int test_pID = 0;
784  trackID = j;
785  thePrim=avertex->GetPrimary(trackID);
786  while(k<NPGParticle&&PGParticleIDs.at(k++)!=thePrim->GetPDGcode()){;};
787  if (k>NPGParticle) continue; // ID not found in the requested particles
788  thePrims.push_back(thePrim);
789  }
790  }
791  return thePrims;
792 }
std::vector< G4PrimaryParticle * > thePrims
double npart
Definition: HydjetWrapper.h:49
int k[5][pyjets_maxn]
void CastorShowerLibraryMaker::InitSLHolder ( ShowerLib showerholder)
private

Definition at line 93 of file CastorShowerLibraryMaker.cc.

References CastorShowerLibraryInfo::Energy, CastorShowerLibraryInfo::Eta, mps_fire::i, 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().

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

Definition at line 698 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

699 {
700 // at this point, the pointer to the shower library should be nullptr
701  if (SLShowerptr) {
702  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nIsSLReady must be called when a new event starts.\n\n";
703  throw SimG4Exception("\n\nNOT nullptr Pointer to the shower library.\n\n");
704  }
705 // it is enough to check if all the energy bin is filled
706  if (DoEmSL) {
708  for(unsigned int i=0;i<SLShowerptr->SLEnergyBins.size();i++) {
709  if (!SLisEBinFilled(i)) {
710  SLShowerptr=nullptr;
711  return false;
712  }
713  }
714  }
715  if (DoHadSL) {
717  for(unsigned int i=0;i<SLShowerptr->SLEnergyBins.size();i++) {
718  if (!SLisEBinFilled(i)) {
719  SLShowerptr=nullptr;
720  return false;
721  }
722  }
723  }
724  SLShowerptr=nullptr;
725  return true;
726 }
void CastorShowerLibraryMaker::KillSecondaries ( const G4Step *  step)
private

Definition at line 988 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

988  {
989  const G4TrackVector *p_sec = aStep->GetSecondary();
990  for(int i=0;i<int(p_sec->size());i++) {
991  /*if (verbosity)*/ std::cout << "Killing track ID " << p_sec->at(i)->GetTrackID() << " and its secondaries"
992  << " Produced by Process " << p_sec->at(i)->GetCreatorProcess()->GetProcessName()
993  << " in the volume " << aStep->GetTrack()->GetVolume()->GetName()
994  << std::endl;
995  p_sec->at(i)->SetTrackStatus(fKillTrackAndSecondaries);
996  }
997 }
void CastorShowerLibraryMaker::printSLstatus ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 793 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

794 {
795  if (!SLShowerptr) {
796  edm::LogInfo("CastorShowerLibraryInfo") << "nullptr shower pointer. Printing both";
797  std::cout << "Electromagnetic" << std::endl;
800  std::cout << "Hadronic" << std::endl;
803  SLShowerptr = nullptr;
804  return;
805  }
806  int nBinsE =SLShowerptr->SLEnergyBins.size();
807  int nBinsEta=SLShowerptr->SLEtaBins.size();
808  int nBinsPhi=SLShowerptr->SLPhiBins.size();
809  std::vector<double> SLenergies = SLShowerptr->SLEnergyBins;
810  for(int n=0;n<11+(nBinsEta*nBinsPhi);n++) std::cout << "=";
811  std::cout << std::endl;
812  for(int i=0;i<nBinsE;i++) {
813  std::cout << "E bin " << std::setw(6) << SLenergies.at(i) << " : ";
814  for(int j=0;j<nBinsEta;j++) {
815  for(int k=0;k<nBinsPhi;k++) {
816  (SLisPhiBinFilled(i,j,k))?std::cout << "1":std::cout << "-";
817  }
818  if (j<nBinsEta-1) std::cout << "|";
819  }
820  std::cout << " (" << SLnEvtInBinE(i) << " events)";
821  std::cout << std::endl;
822  if (ebin!=i) continue;
823  std::cout << " ";
824  for(int j=0;j<nBinsEta;j++) {
825  for(int k=0;k<nBinsPhi;k++) {
826  (ebin==i&&etabin==j&&phibin==k)?std::cout << "^":std::cout << " ";
827  }
828  if (j<nBinsEta-1) std::cout << " ";
829  }
830  std::cout << std::endl;
831  }
832  for(int n=0;n<11+(nBinsEta*nBinsPhi);n++) std::cout << "=";
833  std::cout << std::endl;
834 }
int k[5][pyjets_maxn]
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
bool CastorShowerLibraryMaker::SLacceptEvent ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 835 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

836 {
837  if (SLShowerptr==nullptr) {
838  edm::LogInfo("CastorShowerLibraryMaker::SLacceptEvent:") << "Error. nullptr pointer to CastorShowerEvent";
839  return false;
840  }
841  if (ebin<0||ebin>=int(SLShowerptr->SLEnergyBins.size())) return false;
842  if (SLisEBinFilled(ebin)) return false;
843 
844  if (etabin<0||etabin>=int(SLShowerptr->SLEtaBins.size())) return false;
845  if (SLisEtaBinFilled(ebin,etabin)) return false;
846 
847  if (phibin<0||phibin>=int(SLShowerptr->SLPhiBins.size())) return false;
848  if (SLisPhiBinFilled(ebin,etabin,phibin)) return false;
849  return true;
850 }
bool SLisEtaBinFilled(int ebin, int etabin)
bool SLisPhiBinFilled(int ebin, int etabin, int phibin)
bool CastorShowerLibraryMaker::SLisEBinFilled ( int  ebin)
private

Definition at line 961 of file CastorShowerLibraryMaker.cc.

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

Referenced by IsSLReady(), and SLacceptEvent().

962 {
963  if (!SLShowerptr) {
964  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisEBinFilled can be called only after BeginOfEvent\n\n";
965  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
966  }
967  if (SLShowerptr->nEvtInBinE.at(ebin)<(int)SLShowerptr->nEvtPerBinE) return false;
968  return true;
969 }
bool CastorShowerLibraryMaker::SLisEtaBinFilled ( int  ebin,
int  etabin 
)
private

Definition at line 970 of file CastorShowerLibraryMaker.cc.

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

Referenced by SLacceptEvent().

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

Definition at line 979 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and SLacceptEvent().

980 {
981  if (!SLShowerptr) {
982  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLisPhiBinFilled can be called only after BeginOfEvent\n\n";
983  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
984  }
985  if (SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin)<(int)SLShowerptr->nEvtPerBinPhi) return false;
986  return true;
987 }
std::vector< std::vector< std::vector< int > > > nEvtInBinPhi
int & CastorShowerLibraryMaker::SLnEvtInBinE ( int  ebin)
private

Definition at line 935 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and update().

936 {
937  if (!SLShowerptr) {
938  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinE can be called only after BeginOfEvent\n\n";
939  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
940  }
941  return SLShowerptr->nEvtInBinE.at(ebin);
942 }
int & CastorShowerLibraryMaker::SLnEvtInBinEta ( int  ebin,
int  etabin 
)
private

Definition at line 944 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

945 {
946  if (!SLShowerptr) {
947  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinEta can be called only after BeginOfEvent\n\n";
948  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
949  }
950  return SLShowerptr->nEvtInBinEta.at(ebin).at(etabin);
951 }
std::vector< std::vector< int > > nEvtInBinEta
int & CastorShowerLibraryMaker::SLnEvtInBinPhi ( int  ebin,
int  etabin,
int  phibin 
)
private

Definition at line 953 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

954 {
955  if (!SLShowerptr) {
956  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinPhi can be called only after BeginOfEvent\n\n";
957  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
958  }
959  return SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
960 }
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 147 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().

147  {
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, 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 
155  std::cout << std::endl << "CastorShowerLibraryMaker: Starting Run"<< std::endl;
156 
157  std::cout << "CastorShowerLibraryMaker: output event root file created" << std::endl;
158 
159  TString eventfilename = eventNtFileName;
160  theFile = new TFile(eventfilename,"RECREATE");
161  theTree = new TTree("CastorCherenkovPhotons", "Cherenkov Photons");
162 
163  Int_t split = 1;
164  Int_t bsize = 64000;
166  emShower = new CastorShowerEvent();
169  // Create Branchs
170  theTree->Branch("emShowerLibInfo.", "CastorShowerLibraryInfo", &emInfo, bsize, split);
171  theTree->Branch("emParticles.", "CastorShowerEvent", &emShower, bsize, split);
172  theTree->Branch("hadShowerLibInfo.", "CastorShowerLibraryInfo", &hadInfo, bsize, split);
173  theTree->Branch("hadParticles.", "CastorShowerEvent", &hadShower, bsize, split);
174 
175 // set the Info for electromagnetic shower
176 // set the energy bins info
181 // set the eta bins info
186 // set the eta bins info
191 // The same for the hadronic shower
192 // set the energy bins info
197 // set the eta bins info
202 // set the eta bins info
207  // int flag = theTree->GetBranch("CastorShowerLibInfo")->Fill();
208  // Loop on all leaves of this branch to fill Basket buffer.
209  // The function returns the number of bytes committed to the memory basket.
210  // If a write error occurs, the number of bytes returned is -1.
211  // If no data are written, because e.g. the branch is disabled,
212  // the number of bytes returned is 0.
213  // if(flag==-1) {
214  // edm::LogInfo("CastorAnalyzer") << " WARNING: Error writing to Branch \"CastorShowerLibInfo\" \n" ;
215  // } else
216  // if(flag==0) {
217  // edm::LogInfo("CastorAnalyzer") << " WARNING: No data written to Branch \"CastorShowerLibInfo\" \n" ;
218  // }
219 
220  // Initialize "accounting" variables
221 
222  eventIndex = 0;
223 
224 }
void setNBins(unsigned int n)
void setBin(double val)
void setNEvtPerBin(unsigned int n)
CastorShowerLibraryInfo * hadInfo
CastorShowerLibraryInfo * emInfo
void setNEvts(unsigned int n)
double split
Definition: MVATrainer.cc:139
void CastorShowerLibraryMaker::update ( const EndOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

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

573 {
574 // Fill the tree with the collected objects
575  if (!IsSLReady()) SimG4Exception("\n\nShower Library NOT READY.\n\n");
576 
577  unsigned int ibine,ibineta,ibinphi,ievt; // indexes for em shower
578  unsigned int jbine,jbineta,jbinphi,jevt;// indexes for had shower
579 
580  ibine=ibineta=ibinphi=ievt=jbine=jbineta=jbinphi=jevt=0;
581 
582  int nEvtInTree = 0;
583  int nEMevt = emSLHolder.nEvtPerBinE*emSLHolder.SLEnergyBins.size();
584  int nHadevt = hadSLHolder.nEvtPerBinE*hadSLHolder.SLEnergyBins.size();
585  int maxEvtInTree=std::max(nEMevt,nHadevt);
586 
589 
590  while(nEvtInTree<maxEvtInTree) {
591  if (emShower) emShower->Clear();
592  if (hadShower) hadShower->Clear();
593  while(ibine<emSLHolder.SLEnergyBins.size()&&nEMevt>0){
594  emShower = &(emSLHolder.SLCollection.at(ibine).at(ibineta).at(ibinphi).at(ievt));
595  ievt++;
596  if (ievt==emSLHolder.nEvtPerBinPhi) {ievt=0;ibinphi++;}
597  if (ibinphi==emSLHolder.SLPhiBins.size()) {ibinphi=0;ibineta++;}
598  if (ibineta==emSLHolder.SLEtaBins.size()) {ibineta=0;ibine++;}
599  break;
600  }
601  while(jbine<hadSLHolder.SLEnergyBins.size()&&nHadevt>0){
602  hadShower = &(hadSLHolder.SLCollection.at(jbine).at(jbineta).at(jbinphi).at(jevt));
603  jevt++;
604  if (jevt==hadSLHolder.nEvtPerBinPhi) {jevt=0;jbinphi++;}
605  if (jbinphi==hadSLHolder.SLPhiBins.size()) {jbinphi=0;jbineta++;}
606  if (jbineta==hadSLHolder.SLEtaBins.size()) {jbineta=0;jbine++;}
607  break;
608  }
609  theTree->Fill();
610  nEvtInTree++;
611  if (nEvtInTree==1) {
612  theTree->SetBranchStatus("emShowerLibInfo.",false);
613  theTree->SetBranchStatus("hadShowerLibInfo.",false);
614  }
615  }
616 // check if run is nullptr and exit
617  if (run==nullptr) throw SimG4Exception("\n\nNumber of needed trigger events reached in CastorShowerLibraryMaker\n\n");
618 }
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 227 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, objects.autophobj::particleType, phi, PrimaryMomentum, PrimaryPosition, printSLstatus(), 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().

227  {
228 
229  eventIndex++;
230  stepIndex = 0;
231  InsideCastor = false;
232  PrimaryMomentum.clear();
233  PrimaryPosition.clear();
234  int NAccepted =0;
235 // reset the pointers to the shower objects
236  SLShowerptr = nullptr;
237  MapOfSecondaries.clear();
238  thePrims.clear();
239  G4EventManager *e_mgr = G4EventManager::GetEventManager();
240  if (IsSLReady()) {
241  printSLstatus(-1,-1,-1);
242  update((EndOfRun*)nullptr);
243  return;
244  }
245 
246  thePrims = GetPrimary((*evt)());
247  for(unsigned int i=0;i<thePrims.size();i++) {
248  G4PrimaryParticle* thePrim = thePrims.at(i);
249  int particleType = thePrim->GetPDGcode();
250 
251  std::string SLType("");
252  if (particleType==11) {
254  SLType = "Electromagnetic";
255  }
256  else {
258  SLType = "Hadronic";
259  }
260  double px=0., py=0., pz=0., pInit = 0., eta = 0., phi = 0.;
261  GetKinematics(thePrim,px,py,pz,pInit,eta,phi);
262  int ebin = FindEnergyBin(pInit);
263  int etabin= FindEtaBin(eta);
264  int phibin = FindPhiBin(phi);
265  if (verbosity)
266  std::cout << "\n========================================================================"
267  << "\nBeginOfEvent: E : " << pInit <<"\t bin : " << ebin
268  << "\n Eta : " << eta <<"\t bin : " << etabin
269  << "\n Phi : " << phi <<"\t bin : " << phibin
270  << "\n========================================================================"
271  << std::endl;
272 
273  if (ebin<0||etabin<0||phibin<0) continue;
274  bool accept=false;
275  if (!(SLacceptEvent(ebin,etabin,phibin))) {
276 /*
277 // To increase the chance of a particle arriving at CASTOR inside a not full bin,
278 // check if there is available phase space in the neighboring bins
279  unsigned int ebin_min = std::max(0,ebin-3);
280  unsigned int eta_bin_min = std::max(0,etabin-2);
281  unsigned int eta_bin_max = std::min(etabin,etabin+2);
282  unsigned int phi_bin_min = std::max(0,phibin-2);
283  unsigned int phi_bin_max = std::min(phibin,phibin+2);
284  for(unsigned int i_ebin=ebin_min;i_ebin<=(unsigned int)ebin;i_ebin++) {
285  for (unsigned int i_etabin=eta_bin_min;i_etabin<=eta_bin_max;i_etabin++) {
286  for (unsigned int i_phibin=phi_bin_min;i_phibin<=phi_bin_max;i_phibin++) {
287  if (SLacceptEvent((int)i_ebin,(int)i_etabin,(int)i_phibin)) {accept=true;break;}
288  }
289  if (accept) break;
290  }
291  if (accept) break;
292  }
293 */
294  if (!accept) edm::LogInfo("CastorShowerLibraryMaker") << "Event not accepted for ebin="
295  << ebin<<",etabin="<<etabin<<",phibin="<<phibin<<std::endl;
296  }
297  else {
298  accept=true;
299  }
300  if (accept) NAccepted++;
301  }
302 
303  if (NAccepted==0) {
304  const_cast<G4Event*>((*evt)())->SetEventAborted();
305  const_cast<G4Event*>((*evt)())->KeepTheEvent((G4bool)false);
306  e_mgr->AbortCurrentEvent();
307  }
308  SLShowerptr=nullptr;
309 //
310  std::cout << "CastorShowerLibraryMaker: Processing Event Number: " << eventIndex << std::endl;
311 }
std::vector< G4PrimaryParticle * > thePrims
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::vector< G4PrimaryParticle * > GetPrimary(const G4Event *)
std::map< int, G4ThreeVector > PrimaryMomentum
std::map< int, G4ThreeVector > PrimaryPosition
std::map< int, std::set< int > > MapOfSecondaries
void GetKinematics(G4PrimaryParticle *, double &px, double &py, double &pz, double &pInit, double &eta, double &phi)
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 418 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, objects.autophobj::particleType, phi, PrimaryPosition, printSLstatus(), 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().

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

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

Member Data Documentation

bool CastorShowerLibraryMaker::DeActivatePhysicsProcess
private

Definition at line 136 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

bool CastorShowerLibraryMaker::DoEmSL
private

Definition at line 134 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

bool CastorShowerLibraryMaker::DoHadSL
private

Definition at line 133 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and IsSLReady().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::emInfo
private

Definition at line 140 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::emShower
private

Definition at line 142 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 183 of file CastorShowerLibraryMaker.h.

Referenced by update().

std::string CastorShowerLibraryMaker::eventNtFileName
private

Definition at line 129 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerLibraryInfo* CastorShowerLibraryMaker::hadInfo
private

Definition at line 141 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

CastorShowerEvent* CastorShowerLibraryMaker::hadShower
private

Definition at line 143 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 135 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 152 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

double CastorShowerLibraryMaker::MaxPhi
private

Definition at line 153 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and update().

unsigned int CastorShowerLibraryMaker::NPGParticle
private

Definition at line 131 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

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

Definition at line 132 of file CastorShowerLibraryMaker.h.

Referenced by CastorShowerLibraryMaker(), and GetPrimary().

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

Definition at line 150 of file CastorShowerLibraryMaker.h.

Referenced by GetKinematics(), and update().

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

Definition at line 151 of file CastorShowerLibraryMaker.h.

Referenced by update().

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

Definition at line 184 of file CastorShowerLibraryMaker.h.

Referenced by update().

TFile* CastorShowerLibraryMaker::theFile
private

Definition at line 180 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

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

Definition at line 137 of file CastorShowerLibraryMaker.h.

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

TTree* CastorShowerLibraryMaker::theTree
private

Definition at line 181 of file CastorShowerLibraryMaker.h.

Referenced by Finish(), and update().

int CastorShowerLibraryMaker::verbosity
private

Definition at line 128 of file CastorShowerLibraryMaker.h.

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