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

Public Member Functions

 FullOpHitFinder (const fhicl::ParameterSet &)
 
virtual ~FullOpHitFinder ()
 
void produce (art::Event &)
 
void beginJob ()
 
void endJob ()
 

Private Member Functions

std::map< int, int > GetChannelMap ()
 
std::vector< double > GetSPEScales ()
 
std::vector< double > GetSPEShifts ()
 

Private Attributes

std::string fInputModule
 
std::vector< std::string > fInputLabels
 
std::set< unsigned int > fChannelMasks
 
pmtana::PulseRecoManager fPulseRecoMgr
 
pmtana::PMTPulseRecoBasefThreshAlg
 
pmtana::PMTPedestalBasefPedAlg
 
std::string _output_filename
 
std::vector< double > _tstart_v
 
std::vector< double > _tmax_v
 
std::vector< double > _tend_v
 
std::vector< double > _tcross_v
 
std::vector< double > _amp_v
 
std::vector< double > _area_v
 
std::vector< double > _ped_mean_v
 
std::vector< double > _ped_sigma_v
 
std::vector< double > _wf
 
double _tstart
 
int _run
 
int _event
 
int _ch
 
TTree * _wftree
 
TTree * _hittree
 
TTree * _geotree
 
TFile * _ofile
 

Detailed Description

Definition at line 48 of file FullOpHitFinder_module.cc.

Constructor & Destructor Documentation

opdet::FullOpHitFinder::FullOpHitFinder ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 101 of file FullOpHitFinder_module.cc.

101  :
102  EDProducer{pset},
103  fPulseRecoMgr()
104  {
105 
106  // Indicate that the Input Module comes from .fcl
107  fInputModule = pset.get< std::string >("InputModule");
108  fInputLabels = pset.get< std::vector< std::string > >("InputLabels");
109 
110  for (auto const& ch : pset.get< std::vector< unsigned int > >
111  ("ChannelMasks", std::vector< unsigned int >()))
112  fChannelMasks.insert(ch);
113 
114  // Initialize the hit finder algorithm
115  auto const hit_alg_pset = pset.get< fhicl::ParameterSet >("HitAlgoPset");
116  std::string threshAlgName = hit_alg_pset.get< std::string >("Name");
117  if (threshAlgName == "Threshold")
118  fThreshAlg = new pmtana::AlgoThreshold(hit_alg_pset);
119  else if (threshAlgName == "SiPM")
120  fThreshAlg = new pmtana::AlgoSiPM(hit_alg_pset);
121  else if (threshAlgName == "SlidingWindow")
122  fThreshAlg = new pmtana::AlgoSlidingWindow(hit_alg_pset);
123  else if (threshAlgName == "FixedWindow")
124  fThreshAlg = new pmtana::AlgoFixedWindow(hit_alg_pset);
125  else if (threshAlgName == "CFD" )
126  fThreshAlg = new pmtana::AlgoCFD(hit_alg_pset);
127  else throw art::Exception(art::errors::UnimplementedFeature)
128  << "Cannot find implementation for "
129  << threshAlgName << " algorithm.\n";
130 
131  auto const ped_alg_pset = pset.get< fhicl::ParameterSet >("PedAlgoPset");
132  std::string pedAlgName = ped_alg_pset.get< std::string >("Name");
133  if (pedAlgName == "Edges")
134  fPedAlg = new pmtana::PedAlgoEdges(ped_alg_pset);
135  else if (pedAlgName == "RollingMean")
136  fPedAlg = new pmtana::PedAlgoRollingMean(ped_alg_pset);
137  else if (pedAlgName == "UB" )
138  fPedAlg = new pmtana::PedAlgoUB(ped_alg_pset);
139  else throw art::Exception(art::errors::UnimplementedFeature)
140  << "Cannot find implementation for "
141  << pedAlgName << " algorithm.\n";
142 
145 
146  _output_filename = pset.get<std::string>("OutputFile","out.root");
147 
148  }
std::vector< std::string > fInputLabels
void AddRecoAlgo(pmtana::PMTPulseRecoBase *algo, PMTPedestalBase *ped_algo=nullptr)
A method to set pulse reconstruction algorithm.
pmtana::PMTPedestalBase * fPedAlg
pmtana::PMTPulseRecoBase * fThreshAlg
void SetDefaultPedAlgo(pmtana::PMTPedestalBase *algo)
A method to set a choice of pedestal estimation method.
std::set< unsigned int > fChannelMasks
pmtana::PulseRecoManager fPulseRecoMgr
opdet::FullOpHitFinder::~FullOpHitFinder ( )
virtual

Definition at line 221 of file FullOpHitFinder_module.cc.

222  {
223 
224  delete fThreshAlg;
225  delete fPedAlg;
226 
227  }
pmtana::PMTPedestalBase * fPedAlg
pmtana::PMTPulseRecoBase * fThreshAlg

Member Function Documentation

void opdet::FullOpHitFinder::beginJob ( )

Definition at line 150 of file FullOpHitFinder_module.cc.

