41 const unsigned int n_cpf_ = 25;
42 const unsigned int n_npf_ = 25;
43 const unsigned int n_sv_ = 12;
50 constexpr static bool usePhysForLightAndUndefined =
false;
58 : nameDeepJet_(iConfig.getParameter<
std::
string>(
"nameDeepJet")),
59 idx_nameDeepJet_(iConfig.getParameter<
std::
string>(
"idx_nameDeepJet")),
60 n_cpf_(iConfig.getParameter<unsigned
int>(
"n_cpf")),
61 n_npf_(iConfig.getParameter<unsigned
int>(
"n_npf")),
62 n_sv_(iConfig.getParameter<unsigned
int>(
"n_sv")),
81 iEvent.getByToken(tag_info_src_, tag_infos);
85 std::vector<int> jet_N_CPFCands(
nJets);
86 std::vector<int> jet_N_NPFCands(
nJets);
87 std::vector<int> jet_N_PVs(
nJets);
88 std::vector<int> jet_N_SVs(
nJets);
91 std::vector<std::vector<float>> Cpfcan_BtagPf_trackEtaRel_nCpf(n_cpf_, std::vector<float>(
nJets));
92 std::vector<std::vector<float>> Cpfcan_BtagPf_trackPtRel_nCpf(n_cpf_, std::vector<float>(
nJets));
93 std::vector<std::vector<float>> Cpfcan_BtagPf_trackPPar_nCpf(n_cpf_, std::vector<float>(
nJets));
94 std::vector<std::vector<float>> Cpfcan_BtagPf_trackDeltaR_nCpf(n_cpf_, std::vector<float>(
nJets));
95 std::vector<std::vector<float>> Cpfcan_BtagPf_trackPParRatio_nCpf(n_cpf_, std::vector<float>(
nJets));
96 std::vector<std::vector<float>> Cpfcan_BtagPf_trackSip2dVal_nCpf(n_cpf_, std::vector<float>(
nJets));
97 std::vector<std::vector<float>> Cpfcan_BtagPf_trackSip2dSig_nCpf(n_cpf_, std::vector<float>(
nJets));
98 std::vector<std::vector<float>> Cpfcan_BtagPf_trackSip3dVal_nCpf(n_cpf_, std::vector<float>(
nJets));
99 std::vector<std::vector<float>> Cpfcan_BtagPf_trackSip3dSig_nCpf(n_cpf_, std::vector<float>(
nJets));
100 std::vector<std::vector<float>> Cpfcan_BtagPf_trackJetDistVal_nCpf(n_cpf_, std::vector<float>(
nJets));
101 std::vector<std::vector<float>> Cpfcan_ptrel_nCpf(n_cpf_, std::vector<float>(
nJets));
102 std::vector<std::vector<float>> Cpfcan_drminsv_nCpf(n_cpf_, std::vector<float>(
nJets));
103 std::vector<std::vector<int>> Cpfcan_VTX_ass_nCpf(n_cpf_, std::vector<int>(
nJets));
104 std::vector<std::vector<float>> Cpfcan_puppiw_nCpf(n_cpf_, std::vector<float>(
nJets));
105 std::vector<std::vector<float>> Cpfcan_chi2_nCpf(n_cpf_, std::vector<float>(
nJets));
106 std::vector<std::vector<int>> Cpfcan_quality_nCpf(n_cpf_, std::vector<int>(
nJets));
109 std::vector<std::vector<float>> Npfcan_ptrel_nNpf(n_npf_, std::vector<float>(
nJets));
110 std::vector<std::vector<float>> Npfcan_deltaR_nNpf(n_npf_, std::vector<float>(
nJets));
111 std::vector<std::vector<int>> Npfcan_isGamma_nNpf(n_npf_, std::vector<int>(
nJets));
112 std::vector<std::vector<float>> Npfcan_HadFrac_nNpf(n_npf_, std::vector<float>(
nJets));
113 std::vector<std::vector<float>> Npfcan_drminsv_nNpf(n_npf_, std::vector<float>(
nJets));
114 std::vector<std::vector<float>> Npfcan_puppiw_nNpf(n_npf_, std::vector<float>(
nJets));
122 std::vector<std::vector<float>> sv_mass_nSV(n_sv_, std::vector<float>(
nJets));
123 std::vector<std::vector<float>> sv_pt_nSV(n_sv_, std::vector<float>(
nJets));
124 std::vector<std::vector<int>> sv_ntracks_nSV(n_sv_, std::vector<int>(
nJets));
125 std::vector<std::vector<float>> sv_chi2_nSV(n_sv_, std::vector<float>(
nJets));
126 std::vector<std::vector<float>> sv_normchi2_nSV(n_sv_, std::vector<float>(
nJets));
127 std::vector<std::vector<float>> sv_dxy_nSV(n_sv_, std::vector<float>(
nJets));
128 std::vector<std::vector<float>> sv_dxysig_nSV(n_sv_, std::vector<float>(
nJets));
129 std::vector<std::vector<float>> sv_d3d_nSV(n_sv_, std::vector<float>(
nJets));
130 std::vector<std::vector<float>> sv_d3dsig_nSV(n_sv_, std::vector<float>(
nJets));
131 std::vector<std::vector<float>> sv_costhetasvpv_nSV(n_sv_, std::vector<float>(
nJets));
137 std::vector<std::vector<float>> sv_deltaR_nSV(n_sv_, std::vector<float>(
nJets));
138 std::vector<std::vector<float>> sv_enratio_nSV(n_sv_, std::vector<float>(
nJets));
140 if (!tag_infos->empty()) {
141 for (
unsigned i_jet = 0; i_jet <
nJets; ++i_jet) {
144 const auto& taginfo = (*tag_infos)[i_jet];
145 const auto&
features = taginfo.features();
149 jet_N_CPFCands[i_jet] =
features.c_pf_features.size();
150 jet_N_NPFCands[i_jet] =
features.n_pf_features.size();
151 jet_N_SVs[i_jet] =
features.sv_features.size();
155 auto max_c_pf_n =
std::min(
features.c_pf_features.size(), (std::size_t)n_cpf_);
156 for (std::size_t c_pf_n = 0; c_pf_n < max_c_pf_n; c_pf_n++) {
157 const auto& c_pf_features =
features.c_pf_features.at(c_pf_n);
158 Cpfcan_BtagPf_trackEtaRel_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackEtaRel;
159 Cpfcan_BtagPf_trackPtRel_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackPtRel;
160 Cpfcan_BtagPf_trackPPar_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackPPar;
161 Cpfcan_BtagPf_trackDeltaR_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackDeltaR;
162 Cpfcan_BtagPf_trackPParRatio_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackPParRatio;
163 Cpfcan_BtagPf_trackSip2dVal_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackSip2dVal;
164 Cpfcan_BtagPf_trackSip2dSig_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackSip2dSig;
165 Cpfcan_BtagPf_trackSip3dVal_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackSip3dVal;
166 Cpfcan_BtagPf_trackSip3dSig_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackSip3dSig;
167 Cpfcan_BtagPf_trackJetDistVal_nCpf[c_pf_n][i_jet] = c_pf_features.btagPf_trackJetDistVal;
168 Cpfcan_ptrel_nCpf[c_pf_n][i_jet] = c_pf_features.ptrel;
169 Cpfcan_drminsv_nCpf[c_pf_n][i_jet] = c_pf_features.drminsv;
170 Cpfcan_VTX_ass_nCpf[c_pf_n][i_jet] = c_pf_features.vtx_ass;
171 Cpfcan_puppiw_nCpf[c_pf_n][i_jet] = c_pf_features.puppiw;
172 Cpfcan_chi2_nCpf[c_pf_n][i_jet] = c_pf_features.chi2;
173 Cpfcan_quality_nCpf[c_pf_n][i_jet] = c_pf_features.quality;
177 auto max_n_pf_n =
std::min(
features.n_pf_features.size(), (std::size_t)n_npf_);
178 for (std::size_t n_pf_n = 0; n_pf_n < max_n_pf_n; n_pf_n++) {
179 const auto& n_pf_features =
features.n_pf_features.at(n_pf_n);
180 Npfcan_ptrel_nNpf[n_pf_n][i_jet] = n_pf_features.ptrel;
181 Npfcan_deltaR_nNpf[n_pf_n][i_jet] = n_pf_features.deltaR;
182 Npfcan_isGamma_nNpf[n_pf_n][i_jet] = n_pf_features.isGamma;
183 Npfcan_HadFrac_nNpf[n_pf_n][i_jet] = n_pf_features.hadFrac;
184 Npfcan_drminsv_nNpf[n_pf_n][i_jet] = n_pf_features.drminsv;
185 Npfcan_puppiw_nNpf[n_pf_n][i_jet] = n_pf_features.puppiw;
195 for (std::size_t sv_n = 0; sv_n < max_sv_n; sv_n++) {
196 const auto& sv_features =
features.sv_features.at(sv_n);
197 sv_pt_nSV[sv_n][i_jet] = sv_features.pt;
198 sv_deltaR_nSV[sv_n][i_jet] = sv_features.deltaR;
199 sv_mass_nSV[sv_n][i_jet] = sv_features.mass;
200 sv_ntracks_nSV[sv_n][i_jet] = sv_features.ntracks;
201 sv_chi2_nSV[sv_n][i_jet] = sv_features.chi2;
202 sv_normchi2_nSV[sv_n][i_jet] = sv_features.normchi2;
203 sv_dxy_nSV[sv_n][i_jet] = sv_features.dxy;
204 sv_dxysig_nSV[sv_n][i_jet] = sv_features.dxysig;
205 sv_d3d_nSV[sv_n][i_jet] = sv_features.d3d;
206 sv_d3dsig_nSV[sv_n][i_jet] = sv_features.d3dsig;
207 sv_costhetasvpv_nSV[sv_n][i_jet] = sv_features.costhetasvpv;
208 sv_enratio_nSV[sv_n][i_jet] = sv_features.enratio;
219 auto djTable = std::make_unique<nanoaod::FlatTable>(jet_N_CPFCands.size(), nameDeepJet_,
false,
true);
222 djTable->addColumn<
int>(
"DeepJet_nCpfcand", jet_N_CPFCands,
"Number of charged PF candidates in the jet");
223 djTable->addColumn<
int>(
"DeepJet_nNpfcand", jet_N_NPFCands,
"Number of neutral PF candidates in the jet");
224 djTable->addColumn<
int>(
"DeepJet_nsv", jet_N_SVs,
"Number of secondary vertices in the jet");
225 djTable->addColumn<
int>(
"DeepJet_npv", jet_N_PVs,
"Number of primary vertices");
228 for (
unsigned int p = 0;
p < n_cpf_;
p++) {
231 djTable->addColumn<
float>(
"DeepJet_Cpfcan_puppiw_" +
s,
232 Cpfcan_puppiw_nCpf[
p],
233 "charged candidate PUPPI weight of the " +
s +
". cpf",
235 djTable->addColumn<
int>(
236 "DeepJet_Cpfcan_VTX_ass_" +
s,
237 Cpfcan_VTX_ass_nCpf[
p],
238 "integer flag that indicates whether the track was used in the primary vertex fit for the " +
s +
". cpf",
240 djTable->addColumn<
float>(
"DeepJet_Cpfcan_drminsv_" +
s,
241 Cpfcan_drminsv_nCpf[
p],
242 "track pseudoangular distance from the closest secondary vertex of the " +
s +
". cpf",
244 djTable->addColumn<
float>(
"DeepJet_Cpfcan_ptrel_" +
s,
245 Cpfcan_ptrel_nCpf[
p],
246 "fraction of the jet momentum carried by the track for the " +
s +
". cpf",
248 djTable->addColumn<
int>(
249 "DeepJet_Cpfcan_quality_" +
s,
250 Cpfcan_quality_nCpf[
p],
251 "integer flag which indicates the quality of the fitted track, based on number of detector hits used for the " 252 "reconstruction as well as the overall chi2 of the charged track fit for the " +
255 djTable->addColumn<
float>(
256 "DeepJet_Cpfcan_chi2_" +
s, Cpfcan_chi2_nCpf[
p],
"chi2 of the charged track fit for the " +
s +
". cpf", 10);
258 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackDeltaR_" +
s,
259 Cpfcan_BtagPf_trackDeltaR_nCpf[
p],
260 "track pseudoangular distance from the jet axis for the " +
s +
". cpf",
262 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackEtaRel_" +
s,
263 Cpfcan_BtagPf_trackEtaRel_nCpf[
p],
264 "track pseudorapidity, relative to the jet axis for the " +
s +
". cpf",
266 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackJetDistVal_" +
s,
267 Cpfcan_BtagPf_trackJetDistVal_nCpf[
p],
268 "minimum track approach distance to jet axis for the " +
s +
". cpf",
270 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackPPar_" +
s,
271 Cpfcan_BtagPf_trackPPar_nCpf[
p],
272 "dot product of the jet and track momentum for the " +
s +
". cpf",
274 djTable->addColumn<
float>(
275 "DeepJet_Cpfcan_BtagPf_trackPParRatio_" +
s,
276 Cpfcan_BtagPf_trackPParRatio_nCpf[
p],
277 "dot product of the jet and track momentum divided by the magnitude of the jet momentum for the " +
s +
". cpf",
279 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackPtRel_" +
s,
280 Cpfcan_BtagPf_trackPtRel_nCpf[
p],
281 "track transverse momentum, relative to the jet axis for the " +
s +
". cpf",
283 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackSip2dSig_" +
s,
284 Cpfcan_BtagPf_trackSip2dSig_nCpf[
p],
285 "track 2D signed impact parameter significance for the " +
s +
". cpf",
287 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackSip3dSig_" +
s,
288 Cpfcan_BtagPf_trackSip3dSig_nCpf[
p],
289 "track 3D signed impact parameter significance for the " +
s +
". cpf",
291 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackSip2dVal_" +
s,
292 Cpfcan_BtagPf_trackSip2dVal_nCpf[
p],
293 "track 2D signed impact parameter for the " +
s +
". cpf",
295 djTable->addColumn<
float>(
"DeepJet_Cpfcan_BtagPf_trackSip3dVal_" +
s,
296 Cpfcan_BtagPf_trackSip3dVal_nCpf[
p],
297 "track 3D signed impact parameter for the " +
s +
". cpf",
302 for (
unsigned int p = 0;
p < n_npf_;
p++) {
305 djTable->addColumn<
float>(
"DeepJet_Npfcan_puppiw_" +
s,
306 Npfcan_puppiw_nNpf[
p],
307 "neutral candidate PUPPI weight for the " +
s +
". npf",
309 djTable->addColumn<
float>(
310 "DeepJet_Npfcan_deltaR_" +
s,
311 Npfcan_deltaR_nNpf[
p],
312 "pseudoangular distance between the neutral candidate and the jet axis for the " +
s +
". npf",
314 djTable->addColumn<
float>(
315 "DeepJet_Npfcan_drminsv_" +
s,
316 Npfcan_drminsv_nNpf[
p],
317 "pseudoangular distance between the neutral candidate and the closest secondary vertex for the " +
s +
". npf",
319 djTable->addColumn<
float>(
320 "DeepJet_Npfcan_HadFrac_" +
s,
321 Npfcan_HadFrac_nNpf[
p],
322 "fraction of the neutral candidate energy deposited in the hadronic calorimeter for the " +
s +
". npf",
324 djTable->addColumn<
float>(
"DeepJet_Npfcan_ptrel_" +
s,
325 Npfcan_ptrel_nNpf[
p],
326 "fraction of the jet momentum carried by the neutral candidate for the " +
s +
". npf",
328 djTable->addColumn<
int>(
"DeepJet_Npfcan_isGamma_" +
s,
329 Npfcan_isGamma_nNpf[
p],
330 "integer flag indicating whether the neutral candidate is a photon for the " +
s +
". npf",
346 for (
unsigned int p = 0;
p < n_sv_;
p++) {
349 djTable->addColumn<
float>(
"DeepJet_sv_mass_" +
s, sv_mass_nSV[
p],
"SV mass of the " +
s +
". SV", 10);
350 djTable->addColumn<
float>(
"DeepJet_sv_pt_" +
s, sv_pt_nSV[
p],
"SV pt of the " +
s +
". SV", 10);
351 djTable->addColumn<
float>(
352 "DeepJet_sv_ntracks_" +
s, sv_ntracks_nSV[
p],
"Number of tracks asociated to the " +
s +
". SV", 10);
353 djTable->addColumn<
float>(
"DeepJet_sv_chi2_" +
s, sv_chi2_nSV[
p],
"chi2 of the " +
s +
". SV", 10);
354 djTable->addColumn<
float>(
"DeepJet_sv_normchi2_" +
s, sv_normchi2_nSV[
p],
"chi2/dof of the " +
s +
". SV", 10);
355 djTable->addColumn<
float>(
356 "DeepJet_sv_dxy_" +
s, sv_dxy_nSV[
p],
"2D impact parameter (flight distance) value of the " +
s +
". SV", 10);
357 djTable->addColumn<
float>(
"DeepJet_sv_dxysig_" +
s,
359 "2D impact parameter (flight distance) significance of the " +
s +
". SV",
361 djTable->addColumn<
float>(
362 "DeepJet_sv_d3d_" +
s, sv_d3d_nSV[
p],
"3D impact parameter (flight distance) value of the " +
s +
". SV", 10);
363 djTable->addColumn<
float>(
"DeepJet_sv_d3dsig_" +
s,
365 "3D impact parameter (flight distance) significance of the " +
s +
". SV",
367 djTable->addColumn<
float>(
"DeepJet_sv_costhetasvpv_" +
s,
368 sv_costhetasvpv_nSV[
p],
369 "cosine of the angle between the " +
s +
370 ". SV flight direction and the direction of the " +
s +
". SV momentum",
383 djTable->addColumn<
float>(
"DeepJet_sv_deltaR_" +
s,
385 "pseudoangular distance between jet axis and the " +
s +
". SV direction",
387 djTable->addColumn<
float>(
388 "DeepJet_sv_enratio_" +
s, sv_enratio_nSV[
p],
"ratio of the " +
s +
". SV energy ratio to the jet energy", 10);
394 template <
typename T>
400 desc.add<
unsigned int>(
"n_cpf", 3);
401 desc.add<
unsigned int>(
"n_npf", 3);
402 desc.add<
unsigned int>(
"n_sv", 4);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::string nameDeepJet_
edm::EDGetTokenT< edm::View< T > > jet_token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static constexpr int nJets
std::vector< reco::DeepFlavourTagInfo > TagInfoCollection
static std::string to_string(const XMLCh *ch)
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
#define DEFINE_FWK_MODULE(type)
const std::string idx_nameDeepJet_
DeepJetTableProducer(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< TagInfoCollection > tag_info_src_
~DeepJetTableProducer() override
DeepJetTableProducer< pat::Jet > PatJetDeepJetTableProducer