StFemtoDstReader.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * \class StFemtoDstReader
  3. * \brief Allows to read femtoDst file or a list of files
  4. *
  5. * This class allows to read femtoDst.root file or a list of files
  6. * that contain femtoDst and sets up pointers to the femtoDst, and
  7. * certain TClonesArrays that keep Event, Track, etc...
  8. * One can also turn on or off certain branches using the
  9. * SetStatus method.
  10. *
  11. * \author Grigory Nigmatkulov; e-mail: nigmatkulov@gmail.com
  12. * \date May 28, 2018
  13. */
  14. #ifndef StFemtoDstReader_h
  15. #define StFemtoDstReader_h
  16. // ROOT headers
  17. #include "TChain.h"
  18. #include "TTree.h"
  19. #include "TFile.h"
  20. #include "TString.h"
  21. #include "TClonesArray.h"
  22. // FemtoDst headers
  23. #include "StFemtoDst.h"
  24. #include "StFemtoEvent.h"
  25. #include "StFemtoArrays.h"
  26. //_________________
  27. class StFemtoDstReader : public TObject {
  28. public:
  29. /// Constructor that takes either femtoDst file or file that
  30. /// contains a list of femtoDst.root files
  31. StFemtoDstReader(const Char_t* inFileName);
  32. /// Destructor
  33. ~StFemtoDstReader();
  34. /// Return a pointer to femtoDst (return NULL if no dst is found)
  35. StFemtoDst *femtoDst() { return mFemtoDst; }
  36. /// Return pointer to the chain of .femtoDst.root files
  37. TChain *chain() { return mChain; }
  38. /// Return pointer to the current TTree
  39. TTree *tree() { return mTree; }
  40. /// Set enable/disable branch matching when reading femtoDst
  41. void SetStatus(const Char_t* branchNameRegex, Int_t enable);
  42. /// Calls openRead()
  43. void Init();
  44. /// Read next event in the chain
  45. Bool_t readFemtoEvent(Long64_t iEvent);
  46. /// Close files and finilize
  47. void Finish();
  48. private:
  49. /// Name of the inputfile (or of the inputfiles.list)
  50. TString mInputFileName;
  51. /// Turn off streamers
  52. void streamerOff();
  53. /// Create TClonesArray of femto classes and set them to femtoDst
  54. void createArrays();
  55. /// Clear all TClonesArrays with femtoDst classes
  56. void clearArrays();
  57. /// Set adresses of femtoArrays and their statuses (enable/disable) to chain
  58. void setBranchAddresses(TChain *chain);
  59. /// Pointer to the input/output femtoDst structure
  60. StFemtoDst *mFemtoDst;
  61. /// Pointer to the chain
  62. TChain *mChain;
  63. /// Pointer to the current tree
  64. TTree *mTree;
  65. /// Event counter
  66. Int_t mEventCounter;
  67. /// Pointer to the TClonesArray with the data
  68. TClonesArray *mFemtoArrays[StFemtoArrays::NAllFemtoArrays];
  69. /// Status of the TClonesArray
  70. Char_t mStatusArrays[StFemtoArrays::NAllFemtoArrays];
  71. ClassDef(StFemtoDstReader, 0)
  72. };
  73. #endif // StFemtoDstReader_h