151  {
152  // analyzie tuple prep
153  _ofile = TFile::Open(_output_filename.c_str(),"RECREATE");
154 
155  _wftree = new TTree("wftree","wftree");
156  _wftree->Branch("run",&_run,"run/I");
157  _wftree->Branch("event",&_event,"event/I");
158  _wftree->Branch("ch",&_ch,"ch/I");
159  _wftree->Branch("wf",&_wf);
160  _wftree->Branch("ped_mean",&_ped_mean_v);
161  _wftree->Branch("ped_sigma",&_ped_sigma_v);
162  _wftree->Branch("tstart",&_tstart,"tstart/D");
163 
164  _hittree = new TTree("hittree","hittree");
165  _hittree->Branch("run",&_run,"run/I");
166  _hittree->Branch("event",&_event,"event/I");
167  _hittree->Branch("ch",&_ch,"ch/I");
168  _hittree->Branch("tstart",&_tstart_v);
169  _hittree->Branch("tmax",&_tmax_v);
170  _hittree->Branch("tend",&_tend_v);
171  _hittree->Branch("tcross",&_tcross_v);
172  _hittree->Branch("amp",&_amp_v);
173  _hittree->Branch("area",&_area_v);
174  _hittree->Branch("ped_mean",&_ped_mean_v);
175  _hittree->Branch("ped_sigma",&_ped_sigma_v);
176 
177  _geotree = new TTree("geotree","geotree");
178  std::vector<double> pmtX, pmtY, pmtZ;
179  std::vector<double> minX, minY, minZ;
180  std::vector<double> maxX, maxY, maxZ;
181  auto const geop = lar::providerFrom<geo::Geometry>();
182  double PMTxyz[3];
183  for(size_t opch=0; opch<geop->NOpChannels(); ++opch) {
184  geop->OpDetGeoFromOpChannel(opch).GetCenter(PMTxyz);
185  pmtX.push_back(PMTxyz[0]);
186  pmtY.push_back(PMTxyz[1]);
187  pmtZ.push_back(PMTxyz[2]);
188  }
189  for(auto iter=geop->begin_TPC(); iter!=geop->end_TPC(); ++iter) {
190  auto const& tpc = (*iter);
191  minX.push_back(tpc.BoundingBox().MinX());
192  minY.push_back(tpc.BoundingBox().MinY());
193  minZ.push_back(tpc.BoundingBox().MinZ());
194  maxX.push_back(tpc.BoundingBox().MaxX());
195  maxY.push_back(tpc.BoundingBox().MaxY());
196  maxZ.push_back(tpc.BoundingBox().MaxZ());
197  }
198  _geotree->Branch("pmtX",&pmtX);
199  _geotree->Branch("pmtY",&pmtY);
200  _geotree->Branch("pmtZ",&pmtZ);
201  _geotree->Branch("minX",&minX);
202  _geotree->Branch("minY",&minY);
203  _geotree->Branch("minZ",&minZ);
204  _geotree->Branch("maxX",&maxX);
205  _geotree->Branch("maxY",&maxY);
206  _geotree->Branch("maxZ",&maxZ);
207  _geotree->Fill();
208  }
std::vector< double > _tcross_v
std::vector< double > _ped_mean_v
std::vector< double > _amp_v
std::vector< double > _tend_v
std::vector< double > _area_v
std::vector< double > _tmax_v
std::vector< double > _tstart_v
std::vector< double > _wf
std::vector< double > _ped_sigma_v
void opdet::FullOpHitFinder::endJob ( )

Definition at line 210 of file FullOpHitFinder_module.cc.

211  {
212  _ofile->cd();
213  _wftree->Write();
214  _hittree->Write();
215  _geotree->Write();
216  _ofile->Close();
217  }
std::map< int, int > opdet::FullOpHitFinder::GetChannelMap ( )
private
std::vector< double > opdet::FullOpHitFinder::GetSPEScales ( )
private
std::vector< double > opdet::FullOpHitFinder::GetSPEShifts ( )
private
void opdet::FullOpHitFinder::produce ( art::Event &  evt)

Definition at line 230 of file FullOpHitFinder_module.cc.

