HighEFinder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: HighEFinder
3 // Module Type: filter
4 // File: HighEFinder_module.cc
5 //
6 // Generated at Tue Oct 25 22:21:45 2016 by Andrey Sheshukov using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
23 #include <memory>
24 #include <list>
25 
26 namespace supernova {
27  class HighEFinder;
28 }
29 
30 
32 public:
33  explicit HighEFinder(fhicl::ParameterSet const & p);
34  // The destructor generated by the compiler is fine for classes
35  // without bare pointers or other resource use.
36 
37  // Plugins should not be copied or assigned.
38  HighEFinder(HighEFinder const &) = delete;
39  HighEFinder(HighEFinder &&) = delete;
40  HighEFinder & operator = (HighEFinder const &) = delete;
41  HighEFinder & operator = (HighEFinder &&) = delete;
42 
43  // Required functions.
44  bool filter(art::Event & e) override;
45 
47 
48 private:
49 
50  // parameters
56 };
57 
58 
60  fSlicesTag (p.get< std::string >("slices_tag" )),
61  fHitsTag (p.get< std::string >("hits_tag" )),
62  fOutputTag (p.get< std::string >("output_tag" )),
63  fSelector (p.get<fhicl::ParameterSet>("slice_cuts")),
64  fDTime_min (p.get<int>("TimeRange.min",0)),
65  fDTime_max (p.get<int>("TimeRange.max",1000))
66 {
67  produces<std::vector<novaddt::HitList>>(fOutputTag);
68  mf::LogInfo("HighEFinder")<<"config:"
69  <<"\n slices_tag: "<<fSlicesTag
70  <<"\n hits_tag: "<<fHitsTag
71  <<"\n output_tag: "<<fOutputTag
72  <<"\n slice_cuts: "<<fSelector
73  <<"\n TimeRange: ["<<fDTime_min<<" : "<<fDTime_max<<"]";
74 }
75 
76 //a comparison function for searching in time
77 bool cmp_tdc(const novaddt::DAQHit& h, const novaddt::TDC& tdc){
78  return h.TDC()<tdc;
79 }
80 
82  const novaddt::HitList& allhits,
83  const novaddt::TDC& slice_time
84  )
85 {
86  //find the time range
87  // Only need to look at the time region around the end
88  auto tmin=slice_time+fDTime_min;
89  auto tmax=slice_time+fDTime_max;
90  const auto range_beg = std::lower_bound(allhits.begin(),allhits.end(),tmin, cmp_tdc);
91  const auto range_end = std::lower_bound(range_beg, allhits.end(),tmax, cmp_tdc);
92  mf::LogDebug("HighEFinder")
93  <<"retrieving "<<std::distance(range_beg, range_end)<<" hits "
94  <<"in time range ["<<tmin<<" : "<<tmax<<"]";
95 
96  return novaddt::HitList(range_beg, range_end);
97 }
98 
100 {
102  auto allhits=e.getValidHandle<novaddt::HitList>(fHitsTag);
103  //prepare resulting vector
104  auto result=std::make_unique<std::vector<novaddt::HitList>>();
105 
106  //find the high-energy slice
107  for(unsigned NSlice=0; NSlice<timeslices->n_groups();++NSlice){
108  const auto& slice = timeslices->get(NSlice);
109  if(fSelector.checkSlice(slice)){
110  //found the slice, get its starting time
111  auto slice_time=slice[0].TDC().val;
112  mf::LogInfo("HighEFinder")<<"Found HE slice starting at t="<<slice_time;
113  // get the hits in this time range
114  result->push_back(GetHitsAroundTime(*allhits,slice_time));
115  }
116  }
117 
118  mf::LogDebug("HighEFinder")<<" selected "<<result->size()<<" slices";
119  e.put(std::move(result));
120  return true;
121  //return (!result->empty());
122 }
123 
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
unsigned distance(const T &t1, const T &t2)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
novaddt::SliceSelector fSelector
bool checkSlice(const novaddt::HitList &slice)
Definition: SliceSelector.h:62
bool filter(art::Event &e) override
bool cmp_tdc(const novaddt::DAQHit &h, const novaddt::TDC &tdc)
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
An ART module for generating supernova events via GENIE.
novaddt::HitList GetHitsAroundTime(const novaddt::HitList &, const novaddt::TDC &)
HighEFinder(fhicl::ParameterSet const &p)
HighEFinder & operator=(HighEFinder const &)=delete
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35
enum BeamMode string