28 std::shared_ptr<std::vector<m_pair_t>> histArray =
nullptr;
33 else if (nProng == 1) {
37 else if (nProng == 2) {
41 else if (nProng == 3) {
47 return StatusCode::FAILURE;
51 return StatusCode::FAILURE;
54 std::string fullPath =
find_file(fileName);
55 std::unique_ptr<TFile>
file(TFile::Open(fullPath.c_str(),
"READ"));
59 return StatusCode::FAILURE;
62 ATH_MSG_INFO(
"Loading working points [" << nProng <<
"-prong]: " << fullPath.c_str());
65 for (
int i = 0; i < 100; ++i) {
67 TH2* graph =
dynamic_cast<TH2*
>(
file->Get(Form(
"h2_%02d", i)));
69 ATH_MSG_ERROR(
"Failed to retrieve Graph " << i <<
" named " << Form(
"h2_%02d", i));
70 return StatusCode::FAILURE;
72 graph->SetDirectory(
nullptr);
73 std::shared_ptr<TH2> sharedGraph(graph);
74 histArray->push_back(
m_pair_t(
float(i)/100., std::move(sharedGraph)));
79 return StatusCode::SUCCESS;
84 std::shared_ptr<std::vector<m_pair_t>> histArray =
nullptr;
88 else if (nProng == 1) {
91 else if (nProng == 2) {
94 else if (nProng == 3) {
99 return StatusCode::FAILURE;
103 return StatusCode::FAILURE;
105 std::shared_ptr<TH2> firstHist = histArray->at(0).second;
106 m_xMin[nProng] = firstHist->GetXaxis()->GetXmin();
107 m_xMax[nProng] = firstHist->GetXaxis()->GetBinCenter(firstHist->GetNbinsX());
108 m_yMin[nProng] = firstHist->GetYaxis()->GetXmin();
109 m_yMax[nProng] = firstHist->GetYaxis()->GetBinCenter(firstHist->GetNbinsY());
112 for (
size_t i = 1; i < histArray->size(); ++i) {
113 std::shared_ptr<TH2> hist = histArray->at(i).second;
115 double xMin = hist->GetXaxis()->GetXmin();
116 double xMax = hist->GetXaxis()->GetBinCenter(firstHist->GetNbinsX());
117 double yMin = hist->GetYaxis()->GetXmin();
118 double yMax = hist->GetYaxis()->GetBinCenter(firstHist->GetNbinsY());
120 if (std::abs(
m_xMin[nProng] - xMin) > 1e-5 ||
121 std::abs(
m_xMax[nProng] - xMax) > 1e-5 ||
122 std::abs(
m_yMin[nProng] - yMin) > 1e-5 ||
123 std::abs(
m_yMax[nProng] - yMax) > 1e-5) {
128 return StatusCode::SUCCESS;
133 double efficiency = effLow + (score - cutLow)/(cutHigh - cutLow) * (effHigh - effLow);
142 ATH_MSG_ERROR(
"TauContainerName is provided but DecorWPNames is empty");
143 return StatusCode::FAILURE;
145 for (
size_t wpIndex=0; wpIndex <
m_decorWPs.size(); ++wpIndex) {
161 return StatusCode::FAILURE;
166 m_hists0p = std::make_shared<std::vector<m_pair_t>>();
171 m_hists1p = std::make_shared<std::vector<m_pair_t>>();
177 m_hists2p = std::make_shared<std::vector<m_pair_t>>();
184 m_hists3p = std::make_shared<std::vector<m_pair_t>>();
190 return StatusCode::SUCCESS;
197 double xVariable = tau.
pt();
200 double yVariable = 0.0;
203 yVariable = std::abs(acc_absEta(tau));
209 return StatusCode::FAILURE;
211 yVariable = eventInfoDecorHandle(0);
215 int nProng = nTracks;
226 else if (nTracks > 2) {
239 xVariable = std::min(
m_xMax.at(nProng), std::max(
m_xMin.at(nProng), xVariable));
240 yVariable = std::min(
m_yMax.at(nProng), std::max(
m_yMin.at(nProng), yVariable));
250 std::shared_ptr<std::vector<m_pair_t>> histArray =
nullptr;
252 else if (nProng == 1) histArray =
m_hists1p;
253 else if (nProng == 2) histArray =
m_hists2p;
256 std::array<double, 2> cuts = {-1.01, 1.01};
257 std::array<double, 2> effs = {1.0, 0.0};
259 bool gotHigh =
false;
262 double score = acc_score(tau);
265 for (
unsigned int i = 0; i < histArray->size(); ++i) {
266 std::shared_ptr<TH2> myHist = histArray->at(i).second;
267 double myCut = myHist->Interpolate(xVariable, yVariable);
269 if (myCut <= score && ((!gotLow) || std::abs(myCut-score) < std::abs(cuts[0]-score))) {
271 effs[0] = histArray->at(i).first;
274 else if (myCut > score && ((!gotHigh) || std::abs(myCut-score) < std::abs(cuts[1]-score))) {
276 effs[1] = histArray->at(i).first;
280 if (gotLow && gotHigh){
286 double scoreTrans = -1111.;
287 if (score > cuts[1]) {
288 scoreTrans = 1 - effs[1];
290 else if (score < cuts[0]) {
291 scoreTrans = 1 - effs[0];
294 scoreTrans =
transformScore(score, cuts[0], effs[0], cuts[1], effs[1]);
298 acc_scoreTrans(tau) = scoreTrans;
302 for (
size_t wpIndex=0; wpIndex <
m_EDMWPs.size(); ++wpIndex) {
306 else if(nProng == 1) {
309 else if(nProng == 2) {
317 for (
size_t wpIndex=0; wpIndex <
m_decorWPs.size(); ++wpIndex) {
323 else if(nProng == 1) {
326 else if(nProng == 2) {
335 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
bool isPresent() const
Is the referenced container present in SG?
StatusCode storeLimits(int nProng)
Obtain the limit of the dependent variables.
Gaudi::Property< std::string > m_scoreNameTrans
Gaudi::Property< std::vector< float > > m_EDMWPEffs0p
Gaudi::Property< std::vector< float > > m_EDMWPEffs3p
std::map< int, double > m_yMin
Map of n-prong and the minimum value of y variables.
Gaudi::Property< std::vector< float > > m_EDMWPEffs1p
Gaudi::Property< std::string > m_file3p
Gaudi::Property< std::string > m_tauContainerName
Gaudi::Property< std::vector< std::string > > m_decorWPs
double transformScore(double score, double cutLow, double effLow, double cutHigh, double effHigh) const
Obtain the flattened score.
std::shared_ptr< std::vector< m_pair_t > > m_hists1p
Efficiency and corresponding score distributions of 1-prong taus.
Gaudi::Property< std::vector< float > > m_decorWPEffs0p
std::shared_ptr< std::vector< m_pair_t > > m_hists0p
Efficiency and corresponding score distributions of 0-prong taus.
Gaudi::Property< std::vector< int > > m_EDMWPs
Gaudi::Property< std::vector< float > > m_decorWPEffs1p
Gaudi::Property< bool > m_defineWPs
Gaudi::Property< std::vector< float > > m_EDMWPEffs2p
Gaudi::Property< std::string > m_scoreName
virtual StatusCode initialize() override
Initialization of this tool.
Gaudi::Property< std::string > m_file0p
Gaudi::Property< std::string > m_file1p
std::map< int, double > m_yMax
Map of n-prong and the maximum value of y variables.
SG::WriteDecorHandleKeyArray< xAOD::TauJetContainer > m_decorHandleKeys
virtual StatusCode execute(xAOD::TauJet &tau) const override
Executation of this tool.
std::map< int, double > m_xMax
Map of n-prong and the maximum value of x variables.
std::map< int, double > m_xMin
Map of n-prong and the minimum value of x variables.
std::shared_ptr< std::vector< m_pair_t > > m_hists3p
Efficiency and corresponding score distributions of 3-prong taus.
SG::ReadDecorHandleKey< xAOD::EventInfo > m_aveIntPerXKey
StatusCode retrieveHistos(int nProng)
Retrieve the histograms containing BDT/RNN score distributions as a function of dependent variables.
std::pair< double, std::shared_ptr< TH2 > > m_pair_t
std::vector< SG::Accessor< char > > m_charDecors
Gaudi::Property< std::vector< float > > m_decorWPEffs2p
Gaudi::Property< bool > m_useAbsEta
std::shared_ptr< std::vector< m_pair_t > > m_hists2p
Efficiency and corresponding score distributions of 2-prong taus.
~TauWPDecorator()
Destructor.
Gaudi::Property< std::string > m_file2p
TauWPDecorator(const std::string &name="TauWPDecorator")
Constructor.
Gaudi::Property< std::vector< float > > m_decorWPEffs3p
virtual double pt() const
The transverse momentum ( ) of the particle.
void setIsTau(TauJetParameters::IsTauFlag flag, bool value)
Set Flag for tau acceptance based on predefined arbitrary criteria.
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
IsTauFlag
Enum for IsTau flags.
TauJet_v3 TauJet
Definition of the current "tau version".