Dear all,
I might miss something, however I can't logically understand why
my lines cause a problem, maybe more. Please, correct me.
I am working with ROOT 2.24/04 on SGI. I have a large size of
data samples divided into around 35 root files which have been
"h2root"ed from PAW row-wise ntuples, and I would like to generate
a filtered sample from the data sample. I already know the number
of selected events is very small, let's say 200 events, so I want
to keep them as one root file. That was my first intention of this
try.
At first, I made a chain from data files; and, set branch address
for several branches which are used for the candidate selection.
However, I would like to keep all branches in my new root file
for the selected events.
TChain datachain("h300");
datachain->Add("tops_m10_iso4_real_1a_01.root/TOPS/h300");
datachain->Add("tops_m10_iso4_real_1a_02.root/TOPS/h300");
..........
datachain->SetBranchStatus("*",1);
Float_t nhptm_d;
datachain->SetBranchAddress("nhptm",&nhptm_d);
Float_t ezflag_d;
datachain->SetBranchAddress("ezflag",&ezflag_d);
Float_t mzflag_d;
datachain->SetBranchAddress("mzflag",&mzflag_d);
...........
Second, I create new file; and, tried to clone only header from old tree.
Because the event selection would be done by some comparisons in the
later part of this file.
TFile *filterdatafile = gROOT->FindObject("data_filter.root");
if (filterdatafile) filterdatafile->Close();
filterdatafile = new TFile("data_filter.root", "RECREATE",
"Filtered Data: the paris of Mu and Tau");
TTree *filterdatatree = datachain->CloneTree(0);
================================================
==> I guess this line is not working. However, TTree is inherited as
public to TChain, so that the public member of TTree, CloneTree,
is able to be used, I think, in this way.
message: *** Break *** segmentation violation
Third, I began the filtering by several comparisons:
Int_t ndataevents = Int_t(datachain->GetEntries());
for (Int_t ev=0; ev<ndataevents; ev++) {
datachain->GetEntry(ev);
if(nhptm_d>0) {
if((ezflag_d==0)&&(mzflag_d==0)) {
......
filterdatatree->CopyEntries(datachain,1);
}
}
}
filterdatatree->Print();
filterdatafile->Write();
}
I might start from very wrong place far from my intention. Any
other suggestion or collection, both are welcome. Thanks.
===============================================================
Min-Jeong Kim, CDF/Carnegie Mellon University, mjkim@fnal.gov
===============================================================
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:53 MET