27 for(
auto&
b :
a.second.hists) {
38 if(
file==
"")
return StatusCode::FAILURE;
40 TFile*
f = TFile::Open(
file.c_str());
44 return StatusCode::FAILURE;
50 std::unique_ptr<TIterator> itr(
f->GetListOfKeys()->MakeIterator());
52 while( (
key =
static_cast<TKey*
>(itr->Next())) ) {
53 TClass*
cl = TClass::GetClass(
key->GetClassName());
54 if(!
cl || !
cl->InheritsFrom(TDirectory::Class()))
continue;
58 ATH_MSG_ERROR(
"Systematic must be of form: <string>__Xup OR <string>__Xdown ... where X is a number");
59 return StatusCode::FAILURE;
64 while( (
key =
static_cast<TKey*
>(itr->Next())) ) {
65 TClass*
cl = TClass::GetClass(
key->GetClassName());
66 if(!
cl || !
cl->InheritsFrom(
"TH1"))
continue;
74 TH1*
hist =
static_cast<TH1*
>(
f->Get(
h));
81 return StatusCode::FAILURE;
93 return StatusCode::FAILURE;
97 if(strlen(
hist->GetXaxis()->GetTitle())==0 ||
98 (
hist->GetDimension()>1 && strlen(
hist->GetYaxis()->GetTitle())==0) ||
99 (
hist->GetDimension()>2 && strlen(
hist->GetZaxis()->GetTitle())==0) ) {
100 ATH_MSG_ERROR(
"All axis of histogram " <<
hist->GetName() <<
" need to be labelled");
101 return StatusCode::FAILURE;
104 TH1*& existHist =
m_hists[
type].hists[syst.name()];
107 existHist->GetXaxis()->GetTitle() <<
"," <<
hist->GetXaxis()->GetTitle() <<
108 ") = 2*f(" << existHist->GetXaxis()->GetTitle() <<
")*f(" <<
109 hist->GetXaxis()->GetTitle() <<
")/[f(" << existHist->GetXaxis()->GetTitle() <<
110 ")+f(" <<
hist->GetXaxis()->GetTitle() <<
")]");
113 if(existHist->GetDimension()==1 &&
hist->GetDimension()==1) {
114 std::vector<double> binEdges1, binEdges2;
115 for(
int i=1;
i<=existHist->GetNbinsX()+1;
i++) binEdges1.push_back(existHist->GetBinLowEdge(
i));
116 for(
int i=1;
i<=
hist->GetNbinsX()+1;
i++) binEdges2.push_back(
hist->GetBinLowEdge(
i));
117 newHist =
new TH2D(
"myHist",
"myHist",existHist->GetNbinsX(),&binEdges1[0],
hist->GetNbinsX(),&binEdges2[0]);
119 newHist->GetXaxis()->SetTitle(existHist->GetTitle());
121 for(
int i=0;
i<=existHist->GetNbinsX()+1;
i++) {
122 for(
int j=0;j<=
hist->GetNbinsX()+1;j++) {
123 double a = existHist->GetBinContent(
i);
double b =
hist->GetBinContent(j);
127 double da = existHist->GetBinError(
i);
double db =
hist->GetBinError(j);
135 ATH_MSG_ERROR(
"Unsupported scale factor reparamertization :-(");
136 return StatusCode::FAILURE;
140 existHist =
static_cast<TH1*
>(
hist->Clone(
"myHist")); existHist->SetDirectory(0);
146 for(
int i=0;
i<
hist->GetDimension();
i++) {
147 std::string axisTitle = (
i==0 ) ?
hist->GetXaxis()->GetTitle() : ( (
i==1) ?
hist->GetYaxis()->GetTitle() :
hist->GetZaxis()->GetTitle() );
148 axisTitle.erase(remove_if(axisTitle.begin(), axisTitle.end(), isspace),axisTitle.end());
151 if(axisTitle==
"pt" || axisTitle==
"pt/MeV" || axisTitle==
"pt[MeV]") {
153 }
else if(axisTitle ==
"pt/GeV" || axisTitle==
"pt[GeV]") {
155 }
else if(axisTitle==
"eta") {
158 bfunc = std::bind(
part_decor, std::placeholders::_1, axisTitle);
173 for(
auto&
s : tmpSet) {
186 return StatusCode::SUCCESS;
194 throw std::runtime_error(
TString::Format(
"%s : No scale factor available for particle type %d",
name().c_str(),
int(
particle->type())).Data());
198 std::pair<CP::SystematicVariation,TH1*>
res = histItr->second.getHist(
m_currentSyst);
204 switch(
hist->GetDimension()) {
205 case 1:
bin =
hist->FindFixBin(histItr->second.axisFuncs[0](*
particle));
break;
206 case 2:
bin =
hist->FindFixBin(histItr->second.axisFuncs[0](*
particle),histItr->second.axisFuncs[1](*
particle));
break;
207 case 3:
bin =
hist->FindFixBin(histItr->second.axisFuncs[0](*
particle),histItr->second.axisFuncs[1](*
particle),histItr->second.axisFuncs[2](*
particle));
break;
210 if(!
res.first.parameter())
return hist->GetBinContent(
bin);
226 if(
s.first.basename()!=
set.basename())
continue;
229 if(
set.parameter()*
s.first.parameter()>0)
result =
s;
242 for(
auto& syst : systConfig) {
244 if(
s.basename()==syst.basename()) {
246 return StatusCode::SUCCESS;
252 return StatusCode::SUCCESS;