Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 KFParticlePERFORMANCEBASE_H
0025 #define KFParticlePERFORMANCEBASE_H
0026 
0027 #ifdef KFPWITHTRACKER
0028 #include "AliHLTTPCCounters.h"
0029 
0030 #include "AliHLTTPCPerformanceBase.h"
0031 
0032 #include "AliHLTTPCCADef.h"
0033 #include "AliHLTArray.h"
0034 #include "AliHLTTPCCAMCTrack.h"
0035 #include "AliHLTTPCCAMCPoint.h"
0036 #endif
0037 
0038 #include "KFPartEfficiencies.h"
0039 #include "KFPVEfficiencies.h"
0040 
0041 #include <map>
0042 #include <string>
0043 
0044 class TDirectory;
0045 class TH1F;
0046 class TH2F;
0047 class TH3F;
0048 
0049 class KFParticle;
0050 class TProfile;
0051 class TProfile2D;
0052 
0053 /** @class KFParticlePerformanceBase
0054  ** @brief The base class for KFTopoPerformance.
0055  ** @author  M.Zyzak, I.Kisel
0056  ** @date 05.02.2019
0057  ** @version 1.0
0058  **
0059  ** The class contains a set of histograms, allocates memory for them, sets names and axis names.
0060  ** For each particle from the KF Particle Reconstruction scheme histograms with parameter distribution,
0061  ** efficiencies, fit QA, fit QA of daughters, histograms for the side bands method and histograms for
0062  ** multi-differential extraction of spectra are collected. Also, a set of histograms for quality of
0063  ** the reconstructed parameters of primary vertices is created: distribution of parameters; fit QA;
0064  ** fit QA of primary tracks; contamination of ghost, secondary (background) tracks and tracks from
0065  ** another primary vertex; efficiency.
0066  **/
0067 
0068 class KFParticlePerformanceBase
0069 #ifdef KFPWITHTRACKER
0070 : public AliHLTTPCPerformanceBase
0071 #endif
0072 {
0073  public:
0074 
0075   KFParticlePerformanceBase();
0076   virtual ~KFParticlePerformanceBase(){};
0077     
0078     /// Histograms
0079   virtual void CreateHistos(std::string histoDir = "", TDirectory* outFile = 0, std::map<int,bool> decays = std::map<int,bool>());
0080   TDirectory* GetHistosDirectory() { return fHistoDir; } ///< Returns pointer to the ROOT directory with created histograms.
0081 
0082   /** Switch off collection of histograms requiring Monte Carlo information. Not to allocate memory should be called 
0083    ** before KFParticlePerformanceBase::CreateHistos(). **/
0084   void DoNotStoreMCHistograms()      { fStoreMCHistograms = 0; } 
0085   /** Switch off collection of histograms for primary and secondary candidates. Not to allocate memory should be called 
0086    ** before KFParticlePerformanceBase::CreateHistos(). **/
0087   void DoNotStorePrimSecHistograms() { fStorePrimSecHistograms = 0; }
0088   /** Switch off collection of Z-R histograms. Not to allocate memory should be called 
0089    ** before KFParticlePerformanceBase::CreateHistos(). **/
0090   void DoNotStoreZRHistograms()      { fStoreZRHistograms = 0; }
0091   
0092   /** Returns residual histogram with "iParameter" parameter for decay with "iDecay" number. */
0093   const TH1F* GetDecayResidual(const int iDecay, const int iParameter) const { return hFitQA[iDecay][iParameter];          }
0094   /** Returns pull histogram with "iParameter" parameter for decay with "iDecay" number. */
0095   const TH1F* GetDecayPull(const int iDecay, const int iParameter)     const { return hFitQA[iDecay][iParameter+nFitQA/2]; }
0096   
0097 // efficiencies
0098   KFPartEfficiencies fParteff; ///< Object with reconstruction efficiency of short-lived particles.
0099   KFPVEfficiencies fPVeff; ///< Object with reconstruction efficiency of primary vertices defined by the reconstructed tracks.
0100   KFPVEfficiencies fPVeffMCReconstructable; ///< Object with reconstruction efficiency of primary vertices defined by the Monte Carlo tracks.
0101     
0102  protected:
0103   TString outfileName; ///< Name of the output file, where histograms will be stored.
0104   TDirectory* histodir; ///< Pointer to the ROOT directory, where histograms are created.
0105 
0106   int fNEvents; ///< Number of processed events.
0107   bool fStoreMCHistograms; ///< Flag showing if histograms requiring Monte Carlo information should be created and collected. "True" by default.
0108   bool fStorePrimSecHistograms; ///< Flag showing if histograms for primary and secondary candidates should be created and collected. "True" by default.
0109   bool fStoreZRHistograms; ///< Flag showing if Z-R histograms should be created and collected. "True" by default.
0110 
0111 //histos
0112   static const int nFitQA = 16; ///< Number of fit QA histograms: residuals and pulls in X, Y, Z, Px, Py, Pz, E, M.
0113   TH1F *hFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of daughter particles at production point.
0114   TH1F *hFitQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the reconstructed particle: X, Y, Z at decay point, P, E, M - at production point
0115   TH1F *hFitQANoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with no constraints set.
0116   TH1F *hFitQAMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass constraint. 
0117   TH1F *hFitQATopoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the production point constraint.
0118   TH1F *hFitQATopoMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass and production point constraints.
0119 
0120   static const int nDSToParticleQA = 7; ///< Number of histograms to evaluate GetDStoParticle function: residuals and pulls in X, Y, Z; distance between DCA points.
0121   TH1F *hDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA]; ///< Histograms to evaluate KFParticleSIMD::GetDStoParticle() function
0122   
0123   /** \brief Number of histograms with parameter distributions: mass, p, pt, rapidity, decay length, c*tau, 
0124    ** chi/ndf, prob, theta, phi, X, Y, Z, R, L, L/dL, Mt, multiplicity. **/
0125   static const int nHistoPartParam = 18;
0126   /** Number of sets of histograms with parameter distributions: 0 - all candidates, 1 - reconstructed signal, 2 - physics background from other decays, 3 - combinatorial
0127    ** background (ghost), 4 - reconstructed signal for side bands method, 5- reconstructed background for side bands method, 6 - MC signal. **/
0128   static const int nParametersSet = 7;
0129   TH1F *hPartParam[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of all candidates.
0130   TH1F *hPartParamPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates.
0131   TH1F *hPartParamPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass constraint.
0132   TH1F *hPartParamPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with vertex constraint.
0133   TH1F *hPartParamPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass and vertex constraint.
0134   TH1F *hPartParamSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates.
0135   TH1F *hPartParamSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates with mass constraint.
0136 
0137   static const int nHistoPartParam2D = 4; ///< Number of 2D histograms: 0 - y-pt, 1 - z-r, 2 - armenteros, 3- y-mt.
0138   TH2F *hPartParam2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D histograms for all candidates.
0139   TH2F *hPartParam2DPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates.
0140   TH2F *hPartParam2DPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with mass constraint.
0141   TH2F *hPartParam2DPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with vertex constraint.
0142   TH2F *hPartParam2DPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D with mass and vertex constraints.
0143   TH2F *hPartParam2DSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates.
0144   TH2F *hPartParam2DSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates with mass constraint.
0145 
0146   static const int nHistoPartParam3D = 6; ///< Number of 3D histograms: y-pt-M, y-mt-M, b-pt-M, b-y-M, b-mt-M, ct-pt-M
0147   TH3F *hPartParam3D[1][KFPartEfficiencies::nParticles][nHistoPartParam3D]; ///< 3D histograms.
0148 
0149   static const int nPartEfficiency = 9; ///< Number of efficiency plots for each decay: vs p, pt, y, z, c*tau, decay length, l, r, Mt.
0150   TProfile* hPartEfficiency[KFPartEfficiencies::nParticles][3][nPartEfficiency]; ///< Efficiency plots.
0151   static const int nPartEfficiency2D = 2;  ///< Number of 2D efficiency plots for each decay: y-pt, y-mt.
0152   TProfile2D* hPartEfficiency2D[KFPartEfficiencies::nParticles][3][nPartEfficiency2D]; ///< 2D efficiency plots.
0153   
0154   static const int nHistosPV = 7; ///< Number of QA histograms for primary vertices: residuals, pulls, number of lost tracks.
0155   TH1F *hPVFitQa[2][nHistosPV]; ///< Fit QA of primary vertices, 1D histograms.
0156   TH2F *hPVFitQa2D[2][2][nHistosPV-1]; ///< Fit QA of primary vertices, 2D histograms.
0157 
0158   /** Number of histograms with parameter distributions: x, y, z, r, Ntracks, Chi2, NDF, Chi2/NDF, prob, purity, part of ghost tracks, 
0159    ** part of tracks from the current vertex, number of tracks from merged vertices, number of background tracks from decays, distance in Z between clones. **/
0160   static const int nHistosPVParam = 15; ///< 
0161   TH1F *hPVParam[nHistosPVParam]; ///< Histograms for all vertex candidates.
0162   TH1F *hPVParamGhost[nHistosPVParam]; ///< Histograms for ghost (combinatorial background) vertex candidates.
0163   TH1F *hPVParamSignal[nHistosPVParam]; ///< Histograms for signal vertex candidates.
0164   TH1F *hPVParamPileup[nHistosPVParam]; ///< Histograms for pileup vertex candidates.
0165   TH1F *hPVParamBG[nHistosPVParam]; ///< Histograms for physics background (decays, secondary vertices) vertex candidates.
0166   static const int nHistosPVParam2D = 1; ///< Number of 2D histograms for primary vertex.
0167   TH2F *hPVParam2D[nHistosPVParam2D]; ///< x-y histogram. 
0168   
0169   static const int nFitPVTracksQA = 12; ///< Number of fit QA histograms for primary tracks: residuals and pulls in X, Y, Z, Px, Py, Pz.
0170   TH1F *hFitPVTracksQA[nFitPVTracksQA]; ///< Residuals and pulls of primary tracks at the primary vertex position.
0171   
0172   static const int nHistosTP = KFPartEfficiencies::nParticles + 8; ///< Number of histograms with chi2 primary distributions for daughter tracks.
0173   /** Histograms with chi2 primary distributions for daughter tracks of each decays plus 4 distributions of chi2 and 4 prob for primary, secondary,
0174    ** ghost and all particles. **/
0175   TH1F *hTrackParameters[nHistosTP]; 
0176   
0177   static const int nPVefficiency = 6; ///< Number of Efficiency plots for primary vertices for each category.
0178   TProfile* hPVefficiency[4][nPVefficiency]; ///< Efficiency plots for primary vertices.
0179   
0180   TDirectory *fHistoDir; ///< ROOT directory with histograms.
0181 
0182   bool IsCollectZRHistogram(int iParticle) const;
0183   bool IsCollect3DHistogram(int iParticle) const;
0184   bool IsCollectArmenteros(int iParticle) const;
0185   
0186  private:
0187   const KFParticlePerformanceBase& operator = (const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden.
0188   KFParticlePerformanceBase(const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden.
0189   
0190   void CreateFitHistograms(TH1F* histo[nFitQA], int iPart);
0191   void CreateEfficiencyHistograms(TProfile* histo[3][nPartEfficiency], TProfile2D* histo2[3][nPartEfficiency2D]);
0192   void CreateParameterHistograms(TH1F* histoParameters[KFPartEfficiencies::nParticles][nHistoPartParam],
0193                                  TH2F *histoParameters2D[KFPartEfficiencies::nParticles][nHistoPartParam2D],
0194                                  TH3F *histoParameters3D[KFPartEfficiencies::nParticles][nHistoPartParam3D],
0195                                  int iPart, bool drawZR = 0);
0196   void CreateParameterSubfolder(TString folderName, 
0197                                 TH1F* histoParameters[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam],
0198                                 TH2F* histoParameters2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D],
0199                                 TH1F* histoFit[KFPartEfficiencies::nParticles][nFitQA], int iPart, bool withWrongPVHypothesis = 0);
0200   
0201   TString GetDirectoryPath();
0202 };
0203 
0204 #endif
0205 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE