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>
67 if (v1.ntracks > 2 && v2.
ntracks < 3)
69 if (v1.ntracks < 3 && v2.
ntracks > 2)
71 return (v1.invm > v2.
invm);
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>
145 return GlobalVector(v2.
x() - v1.x(), v2.
y() - v1.y(), v2.
z() - v1.z());
148 template <
typename VTX>
154 template <
typename VTX>
158 v2.
vertex().x() - v1.vertex().x(), v2.
vertex().y() - v1.vertex().y(), v2.
vertex().z() - v1.vertex().z());
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);
reco::TemplatedSecondaryVertex< VTX > SecondaryVertex
double z() const
z coordinate
Measurement1D dist3d() const
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
T const * product() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
void produce(edm::Event &event, const edm::EventSetup &es) override
const Point & vertex() const override
vertex position (overwritten by PF...)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< Vertex > VertexCollection
BtoCharmDecayVertexMergerT< reco::Vertex > BtoCharmDecayVertexMerger
VertexProxy buildVertexProxy(const VTX &vtx)
GlobalVector flightDirection(const reco::Vertex &pv, const reco::Vertex &sv)
friend bool operator<(VertexProxy v1, VertexProxy v2)
double maxvecSumIMCUTForUnique
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
double x() const
x coordinate
double y() const
y coordinate
BtoCharmDecayVertexMergerT(const edm::ParameterSet ¶ms)
void resolveBtoDchain(std::vector< VertexProxy > &coll, unsigned int i, unsigned int k)
GlobalVector flightDirection(const reco::Vertex &v1, const reco::Vertex &v2)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
BtoCharmDecayVertexMergerT< reco::VertexCompositePtrCandidate > CandidateBtoCharmDecayVertexMerger
reco::Candidate::LorentzVector vtxP4(const reco::VertexCompositePtrCandidate &vtx)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::EDGetTokenT< edm::View< VTX > > token_secondaryVertex
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Global3DVector GlobalVector