BmnRoot
26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnFunctionSet.h
Go to the documentation of this file.
1
#ifndef BMNFUNCTIONSET_H
2
#define BMNFUNCTIONSET_H 1
3
4
// ROOT
5
#include "
TDatime.h
"
6
#include "
TString.h
"
7
#include "
TSystem.h
"
8
#include "
TTimeStamp.h
"
9
10
#include <
TFile.h
>
11
12
// STL
13
#include <chrono>
14
#include <string>
15
#include <vector>
16
17
using
SysClock
= std::chrono::system_clock;
18
using
SysPoint
= std::chrono::time_point<SysClock>;
19
20
/** Class with static common functions to simplify experiment code **/
21
class
BmnFunctionSet
22
{
23
public
:
24
// check whether path is a directory
25
static
bool
isDirectory
(
TString
path);
26
// check whether file exists: 1 - exists, 0 - not exists, -1 - exists but cannot access with the mode (default:
27
// kFileExists) fileName: file path; iVerbose: 0 - no output, 1 - print errors; mode: check for 'kFileExists', or
28
// has 'kExecutePermission', 'kWritePermission' or 'kReadPermission'
29
static
int
CheckFileExist
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kFileExists
);
30
// check whether directory exists: 1 - exists, 0 - not exists, -1 - exists but cannot access with the mode (default:
31
// kFileExists)
32
static
int
CheckDirectoryExist
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kFileExists
);
33
// create directory tree for the file name if not exists: 1 - exists, 0 - created
34
// error codes: -1 - exists but cannot access with the mode (default: kWritePermission), -2 - cannot be created, -3
35
// - empty file name
36
static
int
CreateDirectoryTree
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kWritePermission
);
37
// get the list of input ROOT files for the given input file, which can be a ROOT file with data, a ROOT file with
38
// a TChain object or a text file (extension is not '.root') with a list of ROOT files:
39
// inputFileName: path to the input file; fileList: returns the list of ROOT files with expanded paths
40
// return value: number of files in the list, < 0 - error codes
41
static
int
GetInputFileList
(
TString
inputFileName, std::vector<TString>& fileList);
42
43
// define whether ROOT file contains simulation data: 1 - true, 0 - false (experimental data), <0 - some errors
44
// occured if filename is not set then the function checks the current processing
45
static
int
isSimulationFile
(
TString
fileName =
""
);
46
// method_number: 0 - find FairRtdbRun with period number name; 1 - use "FileHeader" (FairFileHeader)
47
static
int
GetPeriodNumber
(
TFile
* root_file,
int
method_number = 0);
48
49
// parsing file name to define beam, target and energy of the run
50
// the file name is parsed with the '_' separator, if it does not fit then with the '.' separator
51
// file_name: name of the file to parse
52
// result (beam, target, energy (GeV)) returns via links, energy is < 0 in case of errors
53
// return value: 0 - success, < 0 - error codes
54
static
Int_t
ParseFileName
(
const
TString
& file_name,
TString
& beam,
TString
& target,
Double_t
& energy);
55
56
// parsing the geometry tag, which can contain the path to an XML file with a local customization of the setup
57
// (see database/geo_db/examples/README.md) after the ';' separator, e.g. "run9_26.09.0;$VMCWORKDIR/my_setup.xml"
58
// If no XML file is given after the separator then the whole value is considered as the setup tag
59
// geometry_tag: the geometry tag to parse, the parsed setup tag is returned via the same link
60
// local_settings: returns the path to the XML file as given (not expanded, e.g. with $VMCWORKDIR), "" if no file
61
// return value: 0 - success, < 0 - error codes
62
static
Int_t
ParseGeometryTag
(
TString
& geometry_tag,
TString
& local_settings);
63
64
// get magnetic field value (mV) for the given beam and its energy (e.g. parsed by ParseFileName)
65
// beam: beam particle name; energy: beam energy (GeV)
66
// return value: magnetic field value (mV), < 0 - in case of errors
67
static
double
GetMagneticFieldByEnergy
(
const
TString
& beam,
double
energy);
68
69
// get the correction factor for the magnetic field map scale calculated as 'field voltage / map voltage'
70
// energy: beam energy (GeV)
71
// return value: correction factor to multiply the field map scale by, 1 - for the energies without correction
72
static
double
GetFieldScaleCorrection
(
double
energy);
73
74
static
TTimeStamp
TimePoint2TS
(
SysPoint
p);
75
static
SysPoint
TimeStamp2TP
(
TTimeStamp
p);
76
static
void
PrintTimePoint
(
SysPoint
p);
77
static
std::string
TimePoint2String
(
SysPoint
p);
78
static
SysPoint
TDatime2GMT
(
TDatime
& tdatime,
Int_t
timezoneOffsetHours = 0);
79
80
private
:
81
BmnFunctionSet
() {}
82
~BmnFunctionSet
() {}
83
84
static
TString
JoinKeys
(
const
std::vector<std::pair<TString, TString>>& dict);
85
// parsing file name with the given separator (used by ParseFileName)
86
// separator: symbol to split the file name into tokens
87
// return value: 0 - success, < 0 - error codes
88
static
Int_t
ParseFileNameBySeparator
(
const
TString
& file_name,
89
const
TString
& separator,
90
TString
& beam,
91
TString
& target,
92
Double_t
& energy);
93
94
ClassDef
(
BmnFunctionSet
, 1)
95
};
96
97
#endif
SysClock
std::chrono::system_clock SysClock
Definition
BmnFunctionSet.h:17
SysPoint
std::chrono::time_point< SysClock > SysPoint
Definition
BmnFunctionSet.h:18
Int_t
int Int_t
Double_t
double Double_t
ClassDef
#define ClassDef(name, id)
TDatime.h
TFile.h
TString.h
TSystem.h
EAccessMode
EAccessMode
kFileExists
kFileExists
kWritePermission
kWritePermission
TTimeStamp.h
BmnFunctionSet
Class with static common functions to simplify experiment code.
Definition
BmnFunctionSet.h:22
BmnFunctionSet::~BmnFunctionSet
~BmnFunctionSet()
Definition
BmnFunctionSet.h:82
BmnFunctionSet::GetMagneticFieldByEnergy
static double GetMagneticFieldByEnergy(const TString &beam, double energy)
Definition
BmnFunctionSet.cxx:286
BmnFunctionSet::PrintTimePoint
static void PrintTimePoint(SysPoint p)
Definition
BmnFunctionSet.cxx:613
BmnFunctionSet::CreateDirectoryTree
static int CreateDirectoryTree(TString &fileName, int iVerbose=0, EAccessMode mode=kWritePermission)
Definition
BmnFunctionSet.cxx:65
BmnFunctionSet::BmnFunctionSet
BmnFunctionSet()
Definition
BmnFunctionSet.h:81
BmnFunctionSet::TDatime2GMT
static SysPoint TDatime2GMT(TDatime &tdatime, Int_t timezoneOffsetHours=0)
Definition
BmnFunctionSet.cxx:629
BmnFunctionSet::CheckDirectoryExist
static int CheckDirectoryExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
Definition
BmnFunctionSet.cxx:44
BmnFunctionSet::GetFieldScaleCorrection
static double GetFieldScaleCorrection(double energy)
Definition
BmnFunctionSet.cxx:345
BmnFunctionSet::ParseGeometryTag
static Int_t ParseGeometryTag(TString &geometry_tag, TString &local_settings)
Definition
BmnFunctionSet.cxx:391
BmnFunctionSet::JoinKeys
static TString JoinKeys(const std::vector< std::pair< TString, TString > > &dict)
Definition
BmnFunctionSet.cxx:272
BmnFunctionSet::ParseFileName
static Int_t ParseFileName(const TString &file_name, TString &beam, TString &target, Double_t &energy)
Definition
BmnFunctionSet.cxx:368
BmnFunctionSet::TimePoint2String
static std::string TimePoint2String(SysPoint p)
Definition
BmnFunctionSet.cxx:618
BmnFunctionSet::isSimulationFile
static int isSimulationFile(TString fileName="")
Definition
BmnFunctionSet.cxx:169
BmnFunctionSet::TimeStamp2TP
static SysPoint TimeStamp2TP(TTimeStamp p)
Definition
BmnFunctionSet.cxx:606
BmnFunctionSet::isDirectory
static bool isDirectory(TString path)
Definition
BmnFunctionSet.cxx:589
BmnFunctionSet::GetInputFileList
static int GetInputFileList(TString inputFileName, std::vector< TString > &fileList)
Definition
BmnFunctionSet.cxx:100
BmnFunctionSet::TimePoint2TS
static TTimeStamp TimePoint2TS(SysPoint p)
Definition
BmnFunctionSet.cxx:599
BmnFunctionSet::GetPeriodNumber
static int GetPeriodNumber(TFile *root_file, int method_number=0)
Definition
BmnFunctionSet.cxx:223
BmnFunctionSet::CheckFileExist
static int CheckFileExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
Definition
BmnFunctionSet.cxx:25
BmnFunctionSet::ParseFileNameBySeparator
static Int_t ParseFileNameBySeparator(const TString &file_name, const TString &separator, TString &beam, TString &target, Double_t &energy)
Definition
BmnFunctionSet.cxx:445
TDatime
TFile
TString
TTimeStamp
base
BmnFunctionSet.h
Generated on
for BmnRoot by
1.17.0