3 #include <FWCore/ParameterSet/interface/ParameterSet.h>
4 #include <FWCore/Utilities/interface/EDMException.h>
6 #include <cp3_llbb/Framework/interface/Histogram.h>
7 #include <cp3_llbb/Framework/interface/BinnedValues.h>
8 #include <cp3_llbb/TreeWrapper/interface/TreeWrapper.h>
10 #include <boost/property_tree/ptree.hpp>
16 enum class Algorithm {
31 enum class SystFlavor {
39 typedef std::tuple<Algorithm, SystFlavor, std::string> branch_key_type;
40 typedef std::tuple<Algorithm, Flavor, std::string> sf_key_type;
42 static std::array<SystFlavor, 2> SystFlavors;
49 virtual void create_branches(
const edm::ParameterSet&)
final;
51 virtual void store_scale_factors(Algorithm algo, Flavor flavor,
const Parameters&,
bool isData)
final;
53 virtual bool has_scale_factors(Algorithm algo)
final {
54 return m_algos.count(algo) != 0;
58 virtual float get_scale_factor(Algorithm algo, Flavor flavor,
const std::string& wp,
size_t index, Variation variation = Variation::Nominal)
final;
61 ROOT::TreeGroup& m_tree;
63 std::map<branch_key_type, std::vector<std::vector<float>>*> m_branches;
64 std::map<sf_key_type, std::unique_ptr<BinnedValues>> m_scale_factors;
66 std::map<Algorithm, std::vector<std::string>> m_algos;
69 static inline std::string algorithm_to_string(Algorithm algo) {
74 case Algorithm::CSVv2:
80 case Algorithm::cMVAv2:
83 case Algorithm::DeepCSV:
91 static inline Algorithm string_to_algorithm(
const std::string& algo) {
92 if ((algo ==
"csv") || (algo ==
"combinedSecondaryVertexBJetTags"))
93 return Algorithm::CSV;
95 if ((algo ==
"csvv2") || (algo ==
"pfCombinedInclusiveSecondaryVertexV2BJetTags"))
96 return Algorithm::CSVv2;
98 if ((algo ==
"jp") || (algo ==
"pfJetProbabilityBJetTags"))
101 if ((algo ==
"cmvav2") || (algo ==
"pfCombinedMVAV2BJetTags"))
102 return Algorithm::cMVAv2;
104 if ((algo ==
"deepCSV") || (algo ==
"pfDeepCSVJetTags:probb"))
105 return Algorithm::DeepCSV;
107 return Algorithm::UNKNOWN;
110 static inline std::string flavor_to_string(Flavor flavor) {
122 throw edm::Exception(edm::errors::NotFound,
"Unsupported flavor");
125 static inline SystFlavor flavor_to_syst_flavor(Flavor flavor) {
129 return SystFlavor::HEAVY;
132 return SystFlavor::LIGHT;
135 throw edm::Exception(edm::errors::NotFound,
"Unsupported flavor");
138 static inline std::string syst_flavor_to_string(SystFlavor flavor) {
140 case SystFlavor::HEAVY:
143 case SystFlavor::LIGHT:
147 throw edm::Exception(edm::errors::NotFound,
"Unsupported syst flavor");
150 static inline Flavor string_to_flavor(
const std::string& flavor) {
151 if (flavor ==
"bjets")
153 else if (flavor ==
"cjets")
155 else if (flavor ==
"lightjets")
156 return Flavor::LIGHT;
158 throw edm::Exception(edm::errors::NotFound,
"Unsupported flavor: " + flavor);
161 static inline Flavor get_flavor(
int hadron_flavor) {
162 switch (hadron_flavor) {
170 return Flavor::LIGHT;
Definition: BTaggingScaleFactors.h:36
Definition: BinnedValues.h:67