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

Public Member Functions

 SSPMonitor (const fhicl::ParameterSet &)
 
virtual ~SSPMonitor ()
 
void beginJob ()
 
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 Member Functions

void calculateFFT (TH1D *hist_waveform, TH1D *graph_frequency)
 

Private Attributes

std::string fOpDetWaveformModuleLabel
 
std::string fOpHitModuleLabel
 
double ADC_max
 
double ADC_min
 
int min_time
 
int max_time
 
int timesamples
 
double startTime
 
bool haveStartTime
 
TH1D * adc_values_
 
TH1D * peaks_
 
TH1D * areas_
 
TH1D * hit_times_
 
std::map< size_t, TH1D * > chan_peaks_
 
std::map< size_t, TH1D * > chan_areas_
 
std::map< size_t, TH2D * > persistent_waveform_
 
std::map< size_t, TH1D * > fft_
 
std::set< size_t > has_waveform
 
TH1I * fHEventNumber
 

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 45 of file SSPMonitor_module.cc.

Constructor & Destructor Documentation

nlana::SSPMonitor::SSPMonitor ( const fhicl::ParameterSet )

Definition at line 95 of file SSPMonitor_module.cc.

96  : EDAnalyzer(pset)
97 {
98 
99  // Get channel map
101 
102  fOpDetWaveformModuleLabel = pset.get<std::string>("OpDetWaveformLabel");
103  fOpHitModuleLabel = pset.get<std::string>("OpHitLabel");
104  ADC_min=pset.get<int>("SSP_ADC_min");
105  ADC_max=pset.get<int>("SSP_ADC_max");
106  timesamples=pset.get<int>("SSP_TIMESAMPLES");
107  min_time=pset.get<int>("SSP_min_time");
108  max_time=pset.get<int>("SSP_max_time");
109 
110  haveStartTime = false;
111 
112  // summary histogram creation
113 
115  fHEventNumber = tFileService->make<TH1I>("EventNumber","SSP: EventNumber;Event Number", 100, 0, 10000);
116  adc_values_ = tFileService->make<TH1D>("ssp_adc_values","SSP: ADC_Values;ADC Value",4096,-0.5,4095.5);
117  peaks_ = tFileService->make<TH1D>("peaks","Peak Amplitudes;Peak Amplitude",100,-30,50);
118  areas_ = tFileService->make<TH1D>("areas","Hit Areas;Hit Area",100,-10000,15000);
119 
120  hit_times_ = tFileService->make<TH1D>("ssp_hit_times","Hit Times",1000,min_time,max_time);
121  hit_times_->GetYaxis()->SetTitle("Number of hits");
122  hit_times_->GetXaxis()->SetTitle("Time [s]");
123 }
std::string fOpDetWaveformModuleLabel
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fOpHitModuleLabel
nlana::SSPMonitor::~SSPMonitor ( )
virtual

Definition at line 127 of file SSPMonitor_module.cc.

128 {}

Member Function Documentation

void nlana::SSPMonitor::analyze ( const art::Event evt)

Save the waveforms for all traces like an oscilloscope

Definition at line 135 of file SSPMonitor_module.cc.

136 {
137 
139 
140  auto OpHitHandle = evt.getHandle< std::vector< recob::OpHit > >(fOpHitModuleLabel);
141 
142  auto OpDetWaveformHandle = evt.getHandle< std::vector< raw::OpDetWaveform > >(fOpDetWaveformModuleLabel);
143 
144  fHEventNumber->Fill(evt.event());
145 
146  for(unsigned int i = 0; i < OpHitHandle->size(); ++i)
147  {
148  art::Ptr< recob::OpHit > ohp(OpHitHandle, i);
149  //recob::OpHit TheOpHit = *TheOpHitPtr; -- see if we can use the ptr straight up.
150  auto channel = ohp->OpChannel();
151  if (chan_peaks_.find(channel) == chan_peaks_.end())
152  {
153  chan_peaks_[channel] = tFileService->make<TH1D>(Form("peaks_%d",channel),Form("Peak Amplitudes_%d;Peak Amplitude",channel),100,-30,50);
154  }
155  if (chan_areas_.find(channel) == chan_areas_.end())
156  {
157  chan_areas_[channel] = tFileService->make<TH1D>(Form("areas_%d",channel),Form("Peak Areas_%d;Peak Area",channel),100,-10000,15000);
158  }
159  peaks_->Fill(ohp->Amplitude());
160  chan_peaks_[channel]->Fill(ohp->Amplitude());
161  areas_->Fill(ohp->Area());
162  chan_areas_[channel]->Fill(ohp->Area());
163 
164  double time = ohp->PeakTimeAbs()*1E-6;
165  if (!haveStartTime)
166  {
167  haveStartTime = true;
168  startTime = time;
169  }
170  hit_times_->Fill(time - startTime);
171 
172  } // End loop over OpHits
173 
174  for(size_t iwaveform = 0; iwaveform < OpDetWaveformHandle->size(); ++iwaveform)
175  {
176  art::Ptr< raw::OpDetWaveform > odp(OpDetWaveformHandle, iwaveform);
177 
178  size_t nADC = odp->size();
179 
180  TH1D *hist = new TH1D("hist","hist",nADC,0,nADC);
181  auto channel = odp->ChannelNumber();
183  {
184  TH2D* pwave = tFileService->make<TH2D>(Form("persistent_waveform_%d",channel),Form("persistent_waveform_%d",channel), 500,0,timesamples, (int)(ADC_max-ADC_min),ADC_min,ADC_max);
185  pwave->SetTitle(Form("Persistent waveform - Channel %d",channel));
186  pwave->GetYaxis()->SetTitle("ADC value");
187  pwave->GetXaxis()->SetTitle("Time sample");
188  persistent_waveform_[channel] = pwave;
189  }
190  if (fft_.find(channel) == fft_.end())
191  {
192  TH1D *fftp = tFileService->make<TH1D>(Form("fft_channel_%d",channel),Form("fft_channel_%d",channel), 100,0,4);
193  fftp->SetTitle(Form("FFT - Channel %d",channel));
194  fftp->GetXaxis()->SetTitle("Frequency [MHz]");
195  fft_[channel] = fftp;
196  }
197 
198  TH2D *pwavep = persistent_waveform_[channel];
199  for (size_t iadc=0; iadc < nADC; ++iadc)
200  {
201  auto adcval = odp->at(iadc);
202  adc_values_->Fill(adcval);
203 
204  ///> Save the waveforms for all traces like an oscilloscope
205  pwavep->Fill(iadc,adcval,1); // (x,y,weight=1)
206  hist->SetBinContent(iadc+1,adcval);
207  }
208 
209  // save one waveform per channel
210 
211  if ( has_waveform.find(channel) == has_waveform.end() )
212  {
213  has_waveform.insert(channel);
214  char histname[100];
215  sprintf(histname,"evt%i_channel%d",evt.event(), channel);
216  TH1D *htf = tFileService->make<TH1D>(histname,histname,nADC,0,nADC);
217  htf->Reset();
218  htf->Add(hist);
219  }
220 
221  // FFT on the single waveform, output divided by channel
222  calculateFFT(hist, fft_[channel]);
223 
224  hist->Delete();
225 
226  } // End loop over OpDetWaveforms
227 
228 }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
std::string fOpDetWaveformModuleLabel
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
void calculateFFT(TH1D *hist_waveform, TH1D *graph_frequency)
std::set< size_t > has_waveform
uint8_t channel
Definition: CRTFragment.hh:201
std::map< size_t, TH1D * > fft_
std::map< size_t, TH2D * > persistent_waveform_
std::map< size_t, TH1D * > chan_areas_
std::string fOpHitModuleLabel
std::map< size_t, TH1D * > chan_peaks_
void nlana::SSPMonitor::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 131 of file SSPMonitor_module.cc.

