BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
DSTConv.C
Go to the documentation of this file.
1
2
const
Int_t
CutMinNTracksPV
= 2;
3
4
// void FilterPV_CBM(TString BaseName, TString TempBaseName, Double_t minZ = -5.45, Double_t maxZ = 6.55) {
5
void
FilterPV
(
TString
BaseName,
TString
TempBaseName,
Double_t
minZ = -7.15,
Double_t
maxZ = 4.85)
6
{
7
printf(
"\nCloning selected exp events:"
);
8
TFile
* BaseHits =
new
TFile
(BaseName,
"READ"
);
9
if
(BaseHits->
IsOpen
() ==
false
) {
10
printf(
"\n!!!!\ncannot open file %s !\n"
, BaseName.
Data
());
11
return
;
12
}
13
TTree
* TreeBase = (
TTree
*)BaseHits->
Get
(
"bmndata"
);
14
// DigiRunHeader* RHBase = (DigiRunHeader*) BaseHits->Get(RHDigiName.Data());
15
TFile
* DestHitsFile =
new
TFile
(TempBaseName,
"RECREATE"
);
16
if
(DestHitsFile->
IsOpen
() ==
false
) {
17
printf(
"\n!!!!\ncannot open file %s !\n"
, TempBaseName.
Data
());
18
return
;
19
}
20
printf(
"\nOUT FILE: "
);
21
printf(
"%s\n"
, TempBaseName.
Data
());
22
TTree
* DestTree = TreeBase->
CloneTree
(0);
//-1, "fast");
23
TClonesArray
* vertex =
nullptr
;
24
TreeBase->
SetBranchAddress
(
"BmnVertex"
, &vertex);
25
UInt_t
iBaseEvent = 0;
26
UInt_t
NBaseEvents = TreeBase->
GetEntries
();
27
for
(
UInt_t
iEv = 0; iEv < NBaseEvents; iEv++) {
28
// DrawBar(iEv, NBaseEvents);
29
TreeBase->
GetEntry
(iEv);
30
BmnVertex
* vtx =
static_cast<
BmnVertex
*
>
(vertex->
UncheckedAt
(0));
31
if
((vtx->
GetZ
() < minZ) || (vtx->
GetZ
() > maxZ) || (vtx->
GetNTracks
() <
CutMinNTracksPV
))
32
continue
;
33
DestTree->
Fill
();
34
}
35
DestTree->
Write
();
36
// DestHitsFile->WriteObject(RHBase, RHDigiName.Data());
37
DestHitsFile->
Write
();
38
DestHitsFile->
Close
();
39
DestHitsFile =
nullptr
;
40
BaseHits->
Close
();
41
printf(
"\nCloning finished!\n"
);
42
return
;
43
}
44
45
void
DSTConv
(
TString
inFile =
"~/filesbmn/4649-cbm-full.root"
,
46
TString
outFile =
"$VMCWORKDIR/macro/run/dst-bmn-4649.root"
,
47
Int_t
nStartEvent = 0,
48
Int_t
nEvents = 0,
49
TString
inFileToClone =
"/eos/nica/bmn/exp/dst/run7/prerelease/3590-4707_BMN_Argon/bmn_run4649_dst.root"
,
50
vector<TString> branchesToClone = {
"BmnTof400Hit"
,
"BmnTof700Hit"
,
"BmnDchTrack"
,
"BmnDchHit"
,
51
"BmnUpstreamHit"
,
"BmnMwpcSegment"
,
"BmnMwpcTrack"
})
52
{
53
TStopwatch
timer;
54
timer.
Start
();
55
gDebug
= 0;
56
Int_t
fVerbose = 2;
57
Int_t
periodId = 7;
58
Int_t
runId = -1;
59
// if nEvents is equal 0 then all events of the given file starting with "nStartEvent" should be processed
60
if
(nEvents == 0)
61
nEvents =
MpdGetNumEvents::GetNumROOTEvents
((
char
*)inFile.Data()) - nStartEvent;
62
63
// if (!UniRun::GetRun(fPeriodId, runId)) {
64
// printf("Run not found in ELOG. Exit.\n");
65
// return;
66
// }
67
68
FairRunAna* fRunAna =
new
FairRunAna();
69
// BmnFairRunSim* fRunAna = new BmnFairRunSim();
70
FairSource
* src =
new
BmnFileSource
(inFile);
71
fRunAna->SetSource(src);
72
// TString inFileTemp = inFile + ".tmp.root";
73
74
fRunAna->SetInputFile(inFile);
75
// if (inFileToF400.Length() > 0)
76
// fRunAna->AddFriend(inFileToF400);
77
fRunAna->SetOutputFile(outFile.Data());
78
fRunAna->SetGenerateRunInfo(
kFALSE
);
79
80
BmnTrackConv
* conv =
new
BmnTrackConv
(periodId, runId,
kBMNSETUP
, inFileToClone, branchesToClone);
81
fRunAna->AddTask(conv);
82
// conv->SetRunSimInst(fRunAna);
83
// BmnEventGetter * eg = new BmnEventGetter(inFileToF700, 0, {"BmnTof700Hit", "BmnDchTrack"});
84
// fRunAna->AddTask(eg);
85
86
fRunAna->Init();
87
fRunAna->Run(nStartEvent, nStartEvent + nEvents);
88
delete
fRunAna;
89
90
TString
outFileTemp = outFile +
".pv.root"
;
91
// FilterPV(outFile, outFileTemp);
92
// std::remove(outFile);
93
94
timer.
Stop
();
95
Double_t
rtime = timer.
RealTime
(), ctime = timer.
CpuTime
();
96
printf(
"RealTime=%f seconds, CpuTime=%f seconds\n"
, rtime, ctime);
97
cout <<
"Macro finished successfully."
<< endl;
// marker of successfully execution for software testing systems
98
}
Int_t
int Int_t
gDebug
Int_t gDebug
UInt_t
unsigned int UInt_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kBMNSETUP
@ kBMNSETUP
Definition
BmnEnums.h:166
BmnFileSource
BmnFileSource.h.
Definition
BmnFileSource.h:30
BmnTrackConv
BmnTrackConv Task for track conversion between BM@N and CBM formats.
Definition
BmnTrackConv.h:104
BmnVertex
Definition
BmnVertex.h:22
BmnVertex::GetNTracks
Int_t GetNTracks() const
Definition
BmnVertex.h:60
BmnVertex::GetZ
Double_t GetZ() const
Definition
BmnVertex.h:57
FairSource
MpdGetNumEvents::GetNumROOTEvents
static Int_t GetNumROOTEvents(const char *filename, const char *treename="", int iVerbose=2)
Definition
MpdGetNumEvents.cxx:511
TClonesArray
TDirectoryFile::Get
T * Get(const char *namecycle)
TFile
TFile::Write
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override
TFile::IsOpen
virtual Bool_t IsOpen() const
TFile::Close
void Close(Option_t *option="") override
TObjArray::UncheckedAt
TObject * UncheckedAt(Int_t i) const
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::Data
const char * Data() const
TTree
TTree::Fill
virtual Int_t Fill()
TTree::GetEntry
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
TTree::GetEntries
virtual Long64_t GetEntries() const
TTree::Write
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
TTree::CloneTree
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
TTree::SetBranchAddress
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
FilterPV
void FilterPV(TString BaseName, TString TempBaseName, Double_t minZ=-7.15, Double_t maxZ=4.85)
Definition
DSTConv.C:5
DSTConv
void DSTConv(TString inFile="~/filesbmn/4649-cbm-full.root", TString outFile="$VMCWORKDIR/macro/run/dst-bmn-4649.root", Int_t nStartEvent=0, Int_t nEvents=0, TString inFileToClone="/eos/nica/bmn/exp/dst/run7/prerelease/3590-4707_BMN_Argon/bmn_run4649_dst.root", vector< TString > branchesToClone={"BmnTof400Hit", "BmnTof700Hit", "BmnDchTrack", "BmnDchHit", "BmnUpstreamHit", "BmnMwpcSegment", "BmnMwpcTrack"})
Definition
DSTConv.C:45
CutMinNTracksPV
const Int_t CutMinNTracksPV
Definition
DSTConv.C:2
install
macro
recotools
DSTConv.C
Generated on
for BmnRoot by
1.17.0