BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
PairCreation.C
Go to the documentation of this file.
1
// #include <Rtypes.h>
2
#include <
TString.h
>
3
4
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
5
6
void
PairCreation
(
TString
inputFileName =
"/scratch1/ramin/bmnroot_final/bmnroot/macro/run/bmndst_mc_latest_0000.root"
,
7
TString
outputFileName =
8
"/scratch1/ramin/bmnroot_final/bmnroot/macro/run/treepair_lambda_mc_latest_1000k_0000.root"
,
9
UInt_t
nEvents = 0,
10
Int_t
runId = 8008,
11
Int_t
pdg = 3122)
// Lambda0 3122, K_S0 310
12
{
13
14
// Int_t run_period = 8;
15
// ----- Timer ---------------------------------------------------------
16
TStopwatch
timer;
17
timer.
Start
();
18
// Create Run Manager
19
FairRunAna* fRunAna =
new
FairRunAna();
20
21
// Input file association
22
// FairSource *fFileSource = new BmnFileSource(inReco, run_period, runId);
23
// fRunAna->SetSource(fFileSource);
24
25
// Output file association
26
// fRunAna->SetSink(new FairRootFileSink(output));
27
28
// Magnetic field
29
// UniRun *pCurrentRun = UniRun::GetRun(run_period, runId);
30
// if (pCurrentRun == 0)
31
// return;
32
// Double_t *field_voltage = pCurrentRun->GetFieldVoltage();
33
// Double_t map_voltage = 112.0;
34
// Double_t fieldScale = (*field_voltage) / map_voltage;
35
// BmnFieldMap *magField = new BmnNewFieldMap("FieldMap_1900_extrap_noPed.root");
36
// magField->SetScale(fieldScale);
37
// magField->Init();
38
// fRunAna->SetField(magField);
39
40
Int_t
run_period = 8;
41
Int_t
fieldType = -1;
42
Double_t
fieldScale = 0.;
43
FairField
* magField =
BmnFunctionAna::GetDSTField
(inputFileName, fieldScale, fieldType);
44
if
(magField !=
nullptr
)
45
fRunAna->SetField(magField);
46
47
// Load geometry from the Geometry Database
48
GeoSetup
gSetup;
49
string
setupTag = gSetup.
GetLastApprovedSetupTag
(
TString::Format
(
"run%d"
, run_period).Data());
50
Int_t
res_code = gSetup.
LoadSetupToGeoManager
(setupTag);
51
if
(res_code != 0) {
52
cout <<
"ERROR: could not load geometry '"
<< setupTag <<
"' from the Geometry Database"
<< endl;
53
exit(-3);
54
}
55
56
// New way
57
// Input file association
58
FairSource
* fFileSource =
new
BmnFileSource
(inputFileName);
59
fRunAna->SetSource(fFileSource);
60
61
// fRunAna->SetSource(new FairFileSource(inputFileName));
62
// Output file association
63
if
(
BmnFunctionSet::CreateDirectoryTree
(outputFileName, 1) < 0)
64
exit(-2);
65
fRunAna->SetSink(
new
FairRootFileSink(outputFileName));
66
fRunAna->SetGenerateRunInfo(
false
);
67
68
// TFile* inFile = TFile::Open(inputFileName.Data());
69
// DstRunHeader* runHeader = (DstRunHeader*)inFile->Get("DstRunHeader");
70
// Double_t fieldScale = runHeader->GetFieldScale();
71
// BmnFieldMap* magField = new BmnNewFieldMap(runHeader->GetFieldName());
72
// magField->SetScale(fieldScale);
73
// magField->Init();
74
// fRunAna->SetField(magField);
75
76
TList
* parFileNameList =
new
TList
();
77
78
BmnPairFinder
* lambda =
new
BmnPairFinder
(
TDatabasePDG::Instance
()->GetParticle(pdg));
79
// lambda->SetGeometryFile("");
80
81
fRunAna->AddTask(lambda);
82
83
// FairRuntimeDb* rtdb = fRunAna->GetRuntimeDb();
84
// FairParRootFileIo* parIo1 = new FairParRootFileIo();
85
// FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
86
// parIo1->open(inputFileName.Data());
87
// parIo2->open(parFileNameList, "in");
88
// rtdb->setFirstInput(parIo1);
89
// rtdb->setSecondInput(parIo2);
90
// rtdb->setOutput(parIo1);
91
// rtdb->saveOutput();
92
93
if
(nEvents == 0)
94
nEvents =
MpdGetNumEvents::GetNumROOTEvents
((
char
*)inputFileName.Data());
95
fRunAna->Init();
96
fRunAna->Run(0, nEvents);
97
// ----- Finish --------------------------------------------------------
98
timer.
Stop
();
99
Double_t
rtime = timer.
RealTime
();
100
Double_t
ctime = timer.
CpuTime
();
101
cout << endl << endl;
102
cout <<
"Macro finished successfully."
<< endl;
103
cout <<
"Real time "
<< rtime <<
" s, CPU time "
<< ctime <<
" s"
<< endl;
104
cout << endl;
105
gSystem
->Exec(
TString::Format
(
"rm -f %s"
, geoFileName.Data()));
106
107
// delete lambda;
108
}
Int_t
int Int_t
UInt_t
unsigned int UInt_t
Double_t
double Double_t
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
TString.h
gSystem
R__EXTERN TSystem * gSystem
BmnFileSource
BmnFileSource.h.
Definition
BmnFileSource.h:30
BmnFunctionAna::GetDSTField
static FairField * GetDSTField(TString fileName, Double_t &fieldScale, Int_t &fieldType, TString *beam=nullptr, TString *target=nullptr, Double_t *beam_energy=nullptr, Int_t *beam_a=nullptr, Int_t *beam_z=nullptr, Int_t *target_a=nullptr, Int_t *target_z=nullptr)
Definition
BmnFunctionAna.cxx:37
BmnFunctionSet::CreateDirectoryTree
static int CreateDirectoryTree(TString &fileName, int iVerbose=0, EAccessMode mode=kWritePermission)
Definition
BmnFunctionSet.cxx:65
BmnPairFinder
Definition
BmnPairFinder.h:49
FairField
FairSource
GeoSetup
GeoSetup class.
Definition
GeoSetup.h:40
GeoSetup::LoadSetupToGeoManager
int LoadSetupToGeoManager(string_view setup_tag)
Load selected geometry setup from the Local Geometry Database and create gGeoManager instance.
Definition
GeoSetup.cxx:512
GeoSetup::GetLastApprovedSetupTag
string GetLastApprovedSetupTag(string_view tag_prefix)
Get tag for the last approved setup corresponding to the pattern.
Definition
GeoSetup.cxx:122
MpdGetNumEvents::GetNumROOTEvents
static Int_t GetNumROOTEvents(const char *filename, const char *treename="", int iVerbose=2)
Definition
MpdGetNumEvents.cxx:511
TDatabasePDG::Instance
static TDatabasePDG * Instance()
TList
TStopwatch
TStopwatch::RealTime
Double_t RealTime()
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
TStopwatch::CpuTime
Double_t CpuTime()
TStopwatch::Stop
void Stop()
TString
TString::Format
static TString Format(const char *fmt,...)
PairCreation
void PairCreation(TString inputFileName="/scratch1/ramin/bmnroot_final/bmnroot/macro/run/bmndst_mc_latest_0000.root", TString outputFileName="/scratch1/ramin/bmnroot_final/bmnroot/macro/run/treepair_lambda_mc_latest_1000k_0000.root", UInt_t nEvents=0, Int_t runId=8008, Int_t pdg=3122)
Definition
PairCreation.C:6
macro
physics
PairCreation.C
Generated on
for BmnRoot by
1.17.0