BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
FilterPV.C
Go to the documentation of this file.
2
3void 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 Int_t
unsigned int UInt_t
double Double_t
Int_t GetNTracks() const
Definition BmnVertex.h:60
Double_t GetZ() const
Definition BmnVertex.h:57
T * Get(const char *namecycle)
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override
virtual Bool_t IsOpen() const
void Close(Option_t *option="") override
TObject * UncheckedAt(Int_t i) const
const char * Data() const
virtual Int_t Fill()
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
const Int_t CutMinNTracksPV
Definition FilterPV.C:1
void FilterPV(TString BaseName, TString TempBaseName, Double_t minZ=-5.45, Double_t maxZ=6.55)
Definition FilterPV.C:3