19 using namespace Diana;
28 ev.Add<
QPulse>(
"Pulse").SetWrite(GetBool(
"SaveSamples",
true));
29 ev.Add<
QBool>(
"Decorrelated");
31 ev.Require<
QHeader>(
"DAQ",
"Header");
32 ev.Require<
QPulse>(
"DAQ",
"Pulse");
34 fUseOF = GetBool(
"UseOF",
false);
37 ev.Add<
QDouble>(
"OFMaximumPosition");
45 const int run = ev.
Get<
QHeader>(
"DAQ",
"Header").GetRun();
49 GlobalHandle<QInt> dataset(
"Dataset");
50 GlobalData().Get(
"",&dataset,
"");
51 GlobalHandle<QChannelCovariance> CovGetter(
"Covariance");
52 CovGetter.SetDataset(dataset.Get());
53 GlobalData().Get(
"NoiseCrossPowerSpectrum",&CovGetter,corrInput);
54 if(!CovGetter.IsValid()) {
56 CovGetter.SetRun(run);
57 GlobalData().Get(
"NoiseCrossPowerSpectrum",&CovGetter,corrInput);
60 fCovariance = CovGetter.Get();
65 if(fDecorrelators.find(
channel) == fDecorrelators.end()) {
67 bool pDeco=
false,pOF=
false,pOFMultiDim=
false;
71 std::string apOwner = GetString(
"AveragePulseOwner",
"AveragePulses",
false);
72 std::string relativesInput = GetString(
"RelativeChannelsInput",
"",
false);
73 std::vector<QVector> averagePulses;
74 std::vector<int> relatives;
76 GlobalHandle<QStdVector<int> > relativesHandle(
"RelativeChannels");
77 relativesHandle.SetChannel(
channel);
78 GlobalData().Get(
"User",&relativesHandle,relativesInput);
79 if(relativesHandle.IsValid() && !relativesHandle.Get().empty()) {
80 relatives = relativesHandle.Get();
82 if(!relatives.empty()) {
86 relatives.insert(relatives.begin(),
channel);
87 for(
size_t i =0; i < relatives.size(); i++) {
88 const int rchan = relatives[i];
90 if(apOwner ==
"Old") {
91 GlobalHandle<QVector> apHandle(
"Average");
92 apHandle.SetChannel(rchan);
93 GlobalData().Get(apOwner,&apHandle,apInput);
97 GlobalHandle<QInt> dataset(
"Dataset");
98 GlobalData().Get(
"",&dataset,
"");
99 apHandle.SetDataset(dataset.Get());
100 GlobalData().Get(apOwner,&apHandle,apInput);
103 averagePulses.push_back(
ap);
109 GlobalHandle<QStdVector<int> > sidesHandle(
"CorrelatedChannels");
110 sidesHandle.SetChannel(
channel);
111 GlobalData().Get(
"User",&sidesHandle,sideInput);
112 if(sidesHandle.IsValid()) {
118 if(GetBool(
"ConvertTomV",
false,
false)) {
120 GlobalData().Get(
"",&
rHandle,
"");
137 fDecorrelators[
channel].fDecorrelator = newdeco;
138 fDecorrelators[
channel].fUsed =
false;
140 Info(
"Channel %04d: Deco %d, OF1D %d, OFMD %d%s",
channel,pDeco,pOF,pOFMultiDim,msg.c_str());
150 ev.
Get<
QBool>(
"Decorrelated") =
false;
153 std::vector<const QVector*> sideSamples;
155 for(
size_t ich = 0; ich < sideChannels.size(); ich++) {
156 const QVector& sideSample = GetNeighbourSamples(sideChannels[ich],neighbours);
157 if(sideSample.Size() > 0) {
158 sideSamples.push_back(&sideSample);
161 if(sideSamples.size() != sideChannels.size()) {
162 decoPulse = pulse.GetSamples();
166 std::vector<const QVector*> samples;
167 samples.push_back(&pulse.GetSamples());
168 const std::vector<int>& channels = deco->
GetChannels();
169 for(
size_t ich = 1; ich < channels.size(); ich++) {
170 const QVector& sample = GetNeighbourSamples(channels[ich],neighbours);
171 if(sample.Size() > 0) {
172 samples.push_back(&sample);
175 if(samples.size() != channels.size()) {
176 decoPulse = pulse.GetSamples();
181 deco->
Filter(samples,sideSamples,decoPulse);
189 amp = decoPulse.GetMax();
190 maxpos = decoPulse.GetMaxIndex();
195 fDecorrelators[
channel].fUsed =
true;
196 ev.
Get<
QBool>(
"Decorrelated") =
true;
199 decoPulse = pulse.GetSamples();
210 std::map<int,ChannelInfo>::const_iterator iter = fDecorrelators.begin();
211 while(iter != fDecorrelators.end()) {
212 if(iter->second.fDecorrelator && !iter->second.fUsed) Warn(
"Channel %d was never decorrelated because the expected neighbours were not present",iter->first);
219 for(
size_t i = 0; i < neighbours.
Size(); i++) {
222 const QPulse& pulse = neighbours[i].Get<
QPulse>(
"DAQ",
"Pulse");
QRunDataHandle rHandle(753)
#define REGISTER_MODULE(clazz)
noise decorrelation using side pulses
const Diana::QVector & GetNeighbourSamples(const int channel, const Diana::QEventList &neighbours)
void Do(Diana::QEvent &ev, const Diana::QEventList &neighbours)
Do method.
global handle for average pulse
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
bool wrapped into a QObject
list of references to const QEvent (s)
size_t Size() const
number of QEvent (s)
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
class to perform multichannel complex decorrelation of single channel waveforms using also optimum fi...
void SetScale(double scale)
scale power spectra and filtered samples
double GetFilteredResolution() const
get filtered resolution
const std::vector< int > & GetChannels() const
get main channels
void SetSideChannels(const std::vector< int > &channels)
chose subset of channels to use for decorrelation
double GetOriginalResolution() const
get original resolution
virtual void Filter(const Diana::QVector &input, const std::vector< const Diana::QVector * > &sideInputs, Diana::QVector &output) const
decorrelate input QVector from this channel using sideInputs QVectors from sideChannels,...
const std::vector< int > & GetSideChannels() const
get subset of channels to use for decorrelation
Raw event: bolometer channel, trigger positions and types.
const QSampleInfo & GetMasterSample() const
Get MasterSample.
bool GetIsNoise() const
Get IsNoise.
const int & GetChannelId() const
Get ChannelId.
Raw event: sampled waveform.
void SetSamplesADC(const Diana::QVectorI &samples)
Set Samples acquired from ADC.
const Diana::QVector & GetSamples() const
Get Samples casted to double (QVector instead of QVectorI). Use this method in place of GetSamplesADC...
global handle for QRunData
Int_t GetSampleIndex() const
Get SampleIndex from the beginning of the waveform.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...