LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
nnet::PointIdTrainingData Class Reference
Inheritance diagram for nnet::PointIdTrainingData:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 PointIdTrainingData (Parameters const &config)
 
void beginJob () override
 
void endJob () override
 
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)
 
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)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
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 ()
 

Private Member Functions

void analyze (const art::Event &event) override
 
int WeightedFit (int n, std::vector< double > const &x, std::vector< double > const &y, std::vector< double > const &w, double *params) const
 

Private Attributes

nnet::TrainingDataAlg fTrainingDataAlg
 
std::string fOutTextFilePath
 
std::string fOutNumpyFileName
 
bool fDumpToRoot
 
bool fDumpToNumpy
 
std::vector< int > fSelectedTPC
 
std::vector< int > fSelectedPlane
 
int fEvent
 
int fRun
 number of the event being processed More...
 
int fSubRun
 number of the run being processed More...
 
bool fCrop
 number of the sub-run being processed More...
 
int fPatch_size_w
 crop data to event (set to false when dumping noise!) More...
 
int fPatch_size_d
 patch size in wire dimension More...
 
double fEm
 patch size in drift dimension More...
 
double fTrk
 
double fMichel
 
double fNone
 
double fStopTrk
 
double fCleanTrk
 
int nEm
 
int nTrk
 
int nMichel
 
int nNone
 
int nEm_sel
 
int nTrk_sel
 
int nMichel_sel
 
int nNone_sel
 
int nStopTrk_sel
 
int nCleanTrk_sel
 
geo::GeometryCore const * fGeometry
 
c2numpy_writer npywriter
 
CLHEP::HepRandomEngine & fEngine
 art-managed random-number engine More...
 

Detailed Description

Definition at line 62 of file PointIdTrainingData_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Constructor & Destructor Documentation

nnet::PointIdTrainingData::PointIdTrainingData ( PointIdTrainingData::Parameters const &  config)
explicit

Definition at line 162 of file PointIdTrainingData_module.cc.

References fGeometry, fSelectedPlane, fSelectedTPC, geo::GeometryCore::MaxPlanes(), and geo::GeometryCore::NTPC().

163  : art::EDAnalyzer(config)
164  , fTrainingDataAlg(config().TrainingDataAlg())
165  , fOutTextFilePath(config().OutTextFilePath())
166  , fOutNumpyFileName(config().OutNumpyFileName())
167  , fDumpToRoot(config().DumpToRoot())
168  , fDumpToNumpy(config().DumpToNumpy())
169  , fSelectedTPC(config().SelectedTPC())
170  , fSelectedPlane(config().SelectedView())
171  , fCrop(config().Crop())
172  , fPatch_size_w(config().Patch_size_w())
173  , fPatch_size_d(config().Patch_size_d())
174  , fEm(config().Em())
175  , fTrk(config().Trk())
176  , fMichel(config().Michel())
177  , fNone(config().None())
178  , fStopTrk(config().StopTrk())
179  , fCleanTrk(config().CleanTrk())
180  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->registerAndSeedEngine(createEngine(0)))
181  {
183 
184  if (fSelectedTPC.empty()) {
185  for (size_t tpc = 0; tpc < fGeometry->NTPC(); ++tpc)
186  fSelectedTPC.push_back(tpc);
187  }
188 
189  if (fSelectedPlane.empty()) {
190  for (size_t p = 0; p < fGeometry->MaxPlanes(); ++p)
191  fSelectedPlane.push_back(p);
192  }
193  }
base_engine_t & createEngine(seed_t seed)
double fEm
patch size in drift dimension
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:686
int fPatch_size_d
patch size in wire dimension
geo::GeometryCore const * fGeometry
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
int fPatch_size_w
crop data to event (set to false when dumping noise!)
bool fCrop
number of the sub-run being processed
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine

Member Function Documentation

void nnet::PointIdTrainingData::analyze ( const art::Event event)
overrideprivate

Definition at line 244 of file PointIdTrainingData_module.cc.

