17 using namespace Diana;
22 std::string window = GetString(
"WindowType",
"welch");
25 Warn(
"Window type not defined, using rectangular window");
29 Info(
"Window type: %d (%s)", fWindowType,window.c_str());
32 fCoherentGain = GetInt(
"WindowCoherentGain",2);
33 else fCoherentGain = 2;
34 fValidityKind = GetString(
"ValidityKind",
"dataset",
false);
35 if(fValidityKind !=
"dataset" && fValidityKind !=
"run") {
36 Panic(
"ValidityKind must be set to dataset or run");
41 fPulseLabel = GetString(
"PulseLabel",
"DAQ@Pulse",
false);
48 fChannelInfos.clear();
55 if(neighbours.
Size() != 1)
return;
56 const QEvent& neigh = neighbours[0];
62 const int chanB = piB.GetChannelId();
63 if(chan != chanB)
return;
66 const int size = samples.Size();
68 if(size != (
int)samplesB.Size())
return;
74 GlobalData().Get(
"",&
rHandle,
"");
80 Long64_t lastSampleB = size-piB.GetMasterSample().GetSampleIndex()-1;
81 lastSampleB += hdrB.
GetTime().GetFromStartRunNs()/samplPeriod;
83 if(firstSample-lastSampleB != 1) {
89 if (run != fCurrentRun) {
91 fSRuns.push_back(fCurrentRun);
94 if(fChannelInfos.find(chan) == fChannelInfos.end()) {
99 chInfo.
fPower.Resize(size);
102 chInfo.
fPower.Initialize(0);
104 chInfo.
fTransformer->SetWindowType(fWindowType, fCoherentGain);
109 QVectorC TransformedPulseB(size);
110 QVectorC TransformedPulse(size);
113 Error(
"QFFTRealComplex::TransformToFreq: pulse B");
116 TransformedPulseB[0].SetRe(0);
117 TransformedPulseB[0].SetIm(0);
120 Error(
"QFFTRealComplex::TransformToFreq: pulse ");
123 TransformedPulse[0].SetRe(0);
124 TransformedPulse[0].SetIm(0);
127 chInfo.
fPowerB += TransformedPulseB.GetModulusSquare();
128 chInfo.
fPower += TransformedPulse.GetModulusSquare();
129 chInfo.
fCovariance += TransformedPulse.Mult(TransformedPulseB.Conj());
136 std::map<int,ChannelInfo>::iterator iter = fChannelInfos.begin();
137 while (iter != fChannelInfos.end() ) {
149 QVector fAvgPower(chanInfo.
fPower.Size());
150 for(
size_t f = 0; f < chanInfo.
fPower.Size(); f++) {
156 coherence[0].Set(0,0);
162 GlobalHandle<QAverageVectorC> handle(
"Coherence");
164 if(fValidityKind==
"dataset"){
165 GlobalHandle<QInt> dHandle(
"Dataset");
166 GlobalData().Get(
"",&dHandle,
"");
167 int dataset = dHandle.Get();
168 handle.SetDataset(dataset);
170 else if (fValidityKind==
"run"){
171 if (fSRuns.size()==1){
172 handle.SetRun(fSRuns[0]);
174 else Error(
"ValidityKind set to run is not permitted when reading multiple runs.");
176 else Error(
"ValidityKind can be set only to run or dataset. Check cfg.");
178 handle.Set(coherence);
179 GlobalData().Set(&handle,fOutput);
187 const size_t size = samples.Size();
188 QVector zeroMeanPulse(size), meanPulse(size);
189 double mean = samples.Sum(size)/size;
190 meanPulse.Initialize(mean);
191 zeroMeanPulse = samples;
192 zeroMeanPulse -= meanPulse;
193 return transformer->TransformToFreq(zeroMeanPulse, out);
QRunDataHandle rHandle(753)
QChannelRunData chanRunData
#define REGISTER_MODULE(clazz)
Diana::QVectorC fCovariance
Diana::QRealComplexFFT * fTransformer
compute correlation between different frequencies
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.
int Transform(Diana::QRealComplexFFT *transformer, const Diana::QVector &in, Diana::QVectorC &out)
void SetNumEvents(int nEvents)
Set the number of events in the average.
void SetSourceRuns(const std::vector< int > &sourceRuns)
Set the list of source runs.
basic channel and run based info. Used in the QRunData object.
double fSamplingFrequency
sampling frequency in Hz
list of references to const QEvent (s)
size_t Size() const
number of QEvent (s)
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
void RequireByLabel(const QEventLabel &label) const
notify the QEvent that we need a QObject, if not found an exception is thrown
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
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
static WindowType StrToWindowType(const std::string &winName)
Convert string to window type.
Raw event: bolometer channel, trigger positions and types.
const QSampleInfo & GetMasterSample() const
Get MasterSample.
const int & GetChannelId() const
Get ChannelId.
Raw event: sampled waveform.
Wrapper for a specific QRealComplexFFT algorithm class.
global handle for QRunData
const QChannelRunData & GetChannelRunData(const int channel) const
get channel based run data quantities
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...