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 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.

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

References gather_cfg::cout, and Finish().

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

Member Function Documentation

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

Definition at line 852 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(), protons_cff::time, CastorNumberingScheme::unpackIndex(), verbosity, and ecaldqm::zside().

Referenced by update().

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

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

Referenced by update().

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

Definition at line 659 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

Definition at line 678 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

Definition at line 622 of file CastorShowerLibraryMaker.cc.

References gather_cfg::cout, theFile, and theTree.

Referenced by ~CastorShowerLibraryMaker().

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

Definition at line 743 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

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

729 {
730  if (thePrim==0) return;
731  if (PrimaryMomentum.find(thePrim)==PrimaryMomentum.end()) return;
732  px = PrimaryMomentum[thePrim].x()/GeV;
733  py = PrimaryMomentum[thePrim].y()/GeV;
734  pz = PrimaryMomentum[thePrim].z()/GeV;
735  pInit=PrimaryMomentum[thePrim].mag()/GeV;
736  if (pInit==0) return;
737  double costheta = pz/pInit;
738  double theta = acos(std::min(std::max(costheta,double(-1.)),double(1.)));
739  eta = -log(tan(theta/2.0));
740  phi = (px==0 && py==0) ? 0 : atan2(py,px); // the recommended way of calculating phi
741  phi = PrimaryMomentum[thePrim].phi();
742 }
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 1000 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

1000  {
1001 // Get the total deposited energy and the one from hit not associated to a primary
1002  miss_energy = 0;
1003  tot_energy = 0;
1004  for (int ihit = 0; ihit < theCAFI->entries(); ihit++) {
1005  int id = (*theCAFI)[ihit]->getTrackID();
1006  tot_energy+=(*theCAFI)[ihit]->getEnergyDeposit();
1007  int hit_prim = 0;
1008  for(unsigned int i=0;i<thePrims.size();i++) {
1009  int particleType = thePrims.at(i)->GetPDGcode();
1010  if (MapOfSecondaries[particleType].find(id)!=MapOfSecondaries[particleType].end())
1011  hit_prim = particleType;
1012  }
1013  if (hit_prim==0) {
1014  std::cout << "Track ID " << id << " produced a hit which is not associated with a primary."
1015  << std::endl;
1016  miss_energy+=(*theCAFI)[ihit]->getEnergyDeposit();
1017  }
1018  }
1019 }
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:39
std::map< int, std::set< int > > MapOfSecondaries
std::vector< G4PrimaryParticle * > CastorShowerLibraryMaker::GetPrimary ( const G4Event *  evt)
private

Definition at line 760 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

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

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

Definition at line 699 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

Definition at line 989 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

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

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

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

Referenced by update().

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

Definition at line 962 of file CastorShowerLibraryMaker.cc.

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

Referenced by IsSLReady(), and SLacceptEvent().

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

Definition at line 971 of file CastorShowerLibraryMaker.cc.

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

Referenced by SLacceptEvent().

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

Definition at line 980 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and SLacceptEvent().

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

Definition at line 936 of file CastorShowerLibraryMaker.cc.

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

Referenced by printSLstatus(), and update().

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

Definition at line 945 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

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

Definition at line 954 of file CastorShowerLibraryMaker.cc.

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

Referenced by update().

955 {
956  if (!SLShowerptr) {
957  edm::LogInfo("CastorShowerLibraryMaker") << "\n\nSLnEvtInBinPhi can be called only after BeginOfEvent\n\n";
958  throw SimG4Exception("\n\nnullptr Pointer to the shower library.");
959  }
960  return SLShowerptr->nEvtInBinPhi.at(ebin).at(etabin).at(phibin);
961 }
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 
150  std::cout << " CastorShowerLibraryMaker::Starting new job " << std::endl;
151 }
void CastorShowerLibraryMaker::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

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

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

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

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

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

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