1 #ifndef FAT_JETS_PRODUCER
2 #define FAT_JETS_PRODUCER
4 #include <cp3_llbb/Framework/interface/CandidatesProducer.h>
5 #include <cp3_llbb/Framework/interface/BTaggingScaleFactors.h>
7 #include <DataFormats/PatCandidates/interface/Jet.h>
11 FatJetsProducer(
const std::string& name,
const ROOT::TreeGroup&
tree,
const edm::ParameterSet& config):
14 BTaggingScaleFactors::create_branches(config);
16 if (config.exists(
"btags")) {
17 const std::vector<std::string>& btags = config.getUntrackedParameter<std::vector<std::string>>(
"btags");
20 for (
const std::string& btag: btags) {
21 std::string branchName{btag};
22 std::replace(std::begin(branchName), std::end(branchName),
':',
'_');
27 if (config.exists(
"subjets_btags")) {
28 m_subjets_btag_discriminators = config.getUntrackedParameter<std::vector<std::string>>(
"subjets_btags");
31 for (
const std::string& btag: m_subjets_btag_discriminators) {
32 m_softdrop_btag_discriminators_branches.emplace(btag,
34 m_softdrop_puppi_btag_discriminators_branches.emplace(btag,
38 Njettinesstau1 = config.getUntrackedParameter<std::string>(
"Njettinesstau1",
"NjettinessAK8:tau1");
39 Njettinesstau2 = config.getUntrackedParameter<std::string>(
"Njettinesstau2",
"NjettinessAK8:tau2");
40 Njettinesstau3 = config.getUntrackedParameter<std::string>(
"Njettinesstau3",
"NjettinessAK8:tau3");
41 SoftDropSubjets = config.getUntrackedParameter<std::string>(
"SoftDropSubjets",
"SoftDrop");
42 SoftDropPuppiSubjets = config.getUntrackedParameter<std::string>(
"SoftDropPuppiSubjets",
"SoftDropPuppi");
47 virtual void doConsumes(
const edm::ParameterSet& config, edm::ConsumesCollector&& collector)
override {
48 m_jets_token = collector.consumes<std::vector<pat::Jet>>(config.getUntrackedParameter<edm::InputTag>(
"jets", edm::InputTag(
"slimmedJetsAK8")));
51 virtual void produce(edm::Event& event,
const edm::EventSetup& eventSetup)
override;
53 float getBTagDiscriminant(
size_t index,
const std::string& name)
const {
54 return m_btag_discriminators.at(name)->at(index);
57 float getSoftDropBTagDiscriminant(
size_t index,
size_t sj_index,
const std::string& btag_name)
const {
58 return m_softdrop_btag_discriminators_branches.at(btag_name)->at(index).at(sj_index);
61 float getSoftDropPuppiBTagDiscriminant(
size_t index,
size_t sj_index,
const std::string& btag_name)
const {
62 return m_softdrop_puppi_btag_discriminators_branches.at(btag_name)->at(index).at(sj_index);
65 float get_scale_factor(Algorithm algo,
const std::string& wp,
size_t index, Variation variation = Variation::Nominal);
70 edm::EDGetTokenT<std::vector<pat::Jet>> m_jets_token;
72 std::map<std::string, std::vector<float>*> m_btag_discriminators;
74 std::vector<std::string> m_subjets_btag_discriminators;
75 std::map<std::string, std::vector<std::vector<float>>*> m_softdrop_btag_discriminators_branches;
76 std::map<std::string, std::vector<std::vector<float>>*> m_softdrop_puppi_btag_discriminators_branches;
78 std::string Njettinesstau1;
79 std::string Njettinesstau2;
80 std::string Njettinesstau3;
81 std::string SoftDropSubjets;
82 std::string SoftDropPuppiSubjets;
86 std::vector<float>& area =
tree[
"area"].write<std::vector<float>>();
87 std::vector<int8_t>& partonFlavor =
tree[
"partonFlavor"].write<std::vector<int8_t>>();
88 std::vector<int8_t>& hadronFlavor =
tree[
"hadronFlavor"].write<std::vector<int8_t>>();
91 std::vector<int8_t>& systFlavor =
tree[
"systFlavor"].write<std::vector<int8_t>>();
93 std::vector<float>& jecFactor =
tree[
"jecFactor"].write<std::vector<float>>();
95 BRANCH(passLooseID, std::vector<bool>);
96 BRANCH(passTightID, std::vector<bool>);
97 BRANCH(passTightLeptonVetoID, std::vector<bool>);
99 BRANCH(tau1, std::vector<float>);
100 BRANCH(tau2, std::vector<float>);
101 BRANCH(tau3, std::vector<float>);
103 BRANCH(puppi_p4, std::vector<LorentzVector>);
104 BRANCH(puppi_tau1, std::vector<float>);
105 BRANCH(puppi_tau2, std::vector<float>);
106 BRANCH(puppi_tau3, std::vector<float>);
108 BRANCH(softdrop_mass, std::vector<float>);
109 BRANCH(pruned_mass, std::vector<float>);
111 BRANCH(softdrop_subjets_p4, std::vector<std::vector<LorentzVector>>);
112 BRANCH(softdrop_puppi_subjets_p4, std::vector<std::vector<LorentzVector>>);
Definition: BTaggingScaleFactors.h:36
Definition: CandidatesProducer.h:9
Definition: FatJetsProducer.h:9
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: FatJetsProducer.h:47
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: FatJetsProducer.cc:5
ROOT::TreeGroup tree
Access point to output tree.
Definition: Producer.h:132