Public Member Functions | Private Attributes | List of all members
opdet::OpHitAna Class Reference
Inheritance diagram for opdet::OpHitAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 OpHitAna (const fhicl::ParameterSet &)
 
void analyze (const art::Event &)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fInputModule
 
float fSampleFreq
 
float fTimeBegin
 
float fTimeEnd
 
bool fMakeHistPerChannel
 
bool fMakeHistAllChannels
 
bool fMakeHitTree
 
TTree * fHitTree
 
Int_t fEventID
 
Int_t fOpChannel
 
Float_t fPeakTime
 
Float_t fNPe
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 33 of file OpHitAna_module.cc.

Constructor & Destructor Documentation

opdet::OpHitAna::OpHitAna ( const fhicl::ParameterSet )

Definition at line 87 of file OpHitAna_module.cc.

88  : EDAnalyzer(pset)
89  {
90 
91  // Indicate that the Input Module comes from .fcl
92  fInputModule = pset.get<std::string>("InputModule");
93 
95  fTimeBegin = odp->TimeBegin();
96  fTimeEnd = odp->TimeEnd();
97  fSampleFreq = odp->SampleFreq();
98 
99 
100  fMakeHistPerChannel = pset.get<bool>("MakeHistPerChannel");
101  fMakeHistAllChannels = pset.get<bool>("MakeHistAllChannels");
102  fMakeHitTree = pset.get<bool>("MakeHitTree");
103 
104  // If required, make TTree for output
105 
106  if(fMakeHitTree)
107  {
109  fHitTree = tfs->make<TTree>("HitTree","HitTree");
110  fHitTree->Branch("EventID", &fEventID, "EventID/I");
111  fHitTree->Branch("OpChannel", &fOpChannel, "OpChannel/I");
112  fHitTree->Branch("PeakTime", &fPeakTime, "PeakTime/F");
113  fHitTree->Branch("NPe", &fNPe, "NPe/F");
114  }
115 
116 
117  }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fInputModule

Member Function Documentation

void opdet::OpHitAna::analyze ( const art::Event evt)

Definition at line 120 of file OpHitAna_module.cc.

121  {
122 
123  // Create a handle for our vector of pulses
125 
126  // Create string for histogram name
127  char HistName[50];
128 
129 
130  // Read in HitHandle
131  evt.getByLabel(fInputModule, HitHandle);
132 
133  // Access ART's TFileService, which will handle creating and writing
134  // histograms for us.
136 
138  int NOpChannels = geom->NOpChannels();
139 
140  std::vector<TH1D*> HitHist;
141 
142  sprintf(HistName, "Event %d AllOpDets", evt.id().event());
143 
144  TH1D * AllHits = nullptr;
146  {
147  AllHits = tfs->make<TH1D>(HistName, ";t (ns);",
149  fTimeBegin * 1000.,
150  fTimeEnd * 1000.);
151  }
152 
153  for(int i=0; i!=NOpChannels; ++i)
154  {
155 
156  sprintf(HistName, "Event %d OpDet %i", evt.id().event(), i);
157  if(fMakeHistPerChannel) HitHist.push_back ( tfs->make<TH1D>(HistName, ";t (ns);",
158  int((fTimeEnd - fTimeBegin) * fSampleFreq),
159  fTimeBegin * 1000.,
160  fTimeEnd * 1000.));
161 
162  }
163 
164 
165  fEventID = evt.id().event();
166 
167 
168  // For every OpHit in the vector
169  for(unsigned int i = 0; i < HitHandle->size(); ++i)
170  {
171  // Get OpHit
172  art::Ptr< recob::OpHit > TheHitPtr(HitHandle, i);
173  recob::OpHit TheHit = *TheHitPtr;
174 
175  fOpChannel = TheHit.OpChannel();
176  fNPe = TheHit.PE();
177  fPeakTime = TheHit.PeakTime();
178 
179  if(fMakeHitTree)
180  fHitTree->Fill();
181 
183  {
184  if(fOpChannel>int(HitHist.size()))
185  {
186  mf::LogError("OpHitAna")<<"Error : Trying to fill channel out of range, " << fOpChannel;
187  }
188  HitHist[fOpChannel]->Fill(fPeakTime,fNPe);
189  }
190 
191  if(fMakeHistAllChannels) AllHits->Fill(fPeakTime, fNPe);
192 
193  }
194 
195  }
double PeakTime() const
Definition: OpHit.h:64
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
double PE() const
Definition: OpHit.h:69
Index NOpChannels(Index)
std::string fInputModule
EventNumber_t event() const
Definition: EventID.h:116
int OpChannel() const
Definition: OpHit.h:62
EventID id() const
Definition: Event.cc:34

Member Data Documentation

Int_t opdet::OpHitAna::fEventID
private

Definition at line 61 of file OpHitAna_module.cc.

TTree* opdet::OpHitAna::fHitTree
private

Definition at line 60 of file OpHitAna_module.cc.

std::string opdet::OpHitAna::fInputModule
private

Definition at line 48 of file OpHitAna_module.cc.

bool opdet::OpHitAna::fMakeHistAllChannels
private

Definition at line 56 of file OpHitAna_module.cc.

bool opdet::OpHitAna::fMakeHistPerChannel
private

Definition at line 55 of file OpHitAna_module.cc.

bool opdet::OpHitAna::fMakeHitTree
private

Definition at line 57 of file OpHitAna_module.cc.

Float_t opdet::OpHitAna::fNPe
private

Definition at line 64 of file OpHitAna_module.cc.

Int_t opdet::OpHitAna::fOpChannel
private

Definition at line 62 of file OpHitAna_module.cc.

Float_t opdet::OpHitAna::fPeakTime
private

Definition at line 63 of file OpHitAna_module.cc.

float opdet::OpHitAna::fSampleFreq
private

Definition at line 49 of file OpHitAna_module.cc.

float opdet::OpHitAna::fTimeBegin
private

Definition at line 50 of file OpHitAna_module.cc.

float opdet::OpHitAna::fTimeEnd
private

Definition at line 51 of file OpHitAna_module.cc.


The documentation for this class was generated from the following file: