75 : name_(iConfig.getParameter<
std::
string>(
"name")),
76 nameSV_(iConfig.getParameter<
std::
string>(
"nameSV")),
77 idx_name_(iConfig.getParameter<
std::
string>(
"idx_name")),
78 idx_nameSV_(iConfig.getParameter<
std::
string>(
"idx_nameSV")),
79 readBtag_(iConfig.getParameter<
bool>(
"readBtag")),
80 jet_radius_(iConfig.getParameter<double>(
"jet_radius")),
87 produces<nanoaod::FlatTable>(
name_);
88 produces<nanoaod::FlatTable>(
nameSV_);
89 produces<std::vector<reco::CandidatePtr>>();
98 auto outCands = std::make_unique<std::vector<reco::CandidatePtr>>();
99 auto outSVs = std::make_unique<std::vector<const reco::VertexCompositePtrCandidate *>>();
100 std::vector<int> jetIdx_pf, jetIdx_sv, pfcandIdx,
svIdx;
102 std::vector<float> btagEtaRel, btagPtRatio, btagPParRatio, btagSip3dVal, btagSip3dSig, btagJetDistVal,
103 btagDecayLenVal, cand_pt, cand_dzFromPV, cand_dxyFromPV, cand_dzErrFromPV, cand_dxyErrFromPV;
110 iEvent.getByToken(vtx_token_, vtxs_);
111 iEvent.getByToken(cand_token_, cands_);
112 iEvent.getByToken(sv_token_, svs_);
115 track_builder_ = iSetup.
getHandle(track_builder_token_);
118 for (
unsigned i_jet = 0; i_jet <
jets->size(); ++i_jet) {
119 const auto &
jet =
jets->at(i_jet);
128 std::vector<const reco::VertexCompositePtrCandidate *> jetSVs;
129 std::vector<const reco::VertexCompositePtrCandidate *> allSVs;
130 for (
const auto &
sv : *svs_) {
135 allSVs.push_back(&
sv);
138 jetSVs.push_back(&
sv);
148 for (
const auto &
sv : jetSVs) {
150 auto svInNewList =
std::find(allSVs.begin(), allSVs.end(),
sv);
151 if (svInNewList == allSVs.end()) {
155 svIdx.push_back(svInNewList - allSVs.begin());
157 outSVs->push_back(
sv);
158 jetIdx_sv.push_back(i_jet);
159 if (readBtag_ && !vtxs_->empty()) {
165 sv_chi2.push_back(
sv->vertexChi2());
168 sv_dxy.push_back(dxy_meas.value());
171 sv_d3d.push_back(d3d_meas.value());
178 sv_enratio.push_back(
sv->energy() /
jet.energy());
183 std::vector<reco::CandidatePtr>
const &
daughters =
jet.daughterPtrVector();
186 auto candPtrs = cands_->ptrs();
187 auto candInNewList =
std::find(candPtrs.begin(), candPtrs.end(),
cand);
188 if (candInNewList == candPtrs.end()) {
192 outCands->push_back(
cand);
193 jetIdx_pf.push_back(i_jet);
194 pfcandIdx.push_back(candInNewList - candPtrs.begin());
195 cand_pt.push_back(
cand->pt());
197 if (packedCand && packedCand->hasTrackDetails()) {
198 const reco::Track *track_ptr = &(packedCand->pseudoTrack());
199 cand_dzFromPV.push_back(track_ptr->
dz(pv_->position()));
200 cand_dxyFromPV.push_back(track_ptr->
dxy(pv_->position()));
202 cand_dxyErrFromPV.push_back(track_ptr->
dxyError(pv_->position(), pv_->covariance()));
204 cand_dzFromPV.push_back(-1);
205 cand_dxyFromPV.push_back(-1);
206 cand_dzErrFromPV.push_back(-1);
207 cand_dxyErrFromPV.push_back(-1);
210 if (readBtag_ && !vtxs_->empty()) {
214 if (packedCand ==
nullptr)
216 if (packedCand && packedCand->hasTrackDetails()) {
218 trkinfo.
buildTrackInfo(&(*packedCand), jet_dir, jet_ref_track_dir, vtxs_->at(0));
226 const reco::Track *track_ptr = packedCand->bestTrack();
237 btagEtaRel.push_back(0);
238 btagPtRatio.push_back(0);
239 btagPParRatio.push_back(0);
240 btagSip3dVal.push_back(0);
241 btagSip3dSig.push_back(0);
242 btagJetDistVal.push_back(0);
243 btagDecayLenVal.push_back(0);
249 auto candTable = std::make_unique<nanoaod::FlatTable>(outCands->size(), name_,
false);
251 candTable->addColumn<
int>(idx_name_, pfcandIdx,
"Index in the candidate list");
252 candTable->addColumn<
int>(
"jetIdx", jetIdx_pf,
"Index of the parent jet");
254 candTable->addColumn<
float>(
"pt", cand_pt,
"pt", 10);
255 candTable->addColumn<
float>(
"dzFromPV", cand_dzFromPV,
"dzFromPV", 10);
256 candTable->addColumn<
float>(
"dxyFromPV", cand_dxyFromPV,
"dxyFromPV", 10);
257 candTable->addColumn<
float>(
"dzErrFromPV", cand_dzErrFromPV,
"dzErrFromPV", 10);
258 candTable->addColumn<
float>(
"dxyErrFromPV", cand_dxyErrFromPV,
"dxyErrFromPV", 10);
259 candTable->addColumn<
float>(
"btagEtaRel", btagEtaRel,
"btagEtaRel", 10);
260 candTable->addColumn<
float>(
"btagPtRatio", btagPtRatio,
"btagPtRatio", 10);
261 candTable->addColumn<
float>(
"btagPParRatio", btagPParRatio,
"btagPParRatio", 10);
262 candTable->addColumn<
float>(
"btagSip3dVal", btagSip3dVal,
"btagSip3dVal", 10);
263 candTable->addColumn<
float>(
"btagSip3dSig", btagSip3dSig,
"btagSip3dSig", 10);
264 candTable->addColumn<
float>(
"btagJetDistVal", btagJetDistVal,
"btagJetDistVal", 10);
265 candTable->addColumn<
float>(
"btagDecayLenVal", btagDecayLenVal,
"btagDecayLenVal", 10);
270 auto svTable = std::make_unique<nanoaod::FlatTable>(outSVs->size(), nameSV_,
false);
272 svTable->addColumn<
int>(
"jetIdx", jetIdx_sv,
"Index of the parent jet");
273 svTable->addColumn<
int>(idx_nameSV_,
svIdx,
"Index in the SV list");
275 svTable->addColumn<
float>(
"mass",
sv_mass,
"SV mass", 10);
276 svTable->addColumn<
float>(
"pt",
sv_pt,
"SV pt", 10);
277 svTable->addColumn<
float>(
"ntracks",
sv_ntracks,
"Number of tracks associated to SV", 10);
278 svTable->addColumn<
float>(
"chi2", sv_chi2,
"chi2", 10);
279 svTable->addColumn<
float>(
"normchi2",
sv_normchi2,
"chi2/ndof", 10);
280 svTable->addColumn<
float>(
"dxy",
sv_dxy,
"", 10);
281 svTable->addColumn<
float>(
"dxysig",
sv_dxysig,
"", 10);
282 svTable->addColumn<
float>(
"d3d",
sv_d3d,
"", 10);
283 svTable->addColumn<
float>(
"d3dsig",
sv_d3dsig,
"", 10);
286 svTable->addColumn<
float>(
"phirel",
sv_phirel,
"DeltaPhi(sv, jet)", 10);
287 svTable->addColumn<
float>(
"ptrel",
sv_ptrel,
"pT relative to parent jet", 10);
288 svTable->addColumn<
float>(
"deltaR",
sv_deltaR,
"dR from parent jet", 10);
289 svTable->addColumn<
float>(
"enration", sv_enratio,
"energy relative to parent jet", 10);
296 template <
typename T>
303 desc.add<
double>(
"jet_radius",
true);
304 desc.add<
bool>(
"readBtag",
true);
constexpr double deltaPhi(double phi1, double phi2)
const std::string idx_nameSV_
reco::Vertex::Point convertPos(const GlobalPoint &p)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
float vertexDdotP(const reco::VertexCompositePtrCandidate &sv, const reco::Vertex &pv)
Measurement1D vertexD3d(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
void buildTrackInfo(const reco::Candidate *candidate, const math::XYZVector &jetDir, GlobalVector refjetdirection, const reco::Vertex &pv)
const float getTrackJetDistVal() const
const float getTrackSip3dVal() const
edm::Handle< SVCollection > svs_
JetConstituentTableProducer< reco::GenJet > GenJetConstituentTableProducer
int closest(std::vector< int > const &vec, int value)
reco::Vertex::Error convertError(const GlobalError &ge)
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::EDGetTokenT< reco::CandidateView > cand_token_
const float getTrackPParRatio() const
const std::string nameSV_
const float getTrackPtRatio() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< VertexCompositePtrCandidate > VertexCompositePtrCandidateCollection
collection of Candidate objects
const float catch_infs_and_bound(const float in, const float replace_value, const float lowerbound, const float upperbound, const float offset=0., const bool use_offsets=true)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dxyError() const
error on dxy
double dzError() const
error on dz
reco::VertexCollection VertexCollection
Measurement1D vertexDxy(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
const MagneticField * field() const
~JetConstituentTableProducer() override
edm::Handle< VertexCollection > vtxs_
#define DEFINE_FWK_MODULE(type)
JetConstituentTableProducer< pat::Jet > PatJetConstituentTableProducer
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const float getTrackSip3dSig() const
edm::ESHandle< TransientTrackBuilder > track_builder_
edm::EDGetTokenT< VertexCollection > vtx_token_
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > track_builder_token_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool sv_vertex_comparator(const SVType &sva, const SVType &svb, const PVType &pv)
edm::EDGetTokenT< SVCollection > sv_token_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
reco::VertexCompositePtrCandidateCollection SVCollection
double significance() const
edm::EDGetTokenT< edm::View< T > > jet_token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string idx_name_
JetConstituentTableProducer(const edm::ParameterSet &)
edm::Handle< reco::CandidateView > cands_
void produce(edm::Event &, const edm::EventSetup &) override
const float getTrackEtaRel() const
TrajectoryStateOnSurface impactPointState() const
edm::View< Candidate > CandidateView
view of a collection containing candidates
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...