Diana Software
MBaselineFilter.cc
Go to the documentation of this file.
1 #include "MBaselineFilter.hh"
2 #include "QEvent.hh"
3 #include "QBaseType.hh"
4 #include "QBaselineData.hh"
5 #include <map>
6 #include <set>
7 #include <string>
8 
9 using std::map;
10 using std::set;
11 using std::string;
12 using std::cerr;
13 using std::endl;
14 
15 using namespace Diana;
16 
18 
19 void MBaselineFilter::GetCuts(const Diana::QEvent& ev)
20 {
21  // Get parameters from cfg
22 
23  // define minimum and maximum value for the variable
24  fMinValue = GetDouble("MinValue",Q_DOUBLE_DEFAULT);
25  fMaxValue = GetDouble("MaxValue",Q_DOUBLE_DEFAULT);
26 
27  fBaselineOwner = GetString("BaselineOwner","BaselineModule",false);
28 
29  fVariable = GetString("Variable","Baseline",false);
30 
31  fIsWarned = false;
32 
33  ev.Require<QBaselineData>((string)fBaselineOwner,"BaselineData");
34 }
35 
36 bool MBaselineFilter::Filter(const Diana::QEvent& ev)
37 {
38 
39  const QBaselineData& bData = ev.Get<QBaselineData>(((string)fBaselineOwner).c_str(),"BaselineData");
40 
41  // get variable from event
42 
43  Double_t variable;
44 
45  if(fVariable.CompareTo("Baseline")==0){
46  variable = bData.GetBaseline();
47 
48  }else if(fVariable.CompareTo("BaselineFlatRMS")==0){
49  variable = bData.GetBaselineFlatRMS();
50 
51  }else if(fVariable.CompareTo("BaselineIntercept")==0){
52  variable = bData.GetBaselineIntercept();
53 
54  }else if(fVariable.CompareTo("BaselineSlope")==0){
55  variable = bData.GetBaselineSlope();
56 
57  }else if(fVariable.CompareTo("BaselineSlopeRMSWindow")==0){
58  variable = bData.GetBaselineSlopeRMSWindow();
59 
60  }else if(fVariable.CompareTo("BaselineRMS")==0){
61  variable = bData.GetBaselineRMS();
62 
63  }else if(fVariable.CompareTo("RightBaseline")==0){
64  variable = bData.GetRightBaseline();
65 
66  }else if(fVariable.CompareTo("RightBaselineRMS")==0){
67  variable = bData.GetRightBaselineInRMS();
68  }else if(fVariable.CompareTo("RightLeftBaseline")==0){
69  variable = bData.GetRightLeftBaseline();
70  }else if(fVariable.CompareTo("RightLeftBaselineInRMS")==0){
71  variable = bData.GetRightLeftBaselineInRMS();
72 
73  }else{
74  Panic(TString("'")+fVariable+TString("' if not a valid choice for the 'Variable' field."));
75  }
76 
77 
78  bool passed = false;
79 
80  // perform selection: true if the event passes the cuts
81  if(fMinValue==Q_DOUBLE_DEFAULT && fMaxValue!=Q_DOUBLE_DEFAULT)
82  {
83  // applies only upper limit
84  if (variable<=fMaxValue) passed = true;
85  }
86  if(fMaxValue==Q_DOUBLE_DEFAULT && fMinValue!=Q_DOUBLE_DEFAULT)
87  {
88  // applies only lower limit
89  if (variable>=fMinValue) passed = true;
90  }
91  // no range specified
92  if(fMaxValue==Q_DOUBLE_DEFAULT && fMinValue==Q_DOUBLE_DEFAULT && !fIsWarned)
93  {
94  Warn("No range specified. The variable will not be filtered");
95  fIsWarned= true;
96  }
97  // wrong range (max < min)
98  if(fMaxValue!=Q_DOUBLE_DEFAULT && fMinValue!=Q_DOUBLE_DEFAULT && fMaxValue <= fMinValue && !fIsWarned)
99  {
100  Warn("Wrong Range (Max %f <= Min %f). The variable will not be filtered",fMaxValue,fMinValue);
101  fIsWarned= true;
102  }
103  else
104  {
105  if (variable>fMinValue && variable<fMaxValue) passed = true;
106  }
107  return passed;
108 
109 }
#define Q_DOUBLE_DEFAULT
Definition: QDiana.hh:24
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Module to filter baseline withing a range [min, max], inclusive.
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
baseline data
double GetBaseline() const
double GetBaselineRMS() const
double GetBaselineSlope() const
double GetBaselineFlatRMS() const
double GetRightLeftBaselineInRMS() const
double GetRightLeftBaseline() const
double GetRightBaselineInRMS() const
double GetBaselineIntercept() const
double GetBaselineSlopeRMSWindow() const
double GetRightBaseline() const
diana event
Definition: QEvent.hh:46
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...