Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:16

0001 #ifndef DataFormat_ParticleFlowReco_PFDisplacedVertexCandidate_h
0002 #define DataFormat_ParticleFlowReco_PFDisplacedVertexCandidate_h
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0006 
0007 #include <vector>
0008 #include <map>
0009 #include <iostream>
0010 
0011 namespace reco {
0012 
0013   /// \brief A block of tracks linked together
0014   /*!
0015     \author Gouzevitch Maxime
0016     \date November 2009
0017 
0018     A DisplacedVertexCandidate is a format produced by 
0019     the DisplacedVertexCandidateFinder to hold a Collection
0020     of Refs to the tracks linked together by DCA. It contains: 
0021     - a set of reco::Tracks candidates for a common displaced vertex.
0022     - a set of links between these reco::Tracks.
0023     - a Seed point calculated as average from DCA Points.
0024     ie. points Pm in the middle between two points P1 and P2 belonging 
0025     to tracks 1 and 2:  P1--Pm--P2
0026   */
0027 
0028   class PFDisplacedVertexCandidate {
0029   public:
0030     /// A structure dedicated to describe the link between two tracks
0031     /// containing a distance value and a Point where this distance
0032     /// is measurted.
0033     struct VertexLink {
0034       VertexLink() : distance_(-1), dcaPoint_(0, 0, 0), test_(0) {}
0035       VertexLink(float d, GlobalPoint p, char t) : distance_(d), dcaPoint_(p), test_(t) {}
0036       float distance_;
0037       GlobalPoint dcaPoint_;
0038       char test_;
0039     };
0040 
0041     /// Test used for the track linkind. For the moment only DCA is used,
0042     /// but other are possibles like distance between inner hits.
0043     enum VertexLinkTest { LINKTEST_DCA, LINKTEST_DUMMY, LINKTEST_ALL };
0044 
0045     typedef std::map<unsigned int, VertexLink> VertexLinkData;
0046 
0047     /// A type to provide the information about the position of DCA Points
0048     /// or values of DCA.
0049     typedef std::map<float, std::pair<int, int> > DistMap;
0050     typedef std::vector<float> DistVector;
0051 
0052     /// Default constructor
0053     PFDisplacedVertexCandidate();
0054 
0055     /// add a track Reference to the current Candidate
0056     void addElement(const TrackBaseRef);
0057 
0058     /// set a link between elements of indices i1 and i2, of "distance" dist
0059     /// the link is set in the linkData vector provided as an argument.
0060     /// As indicated by the 'const' statement, 'this' is not modified.
0061     void setLink(unsigned i1,
0062                  unsigned i2,
0063                  const float dist,
0064                  const GlobalPoint& dcaPoint,
0065                  const VertexLinkTest test = LINKTEST_DCA);
0066 
0067     /// associate 2 elements
0068     void associatedElements(const unsigned i,
0069                             const VertexLinkData& vertexLinkData,
0070                             std::multimap<float, unsigned>& sortedAssociates,
0071                             const VertexLinkTest test = LINKTEST_DCA) const;
0072 
0073     /// -------- Provide useful information -------- ///
0074 
0075     /// \return the map of Radius^2 to DCA Points
0076     DistMap r2Map() const;
0077 
0078     /// \return the vector of Radius^2 to DCA Points
0079     /// useful for FWLite
0080     DistVector r2Vector() const;
0081 
0082     /// \return the vector of DCA useful for DCA
0083     DistVector distVector() const;
0084 
0085     /// \return DCA point between two tracks
0086     const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const;
0087 
0088     /// A Vertex Candidate is valid if it has at least two tracks
0089     bool isValid() const { return elements_.size() > 1; }
0090 
0091     /// \return the reference to a given tracks
0092     const TrackBaseRef& tref(unsigned ie) const { return elements_[ie]; }
0093 
0094     /// \return the vector of Refs to tracks
0095     const std::vector<TrackBaseRef>& elements() const { return elements_; }
0096 
0097     /// \return the number of tracks associated to the candidate
0098     unsigned nTracks() const { return elements_.size(); }
0099 
0100     /// \return the map of link data
0101     const VertexLinkData& vertexLinkData() const { return vertexLinkData_; }
0102 
0103     /// cout function
0104     void Dump(std::ostream& out = std::cout) const;
0105 
0106   private:
0107     /// -------- Internal tools -------- ///
0108 
0109     /// \return distance of link between two tracks
0110     const float dist(unsigned ie1, unsigned ie2) const;
0111 
0112     /// test if a link between two tracks is valid: value_link =! -1
0113     bool testLink(unsigned ie1, unsigned ie2) const;
0114 
0115     /// cout function
0116     friend std::ostream& operator<<(std::ostream&, const PFDisplacedVertexCandidate&);
0117 
0118     /// -------- Storage of the information -------- ///
0119 
0120     /// Those are the tools from PFBlockAlgo
0121     /// \return size of linkData_, calculated from the number of elements
0122     unsigned vertexLinkDataSize() const;
0123 
0124     /// makes the correspondance between a 2d element matrix and
0125     /// the 1D vector which is the most compact way to store the matrix
0126     bool matrix2vector(unsigned i, unsigned j, unsigned& index) const;
0127 
0128     /// -------- MEMBERS -------- ///
0129 
0130     /// vector of refs to the associated tracks
0131     std::vector<TrackBaseRef> elements_;
0132 
0133     /// map of links between tracks
0134     VertexLinkData vertexLinkData_;
0135   };
0136 }  // namespace reco
0137 
0138 #endif