BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
FilterPV.C
Go to the documentation of this file.
1
const
Int_t
CutMinNTracksPV
= 2;
2
3
void
FilterPV
(
TString
BaseName,
TString
TempBaseName,
Double_t
minZ = -5.45,
Double_t
maxZ = 6.55)
4
{
5
printf(
"\nCloning selected exp events:"
);
6
TFile
* BaseHits =
new
TFile
(BaseName,
"READ"
);
7
if
(BaseHits->
IsOpen
() ==
false
) {
8
printf(
"\n!!!!\ncannot open file %s !\n"
, BaseName.
Data
());
9
return
;
10
}
11
TTree
* TreeBase = (
TTree
*)BaseHits->
Get
(
"bmndata"
);
12
// DigiRunHeader* RHBase = (DigiRunHeader*) BaseHits->Get(RHDigiName.Data());
13
TFile
* DestHitsFile =
new
TFile
(TempBaseName,
"RECREATE"
);
14
if
(DestHitsFile->
IsOpen
() ==
false
) {
15
printf(
"\n!!!!\ncannot open file %s !\n"
, TempBaseName.
Data
());
16
return
;
17
}
18
printf(
"\nOUT FILE: "
);
19
printf(
"%s\n"
, TempBaseName.
Data
());
20
TTree
* DestTree = TreeBase->
CloneTree
(0);
//-1, "fast");
21
TClonesArray
* vertex =
nullptr
;
22
TreeBase->
SetBranchAddress
(
"BmnVertex"
, &vertex);
23
UInt_t
iBaseEvent = 0;
24
UInt_t
NBaseEvents = TreeBase->
GetEntries
();
25
for
(
UInt_t
iEv = 0; iEv < NBaseEvents; iEv++) {
26
// DrawBar(iEv, NBaseEvents);
27
TreeBase->
GetEntry
(iEv);
28
BmnVertex
* vtx =
static_cast<
BmnVertex
*
>
(vertex->
UncheckedAt
(0));
29
if
((vtx->
GetZ
() < minZ) || (vtx->
GetZ
() > maxZ) || (vtx->
GetNTracks
() <
CutMinNTracksPV
))
30
continue
;
31
DestTree->
Fill
();
32
}
33
DestTree->
Write
();
34
// DestHitsFile->WriteObject(RHBase, RHDigiName.Data());
35
DestHitsFile->
Write
();
36
DestHitsFile->
Close
();
37
DestHitsFile =
nullptr
;
38
BaseHits->
Close
();
39
printf(
"\nCloning finished!\n"
);
40
return
;
41
}
Int_t
int Int_t
UInt_t
unsigned int UInt_t
Double_t
double Double_t
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
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
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)
CutMinNTracksPV
const Int_t CutMinNTracksPV
Definition
FilterPV.C:1
FilterPV
void FilterPV(TString BaseName, TString TempBaseName, Double_t minZ=-5.45, Double_t maxZ=6.55)
Definition
FilterPV.C:3
macro
recotools
FilterPV.C
Generated on
for BmnRoot by
1.17.0