Diana Software
MSideCoincidence.cc
Go to the documentation of this file.
1 #include "MSideCoincidence.hh"
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QRawEvent.hh"
5 #include "QBaseType.hh"
6 #include "QCoincidenceData.hh"
7 #include "QOFData.hh"
8 #include "QRunDataHandle.hh"
9 #include "QDetChannelCollectionHandle.hh"
10 #include <cmath>
11 
13 
14 using std::vector;
15 using std::string;
16 using namespace Diana;
17 
19 {
20  fNSigma = GetDouble("NumberOfSigma",3,false);
21  fSideAmplitudeOwner = GetString("SideAmplitudeOwner","SideAmplitude",false);
22  fMainEnergyOwner = GetString("MainEnergyOwner","ApplyCalibration",false);
23  fSideEnergyOwner = GetString("SideEnergyOwner","ApplyCalibration_Sync",false);
24 
25  ev.Add<QCoincidenceData>("CoincidenceData");
26  ev.Add<QDouble>("TotalEnergy");
27  fThisRun = -1;
28 
29  ev.Require<QHeader>("DAQ","Header");
30  ev.Require<QPulseInfo>("DAQ","PulseInfo");
31 
32  ev.RequireByLabel<QDouble>(QEventLabel(fSideAmplitudeOwner.c_str(),"Amplitude"));
33  ev.RequireByLabel<QDouble>(QEventLabel(fSideEnergyOwner.c_str(),"Energy"));
34  ev.RequireByLabel<QDouble>(QEventLabel(fMainEnergyOwner.c_str(),"Energy"));
35  ev.RequireByLabel<QDouble>(QEventLabel(fSideAmplitudeOwner.c_str(),"NSigma"));
36 }
37 
38 void MSideCoincidence::Do(QEvent& ev, const QEventList& neighbours)
39 {
40  const QHeader& hdr = ev.Get<QHeader>("DAQ","Header");
41  const int run = hdr.GetRun();
42 
43  const QPulseInfo& pi = ev.Get<QPulseInfo>("DAQ","PulseInfo");
44  const int chan = pi.GetChannelId();
45 
46  if(fThisRun != run) {
47  fThisRun = run;
48  QRunDataHandle rHandle(fThisRun);
49  GlobalData().Get("DAQ",&rHandle,"");
50  fRunData = rHandle.Get();
51  }
52 
53  // position of main event
54 
55  int tower = -1;
56  int floor = -1;
57  int position = -1;
58 
59  QDetChannelCollectionHandle dccHandle;
60  dccHandle.SetRun(run);
61  GlobalData().Get("",&dccHandle,"");
62 
63  tower = dccHandle.Get().Get(chan).fTd.fTdTower;
64  floor = dccHandle.Get().Get(chan).fTd.fTdFloor;
65  position = dccHandle.Get().Get(chan).fTd.fTdPos;
66 
67  QCoincidenceData& coincData = ev.Get<QCoincidenceData>("CoincidenceData");
68  double tot_ene = ev.GetByLabel<QDouble>(QEventLabel(fMainEnergyOwner.c_str(),"Energy"));
69 
70  coincData.fMultiplicity = 1;
71  coincData.fCoincidentChannels.clear();
72  // const double time = GetTime(ev);
73  // ev.Get<QDouble>("Time") = time;
74 
75  // start loop on neighbours (side)
76 
77  for(size_t i = 0; i < neighbours.Size(); i++) {
78  const QDouble& n_energy = neighbours[i].GetByLabel<QDouble>(QEventLabel(fSideEnergyOwner.c_str(),"Energy"));
79  const QDouble& n_nsigma = neighbours[i].GetByLabel<QDouble>(QEventLabel(fSideAmplitudeOwner.c_str(),"NSigma"));
80 
81  int n_tower = -1;
82  int n_floor = -1;
83  int n_position = -1;
84 
85  if (n_nsigma>fNSigma)
86  {
87  const QPulseInfo& n_pi = neighbours[i].Get<QPulseInfo>("","PulseInfo");
88  // const double n_time = GetTime(neighbours[i]);
89  const int n_channel = n_pi.GetChannelId();
90 
91  // const double deltaT = n_time - time;
92 
93  n_tower = dccHandle.Get().Get(n_channel).fTd.fTdTower;
94  n_floor = dccHandle.Get().Get(n_channel).fTd.fTdFloor;
95  n_position = dccHandle.Get().Get(n_channel).fTd.fTdPos;
96 
98  cc.fChannelId = n_channel;
99  // cc.fDeltaT = deltaT;
100  cc.fEnergy = n_energy;
101 
102  cc.fDeltaTower = n_tower-tower;
103  cc.fDeltaFloor = n_floor-floor;
104  cc.fDeltaPosition = n_position-position;
105 
106  cc.fEventNumber = neighbours[i].Get<QHeader>("DAQ","Header").GetEventNumber();
107  coincData.fCoincidentChannels.push_back(cc);
108 
109  coincData.fMultiplicity++;
110  tot_ene += n_energy;
111  }
112  }
113  ev.Get<QDouble>("TotalEnergy") = tot_ene;
114 }
115 
117 {
118  // called at the end of the event loop
119 
120 }
121 
123 {
124  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
125  const QPulseInfo& pi = ev.Get<QPulseInfo>("DAQ","PulseInfo");
126  double time = double(header.GetTime().GetFromStartRunNs())/1e09;
127 
128  const QOFData& of = ev.Get<QOFData>("COF","OFData");
129  double samplingFrequency = fRunData.GetChannelRunData(pi.GetChannelId()).fSamplingFrequency;
130  time += of.GetDelay()/1000 - double(pi.GetMasterSample().GetSampleIndex())/samplingFrequency;
131 
132  return time;
133 }
QOptimumFilter of(ap, an,-1, false)
QRunDataHandle rHandle(753)
chanRunData fSamplingFrequency
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Save as coincidence data the information on side pulses calulated by the module SideAmplitude.
void Init(Diana::QEvent &ev)
Init method.
void Do(Diana::QEvent &ev, const Diana::QEventList &neighbours)
Do method. Declare and implement only one of the two versions.
double GetTime(const Diana::QEvent &ev)
Get time of the event.
void Done()
Done method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
Definition: QBaseType.hh:17
coincidence data
std::vector< QCoincidentChannel > fCoincidentChannels
data of coincident channel
label for QObject in the QEvent
Definition: QEventLabel.hh:23
list of references to const QEvent (s)
Definition: QEventList.hh:21
size_t Size() const
number of QEvent (s)
Definition: QEventList.hh:36
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 RequireByLabel(const QEventLabel &label) const
notify the QEvent that we need a QObject, if not found an exception is thrown
Definition: QEvent.hh:242
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
Definition: QEvent.hh:232
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Definition: QEvent.hh:193
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
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
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...