SliceSelector.h
Go to the documentation of this file.
3 #include <vector>
4 
5 namespace novaddt{
6  class SliceSelector;
7 }
8 
9 template <class T>
10 class Limits{
11  public:
12  Limits():fHasMin(false),fHasMax(false){}
13 
15  fHasMin(p.get_if_present<T>("min",fMin)),
16  fHasMax(p.get_if_present<T>("max",fMax))
17  {}
18  bool Contains (const T& v) const {
19  return (!fHasMin || fMin<=v)&&(!fHasMax || v<=fMax);
20  }
21 
22  template <class U>
23  friend std::ostream& operator << (std::ostream& s,const Limits<U>& lims) {
24  s<<"[";
25  if(lims.fHasMin) s<<lims.fMin<<"<";
26  s<<"x";
27  if(lims.fHasMax) s<<"<"<<lims.fMax;
28  s<<"]";
29  return s;
30  }
31 
32  private:
33  T fMin,fMax;
34  bool fHasMin = false;
35  bool fHasMax = false;
36 };
37 
38 template <class T>
40  return Limits<T>(p);
41 }
42 
44 /// a class to check if the slice passes given cut
45  public:
47  {
49  ("ADC",lim_adc, makeLimits<uint64_t>);
50  p.get_if_present<Limits<uint64_t>, fhicl::ParameterSet>
51  ("nHits.View",lim_Nview, makeLimits<uint64_t>);
52  p.get_if_present<Limits<uint64_t>, fhicl::ParameterSet>
53  ("nHits.Total",lim_Ntot, makeLimits<uint64_t>);
54  p.get_if_present<Limits<uint64_t>, fhicl::ParameterSet>
55  ("FV.x",lim_x, makeLimits<uint64_t>);
56  p.get_if_present<Limits<uint64_t>, fhicl::ParameterSet>
57  ("FV.y",lim_y, makeLimits<uint64_t>);
58  p.get_if_present<Limits<uint64_t>, fhicl::ParameterSet>
59  ("FV.z",lim_z, makeLimits<uint64_t>);
60  }
61 
62  bool checkSlice(const novaddt::HitList& slice)
63  {
64  clusterInfo c=CalcCluster(slice);
65  return checkCluster(c);
66  }
67  //check if adc value for slice is whithin limits
68  bool checkCluster(const clusterInfo& c)
69  {
70  return lim_adc.Contains(c.ADC()) &&
71  lim_Nview.Contains(c.Nx()) &&
72  lim_Nview.Contains(c.Ny()) &&
73  lim_Ntot.Contains(c.N()) &&
74  lim_x.Contains(c.x()) &&
75  lim_y.Contains(c.y()) &&
76  lim_z.Contains(c.z())
77  ;
78  }
79  size_t countPassing(const std::vector<novaddt::HitList>&slices)
80  {
81  size_t nslices=0;
82  for(const auto& slice: slices)
83  if(checkSlice(slice))++nslices;
84  return nslices;
85  }
86  friend std::ostream& operator << (std::ostream& s,const novaddt::SliceSelector& sel){
87  s<<"adc: "<<sel.lim_adc
88  <<"\tNview: "<<sel.lim_Nview
89  <<"\tNtot: "<<sel.lim_Ntot;
90  return s;
91  }
92  private:
95  Limits<uint64_t> lim_x, lim_y, lim_z;
96 
97 };
98 
99 
100 
101 
uint64_t y() const
Definition: clusterInfo.h:15
uint64_t x() const
Definition: clusterInfo.h:14
Limits< uint64_t > lim_z
Definition: SliceSelector.h:95
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
clusterInfo CalcCluster(const novaddt::HitList &slice)
Definition: clusterInfo.h:26
uint64_t Nx() const
Definition: clusterInfo.h:8
Limits< T > makeLimits(const fhicl::ParameterSet &p)
Definition: SliceSelector.h:39
const XML_Char * s
Definition: expat.h:262
bool checkSlice(const novaddt::HitList &slice)
Definition: SliceSelector.h:62
uint64_t ADC() const
Definition: clusterInfo.h:10
uint64_t N() const
Definition: clusterInfo.h:7
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
uint64_t z() const
Definition: clusterInfo.h:16
std::ostream & operator<<(std::ostream &o, skim::ParametersNue const &p)
uint64_t Ny() const
Definition: clusterInfo.h:9
Limits(fhicl::ParameterSet const &p)
Definition: SliceSelector.h:14
bool Contains(const T &v) const
Definition: SliceSelector.h:18
Limits< uint64_t > lim_Ntot
Definition: SliceSelector.h:94
double T
Definition: Xdiff_gwt.C:5
bool checkCluster(const clusterInfo &c)
Definition: SliceSelector.h:68
size_t countPassing(const std::vector< novaddt::HitList > &slices)
Definition: SliceSelector.h:79
Limits< uint64_t > lim_adc
Definition: SliceSelector.h:93
Limits< uint64_t > lim_Nview
Definition: SliceSelector.h:94
SliceSelector(fhicl::ParameterSet const &p)
a class to check if the slice passes given cut
Definition: SliceSelector.h:46