![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
10 #ifndef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
11 #define declareProperty(n, p, h) ExtraPropertyManager<BaseLinearFakeBkgTool>::declareProperty(n, &BaseLinearFakeBkgTool::p, h)
15 #include "TDirectory.h"
26 const char savedYieldsKey[] =
"BaseLinearFakeBkgTool__yields";
27 const char savedHistogramsKey[] =
"BaseLinearFakeBkgTool__histograms";
59 return StatusCode::FAILURE;
61 weight.uncertainties.clear();
64 if(!success)
return StatusCode::FAILURE;
69 return StatusCode::SUCCESS;
72 if(
sc != StatusCode::SUCCESS)
return sc;
74 return StatusCode::SUCCESS;
82 return StatusCode::FAILURE;
89 yield = total.value(
this);
90 yieldStatErrorUp = sqrt(total.stat2.up);
91 yieldStatErrorDown = sqrt(total.stat2.down);
94 for(
int i=0;
i<kv.first->GetNcells();++
i)
96 auto& yield =
m_yields.at(kv.second.first +
i);
97 kv.first->SetBinContent(
i, yield.value(
this));
98 kv.first->SetBinError(
i, yield.stat());
101 return StatusCode::SUCCESS;
122 unsigned index =
m_histogramYieldsRange.at(kv.first).first + kv.first->FindBin(*std::get<0>(kv.second), *std::get<1>(kv.second), *std::get<2>(kv.second));
125 return StatusCode::SUCCESS;
131 if(
sc != StatusCode::SUCCESS)
return sc;
138 if(
sc != StatusCode::SUCCESS)
return sc;
145 if(
sc != StatusCode::SUCCESS)
return sc;
151 const std::string
histname =
h->GetName();
152 std::pair<uint32_t, uint32_t>
range;
155 if(
histname != itr->first->GetName())
continue;
159 return StatusCode::SUCCESS;
165 return StatusCode::SUCCESS;
170 TTree
tree(::savedYieldsKey,
"binned yields saved by BaseLinearFakeBkgTool");
175 float nominal, stat2Up, stat2Down;
177 std::unique_ptr<UShort_t[]> systUID(
new UShort_t[maxSize]);
178 std::unique_ptr<float[]> systUp(
new float[maxSize]), systDown(
new float[maxSize]);
180 tree.Branch(
"Bin", &
bin,
"Bin/i");
182 tree.Branch(
"stat2Up", &stat2Up,
"stat2Up/F");
183 tree.Branch(
"stat2Down", &stat2Down,
"stat2Down/F");
184 tree.Branch(
"N", &
n,
"N/i");
185 tree.Branch(
"systUID", systUID.get(),
"systUID[N]/s");
186 tree.Branch(
"systUp", systUp.get(),
"systUp[N]/F");
187 tree.Branch(
"systDown", systDown.get(),
"systDown[N]/F");
189 auto fillTree = [&](
const auto& yield)
192 stat2Up = yield.stat2.up;
193 stat2Down = yield.stat2.down;
194 n = yield.uncertainties.size();
195 auto itr = yield.uncertainties.begin();
198 systUID[j] = itr->first;
199 systUp[j] = itr->second.up;
200 systDown[j] = itr->second.down;
208 std::hash<std::string> hasher;
212 histname = hasher(kv.first->GetName());
213 for(
uint32_t i=kv.second.first;
i<=kv.second.second;++
i)
215 bin =
i - kv.second.first;
222 dir->mkdir(::savedHistogramsKey);
223 dir->cd(::savedHistogramsKey);
226 return StatusCode::SUCCESS;
233 auto file = std::unique_ptr<TFile>(TFile::Open(
filename.c_str(),
"READ"));
237 return StatusCode::FAILURE;
239 std::string
path = ::savedYieldsKey;
244 auto tree =
static_cast<TTree*
>(
file->Get(
path.c_str()));
248 return StatusCode::FAILURE;
254 std::hash<std::string> hasher;
258 dictionary[hasher(itr->first->GetName())] = itr;
263 float nominal, stat2Up, stat2Down;
265 std::unique_ptr<UShort_t[]> systUID(
new UShort_t[maxSize]);
266 std::unique_ptr<float[]> systUp(
new float[maxSize]), systDown(
new float[maxSize]);
267 tree->SetBranchStatus(
"*", kTRUE);
269 tree->SetBranchAddress(
"Bin", &
bin);
271 tree->SetBranchAddress(
"stat2Up", &stat2Up);
272 tree->SetBranchAddress(
"stat2Down", &stat2Down);
273 tree->SetBranchAddress(
"N", &
n);
275 tree->SetBranchAddress(
"systUID", systUID.get());
276 tree->SetBranchAddress(
"systUp", systUp.get());
277 tree->SetBranchAddress(
"systDown", systDown.get());
279 std::set<std::size_t> filledHistograms;
286 ATH_MSG_ERROR(
"the tool configuration seems to have changed (number of systematics)!");
287 return StatusCode::FAILURE;
297 const TH1*
h = itr->second->first;
298 const auto&
range = itr->second->second;
301 ATH_MSG_ERROR(
"inconsistent binnings found for histogram " <<
h->GetName());
302 return StatusCode::FAILURE;
315 for(
unsigned j=0;j<
n;++j)
321 if(!emplaced.second) emplaced.first->second +=
u;
329 return StatusCode::FAILURE;
333 return StatusCode::SUCCESS;
path
python interpreter configuration --------------------------------------—
Select isolated Photons, Electrons and Muons.
@ u
Enums for curvilinear frames.
void fillTree(AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string PathResolverFindDataFile(const std::string &logical_file_name)
#define ATH_MSG_WARNING(x)