Diana Software
MBadPulse.cc
Go to the documentation of this file.
1 #include "MBadPulse.hh"
2 #include "QEvent.hh"
3 #include "QCountPulsesData.hh"
4 #include "QBaselineData.hh"
5 #include "QPulseParameters.hh"
6 
7 using namespace Diana;
8 
10 
11 
12 void MBadPulse::GetCuts(const QEvent& ev)
13 {
14  fMaxBaselineSlope = GetDouble("MaxBaselineSlope", 0);
15  units = GetString("Units","Absolute",false);
16  if(units.compare("Absolute")!=0 and units.compare("Relative")!=0)Panic("Units not supported, can choose between 'Absolute' (mV/sample) or 'Relative' (BaselineRMS/WindowLength)");
17  // If MinBaselineSlope is specified, fMinBaselineSlope < BaselineSlope < fMaxBaselineSlope;
18  // else, -fMaxBaselineSlope < BaselineSlope < fMaxBaselineSlope
19  fMinBaselineSlope = GetDouble("MinBaselineSlope", -fMaxBaselineSlope);
20  fBaselineOwner = GetString("BaselineOwner","BaselineModule",false);
21  if(fMaxBaselineSlope) {
22  ev.Require<QBaselineData>(fBaselineOwner,"BaselineData");
23  }
24 
25  fFullWindowBaselineSlope = GetDouble("MaxFullWindowBaselineSlope", 0, false);
26  fFullWindowBaselineOwner = GetString("FullWindowBaselineOwner", "BaselineModule_FullWindow", false);
27  if(fFullWindowBaselineSlope) {
28  ev.Require<QBaselineData>(fFullWindowBaselineOwner, "BaselineData");
29  }
30 
31  fnPeaks = GetInt("NumberOfPeaks", -1);
32  fCountPulsesOwner = GetString("CountPulsesOwner","BCountPulses",false);
33  if(fnPeaks >= 0) {
34  ev.Require<QCountPulsesData>(fCountPulsesOwner,"CountPulsesData");
35  }
36 
37  fPulseBasicParametersOwner = GetString("PulseBasicParametersOwner","PulseBasicParameters",false);
38  ev.Require<QPulseParameters>(fPulseBasicParametersOwner,"Parameters");
39  fCheckSaturation = GetBool("CheckSaturation",true,false);
40 }
41 
42 bool MBadPulse::Filter(const QEvent& ev)
43 {
44  // perform selection: true if the event passes the cuts
45  bool result = true;
46  if(fCheckSaturation) {
47  //Note - May 2018:
48  //As the variables IsSaturatedLow/IsSaturatedHigh are assigned up to now, this check only rejects events which have baselines which saturated the ADC range
49  const QPulseParameters& bParams = ev.Get<QPulseParameters>(fPulseBasicParametersOwner.c_str(),"Parameters");
50  if(bParams.fIsSaturatedLow || bParams.fIsSaturatedHigh) result = false;
51  }
52 
53  if(fnPeaks >= 0)
54  {
55  if(ev.Get<QCountPulsesData>(fCountPulsesOwner.c_str(),"CountPulsesData").GetNumberOfPulses() != fnPeaks)
56  result = false;
57  }
58  if(fMaxBaselineSlope){
59  double bs1=0;
60  if(units.compare("Absolute")==0){
61  bs1= ev.Get<QBaselineData>(fBaselineOwner.c_str(),"BaselineData").GetBaselineSlope();
62  }else if(units.compare("Relative")==0){
63  bs1= ev.Get<QBaselineData>(fBaselineOwner.c_str(),"BaselineData").GetBaselineSlopeRMSWindow();
64  }
65  if(bs1 > fMaxBaselineSlope || bs1 < fMinBaselineSlope)
66  result = false;
67  }
68  if(fFullWindowBaselineSlope)
69  {
70  double bs2=0;
71  if(units.compare("Absolute")==0){
72  bs2 = ev.Get<QBaselineData>(fFullWindowBaselineOwner.c_str(),"BaselineData").GetBaselineSlope();
73  }else if(units.compare("Relative")==0){
74  bs2= ev.Get<QBaselineData>(fFullWindowBaselineOwner.c_str(),"BaselineData").GetBaselineSlopeRMSWindow();
75  }
76  if(bs2 > fFullWindowBaselineSlope || bs2 < (-1*fFullWindowBaselineSlope))
77  result = false;
78  }
79 
80  return result;
81 }
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Filter to remove bad pulses.
Definition: MBadPulse.hh:46
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
Definition: MBadPulse.cc:42
baseline data
number of pulses and time interval beetwen peaks in the same acquired window
const int & GetNumberOfPulses() const
diana event
Definition: QEvent.hh:46
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
basic pulse informations
bool fIsSaturatedLow
IsSaturatedLow.
bool fIsSaturatedHigh
IsSaturatedHigh.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...