Navigation Menu

Skip to content

Commit

Permalink
feature to keep only certain systematic uncertainty classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tancredicarli committed Sep 8, 2015
1 parent 11650f7 commit b78de5d
Show file tree
Hide file tree
Showing 14 changed files with 633 additions and 145 deletions.
2 changes: 1 addition & 1 deletion PDF/CT10.txt
Expand Up @@ -45,7 +45,7 @@ num_members = 53 ; number of PDF members
;==============================================================
[STYLE]
fill_style = 3004
fill_color = 633
fill_color = 797
marker_style = 20

;==============================================================
Expand Down
2 changes: 1 addition & 1 deletion PDF/CT14.txt
Expand Up @@ -41,7 +41,7 @@ num_members = 57 ; number of PDF members
;==============================================================
[STYLE]
fill_style = 3004
fill_color = 797
fill_color = 633
marker_style = 20

;==============================================================
Expand Down
2 changes: 2 additions & 0 deletions RELEASE.md
Expand Up @@ -6,6 +6,8 @@

## Change Log

-Feature to only keep systematic uncertainty class of

-Feature to remove class of systematics uncertainties

-SPXPlot/SPXRatio/SPXGraphUtilities
Expand Down
20 changes: 16 additions & 4 deletions examples/Steering/example.txt
Expand Up @@ -52,10 +52,12 @@ apply_grid_corr = true ;[Optional] Apply the grid corrections (e.g. hadronisa
; (as specified in SPXGrid steering) for all grids if true



show_individual_systematics = 0 ;[Optional] Show individual systematic on data above x%
show_systematics_as_lines = 1 ; [Optional] Show systematics as line, number is line thickness
show_systematics_as_lines = 1 ;[Optional] Show systematics as line, number is line thickness

show_total_systematics = 1 ;[Optional] Show total systematics on SPXRatio plot
; number means color
;
order_systematic_colorbyalphabeth = false ;[Optional] if set systematics colors are order by alphabethical order of name

print_total_sigma = true ;[Optional] Print total integrated cross section at the end of the
Expand Down Expand Up @@ -172,13 +174,23 @@ grid_fill_style = 1001,1002 ; type_fill_sty

display_systematic_group = JES, JER ;[Optional] List of groups of systematics to be displayed
; active only for DataOVerData
; components containing classname (like JES) in the
; name are added in quadrature
; to be active show_individual_systemtics=0
; if keyword "Others" is given all uncertainties not specified before are added here
display_systematic_group_band_color = 2,3 ;[Optional] color of band for systematic groups
display_systematic_group_fill_color = 2,3 ;[Optional] color of band for systematic groups
; for negative color: only plot edge histogram with color -idcolor
display_systematic_group_edge_color = 2,3 ;[Optional] color of band for systematic groups edge
display_systematic_group_edge_style = 2,3 ;[Optional] style for systematic groups edge histogram
display_systematic_group_edge_width = 2,3 ;[Optional] style for systematic groups edge histogram line width




remove_systematic_group = JES,JER ; [Optional] Remove systematics that contains name from systematic map
;
contain_systematic_group = JES,JER ; [Optional] Keep only systematics that contains name from systematic map



;total_fill_style=1001 ;[Optional] List of Total marker style OVERRIDES
;total_fill_color=800 ;[Optional] root color code and style https://root.cern.ch/root/html/TAttFill.html
Expand Down
38 changes: 38 additions & 0 deletions src/SPXData.cxx
Expand Up @@ -2156,6 +2156,44 @@ void SPXData::RemoveSystematicthatContains(std::string systclassname){
return;
};

void SPXData::KeepSystematicthatContains(std::string systclassname){
std::string mn ="KeepSystematicthatContains: ";
if(debug) SPXUtilities::PrintMethodHeader(cn, mn);

int nremoved=0;
int nkeep=0;

StringDoubleVectorMap_T::iterator itr = individualSystematics.begin();
while (itr != individualSystematics.end()) {
const std::string &systname = itr->first;
TString mapname=TString(systname);

//if (debug) std::cout <<cn<<mn<<"Check if systematics= "<<mapname.Data()<< " contains= "<<systclassname<<std::endl;

if (!mapname.Contains(systclassname,TString::kIgnoreCase)) {
if (debug) std::cout<<cn<<mn<<"Systematics name class "<<systclassname<<" is in map with systname= "<<mapname.Data()<<std::endl;
individualSystematics.erase(itr++);
nremoved++;
} else {
nkeep++;
++itr;
}
}

if (nremoved>0) {
if (debug) std::cout<<cn<<mn<<"Number of removed systematics nremoved= "<<nremoved<<std::endl;
}

if (nkeep>0) {
if (debug) std::cout<<cn<<mn<<"Number of kept systematics nkeep= "<<nkeep<<std::endl;
}


UpdateSystematics();

return;
};


void SPXData::UpdateSystematics(void){
std::string mn ="UpdateSystematics: ";
Expand Down
2 changes: 2 additions & 0 deletions src/SPXData.h
Expand Up @@ -232,6 +232,8 @@ class SPXData {
bool GetSystematicCorrelationType(std::string name);

void RemoveSystematicthatContains(std::string);
void KeepSystematicthatContains(std::string);

void UpdateSystematics(void);
private:
static bool debug; //Flag indicating debug mode
Expand Down
157 changes: 120 additions & 37 deletions src/SPXGraphUtilities.cxx
Expand Up @@ -637,9 +637,9 @@ TGraphAsymmErrors * SPXGraphUtilities::Divide(TGraphAsymmErrors *g1, TGraphAsymm

//Make sure the two graphs are the same size
if(n1 != n2) {
std::cout<<cn<<mn<<" Graph1: "<<g1->GetName()<<std::endl;
std::cout<<cn<<mn<<"Graph1: "<<g1->GetName()<<std::endl;
g1->Print();
std::cout<<cn<<mn<<" Graph2: "<<g2->GetName()<<std::endl;
std::cout<<cn<<mn<<"Graph2: "<<g2->GetName()<<std::endl;
g2->Print();

std::ostringstream oss;
Expand All @@ -651,22 +651,23 @@ TGraphAsymmErrors * SPXGraphUtilities::Divide(TGraphAsymmErrors *g1, TGraphAsymm

//std::cout << cn<<mn<<" n1= " <<n1<<" n2= "<<n2<< std::endl;


//@TODO Pass result as parameter and return that way! Don't call 'new' in a function
TGraphAsymmErrors *result = new TGraphAsymmErrors();

if (!result) std::cout<<cn<<mn<<"WARNING Error creating ratio graph"<< std::endl;
result->SetName(g1->GetName());
result->SetMarkerStyle(g1->GetMarkerStyle());

result->SetMarkerColor(g1->GetMarkerColor());
result->SetMarkerSize(g1->GetMarkerSize());
//result->SetMarkerStyle(g1->GetMarkerStyle());

result->SetLineColor(g1->GetLineColor());
result->SetLineWidth(g1->GetLineWidth());
//result->SetMarkerColor(g1->GetMarkerColor());
//result->SetMarkerSize(g1->GetMarkerSize());

result->SetFillStyle(g1->GetFillStyle());
result->SetFillColor(g1->GetFillColor());
//result->SetLineColor(g1->GetLineColor());
//result->SetLineWidth(g1->GetLineWidth());

//result->SetFillStyle(g1->GetFillStyle());
//result->SetFillColor(g1->GetFillColor());

SPXGraphUtilities::SPXCopyGraphProperties((TGraphErrors *)g1,(TGraphErrors *)result);

Double_t x1=0.0, y1=0.0, x2=0.0, y2=0.0;
Double_t dx1h=0.0, dx1l=0.0;
Expand Down Expand Up @@ -816,12 +817,86 @@ void SPXGraphUtilities::SPXCopyGraphProperties(TGraphErrors* g1, TGraphErrors* g
if (!g2) throw SPXGraphException(cn + mn + "Graph g2 does not exist ! " );

g2->SetName (g1->GetName());

g2->SetMarkerStyle(g1->GetMarkerStyle());
g2->SetMarkerColor(g1->GetMarkerColor());

g2->SetLineColor (g1->GetLineColor());
g2->SetLineStyle (g1->GetLineStyle());
g2->SetLineWidth (g1->GetLineWidth());

g2->SetFillColor (g1->GetFillColor());
g2->SetFillStyle (g1->GetFillStyle());

return;
}

void SPXGraphUtilities::SPXCopyGraphProperties(TGraphErrors* g1, TH1D* h2){
std::string mn = "SPXCopyGraphProperties";
// copy properties of graph g1 to histogram h2

if (!g1) throw SPXGraphException(cn + mn + "Graph g1 does not exist ! " );
if (!h2) throw SPXGraphException(cn + mn + "Graph h2 does not exist ! " );

TString hname="histo";
hname+=g1->GetName();
h2->SetName (hname);

h2->SetMarkerStyle(g1->GetMarkerStyle());
h2->SetMarkerColor(g1->GetMarkerColor());

h2->SetLineColor (g1->GetLineColor());
h2->SetLineStyle (g1->GetLineStyle());
h2->SetLineWidth (g1->GetLineWidth());

h2->SetFillColor (g1->GetFillColor());
h2->SetFillStyle (g1->GetFillStyle());


return;
}


void SPXGraphUtilities::SPXPrintGraphProperties(TGraphErrors* g1){
std::string mn = "SPXPrintGraphProperties";
// Print properties of graph g1

if (!g1) throw SPXGraphException(cn + mn + "Graph g1 does not exist ! " );

std::cout<<cn<<mn<<" Print properties of graph "<<g1->GetName()<<std::endl;

std::cout<<cn<<mn<<" MarkerStyle= "<<g1->GetMarkerStyle()<<std::endl;
std::cout<<cn<<mn<<" MarkerColor= "<<g1->GetMarkerColor()<<std::endl;

std::cout<<cn<<mn<<" LineStyle= "<<g1->GetLineStyle()<<std::endl;
std::cout<<cn<<mn<<" LineColor= "<<g1->GetLineColor()<<std::endl;
std::cout<<cn<<mn<<" LineWidth= "<<g1->GetLineWidth()<<std::endl;

std::cout<<cn<<mn<<" FillStyle= "<<g1->GetFillStyle()<<std::endl;
std::cout<<cn<<mn<<" FillColor= "<<g1->GetFillColor()<<std::endl;

return;
}


void SPXGraphUtilities::SPXPrintHistoProperties(TH1* h1){
std::string mn = "SPXPrintHistoProperties";
// Print properties of TH1 h1

if (!h1) throw SPXGraphException(cn + mn + "Histogram h1 does not exist ! " );

std::cout<<cn<<mn<<" Print properties of histogram "<<h1->GetName()<<std::endl;

std::cout<<cn<<mn<<" MarkerStyle= "<<h1->GetMarkerStyle()<<std::endl;
std::cout<<cn<<mn<<" MarkerColor= "<<h1->GetMarkerColor()<<std::endl;

std::cout<<cn<<mn<<" LineStyle= "<<h1->GetLineStyle()<<std::endl;
std::cout<<cn<<mn<<" LineColor= "<<h1->GetLineColor()<<std::endl;
std::cout<<cn<<mn<<" LineWidth= "<<h1->GetLineWidth()<<std::endl;

std::cout<<cn<<mn<<" FillStyle= "<<h1->GetFillStyle()<<std::endl;
std::cout<<cn<<mn<<" FillColor= "<<h1->GetFillColor()<<std::endl;

return;
}

Expand Down Expand Up @@ -954,8 +1029,14 @@ TH1D *SPXGraphUtilities::GetEdgeHistogram(TGraphAsymmErrors * g, bool low) {
TH1D *h1 = new TH1D(name,name,nbin,xbins);
if (!h1) std::cout << cn<<mn<<"WARNING: Problem creating edge histogram for graph "<<g->GetName()<<std::endl;

int icol=g->GetLineColor();
h1->SetLineColor(icol);
//h1->SetLineColor(g->GetLineColor());
//h1->SetLineStyle(g->GetLineStyle());
//h1->SetMarkerColor(g->GetMarkerColor());
//h1->SetMarkerStyle(g->GetMarkerStyle());
//h1->SetFillColor(g->GetFillColor());
//h1->SetFillStyle(g->GetFillStyle());

SPXGraphUtilities::SPXCopyGraphProperties((TGraphErrors*)g, h1);

for(int ibin = 0; ibin < nbin; ibin++) {
double eyh=g->GetErrorYhigh(ibin);
Expand Down Expand Up @@ -1494,7 +1575,7 @@ void SPXGraphUtilities::AddinQuadrature(TGraphAsymmErrors* g1, TGraphAsymmErrors
return;
}

if (takesign) std::cout<<cn<<mn<<"WARNING takesign option not yet implemented "<<std::endl;
//if (takesign) std::cout<<cn<<mn<<"WARNING takesign option not yet implemented "<<std::endl;

Double_t* EYhigh1 = g1-> GetEYhigh();
Double_t* EYlow1 = g1-> GetEYlow();
Expand All @@ -1505,28 +1586,30 @@ void SPXGraphUtilities::AddinQuadrature(TGraphAsymmErrors* g1, TGraphAsymmErrors
for (Int_t i=0; i<g1->GetN(); i++) {
Double_t eyh=0., eyl=0.;

if (EYhigh1[i]<0 && EYlow1[i]>0) {
Double_t x1=0., y1=0.;
g1->GetPoint(i, x1,y1);
if (y1==0.)
std::cout<<cn<<mn<<"INFO: switch signs for g1= "<<g1->GetName()<<" EYhigh1["<<i<<"]= " << EYhigh1[i]<<" EYlow1["<<i<<"]= "<<EYlow1[i]<< std::endl;
else
std::cout<<cn<<mn<<"INFO: switch signs for relative g1= "<<g1->GetName()<<" EYhigh1["<<i<<"]= " << EYhigh1[i]/y1 <<" EYlow1["<<i<<"]= "<<EYlow1[i]/y1<< std::endl;
double tmp=EYhigh1[i];
EYhigh1[i]= EYlow1[i];
EYlow1[i]=tmp;
}
if (takesign) {
if (EYhigh1[i]<0 && EYlow1[i]>0) {
Double_t x1=0., y1=0.;
g1->GetPoint(i, x1,y1);
if (y1==0.)
std::cout<<cn<<mn<<"INFO: switch signs for g1= "<<g1->GetName()<<" EYhigh1["<<i<<"]= " << EYhigh1[i]<<" EYlow1["<<i<<"]= "<<EYlow1[i]<< std::endl;
else
std::cout<<cn<<mn<<"INFO: switch signs for relative g1= "<<g1->GetName()<<" EYhigh1["<<i<<"]= " << EYhigh1[i]/y1 <<" EYlow1["<<i<<"]= "<<EYlow1[i]/y1<< std::endl;
double tmp=EYhigh1[i];
EYhigh1[i]= EYlow1[i];
EYlow1[i]=tmp;
}

if (EYhigh2[i]<0 && EYlow2[i]>0) {
Double_t x2=0., y2=0.;
g2->GetPoint(i, x2,y2);
if (y2==0.)
std::cout<<cn<<mn<<"INFO: switch signs for g2= "<<g2->GetName()<<" EYhigh2["<<i<<"]= " << EYhigh2[i] <<" EYlow2["<<i<<"]= "<<EYlow2[i]<< std::endl;
else
std::cout<<cn<<mn<<"INFO: switch signs for relative g2= "<<g2->GetName()<<" EYhigh2["<<i<<"]= " << EYhigh2[i]/y2 <<" EYlow2["<<i<<"]= "<<EYlow2[i]/y2<< std::endl;
double tmp=EYhigh2[i];
EYhigh2[i]= EYlow2[i];
EYlow2[i]=tmp;
if (EYhigh2[i]<0 && EYlow2[i]>0) {
Double_t x2=0., y2=0.;
g2->GetPoint(i, x2,y2);
if (y2==0.)
std::cout<<cn<<mn<<"INFO: switch signs for g2= "<<g2->GetName()<<" EYhigh2["<<i<<"]= " << EYhigh2[i] <<" EYlow2["<<i<<"]= "<<EYlow2[i]<< std::endl;
else
std::cout<<cn<<mn<<"INFO: switch signs for relative g2= "<<g2->GetName()<<" EYhigh2["<<i<<"]= " << EYhigh2[i]/y2 <<" EYlow2["<<i<<"]= "<<EYlow2[i]/y2<< std::endl;
double tmp=EYhigh2[i];
EYhigh2[i]= EYlow2[i];
EYlow2[i]=tmp;
}
}

if ((EYhigh2[i]>0 && EYlow2[i]>0) || (EYhigh2[i]<0 && EYlow2[i]<0)) {
Expand All @@ -1548,13 +1631,13 @@ void SPXGraphUtilities::AddinQuadrature(TGraphAsymmErrors* g1, TGraphAsymmErrors
}

void SPXGraphUtilities::SetColors(TGraphAsymmErrors* g1, Color_t icol) {
//
std::string mn = "SetColors: ";

//
if (!g1) {
std::cout<<cn<<mn<<"WARNING Graph g1 not found ! "<<std::endl;
return;
}

g1->SetLineColor(icol);
g1->SetFillColor(icol);
g1->SetMarkerColor(icol);
Expand Down
3 changes: 3 additions & 0 deletions src/SPXGraphUtilities.h
Expand Up @@ -76,6 +76,9 @@ class SPXGraphUtilities {
static void ScaleYErrors(TGraphAsymmErrors * g, double scale);

static void SPXCopyGraphProperties(TGraphErrors* g1, TGraphErrors* g2);
static void SPXCopyGraphProperties(TGraphErrors* g1, TH1D* h2);
static void SPXPrintGraphProperties(TGraphErrors* g1);
static void SPXPrintHistoProperties(TH1* h1);

static TH1D* GetEdgeHistogram(TGraphAsymmErrors * g, bool low = false);

Expand Down

0 comments on commit b78de5d

Please sign in to comment.