CheckAuxDetHit_module.cc
Go to the documentation of this file.
1 // STL includes
2 #include <cmath>
3 
4 // art Framework includes.
9 #include "art_root_io/TFileDirectory.h"
10 #include "art_root_io/TFileService.h"
13 #include "artg4tk/services/DetectorHolder_service.hh"
15 
16 // Root includes.
17 #include "TFile.h"
18 #include "TH1F.h"
19 #include "TNtuple.h"
20 #include "TDirectory.h"
21 
22 // Other includes.
23 #include "CLHEP/Units/SystemOfUnits.h"
24 
25 namespace larg4 {
26  class CheckAuxDetHit;
27 }
28 
30 public:
31  explicit CheckAuxDetHit(fhicl::ParameterSet const& p);
32 
33 private:
34  void beginJob() override;
35  void analyze(const art::Event& event) override;
36 
37  TH1F* _hnHits{nullptr}; // number of AuxDetHitHits
38  TH1F* _hEdep{nullptr}; // average energy deposition in AuxDetHitHits
39  TH1F* _hID{nullptr}; // AuxDet ID's
40  TH1F* _hexit{nullptr}; // exit points in z
41  TH1F* _hentry{nullptr}; // entry points in z
42  // TNtuple* _ntuple;
43 };
44 
46  art::EDAnalyzer(p)
47 {}
48 
50 {
52  _hnHits = tfs->make<TH1F>("hnHits", "Number of AuxDetHits", 30, 0,30 );
53  _hEdep = tfs->make<TH1F>("hEdep", "Energy deposition in AuxDetHits", 100,0.,4.);
54  _hID = tfs->make<TH1F>("hID", "Id of hit AuxDet", 100,0.,5.);
55  _hexit = tfs->make<TH1F>("hexit", "exit points in z", 100,-100.,100.);
56  _hentry = tfs->make<TH1F>("hentry", "entry points in z", 100,-100.,100.);
57  // _ntuple = tfs->make<TNtuple>("ntuple","Demo ntuple",
58  // "Event:Edep:em_Edep:nonem_Edep:xpos:ypos:zpos:time");
59 } // end beginJob
60 
62 {
63  //std::vector<art::Handle<sim::AuxDetHitCollection>> allSims;
64  //event.getManyByType(allSims);
65  auto allSims = event.getMany<sim::AuxDetHitCollection>();
66  for (auto const& sims : allSims) {
67  _hnHits->Fill(sims->size());
68  for (auto const& hit : *sims) {
69  _hEdep->Fill(hit.GetEnergyDeposited());
70  _hexit->Fill(hit.GetExitZ());
71  _hentry->Fill(hit.GetEntryZ());
72  _hID->Fill(hit.GetID());
73  }
74  }
75 } // end analyze
76 
void analyze(const art::Event &event) override
Geant4 interface.
CheckAuxDetHit(fhicl::ParameterSet const &p)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
p
Definition: test.py:223
Detector simulation of raw signals on wires.
std::vector< AuxDetHit > AuxDetHitCollection
Definition: AuxDetHit.h:183
Event finding and building.