39 if(
file==
"")
return StatusCode::FAILURE;
41 TFile* f = TFile::Open(
file.c_str());
45 return StatusCode::FAILURE;
51 std::unique_ptr<TIterator> itr(f->GetListOfKeys()->MakeIterator());
53 while( (key =
static_cast<TKey*
>(itr->Next())) ) {
54 TClass* cl = TClass::GetClass(key->GetClassName());
55 if(!cl || !cl->InheritsFrom(TDirectory::Class()))
continue;
59 ATH_MSG_ERROR(
"Systematic must be of form: <string>__Xup OR <string>__Xdown ... where X is a number");
60 return StatusCode::FAILURE;
65 while( (key =
static_cast<TKey*
>(itr->Next())) ) {
66 TClass* cl = TClass::GetClass(key->GetClassName());
67 if(!cl || !cl->InheritsFrom(
"TH1"))
continue;
74 TString
h = (syst==
CP::SystematicVariation(
"")) ? std::string(key->GetName()) : syst.name()+
"/" + std::string(key->GetName());
75 TH1* hist =
static_cast<TH1*
>(f->Get(
h));
78 ATH_MSG_VERBOSE(
"No " << syst.name() <<
" variation of " << key->GetName());
82 return StatusCode::FAILURE;
94 return StatusCode::FAILURE;
98 if(strlen(hist->GetXaxis()->GetTitle())==0 ||
99 (hist->GetDimension()>1 && strlen(hist->GetYaxis()->GetTitle())==0) ||
100 (hist->GetDimension()>2 && strlen(hist->GetZaxis()->GetTitle())==0) ) {
101 ATH_MSG_ERROR(
"All axis of histogram " << hist->GetName() <<
" need to be labelled");
102 return StatusCode::FAILURE;
105 TH1*& existHist =
m_hists[
type].hists[syst.name()];
108 existHist->GetXaxis()->GetTitle() <<
"," << hist->GetXaxis()->GetTitle() <<
109 ") = 2*f(" << existHist->GetXaxis()->GetTitle() <<
")*f(" <<
110 hist->GetXaxis()->GetTitle() <<
")/[f(" << existHist->GetXaxis()->GetTitle() <<
111 ")+f(" << hist->GetXaxis()->GetTitle() <<
")]");
114 if(existHist->GetDimension()==1 && hist->GetDimension()==1) {
115 std::vector<double> binEdges1, binEdges2;
116 for(
int i=1;i<=existHist->GetNbinsX()+1;i++) binEdges1.push_back(existHist->GetBinLowEdge(i));
117 for(
int i=1;i<=hist->GetNbinsX()+1;i++) binEdges2.push_back(hist->GetBinLowEdge(i));
118 newHist =
new TH2D(
"myHist",
"myHist",existHist->GetNbinsX(),&binEdges1[0],hist->GetNbinsX(),&binEdges2[0]);
119 newHist->SetDirectory(0);
120 newHist->GetXaxis()->SetTitle(existHist->GetTitle());
121 newHist->GetYaxis()->SetTitle(hist->GetTitle());
122 for(
int i=0;i<=existHist->GetNbinsX()+1;i++) {
123 for(
int j=0;j<=hist->GetNbinsX()+1;j++) {
124 double a = existHist->GetBinContent(i);
double b = hist->GetBinContent(j);
125 if(
a && b) newHist->SetBinContent(newHist->GetBin(i,j), 2.0 * (
a*b)/(
a+b) );
128 double da = existHist->GetBinError(i);
double db = hist->GetBinError(j);
129 if(
a && b) newHist->SetBinError(newHist->GetBin(i,j), 2.0 * (da*b*b + db*
a*
a)/((
a+b)*(
a+b)) );
136 ATH_MSG_ERROR(
"Unsupported scale factor reparamertization :-(");
137 return StatusCode::FAILURE;
141 existHist =
static_cast<TH1*
>(hist->Clone(
"myHist")); existHist->SetDirectory(0);
147 for(
int i=0;i<hist->GetDimension();i++) {
148 std::string axisTitle = ( i==0 ) ? hist->GetXaxis()->GetTitle() : ( (i==1) ? hist->GetYaxis()->GetTitle() : hist->GetZaxis()->GetTitle() );
149 axisTitle.erase(remove_if(axisTitle.begin(), axisTitle.end(), isspace),axisTitle.end());
152 if(axisTitle==
"pt" || axisTitle==
"pt/MeV" || axisTitle==
"pt[MeV]") {
154 }
else if(axisTitle ==
"pt/GeV" || axisTitle==
"pt[GeV]") {
156 }
else if(axisTitle==
"eta") {
159 bfunc = std::bind(
part_decor, std::placeholders::_1, axisTitle);
161 m_hists[
type].axisFuncs.push_back(std::move(bfunc));
174 for(
auto& s : tmpSet) {
187 return StatusCode::SUCCESS;
192 auto histItr =
m_hists.find(particle->type());
194 ATH_MSG_ERROR(
"No scale factor available for particle type: " << particle->type());
195 throw std::runtime_error(TString::Format(
"%s : No scale factor available for particle type %d",name().c_str(),
int(particle->type())).Data());
199 std::pair<CP::SystematicVariation,TH1*>
res = histItr->second.getHist(
m_currentSyst);
201 const TH1* hist =
res.second;
205 switch(hist->GetDimension()) {
206 case 1:
bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle));
break;
207 case 2:
bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle),histItr->second.axisFuncs[1](*particle));
break;
208 case 3:
bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle),histItr->second.axisFuncs[1](*particle),histItr->second.axisFuncs[2](*particle));
break;
211 if(
res.first.parameter() == 0.)
return hist->GetBinContent(
bin);
215 return nom + (
m_currentSyst.parameter()/
res.first.parameter()) * (hist->GetBinContent(
bin) - nom);
Class providing the definition of the 4-vector interface.