Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00009 #undef debug
00010 #ifndef CastorShowerLibraryMaker_h
00011 #define CastorShowerLibraryMaker_h
00012
00013 #include "SimG4Core/Notification/interface/BeginOfJob.h"
00014 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00015 #include "SimG4Core/Notification/interface/EndOfRun.h"
00016 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00017 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00018
00019 #include "G4RunManager.hh"
00020 #include "G4SDManager.hh"
00021 #include "G4Step.hh"
00022 #include "G4Track.hh"
00023 #include "G4Event.hh"
00024 #include "G4PrimaryVertex.hh"
00025 #include "G4VProcess.hh"
00026 #include "G4HCofThisEvent.hh"
00027 #include "G4UserEventAction.hh"
00028 #include "CLHEP/Units/SystemOfUnits.h"
00029 #include "CLHEP/Units/PhysicalConstants.h"
00030
00031 #include "SimG4Core/Notification/interface/Observer.h"
00032 #include "SimG4Core/Watcher/interface/SimWatcher.h"
00033
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 #include "FWCore/ServiceRegistry/interface/Service.h"
00036 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00037
00038
00039 #include "SimDataFormats/CaloHit/interface/CastorShowerLibraryInfo.h"
00040 #include "SimDataFormats/CaloHit/interface/CastorShowerEvent.h"
00041
00042 #include <cassert>
00043 #include <iostream>
00044 #include <string>
00045 #include <map>
00046 #include <set>
00047 #include <cmath>
00048 #include <memory>
00049 #include <vector>
00050
00051 #include <CLHEP/Random/Randomize.h>
00052
00053 #include "TROOT.h"
00054 #include "TFile.h"
00055 #include "TH1.h"
00056 #include "TH2.h"
00057 #include "TProfile.h"
00058 #include "TNtuple.h"
00059 #include "TRandom.h"
00060 #include "TLorentzVector.h"
00061 #include "TUnixSystem.h"
00062 #include "TSystem.h"
00063 #include "TMath.h"
00064 #include "TF1.h"
00065
00066
00067 class G4Step;
00068 class BeginOfJob;
00069 class BeginOfRun;
00070 class EndOfRun;
00071 class BeginOfEvent;
00072 class EndOfEvent;
00073
00074
00075
00076
00077
00078
00079 typedef std::vector<std::vector<std::vector<std::vector<CastorShowerEvent> > > > SLBin3D;
00080
00081 class CastorShowerLibraryMaker : public SimWatcher,
00082 public Observer<const BeginOfJob *>,
00083 public Observer<const BeginOfRun *>,
00084 public Observer<const EndOfRun *>,
00085 public Observer<const BeginOfEvent *>,
00086 public Observer<const EndOfEvent *>,
00087 public Observer<const G4Step *> {
00088
00089 public:
00090
00091 CastorShowerLibraryMaker(const edm::ParameterSet &p);
00092 virtual ~CastorShowerLibraryMaker();
00093
00094 private:
00095 typedef int ebin;
00096 typedef int etabin;
00097 typedef int phibin;
00098
00099 struct ShowerLib {
00100 CastorShowerLibraryInfo SLInfo;
00101 SLBin3D SLCollection;
00102 std::vector<double> SLEnergyBins;
00103 std::vector<double> SLEtaBins;
00104 std::vector<double> SLPhiBins;
00105 unsigned int nEvtPerBinE;
00106 unsigned int nEvtPerBinEta;
00107 unsigned int nEvtPerBinPhi;
00108 std::vector<int> nEvtInBinE;
00109 std::vector<std::vector<int> > nEvtInBinEta;
00110 std::vector<std::vector<std::vector<int> > > nEvtInBinPhi;
00111 };
00112
00113
00114 void update(const BeginOfJob * run);
00115 void update(const BeginOfRun * run);
00116 void update(const EndOfRun * run);
00117 void update(const BeginOfEvent * evt);
00118 void update(const EndOfEvent * evt);
00119 void update(const G4Step * step);
00120
00121 private:
00122
00123 void Finish();
00124
00125
00126 int verbosity;
00127 std::string eventNtFileName;
00128
00129 unsigned int NPGParticle;
00130 std::vector<int> PGParticleIDs;
00131 bool DoHadSL;
00132 bool DoEmSL;
00133
00134
00135 CastorShowerLibraryInfo *emInfo;
00136 CastorShowerLibraryInfo *hadInfo;
00137 CastorShowerEvent *emShower;
00138 CastorShowerEvent *hadShower;
00139 ShowerLib emSLHolder;
00140 ShowerLib hadSLHolder;
00141 ShowerLib* SLShowerptr;
00142 std::map<int,std::set<int> > MapOfSecondaries;
00143
00144
00145
00146 int FindEnergyBin(double e);
00147 int FindEtaBin(double eta);
00148 int FindPhiBin(double phi);
00149 bool SLacceptEvent(int, int, int);
00150 bool IsSLReady();
00151 void GetKinematics(G4PrimaryParticle* ,
00152 double& px, double& py, double& pz, double& pInit, double& eta, double& phi);
00153
00154 std::vector<G4PrimaryParticle*> GetPrimary(const EndOfEvent * );
00155 bool FillShowerEvent(G4HCofThisEvent* ,CastorShowerEvent*, int);
00156 void InitSLHolder(ShowerLib& );
00157
00158 void printSLstatus(int , int, int);
00159 int& SLnEvtInBinE(int ebin);
00160 int& SLnEvtInBinEta(int ebin, int etabin);
00161 int& SLnEvtInBinPhi(int ebin, int etabin, int phibin);
00162 bool SLisEBinFilled(int ebin);
00163 bool SLisEtaBinFilled(int ebin, int etabin);
00164 bool SLisPhiBinFilled(int ebin, int etabin, int phibin);
00165
00166
00167 TFile* theFile;
00168 TTree* theTree;
00169
00170 int eventIndex;
00171 int stepIndex;
00172
00173 };
00174
00175 #endif // CastorShowerLibraryMaker_h