All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ana::SBNOsc::OpDetWaveformMaker Class Reference

Electron neutrino event selection. More...

Inheritance diagram for ana::SBNOsc::OpDetWaveformMaker:
core::SelectionBase core::ProcessorBase

Public Member Functions

 OpDetWaveformMaker ()
 
void Initialize (fhicl::ParameterSet *config=NULL)
 
void Finalize ()
 
bool ProcessEvent (const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
 
- Public Member Functions inherited from core::SelectionBase
 SelectionBase ()
 
virtual ~SelectionBase ()
 
- Public Member Functions inherited from core::ProcessorBase
 ProcessorBase ()
 
virtual ~ProcessorBase ()
 
virtual void FillTree ()
 
virtual void FillRecoTree ()
 
virtual void EventCleanup ()
 
template<class T >
TBranch * AddBranch (std::string name, T *obj)
 
template<class T >
TBranch * AddRecoBranch (std::string name, T *obj)
 

Protected Attributes

std::string fOpDetWaveformTag
 
float clock_freq
 
unsigned event_ind
 
- Protected Attributes inherited from core::ProcessorBase
unsigned long fEventIndex
 An incrementing index. More...
 
Experiment fExperimentID
 Experiment identifier. More...
 
ProviderManagerfProviderManager
 Interface for provider access. More...
 
std::string fOutputFilename
 The output filename. More...
 
std::string fProviderConfig
 A custom provider config fcl file. More...
 
std::vector< geo::BoxBoundedGeofActiveVolumes
 List of active volumes in configured detector. More...
 
bool fWriteTree
 Enable writing of the main tree. More...
 
TFile * fOutputFile
 The output ROOT file. More...
 
TTree * fTree
 The output ROOT tree. More...
 
event::EventfEvent
 The standard output event data structure. More...
 
bool fWriteRecoTree
 Enable writing of the reco tree. More...
 
TTree * fRecoTree
 The output reco ROOT tree. More...
 
event::RecoEventfRecoEvent
 The standard output reco event data structure. More...
 
TTree * fSubRunTree
 Subrun output tree. More...
 
SubRunfSubRun
 Standard output subrun structure. More...
 
TTree * fFileMetaTree
 File metadata output tree. More...
 
FileMetafFileMeta
 standard output file metadata structure More...
 
TParameter< int > * fExperimentParameter
 Saves value of experiment enum. More...
 
std::set< std::pair< int, int > > fSubRunCache
 Cache stored subruns. More...
 
art::InputTag fTruthTag
 art tag for MCTruth information More...
 
art::InputTag fFluxTag
 art tag for MCFlux information More...
 
std::vector< art::InputTag > fWeightTags
 art tag(s) for MCEventWeight information More...
 
art::InputTag fMCTrackTag
 art tag for MCTrack More...
 
art::InputTag fMCShowerTag
 art tag for MCShower More...
 
art::InputTag fMCParticleTag
 art tag for MCParticle More...
 
std::string fGeneratorProcess
 process_name of process used to run genie. Used to extract subrun/POT information More...
 

Additional Inherited Members

- Public Attributes inherited from core::ProcessorBase
std::vector
< event::RecoInteraction > * 
fReco
 Reco interaction list. More...
 
- Protected Member Functions inherited from core::ProcessorBase
virtual void Initialize (char *config=NULL)
 
virtual void Setup (char *config=NULL)
 
virtual void Setup (fhicl::ParameterSet *config=NULL)
 
virtual void Teardown ()
 
void BuildEventTree (gallery::Event &ev)
 
void SetupServices (gallery::Event &ev)
 
void UpdateSubRuns (gallery::Event &ev)
 
void UpdateFileMeta (gallery::Event &ev)
 

Detailed Description

Electron neutrino event selection.

Definition at line 31 of file OpDetWaveformMaker.cc.

Constructor & Destructor Documentation

ana::SBNOsc::OpDetWaveformMaker::OpDetWaveformMaker ( )
inline

Constructor.

Definition at line 34 of file OpDetWaveformMaker.cc.

34 {}

Member Function Documentation

void ana::SBNOsc::OpDetWaveformMaker::Finalize ( )
inlinevirtual

Finalize and write objects to the output file.

Implements core::ProcessorBase.

Definition at line 49 of file OpDetWaveformMaker.cc.

49  {
50  }
void ana::SBNOsc::OpDetWaveformMaker::Initialize ( fhicl::ParameterSet *  config = NULL)
inlinevirtual

Initialization.

Parameters
configA configuration, as a FHiCL ParameterSet object

Implements core::ProcessorBase.

Definition at line 41 of file OpDetWaveformMaker.cc.

41  {
42  fOpDetWaveformTag = config ? config->get<std::string>("OpDetWaveformTag", "opdaq") : "opdaq";
43  clock_freq = fProviderManager->GetDetectorClocksProvider()->OpticalClock().Frequency();
44  std::cout << "CLOCK FREQ: " << clock_freq << std::endl;
45  event_ind = 0;
46  }
const detinfo::DetectorClocksStandard * GetDetectorClocksProvider() const
ProviderManager * fProviderManager
Interface for provider access.
BEGIN_PROLOG could also be cout
bool ana::SBNOsc::OpDetWaveformMaker::ProcessEvent ( const gallery::Event &  ev,
const std::vector< event::Interaction > &  truth,
std::vector< event::RecoInteraction > &  reco 
)
inlinevirtual

Process one event.

Parameters
evA single event, as a gallery::Event
Reconstructedinteractions
Returns
True to keep event

Implements core::ProcessorBase.

Definition at line 59 of file OpDetWaveformMaker.cc.

59  {
60  const std::vector<raw::OpDetWaveform> &waveforms = *ev.getValidHandle<std::vector<raw::OpDetWaveform>>(fOpDetWaveformTag);
61  //std::map<raw::Channel_t, std::pair<std::vector<float>, std::vector<float>>> waveform_plots;
62  std::map<raw::Channel_t, std::vector<std::pair<float, float>>> waveform_data;
63  std::map<raw::Channel_t, std::vector<float>> wf_start_times;
64  std::map<raw::Channel_t, std::vector<float>> wf_periods;
65  for (const raw::OpDetWaveform &wfconst: waveforms) {
66  raw::OpDetWaveform wf = wfconst;
67  //if (waveform_plots.count(wf.ChannelNumber()) > 0) {
68  // std::cout << "Multi-waveform output! Channel: " << wf.ChannelNumber() << " Event: " << event_ind << std::endl;
69  //}
70  for (unsigned i = 0; i < wf.Waveform().size(); i++) {
71  waveform_data[wf.ChannelNumber()].push_back({i / clock_freq + wf.TimeStamp(), (float)wf.Waveform()[i]});
72  }
73  wf_start_times[wf.ChannelNumber()].push_back(wf.TimeStamp());
74  wf_periods[wf.ChannelNumber()].push_back( wf.Waveform().size() / clock_freq);
75  }
76 
77  // now sort each one
78  //for (auto &wf_data_pair: waveform_data) {
79  // std::sort(wf_data_pair.second.begin(), wf_data_pair.second.end(), [](auto lhs, auto rhs) {return lhs.first < rhs.first;});
80  //}
81  std::map<raw::Channel_t, std::pair<std::vector<float>, std::vector<float>>> waveform_plots;
82  for (auto &wf_data_pair: waveform_data) {
83  for (auto data_pair: wf_data_pair.second) {
84  waveform_plots[wf_data_pair.first].first.push_back(data_pair.first);
85  waveform_plots[wf_data_pair.first].second.push_back(data_pair.second);
86  }
87  }
88 
89  for (auto &start_time_pair: wf_start_times) {
90  std::cout << "Event: " << event_ind << " Channel: " << start_time_pair.first << std::endl;
91  const std::vector<float> &wf_period = wf_periods.at(start_time_pair.first);
92  for (unsigned i = 0; i < start_time_pair.second.size(); i++) {
93  std::cout << start_time_pair.second[i] << " (" << wf_period[i] <<") ";
94 
95  }
96  std::cout << std::endl;
97  }
98 
99  std::vector<TGraph *> plots;
100  for (auto &plot_info: waveform_plots) {
101  TGraph *plot = new TGraph(plot_info.second.first.size(), &plot_info.second.first[0], &plot_info.second.second[0]);
102  plot->SetName((std::string("Waveform ch: ") + std::to_string(plot_info.first) + " ev: " + std::to_string(event_ind)).c_str());
103  plot->SetTitle((std::string("Waveform ch: ") + std::to_string(plot_info.first) + " ev: " + std::to_string(event_ind)).c_str());
104  plots.push_back(plot);
105  }
106  fOutputFile->cd();
107  for (TGraph *plot: plots) {
108  plot->Write();
109  delete plot;
110  }
111  event_ind += 1;
112 
113  return false;
114  }
TFile * fOutputFile
The output ROOT file.
std::vector< ADC_Count_t > & Waveform()
process_name plot
std::vector< PlotDef > plots
Definition: demo.h:54
std::string to_string(WindowPattern const &pattern)
BEGIN_PROLOG could also be cout

Member Data Documentation

float ana::SBNOsc::OpDetWaveformMaker::clock_freq
protected

Definition at line 118 of file OpDetWaveformMaker.cc.

unsigned ana::SBNOsc::OpDetWaveformMaker::event_ind
protected

Definition at line 119 of file OpDetWaveformMaker.cc.

std::string ana::SBNOsc::OpDetWaveformMaker::fOpDetWaveformTag
protected

Definition at line 117 of file OpDetWaveformMaker.cc.


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