231  {
232 
233  _event = evt.id().event();
234  _run = evt.id().run();
235 
236  // These is the storage pointer we will put in the event
237  std::unique_ptr< std::vector< recob::OpHit > >
238  HitPtr(new std::vector< recob::OpHit >);
239 
240  //
241  // Get the pulses from the event
242  //
243 
244  if(fInputLabels.empty()) fInputLabels.push_back("");
245  for (auto label : fInputLabels) {
246 
247  art::Handle< std::vector< raw::OpDetWaveform > > wfHandle;
248  evt.getByLabel(fInputModule, label, wfHandle);
249  if (!wfHandle.isValid()) continue; // Skip non-existent collections
250 
251  for(auto const& waveform : (*wfHandle)) {
252 
253  _ch = static_cast< int >(waveform.ChannelNumber());
254  _tstart = waveform.TimeStamp();
255 
256  _wf.clear();
257  _wf.resize(waveform.size());
258  for(size_t idx=0; idx<_wf.size(); ++idx)
259  _wf[idx] = waveform[idx];
260 
261  fPulseRecoMgr.Reconstruct(waveform);
262 
263  // Record waveforms
264  _ped_mean_v = fPedAlg->Mean();
266  _wftree->Fill();
267 
268  // Record pulses
269  auto const& pulses = fThreshAlg->GetPulses();
270  size_t npulse = pulses.size();
271  _tstart_v.resize(npulse); _tmax_v.resize(npulse); _tend_v.resize(npulse); _tcross_v.resize(npulse);
272  _amp_v.resize(npulse); _area_v.resize(npulse);
273  _ped_mean_v.resize(npulse); _ped_sigma_v.resize(npulse);
274 
275  for(size_t idx=0; idx<npulse; ++idx) {
276  auto const& pulse = pulses[idx];
277  _tstart_v[idx] = pulse.t_start;
278  _tmax_v[idx] = pulse.t_max;
279  _tend_v[idx] = pulse.t_end;
280  _tcross_v[idx] = pulse.t_cfdcross;
281  _amp_v[idx] = pulse.peak;
282  _area_v[idx] = pulse.area;
283  _ped_mean_v[idx] = pulse.ped_mean;
284  _ped_sigma_v[idx] = pulse.ped_sigma;
285  }
286  _hittree->Fill();
287  }
288  }
289  }
std::vector< double > _tcross_v
std::vector< double > _ped_mean_v
double Mean(size_t i) const
Getter of the pedestal mean value.
unsigned int event
Definition: DataStructs.h:634
unsigned int run
Definition: DataStructs.h:635
std::vector< double > _amp_v
std::vector< double > _tend_v
std::vector< double > _area_v
std::vector< double > _tmax_v
std::vector< std::string > fInputLabels
pmtana::PMTPedestalBase * fPedAlg
pmtana::PMTPulseRecoBase * fThreshAlg
const pulse_param_array & GetPulses() const
A getter for the whole array of pulse_param struct object.
double Sigma(size_t i) const
Getter of the pedestal standard deviation.
bool Reconstruct(const pmtana::Waveform_t &) const
Implementation of ana_base::analyze method.
std::vector< double > _tstart_v
std::vector< double > _wf
std::vector< double > _ped_sigma_v
TCEvent evt
Definition: DataStructs.cxx:8
pmtana::PulseRecoManager fPulseRecoMgr

Member Data Documentation

std::vector<double> opdet::FullOpHitFinder::_amp_v
private

Definition at line 78 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_area_v
private

Definition at line 78 of file FullOpHitFinder_module.cc.

int opdet::FullOpHitFinder::_ch
private

Definition at line 82 of file FullOpHitFinder_module.cc.

int opdet::FullOpHitFinder::_event
private

Definition at line 82 of file FullOpHitFinder_module.cc.

TTree* opdet::FullOpHitFinder::_geotree
private

Definition at line 86 of file FullOpHitFinder_module.cc.

TTree* opdet::FullOpHitFinder::_hittree
private

Definition at line 85 of file FullOpHitFinder_module.cc.

TFile* opdet::FullOpHitFinder::_ofile
private

Definition at line 87 of file FullOpHitFinder_module.cc.

std::string opdet::FullOpHitFinder::_output_filename
private

Definition at line 76 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_ped_mean_v
private

Definition at line 79 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_ped_sigma_v
private

Definition at line 79 of file FullOpHitFinder_module.cc.

int opdet::FullOpHitFinder::_run
private

Definition at line 82 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_tcross_v
private

Definition at line 77 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_tend_v
private

Definition at line 77 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_tmax_v
private

Definition at line 77 of file FullOpHitFinder_module.cc.

double opdet::FullOpHitFinder::_tstart
private

Definition at line 81 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_tstart_v
private

Definition at line 77 of file FullOpHitFinder_module.cc.

std::vector<double> opdet::FullOpHitFinder::_wf
private

Definition at line 80 of file FullOpHitFinder_module.cc.

TTree* opdet::FullOpHitFinder::_wftree
private

Definition at line 84 of file FullOpHitFinder_module.cc.

std::set< unsigned int > opdet::FullOpHitFinder::fChannelMasks
private

Definition at line 69 of file FullOpHitFinder_module.cc.

std::vector< std::string > opdet::FullOpHitFinder::fInputLabels
private

Definition at line 68 of file FullOpHitFinder_module.cc.

std::string opdet::FullOpHitFinder::fInputModule
private

Definition at line 67 of file FullOpHitFinder_module.cc.

pmtana::PMTPedestalBase* opdet::FullOpHitFinder::fPedAlg
private

Definition at line 73 of file FullOpHitFinder_module.cc.

pmtana::PulseRecoManager opdet::FullOpHitFinder::fPulseRecoMgr
private

Definition at line 71 of file FullOpHitFinder_module.cc.

pmtana::PMTPulseRecoBase* opdet::FullOpHitFinder::fThreshAlg
private

Definition at line 72 of file FullOpHitFinder_module.cc.


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