Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:36

0001 #ifndef RecoParticleFlow_PFTracking_PFDisplacedVertexFinder_h
0002 #define RecoParticleFlow_PFTracking_PFDisplacedVertexFinder_h
0003 
0004 #include "RecoParticleFlow/PFTracking/interface/PFDisplacedVertexHelper.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 
0007 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidate.h"
0008 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidateFwd.h"
0009 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexSeed.h"
0010 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexSeedFwd.h"
0011 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertex.h"
0012 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
0013 
0014 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0015 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0016 
0017 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0018 
0019 #include "RecoParticleFlow/PFTracking/interface/PFCheckHitPattern.h"
0020 
0021 /// \brief Displaced Vertex Finder Algorithm
0022 /*!
0023   \author Maxime Gouzevitch
0024   \date October 2009
0025 */
0026 
0027 class TrackingGeometry;
0028 class TrackerGeometry;
0029 class MagneticField;
0030 
0031 class PFDisplacedVertexFinder {
0032 public:
0033   PFDisplacedVertexFinder();
0034 
0035   ~PFDisplacedVertexFinder();
0036 
0037   /// -------- Useful Types -------- ///
0038 
0039   typedef reco::PFDisplacedVertexSeedCollection::iterator IDVS;
0040   typedef reco::PFDisplacedVertexCollection::iterator IDV;
0041 
0042   typedef std::pair<unsigned int, unsigned int> PFTrackHitInfo;
0043   typedef std::pair<PFTrackHitInfo, PFTrackHitInfo> PFTrackHitFullInfo;
0044 
0045   /// Fitter Type
0046   enum FitterType { F_NOTDEFINED, F_DONOTREFIT, F_KALMAN, F_ADAPTIVE };
0047 
0048   /// -------- Set different algo parameters -------- ///
0049 
0050   /// Sets algo parameters for the vertex finder
0051   void setParameters(double transvSize,
0052                      double longSize,
0053                      double primaryVertexCut,
0054                      double tobCut,
0055                      double tecCut,
0056                      double minAdaptWeight,
0057                      bool switchOff2TrackVertex) {
0058     transvSize_ = transvSize;
0059     longSize_ = longSize;
0060     primaryVertexCut_ = primaryVertexCut;
0061     tobCut_ = tobCut;
0062     tecCut_ = tecCut;
0063     minAdaptWeight_ = minAdaptWeight;
0064     switchOff2TrackVertex_ = switchOff2TrackVertex;
0065   }
0066 
0067   /// Sets debug printout flag
0068   void setDebug(bool debug) { debug_ = debug; }
0069 
0070   /// Sets parameters for track extrapolation and hits study
0071   void setEdmParameters(const MagneticField* magField,
0072                         edm::ESHandle<GlobalTrackingGeometry> globTkGeomHandle,
0073                         const TrackerTopology* tkerTopo,
0074                         const TrackerGeometry* tkerGeom) {
0075     magField_ = magField;
0076     globTkGeomHandle_ = globTkGeomHandle;
0077     tkerTopo_ = tkerTopo;
0078     tkerGeom_ = tkerGeom;
0079   }
0080 
0081   void setTracksSelector(const edm::ParameterSet& ps) { helper_.setTracksSelector(ps); }
0082 
0083   void setVertexIdentifier(const edm::ParameterSet& ps) { helper_.setVertexIdentifier(ps); }
0084 
0085   void setPrimaryVertex(edm::Handle<reco::VertexCollection> mainVertexHandle,
0086                         edm::Handle<reco::BeamSpot> beamSpotHandle) {
0087     helper_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
0088   }
0089 
0090   void setAVFParameters(const edm::ParameterSet& ps) {
0091     sigmacut_ = ps.getParameter<double>("sigmacut");
0092     t_ini_ = ps.getParameter<double>("Tini");
0093     ratio_ = ps.getParameter<double>("ratio");
0094   }
0095 
0096   /// Set input collections of tracks
0097   void setInput(const edm::Handle<reco::PFDisplacedVertexCandidateCollection>&);
0098 
0099   /// \return unique_ptr to collection of DisplacedVertices
0100   std::unique_ptr<reco::PFDisplacedVertexCollection> transferDisplacedVertices() {
0101     return std::move(displacedVertices_);
0102   }
0103 
0104   const std::unique_ptr<reco::PFDisplacedVertexCollection>& displacedVertices() const {
0105     return std::move(displacedVertices_);
0106   }
0107 
0108   /// -------- Main function which find vertices -------- ///
0109 
0110   void findDisplacedVertices();
0111 
0112 private:
0113   /// -------- Different steps of the finder algorithm -------- ///
0114 
0115   /// Analyse a vertex candidate and select potential vertex point(s)
0116   void findSeedsFromCandidate(const reco::PFDisplacedVertexCandidate&, reco::PFDisplacedVertexSeedCollection&);
0117 
0118   /// Sometimes two vertex candidates can be quite close and coming from the same vertex
0119   void mergeSeeds(reco::PFDisplacedVertexSeedCollection&, std::vector<bool>& bLocked);
0120 
0121   /// Fit one by one the vertex points with associated tracks to get displaced vertices
0122   bool fitVertexFromSeed(const reco::PFDisplacedVertexSeed&, reco::PFDisplacedVertex&);
0123 
0124   /// Remove potentially fakes displaced vertices
0125   void selectAndLabelVertices(reco::PFDisplacedVertexCollection&, std::vector<bool>&);
0126 
0127   bool rejectAndLabelVertex(reco::PFDisplacedVertex& dv);
0128 
0129   /// -------- Tools -------- ///
0130 
0131   bool isCloseTo(const reco::PFDisplacedVertexSeed&, const reco::PFDisplacedVertexSeed&) const;
0132 
0133   std::pair<float, float> getTransvLongDiff(const GlobalPoint&, const GlobalPoint&) const;
0134 
0135   reco::PFDisplacedVertex::VertexTrackType getVertexTrackType(PFTrackHitFullInfo&) const;
0136 
0137   unsigned commonTracks(const reco::PFDisplacedVertex&, const reco::PFDisplacedVertex&) const;
0138 
0139   friend std::ostream& operator<<(std::ostream&, const PFDisplacedVertexFinder&);
0140 
0141   /// -------- Members -------- ///
0142 
0143   reco::PFDisplacedVertexCandidateCollection const* displacedVertexCandidates_;
0144   std::unique_ptr<reco::PFDisplacedVertexCollection> displacedVertices_;
0145 
0146   /// -------- Parameters -------- ///
0147 
0148   /// Algo parameters for the vertex finder
0149 
0150   float transvSize_;
0151   float longSize_;
0152   double primaryVertexCut_;
0153   double tobCut_;
0154   double tecCut_;
0155   double minAdaptWeight_;
0156 
0157   bool switchOff2TrackVertex_;
0158 
0159   /// Adaptive Vertex Fitter parameters
0160 
0161   double sigmacut_;  //= 6;
0162   double t_ini_;     //= 256.;
0163   double ratio_;     //= 0.25;
0164 
0165   /// If true, debug printouts activated
0166   bool debug_;
0167 
0168   /// Tracker geometry for discerning hit positions
0169   edm::ESHandle<GlobalTrackingGeometry> globTkGeomHandle_;
0170 
0171   /// doc?
0172   const TrackerTopology* tkerTopo_;
0173   const TrackerGeometry* tkerGeom_;
0174 
0175   /// to be able to extrapolate tracks f
0176   const MagneticField* magField_;
0177 
0178   PFCheckHitPattern hitPattern_;
0179 
0180   PFDisplacedVertexHelper helper_;
0181 };
0182 
0183 #endif