Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:23

0001 #ifndef _Vtx_TransientVertex_H_
0002 #define _Vtx_TransientVertex_H_
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0006 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0007 #include "RecoVertex/VertexPrimitives/interface/VertexState.h"
0008 #include "RecoVertex/VertexPrimitives/interface/TTtoTTmap.h"
0009 #include "DataFormats/VertexReco/interface/Vertex.h"
0010 #include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
0011 
0012 #include <vector>
0013 #include <map>
0014 
0015 /** \class TransientVertex
0016  */
0017 
0018 class TransientVertex {  //: public reco::Vertex {
0019 
0020 public:
0021   typedef std::map<reco::TransientTrack, float> TransientTrackToFloatMap;
0022 
0023   /** Empty constructor, produces invalid vertex
0024    */
0025   TransientVertex();
0026 
0027   /** Constructor defining the RecVertex by its 3D position
0028    *  and position uncertainty, its associated tracks
0029    *  and its chi-squared.
0030    *  The number of degrees of freedom is equal to
0031    *  2*nb of tracks - 3.
0032    */
0033   TransientVertex(const GlobalPoint& pos,
0034                   const GlobalError& posError,
0035                   const std::vector<reco::TransientTrack>& tracks,
0036                   float chi2);
0037   TransientVertex(const GlobalPoint& pos,
0038                   const double time,
0039                   const GlobalError& posError,
0040                   const std::vector<reco::TransientTrack>& tracks,
0041                   float chi2);
0042 
0043   /** Constructor defining the RecVertex by its 3D position
0044    *  and position uncertainty, its associated tracks, its chi-squared
0045    *  and its number of degrees of freedom.
0046    *  The ndf can be a float.
0047    */
0048   TransientVertex(const GlobalPoint& pos,
0049                   const GlobalError& posError,
0050                   const std::vector<reco::TransientTrack>& tracks,
0051                   float chi2,
0052                   float ndf);
0053   TransientVertex(const GlobalPoint& pos,
0054                   const double time,
0055                   const GlobalError& posError,
0056                   const std::vector<reco::TransientTrack>& tracks,
0057                   float chi2,
0058                   float ndf);
0059 
0060   /** Constructor defining the RecVertex by the prior,
0061    *  the vertex 3D position and uncertainty, the associated tracks
0062    *  and the chi-squared. Since the prior brings information on
0063    *  3 coordinates, the number of degrees of freedom is equal to
0064    *  2*nb of tracks.
0065    */
0066   TransientVertex(const GlobalPoint& priorPos,
0067                   const GlobalError& priorErr,
0068                   const GlobalPoint& pos,
0069                   const GlobalError& posError,
0070                   const std::vector<reco::TransientTrack>& tracks,
0071                   float chi2);
0072   TransientVertex(const GlobalPoint& priorPos,
0073                   const double priorTime,
0074                   const GlobalError& priorErr,
0075                   const GlobalPoint& pos,
0076                   const double time,
0077                   const GlobalError& posError,
0078                   const std::vector<reco::TransientTrack>& tracks,
0079                   float chi2);
0080 
0081   /** Constructor defining the RecVertex by the prior,
0082    *  the vertex 3D position and uncertainty, the associated tracks,
0083    *  the chi-squared and the number of degrees of freedom.
0084    *  The ndf can be a float.
0085    */
0086   TransientVertex(const GlobalPoint& priorPos,
0087                   const GlobalError& priorErr,
0088                   const GlobalPoint& pos,
0089                   const GlobalError& posError,
0090                   const std::vector<reco::TransientTrack>& tracks,
0091                   float chi2,
0092                   float ndf);
0093   TransientVertex(const GlobalPoint& priorPos,
0094                   const double priorTime,
0095                   const GlobalError& priorErr,
0096                   const GlobalPoint& pos,
0097                   const double time,
0098                   const GlobalError& posError,
0099                   const std::vector<reco::TransientTrack>& tracks,
0100                   float chi2,
0101                   float ndf);
0102 
0103   /** Constructor defining the RecVertex by the prior,
0104    *  the vertex 3D position and uncertainty, time and uncertainty, the associated tracks,
0105    *  the chi-squared and the number of degrees of freedom.
0106    *  The ndf can be a float.
0107    */
0108   TransientVertex(const GlobalPoint& priorPos,
0109                   const GlobalError& priorErr,
0110                   const double priorTime,
0111                   const double priorTimeErr,
0112                   const GlobalPoint& pos,
0113                   const GlobalError& posError,
0114                   const double time,
0115                   const double timeErr,
0116                   const std::vector<reco::TransientTrack>& tracks,
0117                   float chi2,
0118                   float ndf);
0119 
0120   /** Constructor defining the RecVertex by its 3D position 
0121    *  and position uncertainty, its associated tracks 
0122    *  and its chi-squared. 
0123    *  The number of degrees of freedom is equal to 
0124    *  2*nb of tracks - 3.
0125    */
0126   TransientVertex(const VertexState& state, const std::vector<reco::TransientTrack>& tracks, float chi2);
0127 
0128   /** Constructor defining the RecVertex by its 3D position
0129    *  and position uncertainty, its associated tracks, its chi-squared
0130    *  and its number of degrees of freedom.
0131    *  The ndf can be a float.
0132    */
0133   TransientVertex(const VertexState& state, const std::vector<reco::TransientTrack>& tracks, float chi2, float ndf);
0134 
0135   /** Constructor defining the RecVertex by the prior,
0136    *  the vertex 3D position and uncertainty, the associated tracks
0137    *  and the chi-squared. Since the prior brings information on
0138    *  3 coordinates, the number of degrees of freedom is equal to
0139    *  2*nb of tracks.
0140    */
0141   TransientVertex(const VertexState& prior,
0142                   const VertexState& state,
0143                   const std::vector<reco::TransientTrack>& tracks,
0144                   float chi2);
0145 
0146   /** Constructor defining the RecVertex by the prior,
0147    *  the vertex 3D position and uncertainty, the associated tracks,
0148    *  the chi-squared and the number of degrees of freedom.
0149    *  The ndf can be a float.
0150    */
0151   TransientVertex(const VertexState& prior,
0152                   const VertexState& state,
0153                   const std::vector<reco::TransientTrack>& tracks,
0154                   float chi2,
0155                   float ndf);
0156 
0157   //   /** Constructor defining the RecVertex by its 3D position
0158   //    *  and position uncertainty, its associated tracks, its chi-squared
0159   //    *  and its number of degrees of freedom, and the track weights.
0160   //    *  The ndf can be a float.
0161   //    */
0162   //   TransientVertex(const VertexState & state,
0163   //            const std::vector<reco::TransientTrack> & tracks, float chi2, float ndf,
0164   //            const reco::TransientTrackToFloatMap & weightMap);
0165 
0166   /** Access methods
0167    */
0168   VertexState const& vertexState() const { return theVertexState; }
0169   GlobalPoint position() const { return theVertexState.position(); }
0170   GlobalError positionError() const {
0171     return theVertexState.is4D() ? theVertexState.error4D() : theVertexState.error();
0172   }
0173   GlobalPoint priorPosition() const { return thePriorVertexState.position(); }
0174   GlobalError priorError() const {
0175     return thePriorVertexState.is4D() ? thePriorVertexState.error4D() : thePriorVertexState.error();
0176   }
0177   double time() const { return theVertexState.time(); }
0178   double timeError() const { return theVertexState.timeError(); }
0179   double priorTime() const { return thePriorVertexState.time(); }
0180   double priorTimeError() const { return thePriorVertexState.timeError(); }
0181   bool hasPrior() const { return withPrior; }
0182 
0183   //   /** Implements method of abstract Vertex.
0184   //    *  Returns track pointer container by value
0185   //    */
0186   //   Vertex::TrackPtrContainer tracks() const;
0187 
0188   float totalChiSquared() const { return theChi2; }
0189   float normalisedChiSquared() const { return totalChiSquared() / degreesOfFreedom(); }
0190   float degreesOfFreedom() const { return theNDF; }
0191 
0192   /** Returns true if vertex is valid.
0193    *  An invalid RecVertex is created e.g. when vertex fitting fails.
0194    */
0195   bool isValid() const { return vertexValid; }
0196 
0197   /** Access to the original tracks used to make the vertex.
0198    *  Returns track container by value.
0199    */
0200   std::vector<reco::TransientTrack> const& originalTracks() const { return theOriginalTracks; }
0201 
0202   /**
0203    * Returns true if at for at least one of the original tracks,
0204    * the refitted track is available
0205    */
0206   bool hasRefittedTracks() const { return withRefittedTracks; }
0207 
0208   /** Access to the refitted tracks used to make the vertex.
0209    *  Returns track container by value.
0210    */
0211   std::vector<reco::TransientTrack> const& refittedTracks() const { return theRefittedTracks; }
0212 
0213   /**
0214    * Returns the original track which corresponds to a particular refitted Track
0215    * Throws an exception if now refitted tracks are stored ot the track is not found in the list
0216    */
0217 
0218   reco::TransientTrack originalTrack(const reco::TransientTrack& refTrack) const;
0219 
0220   /**
0221    * Returns the refitted track which corresponds to a particular original Track
0222    * Throws an exception if now refitted tracks are stored ot the track is not found in the list
0223    */
0224   reco::TransientTrack refittedTrack(const reco::TransientTrack& track) const;
0225 
0226   /** Method to set the refitted tracks used to make the vertex.
0227    */
0228   void refittedTracks(const std::vector<reco::TransientTrack>& refittedTracks);
0229 
0230   /**
0231    * Returns true if the track-weights are available.
0232    */
0233   bool hasTrackWeight() const { return theWeightMapIsAvailable; }
0234 
0235   /**
0236    *   Returns the weight with which a track has been used in the fit.
0237    *   If the track is not present in the list, it is obviously not used, and
0238    *   this method returns a weight of 0.
0239    *   If this information has not been provided at construction, a weight of
0240    *   1.0 is assumed for all tracks used and present in the originalTracks() std::vector.
0241    */
0242   float trackWeight(const reco::TransientTrack& track) const;
0243 
0244   TransientTrackToFloatMap weightMap() const { return theWeightMap; }
0245 
0246   void weightMap(const TransientTrackToFloatMap& theMap);
0247 
0248   /**
0249    * Returns true if the Track-to-track covariance matrices have been calculated.
0250    */
0251   bool tkToTkCovarianceIsAvailable() const { return theCovMapAvailable; }
0252 
0253   /**
0254    *   Returns the Track-to-track covariance matrix for two specified tracks.
0255    *   In case these do not exist, or one of the tracks does not belong to the
0256    *   vertex, an exception is thrown.
0257    */
0258   AlgebraicMatrix33 tkToTkCovariance(const reco::TransientTrack& t1, const reco::TransientTrack& t2) const;
0259   void tkToTkCovariance(const TTtoTTmap& covMap);
0260 
0261   operator reco::Vertex() const;
0262   operator reco::VertexCompositePtrCandidate() const;
0263 
0264 private:
0265   mutable VertexState thePriorVertexState;
0266   mutable VertexState theVertexState;
0267 
0268   //   void addTracks(const std::vector<reco::TransientTrack> & tracks);
0269 
0270   std::vector<reco::TransientTrack> theOriginalTracks;
0271   std::vector<reco::TransientTrack> theRefittedTracks;
0272 
0273   float theChi2;
0274   float theNDF;
0275   bool vertexValid;
0276   bool withPrior, theWeightMapIsAvailable, theCovMapAvailable;
0277   bool withRefittedTracks;
0278   TTtoTTmap theCovMap;
0279   TransientTrackToFloatMap theWeightMap;
0280 };
0281 
0282 #endif