PlotEventDetails_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // PlotEventDetails_module.cc
4 //
5 // Author: Leigh Whitehead (leigh.howard.whitehead@cern.ch)
6 //
7 // Module to provide basic event information for protoDUNE
8 // Nearline Monitoring
9 //
10 ////////////////////////////////////////////////////////////////////////
11 
19 #include "fhiclcpp/ParameterSet.h"
21 
25 #include "art_root_io/TFileService.h"
26 #include "art_root_io/TFileDirectory.h"
27 #include "canvas/Persistency/Common/FindManyP.h"
28 
29 #include "TH1F.h"
30 
31 namespace nlana {
32  class PlotEventDetails;
33 }
34 
36 public:
37  explicit PlotEventDetails(fhicl::ParameterSet const & p);
38  // The compiler-generated destructor is fine for non-base
39  // classes without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  PlotEventDetails(PlotEventDetails const &) = delete;
44  PlotEventDetails & operator = (PlotEventDetails const &) = delete;
46 
47  // Required functions.
48  void analyze(art::Event const & e) override;
49 
50  // Selected optional functions.
51  void beginJob() override;
52  void endJob() override;
53  void reconfigure(fhicl::ParameterSet const & p) ;
54 
55 private:
56 
60 
62 
63  // Number of tracks
65  TH1F *fNTracksHist;
68 
69 };
70 
71 
73  :
74  EDAnalyzer(pset) // ,
75  // More initializers here.
76 {
77  reconfigure(pset);
78 
79 }
80 
81 //--------------------------------------------------------------------
83 {
84  // Implementation of optional member function here.
85 
87 
88  fNParticlesHist = tfs->make<TH1F>("NParticles",";Number of particles",50,0,200);
89  fNTracksHist = tfs->make<TH1F>("NTracks",";Number of tracks",50,0,200);
90  fNLongTracksHist = tfs->make<TH1F>("NLongTracks",";Number of long tracks",50,0,200);
91  fNShowersHist = tfs->make<TH1F>("NShowers",";Number of showers",50,0,200);
92 
93 } // beginJob
94 
95 //--------------------------------------------------------------------
97 {
98  // The names of the module that produced the reconstructed objects
99  fParticleProducerLabel = pset.get<std::string>("ParticleProducerLabel");
100  fTrackProducerLabel = pset.get<std::string>("TrackProducerLabel");
101  fShowerProducerLabel = pset.get<std::string>("ShowerProducerLabel");
102 
103  // Threshold cut for considering a track as long
104  fLongTrackCut = pset.get<float>("LongTrackThreshold");
105 
106 } // reconfigure
107 
108 
109 //--------------------------------------------------------------------
111 {
112 
113 } // endJob
114 
115 //--------------------------------------------------------------------
117 {
118 
119  // Try finding some tracks
120  art::ValidHandle< std::vector<recob::PFParticle> > particleHandle = evt.getValidHandle<std::vector<recob::PFParticle> >(fParticleProducerLabel);
121  art::ValidHandle< std::vector<recob::Track> > trackHandle = evt.getValidHandle<std::vector<recob::Track> >(fTrackProducerLabel);
122  art::ValidHandle< std::vector<recob::Shower> > showerHandle = evt.getValidHandle<std::vector<recob::Shower> >(fShowerProducerLabel);
123 
124  fNParticlesHist->Fill(particleHandle->size());
125 
126  fNTracksHist->Fill(trackHandle->size());
127  unsigned int nLongTracks = 0;
128  for(auto const track : (*trackHandle)){
129  if(track.Length() > fLongTrackCut) ++nLongTracks;
130  }
131  fNLongTracksHist->Fill(nLongTracks);
132 
133  fNShowersHist->Fill(showerHandle->size());
134 
135 } // analyze
136 
137 
PlotEventDetails(fhicl::ParameterSet const &p)
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void reconfigure(fhicl::ParameterSet const &p)
T get(std::string const &key) const
Definition: ParameterSet.h:271
void analyze(art::Event const &e) override
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
PlotEventDetails & operator=(PlotEventDetails const &)=delete
Provides recob::Track data product.
TCEvent evt
Definition: DataStructs.cxx:7