#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TEventList.h"
#include "TDirectory.h"
#include <iostream>
#include "TObjArray.h"
#include "TRegexp.h"
#include <vector>
Go to the source code of this file.
Definition at line 26 of file softrig/compress.C.
References fi, i, mode, SplitString(), and TString.
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);
51 else SplitString(bnames,
"§ , toks);
TFile *fi = new TFile(fnamein,"READ");
TTree *ti = (TTree*) fi->Get(ntp);
cout <<"Converting tree '"<<ntp<<"': "<<fnamein<<" ("<<ti->GetNbranches()<<" br, "<<ti->GetEntriesFast()<<" ev) ... "<<flush;
ti->Draw(">>el",precut);
TEventList *el = (TEventList*)gDirectory->Get("el");
ti->SetBranchStatus("*",0);
for (int i=0;i<toks.size();++i)
{
if (toks[i].BeginsWith("!"))
{
TString tmp=toks[i](1,100);
ti->SetBranchStatus(tmp,0);
}
else
ti->SetBranchStatus(toks[i].Data(),1);
}
ti->SetEventList(el);
TFile *fo = new TFile(fnameout, "RECREATE");
TTree *to = ti->CopyTree("");
// to->SetEventList(el);
cout <<"to "<<fnameout<<" ("<<to->GetNbranches()<<" br, "<<to->GetEntriesFast()<<" ev) "<<endl;
fo->Write();
fo->Close();
fi->Close();
return 0;
}
", 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)
Definition at line 13 of file softrig/compress.C.
References i, and TString.
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);