ATLAS Offline Software
Loading...
Searching...
No Matches
CalibrationDataInterfaceTester.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// CalibrationDataInterfaceTester.cxx, (c) ATLAS Detector software
8
9
12#include "JetEvent/Jet.h"
15#include <algorithm>
16#include <utility>
17#include <cctype>
18
19using std::string;
21
22//================ Constructor =================================================
23
24Analysis::CalibrationDataInterfaceTester::CalibrationDataInterfaceTester(const std::string& name, ISvcLocator* pSvcLocator)
25 : AthAlgorithm(name, pSvcLocator)
26{
27 // template for property declaration
28 declareProperty("JetCollection", m_jetCollection, "name of the jet collection to be used");
29 declareProperty("Tagger", m_tagger, "name of the tagging algorithm to be used");
30 declareProperty("OperatingPoint", m_operatingPoint, "name of the tagging algorithm operating point to be used");
31 declareProperty("CalibrationUncertainty", m_calibrationUncertainty, "calibration uncertainty result");
32 declareProperty("CalibrationInterface", m_calibrationInterface, "interface tool instance name");
33}
34
35//================ Initialisation =================================================
36
38{
39
40
41 ATH_CHECK(m_JetCollectionKey.initialize());
42
43 StatusCode sc = m_calibrationInterface.retrieve();
44 if (sc.isFailure()) {
45 ATH_MSG_ERROR("initialize() in " << name() << ": unable to retrieve "
46 << "calibration interface tool!");
47 return sc;
48 }
49
50 std::transform(m_calibrationUncertainty.begin(), m_calibrationUncertainty.end(),
52 if (m_calibrationUncertainty.find("total") != string::npos) {
53 m_uncertaintyType = CalibrationDataInterfaceTool::Total;
54 } else if (m_calibrationUncertainty.find("syst") != string::npos) {
55 m_uncertaintyType = CalibrationDataInterfaceTool::Systematic;
56 } else if (m_calibrationUncertainty.find("stat") != string::npos) {
57 m_uncertaintyType = CalibrationDataInterfaceTool::Statistical;
58 } else {
59 m_uncertaintyType = CalibrationDataInterfaceTool::None;
60 }
61
62 ATH_MSG_INFO("initialize() successful in " << name());
63 return StatusCode::SUCCESS;
64}
65
66//================ Execution ====================================================
67
69{
70 // Code entered here will be executed once per event
71
72 // retrieve the desired jet collection
73 EventContext& ctx = Gaudi::Hive::currentContext();
75 ATH_CHECK(jets.isValid());
76
77 int njtag = (*jets).size();
78 ATH_MSG_INFO("JetCollection " << m_jetCollection
79 << " found with " << njtag << " jets.");
80
81 for (auto jetItr : jets) {
82 // --- get btagging weight for the tagger under consideration
83 double weight = (*jetItr)->getFlavourTagWeight(m_tagger);
84
85 // --- get the true label of the jet from MC Truth:
86 const Analysis::TruthInfo* mcinfo = (*jetItr)->tagInfo<Analysis::TruthInfo>("TruthInfo");
87 if (! mcinfo) {
88 ATH_MSG_DEBUG("could not find TruthInfo for matching jet");
89 continue;
90 }
91 string label = mcinfo->jetTruthLabel();
92
93 std::pair<double, double> sfResult =
95 std::pair<double, double> effResult =
97
98 ATH_MSG_DEBUG("Jet with " << m_tagger << " weight: " << weight);
99 ATH_MSG_DEBUG(" label: " << label);
100 ATH_MSG_DEBUG(" SF (unc.): " << sfResult.first
101 << "(" << sfResult.second << ")");
102 ATH_MSG_DEBUG(" eff (unc.): " << effResult.first << "(" << effResult.second << ")");
103
104 }
105
106 return StatusCode::SUCCESS;
107}
108
109//============================================================================================
110
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
void tolower(std::string &s)
static Double_t sc
std::string m_calibrationUncertainty
calibration uncertainty result
ToolHandle< ICalibrationDataInterfaceTool > m_calibrationInterface
pointer to the CalibrationDataInterfaceTool
SG::ReadHandleKey< JetCollection > m_JetCollectionKey
I/O handlers.
Gaudi::Property m_operatingPoint
tagger operating point
CalibrationDataInterfaceTool::Uncertainty m_uncertaintyType
CalibrationDataInterfaceTester(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
StatusCode initialize() override
standard Athena-Algorithm method
StatusCode execute() override
standard Athena-Algorithm method
hold: in particular, "channel" (jet author) aliasing is possible.
Class TruthInfo: Class to store more truth information about a JetTag (e.g.
Definition TruthInfo.h:19
const std::string & jetTruthLabel() const
return the truth label
Definition TruthInfo.h:79
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string label(const std::string &format, int i)
Definition label.h:19