27 const std::vector<reco::CandidatePtr> &
tracks =
vtx.daughterPtrVector();
30 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double>> vec;
31 vec.SetPx((*track)->px());
32 vec.SetPy((*track)->py());
33 vec.SetPz((*track)->pz());
40 template <
typename VTX>
83 template <
typename VTX>
87 maxDRForUnique(
params.getParameter<double>(
"maxDRUnique")),
88 maxvecSumIMCUTForUnique(
params.getParameter<double>(
"maxvecSumIMifsmallDRUnique")),
94 produces<std::vector<VTX>>();
97 template <
typename VTX>
102 iEvent.getByToken(token_primaryVertex, PVcoll);
104 if (!PVcoll->empty()) {
113 std::vector<VertexProxy> vertexProxyColl;
116 vertexProxyColl.push_back(buildVertexProxy(*
sv));
120 sort(vertexProxyColl.begin(), vertexProxyColl.end());
123 for (
unsigned int iVtx = 0; iVtx < vertexProxyColl.size(); ++iVtx) {
126 for (
unsigned int kVtx = vertexProxyColl.size() - 1; kVtx > iVtx; --kVtx) {
128 resolveBtoDchain(vertexProxyColl, iVtx, kVtx);
133 auto bvertColl = std::make_unique<std::vector<VTX>>();
134 for (
typename std::vector<VertexProxy>::const_iterator it = vertexProxyColl.begin(); it != vertexProxyColl.end();
136 bvertColl->push_back((*it).vert);
139 iEvent.put(std::make_unique<std::vector<VTX>>());
143 template <
typename VTX>
148 template <
typename VTX>
154 template <
typename VTX>
183 using namespace reco;
198 if (sv1.dist3d().value() >= sv2.
dist3d().
value()) {
201 momentumNear = momentum2;
202 momentumFar = momentum1;
208 double cosPA = nearToFar.
dot(momentumFar) / momentumFar.
mag() / nearToFar.
mag();
209 double cosa = pvToNear.
dot(momentumFar) / pvToNear.
mag() / momentumFar.
mag();
210 double ptrel =
sqrt(1.0 - cosa * cosa) * momentumFar.
mag();
215 std::set<reco::TrackRef> trackrefs;
218 if (sv1.trackWeight(*ti) > 0.5) {
225 if (sv2.trackWeight(*ti) > 0.5) {
232 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double>> mother;
233 for (std::set<reco::TrackRef>::const_iterator it = trackrefs.begin(); it != trackrefs.end(); ++it) {
234 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double>>
temp(
240 if (vertexDeltaR < maxDRForUnique && mother.M() < maxvecSumIMCUTForUnique && cosPA >
minCosPAtomerge &&
244 bool bFoundDuplicate =
false;
247 if (it == sv1.tracks_end())
248 coll[
i].vert.add(*ti, sv2.refittedTrack(*ti), sv2.trackWeight(*ti));
250 bFoundDuplicate =
true;
255 if (bFoundDuplicate) {
257 std::vector<TrackBaseRef> tracks_;
258 std::vector<Track> refittedTracks_;
259 std::vector<float> weights_;
261 tracks_.push_back(*it);
262 refittedTracks_.push_back(coll[
i].vert.refittedTrack(*it));
263 weights_.push_back(coll[
i].vert.trackWeight(*it));
266 coll[
i].vert.removeTracks();
267 std::vector<Track>::iterator it2 = refittedTracks_.begin();
268 std::vector<float>::iterator it3 = weights_.begin();
271 float weight2 = sv2.trackWeight(*it);
272 Track refittedTrackWithLargerWeight = *it2;
275 refittedTrackWithLargerWeight = sv2.refittedTrack(*it);
277 coll[
i].vert.add(*it, refittedTrackWithLargerWeight,
weight);
282 coll.erase(coll.begin() +
k);
290 using namespace reco;
307 if (sv1.dist3d().value() >= sv2.
dist3d().
value()) {
310 momentumNear = momentum2;
311 momentumFar = momentum1;
317 double cosPA = nearToFar.
dot(momentumFar) / momentumFar.
mag() / nearToFar.
mag();
318 double cosa = pvToNear.
dot(momentumFar) / pvToNear.
mag() / momentumFar.
mag();
319 double ptrel =
sqrt(1.0 - cosa * cosa) * momentumFar.
mag();
324 std::set<reco::CandidatePtr> trackrefs;
326 for (
size_t i = 0;
i < sv1.numberOfSourceCandidatePtrs(); ++
i)
327 trackrefs.insert(sv1.daughterPtr(
i));
329 for (
size_t i = 0;
i < sv2.numberOfSourceCandidatePtrs(); ++
i)
330 trackrefs.insert(sv2.daughterPtr(
i));
334 for (std::set<reco::CandidatePtr>::const_iterator it = trackrefs.begin(); it != trackrefs.end(); ++it) {
340 if (vertexDeltaR < maxDRForUnique && mother.M() < maxvecSumIMCUTForUnique && cosPA >
minCosPAtomerge &&
344 const std::vector<reco::CandidatePtr> &tracks1 = sv1.daughterPtrVector();
345 const std::vector<reco::CandidatePtr> &tracks2 = sv2.daughterPtrVector();
346 for (std::vector<reco::CandidatePtr>::const_iterator ti = tracks2.begin(); ti != tracks2.end(); ++ti) {
347 std::vector<reco::CandidatePtr>::const_iterator it =
find(tracks1.begin(), tracks1.end(), *ti);
348 if (it == tracks1.end()) {
349 coll[
i].vert.addDaughter(*ti);
350 coll[
i].vert.setP4((*ti)->p4() + coll[
i].vert.p4());
355 coll.erase(coll.begin() +
k);