Skip to content

Commit 9722fcd

Browse files
author
Martino Dall'Osso
authored
Merge pull request #44 from cms-hh-pd/moriond17_dev
align master to moriond17dev to use new ntuples
2 parents 93e9a29 + e32c139 commit 9722fcd

25 files changed

+4406
-163
lines changed

data/CSVv2_Moriond17_B_H.csv

Lines changed: 1918 additions & 0 deletions
Large diffs are not rendered by default.

data/DeepCSV_Moriond17_B_H.csv

Lines changed: 250 additions & 0 deletions
Large diffs are not rendered by default.

data/cMVAv2_Moriond17_B_H.csv

Lines changed: 1672 additions & 0 deletions
Large diffs are not rendered by default.

interface/BTagFilterOperator.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#include "Event.h"
1010
#include "Utils.h"
1111

12-
constexpr auto CSV_name = "pfCombinedInclusiveSecondaryVertexV2BJetTags";
13-
constexpr auto CMVA_name = "pfCombinedMVAV2BJetTags";
14-
1512
template <class EventClass> class BTagFilterOperator : public BaseOperator<EventClass> {
1613

1714
public:
@@ -63,7 +60,7 @@ constexpr auto CMVA_name = "pfCombinedMVAV2BJetTags";
6360
"up_lfstats1", "down_lfstats1",
6461
"up_lfstats2", "down_lfstats2"}}};
6562

66-
btcalib = BTagCalibration(s_name_map.at(disc), data_path+s_name_map.at(disc)+"_ichep.csv");
63+
btcalib = BTagCalibration(s_name_map.at(disc), data_path+s_name_map.at(disc)+"_Moriond17_B_H.csv"); //_ichep.csv
6764

6865
cr_map.emplace("central",
6966
BTagCalibrationReader{BTagEntry::OP_RESHAPING,
@@ -112,8 +109,9 @@ constexpr auto CMVA_name = "pfCombinedMVAV2BJetTags";
112109
}
113110
}
114111

