Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:39

0001 #ifndef RecoParticleFlow_PFTracking_PFDisplacedVertexCandidateFinder_h
0002 #define RecoParticleFlow_PFTracking_PFDisplacedVertexCandidateFinder_h
0003 
0004 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidate.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidateFwd.h"
0006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0007 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0008 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0009 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0010 #include "CommonTools/Utils/interface/KinematicTables.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
0016 #include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h"
0017 
0018 /// \brief Displaced Vertex Candidate Finder
0019 /*!
0020   \author Maxime Gouzevitch
0021   \date October 2009
0022 */
0023 
0024 class MagneticField;
0025 
0026 class PFDisplacedVertexCandidateFinder {
0027 public:
0028   PFDisplacedVertexCandidateFinder();
0029 
0030   ~PFDisplacedVertexCandidateFinder();
0031 
0032   /// Mask used to spot if a track is free or not
0033   typedef std::vector<bool> Mask;
0034 
0035   typedef std::list<reco::TrackBaseRef>::iterator IE;
0036   typedef std::list<reco::TrackBaseRef>::const_iterator IEC;
0037   typedef reco::PFDisplacedVertexCandidateCollection::const_iterator IBC;
0038 
0039   /// --------- Set different algo parameters ------ ///
0040 
0041   /// Sets algo parameters for the vertex candidate finder
0042   void setParameters(double dcaCut, double primaryVertexCut, double dcaPInnerHitCut, const edm::ParameterSet& ps_trk) {
0043     dcaCut_ = dcaCut;
0044     primaryVertexCut2_ = primaryVertexCut * primaryVertexCut;
0045     dcaPInnerHitCut2_ = dcaPInnerHitCut * dcaPInnerHitCut;
0046     nChi2_max_ = ps_trk.getParameter<double>("nChi2_max");
0047     pt_min_ = ps_trk.getParameter<double>("pt_min");
0048     pt_min_prim_ = ps_trk.getParameter<double>("pt_min_prim");
0049     dxy_ = ps_trk.getParameter<double>("dxy");
0050   }
0051 
0052   /// sets debug printout flag
0053   void setDebug(bool debug) { debug_ = debug; }
0054 
0055   /// Set the imput collection of tracks and calculate their
0056   /// trajectory parameters the Global Trajectory Parameters
0057   void setInput(const edm::Handle<reco::TrackCollection>& trackh, const MagneticField* magField);
0058 
0059   /// \return auto_ptr to collection of DisplacedVertexCandidates
0060   std::unique_ptr<reco::PFDisplacedVertexCandidateCollection> transferVertexCandidates() {
0061     return std::move(vertexCandidates_);
0062   }
0063 
0064   const std::unique_ptr<reco::PFDisplacedVertexCandidateCollection>& vertexCandidates() const {
0065     return std::move(vertexCandidates_);
0066   }
0067 
0068   /// -------- Main function which find vertices -------- ///
0069 
0070   void findDisplacedVertexCandidates();
0071 
0072   void setPrimaryVertex(edm::Handle<reco::VertexCollection> mainVertexHandle,
0073                         edm::Handle<reco::BeamSpot> beamSpotHandle);
0074 
0075 private:
0076   /// -------- Different steps of the finder algorithm -------- ///
0077 
0078   /// Recursive procedure to associate tracks together
0079   IE associate(IE next, IE last, reco::PFDisplacedVertexCandidate& tempVertexCandidate);
0080 
0081   /// Check whether 2 elements are linked and fill the link parameters
0082   void link(const reco::TrackBaseRef& el1,
0083             const reco::TrackBaseRef& el2,
0084             double& dist,
0085             GlobalPoint& crossing_point,
0086             reco::PFDisplacedVertexCandidate::VertexLinkTest& linktest);
0087 
0088   /// Compute missing links in the displacedVertexCandidates
0089   /// (the recursive procedure does not build all links)
0090   void packLinks(reco::PFDisplacedVertexCandidate& vertexCandidate);
0091 
0092   /// -------- TOOLS -------- //
0093 
0094   /// Allows to calculate the helix aproximation for a given track
0095   /// which may be then extrapolated to any point.
0096   GlobalTrajectoryParameters getGlobalTrajectoryParameters(const reco::Track*) const;
0097 
0098   /// Quality Criterion on the Pt resolution to select a Track
0099   bool goodPtResolution(const reco::TrackBaseRef& trackref) const;
0100 
0101   /// A function which gather the information
0102   /// if a track is available for vertexing
0103   bool isSelected(const reco::TrackBaseRef& trackref) { return goodPtResolution(trackref); }
0104 
0105   friend std::ostream& operator<<(std::ostream&, const PFDisplacedVertexCandidateFinder&);
0106 
0107   /// -------- Members -------- ///
0108 
0109   std::unique_ptr<reco::PFDisplacedVertexCandidateCollection> vertexCandidates_;
0110 
0111   /// The track refs
0112   std::list<reco::TrackBaseRef> eventTracks_;
0113 
0114   /// The trackMask allows to keep the information on the
0115   /// tracks which are still free and those which are already
0116   /// used or disabled.
0117   Mask trackMask_;
0118   /// The Trajectories vector allow to calculate snd to store
0119   /// only once the track trajectory parameters
0120   std::vector<GlobalTrajectoryParameters> eventTrackTrajectories_;
0121 
0122   /// ----- Algo parameters for the vertex finder ---- ///
0123 
0124   /// Distance of minimal approach below which
0125   /// two tracks are considered as linked together
0126   double dcaCut_;
0127   /// Do not reconstruct vertices wich are too close to the beam pipe
0128   double primaryVertexCut2_;
0129   /// Maximum distance between the DCA Point and the inner hit of the track
0130   double dcaPInnerHitCut2_;
0131 
0132   /// Tracks preselection to reduce the combinatorics in PFDisplacedVertexCandidates
0133   /// this cuts are repeated then in a smarter way in the PFDisplacedVertexFinder
0134   /// be sure you are consistent between them
0135   double nChi2_max_;
0136   double pt_min_;
0137 
0138   double pt_min_prim_;
0139   double dxy_;
0140 
0141   /// Max number of expected vertexCandidates in the event
0142   /// Used to allocate the memory and avoid multiple copy
0143   unsigned vertexCandidatesSize_;
0144 
0145   // Two track minimum distance algo
0146   TwoTrackMinimumDistance theMinimum_;
0147 
0148   math::XYZPoint pvtx_;
0149 
0150   /// if true, debug printouts activated
0151   bool debug_;
0152 
0153   // Tracker geometry for extrapolation
0154   const MagneticField* magField_;
0155 
0156   edm::soa::PtEtaPhiTable track_table_;
0157 };
0158 
0159 #endif