SupernovaTrigger_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SupernovaTrigger
3 // Module Type: filter
4 // File: SupernovaTrigger_module.cc
5 //
6 // Generated at Mon Dec 17 15:29:53 2012 by Zukai Wang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
15 
25 
28 
29 #include <string>
30 #include <queue>
31 #include <algorithm>
32 #include <functional>
33 
34 namespace novaddt {
35  class SupernovaTrigger;
36 }
37 
39 public:
40  explicit SupernovaTrigger(fhicl::ParameterSet const & p);
41  virtual ~SupernovaTrigger();
42  virtual bool filter(art::Event & e) override;
43  virtual void endJob() override;
44 private:
45  uint64_t GetCandidates(const art::Event & e);
46  uint64_t GetTime(const art::Event & e);
47 private:
48  bool fVerbose;
52 
53  bool fGroupDoRemove; // should we bother to remove large groups
54  size_t fGroupCountMax; // groups larger than this will not be counted
55  int fGroupDTmax; // maximum time distance to group
56  bool fGroupNeighbours; // if TRUE, add cluster to group when close to last hit
57 };
58 
60  fVerbose(p.get<bool>("verbose")),
61  fHeaderTag (p.get< std::string >("header_tag" )),
62  fSlicesTag (p.get< std::string >("slices_tag" )),
63  fSelector (p.get<fhicl::ParameterSet>("slice_cuts")),
64  fGroupDoRemove (p.get<bool>("group.remove",false)),
65  fGroupCountMax (p.get<size_t>("group.size_max",5)),
66  fGroupDTmax (p.get<int>("group.DT_max",3)),
67  fGroupNeighbours (p.get<bool>("group.neighbours",false))
68 {
69  mf::LogInfo("SupernovaTrigger")<<"config:"
70  <<"\n slices_tag: "<<fSlicesTag
71  <<"\n header_tag: "<<fHeaderTag
72  <<"\n slice_cuts: "<<fSelector
73  <<"\n group: "
74  <<"\n \t remove: "<<fGroupDoRemove
75  <<"\n \t neighbours: "<<fGroupNeighbours
76  <<"\n \t size_max: "<<fGroupCountMax
77  <<"\n \t DT_max: "<<fGroupDTmax;
78 
79 }
80 
82 {
83  // Clean up dynamic memory and other resources here.
84 }
85 
86 
88 {
89 
90  auto slices=e.getValidHandle<std::vector<novaddt::HitList>>(fSlicesTag);
91 
92  if(!fGroupDoRemove)
93  //no Groups removal needed, just simple counting
94  return fSelector.countPassing(*slices);
95 
96 
97  size_t Nselected = 0; //count number of candidates
98  size_t groupCount=0;
99 
100  uint64_t t0=0, t1=0;
101  int dT;
102  ///subtract large groups of candidates, clustered in time -
103  ///they are mostly remnants of unreconstructed muon tracks
104  for(const auto& slice: *slices){
105  auto cluster=CalcCluster(slice);
106  if(fSelector.checkCluster(cluster)==false) continue;
107  t1=cluster.t;
108  dT=t1-t0;
109  if(dT>fGroupDTmax){
110  if(groupCount<fGroupCountMax)Nselected+=groupCount;
111  groupCount=0;
112  }
113  ++groupCount;
114  if(groupCount==1||fGroupNeighbours)t0=t1;
115  mf::LogDebug("SupernovaTrigger")<<Nselected<<" "<<groupCount<<" "<<dT;
116  }
117  if(groupCount<fGroupCountMax)Nselected+=groupCount;
118 
119  mf::LogDebug("SupernovaTrigger")<<"counting slices:"
120  <<"\nNSlices All="<<slices->size()
121  <<"\nNSlices Sel="<<Nselected;
122  //calculate hits in signal region
123  return Nselected;
124 }
125 
127 {
128  const uint64_t msec=64000; //TDC ticks/msec
131  return header->timeStart/msec;
132  else
133  return e.event()*5;
134 }
135 
137 {
138  //service to send the data points
140  //send the data
141  msg->PushPoint(GetTime(e),GetCandidates(e));
142  return false;
143 }
144 
145 
147 {
148 }
uint64_t GetTime(const art::Event &e)
uint64_t GetCandidates(const art::Event &e)
virtual bool filter(art::Event &e) override
virtual void endJob() override
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
clusterInfo CalcCluster(const novaddt::HitList &slice)
Definition: clusterInfo.h:26
virtual void PushPoint(uint64_t time, uint64_t hits)=0
EventNumber_t event() const
Definition: Event.h:67
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35
bool checkCluster(const clusterInfo &c)
Definition: SliceSelector.h:68
size_t countPassing(const std::vector< novaddt::HitList > &slices)
Definition: SliceSelector.h:79
SupernovaTrigger(fhicl::ParameterSet const &p)
enum BeamMode string