4 #include "TEventList.h"
5 #include "TDirectory.h"
16 TObjArray *tok = s.Tokenize(delim);
17 int N = tok->GetEntries();
20 TString token = (((TObjString*)tok->At(
i))->String()).Strip(TString::kBoth);
21 toks.push_back(token);
28 if (bnames==
"*" && precut==
"")
30 cout <<
"Nothing to compress. Exiting."<<endl;
34 TString smode = ntp(1,ntp.Length());
35 int mode = smode.Atoi()/10;
36 bool dst = (mode == 11 || mode == 13 || mode == 15);
41 bnames +=
"ev mode run recmode reccnt nsig mmiss xm xmct";
42 bnames +=
" es* *p *tht *pcm *thtcm *pt *ang *pid* *poc*";
43 if (dst) bnames +=
" xmdif";
46 bnames +=
" !*beam* !*vx !*vy !*vz !t* !*pdg* !*pocmag tag";
50 if (bnames.Index(
" ")>=0)
SplitString(bnames,
" ", toks);
53 TFile *
fi =
new TFile(fnamein,
"READ");
54 TTree *ti = (TTree*) fi->Get(ntp);
56 cout <<
"Converting tree '"<<ntp<<
"': "<<fnamein<<
" ("<<ti->GetNbranches()<<
" br, "<<ti->GetEntriesFast()<<
" ev) ... "<<flush;
58 ti->Draw(
">>el",precut);
59 TEventList *el = (TEventList*)gDirectory->Get(
"el");
61 ti->SetBranchStatus(
"*",0);
62 for (
int i=0;
i<toks.size();++
i)
64 if (toks[
i].BeginsWith(
"!"))
67 ti->SetBranchStatus(tmp,0);
70 ti->SetBranchStatus(toks[
i].Data(),1);
75 TFile *fo =
new TFile(fnameout,
"RECREATE");
76 TTree *to = ti->CopyTree(
"");
79 cout <<
"to "<<fnameout<<
" ("<<to->GetNbranches()<<
" br, "<<to->GetEntriesFast()<<
" ev) "<<endl;
int SplitString(TString s, TString delim, StrVec &toks)
std::vector< TString > StrVec
int compress(TString ntp, TString fnamein, TString fnameout, TString bnames="", TString precut="tag")