LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CheckTrackerHits_module.cc
Go to the documentation of this file.
1 //
2 // __ __ __ __ __
3 // ____ ______/ /_____ _/ // / / /_/ /__
4 // / __ `/ ___/ __/ __ `/ // /_/ __/ //_/
5 // / /_/ / / / /_/ /_/ /__ __/ /_/ ,<
6 // \__,_/_/ \__/\__, / /_/ \__/_/|_|
7 // /____/
8 //
9 // artg4tk: art based Geant 4 Toolkit
10 //
11 //=============================================================================
12 // CheckTrackerHits_module.cc: Analyzer module that demonstrates access to
13 // Calorimeter hits
14 // and makes some histograms
15 //
16 // Author: Hans Wenzel (Fermilab)
17 //=============================================================================
18 
19 // art Framework includes.
26 #include "art_root_io/TFileService.h"
27 
28 // artg4tk includes:
29 #include "artg4tk/pluginDetectors/gdml/TrackerHit.hh"
30 
31 // Root includes.
32 #include "TH1F.h"
33 
34 // Other includes.
35 #include "CLHEP/Units/SystemOfUnits.h"
36 
37 // C++ includes
38 #include <math.h>
39 
40 using namespace std;
41 namespace artg4tk {
42  class CheckTrackerHits;
43 }
44 
46 public:
47  explicit CheckTrackerHits(fhicl::ParameterSet const& p);
48  void beginJob() override;
49  void beginRun(const art::Run& Run) override;
50  void analyze(const art::Event& event) override;
51 
52 private:
53  TH1F* _hnHits; // number of TrackerHits
54  TH1F* _hEdep; // total energy deposition
55  TH1F* _hrEdep; // radius of Energy deposition
56  TH1F* _hzEdep; // z position of Energy deposition
57 };
58 
60  : art::EDAnalyzer(p), _hnHits(0), _hEdep(0), _hrEdep(), _hzEdep(0)
61 {}
62 
63 void
65 {
66  std::cout << "******************************Run: " << thisRun.id() << std::endl;
67 }
68 
69 void
71 {
73  _hnHits = tfs->make<TH1F>("hnHits", "Number of TrackerArtHits", 200, 0., 10000.);
74  _hEdep = tfs->make<TH1F>("hEdep", "total Energy deposition in TrackerArtHits", 200, 0., 1.2);
75  _hrEdep =
76  tfs->make<TH1F>("hrEdep", "radius of total Energy deposition in TrackerArtHits", 300, 0., 300.);
77  _hzEdep = tfs->make<TH1F>("hzEdep", "total Energy deposition in TrackerArtHits", 600, 0., 600.);
78 } // end beginJob
79 
80 void
82 {
83  typedef std::vector<art::Handle<TrackerHitCollection>> HandleVector;
84  auto allSims = event.getMany<TrackerHitCollection>();
85 
86  for (HandleVector::const_iterator i = allSims.begin(); i != allSims.end(); ++i) {
87  const TrackerHitCollection& sims(**i);
88  double sumE = 0.0;
89  _hnHits->Fill(sims.size());
90  for (TrackerHitCollection::const_iterator j = sims.begin(); j != sims.end(); ++j) {
91  const TrackerHit& hit = *j;
92  double radius = 0.1 * sqrt(hit.xpos * hit.xpos + hit.ypos * hit.ypos);
93  _hrEdep->Fill(radius);
94  _hzEdep->Fill(0.1 * hit.zpos + 300., hit.Edep);
95  sumE = sumE + hit.Edep;
96  }
97  _hEdep->Fill(sumE / CLHEP::GeV);
98  }
99 
100 } // end analyze
101 
RunID id() const
Definition: Run.cc:21
STL namespace.
intermediate_table::const_iterator const_iterator
void beginRun(const art::Run &Run) override
Definition: Run.h:37
void analyze(const art::Event &event) override
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
void beginJob()
Definition: Breakpoints.cc:14
Float_t radius
Definition: plot.C:23
Detector simulation of raw signals on wires.
CheckTrackerHits(fhicl::ParameterSet const &p)
Definition: MVAAlg.h:12
Event finding and building.