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

Public Member Functions

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

Private Attributes

std::string fInputModule
 
std::string fInstanceName
 
float fSampleFreq
 
float fTimeBegin
 
float fTimeEnd
 
float fZeroSupThresh
 
double fSPEAmp
 
bool fMakeBipolarHist
 
bool fMakeUnipolarHist
 

Detailed Description

Definition at line 29 of file OpDigiAna_module.cc.

Constructor & Destructor Documentation

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

Definition at line 67 of file OpDigiAna_module.cc.

68  : EDAnalyzer(pset)
69  {
70 
71  art::ServiceHandle<OpDigiProperties> odp;
72  fSPEAmp = odp->GetSPECumulativeAmplitude();
73  fTimeBegin = odp->TimeBegin();
74  fTimeEnd = odp->TimeEnd();
75  fSampleFreq = odp->SampleFreq();
76 
77 
78  // Indicate that the Input Module comes from .fcl
79  fInputModule = pset.get<std::string>("InputModule");
80  fInstanceName = pset.get<std::string>("InstanceName");
81  fZeroSupThresh = pset.get<double>("ZeroSupThresh") * fSPEAmp;
82 
83  fMakeBipolarHist = pset.get<bool>("MakeBipolarHist");
84  fMakeUnipolarHist = pset.get<bool>("MakeUnipolarHist");
85 
86 
87  }
std::string fInputModule
std::string fInstanceName

Member Function Documentation

void opdet::OpDigiAna::analyze ( const art::Event &  evt)

Definition at line 90 of file OpDigiAna_module.cc.

91  {
92 
93  // Create a handle for our vector of pulses
94  art::Handle< std::vector< raw::OpDetPulse > > WaveformHandle;
95 
96  // Create string for histogram name
97  char HistName[50];
98 
99 
100  // Read in WaveformHandle
101  evt.getByLabel(fInputModule, fInstanceName, WaveformHandle);
102 
103  // Access ART's TFileService, which will handle creating and writing
104  // histograms for us.
105  art::ServiceHandle<art::TFileService const> tfs;
106 
107 
108  std::vector<std::string> histnames;
109 
110  // For every OpDet waveform in the vector given by WaveformHandle
111  for(unsigned int i = 0; i < WaveformHandle->size(); ++i)
112  {
113  // Get OpDetPulse
114  art::Ptr< raw::OpDetPulse > ThePulsePtr(WaveformHandle, i);
115  raw::OpDetPulse ThePulse = *ThePulsePtr;
116 
117  // Make an instance of histogram and its pointer, changing all units to ns
118  // Notice that histogram axis is in ns but binned by 1/64MHz;
119  // appropriate conversions are made from beginning and end time
120  // in us, and frequency in MHz.
121 
122  // Make sure the histogram name is unique since there can be multiple pulses
123  // per event and photo detector
124  unsigned int pulsenum = 0;
125  while (true) {
126  sprintf(HistName, "Event_%d_OpDet_%i_Pulse_%i", evt.id().event(), ThePulse.OpChannel(), pulsenum);
127  auto p = std::find(histnames.begin(), histnames.end(), HistName);
128  if ( p != histnames.end() ) {
129  // Found a duplicate
130  pulsenum++;
131  }
132  else {
133  // Found a unique name
134  histnames.push_back(HistName);
135  break;
136  }
137  }
138 
139 
140 
141  TH1D* PulseHist = nullptr;
142  if(fMakeBipolarHist)
143  {
144  PulseHist= tfs->make<TH1D>(HistName, ";t (ns);",
145  int((fTimeEnd - fTimeBegin) * fSampleFreq),
146  fTimeBegin * 1000.,
147  fTimeEnd * 1000.);
148  }
149 
150  sprintf(HistName, "Event_%d_uni_OpDet_%i_Pulse_%i", evt.id().event(), ThePulse.OpChannel(), pulsenum);
151  TH1D* UnipolarHist = nullptr;
153  {
154  UnipolarHist= tfs->make<TH1D>(HistName, ";t (ns);",
155  int((fTimeEnd - fTimeBegin) * fSampleFreq),
156  fTimeBegin * 1000.,
157  fTimeEnd * 1000.);
158  }
159 
160  for(unsigned int binNum = 0; binNum < ThePulse.Waveform().size(); ++binNum)
161  {
162  // Fill histogram with waveform
163 
164  if(fMakeBipolarHist) PulseHist->SetBinContent( binNum,
165  (double) ThePulse.Waveform()[binNum] );
166  if((binNum>0)&&(fMakeUnipolarHist))
167  {
168  double BinContent = (double) ThePulse.Waveform()[binNum] +
169  (double) UnipolarHist->GetBinContent(binNum-1);
170  if(BinContent>fZeroSupThresh)
171  UnipolarHist->SetBinContent(binNum,BinContent);
172  else
173  UnipolarHist->SetBinContent(binNum,0);
174 
175  }
176 
177  }
178 
179  }
180  }
unsigned int event
Definition: DataStructs.h:634
std::string fInputModule
unsigned short OpChannel() const
Definition: OpDetPulse.h:61
pdgs p
Definition: selectors.fcl:22
const std::vector< short > & Waveform() const
Definition: OpDetPulse.h:59
std::string fInstanceName
art::ServiceHandle< art::TFileService > tfs
TCEvent evt
Definition: DataStructs.cxx:8

Member Data Documentation

std::string opdet::OpDigiAna::fInputModule
private

Definition at line 46 of file OpDigiAna_module.cc.

std::string opdet::OpDigiAna::fInstanceName
private

Definition at line 47 of file OpDigiAna_module.cc.

bool opdet::OpDigiAna::fMakeBipolarHist
private

Definition at line 56 of file OpDigiAna_module.cc.

bool opdet::OpDigiAna::fMakeUnipolarHist
private

Definition at line 57 of file OpDigiAna_module.cc.

float opdet::OpDigiAna::fSampleFreq
private

Definition at line 48 of file OpDigiAna_module.cc.

double opdet::OpDigiAna::fSPEAmp
private

Definition at line 54 of file OpDigiAna_module.cc.

float opdet::OpDigiAna::fTimeBegin
private

Definition at line 49 of file OpDigiAna_module.cc.

float opdet::OpDigiAna::fTimeEnd
private

Definition at line 50 of file OpDigiAna_module.cc.

float opdet::OpDigiAna::fZeroSupThresh
private

Definition at line 52 of file OpDigiAna_module.cc.


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