References util::abs(), c2numpy_float32(), c2numpy_uint16(), c2numpy_uint32(), c2numpy_uint8(), d, e, edep, art::EventID::event(), fCleanTrk, fCrop, fDumpToNumpy, fDumpToRoot, fEm, fEngine, fEvent, nnet::TrainingDataAlg::findCrop(), fMichel, fNone, fOutTextFilePath, fPatch_size_d, fPatch_size_w, fRun, fSelectedPlane, fSelectedTPC, fStopTrk, fSubRun, fTrainingDataAlg, fTrk, art::Event::id(), nCleanTrk_sel, nEm, nEm_sel, nMichel, nMichel_sel, nNone, nNone_sel, npywriter, img::DataProviderAlg::NScaledDrifts(), nStopTrk_sel, nTrk, nTrk_sel, img::DataProviderAlg::NWires(), art::EventID::run(), nnet::TrainingDataAlg::saveSimInfo(), nnet::TrainingDataAlg::setEventData(), art::EventID::subRun(), w, WeightedFit(), img::DataProviderAlg::wireData(), nnet::TrainingDataAlg::wireEdep(), nnet::TrainingDataAlg::wirePdg(), y1, y2, and y3.

245  {
246  fEvent = event.id().event();
247  fRun = event.run();
248  fSubRun = event.subRun();
249 
250  bool saveSim = fTrainingDataAlg.saveSimInfo() && !event.isRealData();
251 
252  std::ostringstream os;
253  os << "event_" << fEvent << "_run_" << fRun << "_subrun_" << fSubRun;
254 
255  std::cout << "analyze " << os.str() << std::endl;
256 
257  auto const clockData =
259  auto const detProp =
261 
262  CLHEP::RandFlat flat(fEngine);
263 
264  for (size_t i = 0; i < fSelectedTPC.size(); ++i)
265  for (size_t v = 0; v < fSelectedPlane.size(); ++v) {
267  event, clockData, detProp, fSelectedPlane[v], fSelectedTPC[i], 0);
268 
269  unsigned int w0, w1, d0, d1;
270  if (fCrop && saveSim) {
271  if (fTrainingDataAlg.findCrop(0.004F, w0, w1, d0, d1)) {
272  std::cout << " crop: " << w0 << " " << w1 << " " << d0 << " " << d1 << std::endl;
273  }
274  else {
275  std::cout << " skip empty tpc:" << fSelectedTPC[i] << " / view:" << fSelectedPlane[v]
276  << std::endl;
277  continue;
278  }
279  }
280  else {
281  w0 = 0;
282  w1 = fTrainingDataAlg.NWires();
283  d0 = 0;
285  }
286 
287  if (fDumpToRoot) {
288  std::ostringstream ss1;
289  ss1 << "raw_" << os.str() << "_tpc_" << fSelectedTPC[i] << "_view_"
290  << fSelectedPlane[v]; // TH2's name
291 
293  TH2F* rawHist =
294  tfs->make<TH2F>((ss1.str() + "_raw").c_str(), "ADC", w1 - w0, w0, w1, d1 - d0, d0, d1);
295  TH2F* depHist = 0;
296  TH2I* pdgHist = 0;
297  if (saveSim) {
298  depHist = tfs->make<TH2F>(
299  (ss1.str() + "_deposit").c_str(), "Deposit", w1 - w0, w0, w1, d1 - d0, d0, d1);
300  pdgHist = tfs->make<TH2I>(
301  (ss1.str() + "_pdg").c_str(), "PDG", w1 - w0, w0, w1, d1 - d0, d0, d1);
302  }
303 
304  for (size_t w = w0; w < w1; ++w) {
305  auto const& raw = fTrainingDataAlg.wireData(w);
306  for (size_t d = d0; d < d1; ++d) {
307  rawHist->Fill(w, d, raw[d]);
308  }
309 
310  if (saveSim) {
311  auto const& edep = fTrainingDataAlg.wireEdep(w);
312  for (size_t d = d0; d < d1; ++d) {
313  depHist->Fill(w, d, edep[d]);
314  }
315 
316  auto const& pdg = fTrainingDataAlg.wirePdg(w);
317  for (size_t d = d0; d < d1; ++d) {
318  pdgHist->Fill(w, d, pdg[d]);
319  }
320  }
321  }
322 
323  writeAndDelete(rawHist);
324  writeAndDelete(depHist);
325  writeAndDelete(pdgHist);
326  }
327  else if (fDumpToNumpy) {
328  for (size_t w = w0; w < w1; ++w) {
329  int w_start = w - fPatch_size_w / 2;
330  int w_stop = w_start + fPatch_size_w;
331  if (w_start < int(w0) || w_start > int(w1)) continue;
332  if (w_stop < int(w0) || w_stop > int(w1)) continue;
333  auto const& pdg = fTrainingDataAlg.wirePdg(w);
334  auto const& deposit = fTrainingDataAlg.wireEdep(w);
335  auto const& raw = fTrainingDataAlg.wireData(w);
336  for (size_t d = d0; d < d1; ++d) {
337  int d_start = d - fPatch_size_d / 2;
338  int d_stop = d_start + fPatch_size_d;
339  if (d_start < int(d0) || d_start > int(d1)) continue;
340  if (d_stop < int(d0) || d_stop > int(d1)) continue;
341  int y0 = 0, y1 = 0, y2 = 0, y3 = 0;
342  if (deposit[d] < 2e-5 || raw[d] < 0.05) { //empty pixel
343  y3 = 1;
344  ++nNone;
345  if (flat.fire() > fNone) continue;
346  ++nNone_sel;
347  }
348  else if ((pdg[d] & 0x0FFF) == 11) { //shower
349  y1 = 1;
350  ++nEm;
351  if ((pdg[d] & 0xF000) == 0x2000) { //Michel
352  y2 = 1;
353  ++nMichel;
354  if (flat.fire() > fMichel) continue;
355  ++nMichel_sel;
356  }
357  else {
358  if (flat.fire() > fEm) continue;
359  ++nEm_sel;
360  }
361  }
362  else { //track
363  y0 = 1;
364  ++nTrk;
365  //Check if the track appears to be stopping
366  int nPxlw0 = 0, nPxlw1 = 0, nPxld0 = 0, nPxld1 = 0;
367  //Try to fit a track
368  std::vector<double> wfit, dfit, chgfit;
369  double total_trkchg = 0;
370  for (int ww = w_start; ww < w_stop; ++ww) {
371  auto const& pdg1 = fTrainingDataAlg.wirePdg(ww);
372  auto const& deposit1 = fTrainingDataAlg.wireEdep(ww);
373  auto const& raw1 = fTrainingDataAlg.wireData(ww);
374  for (int dd = d_start; dd < d_stop; ++dd) {
375  if (deposit1[dd] < 2e-5 || raw1[dd] < 0.05) continue; //empty pixel
376  if ((pdg1[dd] & 0x0FFF) != 11) { //track pixel
377  wfit.push_back(ww);
378  dfit.push_back(dd);
379  chgfit.push_back(raw1[dd]);
380  total_trkchg += raw1[dd];
381  if (ww - w_start < 3) ++nPxlw0;
382  if (w_stop - ww - 1 < 3) ++nPxlw1;
383  if (dd - d_start < 3) ++nPxld0;
384  if (d_stop - dd - 1 < 3) ++nPxld1;
385  }
386  }
387  }
388  //Fit track pixels
389  double fit_trkchg = 0;
390  double parm[2] = {};
391  if (!wfit.empty()) {
392  if (!WeightedFit(wfit.size(), wfit, dfit, chgfit, &parm[0])) {
393  for (size_t j = 0; j < wfit.size(); ++j) {
394  if (std::abs((dfit[j] - (parm[0] + wfit[j] * parm[1])) * cos(atan(parm[1]))) <
395  3) {
396  fit_trkchg += chgfit[j];
397  }
398  }
399  }
400  else if (!WeightedFit(dfit.size(), dfit, wfit, chgfit, &parm[0])) {
401  for (size_t j = 0; j < dfit.size(); ++j) {
402  if (std::abs((wfit[j] - (parm[0] + dfit[j] * parm[1])) * cos(atan(parm[1]))) <
403  3) {
404  fit_trkchg += chgfit[j];
405  }
406  }
407  }
408  }
409  if (((nPxlw0) && (!nPxlw1) && (!nPxld0) && (!nPxld1)) ||
410  ((!nPxlw0) && (nPxlw1) && (!nPxld0) && (!nPxld1)) ||
411  ((!nPxlw0) && (!nPxlw1) && (nPxld0) && (!nPxld1)) ||
412  ((!nPxlw0) && (!nPxlw1) && (!nPxld0) && (nPxld1))) { //stopping track
413  if (flat.fire() > fStopTrk) continue;
414  ++nStopTrk_sel;
415  }
416  else if (total_trkchg && fit_trkchg / total_trkchg > 0.9) { //clean track
417  if (flat.fire() > fCleanTrk) continue;
418  ++nCleanTrk_sel;
419  }
420  else {
421  if (flat.fire() > fTrk) continue;
422  ++nTrk_sel;
423  }
424  }
425  c2numpy_uint32(&npywriter, event.id().run());
426  c2numpy_uint32(&npywriter, event.id().subRun());
427  c2numpy_uint32(&npywriter, event.id().event());
429  c2numpy_uint8(&npywriter, fSelectedPlane[v]);
432  c2numpy_uint8(&npywriter, y0);
436  for (int ww = w_start; ww < w_stop; ++ww) {
437  auto const& raw1 = fTrainingDataAlg.wireData(ww);
438  for (int dd = d_start; dd < d_stop; ++dd) {
439  c2numpy_float32(&npywriter, raw1[dd]);
440  }
441  }
442  }
443  }
444  }
445  else {
446  std::ostringstream ss1;
447  ss1 << fOutTextFilePath << "/raw_" << os.str() << "_tpc_" << fSelectedTPC[i] << "_view_"
448  << fSelectedPlane[v];
449 
450  std::ofstream fout_raw, fout_deposit, fout_pdg;
451 
452  fout_raw.open(ss1.str() + ".raw");
453  if (saveSim) {
454  fout_deposit.open(ss1.str() + ".deposit");
455  fout_pdg.open(ss1.str() + ".pdg");
456  }
457 
458  for (size_t w = w0; w < w1; ++w) {
459  auto const& raw = fTrainingDataAlg.wireData(w);
460  for (size_t d = d0; d < d1; ++d) {
461  fout_raw << raw[d] << " ";
462  }
463  fout_raw << std::endl;
464 
465  if (saveSim) {
466  auto const& edep = fTrainingDataAlg.wireEdep(w);
467  for (size_t d = d0; d < d1; ++d) {
468  fout_deposit << edep[d] << " ";
469  }
470  fout_deposit << std::endl;
471 
472  auto const& pdg = fTrainingDataAlg.wirePdg(w);
473  for (size_t d = d0; d < d1; ++d) {
474  fout_pdg << pdg[d] << " ";
475  }
476  fout_pdg << std::endl;
477  }
478  }
479 
480  fout_raw.close();
481  if (saveSim) {
482  fout_deposit.close();
483  fout_pdg.close();
484  }
485  }
486  }
487 
488  } // PointIdTrainingData::analyze()
double fEm
patch size in drift dimension
std::vector< float > const & wireEdep(size_t widx) const
Definition: PointIdAlg.h:287
Float_t y1[n_points_granero]
Definition: compare.C:5
int WeightedFit(int n, std::vector< double > const &x, std::vector< double > const &y, std::vector< double > const &w, double *params) const
bool saveSimInfo() const
Definition: PointIdAlg.h:262
bool setEventData(const art::Event &event, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: PointIdAlg.cxx:867
int fPatch_size_d
patch size in wire dimension
constexpr auto abs(T v)
Returns the absolute value of the argument.
int c2numpy_uint8(c2numpy_writer *writer, uint8_t data)
Definition: c2numpy.h:316
Raw data description.
Definition: RawTypes.h:6
RunNumber_t run() const
Definition: EventID.h:98
Float_t y2[n_points_geant4]
Definition: compare.C:26
int fRun
number of the event being processed
unsigned int NWires() const
int fPatch_size_w
crop data to event (set to false when dumping noise!)
Float_t d
Definition: plot.C:235
bool fCrop
number of the sub-run being processed
bool findCrop(float max_e_cut, unsigned int &w0, unsigned int &w1, unsigned int &d0, unsigned int &d1) const
Double_t edep
Definition: macro.C:13
int c2numpy_uint32(c2numpy_writer *writer, uint32_t data)
Definition: c2numpy.h:334
int c2numpy_float32(c2numpy_writer *writer, float data)
Definition: c2numpy.h:369
int fSubRun
number of the run being processed
int c2numpy_uint16(c2numpy_writer *writer, uint16_t data)
Definition: c2numpy.h:325
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
unsigned int NScaledDrifts() const
EventNumber_t event() const
Definition: EventID.h:116
std::vector< int > const & wirePdg(size_t widx) const
Definition: PointIdAlg.h:288
Float_t y3[n_points_geant4]
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:23
std::vector< float > const & wireData(size_t widx) const
void nnet::PointIdTrainingData::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 196 of file PointIdTrainingData_module.cc.

References c2numpy_addcolumn(), C2NUMPY_FLOAT32, c2numpy_init(), C2NUMPY_UINT16, C2NUMPY_UINT32, C2NUMPY_UINT8, fOutNumpyFileName, fPatch_size_d, fPatch_size_w, nCleanTrk_sel, nEm, nEm_sel, nMichel, nMichel_sel, nNone, nNone_sel, npywriter, nStopTrk_sel, nTrk, and nTrk_sel.

197  {
198 
211  for (int i = 0; i < fPatch_size_w * fPatch_size_d; ++i) {
212  c2numpy_addcolumn(&npywriter, Form("x%d", i), C2NUMPY_FLOAT32);
213  }
214  nEm = 0;
215  nTrk = 0;
216  nMichel = 0;
217  nNone = 0;
218  nEm_sel = 0;
219  nTrk_sel = 0;
220  nMichel_sel = 0;
221  nNone_sel = 0;
222  nStopTrk_sel = 0;
223  nCleanTrk_sel = 0;
224  }
int c2numpy_init(c2numpy_writer *writer, const std::string outputFilePrefix, int32_t numRowsPerFile)
Definition: c2numpy.h:140
int fPatch_size_d
patch size in wire dimension
int c2numpy_addcolumn(c2numpy_writer *writer, const std::string name, c2numpy_type type)
Definition: c2numpy.h:157
int fPatch_size_w
crop data to event (set to false when dumping noise!)
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::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 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void nnet::PointIdTrainingData::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 227 of file PointIdTrainingData_module.cc.

References c2numpy_close(), nCleanTrk_sel, nEm, nEm_sel, nMichel, nMichel_sel, nNone, nNone_sel, npywriter, nStopTrk_sel, nTrk, and nTrk_sel.

228  {
229  std::cout << "nEm = " << nEm << std::endl;
230  std::cout << "nTrk = " << nTrk << std::endl;
231  std::cout << "nMichel = " << nMichel << std::endl;
232  std::cout << "nNone = " << nNone << std::endl;
233  std::cout << std::endl;
234  std::cout << "nEm_sel = " << nEm_sel << std::endl;
235  std::cout << "nTrk_sel = " << nTrk_sel << std::endl;
236  std::cout << "nMichel_sel = " << nMichel_sel << std::endl;
237  std::cout << "nNone_sel = " << nNone_sel << std::endl;
238  std::cout << "nStopTrk_sel = " << nStopTrk_sel << std::endl;
239  std::cout << "nCleanTrk_sel = " << nCleanTrk_sel << std::endl;
241  }
int c2numpy_close(c2numpy_writer *writer)
Definition: c2numpy.h:425
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

Referenced by art::OutputModule::doEvent(), art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
int nnet::PointIdTrainingData::WeightedFit ( int  n,
std::vector< double > const &  x,
std::vector< double > const &  y,
std::vector< double > const &  w,
double *  params 
) const
private

Definition at line 491 of file PointIdTrainingData_module.cc.

References DEFINE_ART_MODULE, and n.

Referenced by analyze().

496  {
497  Double_t sumx = 0.;
498  Double_t sumx2 = 0.;
499  Double_t sumy = 0.;
500  Double_t sumy2 = 0.;
501  Double_t sumxy = 0.;
502  Double_t sumw = 0.;
503  Double_t eparams[2] = {};
504 
505  for (Int_t i = 0; i < n; i++) {
506  sumx += x[i] * w[i];
507  sumx2 += x[i] * x[i] * w[i];
508  sumy += y[i] * w[i];
509  sumy2 += y[i] * y[i] * w[i];
510  sumxy += x[i] * y[i] * w[i];
511  sumw += w[i];
512  }
513 
514  if (sumx2 * sumw - sumx * sumx == 0.) return 1;
515  if (sumx2 - sumx * sumx / sumw == 0.) return 1;
516 
517  params[0] = (sumy * sumx2 - sumx * sumxy) / (sumx2 * sumw - sumx * sumx);
518  params[1] = (sumxy - sumx * sumy / sumw) / (sumx2 - sumx * sumx / sumw);
519 
520  eparams[0] = sumx2 * (sumx2 * sumw - sumx * sumx);
521  eparams[1] = (sumx2 - sumx * sumx / sumw);
522 
523  if (eparams[0] < 0. || eparams[1] < 0.) return 1;
524 
525  eparams[0] = sqrt(eparams[0]) / (sumx2 * sumw - sumx * sumx);
526  eparams[1] = sqrt(eparams[1]) / (sumx2 - sumx * sumx / sumw);
527 
528  return 0;
529  }
Char_t n[5]

Member Data Documentation

double nnet::PointIdTrainingData::fCleanTrk
private

Definition at line 142 of file PointIdTrainingData_module.cc.

Referenced by analyze().

bool nnet::PointIdTrainingData::fCrop
private

number of the sub-run being processed

Definition at line 136 of file PointIdTrainingData_module.cc.

Referenced by analyze().

bool nnet::PointIdTrainingData::fDumpToNumpy
private

Definition at line 127 of file PointIdTrainingData_module.cc.

Referenced by analyze().

bool nnet::PointIdTrainingData::fDumpToRoot
private

Definition at line 126 of file PointIdTrainingData_module.cc.

Referenced by analyze().

double nnet::PointIdTrainingData::fEm
private

patch size in drift dimension

Definition at line 141 of file PointIdTrainingData_module.cc.

Referenced by analyze().

CLHEP::HepRandomEngine& nnet::PointIdTrainingData::fEngine
private

art-managed random-number engine

Definition at line 152 of file PointIdTrainingData_module.cc.

Referenced by analyze().

int nnet::PointIdTrainingData::fEvent
private

Definition at line 132 of file PointIdTrainingData_module.cc.

Referenced by analyze().

geo::GeometryCore const* nnet::PointIdTrainingData::fGeometry
private

Definition at line 148 of file PointIdTrainingData_module.cc.

Referenced by PointIdTrainingData().

double nnet::PointIdTrainingData::fMichel
private

Definition at line 141 of file PointIdTrainingData_module.cc.

Referenced by analyze().

double nnet::PointIdTrainingData::fNone
private

Definition at line 141 of file PointIdTrainingData_module.cc.

Referenced by analyze().

std::string nnet::PointIdTrainingData::fOutNumpyFileName
private

Definition at line 125 of file PointIdTrainingData_module.cc.

Referenced by beginJob().

std::string nnet::PointIdTrainingData::fOutTextFilePath
private

Definition at line 124 of file PointIdTrainingData_module.cc.

Referenced by analyze().

int nnet::PointIdTrainingData::fPatch_size_d
private

patch size in wire dimension

Definition at line 139 of file PointIdTrainingData_module.cc.

Referenced by analyze(), and beginJob().

int nnet::PointIdTrainingData::fPatch_size_w
private

crop data to event (set to false when dumping noise!)

Definition at line 138 of file PointIdTrainingData_module.cc.

Referenced by analyze(), and beginJob().

int nnet::PointIdTrainingData::fRun
private

number of the event being processed

Definition at line 133 of file PointIdTrainingData_module.cc.

Referenced by analyze().

std::vector<int> nnet::PointIdTrainingData::fSelectedPlane
private

Definition at line 130 of file PointIdTrainingData_module.cc.

Referenced by analyze(), and PointIdTrainingData().

std::vector<int> nnet::PointIdTrainingData::fSelectedTPC
private

Definition at line 129 of file PointIdTrainingData_module.cc.

Referenced by analyze(), and PointIdTrainingData().

double nnet::PointIdTrainingData::fStopTrk
private

Definition at line 142 of file PointIdTrainingData_module.cc.

Referenced by analyze().

int nnet::PointIdTrainingData::fSubRun
private

number of the run being processed

Definition at line 134 of file PointIdTrainingData_module.cc.

Referenced by analyze().

nnet::TrainingDataAlg nnet::PointIdTrainingData::fTrainingDataAlg
private

Definition at line 122 of file PointIdTrainingData_module.cc.

Referenced by analyze().

double nnet::PointIdTrainingData::fTrk
private

Definition at line 141 of file PointIdTrainingData_module.cc.

Referenced by analyze().

int nnet::PointIdTrainingData::nCleanTrk_sel
private

Definition at line 146 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nEm
private

Definition at line 144 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nEm_sel
private

Definition at line 145 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nMichel
private

Definition at line 144 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nMichel_sel
private

Definition at line 145 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nNone
private

Definition at line 144 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nNone_sel
private

Definition at line 145 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

c2numpy_writer nnet::PointIdTrainingData::npywriter
private

Definition at line 150 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nStopTrk_sel
private

Definition at line 146 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nTrk
private

Definition at line 144 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().

int nnet::PointIdTrainingData::nTrk_sel
private

Definition at line 145 of file PointIdTrainingData_module.cc.

Referenced by analyze(), beginJob(), and endJob().


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