BmnRoot
26.10.0-233-gb9bbe585
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
// FairRoot
5
#include "FairField.h"
6
#include "FairPrimaryGenerator.h"
7
8
// ROOT
9
#include "
TDatime.h
"
10
#include "
TString.h
"
11
#include "
TSystem.h
"
12
#include "
TTimeStamp.h
"
13
14
#include <
TFile.h
>
15
16
// STL
17
#include <chrono>
18
#include <string>
19
#include <vector>
20
21
using
SysClock
= std::chrono::system_clock;
22
using
SysPoint
= std::chrono::time_point<SysClock>;
23
24
/** Class with static common functions to simplify experiment code **/
25
class
BmnFunctionSet
26
{
27
public
:
28
// check whether path is a directory
29
static
bool
isDirectory
(
TString
path);
30
// check whether file exists: 1 - exists, 0 - not exists, -1 - exists but cannot access with the mode (default:
31
// kFileExists) fileName: file path; iVerbose: 0 - no output, 1 - print errors; mode: check for 'kFileExists', or
32
// has 'kExecutePermission', 'kWritePermission' or 'kReadPermission'
33
static
int
CheckFileExist
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kFileExists
);
34
// check whether directory exists: 1 - exists, 0 - not exists, -1 - exists but cannot access with the mode (default:
35
// kFileExists)
36
static
int
CheckDirectoryExist
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kFileExists
);
37
// create directory tree for the file name if not exists: 1 - exists, 0 - created
38
// error codes: -1 - exists but cannot access with the mode (default: kWritePermission), -2 - cannot be created, -3
39
// - empty file name
40
static
int
CreateDirectoryTree
(
TString
& fileName,
int
iVerbose = 0,
EAccessMode
mode =
kWritePermission
);
41
// get the list of input ROOT files for the given input file, which can be a ROOT file with data, a ROOT file with
42
// a TChain object or a text file (extension is not '.root') with a list of ROOT files:
43
// inputFileName: path to the input file; fileList: returns the list of ROOT files with expanded paths
44
// return value: number of files in the list, < 0 - error codes
45
static
int
GetInputFileList
(
TString
inputFileName, std::vector<TString>& fileList);
46
47
// define whether ROOT file contains simulation data: 1 - true, 0 - false (experimental data), <0 - some errors
48
// occured if filename is not set then the function checks the current processing
49
static
int
isSimulationFile
(
TString
fileName =
""
);
50
// method_number: 0 - find FairRtdbRun with period number name; 1 - use "FileHeader" (FairFileHeader)
51
static
int
GetPeriodNumber
(
TFile
* root_file,
int
method_number = 0);
52
53
// parsing file name to define beam, target and energy of the run
54
// the file name is parsed with the '_' separator, if it does not fit then with the '.' separator
55
// file_name: name of the file to parse
56
// result (beam, target, energy (GeV)) returns via links, energy is < 0 in case of errors
57
// return value: 0 - success, < 0 - error codes
58
static
Int_t
ParseFileName
(
const
TString
& file_name,
TString
& beam,
TString
& target,
Double_t
& energy);
59
// define beam and energy of the run by FairIonGenerator added to the primary generator (e.g. ION generator in
60
// run_sim_bmn.C): the generated ion is considered as the beam
61
// result (beam, energy - kinetic energy per nucleon (GeV)) returns via links, energy is < 0 in case of errors
62
// return value: 0 - success, < 0 - error codes
63
static
Int_t
GetBeamByIonGenerator
(FairPrimaryGenerator* primary_generator,
TString
& beam,
Double_t
& energy);
64
65
// get magnetic field value (mV) for the given beam and its energy (e.g. parsed by ParseFileName)
66
// beam: beam particle name; energy: beam energy (GeV)
67
// return value: magnetic field value (mV), < 0 - in case of errors
68
static
double
GetMagneticFieldByEnergy
(
const
TString
& beam,
double
energy);
69
70
// get the correction factor for the magnetic field map scale calculated as 'field voltage / map voltage'
71
// energy: beam energy (GeV)
72
// return value: correction factor to multiply the field map scale by, 1 - for the energies without correction
73
static
double
GetFieldScaleCorrection
(
double
energy);
74
75
// set the scale of the magnetic field of any type, so the code does not depend on whether the field
76
// of the run is a field map or a constant field. The zero scale gives the zero field (the magnet is off).
77
// field: the magnetic field; scale: 'field voltage of the run / reference voltage of the field'
78
// return value: true - success, false - no field or the field type is not supported
79
static
bool
SetFieldScale
(
FairField
* field,
double
scale);
80
81
static
TTimeStamp
TimePoint2TS
(
SysPoint
p);
82
static
SysPoint
TimeStamp2TP
(
TTimeStamp
p);
83
static
void
PrintTimePoint
(
SysPoint
p);
84
static
std::string
TimePoint2String
(
SysPoint
p);
85
static
SysPoint
TDatime2GMT
(
TDatime
& tdatime,
Int_t
timezoneOffsetHours = 0);
86
87
private
:
88
BmnFunctionSet
() {}
89
~BmnFunctionSet
() {}
90
91
static
TString
JoinKeys
(
const
std::vector<std::pair<TString, TString>>& dict);
92
// parsing file name with the given separator (used by ParseFileName)
93
// separator: symbol to split the file name into tokens
94
// return value: 0 - success, < 0 - error codes
95
static
Int_t
ParseFileNameBySeparator
(
const
TString
& file_name,
96
const
TString
& separator,
97
TString
& beam,
98
TString
& target,
99
Double_t
& energy);
100
101
ClassDef
(
BmnFunctionSet
, 1)
102
};
103
104
#endif
SysClock
std::chrono::system_clock SysClock
Definition
BmnFunctionSet.h:21
SysPoint
std::chrono::time_point< SysClock > SysPoint
Definition
BmnFunctionSet.h:22
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:26
BmnFunctionSet::~BmnFunctionSet
~BmnFunctionSet()
Definition
BmnFunctionSet.h:89
BmnFunctionSet::GetMagneticFieldByEnergy
static double GetMagneticFieldByEnergy(const TString &beam, double energy)
Definition
BmnFunctionSet.cxx:292
BmnFunctionSet::PrintTimePoint
static void PrintTimePoint(SysPoint p)
Definition
BmnFunctionSet.cxx:675
BmnFunctionSet::CreateDirectoryTree
static int CreateDirectoryTree(TString &fileName, int iVerbose=0, EAccessMode mode=kWritePermission)
Definition
BmnFunctionSet.cxx:71
BmnFunctionSet::BmnFunctionSet
BmnFunctionSet()
Definition
BmnFunctionSet.h:88
BmnFunctionSet::TDatime2GMT
static SysPoint TDatime2GMT(TDatime &tdatime, Int_t timezoneOffsetHours=0)
Definition
BmnFunctionSet.cxx:691
BmnFunctionSet::CheckDirectoryExist
static int CheckDirectoryExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
Definition
BmnFunctionSet.cxx:50
BmnFunctionSet::GetFieldScaleCorrection
static double GetFieldScaleCorrection(double energy)
Definition
BmnFunctionSet.cxx:351
BmnFunctionSet::JoinKeys
static TString JoinKeys(const std::vector< std::pair< TString, TString > > &dict)
Definition
BmnFunctionSet.cxx:278
BmnFunctionSet::ParseFileName
static Int_t ParseFileName(const TString &file_name, TString &beam, TString &target, Double_t &energy)
Definition
BmnFunctionSet.cxx:407
BmnFunctionSet::TimePoint2String
static std::string TimePoint2String(SysPoint p)
Definition
BmnFunctionSet.cxx:680
BmnFunctionSet::SetFieldScale
static bool SetFieldScale(FairField *field, double scale)
Definition
BmnFunctionSet.cxx:370
BmnFunctionSet::isSimulationFile
static int isSimulationFile(TString fileName="")
Definition
BmnFunctionSet.cxx:175
BmnFunctionSet::GetBeamByIonGenerator
static Int_t GetBeamByIonGenerator(FairPrimaryGenerator *primary_generator, TString &beam, Double_t &energy)
Definition
BmnFunctionSet.cxx:432
BmnFunctionSet::TimeStamp2TP
static SysPoint TimeStamp2TP(TTimeStamp p)
Definition
BmnFunctionSet.cxx:668
BmnFunctionSet::isDirectory
static bool isDirectory(TString path)
Definition
BmnFunctionSet.cxx:651
BmnFunctionSet::GetInputFileList
static int GetInputFileList(TString inputFileName, std::vector< TString > &fileList)
Definition
BmnFunctionSet.cxx:106
BmnFunctionSet::TimePoint2TS
static TTimeStamp TimePoint2TS(SysPoint p)
Definition
BmnFunctionSet.cxx:661
BmnFunctionSet::GetPeriodNumber
static int GetPeriodNumber(TFile *root_file, int method_number=0)
Definition
BmnFunctionSet.cxx:229
BmnFunctionSet::CheckFileExist
static int CheckFileExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
Definition
BmnFunctionSet.cxx:31
BmnFunctionSet::ParseFileNameBySeparator
static Int_t ParseFileNameBySeparator(const TString &file_name, const TString &separator, TString &beam, TString &target, Double_t &energy)
Definition
BmnFunctionSet.cxx:507
FairField
TDatime
TFile
TString
TTimeStamp
base
BmnFunctionSet.h
Generated on
for BmnRoot by
1.17.0