KFTopoPerformance.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //----------------------------------------------------------------------------
  2. // Implementation of the KFParticle class
  3. // .
  4. // @author I.Kisel, I.Kulakov, M.Zyzak
  5. // @version 1.0
  6. // @since 20.08.13
  7. //
  8. //
  9. // -= Copyright &copy ALICE HLT and CBM L1 Groups =-
  10. //____________________________________________________________________________
  11. #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
  12. #ifndef KFTOPOPERFORMANCE_H
  13. #define KFTOPOPERFORMANCE_H
  14. #include "KFParticlePerformanceBase.h"
  15. #include "KFMCVertex.h"
  16. #include "KFMCTrack.h"
  17. #include <cstdio>
  18. #include <map>
  19. #include "KFPartMatch.h"
  20. #include "KFMCParticle.h"
  21. class AliHLTTPCCAGBTracker;
  22. class KFParticleTopoReconstructor;
  23. class KFPHistogram;
  24. /** @class KFTopoPerformance
  25. ** @brief The class to collect histograms.
  26. ** @author M.Zyzak, I.Kisel
  27. ** @date 05.02.2019
  28. ** @version 1.0
  29. **
  30. ** The class collects a set of histograms.
  31. ** For each particle from the KF Particle Reconstruction scheme histograms with parameter distribution,
  32. ** efficiencies, fit QA, fit QA of daughters, histograms for the side bands method and histograms for
  33. ** multi-differential extraction of spectra are collected. Also, a set of histograms for quality of
  34. ** the reconstructed parameters of primary vertices is created: distribution of parameters; fit QA;
  35. ** fit QA of primary tracks; contamination of ghost, secondary (background) tracks and tracks from
  36. ** another primary vertex; efficiency.
  37. **/
  38. class KFTopoPerformance: public KFParticlePerformanceBase
  39. {
  40. public:
  41. KFTopoPerformance();
  42. virtual ~KFTopoPerformance();
  43. #ifdef KFPWITHTRACKER
  44. virtual void SetNewEvent(
  45. const AliHLTTPCCAGBTracker * const Tracker,
  46. AliHLTResizableArray<AliHLTTPCCAHitLabel> *hitLabels,
  47. AliHLTResizableArray<AliHLTTPCCAMCTrack> *mcTracks,
  48. AliHLTResizableArray<AliHLTTPCCALocalMCPoint> *localMCPoints);
  49. #endif
  50. void SetTopoReconstructor( const KFParticleTopoReconstructor * const TopoReconstructor );
  51. const KFParticleTopoReconstructor * GetTopoReconstructor() const { return fTopoReconstructor; } ///< Returns pointer to the KFParticleTopoReconstructor object.
  52. // Check if MC track is reconstructable. Calculate set of MC track. Etc.
  53. virtual void CheckMCTracks(); // fill mcData.
  54. // Find reco-MCTracks correspondence
  55. virtual void MatchTracks(); // fill recoData.
  56. // Calculate efficiencies
  57. /// Histograms
  58. void FillHistos();
  59. void FillHistos(const KFPHistogram* histograms);
  60. void FillMCHistos();
  61. void AddV0Histos();
  62. void SetTrackMatch(const std::vector<int>& trackMatch) { fTrackMatch = trackMatch;} ///< Fill matching between Monte Carlo and reconstructed tracks.
  63. void SetMCTracks(const std::vector<KFMCTrack>& mcTracks) { vMCTracks = mcTracks; } ///< Fill Monte Carlo tracks.
  64. const KFPartEfficiencies GetEfficiency() const { return fParteff; } ///< Returns KFPartEfficiencies object with calculated efficiency.
  65. void SetPrintEffFrequency(int n) { fPrintEffFrequency = n;} ///< Sets frequency in events for efficiency table to be printed on the screen.
  66. const std::vector<KFMCVertex> GetPrimVertices() { return fPrimVertices; } ///< Returns Monte Carlo primary vertices in the current event.
  67. const std::vector<KFMCParticle>& MCParticles() { return vMCParticles; } ///< Returns Monte Carlo particles in the current event.
  68. const std::vector<KFPartMatch>& ParticlesMatch() { return RtoMCParticleId; } ///< Returns matching between reconstructed and Monte Carlo particles.
  69. const std::vector<KFPartMatch>& GetMCtoRPVId() { return MCtoRPVId; } ///< Returns matching between Monte Carlo and reconstructed primary vertices.
  70. const std::vector<KFPartMatch>& GetRtoMCPVId() { return RtoMCPVId; } ///< Returns matching between reconstructed and Monte Carlo primary vertices.
  71. const KFMCTrack& GetMCTrack(const int iRecoTrack)
  72. {
  73. /** Returns Monte Carlo track matched with the reconstructed track with index "iRecoTrack". */
  74. int iMCTrack = 0;
  75. if(RtoMCParticleId[iRecoTrack].IsMatched())
  76. iMCTrack = RtoMCParticleId[iRecoTrack].GetBestMatch();
  77. std::cout << "iMCTrack = " << iMCTrack << std::endl;
  78. return vMCTracks[iMCTrack];
  79. }
  80. void SetCentralityBin(const int iBin) { fCentralityBin = iBin; } ///< Sets centrality bin of the current event.
  81. void SetCentralityWeight(const float weight) { fCentralityWeight = weight; } ///< Sets weight of the centrality bin of the current event.
  82. private:
  83. const KFTopoPerformance& operator = (const KFTopoPerformance&); ///< Copying of objects of this class is forbidden.
  84. KFTopoPerformance(const KFTopoPerformance&); ///< Copying of objects of this class is forbidden.
  85. void GetMCParticles();
  86. void MatchParticles();
  87. void MatchPV();
  88. void CalculateEfficiency();
  89. void CalculatePVEfficiency();
  90. void FindReconstructableMCParticles();
  91. void CheckMCParticleIsReconstructable(KFMCParticle &part);
  92. void FindReconstructableMCVertices();
  93. void FillParticleParameters(KFParticle& TempPart,
  94. int iParticle,
  95. int iP,
  96. int iPV,
  97. TH1F* histoParameters[4][KFPartEfficiencies::nParticles][nHistoPartParam],
  98. TH2F* histoParameters2D[4][KFPartEfficiencies::nParticles][nHistoPartParam2D],
  99. TH3F* histoParameters3D[1][KFPartEfficiencies::nParticles][nHistoPartParam3D],
  100. TH1F* histoFit[KFPartEfficiencies::nParticles][nFitQA] = 0,
  101. TH1F* histoFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA] = 0,
  102. TH1F* histoDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA] = 0,
  103. std::vector<int>* multiplicities = 0);
  104. const KFParticleTopoReconstructor *fTopoReconstructor; ///< Pointer to the KFParticleTopoReconstructor object with particles and vertices to be analysed.
  105. std::vector<KFMCVertex> fPrimVertices; ///< Monte Carlo primary vertices.
  106. std::vector<int> fMCTrackToMCPVMatch; ///< Matching of Monte Carlo tracks and corresponding primary vertex
  107. std::vector<double> fPVPurity; ///< Purity of the primary vertices.
  108. 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.
  109. std::vector<int> fNCorrectPVTracks; ///< Number of correctly attached tracks in the corresponding reconstructed primary vertex.
  110. std::vector<int> fTrackMatch; ///< Matching between reconstructed tracks and
  111. std::vector<KFMCTrack> vMCTracks; ///< Monte Carlo tracks (parameters of the particle trajectories at the production point).
  112. std::vector<KFMCParticle> vMCParticles; ///< Monte Carlo particles.
  113. std::vector<int> fNeutralIndex; ///< Index of the created neutral daughters for missing mass method in vMCTracks for the Monte Carlo track with given index.
  114. /** Matching between Monte Carlo and reconstructed particles. MCtoRParticleId[i] provides index of the reconstructed particle in the
  115. ** fTopoReconstructor->GetParticles() array for the Monte Carlo particle (or track) with index "i". **/
  116. std::vector<KFPartMatch> MCtoRParticleId;
  117. /** Matching between reconstructed and Monte Carlo particles. RtoMCParticleId[i] provides index of the Monte Carlo particle in the
  118. ** vMCTracks and vMCParticles arrays for the reconstructed particle with index "i" from fTopoReconstructor->GetParticles(). **/
  119. std::vector<KFPartMatch> RtoMCParticleId;
  120. /** Matching between Monte Carlo and reconstructed primary vertices. MCtoRPVId[i] provides index of the reconstructed vertex in the
  121. ** fTopoReconstructor->GetPrimVertex() array for the Monte Carlo vertex with index "i". **/
  122. std::vector<KFPartMatch> MCtoRPVId;
  123. /** Matching between reconstructed and Monte Carlo primary vertices. RtoMCPVId[i] provides index of the Monte Carlo vertex in the
  124. ** fPrimVertices array for the reconstructed vertex with index "i" from fTopoReconstructor->GetPrimVertex(). **/
  125. std::vector<KFPartMatch> RtoMCPVId;
  126. int fPrintEffFrequency; ///< Frequency in events with which efficiency table is printed on the screen.
  127. int fCentralityBin; ///< Centrality bin for the current event.
  128. float fCentralityWeight; ///< Centrality weight for the current event.
  129. };
  130. #endif
  131. #endif //DO_TPCCATRACKER_EFF_PERFORMANCE