All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
opdet::OpHitAna Class Reference
Inheritance diagram for opdet::OpHitAna:

Public Member Functions

 OpHitAna (const fhicl::ParameterSet &)
 
void analyze (const art::Event &)
 

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
 

Detailed Description

Definition at line 33 of file OpHitAna_module.cc.

Constructor & Destructor Documentation

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

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 
94  art::ServiceHandle<OpDigiProperties> odp;
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  {
108  art::ServiceHandle<art::TFileService const> tfs;
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 fInputModule
art::ServiceHandle< art::TFileService > tfs

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
124  art::Handle< std::vector< recob::OpHit > > HitHandle;
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.
135  art::ServiceHandle<art::TFileService const> tfs;
136 
137  art::ServiceHandle<geo::Geometry const> geom;
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);",
148  int((fTimeEnd - fTimeBegin) * fSampleFreq),
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  }
unsigned int event
Definition: DataStructs.h:634
double PeakTime() const
Definition: OpHit.h:88
double PE() const
Definition: OpHit.h:95
std::string fInputModule
art::ServiceHandle< art::TFileService > tfs
TCEvent evt
Definition: DataStructs.cxx:8
int OpChannel() const
Definition: OpHit.h:86

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: