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

Public Member Functions

 AverageWaveform (fhicl::ParameterSet const &)
 
virtual ~AverageWaveform ()
 
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
 
double fSampleFreq
 
double fTimeBegin
 
int fBaselineSubtract
 
int fNticks
 
std::map< int, TH1D * > averageWaveforms
 
std::map< int, int > waveformCount
 
TH1D * averageWaveformAll
 
int eventCount
 

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 43 of file AverageWaveform_module.cc.

Constructor & Destructor Documentation

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

Definition at line 89 of file AverageWaveform_module.cc.

90  : EDAnalyzer(pset)
91  , fInputModule { pset.get< std::string >("InputModule") }
92  , fInstanceName { pset.get< std::string >("InstanceName") }
93  , fTimeBegin { 0 }
94  , fBaselineSubtract { pset.get< int >("BaselineSubtract", 0) }
95  , fNticks { pset.get< int >("Nticks", 0) }
96  , averageWaveformAll{ NULL }
97  , eventCount { 0 }
98  {
99 
100  // Obtain parameters from TimeService
101  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
102  fSampleFreq = clockData.OpticalClock().Frequency();
103 
104  // Assume starting at 0
105  fTimeBegin = 0;
106 
107  }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
opdet::AverageWaveform::~AverageWaveform ( )
virtual

Definition at line 111 of file AverageWaveform_module.cc.

112  {
113  }

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 137 of file AverageWaveform_module.cc.

138  {
139 
140  // Get OpDetWaveforms from the event
142  auto waveformHandle = evt.getHandle< std::vector< raw::OpDetWaveform > >(itag1);
143 
144  // Access ART's TFileService, which will handle creating and writing
145  // histograms for us
147 
148  for (size_t i = 0; i < waveformHandle->size(); i++)
149  {
150 
151 
152  // This was probably required to overcome the "const" problem
153  // with OpDetPulse::Waveform()
154  art::Ptr< raw::OpDetWaveform > waveformPtr(waveformHandle, i);
155  raw::OpDetWaveform pulse = *waveformPtr;
156  int channel = pulse.ChannelNumber();
157 
158  if (fNticks == 0) fNticks = pulse.size();
159 
160 
161  // Create the TH1 if it doesn't exist
162  auto waveform = averageWaveforms.find( channel );
163  if ( waveform == averageWaveforms.end() ) {
164  TString histName = TString::Format("avgwaveform_channel_%03i", channel);
165  averageWaveforms[channel] = tfs->make< TH1D >(histName, ";t (us);", fNticks, 0, float(fNticks+1) / fSampleFreq);
166  }
167  if (!averageWaveformAll) {
168  averageWaveformAll = tfs->make< TH1D >("avgwaveform_channel_all", ";t (us);", fNticks, 0, float(fNticks+1) / fSampleFreq);
169  }
170 
171  // Add this waveform to this histogram
172  for (size_t tick = 0; tick < pulse.size(); tick++) {
174  averageWaveformAll->Fill(double(tick)/fSampleFreq, pulse[tick] - fBaselineSubtract);
175  }
176 
177  // Count number of waveforms on each channel
179  }
180  eventCount++;
181 
182  }
Format
Definition: utils.h:7
Channel_t ChannelNumber() const
Definition: OpDetWaveform.h:65
std::map< int, int > waveformCount
std::map< int, TH1D * > averageWaveforms
uint8_t channel
Definition: CRTFragment.hh:201
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
TCEvent evt
Definition: DataStructs.cxx:7
Definition: fwd.h:31
void opdet::AverageWaveform::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 117 of file AverageWaveform_module.cc.

118  {
119  }
void opdet::AverageWaveform::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 122 of file AverageWaveform_module.cc.

123  {
124  double waveformCountAll = 0;
125  for (auto iter = averageWaveforms.begin(); iter != averageWaveforms.end(); iter++)
126  {
127  waveformCountAll += waveformCount[iter->first];
128  mf::LogInfo("AverageWaveform") << "Scaling down channel " << iter->first << " by 1./" << waveformCount[iter->first] << std::endl;
129  iter->second->Scale(1./waveformCount[iter->first]);
130  }
131  mf::LogInfo("AverageWaveform") << "Scaling down all channels by 1./" << eventCount << std::endl;
132  averageWaveformAll->Scale(1./eventCount);
133  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::map< int, int > waveformCount
std::map< int, TH1D * > averageWaveforms
QTextStream & endl(QTextStream &s)

Member Data Documentation

TH1D* opdet::AverageWaveform::averageWaveformAll
private

Definition at line 69 of file AverageWaveform_module.cc.

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

Definition at line 67 of file AverageWaveform_module.cc.

int opdet::AverageWaveform::eventCount
private

Definition at line 70 of file AverageWaveform_module.cc.

int opdet::AverageWaveform::fBaselineSubtract
private

Definition at line 63 of file AverageWaveform_module.cc.

std::string opdet::AverageWaveform::fInputModule
private

Definition at line 59 of file AverageWaveform_module.cc.

std::string opdet::AverageWaveform::fInstanceName
private

Definition at line 60 of file AverageWaveform_module.cc.

int opdet::AverageWaveform::fNticks
private

Definition at line 64 of file AverageWaveform_module.cc.

double opdet::AverageWaveform::fSampleFreq
private

Definition at line 61 of file AverageWaveform_module.cc.

double opdet::AverageWaveform::fTimeBegin
private

Definition at line 62 of file AverageWaveform_module.cc.

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

Definition at line 68 of file AverageWaveform_module.cc.


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