|
ATLAS Offline Software
|
Go to the documentation of this file.
10 #include "TDirectory.h"
21 const char savedYieldsKey[] =
"BaseLinearFakeBkgTool__yields";
22 const char savedHistogramsKey[] =
"BaseLinearFakeBkgTool__histograms";
52 return StatusCode::FAILURE;
54 weight.uncertainties.clear();
57 if(!success)
return StatusCode::FAILURE;
62 return StatusCode::SUCCESS;
65 if(
sc != StatusCode::SUCCESS)
return sc;
67 return StatusCode::SUCCESS;
75 return StatusCode::FAILURE;
82 yield = total.value(
this);
83 yieldStatErrorUp = sqrt(total.stat2.up);
84 yieldStatErrorDown = sqrt(total.stat2.down);
87 for(
int i=0;
i<kv.first->GetNcells();++
i)
89 auto& thisYield =
m_yields.at(kv.second.first +
i);
90 kv.first->SetBinContent(
i, thisYield.value(
this));
91 kv.first->SetBinError(
i, thisYield.stat());
94 return StatusCode::SUCCESS;
115 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));
118 return StatusCode::SUCCESS;
124 if(
sc != StatusCode::SUCCESS)
return sc;
131 if(
sc != StatusCode::SUCCESS)
return sc;
138 if(
sc != StatusCode::SUCCESS)
return sc;
144 const std::string
histname =
h->GetName();
145 std::pair<uint32_t, uint32_t>
range;
148 if(
histname != itr->first->GetName())
continue;
152 return StatusCode::SUCCESS;
158 return StatusCode::SUCCESS;
163 TTree
tree(::savedYieldsKey,
"binned yields saved by BaseLinearFakeBkgTool");
168 float nominal, stat2Up, stat2Down;
170 std::unique_ptr<UShort_t[]> systUID(
new UShort_t[maxSize]);
171 std::unique_ptr<float[]> systUp(
new float[maxSize]), systDown(
new float[maxSize]);
173 tree.Branch(
"Bin", &
bin,
"Bin/i");
174 tree.Branch(
"nominal", &nominal,
"nominal/F");
175 tree.Branch(
"stat2Up", &stat2Up,
"stat2Up/F");
176 tree.Branch(
"stat2Down", &stat2Down,
"stat2Down/F");
177 tree.Branch(
"N", &
n,
"N/i");
178 tree.Branch(
"systUID", systUID.get(),
"systUID[N]/s");
179 tree.Branch(
"systUp", systUp.get(),
"systUp[N]/F");
180 tree.Branch(
"systDown", systDown.get(),
"systDown[N]/F");
182 auto fillTree = [&](
const auto& yield)
184 nominal = yield.nominal;
185 stat2Up = yield.stat2.up;
186 stat2Down = yield.stat2.down;
187 n = yield.uncertainties.size();
188 auto itr = yield.uncertainties.begin();
191 systUID[j] = itr->first;
192 systUp[j] = itr->second.up;
193 systDown[j] = itr->second.down;
201 std::hash<std::string> hasher;
205 histname = hasher(kv.first->GetName());
206 for(
uint32_t i=kv.second.first;
i<=kv.second.second;++
i)
208 bin =
i - kv.second.first;
215 dir->mkdir(::savedHistogramsKey);
216 dir->cd(::savedHistogramsKey);
219 return StatusCode::SUCCESS;
226 auto file = std::unique_ptr<TFile>(TFile::Open(
filename.c_str(),
"READ"));
230 return StatusCode::FAILURE;
232 std::string
path = ::savedYieldsKey;
237 auto tree =
static_cast<TTree*
>(
file->Get(
path.c_str()));
241 return StatusCode::FAILURE;
247 std::hash<std::string> hasher;
251 dictionary[hasher(itr->first->GetName())] = itr;
256 float nominal, stat2Up, stat2Down;
258 std::unique_ptr<UShort_t[]> systUID(
new UShort_t[maxSize]);
259 std::unique_ptr<float[]> systUp(
new float[maxSize]), systDown(
new float[maxSize]);
260 tree->SetBranchStatus(
"*", kTRUE);
262 tree->SetBranchAddress(
"Bin", &
bin);
263 tree->SetBranchAddress(
"nominal", &nominal);
264 tree->SetBranchAddress(
"stat2Up", &stat2Up);
265 tree->SetBranchAddress(
"stat2Down", &stat2Down);
266 tree->SetBranchAddress(
"N", &
n);
268 tree->SetBranchAddress(
"systUID", systUID.get());
269 tree->SetBranchAddress(
"systUp", systUp.get());
270 tree->SetBranchAddress(
"systDown", systDown.get());
272 std::set<std::size_t> filledHistograms;
279 ATH_MSG_ERROR(
"the tool configuration seems to have changed (number of systematics)!");
280 return StatusCode::FAILURE;
290 const TH1*
h = itr->second->first;
291 const auto&
range = itr->second->second;
294 ATH_MSG_ERROR(
"inconsistent binnings found for histogram " <<
h->GetName());
295 return StatusCode::FAILURE;
308 for(
unsigned j=0;j<
n;++j)
314 if(!emplaced.second) emplaced.first->second +=
u;
322 return StatusCode::FAILURE;
326 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)