DataReader2021.h 3.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/** @file DataReader2021
 *  @brief Function prototypes for DataReader2021
 *
 *  This contains the prototypes and members
 *  for DataReader2021
 *
 *  @author Yakov Kulinich
 *  @bug No known bugs.
 */

#ifndef DataReader2021_H
#define DataReader2021_H

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#include "XMLSettingsReader.h"
#include "Containers.h"
#include "Detector.h"
#include "ZDC.h"
#include "RPD.h"


#include <TChain.h>
#include <TSystem.h>

class TFile;
class Analysis;

class DataReader2021{

 public:
  DataReader2021( );
  DataReader2021( const unsigned int = 0,  const unsigned int = 0 );
  DataReader2021( const unsigned int = 0,  const unsigned int = 0,
              const std::string& = "" );
  DataReader2021( const unsigned int = 0,  const unsigned int = 0,
              const std::string& = "", const unsigned int = 0 );
  virtual ~DataReader2021();

  void AddPreAnalysis  ( Analysis* );
  void AddDetectorAnalysis  ( Analysis* );
  void SelectDetectorForAnalysis ( bool _useUEM, bool _usePFRPD, bool _useTRPD, bool _useZDCs );

  void ReadListOfFiles( std::string listname );

  void LoadAlignmentFile     (std::string _inFile = std::getenv("JZCaPA") + std::string("/Utils/Alignment_2018.xml"));
  void LoadConfigurationFile (std::string _inFile = std::getenv("JZCaPA") + std::string("/Utils/ConfigFile2018.xml"));
  void LoadTimingFile        (std::string _inFile = "" );
  void SetDebugMode          ( ) { m_debug = true; }
  void SetVerbosity          ( int _level ){ m_verbose = _level; }
  void SetOutputDirectory    ( std::string _dir ){ m_outputDir = _dir; }
  void UpdateConsole         ( Long_t _updateRate);

  void EnablePlotLabel       (  ) { m_useLabel = true; }

  Detector*   GetDetector( std::string _detName );
  Alignment2021*  GetAlignment(){ return m_alignment; }

  void Run();

  void Initialize   ( );
  void ProcessEvents( );
  void Finalize     ( );

 private:
  // output file
  TFile* m_fOut;
  // Output TTree
  TTree* m_tOut;
  // Output directory
  std::string m_outputDir = "";

  // vector of pre-detector analysis
  std::vector< Analysis* > m_ana;
  // vector of detector analysis
  std::vector< Analysis* > m_det_ana;
  // Vector of time vectors for DRS4 modules
  std::vector< std::vector< float >* > m_time;

  //Number of channels to be read
  unsigned int m_nCh;
  //Number of samples per channel
  unsigned int m_nSamp;

  //Input file name
  std::string m_fNameIn;
  //Input list of files
  std::string m_fListOfFiles;

  //Run number
  unsigned int m_runNumber;

  //Boolean switch to enable the reading of a list of files
  bool m_readListOfFiles;

  //Input file (in case of a single processing)
  TFile* m_fIn;
  //TChain to accomodate many files (in case of a list of files)
  TChain* m_fileChain;

  //Vector of detectors placed in the 2018 setup (2 ZDCs, 1 RPD)
  std::vector < Detector* > m_detectors;

  //Vectors of

  //Alignment information for the given run
  Alignment2021* m_alignment;

  //XML parser
  XMLSettingsReader *m_XMLparser;

  //Current event
  int m_event;
  //Event number of last update
  int m_event_old = 0;

  //Booleans for analysis selection
  bool m_useZDCs, m_usePFRPD, m_useTRPD, m_useUEM;
  //Boolean to enable plot labelling
  bool m_useLabel = false;

  //DebugVariable
  bool m_debug = false;
  //Verbosity level
  int m_verbose = 0;


  //Memory info container for UpdateConsole
  MemInfo_t m_memInfo;
  //CPU info container for UpdateConsole
  CpuInfo_t m_cpuInfo;
  //Process info container for UpdateConsole
  ProcInfo_t m_procInfo;
};

#endif