29 for (std::vector<reco::CandidatePtr>::const_iterator
track = tracks.begin();
track != tracks.end(); ++
track) {
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>
86 token_secondaryVertex(consumes<edm::
View<VTX>>(params.getParameter<edm::
InputTag>(
"secondaryVertices"))),
87 maxDRForUnique(params.getParameter<double>(
"maxDRUnique")),
88 maxvecSumIMCUTForUnique(params.getParameter<double>(
"maxvecSumIMifsmallDRUnique")),
89 minCosPAtomerge(params.getParameter<double>(
"minCosPAtomerge")),
90 maxPtreltomerge(params.getParameter<double>(
"maxPtreltomerge"))
94 produces<std::vector<VTX>>();
97 template <
typename VTX>
102 iEvent.
getByToken(token_primaryVertex, PVcoll);
104 if (!PVcoll->empty()) {
110 iEvent.
getByToken(token_secondaryVertex, secondaryVertices);
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 &&
241 std::abs(ptrel) < maxPtreltomerge) {
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;
273 if (weight2 > weight) {
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 &&
341 std::abs(ptrel) < maxPtreltomerge) {
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);
size_type numberOfSourceCandidatePtrs() const override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
reco::TemplatedSecondaryVertex< VTX > SecondaryVertex
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
double y() const
y coordinate
Measurement1D dist3d() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
void produce(edm::Event &event, const edm::EventSetup &es) override
auto const & tracks
cannot be loose
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
virtual const daughters & daughterPtrVector() const
references to daughtes
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)
double z() const
z coordinate
size_t tracksSize() const
number of tracks
double x() const
x coordinate
BtoCharmDecayVertexMergerT(const edm::ParameterSet ¶ms)
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
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