Diana Software
QCreateSidePulseByPulseSplitting.cc
Go to the documentation of this file.
2 #include "QBool.hh"
3 #include "QReader.hh"
4 #include "QEvent.hh"
5 #include "QHeader.hh"
6 #include "QPulse.hh"
7 #include "QPulseFiller.hh"
8 #include "QPulseInfo.hh"
9 #include "QSidePulses.hh"
10 #include "QEventAssembler.hh"
11 #include "QCachedEventList.hh"
12 #include "QGlobalDataManager.hh"
13 #include "QMessage.hh"
14 #include <sstream>
15 
17 
19 {
20 }
21 
23 {
24  std::vector<std::string> def;
25  def.push_back("DAQ@Pulse");
26  fPulseLabels = reader.GetVectorString("PulseLabels",def,false);
27  for(size_t p = 0; p < fPulseLabels.size(); p++) {
28  std::string owner = "CreateSidePulseByPulseSplitting_";
29  QEventLabel label(fPulseLabels[p]);
30  owner += label.owner;
31  eva.Add<QPulse>(owner.c_str(),label.name.c_str());
32  eva.Get<QPulse>(owner.c_str(),label.name.c_str()).SetIsJustAdded();
33  eva.GetEvent().RequireByLabel<QPulse>(label);
34  }
35 
36 }
37 
39 {
40  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
41  const QPulseInfo& pulseInfo = ev.Get<QPulseInfo>("DAQ","PulseInfo");
42 
43  // the side event has the same structure of the main event
44  QEventAssembler evaA,evaB;
45  evaA.Assign(ev);
46  evaB.Assign(ev);
47  // same structure but everything is not valid
48  evaB.Clear();
49 
50  // set the raw event
51 
52  // fill Master sample
53  QPulseInfo& sPulseInfo = evaB.Get<QPulseInfo>("DAQ","PulseInfo");
54  sPulseInfo.SetChannelId(pulseInfo.GetChannelId());
55 
56  QSampleInfo& sMaster = sPulseInfo.GetMasterSample();
57  sMaster = pulseInfo.GetMasterSample();
58  sMaster.SetIsSide();
59  sPulseInfo.Validate();
60 
61 
62  int pulseLength = 0;
63 
64  for(size_t p = 0; p < fPulseLabels.size(); p++) {
65  const QPulse& pulse = ev.GetByLabel<QPulse>(fPulseLabels[p].c_str());
66  const QVectorI & samples = pulse.GetSamplesADC();
67  size_t newSize = samples.Size()/2;
68  int offset = 0;
69  if(newSize % 2 != 0) {
70  newSize--;
71  offset = 1;
72  }
73  QVectorI samplesA(newSize);
74  for(size_t i = 0; i < newSize; i++) samplesA[i] = samples[i+offset];
75  QVectorI samplesB(newSize);
76  for(size_t i = 0; i < newSize; i++) samplesB[i] = samples[i+samples.Size()/2];
77 
78  QPulse pulseA,pulseB;
79  pulseA.SetSamplesADC(samplesA);
80  pulseB.SetSamplesADC(samplesB);
81  pulseA.Validate();
82  pulseB.Validate();
83  std::string owner = "CreateSidePulseByPulseSplitting_";
84  QEventLabel label(fPulseLabels[p]);
85  owner += label.owner;
86  evaA.Get<QPulse>(owner.c_str(),label.name.c_str()) = pulseA;
87  evaB.Get<QPulse>(owner.c_str(),label.name.c_str()) = pulseB;
88 
89  if(p == 0) pulseLength = samples.Size()/2;
90  }
91 
92  // fill header
93  QHeader& sHeader = evaB.Get<QHeader>("DAQ","Header");
94  sHeader = header;
95  Long64_t triggerTime = sHeader.GetTime().GetFromStartRunNs()+pulseLength;
96  sHeader.GetTime().SetFromStartRunNs(triggerTime);
97 
98 
99 
100  // Specify that this event has been generated in an event generator
101  evaB.Get<QBool>("Reader","GeneratedEvent")=true;
102 
103  // insert side event in the list
104  list.Push(evaB.GetEvent());
105  // insert this event at the end of the list
106  list.Push(evaA.GetEvent());
107 }
108 
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
std::vector< std::string > GetVectorString(const std::string &parname, std::vector< std::string > defVal, bool warnCfg=true) const
Get a vector<string> parameter from config file ( see GetVectorDouble() )
Definition: QBaseModule.cc:313
bool wrapped into a QObject
Definition: QBool.hh:17
void Push(const QEvent &obj)
void Init(const QReader &reader, QEventAssembler &eva)
void FillList(const QEvent &ev, QCachedEventList &list)
Visitor class of QEvent that provides full handling of QEvent.
QEvent & GetEvent()
Get the QEvent.
void Get(const char *owner, WriteHandle< Q > &handle)
Get QObject from the event in write mode. This method has to be called in the event loop,...
void Assign(const QEvent &ev)
copies the underlying QEvent (calls QEvent::operator=)
void Add(const char *owner, WriteHandle< Q > &handle)
Add QObject to the event. This method has to be called before the event loop, e.g....
label for QObject in the QEvent
Definition: QEventLabel.hh:23
std::string owner
owner of the QObject
Definition: QEventLabel.hh:60
std::string name
name of the QObject
Definition: QEventLabel.hh:62
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 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
const QSampleInfo & GetMasterSample() const
Get MasterSample.
Definition: QPulseInfo.hh:26
void SetChannelId(const int &channelId)
Set ChannelId.
Definition: QPulseInfo.hh:24
Raw event: sampled waveform.
Definition: QPulse.hh:22
const Diana::QVectorI & GetSamplesADC() const
Get Samples acquired from ADC. Beware that fSamplesADC may by empty if fFiller is valid
Definition: QPulse.cc:69
void SetSamplesADC(const Diana::QVectorI &samples)
Set Samples acquired from ADC.
Definition: QPulse.cc:74
Base class for diana event readers.
Definition: QReader.hh:50
contains information on flagged samples
Definition: QSampleInfo.hh:24
void SetIsSide()
Set event type to Side.
Definition: QSampleInfo.hh:71
Interface for raw daq vectors in Diana.
Definition: QVectorI.hh:19