Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
0023 
0024 #ifndef KFTOPOPERFORMANCE_H
0025 #define KFTOPOPERFORMANCE_H
0026 
0027 
0028 #include "KFParticlePerformanceBase.h"
0029 
0030 #include "KFMCVertex.h"
0031 #include "KFMCTrack.h"
0032 #include <cstdio>
0033 #include <map>
0034 
0035 #include "KFPartMatch.h"
0036 #include "KFMCParticle.h"
0037 
0038 class AliHLTTPCCAGBTracker;
0039 
0040 class KFParticleTopoReconstructor;
0041 class KFPHistogram;
0042 
0043 /** @class KFTopoPerformance
0044  ** @brief The class to collect histograms.
0045  ** @author  M.Zyzak, I.Kisel
0046  ** @date 05.02.2019
0047  ** @version 1.0
0048  **
0049  ** The class collects a set of histograms.
0050  ** For each particle from the KF Particle Reconstruction scheme histograms with parameter distribution,
0051  ** efficiencies, fit QA, fit QA of daughters, histograms for the side bands method and histograms for
0052  ** multi-differential extraction of spectra are collected. Also, a set of histograms for quality of
0053  ** the reconstructed parameters of primary vertices is created: distribution of parameters; fit QA;
0054  ** fit QA of primary tracks; contamination of ghost, secondary (background) tracks and tracks from
0055  ** another primary vertex; efficiency.
0056  **/
0057 
0058 class KFTopoPerformance: public KFParticlePerformanceBase
0059 {
0060  public:
0061   
0062   KFTopoPerformance();
0063   virtual ~KFTopoPerformance();
0064 #ifdef KFPWITHTRACKER
0065   virtual void SetNewEvent(
0066     const AliHLTTPCCAGBTracker * const Tracker,
0067     AliHLTResizableArray<AliHLTTPCCAHitLabel> *hitLabels,
0068     AliHLTResizableArray<AliHLTTPCCAMCTrack> *mcTracks,
0069     AliHLTResizableArray<AliHLTTPCCALocalMCPoint> *localMCPoints);
0070 #endif  
0071   void SetTopoReconstructor( const KFParticleTopoReconstructor * const TopoReconstructor );
0072   const KFParticleTopoReconstructor * GetTopoReconstructor() const { return fTopoReconstructor; } ///< Returns pointer to the KFParticleTopoReconstructor object.
0073     
0074     // Check if MC track is reconstructable. Calculate set of MC track. Etc.
0075   virtual void CheckMCTracks(); // fill mcData.
0076     // Find reco-MCTracks correspondence
0077   virtual void MatchTracks();   // fill recoData.
0078     // Calculate efficiencies
0079   
0080   /// Histograms
0081   void FillHistos();
0082   void FillHistos(const KFPHistogram* histograms);
0083   void FillMCHistos();
0084 
0085   void AddV0Histos();
0086   
0087   void SetTrackMatch(const std::vector<int>& trackMatch) { fTrackMatch = trackMatch;} ///< Fill matching between Monte Carlo and reconstructed tracks.
0088   void SetMCTracks(const std::vector<KFMCTrack>& mcTracks) { vMCTracks = mcTracks; } ///< Fill Monte Carlo tracks.
0089   
0090   const KFPartEfficiencies GetEfficiency() const { return fParteff; } ///< Returns KFPartEfficiencies object with calculated efficiency.
0091   void SetPrintEffFrequency(int n) { fPrintEffFrequency = n;} ///< Sets frequency in events for efficiency table to be printed on the screen.
0092 
0093   const std::vector<KFMCVertex> GetPrimVertices() { return fPrimVertices; } ///< Returns Monte Carlo primary vertices in the current event.
0094   const std::vector<KFMCParticle>& MCParticles() { return vMCParticles; } ///< Returns Monte Carlo particles in the current event.
0095   const std::vector<KFPartMatch>& ParticlesMatch() { return RtoMCParticleId; } ///< Returns matching between reconstructed and Monte Carlo particles.
0096   const std::vector<KFPartMatch>& GetMCtoRPVId() { return MCtoRPVId; } ///< Returns matching between Monte Carlo and reconstructed primary vertices.
0097   const std::vector<KFPartMatch>& GetRtoMCPVId() { return RtoMCPVId; } ///< Returns matching between reconstructed and Monte Carlo primary vertices.
0098   const KFMCTrack& GetMCTrack(const int iRecoTrack)
0099   { 
0100     /** Returns Monte Carlo track matched with the reconstructed track with index "iRecoTrack". */
0101     int iMCTrack = 0;
0102     if(RtoMCParticleId[iRecoTrack].IsMatched())
0103       iMCTrack = RtoMCParticleId[iRecoTrack].GetBestMatch();
0104     return vMCTracks[iMCTrack]; 
0105   }
0106   
0107   void SetCentralityBin(const int iBin) { fCentralityBin = iBin; } ///< Sets centrality bin of the current event.
0108   void SetCentralityWeight(const float weight) { fCentralityWeight = weight; } ///< Sets weight of the centrality bin of the current event.
0109   
0110  private:
0111 
0112   const KFTopoPerformance& operator = (const KFTopoPerformance&); ///< Copying of objects of this class is forbidden.
0113   KFTopoPerformance(const KFTopoPerformance&); ///< Copying of objects of this class is forbidden.
0114    
0115   void GetMCParticles();
0116   void MatchParticles();
0117   void MatchPV();
0118   void CalculateEfficiency();
0119   void CalculatePVEfficiency();
0120   void FindReconstructableMCParticles();
0121   void CheckMCParticleIsReconstructable(KFMCParticle &part);
0122   void FindReconstructableMCVertices();
0123   void FillParticleParameters(KFParticle& TempPart,
0124                               int iParticle,
0125                               int iP,
0126                               int iPV,
0127                               TH1F* histoParameters[4][KFPartEfficiencies::nParticles][nHistoPartParam],
0128                               TH2F* histoParameters2D[4][KFPartEfficiencies::nParticles][nHistoPartParam2D],
0129                               TH3F* histoParameters3D[1][KFPartEfficiencies::nParticles][nHistoPartParam3D],
0130                               TH1F* histoFit[KFPartEfficiencies::nParticles][nFitQA] = 0,
0131                               TH1F* histoFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA] = 0,
0132                               TH1F* histoDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA] = 0,
0133                               std::vector<int>* multiplicities = 0);
0134   
0135   const KFParticleTopoReconstructor *fTopoReconstructor; ///< Pointer to the KFParticleTopoReconstructor object with particles and vertices to be analysed.
0136 
0137   std::vector<KFMCVertex> fPrimVertices; ///< Monte Carlo primary vertices.
0138   std::vector<int> fMCTrackToMCPVMatch; ///< Matching of Monte Carlo tracks and corresponding primary vertex 
0139   std::vector<double> fPVPurity; ///< Purity of the primary vertices.
0140   std::vector<double> fPVTracksRate[4]; ///< Ratio in the primary vertices of: 0 - ghost tracks, 1 - from trigger PV, 2 - from pileup, 3 - from physics background.
0141   std::vector<int> fNCorrectPVTracks; ///< Number of correctly attached tracks in the corresponding reconstructed primary vertex.
0142 
0143   std::vector<int> fTrackMatch; ///< Matching between reconstructed tracks and 
0144   std::vector<KFMCTrack> vMCTracks;  ///< Monte Carlo tracks (parameters of the particle trajectories at the production point).
0145   std::vector<KFMCParticle> vMCParticles;  ///< Monte Carlo particles.
0146   std::vector<int> fNeutralIndex; ///< Index of the created neutral daughters for missing mass method in vMCTracks for the Monte Carlo track with given index.
0147   
0148   /** Matching between Monte Carlo and reconstructed particles. MCtoRParticleId[i] provides index of the reconstructed particle in the 
0149    ** fTopoReconstructor->GetParticles() array for the Monte Carlo particle (or track) with index "i". **/
0150   std::vector<KFPartMatch> MCtoRParticleId;
0151   /** Matching between reconstructed and Monte Carlo particles. RtoMCParticleId[i] provides index of the Monte Carlo particle in the 
0152    ** vMCTracks and vMCParticles arrays for the reconstructed particle with index "i" from fTopoReconstructor->GetParticles(). **/
0153   std::vector<KFPartMatch> RtoMCParticleId;
0154 
0155   /** Matching between Monte Carlo and reconstructed primary vertices. MCtoRPVId[i] provides index of the reconstructed vertex in the 
0156    ** fTopoReconstructor->GetPrimVertex() array for the Monte Carlo vertex with index "i". **/
0157   std::vector<KFPartMatch> MCtoRPVId;
0158   /** Matching between reconstructed and Monte Carlo primary vertices. RtoMCPVId[i] provides index of the Monte Carlo vertex in the 
0159    ** fPrimVertices array for the reconstructed vertex with index "i" from fTopoReconstructor->GetPrimVertex(). **/
0160   std::vector<KFPartMatch> RtoMCPVId;
0161   
0162   int fPrintEffFrequency; ///< Frequency in events with which efficiency table is printed on the screen. 
0163   
0164   int fCentralityBin; ///< Centrality bin for the current event. 
0165   float fCentralityWeight; ///< Centrality weight for the current event.
0166 };
0167 
0168 #endif
0169 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE