File indexing completed on 2024-12-10 02:32:04
0001 #ifndef SequentialPrimaryVertexFitterAdapter_h
0002 #define SequentialPrimaryVertexFitterAdapter_h
0003
0004
0005
0006
0007
0008
0009
0010 #include <sstream>
0011
0012 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
0013 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0014 #include "RecoVertex/PrimaryVertexProducer/interface/PrimaryVertexFitterBase.h"
0015 #include "RecoVertex/VertexPrimitives/interface/VertexFitter.h"
0016
0017 class SequentialPrimaryVertexFitterAdapter : public PrimaryVertexFitterBase {
0018 public:
0019 SequentialPrimaryVertexFitterAdapter() : fitter(nullptr) {}
0020 SequentialPrimaryVertexFitterAdapter(const VertexFitter<5>* vertex_fitter) : fitter(vertex_fitter) {}
0021 ~SequentialPrimaryVertexFitterAdapter() override = default;
0022
0023 std::vector<TransientVertex> fit(const std::vector<reco::TransientTrack>& dummy,
0024 const std::vector<TransientVertex>& clusters,
0025 const reco::BeamSpot& beamspot,
0026 const bool useBeamConstraint) override {
0027 std::vector<TransientVertex> pvs;
0028 for (auto& cluster : clusters) {
0029 const std::vector<reco::TransientTrack>& tracklist = cluster.originalTracks();
0030 TransientVertex v;
0031 if (useBeamConstraint && (tracklist.size() > 1)) {
0032 try {
0033 v = fitter->vertex(tracklist, beamspot);
0034 } catch (VertexException& ex) {
0035 std::ostringstream beamspotInfo;
0036 beamspotInfo << "While processing SequentialPrimaryVertexFitterAdapter::fit() with BeamSpot parameters: \n"
0037 << beamspot;
0038 ex.addContext(beamspotInfo.str());
0039 throw;
0040 }
0041 } else if (!(useBeamConstraint) && (tracklist.size() > 1)) {
0042 v = fitter->vertex(tracklist);
0043 }
0044
0045 if (v.isValid()) {
0046 pvs.push_back(v);
0047 }
0048 }
0049 return pvs;
0050 };
0051
0052 protected:
0053
0054 const VertexFitter<5>* fitter;
0055 };
0056 #endif