PlotOpticalDetails_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // PlotOpticalDetails_module.cc
4 //
5 // Author: Leigh Whitehead (leigh.howard.whitehead@cern.ch)
6 //
7 // Module to provide basic photon detector information for protoDUNE
8 // Nearline Monitoring
9 //
10 ////////////////////////////////////////////////////////////////////////
11 
12 // ROOT includes
13 #include "TH1D.h"
14 #include "TH2.h"
15 #include "TLorentzVector.h"
16 #include "TVector3.h"
17 #include "TTree.h"
18 
19 // C++ includes
20 #include <vector>
21 #include <iostream>
22 #include <cstring>
23 #include <sstream>
24 #include "math.h"
25 #include <climits>
26 
27 // LArSoft includes
31 
32 // ART includes.
35 #include "fhiclcpp/ParameterSet.h"
40 #include "art_root_io/TFileService.h"
41 #include "art_root_io/TFileDirectory.h"
44 #include "canvas/Persistency/Common/FindManyP.h"
45 
46 namespace nlana {
47 
49  public:
50 
51  // Standard constructor and destructor for an ART module.
53  virtual ~PlotOpticalDetails();
54 
55  // This method is called once, at the start of the job. In this
56  // example, it will define the histogram we'll write.
57  void beginJob();
58 
59  // The analyzer routine, called once per event.
60  void analyze (const art::Event&);
61 
62  private:
63 
64  // The stuff below is the part you'll most likely have to change to
65  // go from this custom example to your own task.
66 
67  // The parameters we'll read from the .fcl file.
68  std::string fOpFlashModuleLabel; // Input tag for OpFlash collection
69 
70  TH1D *hFlashTime;
71  TH1D *hNFlash;
73  };
74 
75 }
76 
77 //-----------------------------------------------------------------------
78 // Constructor
80  : EDAnalyzer(pset)
81 {
82 
83  // Indicate that the Input Module comes from .fcl
84  fOpFlashModuleLabel = pset.get<std::string>("OpFlashLabel");
85 
87 
88  // Make a few plots
89  hFlashTime = tfs->make<TH1D>("hFlashTime","",50,-5000,5000);
90  hNFlash = tfs->make<TH1D>("hNFlash","",50,0,250);
91  hNHitPerFlash = tfs->make<TH1D>("hNHitPerFlash","",50,0,200);
92 }
93 
94 //-----------------------------------------------------------------------
95 // Destructor
97 {}
98 
99 //-----------------------------------------------------------------------
101 {}
102 
103 //-----------------------------------------------------------------------
105 {
106  // Get flashes from event
107  auto FlashHandle = evt.getHandle< std::vector< recob::OpFlash > >(fOpFlashModuleLabel);
108 
109  // Get assosciations between flashes and hits
110  art::FindManyP< recob::OpHit > Assns(FlashHandle, evt, fOpFlashModuleLabel);
111 
112  hNFlash->Fill(FlashHandle->size());
113 
114  // For every OpFlash in the vector
115  for(unsigned int i = 0; i < FlashHandle->size(); ++i)
116  {
117 
118  // Get OpFlash and associated hits
119  art::Ptr< recob::OpFlash > TheFlashPtr(FlashHandle, i);
120  recob::OpFlash TheFlash = *TheFlashPtr;
121 
122  // Find the hits associated to this flash
123  std::vector< art::Ptr<recob::OpHit> > matchedHits = Assns.at(i);
124 
125  hFlashTime->Fill(TheFlash.Time());
126 
127  hNHitPerFlash->Fill(matchedHits.size());
128 
129  } // End loop over flashes
130 
131 }
132 
133 namespace nlana {
135 }
136 
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
PlotOpticalDetails(const fhicl::ParameterSet &)
double Time() const
Definition: OpFlash.h:106
void analyze(const art::Event &)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
T get(std::string const &key) const
Definition: ParameterSet.h:271
TCEvent evt
Definition: DataStructs.cxx:7