Diana Software
QTimeNeighbour.cc
Go to the documentation of this file.
1 #include "QTimeNeighbour.hh"
2 #include "QReader.hh"
3 #include "QEvent.hh"
4 #include "QRawEvent.hh"
5 #include "QBool.hh"
6 
8 
9 void QTimeNeighbour::Init(const QReader& reader)
10 {
11  fWindowSizeMs = reader.GetDouble("WindowSizeMs",200);
12  fNeighbourDistanceMs = reader.GetDouble("NeighbourDistanceMs",100);
13  fNeighbourOffsetMs = reader.GetDouble("NeighbourOffsetNs",0);
14  fFiltVar = reader.GetString("MasterFilteringVariable","",false);
16 }
17 
19 {
20 
22  const QHeader& thisHeader = thisEvent.Get<QHeader>("DAQ","Header");
23  const QHeader& otherHeader = otherEvent.Get<QHeader>("DAQ","Header");
24 
25 
26  unsigned long long stime = thisHeader.GetTime().GetStartRunUnix();
27  unsigned long long sothertime = otherHeader.GetTime().GetStartRunUnix();
28 
29  //If different start runs then they are not neighbours (debatable)
30  if(stime != sothertime) {
31  info.fIsInWindow = false;
32  info.fIsNeighbour = false;
33  return info;
34  }
35 
36 
37 
38  long long time = thisHeader.GetTime().GetFromStartRunNs()+fOffsetNs;
39  long long othertime = otherHeader.GetTime().GetFromStartRunNs();
40 
41  //da mettere qui l'offset!
42  double diff = llabs(time-othertime);
43  diff /= 1.e06;
44  int channel = thisEvent.Get<QPulseInfo>("DAQ","PulseInfo").GetChannelId();
45  int ochannel = otherEvent.Get<QPulseInfo>("DAQ","PulseInfo").GetChannelId();
46 
47  info.fIsInWindow = false;
48  info.fIsNeighbour = false;
49 
50  if(diff < fWindowSizeMs) {
51  info.fIsInWindow = true;
52  if(diff < fNeighbourDistanceMs && channel != ochannel) info.fIsNeighbour = true;
53  }
54  return info;
55 
56 
57 }
58 
60  return (bool)thisEvent.GetByLabel<Diana::QBool>(fFiltVar);
61 }
62 
64 
double diff
Definition: CheckOFShape.C:173
const int channel
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
const std::string & GetString(const std::string &parname, const std::string &defVal, bool warnCfg=true) const
Get a string parameter from config file ( see GetDouble() )
Definition: QBaseModule.cc:297
double GetDouble(const std::string &parname, double defVal, bool warnCfg=true) const
Get a double parameter from config file.
Definition: QBaseModule.cc:184
diana event
Definition: QEvent.hh:46
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
Definition: QEvent.hh:135
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
Base class for diana event readers.
Definition: QReader.hh:50
long long fOffsetNs
bool GetWantsNeighbours(const QEvent &thisEvent)
double fNeighbourDistanceMs
double fNeighbourOffsetMs
void Init(const QReader &reader)
Initialzation.
QReaderNeighbour::NeighbourInfo GetNeighbourInfo(const QEvent &thisEvent, const QEvent &otherEvent)
Get the neighbour info between two events.
QEventLabel fFiltVar