MpdMiniDstFillTask.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * \class MpdMiniDstFillTrask
  3. * \brief Class that reads event, track, and detector parameters and fills MpdMiniDst
  4. *
  5. * The MpdMiniDstFillTask reads information from the reconstructed (and/or simulated) event, track, vertex
  6. * and detectors and fill MpdMiniDst structure.
  7. *
  8. * \author Pavel Batyuk (JINR), Grigory Nigmatkulov (NRNU MEPhI)
  9. * \email pavel.batyuk@jinr.ru ; nigmatkulov@gmail.com ; ganigmatkulov@mephi.ru
  10. * \date Aug 01, 2019
  11. **/
  12. #ifndef MpdMiniDstFillTask_h
  13. #define MpdMiniDstFillTask_h
  14. // C++ headers
  15. #include <vector>
  16. #include <utility>
  17. #include <map>
  18. // ROOT and FAIRROOT headers
  19. #include "TNamed.h"
  20. #include "TClass.h"
  21. #include "TChain.h"
  22. #include "TTree.h"
  23. #include "TString.h"
  24. #include "TClonesArray.h"
  25. #include "TFile.h"
  26. // FairRoot headers
  27. #include "FairTask.h"
  28. #include "FairRunAna.h"
  29. #include "FairField.h"
  30. #include "FairRootManager.h"
  31. #include "FairMCEventHeader.h"
  32. #include "FairEventHeader.h"
  33. // MpdRoot headers
  34. class MpdEvent;
  35. class MpdKalmanTrack;
  36. class MpdVertex;
  37. // MpdMiniDst headers
  38. class MpdMiniDst;
  39. class MpdMiniTrack;
  40. class MpdMiniTrackCovMatrix;
  41. //_________________
  42. class MpdMiniDstFillTask : public FairTask {
  43. public:
  44. /// Default constructor
  45. MpdMiniDstFillTask();
  46. /// Constructor with output file name for miniDST and IO-modes (read or write)
  47. MpdMiniDstFillTask(TString);
  48. /// Destructor
  49. virtual ~MpdMiniDstFillTask();
  50. /// Init
  51. virtual InitStatus Init();
  52. /// Execute
  53. virtual void Exec(Option_t* option);
  54. /// Finish
  55. virtual void Finish();
  56. /// Fill track covariant matrix
  57. /// \param true store covariant matrix (default)
  58. /// \param false do not store covariant matrix information
  59. void isUseCovMatrix(Bool_t flag) { fIsUseCovMatrix = flag; }
  60. /// Fill ECal-related information
  61. void isUseECal(Bool_t flag) { fIsUseECal = flag; }
  62. /// Set how to fill nSigma(e,pi,K,p)
  63. /// \par 0 use values from MpdDst (default)
  64. /// \par 1 use values from special tables (cheat way)
  65. void setNSigmaDedxEstimator(Int_t estimator)
  66. { fNSigmaDedxEstimator = (estimator==0 || estimator==1 ) ? estimator : 0; }
  67. private:
  68. /// Store/Not store track covariant matrix information
  69. Bool_t fIsUseCovMatrix;
  70. /// Store/Not store ECal information
  71. Bool_t fIsUseECal;
  72. /// Pointer to event header
  73. FairMCEventHeader* fEventHeaders;
  74. /// Pointer to MpdEvent
  75. MpdEvent* fEvents;
  76. /// Pointer to primary vertieces
  77. TClonesArray* fVertices;
  78. /// Pointer to TPC tracks
  79. TClonesArray* fTpcTracks;
  80. /// Pointer to TOF hits
  81. TClonesArray* fTofHits;
  82. /// Pointer to TOF-matching information
  83. TClonesArray* fTofMatching;
  84. /// Pointer to MC tracks
  85. TClonesArray* fMCTracks;
  86. // Pointer to GenTracks (Primaries from MC-generator)
  87. TClonesArray* fGenTracks;
  88. // Pointer to EMC clusters
  89. TClonesArray* fEmcClusters;
  90. // Pointer to ZDC digits
  91. TClonesArray* fZdcDigits;
  92. /// A pointer to the main input/outpur miniDst structure containing all `TObjArray`s
  93. MpdMiniDst* fMiniDst;
  94. /// Magnetic field of the current event
  95. Float_t fBField;
  96. /// Output file name
  97. TString fOutputFileName;
  98. /// Pointer to the output file
  99. TFile* fOutputFile;
  100. /// Pointer to the TTree with miniDst
  101. TTree* fTTree;
  102. /// Splitting level of ROOT file
  103. Int_t fSplit;
  104. /// Compression level
  105. Int_t fCompression;
  106. /// Size of the buffer
  107. Int_t fBufferSize;
  108. /// Pointer to the mini arrays
  109. TClonesArray** fMiniArrays;
  110. /// Vector that keeps McTrack to miniMcTrack correspondence
  111. std::vector< std::pair<Int_t, UShort_t> > fMcTrk2MiniMcTrk;
  112. /// Mat for keeping MC track to barrel ECal cluster correpsondence
  113. std::map< Int_t, Int_t > fMcTrk2EcalCluster;
  114. /// How to fill nSigma(e,pi,K,p)
  115. /// \par 0 use values from MpdDst (default)
  116. /// \par 1 use values from special tables (cheat way)
  117. Int_t fNSigmaDedxEstimator;
  118. /// Turn-off ROOT streamers
  119. void streamerOff();
  120. /// Create arrays
  121. void createArrays();
  122. /// Fill event information
  123. void fillEvent();
  124. /// Fill MC tracks
  125. void fillMcTracks();
  126. /// Fill barrel ECal clusters
  127. void fillECalClusters();
  128. /// Fill track information
  129. void fillTracks();
  130. /// Fill BTOF information
  131. void fillBTofHits();
  132. /// Fill FHCal information
  133. void fillFHCalHits();
  134. /// Return index of miniMcTrack that corresponds to McTrack (-1 not found)
  135. Int_t miniMcIdxFromMcIdx(Int_t mcIdx);
  136. /* Below is given a set of auxiliary functions */
  137. /// Compute matrices of derivatives
  138. void computeAandB(TMatrixD&, const MpdKalmanTrack*, const MpdKalmanTrack&,
  139. TMatrixD&, TMatrixD&, TMatrixD&);
  140. /// Adjust track parameters
  141. void Proxim(const MpdKalmanTrack&, MpdKalmanTrack&);
  142. /// A function to be used when doing refit of tracks considered
  143. /// as primaries to the primary vertex aimed at precising of their momenta
  144. void refit2Vp(MpdMiniTrack*, Int_t, MpdVertex*);
  145. /// Fill covariance matrix if needed
  146. void fillCovMatrix(MpdTpcKalmanTrack*, MpdMiniTrackCovMatrix*);
  147. /// Check if the event event is okay (reasonabler reconstruction)
  148. Bool_t isGoodEvent();
  149. /// Estimate nSigma value (cheat way). Returns vector with
  150. /// values for electron, pion, kaon and proton
  151. std::vector< Double_t > nSigmaDedx(Double_t p, Double_t dEdx);
  152. ClassDef(MpdMiniDstFillTask, 0)
  153. };
  154. #endif // MpdMiniDstFillTask_h