115-
for (auto & jet : ev.jets_) {
116-
if(!isdata_) {
112+
113+
if(!isdata_) {
114+
for (auto & jet : ev.jets_) {
117115
auto jet_flavour = flavour_map.at(jet.hadronFlavour());
118116
auto jet_eta = jet.eta();
119117
auto jet_pt = jet.pt();
@@ -145,7 +143,6 @@ constexpr auto CMVA_name = "pfCombinedMVAV2BJetTags";
145143
weight_map.at("BTagWeight_"+syst) *= syst_sf;
146144
if (per_jet_sf_) jet.discs_.emplace_back("BTagWeight_"+syst,central_sf);
147145
}
148-
149146
}
150147
}
151148

interface/ComposableSelector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ template <class EventClass> bool ComposableSelector<EventClass>::Process(Long64
173173
{
174174

175175
n_entries++;
176-
if (n_entries>300000 && (n_entries%((int)tot_entries/5)) == 0) std::cout << "processing " << n_entries << " entry" << std::endl;
176+
if (n_entries>300000 && (n_entries%((int)tot_entries/5)) == 0) std::cout << "processing " << n_entries << " entry" << std::endl;
177177

178-
// set TTreeReader entry
178+
// set TTreeReader entry
179179
reader_.SetLocalEntry(entry);
180180
// update event objects
181181
ev_.update();

interface/EventWriterOperator.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ template <class EventClass> class EventWriterOperator : public BaseOperator<Even
1818
alp::EventInfo * eventInfo_ptr = nullptr;
1919

2020
std::vector<std::string> weights_;
21+
bool hasGen_;
2122

2223
// variables to save in branches
2324
float_t evtWeight = 1.;
@@ -38,7 +39,10 @@ template <class EventClass> class EventWriterOperator : public BaseOperator<Even
3839

3940
EventWriterOperator(const std::string & config_s, const std::vector<std::string> & weights = {}) :
4041
config_(json::parse(config_s)),
41-
weights_(weights) {}
42+
weights_(weights) {
43+
if(config_s.find("isSignal")) hasGen_ = true;
44+
else hasGen_ = false;
45+
}
4246

4347
virtual ~EventWriterOperator() {}
4448

@@ -113,7 +117,7 @@ template <class EventClass> class EventWriterOperator : public BaseOperator<Even
113117
tl_genhs_ptr = dynamic_cast<std::vector<alp::Candidate> *>(&ev.tl_genhs_);
114118

115119
ev.tl_genhh_.clear();
116-
ev.tl_genhh_.emplace_back(ev.tl_genhs_.at(0).p4_ , ev.tl_genhs_.at(1).p4_); // check if reasonable
120+
//if(hasGen_) ev.tl_genhh_.emplace_back(ev.tl_genhs_.at(0).p4_ , ev.tl_genhs_.at(1).p4_); #FIXME
117121
tl_genhh_ptr = dynamic_cast<std::vector<alp::DiObject> *>(&ev.tl_genhh_);
118122
dijets_ptr = dynamic_cast<std::vector<alp::DiObject> *>(&ev.dijets_);
119123
dihiggs_ptr = dynamic_cast<std::vector<alp::DiObject> *>(&ev.dihiggs_);

interface/Hemisphere.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ namespace alp {
6464
}
6565

6666
static int nTags(const Hemisphere & hem,
67-
std::string disc = "pfCombinedInclusiveSecondaryVertexV2BJetTags",
68-
float wp = 0.8) {
67+
std::string disc,
68+
float wp) {
6969
int nTags = 0;
7070
for (const auto & j : hem.jets_) {
7171
if (j.disc(disc) > wp) nTags++;
@@ -94,7 +94,7 @@ namespace alp {
9494
return nJets(*this);
9595
}
9696

97-
int getNTags(std::string disc = "pfCombinedInclusiveSecondaryVertexV2BJetTags", float wp = 0.8) {
97+
int getNTags(std::string disc, float wp) {
9898
return nTags(*this,disc,wp);
9999
}
100100

interface/HemisphereMixerOperator.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
107107

108108
public:
109109

110-
typedef std::function<int(const alp::Hemisphere &)> FuncI;
111-
typedef std::vector<std::function<int(const alp::Hemisphere &)>> FuncIVec;
110+
typedef std::function<int(const alp::Hemisphere &, std::string , double )> FuncI;
111+
typedef std::vector<std::function<int(const alp::Hemisphere &, std::string , double)>> FuncIVec;
112112
typedef std::function<double(const alp::Hemisphere &)> FuncD;
113113
typedef std::vector<std::function<double(const alp::Hemisphere &)>> FuncDVec;
114114
typedef std::vector<alp::Hemisphere> HemVec;
@@ -119,6 +119,8 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
119119
nanoflann::L2_Simple_Adaptor<double, HemisphereLibrary>,
120120
HemisphereLibrary > my_kd_tree_t;
121121

122+
std::string btagAlgo_;
123+
double btagCut_;
122124
// map of vectors of hemipsheres (key is integer category)
123125
std::map<IntVec, HemVec> hem_m_;
124126
std::map<IntVec, HemisphereLibrary> hem_lib_;
@@ -135,23 +137,25 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
135137
std::size_t knn_;
136138

137139
HemisphereMixerOperator( TChain * tc_hm,
140+
std::string btagAlgo, double btagCut,
138141
std::vector<std::string> nn_vars = { "thrustMayor","thrustMinor",
139-
"sumPz","invMass"},
142+
"sumPz","invMass"},
140143
Scaling scaling = Scaling::set,
141144
std::size_t knn = 10) :
145+
btagAlgo_(btagAlgo),
146+
btagCut_(btagCut),
142147
scaling_(scaling),
143148
var_stds_(nn_vars.size(), 0.0),
144-
knn_(knn) {
145-
146-
funcIVec_ = { FuncI( [] (const alp::Hemisphere & hem) {
149+
knn_(knn)
150+
{
151+
funcIVec_ = { FuncI( [] (const alp::Hemisphere & hem, std::string disc, double cut) {
147152
int nJets = alp::Hemisphere::nJets(hem);
148153
return ( nJets > 3 ? 4 : nJets);
149154
}),
150-
FuncI( [] (const alp::Hemisphere & hem) {
151-
int nTags = alp::Hemisphere::nTags(hem,
152-
"pfCombinedInclusiveSecondaryVertexV2BJetTags", 0.800);
155+
FuncI( [] (const alp::Hemisphere & hem, std::string disc, double cut) {
156+
int nTags = alp::Hemisphere::nTags(hem, disc, cut);
153157
return ( nTags > 3 ? 4 : nTags);
154-
})};
158+
})};
155159

156160
FuncDMap funcDMap = {{"thrustMayor", FuncD(&alp::Hemisphere::thrustMayor)},
157161
{"thrustMinor",FuncD(&alp::Hemisphere::thrustMinor)},
@@ -181,7 +185,7 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
181185
hem_reader.SetEntry(chainEntry);
182186
for (const auto & hem : *hems) {
183187
IntVec cat;
184-
for (const auto & funcI : funcIVec_) cat.emplace_back(funcI(hem));
188+
for (const auto & funcI : funcIVec_) cat.emplace_back(funcI(hem, btagAlgo_, btagCut_));
185189
if (hem_m_.count(cat) < 1) hem_m_[cat] = {};
186190
hem_m_.at(cat).emplace_back(hem);
187191
}
@@ -191,7 +195,7 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
191195
while (hem_reader.Next()) {
192196
for (const auto & hem : *hems) {
193197
IntVec cat;
194-
for (const auto & funcI : funcIVec_) cat.emplace_back(funcI(hem));
198+
for (const auto & funcI : funcIVec_) cat.emplace_back(funcI(hem, btagAlgo_, btagCut_));
195199
if (hem_m_.count(cat) < 1) hem_m_[cat] = {};
196200
hem_m_.at(cat).emplace_back(hem);
197201
}
@@ -258,7 +262,7 @@ template <class EventClass> class HemisphereMixerOperator : public BaseOperator<
258262

259263
// get integer category
260264
std::vector<int> h_cat;
261-
for (const auto & funcI : funcIVec_) h_cat.emplace_back(funcI(h));
265+
for (const auto & funcI : funcIVec_) h_cat.emplace_back(funcI(h, btagAlgo_, btagCut_));
262266
if (index_m_.count(h_cat) < 1) {
263267
std::cout << "No index for category: " << h_cat << std::endl;
264268
return false; // remove event

interface/JERShifterOperator.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
#pragma once
3+
4+
#include <algorithm>
5+
6+
#include "BaseOperator.h"
7+
#include "Event.h"
8+
9+
template <class EventClass> class JERShifterOperator : public BaseOperator<EventClass> {
10+
11+
public:
12+
13+
bool shiftUp_;
14+
15+
JERShifterOperator(bool shiftUp) :
16+
shiftUp_(shiftUp) {}
17+
virtual ~JERShifterOperator() {}
18+
19+
virtual bool process( EventClass & ev ) {
20+
21+
//get corrected pt and shift by uncertainty
22+
for (auto it = ev.jets_.begin(); it!=ev.jets_.end(); ++it) {
23+
(*it).p4_ *= (1./(*it).JERunc()); //NOTE: to restore default pT
24+
if (shiftUp_) (*it).p4_ *= ((*it).JERuncUp());
25+
else (*it).p4_ *= ((*it).JERuncDown());
26+
};
27+
return true;
28+
}
29+
30+
virtual std::string get_name() {
31+
auto name = std::string{};
32+
name+= "JER"+std::to_string(shiftUp_);
33+
return name;
34+
}
35+
36+
};

interface/JetPlotterOperator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ template <class EventClass> class JetPlotterOperator : public BaseOperator<Event
2323
TH1D h_jets_cmva {"h_jets_cmva", "jets cmva", 300, -1., 1.};
2424

2525
TH1D h_jet0_cmva {"h_jet0_cmva", "jet0 cmva", 300, -1., 1.};
26-
TH1D h_jet1_cmva {"h_jet1_cmva", "jet2 cmva", 300, -1., 1.};
26+
TH1D h_jet1_cmva {"h_jet1_cmva", "jet1 cmva", 300, -1., 1.};
2727
TH1D h_jet2_cmva {"h_jet2_cmva", "jet2 cmva", 300, -1., 1.};
2828
TH1D h_jet3_cmva {"h_jet3_cmva", "jet3 cmva", 300, -1., 1.};
2929

0 commit comments

Comments
 (0)