1 #include "G4Electron.hh" 2 #include "G4Positron.hh" 3 #include "G4PrimaryParticle.hh" 4 #include "G4PrimaryVertex.hh" 5 #include "G4SDManager.hh" 7 #include "G4VProcess.hh" 17 using namespace CLHEP;
24 recoEnergyScaleEB_ = myP.
getParameter<
double>(
"recoEnergyScaleEB");
25 recoEnergyScaleEE_ = myP.
getParameter<
double>(
"recoEnergyScaleEE");
27 histFile_ =
new TFile(histFileName_.c_str(),
"RECREATE");
29 TH1::AddDirectory(kTRUE);
31 em_incE =
new TH1F(
"em_incE",
"Incoming energy at Ecal;E (GeV);Number of Events", 500, 0.0, 500.0);
32 em_vtx_rho =
new TH1F(
"em_vtx_rho",
"vertex position;#rho (cm);Number of Events", 100, 0.0, 10.0);
33 em_vtx_z =
new TH1F(
"em_vtx_z",
"vertex position;z (cm);Number of Events", 100, -10.0, 10.0);
35 eb_ssp_rho =
new TH1F(
"eb_ssp_rho",
"Shower starting position;#rho (cm);Number of Events", 200, 0.0, 200.0);
36 eb_hit_long =
new TH1F(
"eb_hit_long",
37 "longitudinal hit position;shower depth (cm);Number " 38 "of energy weighted hits",
42 eb_hit_lat =
new TH1F(
"eb_hit_lat",
"lateral hit position;arm (cm);Number of energy weighted hits", 100, 0.0, 5.0);
44 "eb_hit_rz",
"hit position along the shower direction;shower depth (cm);arm (cm)", 400, 0.0, 200.0, 100, 0.0, 5.0);
45 eb_hit_long_sd =
new TH1F(
"eb_hit_long_sd",
46 "longitudinal hit position in Sensitive Detector;shower depth " 47 "(cm);Number of energy weighted hits",
51 eb_hit_lat_sd =
new TH1F(
"eb_hit_lat_sd",
52 "lateral hit position in Sensitive Detector;arm " 53 "(cm);Number of energy weighted hits",
57 eb_hit_rz_sd =
new TH2F(
"eb_hit_rz_sd",
58 "hit position along the shower direction in " 59 "Sensitive Detector;shower depth (cm);arm (cm)",
67 ee_ssp_z =
new TH1F(
"ee_ssp_z",
"Shower starting position;z (cm);Number of Events", 800, -400.0, 400.0);
68 ee_hit_long =
new TH1F(
"ee_hit_long",
69 "longitudinal hit position;shower depth (cm);Number " 70 "of energy weighted hits",
74 ee_hit_lat =
new TH1F(
"ee_hit_lat",
"lateral hit position;arm (cm);Number of energy weighted hits", 100, 0.0, 5.0);
76 "ee_hit_rz",
"hit position along the shower direction;shower depth (cm);arm (cm)", 800, 0.0, 400.0, 100, 0.0, 5.0);
77 ee_hit_long_sd =
new TH1F(
"ee_hit_long_sd",
78 "longitudinal hit position in Sensitive Detector;shower depth " 79 "(cm);Number of energy weighted hits",
83 ee_hit_lat_sd =
new TH1F(
"ee_hit_lat_sd",
84 "lateral hit position in Sensitive Detector;arm " 85 "(cm);Number of energy weighted hits",
89 ee_hit_rz_sd =
new TH2F(
"ee_hit_rz_sd",
90 "hit position along the shower direction in " 91 "Sensitive Detector;shower depth (cm);arm (cm)",
109 const G4Event *evt = (*g4Event)();
110 inc_vertex = evt->GetPrimaryVertex(0)->GetPosition();
111 inc_position = inc_vertex;
112 inc_direction = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMomentum().unit();
113 inc_energy = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMomentum().mag();
116 em_incE->Fill(inc_energy / GeV);
117 em_vtx_rho->Fill(inc_vertex.rho() / cm);
118 em_vtx_z->Fill(inc_vertex.z() / cm);
120 if (
std::abs(inc_direction.eta()) < 1.5)
121 eb_ssp_rho->Fill(inc_position.rho() / cm);
123 ee_ssp_z->Fill(inc_position.z() / cm);
129 if (aStep ==
nullptr)
132 double hitEnergy = aStep->GetTotalEnergyDeposit();
134 if (hitEnergy < 1.0
e-6)
137 bool inEB =
std::abs(inc_direction.eta()) < 1.5;
139 out_energy += hitEnergy;
142 G4ThreeVector hitPosition = aStep->GetPreStepPoint()->GetPosition();
143 G4ThreeVector
diff = hitPosition - inc_position;
144 double angle =
diff.angle(inc_direction);
148 G4VSensitiveDetector *aSensitive = aStep->GetPreStepPoint()->GetSensitiveDetector();
151 hitEnergy *= recoEnergyScaleEB_;
152 eb_hit_long->Fill(diff_z / cm, hitEnergy / GeV);
153 eb_hit_lat->Fill(diff_r / cm, hitEnergy / GeV);
154 eb_hit_rz->Fill(diff_z / cm, diff_r / cm, hitEnergy / GeV);
156 eb_hit_long_sd->Fill(diff_z / cm, hitEnergy / GeV);
157 eb_hit_lat_sd->Fill(diff_r / cm, hitEnergy / GeV);
158 eb_hit_rz_sd->Fill(diff_z / cm, diff_r / cm, hitEnergy / GeV);
161 hitEnergy *= recoEnergyScaleEE_;
162 ee_hit_long->Fill(diff_z / cm, hitEnergy / GeV);
163 ee_hit_lat->Fill(diff_r / cm, hitEnergy / GeV);
164 ee_hit_rz->Fill(diff_z / cm, diff_r / cm, hitEnergy / GeV);
166 ee_hit_long_sd->Fill(diff_z / cm, hitEnergy / GeV);
167 ee_hit_lat_sd->Fill(diff_r / cm, hitEnergy / GeV);
168 ee_hit_rz_sd->Fill(diff_z / cm, diff_r / cm, hitEnergy / GeV);
#define DEFINE_SIMWATCHER(type)
T getParameter(std::string const &) const
Sin< T >::type sin(const T &t)
GflashG4Watcher(const edm::ParameterSet &p)
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
~GflashG4Watcher() override
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)