All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaxNPEWindow.cxx
Go to the documentation of this file.
1 #ifndef OPT0FINDER_MAXNPEWINDOW_CXX
2 #define OPT0FINDER_MAXNPEWINDOW_CXX
3 
4 #include "MaxNPEWindow.h"
5 #include "TimeRange.h"
6 #include <map>
7 #include <numeric>
8 //#include <functional>
9 namespace flashmatch {
10 
12 
13  MaxNPEWindow::MaxNPEWindow(const std::string name)
14  : BaseFlashFilter(name)
15  , _time_lower_bound(-0.1) // Default T1 in micro-second
16  , _time_upper_bound(8.) // Default T2 in micro-second
17  , _npe_threshold(10) // Default # p.e. as a threshold
18  {}
19 
21  {
22  _time_lower_bound = pset.get<double>("TimeLowerBound");
23  _time_upper_bound = pset.get<double>("TimeUpperBound");
24  _npe_threshold = pset.get<double>("NPEThreshold" );
25  }
26 
28  {
29  // order flash via npe
30  std::multimap<double,ID_t> npe_map;
31  // Loop over flash array
32  for(size_t index=0; index<flash_v.size(); ++index) {
33 
34  auto const& flash = flash_v[index]; // Retrieve this flash
35 
36  double npe = std::accumulate(flash.pe_v.begin(),flash.pe_v.end(),0.0); // Sum p.e.
37 
38  if(npe < _npe_threshold) continue; // Ignore if below threshold
39 
40  npe_map.emplace( 1./npe, index ); // Use inverse of npe to order high=>low
41 
42  }
43 
44  // Prepare a return flashmatch::IDArray_t object
45  IDArray_t ordered_index_v;
46  ordered_index_v.reserve(npe_map.size()); // reserve for fast push_back
47 
48  TimeRangeSet trs; // Use TimeRange utility to detect overlap windows
49  for(auto const& npe_index : npe_map) {
50 
51  auto const& flash = flash_v[npe_index.second]; // retrieve flash
52 
53  if(trs.Overlap(flash.time)) continue; // if within defined set of windows, ignore
54 
55  ordered_index_v.push_back(npe_index.second); // candidate: add to a list
56 
57  // update TimeRangeSet to keep track of windows.
58  trs.Insert( TimeRange(flash.time + _time_lower_bound,
59  flash.time + _time_upper_bound) );
60  }
61 
62  return ordered_index_v;
63  }
64 
65 
66 }
67 
68 #endif
Class def header for a class MaxNPEWindow.
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
static MaxNPEWindowFactory __global_MaxNPEWindowFactory__
double _time_upper_bound
T2 [us]: the upper edge of the opened time window.
Definition: MaxNPEWindow.h:70
Class def header for a class TimeRange.
double _npe_threshold
threshold [p.e.]: to ignore any flash below this value
Definition: MaxNPEWindow.h:71
IDArray_t Filter(const FlashArray_t &)
Implementation of a virtual function.
double _time_lower_bound
T1 [us]: the lower edge of the opened time window.
Definition: MaxNPEWindow.h:69
MaxNPEWindow(const std::string name="MaxNPEWindow")
Default constructor.
void Insert(const flashmatch::TimeRange &range)
Definition: TimeRange.h:104
std::vector< flashmatch::ID_t > IDArray_t
Index collection.
void _Configure_(const Config_t &pset)
then echo fcl name
std::vector< flashmatch::Flash_t > FlashArray_t
Collection of Flash objects.
bool Overlap(const flashmatch::TimeRange &range) const
Definition: TimeRange.h:86