|
ATLAS Offline Software
|
#include <fstream>
#include <map>
#include <memory>
#include <getopt.h>
#include <TSystem.h>
#include <TError.h>
#include <TFile.h>
#include <TH1F.h>
#include "POOLRootAccess/TEvent.h"
#include "AsgTools/AnaToolHandle.h"
#include "xAODEventInfo/EventInfo.h"
#include "xAODEventInfo/EventAuxInfo.h"
#include "xAODEgamma/Electron.h"
#include "xAODMuon/Muon.h"
#include "AthContainers/Accessor.h"
#include "AsgMessaging/MessageCheck.h"
#include "AsgAnalysisInterfaces/IFakeBkgTool.h"
#include "AsgAnalysisInterfaces/ILinearFakeBkgTool.h"
Go to the source code of this file.
|
bool | successful (bool arg) |
|
bool | successful (const StatusCode &arg) |
|
bool | allTests (Store_t &store) |
|
bool | minimalTest (const std::string &type, const std::vector< std::string > &config, Store_t &store, Result &result) |
|
bool | parallelJob (const std::string &type, const std::vector< std::string > &config, Store_t &store, const std::string &saveAs, int nEvents, int eventOffset) |
|
bool | readFromROOT (std::vector< std::string > &config) |
|
bool | readFromXML (std::vector< std::string > &config) |
|
template<class Interface = CP::IFakeBkgTool> |
bool | setup (asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile) |
| mostly useful for athena, which will otherwise re-use the previous tool More...
|
|
template<class Interface = CP::IFakeBkgTool> |
bool | eventLoop (asg::AnaToolHandle< Interface > &tool, Store_t &store, Result &result, int nEvents, int eventOffset=0) |
|
bool | addEventWeight (asg::AnaToolHandle< CP::ILinearFakeBkgTool > &tool, Result &result) |
|
bool | addEventWeight (asg::AnaToolHandle< CP::IFakeBkgTool > &tool, Result &result) |
|
template<class Interface = CP::IFakeBkgTool> |
bool | fillResult (asg::AnaToolHandle< Interface > &tool, Result &result) |
|
int | main (int argc, char *argv[]) |
|
◆ FBT_CHECK
◆ FBT_CHECK1
#define FBT_CHECK1 |
( |
|
x, |
|
|
|
FAIL |
|
) |
| |
Value: do { \
Error("fbtTestBasics", "failure encounted on l.%d", __LINE__); \
return FAIL; \
} \
} while(false)
Definition at line 40 of file fbtTestBasics.cxx.
◆ Store_t
◆ addEventWeight() [1/2]
◆ addEventWeight() [2/2]
◆ allTests()
Definition at line 109 of file fbtTestBasics.cxx.
111 std::vector<std::string>
config;
112 Result result0, result1, result2, result3, result4, result5;
114 if(
verbose) std::cout <<
"\nWill do minimal test with CP::ApplyFakeFactor\n";
118 if(
verbose) std::cout <<
"\nWill do minimal test with CP::AsymptMatrixTool\n";
121 if(
verbose) std::cout <<
"\nWill do minimal test with CP::LhoodMM_tools\n";
124 if(
verbose) std::cout <<
"\nWill test loading efficiencies from XML\n";
130 if(
verbose) std::cout <<
"\nWill test getEventWeight()\n";
139 if(
verbose) std::cout <<
"\nWill test parallel jobs and merging\n";
143 FBT_CHECK( gSystem->Exec(
"hadd -f fbt_merged.root fbt_job*.root") == 0 );
◆ eventLoop()
template<class Interface = CP::IFakeBkgTool>
Definition at line 204 of file fbtTestBasics.cxx.
206 auto eventInfo = std::make_unique<xAOD::EventInfo>();
207 auto eventAuxInfo = std::make_unique<xAOD::EventAuxInfo>();
208 eventInfo->setStore(eventAuxInfo.get());
210 flagAcc(*eventInfo) = 1;
215 auto e = std::make_unique<xAOD::Electron>();
216 e->makePrivateStore();
220 for(
int i=eventOffset;
i<
nEvents+eventOffset;++
i)
222 e->setP4((1 + (
i%3))*1
e4, 0., 0. ,0.511);
223 TightAcc(*
e) = (
i%4)? 0 : 1;
228 #ifdef XAOD_STANDALONE
◆ fillResult()
template<class Interface = CP::IFakeBkgTool>
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 81 of file fbtTestBasics.cxx.
85 std::string option =
argv[
i];
86 if(option==
"-v" || option==
"--verbose")
verbose =
true;
89 #ifdef XAOD_STANDALONE
93 StatusCode::enableFailure();
103 #ifndef XAOD_STANDALONE
◆ minimalTest()
bool minimalTest |
( |
const std::string & |
type, |
|
|
const std::vector< std::string > & |
config, |
|
|
Store_t & |
store, |
|
|
Result & |
result |
|
) |
| |
◆ parallelJob()
bool parallelJob |
( |
const std::string & |
type, |
|
|
const std::vector< std::string > & |
config, |
|
|
Store_t & |
store, |
|
|
const std::string & |
saveAs, |
|
|
int |
nEvents, |
|
|
int |
eventOffset |
|
) |
| |
Definition at line 163 of file fbtTestBasics.cxx.
169 std::unique_ptr<TFile>
f(TFile::Open(saveAs.c_str(),
"RECREATE"));
177 std::cout <<
"Parallel job stored intermediate yield " <<
value <<
" +" <<
up <<
" -" << down << std::endl;
◆ readFromROOT()
bool readFromROOT |
( |
std::vector< std::string > & |
config | ) |
|
Definition at line 309 of file fbtTestBasics.cxx.
312 config.emplace_back(
"fbt_efficiencies.root");
313 TH1D hElFake(
"FakeEfficiency_el_pt",
"FakeEfficiency", 1, 10., 100.);
314 hElFake.SetBinContent(1, 0.05);
315 hElFake.SetBinError(1, 0.01);
316 TH1D hMuFake(
"FakeEfficiency_mu_pt",
"FakeEfficiency", 1, 10., 100.);
317 hMuFake.SetBinContent(1, 0.15);
318 hMuFake.SetBinError(1, 0.032);
319 TH1D hElReal(
"RealEfficiency_el_pt",
"RealEfficiency", 1, 10., 100.);
320 hElReal.SetBinContent(1, 0.90);
321 hElReal.SetBinError(1, 0.01);
322 TH1D hMuReal(
"RealEfficiency_mu_pt",
"RealEfficiency", 1, 10., 100.);
323 hMuReal.SetBinContent(1, 0.95);
324 hMuReal.SetBinError(1, 0.01);
325 std::unique_ptr<TFile>
f(TFile::Open(
config.back().c_str(),
"RECREATE"));
◆ readFromXML()
bool readFromXML |
( |
std::vector< std::string > & |
config | ) |
|
note: the declarations must be placed in the "good" order, otherwise the definitions of the SystematicVariations will be different than those obtained with readFromROOT()
Definition at line 336 of file fbtTestBasics.cxx.
339 config.emplace_back(
"fbt_efficiencies.xml");
344 out <<
"<efficiencies>\n";
345 out <<
"<param type=\"int\" level=\"event\"> flag </param>\n";
346 out <<
"<electron type=\"fake-efficiency\" input=\"central-value\" stat=\"per-bin\" >\n\t<bin flag=\"1\">\n 0.05 +- 0.01 (stat) </bin>\n</electron>\n";
347 out <<
"<electron type=\"real-efficiency\" input=\"central-value\" stat=\"global\" >\n\t<bin flag=\"1\">\n 0.90 +- 0.01 (stat) </bin>\n</electron>\n";
348 out <<
"<muon type=\"fake-efficiency\" input=\"central-value\" stat=\"per-bin\" >\n\t<bin flag=\"1\">\n 0.15 +- 0.032 (stat) </bin>\n</muon>\n";
349 out <<
"<muon type=\"real-efficiency\" input=\"central-value\" stat=\"global\" >\n\t<bin flag=\"1\">\n 0.95 +- 0.01 (stat) </bin>\n</muon>\n";
350 out <<
"</efficiencies>\n";
◆ setup()
template<class Interface = CP::IFakeBkgTool>
mostly useful for athena, which will otherwise re-use the previous tool
Definition at line 185 of file fbtTestBasics.cxx.
193 if(!progressFile.empty())
195 FBT_CHECK(
tool.setProperty(
"ProgressFileName", progressFile) );
196 FBT_CHECK(
tool.setProperty(
"ProgressFileDirectory",
"fakes") );
◆ successful() [1/2]
bool successful |
( |
bool |
arg | ) |
|
◆ successful() [2/2]
bool successful |
( |
const StatusCode & |
arg | ) |
|
◆ nEvents
◆ process
const std::string process = ">=1F[T]" |
◆ readCPVariations
const bool readCPVariations = true |
◆ selection
const std::string selection = ">=1T" |
◆ verbose
std::atomic<bool> verbose = false |
std::atomic< bool > verbose
const bool readCPVariations
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile="")
mostly useful for athena, which will otherwise re-use the previous tool
@ kClassAccess
Access auxiliary data using the aux containers.
Class providing the definition of the 4-vector interface.
bool eventLoop(asg::AnaToolHandle< Interface > &tool, Store_t &store, Result &result, int nEvents, int eventOffset=0)
bool minimalTest(const std::string &type, const std::vector< std::string > &config, Store_t &store, Result &result)
#define FBT_CHECK1(x, FAIL)
bool successful(bool arg)
IAppMgrUI * Init(const char *options="POOLRootAccess/basic.opts")
Bootstraps (creates and configures) the Gaudi Application with the provided options file.
The Athena Transient Store API.
bool allTests(Store_t &store)
POOL::TEvent event(POOL::TEvent::kClassAccess)
bool readFromXML(std::vector< std::string > &config)
bool fillResult(asg::AnaToolHandle< Interface > &tool, Result &result)
const std::string selection
std::string to_string(const DetectorType &type)
ServiceHandle< StoreGateSvc > & evtStore()
void record(const T *p, const std::string &key)
bool readFromROOT(std::vector< std::string > &config)
bool addEventWeight(asg::AnaToolHandle< CP::ILinearFakeBkgTool > &tool, Result &result)
const std::string process
bool parallelJob(const std::string &type, const std::vector< std::string > &config, Store_t &store, const std::string &saveAs, int nEvents, int eventOffset)
constexpr int pow(int base, int exp) noexcept
Tool for accessing xAOD files outside of Athena.
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.