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

Public Member Functions

 CalibrationAnalysis (fhicl::ParameterSet const &)
 
virtual ~CalibrationAnalysis ()
 
void analyze (art::Event const &) override
 
- 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 beginJob () override
 
void endJob () override
 

Private Attributes

std::string fInputModule
 
std::string fInstanceName
 
std::string fOpHitModule
 
double fSampleFreq
 
double fTimeBegin
 
std::map< int, TH1D * > averageWaveforms
 
std::map< int, int > waveformCount
 
std::map< int, int > OpHitCount
 
std::map< int, double > FirstHitTimePerChannel
 
TH1D * fPedestalMeanPerChannel
 
TH1D * fPedestalSigmaPerChannel
 
TH1D * fIntegratedSignalMeanPerChannel
 
TH1D * fFractionSamplesNearMaximumPerChannel
 
TH1D * fNumberOfWaveformsProcessedPerChannel
 
TH1D * fFirstOpHitTimeMean
 
TH1D * fSecondOpHitTimeMean
 
TH1D * fFirstSecondDiffOpHitTimeMean
 
TH1D * fNumberOfOpHitsPerChannelPerEvent
 

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 CalibrationAnalysis_module.cc.

Constructor & Destructor Documentation

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

Definition at line 108 of file CalibrationAnalysis_module.cc.

109  : EDAnalyzer(pset)
110  {
111 
112  // Read the fcl-file
113  fInputModule = pset.get< std::string >("InputModule");
114  fInstanceName = pset.get< std::string >("InstanceName");
115  fOpHitModule = pset.get<std::string>("OpHitModule");
116  // Obtain parameters from TimeService
117  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
118  fSampleFreq = clockData.OpticalClock().Frequency();
119 
120  // Assume starting at 0
121  fTimeBegin = 0;
122 
123 
124  }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
opdet::CalibrationAnalysis::~CalibrationAnalysis ( )
virtual

Definition at line 128 of file CalibrationAnalysis_module.cc.

129  {
130  }

Member Function Documentation

void opdet::CalibrationAnalysis::analyze ( art::Event const &  evt)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 207 of file CalibrationAnalysis_module.cc.

208  {
209 
210 
211  // Get OpDetWaveforms from the event
213  auto waveformHandle = evt.getHandle< std::vector< raw::OpDetWaveform > >(itag1);
214 
215  // Access ART's TFileService, which will handle creating and writing
216  // histograms for us
218 
219  for (size_t i = 0; i < waveformHandle->size(); i++)
220  {
221 
222  // This was probably required to overcome the "const" problem
223  // with OpDetPulse::Waveform()
224  art::Ptr< raw::OpDetWaveform > waveformPtr(waveformHandle, i);
225  raw::OpDetWaveform pulse = *waveformPtr;
226  int channel = pulse.ChannelNumber();
227 
228  // Create the TH1 if it doesn't exist
229  auto waveform = averageWaveforms.find( channel );
230  if ( waveform == averageWaveforms.end() ) {
231  TString histName = TString::Format("avgwaveform_channel_%03i", channel);
232  averageWaveforms[channel] = tfs->make< TH1D >(histName, ";t (us);", pulse.size(), 0, double(pulse.size()) / fSampleFreq);
233  }
234 
235  double PedestalMean = 0;
236  double PedestalVariance = 0;
237  double IntegratedSignalMean = 0;
238  // double IntegratedSignalSigma = 0;
239 
240 
241  // Add this waveform to this histogram
242  for (size_t tick = 0; tick < pulse.size(); tick++) {
243  averageWaveforms[channel]->Fill(double(tick)/fSampleFreq, pulse[tick]);
244 
245  if(tick < 30)
246  PedestalMean += pulse[tick];
247 
248  if(pulse[tick] > 4000)
249  fFractionSamplesNearMaximumPerChannel->Fill(channel,1.0/pulse.size());
250  }
251 
252  PedestalMean /= 30;
253 
254 
255 
256  for (size_t tick = 0; tick < pulse.size(); tick++) {
257 
258  PedestalVariance += ( pulse[tick] - PedestalMean)*( pulse[tick] - PedestalMean);
259 
260  IntegratedSignalMean += pulse[tick] - PedestalMean;
261  }
262 
263 
264  PedestalVariance /= (pulse.size() - 1);
265  double PedestalSigma = sqrt(PedestalVariance);
266 
267  fPedestalMeanPerChannel->Fill(channel,PedestalMean);
268  fPedestalSigmaPerChannel->Fill(channel,PedestalSigma);
269 
270  fIntegratedSignalMeanPerChannel->Fill(channel,IntegratedSignalMean);
271 
272  // Count number of waveforms on each channel
274 
275 
276  }
277 
278  auto OpHitHandle = evt.getHandle< std::vector< recob::OpHit > >(fOpHitModule);
279 
280  // Map to store how many OpHits are on one optical channel per event
281  std::map< int, int > OpHitCountPerEvent;
282 
283 
284 
285 
286  if(OpHitHandle->size() > 0)
287  std::cout << "OpHitHandle->size() = " << OpHitHandle->size() << std::endl;
288 
289  for(size_t i=0; i!=OpHitHandle->size(); ++i)
290  {
291 
292  int channel = OpHitHandle->at(i).OpChannel();
293  //std::cout << "hit number = " << i << ", online channel number = " << OpHitHandle->at(i).OpChannel() << ", offline channel number = " << channel << std::endl;
294  ++OpHitCount[channel];
295  ++OpHitCountPerEvent[channel];
296 
297  double firstophitpeaktime;
298  double secondophitpeaktime;
299 
300  if(OpHitCountPerEvent[channel] == 1){
301  firstophitpeaktime = OpHitHandle->at(i).PeakTime();
302  FirstHitTimePerChannel[channel] = firstophitpeaktime;
303  fFirstOpHitTimeMean->Fill(channel, firstophitpeaktime);
304 
305  }
306  else if(OpHitCountPerEvent[channel] == 2){
307  secondophitpeaktime = OpHitHandle->at(i).PeakTime();
308  fSecondOpHitTimeMean->Fill(channel, secondophitpeaktime);
309  fFirstSecondDiffOpHitTimeMean->Fill(channel, secondophitpeaktime-FirstHitTimePerChannel[channel]);
310  }
311 
312  }
313 
314  for (auto iter = OpHitCountPerEvent.begin(); iter != OpHitCountPerEvent.end(); iter++){
315  fNumberOfOpHitsPerChannelPerEvent->Fill(iter->second);
316  }
317 
318  }
Format
Definition: utils.h:7
Channel_t ChannelNumber() const
Definition: OpDetWaveform.h:65
uint8_t channel
Definition: CRTFragment.hh:201
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
std::map< int, double > FirstHitTimePerChannel
TCEvent evt
Definition: DataStructs.cxx:7
Definition: fwd.h:31
QTextStream & endl(QTextStream &s)
std::map< int, TH1D * > averageWaveforms
void opdet::CalibrationAnalysis::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 134 of file CalibrationAnalysis_module.cc.

