1 #include "SystematicCovariance.hxx" 5 SystematicCovariance::SystematicCovariance(){
11 SystematicCovariance::~SystematicCovariance() {
21 std::cout <<
" constructing things! " << std::endl;
23 int nTotalParameters = 0;
27 std::cout <<
"nVarSys = " << nVarSys << std::endl;
28 for (
int it = 0; it < nVarSys; it++)
29 nTotalParameters += varArr[it]->GetNParameters();
33 for (
int it = 0; it < nSys; it++)
34 nTotalParameters += weightArr[it]->GetNParameters();
38 for (
int it = 0; it < nSys; it++)
39 nTotalParameters += weightArr[it]->GetNParameters();
42 std::cout <<
" Total parameters: " << nTotalParameters << std::endl;
47 for (
int it = 0; it < nVarSys; it++)
48 FillLinks(varArr[it]);
52 for (
int it = 0; it < nSys; it++)
53 FillLinks(weightArr[it]);
57 for (
int it = 0; it < nSys; it++)
58 FillLinks(weightArr[it]);
63 for(
unsigned int j=0; j<
covlinks[i].inputindex.size(); j++)
64 for(
unsigned int k=0; k<
covlinks[i].inputindex.size(); k++)
67 for(
unsigned int i=0; i<
links.size(); i++)
68 if(
links[i].inputcov == -1)
69 (*_covarianceMatrix)(
links[i].covarianceindex,
links[i].covarianceindex) = 1;
76 bool SystematicCovariance::IsInList(std::string name, std::vector< std::string > list,
int& index){
80 for (std::vector< std::string >::iterator it = list.begin(); it != list.end(); it++, index++)
90 std::cout <<
"filling links" << std::endl;
92 TString parname = syst->
GetName();
95 sprintf(paramcov,
"psycheSystematics.%s.CovFile",parname.Data());
105 temp.covarianceindex =
links.size();
106 temp.inputindex = -1;
108 links.push_back(temp);
115 if(!IsInList(ND::params().GetParameterS(paramcov),
listoffiles,index))
117 listoffiles.push_back(ND::params().GetParameterS(paramcov));
119 sprintf(dirname,
"%s/data/%s",getenv(
"PSYCHESYSTEMATICSROOT"),ND::params().GetParameterS(paramcov).c_str());
123 char paramcovname[300];
124 sprintf(paramcovname,
"psycheSystematics.%s.CovFileCov",parname.Data());
127 TMatrixT<double>* tempcov = (TMatrixT<double>*)file.Get(ND::params().
GetParameterS(paramcovname).c_str());
130 char paramcovlo[200];
131 sprintf(paramcovlo,
"psycheSystematics.%s.CovLowIndex",parname.Data());
135 sprintf(paramcovlo,
"psycheSystematics.%s.CovHighIndex",parname.Data());
140 std::cerr <<
" Parameter Number mismatch!!!!!!" << std::endl;
145 temp.covarianceindex = (int)
links.size();
146 temp.inputindex = loindex+i;
148 links.push_back(temp);
159 void SystematicCovariance::MapIndices(){
165 temp.inputindex = std::vector<double>();
166 temp.covarianceindex = std::vector<double>();
171 for(std::vector<indexlink>::iterator it =
links.begin(); it !=
links.end(); it++)
173 if((*it).inputcov!=-1)
175 covlinks[(*it).inputcov].inputindex.push_back((*it).inputindex);
176 covlinks[(*it).inputcov].covarianceindex.push_back((*it).covarianceindex);
void ConstructCovarianceMatrix(SystematicManager *man)
Creates the covariance matrix for the enabled parameters.
This class constructs and manipulates the covariance of the systematic uncertainties.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
EventVariationBase ** GetVariationSystematics(int &nSys)
Get the vector of variationSystematics.
std::string GetParameterS(std::string)
Get parameter. Value is returned as string.
std::vector< std::string > listoffiles
list of file names for covariances
The maximum number of systematics that is supported.
EventWeightBase ** GetWeightSystematics(int &nSys)
Get the vector of weightsSystematics.
bool HasParameter(std::string)
Check if Parameter is stored in database.
EventWeightBase ** GetFluxSystematics(int &nSys)
Get the vector of fluxSystematics.
TMatrixT< double > * _covarianceMatrix
The covariance matrix for the enabled systematics.
std::vector< TMatrixT< double > * > covariances
list of covariances
std::vector< covlink > covlinks
vector of covariance links
std::vector< indexlink > links
vector of index links
UInt_t GetNParameters() const
Returns the number of systematic parameters associated to this systematic.
virtual const char * GetName() const
Return the name of this systematic. This overrides the TObject::GetName() interface.