132 {}
void nlana::SSPMonitor::calculateFFT ( TH1D *  hist_waveform,
TH1D *  graph_frequency 
)
private

Definition at line 230 of file SSPMonitor_module.cc.

230  {
231 
232  int n_bins = hist_waveform->GetNbinsX();
233  TH1* hist_transform = 0;
234 
235  // Create hist_transform from the input hist_waveform
236  hist_transform = hist_waveform->FFT(hist_transform, "MAG");
237  hist_transform -> Scale (1.0 / float(n_bins));
238  int nFFT=hist_transform->GetNbinsX();
239 
240  Double_t frequency;
241  Double_t amplitude;
242 
243  // Loop on the hist_transform to fill the hist_transform_frequency
244  for (int k = 2; k <= nFFT/40; ++k){
245 
246  frequency = (k-1)/(n_bins/150.); // MHz
247  amplitude = hist_transform->GetBinContent(k);
248 
249  hist_frequency->Fill(frequency, amplitude);
250  }
251 
252  hist_transform->Delete();
253 
254 }
Scale(size_t pos, T factor) -> Scale< T >

Member Data Documentation

double nlana::SSPMonitor::ADC_max
private

Definition at line 61 of file SSPMonitor_module.cc.

double nlana::SSPMonitor::ADC_min
private

Definition at line 62 of file SSPMonitor_module.cc.

TH1D* nlana::SSPMonitor::adc_values_
private

Definition at line 73 of file SSPMonitor_module.cc.

TH1D* nlana::SSPMonitor::areas_
private

Definition at line 75 of file SSPMonitor_module.cc.

std::map<size_t,TH1D*> nlana::SSPMonitor::chan_areas_
private

Definition at line 82 of file SSPMonitor_module.cc.

std::map<size_t,TH1D*> nlana::SSPMonitor::chan_peaks_
private

Definition at line 81 of file SSPMonitor_module.cc.

std::map<size_t,TH1D*> nlana::SSPMonitor::fft_
private

Definition at line 84 of file SSPMonitor_module.cc.

TH1I* nlana::SSPMonitor::fHEventNumber
private

Definition at line 87 of file SSPMonitor_module.cc.

std::string nlana::SSPMonitor::fOpDetWaveformModuleLabel
private

Definition at line 59 of file SSPMonitor_module.cc.

std::string nlana::SSPMonitor::fOpHitModuleLabel
private

Definition at line 60 of file SSPMonitor_module.cc.

std::set<size_t> nlana::SSPMonitor::has_waveform
private

Definition at line 85 of file SSPMonitor_module.cc.

bool nlana::SSPMonitor::haveStartTime
private

Definition at line 69 of file SSPMonitor_module.cc.

TH1D* nlana::SSPMonitor::hit_times_
private

Definition at line 76 of file SSPMonitor_module.cc.

int nlana::SSPMonitor::max_time
private

Definition at line 64 of file SSPMonitor_module.cc.

int nlana::SSPMonitor::min_time
private

Definition at line 63 of file SSPMonitor_module.cc.

TH1D* nlana::SSPMonitor::peaks_
private

Definition at line 74 of file SSPMonitor_module.cc.

std::map<size_t,TH2D*> nlana::SSPMonitor::persistent_waveform_
private

Definition at line 83 of file SSPMonitor_module.cc.

double nlana::SSPMonitor::startTime
private

Definition at line 68 of file SSPMonitor_module.cc.

int nlana::SSPMonitor::timesamples
private

Definition at line 66 of file SSPMonitor_module.cc.


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