Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Std.h
1#ifndef HALSTD_H_
2#define HALSTD_H_
3
4#include "StdHist.h"
5#include "StdMath.h"
6#include "StdString.h"
7
8#include <complex>
9#include <vector>
10//#define HAL_DEBUG
11class TVirtualPad;
12
13#define Draw_2D_option "colz"
14#define Draw_3D_option "box2"
15#define HAL_PHYSICALANALYSYS_VER "jun2024"
16
17// some enums used almost everywhere
18
19namespace Hal {
20 enum class EInfo { kDebugInfo = 0, kInfo = 1, kLowWarning = 2, kWarning = 3, kError = 4, kCriticalError = 5 };
21 enum class EFormatType { kSim = 0, kReco = 1, kComplexReco = 2, kComplexSim = 3 };
22
23 enum class ERound { kSeparator, kPrefix };
24 enum class ECutUpdate { kNo = -1, kEvent = 0, kTrack = 1, kTwoTrack = 2, kTwoTrackBackground = 3 };
25
26 enum class EFormatDepth { kAll, kBuffered, kNonBuffered };
27
28} // namespace Hal
29
30class TClonesArray;
31namespace Hal {
32 class CompressionMap;
33 namespace Std {
34 struct ITriplet {
35 int x, y, z;
36 };
37 typedef std::complex<double> DComplex;
43 TString UpdateEnumToString(Hal::ECutUpdate upd);
50 void CopyFiles(TString from, TString to, Bool_t hidden = kFALSE);
57 template<typename T>
58 std::vector<T> GetVector(const std::initializer_list<T>& list) {
59 std::vector<T> vec;
60 for (auto i : list) {
61 vec.push_back(i);
62 }
63 return vec;
64 }
74 std::vector<TString> GetListOfFiles(TString path, TString extension, Bool_t fullPath = kFALSE, Int_t depth = 0);
79 TString GetDate();
84 TString GetTime();
91 TString GetUniqueName(TString name);
96 TString GetJsRoot();
103 TString GetHalrootPlus();
109 TString GetConfigParameter(TString par_name);
120 std::vector<std::vector<TVirtualPad*>> GetGridPad(Int_t x_pads, Int_t y_pads, Float_t x_margin, Float_t y_margin);
126 Int_t VersionId(TString name);
132 Bool_t FileExists(TString path);
142 TVector3 CalcualteBoostVector(Double_t energy_per_nucleon, Int_t n_proj, Int_t p_proj, Int_t n_tar, Int_t p_tar);
149 void CompressArray(TClonesArray* array, const CompressionMap& map);
153 Int_t GetJsRootVer();
160 template<typename T>
161 void ResizeVector1D(std::vector<T>& vec, int size) {
162 vec.resize(size);
163 }
167 template<typename T>
168 void ResizeVector2D(std::vector<std::vector<T>>& vec, int sizeX, int sizeY) {
169 vec.resize(sizeX);
170 for (auto& el : vec)
171 el.resize(sizeY);
172 }
181 template<typename T>
182 void ResizeVector3D(std::vector<std::vector<std::vector<T>>>& vec, int sizeX, int sizeY, int sizeZ) {
183 vec.resize(sizeX);
184 for (auto& ela : vec) {
185 ela.resize(sizeY);
186 for (auto& el : ela) {
187 el.resize(sizeZ);
188 }
189 }
190 }
197 template<typename T>
198 unsigned int GetTotalSize(const std::vector<std::vector<T>>& vec) {
199 unsigned int rowSize = vec.size();
200 unsigned int totSize = 0;
201 for (auto& i : vec) {
202 totSize += rowSize * i.size();
203 }
204 return totSize;
205 }
212 template<typename T>
213 unsigned int GetTotalSize(const std::vector<std::vector<std::vector<T>>>& vec) {
214 unsigned int rowSize = vec.size();
215 unsigned int totSize = 0;
216 for (auto& i : vec) {
217 totSize += rowSize * GetTotalSize(i);
218 }
219 return totSize;
220 }
226 template<typename T>
227 void DeletePointerVector(std::vector<T*>& vec) {
228 for (auto& i : vec) {
229 if (i) delete i;
230 i = nullptr;
231 }
232 }
233 } // namespace Std
234} // namespace Hal
235
236
237#endif