22 , _needToRecalculate(true)
33 , _dFraction_by_dN(1, 1)
34 , _dFractionSum_by_dFraction(1, 1)
35 , _dIntegral_by_dN(1, 1)
40 : _myList(other._myList)
41 , _Nevents(other._Nevents)
43 , _needToRecalculate(true)
44 , _sum_x(other._sum_x)
45 , _sum_xy(other._sum_xy)
46 , _cov2N(other._cov2N)
47 , _corr2N(other._corr2N)
50 , _fractionCov(other._fractionCov)
51 , _fractionSumCov(other._fractionSumCov)
52 , _integralCov(other._integralCov)
53 , _dN_by_d2N(other._dN_by_d2N)
54 , _dFraction_by_dN(other._dFraction_by_dN)
55 , _dFractionSum_by_dFraction(other._dFractionSum_by_dFraction)
56 , _dIntegral_by_dN(other._dIntegral_by_dN)
62 , _Nevents(other._Nevents)
64 , _needToRecalculate(true)
65 , _sum_x(other._sum_x)
66 , _sum_xy(other._sum_xy)
67 , _cov2N(other._cov2N)
68 , _corr2N(other._corr2N)
71 , _fractionCov(other._fractionCov)
72 , _fractionSumCov(other._fractionSumCov)
73 , _integralCov(other._integralCov)
74 , _dN_by_d2N(other._dN_by_d2N)
75 , _dFraction_by_dN(other._dFraction_by_dN)
76 , _dFractionSum_by_dFraction(other._dFractionSum_by_dFraction)
77 , _dIntegral_by_dN(other._dIntegral_by_dN)
93 for(
unsigned int i=0; i < this->
size(); i++){
101 cout <<
"WARNING in FitAmpPairCovariance::add: " 102 <<
"trying to add incompatible FitAmpPairCovariances" 103 <<
"\n\t _myListPtr = " <<
_myList <<
" other's: " << other.
_myList 108 cout <<
"WARNING in FitAmpPairCovariance::add: " 109 <<
"trying to add incompatible FitAmpPairCovariances" 127 cout <<
"FitAmpPairCovariance::resize()" 128 <<
" resizing from " <<
size()
130 <<
" with maxSize() = " <<
maxSize()
139 cout <<
"FitAmpPairCovariance::resize size() = " <<
size()
140 <<
" that's too big! won't do it!" << endl;
164 cout <<
"FitAmpPairCovariance::resize() to " 165 <<
size() <<
" done." << endl;
180 if(dbThis) cout <<
"FitAmpPairCovariance::addLastEventFromList() size() " 182 if(!
resize())
return false;
186 if(dbThis)cout <<
"FitAmpPairCovariance::addLastEventFromList()" 187 <<
" adding event to cov matrix." << endl;
191 if(dbThis) cout <<
" i= " << i << endl;
214 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 215 <<
" making dN_by_d2N" << endl;
218 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 219 <<
" making dFraction_by_dN" << endl;
222 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 223 <<
" making dFractionSum_by_dFraction" << endl;
226 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 227 <<
" making dIntegral_by_dN" << endl;
230 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 231 <<
" making 2NCovariance" << endl;
233 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 234 <<
" making NCovariance" << endl;
236 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 237 <<
" making FractionCovariance" << endl;
239 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 240 <<
" making FractionSumCovariance" << endl;
242 if(dbThis) cout <<
"FitAmpPairCovariance::calculateAll" 243 <<
" making IntegralCovariance" << endl;
253 if(dbThis) cout <<
"FitAmpPairCovariance::make_dN_by_d2N() called" << endl;
268 complex<double> fpv =
280 if(dbThis) cout <<
"FitAmpPairCovariance::make_dFraction_by_dN() called" 298 double integ2 = integ*integ;
311 if(dbThis) cout <<
"FitAmpPairCovariance::make_dIntegral_by_dN() called" 328 if(dbThis) cout <<
"FitAmpPairCovariance::make_dFractionSum_by_dFraction()" 329 <<
" called" << endl;
351 if(dbThis) cout <<
"making 2N covariance" << endl;
365 _cov2N(i, j) = (mean_xy(i,j) - mean_x(i,0)*mean_x(j,0));
375 _cov2N(i, j) *= dN*dN/sfden;
389 cout <<
"After " <<
_Nevents <<
"events" << endl;
390 cout <<
"mean matrix" << endl;
392 cout <<
"Covariance Matrix 2N" << endl;
394 cout <<
"Correlation Matrix 2N" << endl;
408 TMatrixT<float> dN_by_d2N_Transpose(2*
size(),
size());
411 cout <<
"FitAmpPairCovariance::makeNCovariance()" 415 cout <<
"and its transpose:" << endl;
416 dN_by_d2N_Transpose.Print();
422 if(
_cov(i, i) <= 0)
continue;
432 cout <<
"After " <<
_Nevents <<
"events" << endl;
433 cout <<
"Covariance Matrix N" << endl;
435 cout <<
"Correlation Matrix N" << endl;
444 TMatrixT<float> dFraction_by_dN_Transpose(
size(),
size());
448 dFraction_by_dN_Transpose);
451 cout <<
"Correlation Matrix Fractions" << endl;
460 TMatrixT<float> dFractionSum_by_dFraction_Transpose(
size(), 1);
465 dFractionSum_by_dFraction_Transpose);
468 cout <<
"After " <<
_Nevents <<
"events" << endl;
469 cout <<
"Covariance Matrix for FractionSum" << endl;
479 TMatrixT<float> dIntegral_by_dN_Transpose(
size(), 1);
484 * dIntegral_by_dN_Transpose);
487 cout <<
"Correlation Matrix Integral" << endl;
497 if(i < 0 || i >=
_fractionCov.GetNcols())
return -9999.0;
498 if(i < 0 || i >=
_fractionCov.GetNrows())
return -9999.0;
504 cout <<
"ERROR in FitAmpPairCovariance::getFractionError" 505 <<
" variance is " << V <<
" which is < 0." 506 <<
" will return -9999." 521 cout <<
"ERROR in FitAmpPairCovariance::getFractionSumError" 522 <<
" variance is " << V <<
" which is < 0." 540 cout <<
"ERROR in FitAmpPairCovariance::getFractionError" 541 <<
" variance is " << V <<
" which is < 0." 542 <<
" will return -9999." 551 static int numWarnings=0;
552 const static int maxWarnings=10;
554 cout <<
" FitAmpPairCovariance::isValid() with: " 555 <<
size() <<
" == " <<
_sum_x.GetNcols() <<
" ? " << endl;
558 if(numWarnings < 10){
559 cout <<
"WARNING: FitAmpPairCovariance::isValid returns false" 560 <<
" because size (" <<
size() <<
") is too big" 562 cout <<
" Will print this " << maxWarnings
563 <<
" times (" << numWarnings <<
")." << endl;
568 if(
size() <= 0)
return false;
577 if(0 != this->
size()){
614 mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
619 int zeroForSuccess = 0;
620 zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
621 zeroForSuccess |= mkdir( (
dirName(asSubdirOf) ).c_str(), mode );
622 return (0 == zeroForSuccess);
626 return asSubdirOf +
"/" +
"FitAmpPairCovariance";
629 return dirName(asSubdirOf) +
"/" +
"matrix_x.txt";
632 return dirName(asSubdirOf) +
"/" +
"matrix_xy.txt";
638 cout <<
"WARNING FitAmpPairCovariance::save(" << inDirectory <<
")" 639 <<
" I'm not valid, I won't save anything." << endl;
643 cout <<
"saving FitAmpPairCovariance in " << inDirectory <<
"." << endl;
656 cout <<
"WARNING FitAmpPairCovariance::save_sum_x(" << inDirectory <<
")" 657 <<
" I'm not valid, I won't save anything." << endl;
663 cout <<
"about to save: ";
668 os << setprecision(20) <<
realName(i) <<
" " 671 os << setprecision(20) <<
imagName(i) <<
" " 681 cout <<
"WARNING FitAmpPairCovariance::save_sum_xy(" << inDirectory <<
")" 682 <<
" I'm not valid, I won't save anything." << endl;
688 cout <<
"about to save: ";
712 if(!
resize())
return false;
723 if(is.bad())
return false;
725 if(dbThis) cout <<
"opened file: " 730 std::map<string, double> map_x;
734 if(dbThis) cout <<
"reading " << counter <<
". line" << endl;
738 cout <<
"just read " << st1 <<
" " <<
_Nevents << endl;
744 cout <<
"just read " << st1 <<
" " << val << endl;
750 if(dbThis)cout <<
"retrieve_sum_x, filling _sum_x for size " 752 for(
unsigned int i=0; i <
size(); i++){
756 cout <<
"Tried to retrieve from map entry for " <<
realName(i)
757 <<
" \n got: " << map_x[
realName(i)] << endl;
762 cout <<
" did so, look at what I got for sum_x" << endl;
772 if(is.bad())
return false;
773 if(dbThis) cout <<
"opened file: " 776 std::string st1, st2;
778 map< string, map<string, double> > map_xy;
785 is >> st1 >> st2 >> val;
786 map_xy[st1][st2] = val;
787 if(dbThis) cout <<
"just read " << counter <<
". line: " 788 << st1 <<
" " << st2 <<
" " << val << endl;
794 for(
unsigned int i=0; i <
size(); i++){
795 for(
unsigned int j=0; j <
size(); j++){
803 cout <<
"got _sum_xy: " << endl;
816 return (returnVal += other);
int indexImag(int listPosition) const
std::string realName(int listPosition) const
std::complex< double > fitParValue() const
TMatrixTSym< float > _fractionCov
virtual ~FitAmpPairCovariance()
TMatrixTSym< float > _cov2N
std::string imagName(int listPosition) const
double getFractionSumError()
bool makeDirectory(const std::string &asSubdirOf=".") const
std::string dirName(const std::string &asSubdirOf=".") const
std::complex< double > lastEntry() const
TMatrixTSym< T > makeTMatrixTSym(const TMatrixT< T > &m)
bool makeIntegralCovariance()
bool retrieve_sum_xy(const std::string &inDirectory)
static unsigned int _maxSize
double getIntegralError()
int listPositionFromIndex(int idx) const
int indexReal(int listPosition) const
double getIntegralVariance()
bool retrieve_sum_x(const std::string &inDirectory)
bool isCompatibleWith(const FitAmpPairList &other) const
bool makeFractionCovariance()
const FitAmpPairList * _myList
bool makeFractionSumCovariance()
TMatrixTSym< float > _fractionSumCov
bool make_dFractionSum_by_dFraction()
TMatrixT< float > _dFractionSum_by_dFraction
FitAmpPairCovariance(const FitAmpPairList *myList)
virtual double integral() const
unsigned int maxSize() const
TMatrixTSym< float > _sum_xy
unsigned int size() const
FitAmpPairCovariance & operator+=(const FitAmpPairCovariance &other)
FitAmpPairCovariance operator+(const FitAmpPairCovariance &other) const
TMatrixT< float > _dFraction_by_dN
bool retrieve(const std::string &fromDirectory=".")
unsigned int size() const
bool add(const FitAmpPairCovariance &other)
double getFractionVariance(int i)
std::string matrix_xy_fname(const std::string &asSubdirOf=".") const
TMatrixTSym< float > _corr2N
TMatrixT< float > _dN_by_d2N
bool make_dIntegral_by_dN()
TMatrixTSym< float > _integralCov
bool save_sum_xy(const std::string &inDirectory) const
double getFractionError(int i)
virtual int numEvents() const
TMatrixT< float > _dIntegral_by_dN
bool save_sum_x(const std::string &inDirectory) const
bool isCompatibleWith(const FitAmpPairCovariance &other) const
TMatrixTSym< float > _cov
bool addLastEventFromList()
double getFractionSumVariance()
bool make_dFraction_by_dN()
const std::string & name() const
bool save(const std::string &asSubdirOf=".") const
TMatrixTSym< float > _corr
std::string matrix_x_fname(const std::string &asSubdirOf=".") const