Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:14

0001 /*
0002  * This file is part of KFParticle package
0003  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
0004  *               2007-2019 Goethe University of Frankfurt
0005  *               2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
0006  *               2007-2019 Maksym Zyzak
0007  *
0008  * KFParticle is free software: you can redistribute it and/or modify
0009  * it under the terms of the GNU General Public License as published by
0010  * the Free Software Foundation, either version 3 of the License, or
0011  * (at your option) any later version.
0012  *
0013  * KFParticle is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016  * GNU General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU General Public License
0019  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0020  */
0021 
0022 
0023 #ifndef KFParticlePVReconstructor_H
0024 #define KFParticlePVReconstructor_H
0025 
0026 #include "KFVertex.h"
0027 #include "assert.h"
0028 
0029 #include <vector>
0030 
0031 class KFParticle;
0032 class KFPTrackVector;
0033 
0034 /** @class KFParticlePVReconstructor
0035  ** @brief Class for reconstruction of primary vertices.
0036  ** @author  I.Kisel, M.Zyzak
0037  ** @date 05.02.2019
0038  ** @version 1.0
0039  **
0040  ** The class is based on KFVertex. For reconstruction of primary vertices
0041  ** the Kalman filter mathematics is used. Allows reconstruction of multiple
0042  ** primary vertices.
0043  **/
0044 
0045 class KFParticlePVReconstructor{
0046  public:
0047   KFParticlePVReconstructor():fParticles(0), fNParticles(0), fWeight(0.f), fBeamLine(), fIsBeamLine(0), fClusters(0), fPrimVertices(0), fChi2CutPreparation(100), fChi2Cut(16) {};
0048   ~KFParticlePVReconstructor(){};
0049   
0050   void Init(KFPTrackVector *tracks, int nParticles);
0051   
0052   void ReconstructPrimVertex();
0053 
0054   int NPrimaryVertices() const { return fPrimVertices.size(); } ///< Returns number of the found candidates for the primary vertex.
0055   KFParticle &GetPrimVertex(int iPV=0)   { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFParticle with index "iPV".
0056   KFVertex   &GetPrimKFVertex(int iPV=0)   { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFVertex with index "iPV".
0057   std::vector<int>& GetPVTrackIndexArray(int iPV=0) { return fClusters[iPV].fTracks; } ///< Returns vector with track indices from a cluster with index "iPV".
0058   KFParticle &GetParticle(int i){ assert( i < fNParticles ); return fParticles[i]; } ///< Returns input particle with index "i".
0059   
0060   void SetBeamLine(KFParticle& p) { fBeamLine = p; fIsBeamLine = 1; } ///< Sets the beam line position and direction, sets corresponding flag to "true".
0061   bool IsBeamLine() const { return fIsBeamLine; } ///< Check if the beam line is set.
0062   
0063   /** Adds externally found primary vertex to the list together with the cluster of
0064    ** tracks from this vertex.
0065    ** \param[in] pv - external primary vertex
0066    ** \param[in] tracks - vector with indices of tracks associated with the provided primary vertex.
0067    **/
0068   void AddPV(const KFVertex &pv, const std::vector<int> &tracks);
0069   /** Adds externally found primary vertex to the list.
0070    ** \param[in] pv - external primary vertex
0071    **/
0072   void AddPV(const KFVertex &pv);
0073   void CleanPV() { fClusters.clear(); fPrimVertices.clear(); } ///< Clean vectors with primary vertex candidates and corresponding clusters.
0074 
0075   /** \brief Sets cut fChi2Cut on chi2-deviation of primary tracks from the vertex candidate to "chi2"
0076    ** and a soft preparation cut fChi2CutPreparation to "10*chi2". */
0077   void SetChi2PrimaryCut(float chi2) { fChi2Cut = chi2; fChi2CutPreparation = chi2*5; }
0078   
0079  private:
0080   KFParticlePVReconstructor &operator=(KFParticlePVReconstructor &); ///< Is not defined. Deny copying of the objects of this class.
0081   KFParticlePVReconstructor(KFParticlePVReconstructor &); ///< Is not defined. Deny copying of the objects of this class.
0082 
0083   void FindPrimaryClusters( int cutNDF = 1);
0084 
0085   std::vector<KFParticle> fParticles; ///< Array of the input particles constructed from tracks.
0086   int fNParticles;                    ///< Number of the input particles.
0087 
0088   std::vector<float> fWeight; ///< Vector with weights of each track, the weight is defined in KFParticlePVReconstructor::Init().
0089   
0090   KFParticle fBeamLine; ///< Position and direction of the beam line.
0091   bool fIsBeamLine;     ///< Flag showing if the beam line is set.
0092   
0093   /** @class KFParticleCluster
0094    ** @brief A helper structure for reconstruction of a primary vertex.
0095    ** @author  I.Kisel, M.Zyzak
0096    ** @date 05.02.2019
0097    ** @version 1.0
0098    ** Contains a list of track and initial approximation for the vertex position,
0099    ** which are then provided to KFVertex object for fit.
0100    **/
0101   struct KFParticleCluster {
0102     KFParticleCluster():fTracks(0) {};
0103     std::vector<int> fTracks; ///< List of tracks in a cluster.
0104     float fP[3]; ///< Estimation of the vertex position based on the current cluster: {X, Y, Z}.
0105     float fC[6]; ///< Estimated errors of the position approximation.
0106   };
0107 
0108   std::vector< KFParticleCluster > fClusters; ///< Vector with clusters to be used for fit of a primary vertex.
0109   std::vector<KFVertex> fPrimVertices;  ///< Vector with reconstructed candidates for a primary vertex.
0110   
0111   float fChi2CutPreparation; ///< A soft cut on the chi2-deviation which is used to form a cluster.
0112   float fChi2Cut;            ///< Cut on the chi2-deviation of the tracks to the primary vertex \see KFVertex::ConstructPrimaryVertex(), where it is used.
0113 }; // class KFParticlePVReconstructor
0114 
0115 
0116 #endif // KFParticlePVReconstructor_H
0117