Diana Software
MSampleInfoFilter.cc
Go to the documentation of this file.
1 #include "MSampleInfoFilter.hh"
2 
3 #include "QEvent.hh"
4 #include "QSampleInfo.hh"
5 #include "QRawEvent.hh"
6 #include "QChannelRunData.hh"
7 #include "QRunDataHandle.hh"
8 
9 
11 
12 
13 void MSampleInfoFilter::GetCuts(const Diana::QEvent& ev)
14 {
15  // Get parameters from cfg
16  fType = GetString("Type","Noise");
17  fKeepType = GetBool("KeepType",true);
18  fTimeThreshold = GetDouble("PulserTimeThreshold", 0.04);
19  ev.Require<QPulseInfo>("DAQ","PulseInfo");
20  ev.Require<QHeader>("DAQ","Header");
21  return;
22 }
23 
24 bool MSampleInfoFilter::Filter(const Diana::QEvent& ev)
25 {
26  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
27  const QPulseInfo& pulseInfo = ev.Get<QPulseInfo>("DAQ","PulseInfo");
28  const int chan = pulseInfo.GetChannelId();
29  QRunDataHandle rHandle(header.GetRun());
30  GlobalData().Get("",&rHandle,"");
31  const QRunData& runData = rHandle.Get();
32  const QChannelRunData& channelRunData = runData.GetChannelRunData(chan);
33 
34  double sampFreq = channelRunData.fSamplingFrequency;
35 
36  // Within this threshold, pulser triggers and corresponding derivative triggers are considered as one
37  double sampleThreshold = fTimeThreshold * sampFreq;
38 
39  const std::vector<QSampleInfo>& samplesInfo = pulseInfo.GetSamplesInfo();
40  if(!samplesInfo.empty()) {
41  std::vector<QSampleInfo>::const_iterator sampleInfo = samplesInfo.begin();
42  while(sampleInfo != samplesInfo.end()) {
43  const int trigpos = pulseInfo.GetMasterSample().GetSampleIndex();
44  bool same = (abs(trigpos-(int)sampleInfo->GetSampleIndex())<sampleThreshold);
45  if(fKeepType){
46  if(fType == "Noise" && !sampleInfo->GetIsNoise()) return false;
47  else if(fType == "Signal" && !sampleInfo->GetIsSignal() && same) return false;
48  else if(fType == "Heater" && !sampleInfo->GetIsPulser() && same) return false;
49  else if(fType == "LED" && !sampleInfo->GetIsLED() && same) return false;
50  }else{
51  if(fType == "Noise" && sampleInfo->GetIsNoise()) return false;
52  else if(fType == "Signal" && sampleInfo->GetIsSignal()) return false;
53  else if(fType == "Heater" && sampleInfo->GetIsPulser()) return false;
54  else if(fType == "LED" && sampleInfo->GetIsLED()) return false;
55  }
56  sampleInfo++;
57  }
58  }
59  return true;
60 }
QRunDataHandle rHandle(753)
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Diana::QVector abs(const Diana::QVector &v)
Definition: QVector.cc:811
discards events with secondary triggers different to a specified type.
bool Filter(const Diana::QEvent &ev)
return true if ev passes the cuts
bool fKeepType
If True it keeps only trigger of certain type, if false removes all trigger of that type.
double fTimeThreshold
Time threshold within which a pulser flag and the corresponding trigger are considered as one.
basic channel and run based info. Used in the QRunData object.
double fSamplingFrequency
sampling frequency in Hz
diana event
Definition: QEvent.hh:46
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
int GetRun() const
destructor
Definition: QHeader.hh:22
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
const int & GetChannelId() const
Get ChannelId.
Definition: QPulseInfo.hh:22
global handle for QRunData
Basic run based info.
Definition: QRunData.hh:20
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
Definition: QRunData.cc:339
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...