9 return lhs.second > rhs.second;
32 fCovariance[f].Resize(channels.size(),channels.size());
35 for(
size_t i = 0; i < channels.size(); i++) {
38 fNevents.Resize(channels.size(),channels.size());
46 std::stringstream msg;
47 msg<<
"Size of given QVectorC, "
48 <<cov.Size()<<
", is wrong; expects" <<
fCovariance.size();
49 err.SetDescription(__FILE__,__LINE__,msg.str());
71 std::map<int,int>::const_iterator iter =
fChannels.begin();
73 for(
size_t i = 0; iter !=
fChannels.end(); i++) {
123 for(
size_t i = 0; i < channels.size(); i++) {
124 for(
size_t j = 0; j < channels.size(); j++) {
125 const int chanI = channels[i];
126 const int chanJ = channels[j];
139 Diana::QVectorC covII, covJJ, covIJ;
144 Diana::QVectorC res(covII.Size());
147 for(
size_t f = 1; f < covII.Size(); f++) {
148 const double div = sqrt(fabs(covII[f].
Re()*covJJ[f].
Re()));
149 res[f] = covIJ[f]/div;
159 double num = 0., den = 0.;
160 if(fmin <= 0 || fmin >= (
int)rho2.Size()) fmin = 1;
161 if(fmax < 0 || fmax >= (
int)rho2.Size()) fmax = -1+rho2.Size();
163 for(
int f = fmin; f < fmax; f++) {
164 num += rho2[f]*fabs(covII[f].
Re());
165 den += fabs(covII[f].
Re());
168 if(den != 0) res = sqrt(num/den);
174 std::vector<std::pair<int,double> > pairs;
176 for(
size_t i = 0; i < ch.size(); i++) {
180 std::pair<int,double> p(chJ,corr);
185 std::vector<int> res;
186 for(
size_t i = 0; i < pairs.size(); i++) {
187 res.push_back(pairs[i].first);
197 o<<
"# of chans: "<<ch.size()<<std::endl;
200 if(ch.empty())
return;
203 o<<
"channel "<<ch[0];
205 o<<
": Covariance[f=1] = "<<
fCovariance[1](ch[0],ch[0]);
206 o<<
", Nevents = "<<
fNevents(ch[0],ch[0]);
209 o<<
"first 2 chans ("<<ch[0]<<
","<<ch[1]<<
")";
211 o<<
": Covariance[f=1] = "<<
fCovariance[1](ch[0],ch[1]);
212 o<<
", Nevents = "<<
fNevents(ch[0],ch[0]);
220 std::map<int,int>::const_iterator chIIter =
fChannels.begin();
221 std::map<int,int>::const_iterator chKIter =
fChannels.begin();
223 o<<
"\t"<<chKIter->first<<
" ";
229 o<<chIIter->first<<
"\t";
230 std::map<int,int>::const_iterator chJIter =
fChannels.begin();
245 std::map<int,int>::const_iterator chIIter =
fChannels.find(chI);
246 std::map<int,int>::const_iterator chJIter =
fChannels.find(chJ);
249 std::stringstream msg;
250 msg<<
"Given channel "<<chI<<
" not allowed";
251 err.SetDescription(__FILE__,__LINE__,msg.str());
257 std::stringstream msg;
258 msg<<
"Given channel "<<chJ<<
" not allowed";
259 err.SetDescription(__FILE__,__LINE__,msg.str());
QObjectImp(QChannelCovariance)
bool CompareCorrelations(const std::pair< int, double > &lhs, const std::pair< int, double > &rhs)
double Re(const Diana::QComplex &z)
Function to get the real part.
Complex covariance matrix of an array of bolometers.
std::map< int, int > fChannels
map real channel number into channel index
void SetNEvents(int chI, int chJ, int nev)
set number of events of the couple I,J
void DumpMeanCorrelationMatrix(std::ostream &o, const int fmin=-1, const int fmax=-1) const
dump mean correlation matrix
void Dump(std::ostream &o) const
dump summary of content
double GetMeanCorrelation(int chI, int chJ, int fmin=-1, int fmax=-1) const
get mean correlation between frequency indices fmin and fmax of the couple (chI,chJ)
Diana::QVectorC GetCorrelation(int chI, int chJ) const
get correlation
void SetChannels(const std::vector< int > &channels)
set channels
QChannelCovariance GetSubMatrix(const std::vector< int > &channels) const
Get sub matrix of channels.
std::vector< int > GetChannels() const
get channels
void Clear()
clear members
QChannelCovariance Inverse() const
get inverse matrix
void SetNFreq(size_t nfreq)
set number of frequencies
Diana::QVectorC GetCovarianceByIndex(int i, int j) const
int GetNEvents(int chI, int chJ) const
get number of events of the couple I,J
Diana::QVectorC GetCovariance(int chI, int chJ) const
get covariance between channel I and J
Diana::QMatrix fNevents
number of events used to build each element of fCovariance
void Channels2Indices(const int chI, const int chJ, int &i, int &j) const
convert channel numbers to indices
std::vector< Diana::QMatrixC > fCovariance
std::vector< int > GetChannelsByCorrelation(int chI, int fmin=-1, int fmax=-1) const
get mean correlation between frequency indices fmin and fmax of the couple (chI,chJ)
void SetCovariance(int chI, int chJ, const Diana::QVectorC &cov)
set covariance (size equal to nfreq) of channels I and J
error class with error type and description