135  {
136 
137  // Access ART's TFileService, which will handle creating and writing
138  // histograms for us
140 
141 
142  fPedestalMeanPerChannel = tfs->make< TH1D >("PedestalMeanPerChannel", "Pedestal Means;Channel Number;Pedestal Mean (ADC)", 711, 0.5, 711.5);
143  fPedestalSigmaPerChannel = tfs->make< TH1D >("PedestalSigmaPerChannel", "Pedestal Sigma;Channel Number;Pedestal Sigma (ADC)", 711, 0.5, 711.5);
144  fIntegratedSignalMeanPerChannel = tfs->make< TH1D >("IntegratedSignalMeanPerChannel", "Integrated Signal Means;Channel Number; Integrated SignalMean (ADC)", 711, 0.5, 711.5);
146  fFractionSamplesNearMaximumPerChannel = tfs->make< TH1D >("FractionSamplesNearMaximumPerChannel", "Fraction of Samples Near Maximum;Channel Number;Fraction Near Maximum", 711, 0.5, 711.5);
147 
148  fNumberOfWaveformsProcessedPerChannel = tfs->make< TH1D >("NumberOfWaveformsProcessedPerChannel", "Number of Waveforms Processed per Channel;Channel Number;Fraction Near Maximum", 711, 0.5, 711.5);
149 
150  fFirstOpHitTimeMean = tfs->make< TH1D >("FirstOpHitTimeMean", "Mean of first OpHit time per Channel;Channel Number;First OpHit time mean (ticks)", 711, 0.5, 711.5);
151  //fFirstOpHitTimeSigma = tfs->make< TH1D >("FirstOpHitTimeSigma","Sigma of first OpHit time per Channel;Channel Number;First OpHit time sigma (ticks)", 711, 0.5, 711.5);
152  fSecondOpHitTimeMean = tfs->make< TH1D >("SecondOpHitTimeMean", "Mean of second OpHit time per Channel;Channel Number;Second OpHit time mean (ticks)", 711, 0.5, 711.5);
153  //fSecondOpHitTimeSigma = tfs->make< TH1D >("SecondOpHitTimeSigma","Sigma of second OpHit time per Channel;Channel Number;Second OpHit time sigma (ticks)", 711, 0.5, 711.5);
154  fFirstSecondDiffOpHitTimeMean = tfs->make< TH1D >("FirstSecondDiffOpHitTimeMean", "Mean of first-second OpHit time difference per Channel;Channel Number;(second - first) OpHit time mean (ticks)", 711, 0.5, 711.5);
155  //fFirstSecondDiffOpHitTimeSigma = tfs->make< TH1D >("FirstSecondDiffOpHitTimeSigma","Sigma of first-second OpHit time difference per Channel;Channel Number;(second - first) OpHit time sigma (ticks)", 711, 0.5, 711.5);
156  fNumberOfOpHitsPerChannelPerEvent = tfs->make< TH1D >("NumberOfOpHitsPerChannelPerEvent", "Number of OpHits in one channel per event;Number of OpHits;", 16, -0.5, 15.5);
157 
158  }
void opdet::CalibrationAnalysis::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 161 of file CalibrationAnalysis_module.cc.

