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;
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);
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());
204 cand_dzFromPV.push_back(-1);
205 cand_dxyFromPV.push_back(-1);
206 cand_dzErrFromPV.push_back(-1);
207 cand_dxyErrFromPV.push_back(-1);
214 if (packedCand ==
nullptr)
216 if (packedCand && packedCand->hasTrackDetails()) {
218 trkinfo.buildTrackInfo(&(*packedCand), jet_dir, jet_ref_track_dir,
vtxs_->at(0));
219 btagEtaRel.push_back(trkinfo.getTrackEtaRel());
220 btagPtRatio.push_back(trkinfo.getTrackPtRatio());
221 btagPParRatio.push_back(trkinfo.getTrackPParRatio());
222 btagSip3dVal.push_back(trkinfo.getTrackSip3dVal());
223 btagSip3dSig.push_back(trkinfo.getTrackSip3dSig());
224 btagJetDistVal.push_back(trkinfo.getTrackJetDistVal());
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");
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);
constexpr double deltaPhi(double phi1, double phi2)
const std::string idx_nameSV_
reco::Vertex::Point convertPos(const GlobalPoint &p)
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)
edm::Handle< SVCollection > svs_
const Point & position() const
position
int closest(std::vector< int > const &vec, int value)
reco::Vertex::Error convertError(const GlobalError &ge)
edm::EDGetTokenT< reco::CandidateView > cand_token_
double zError() const
error on z
const std::string nameSV_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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)
reco::TransientTrack build(const reco::Track *p) const
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
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
Measurement1D vertexDxy(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
const MagneticField * field() const
edm::Handle< VertexCollection > vtxs_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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())
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
double significance() const
edm::EDGetTokenT< edm::View< T > > jet_token_
const std::string idx_name_
edm::Handle< reco::CandidateView > cands_
TrajectoryStateOnSurface impactPointState() const
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...