CheckSimEnergyDeposit_module.cc
Go to the documentation of this file.
1 // art Framework includes.
6 #include "art_root_io/TFileService.h"
7 #include "art_root_io/TFileDirectory.h"
9 #include "artg4tk/services/DetectorHolder_service.hh"
11 
12 // Root includes.
13 #include "TH1F.h"
14 #include "TNtuple.h"
15 
16 // STL includes.
17 #include <cmath>
18 
19 // Other includes.
20 #include "CLHEP/Units/SystemOfUnits.h"
21 
22 using namespace std;
23 namespace larg4 {
24  class CheckSimEnergyDeposit;
25 }
26 
28 public:
29 
31 
32 private:
33  void beginJob() override;
34  void analyze(const art::Event& event) override;
35 
36  TH1F* _hnHits{nullptr}; // number of SimEnergyDepositHits
37  TH1F* _hEdep{nullptr}; // average energy deposition in SimEnergyDepositHits
38  TH1F* _hnumPhotons{nullptr}; // number of Photons per SimEnergyDepositHits
39  TH1F* _hLandauPhotons{nullptr}; // Edep/cm SimEnergyDepositHits
40  TH1F* _hLandauEdep{nullptr}; // number of Photons/cm SimEnergyDepositHits
41  TH1F* _hSteplength{nullptr}; // Geant 4 step length
42  TNtuple* _ntuple{nullptr};
43 };
44 
46  art::EDAnalyzer(p)
47 {}
48 
50 {
52  _hnHits = tfs->make<TH1F>("hnHits", "Number of SimEnergyDeposits", 300, 0, 0);
53  _hEdep = tfs->make<TH1F>("hEdep", "Energy deposition in SimEnergyDeposits", 100,0.,0.02);
54  _hnumPhotons = tfs->make<TH1F>("hnumPhotons", "number of photons per SimEnergyDeposit", 100,0.,500.);
55  _hLandauPhotons= tfs->make<TH1F>("hLandauPhotons", "number of photons/cm", 100,0.,2000000.);
56  _hLandauEdep= tfs->make<TH1F>("hLandauEdep", "Edep/cm", 100,0.,10.);
57  _hSteplength= tfs->make<TH1F>("hSteplength", "geant 4 step length", 100,0.,0.05);
58  _ntuple = tfs->make<TNtuple>("ntuple","Demo ntuple",
59  "Event:Edep:em_Edep:nonem_Edep:xpos:ypos:zpos:time");
60 } // end beginJob
61 
63 {
64  //std::vector<art::Handle<sim::SimEnergyDepositCollection>> allSims;
65  //event.getManyByType(allSims);
66  auto allSims = event.getMany<sim::SimEnergyDepositCollection>();
67  for (auto const& sims : allSims) {
68  double sumPhotons=0.0;
69  double sumE = 0.0;
70  _hnHits->Fill(sims->size());
71  for (auto const& hit : *sims) {
72  // sum up energy deposit in a 1cm slice of liquid Argon.
73  if (std::abs(hit.EndZ())<0.5) {
74  sumPhotons= sumPhotons + hit.NumPhotons();
75  sumE= sumE +hit.Energy();
76  }
77  _hnumPhotons->Fill( hit.NumPhotons());
78  _hEdep->Fill( hit.Energy()); // energy deposit in MeV
79  _hSteplength->Fill( hit.StepLength()); // step length in cm
80  /*
81  _ntuple->Fill(event.event(),
82  hit.GetEdep(),
83  hit.GetEdepEM(),
84  hit.GetEdepnonEM(),
85  hit.GetXpos(),
86  hit.GetYpos(),
87  hit.GetZpos(),
88  hit.GetTime());
89  */
90  }
91  _hLandauPhotons->Fill(sumPhotons);
92  _hLandauEdep->Fill(sumE);
93  }
94 } // end analyze
95 
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
Geant4 interface.
STL namespace.
CheckSimEnergyDeposit(fhicl::ParameterSet const &p)
T abs(T value)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void beginJob()
Definition: Breakpoints.cc:14
p
Definition: test.py:223
Detector simulation of raw signals on wires.
std::vector< SimEnergyDeposit > SimEnergyDepositCollection
contains information for a single step in the detector simulation
void analyze(const art::Event &event) override
Event finding and building.