162  {
163 
164  for (auto iter = averageWaveforms.begin(); iter != averageWaveforms.end(); iter++)
165  {
166  mf::LogInfo("Scaling down channel ") << iter->first << " by 1./" << waveformCount[iter->first] << std::endl;
167  iter->second->Scale(1./waveformCount[iter->first]);
168 
169  //Also scale down pedestal mean, sigma, and integrated signal mean and sigma histograms
170 
171  double adjustedPedestalMean = fPedestalMeanPerChannel->GetBinContent(iter->first)/waveformCount[iter->first];
172  fPedestalMeanPerChannel->SetBinContent(iter->first,adjustedPedestalMean);
173  double adjustedPedestalSigma = fPedestalSigmaPerChannel->GetBinContent(iter->first)/waveformCount[iter->first];
174  fPedestalSigmaPerChannel->SetBinContent(iter->first,adjustedPedestalSigma);
175 
176  double adjustedFractionSamplesNearMaximumPerChannel = fFractionSamplesNearMaximumPerChannel->GetBinContent(iter->first)/waveformCount[iter->first];
177  fFractionSamplesNearMaximumPerChannel->SetBinContent(iter->first,adjustedFractionSamplesNearMaximumPerChannel);
178 
179  fNumberOfWaveformsProcessedPerChannel->SetBinContent(iter->first,waveformCount[iter->first]);
180 
181  double adjustedIntegratedSignalMeanPerChannel = fIntegratedSignalMeanPerChannel->GetBinContent(iter->first)/waveformCount[iter->first];
182  //double adjustedIntegratedSignalErrorPerChannel = fIntegratedSignalMeanPerChannel->GetBinError(iter->first)/waveformCount[iter->first];
183 
184  fIntegratedSignalMeanPerChannel->SetBinContent(iter->first,adjustedIntegratedSignalMeanPerChannel);
185  //fIntegratedSignalMeanPerChannel->SetBinError(iter->first,adjustedIntegratedSignalErrorPerChannel);
186 
187  }
188 
189  for (auto iter = OpHitCount.begin(); iter != OpHitCount.end(); iter++){
190  double adjustedFirstOpHitTimeMean = fFirstOpHitTimeMean->GetBinContent(iter->first)/(iter->second);
191  fFirstOpHitTimeMean->SetBinContent(iter->first,adjustedFirstOpHitTimeMean);
192 
193  double adjustedSecondOpHitTimeMean = fSecondOpHitTimeMean->GetBinContent(iter->first)/(iter->second);
194  fSecondOpHitTimeMean->SetBinContent(iter->first,adjustedSecondOpHitTimeMean);
195 
196  double adjustedFirstSecondDiffOpHitTimeMean = fFirstSecondDiffOpHitTimeMean->GetBinContent(iter->first)/(iter->second);
197  fFirstSecondDiffOpHitTimeMean->SetBinContent(iter->first,adjustedFirstSecondDiffOpHitTimeMean);
198 
199  }
200 
201 
202 
203  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
QTextStream & endl(QTextStream &s)
std::map< int, TH1D * > averageWaveforms

Member Data Documentation

std::map< int, TH1D* > opdet::CalibrationAnalysis::averageWaveforms
private

Definition at line 69 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fFirstOpHitTimeMean
private

Definition at line 84 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fFirstSecondDiffOpHitTimeMean
private

Definition at line 88 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fFractionSamplesNearMaximumPerChannel
private

Definition at line 82 of file CalibrationAnalysis_module.cc.

std::string opdet::CalibrationAnalysis::fInputModule
private

Definition at line 62 of file CalibrationAnalysis_module.cc.

std::string opdet::CalibrationAnalysis::fInstanceName
private

Definition at line 63 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fIntegratedSignalMeanPerChannel
private

Definition at line 81 of file CalibrationAnalysis_module.cc.

std::map< int, double > opdet::CalibrationAnalysis::FirstHitTimePerChannel
private

Definition at line 76 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fNumberOfOpHitsPerChannelPerEvent
private

Definition at line 90 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fNumberOfWaveformsProcessedPerChannel
private

Definition at line 83 of file CalibrationAnalysis_module.cc.

std::string opdet::CalibrationAnalysis::fOpHitModule
private

Definition at line 64 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fPedestalMeanPerChannel
private

Definition at line 79 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fPedestalSigmaPerChannel
private

Definition at line 80 of file CalibrationAnalysis_module.cc.

double opdet::CalibrationAnalysis::fSampleFreq
private

Definition at line 65 of file CalibrationAnalysis_module.cc.

TH1D* opdet::CalibrationAnalysis::fSecondOpHitTimeMean
private

Definition at line 86 of file CalibrationAnalysis_module.cc.

double opdet::CalibrationAnalysis::fTimeBegin
private

Definition at line 66 of file CalibrationAnalysis_module.cc.

std::map< int, int > opdet::CalibrationAnalysis::OpHitCount
private

Definition at line 73 of file CalibrationAnalysis_module.cc.

std::map< int, int > opdet::CalibrationAnalysis::waveformCount
private

Definition at line 70 of file CalibrationAnalysis_module.cc.


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