All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CheckAuxDetHit_module.cc
Go to the documentation of this file.
1 // STL includes
2 #include <cmath>
3 
4 // art Framework includes.
5 #include "art/Framework/Core/EDAnalyzer.h"
6 #include "art/Framework/Principal/Event.h"
7 #include "art/Framework/Principal/Handle.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art_root_io/TFileDirectory.h"
10 #include "art_root_io/TFileService.h"
11 #include "art/Framework/Services/Registry/ServiceHandle.h"
12 #include "art/Framework/Principal/Provenance.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 
29 class larg4::CheckAuxDetHit : public art::EDAnalyzer {
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 
45 larg4::CheckAuxDetHit::CheckAuxDetHit(fhicl::ParameterSet const& p) :
46  art::EDAnalyzer(p)
47 {}
48 
50 {
51  art::ServiceHandle<art::TFileService const> tfs;
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 
61 void larg4::CheckAuxDetHit::analyze(const art::Event& event)
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 
77 DEFINE_ART_MODULE(larg4::CheckAuxDetHit)
void analyze(const art::Event &event) override
pdgs p
Definition: selectors.fcl:22
CheckAuxDetHit(fhicl::ParameterSet const &p)
process_name hit
Definition: cheaterreco.fcl:51
std::vector< AuxDetHit > AuxDetHitCollection
Definition: AuxDetHit.h:183
art::ServiceHandle< art::TFileService > tfs