#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 production/scripts/compress.C.
References bnam, COMSplitString(), fi, i, name, Ns, printf(), and TString.
28 if (ntp==
"" || fnamein==
"" || fnameout==
"")
30 cout <<
"USAGE:\ncompress(TString tree, TString infile, TString outfile, TString bnames, TString precut)\n\n";
31 cout <<
" tree : name of the TTree to be compressed.\n";
32 cout <<
" infile : input file name.\n";
33 cout <<
" outfile : output file name.\n";
34 cout <<
" bnames : blank separated list of branch variable names to be copied; can make use of name* / *name /*name*; !(*)name(*) excludes variables (default = \"*\").\n";
35 cout <<
" precut : cut to be applied before compressing branches (default = \"\"). Either bnames!=\"*\" or precut!=\"\".\n\n";
40 if (bnames==
"*" && precut==
"")
42 cout <<
"Nothing to compress. Exiting."<<endl;
46 TFile *
fi =
new TFile(fnamein,
"READ");
47 TTree *ti = (TTree*) fi->Get(ntp);
50 ti->Draw(
">>el",precut);
51 TEventList *el = (TEventList*)gDirectory->Get(
"el");
53 int N0 = ti->GetEntries();
61 ti->SetBranchStatus(
"*",0);
62 for (
unsigned int i=0;
i<bnam.size();++
i)
63 if (bnam[
i].BeginsWith(
"!")) {
TString tmp = bnam[
i](1,1000); ti->SetBranchStatus(tmp,0);}
64 else ti->SetBranchStatus(bnam[
i],1);
67 TObjArray* blist = ti->GetListOfBranches();
68 for(
unsigned int i=0; i<=blist->GetLast(); ++
i)
70 TString name = ((TBranch*)blist->UncheckedAt(i))->GetName();
71 if (ti->GetBranchStatus(name)>0) bnam.push_back(name);
75 cout<<
"**** Pre cut : \"" << precut <<
"\"" << endl;
76 cout<<
"**** Selected : " << Ns <<
" / "<< N0 <<
" entries"<< endl;
77 cout<<
"**** Branch pattern: \"" << bnames <<
"\"" << endl;
78 cout<<
"**** "<<bnam.size()<<
" branches found: \n";
79 for (
unsigned int i=0;i<bnam.size();++
i)
printf(
"%s ",bnam[i].Data());
82 cout <<
"Converting tree '"<<ntp<<
"': "<<fnamein<<
" ("<<ti->GetNbranches()<<
" br, "<<ti->GetEntriesFast()<<
" ev) ... "<<flush;
86 TFile *fo =
new TFile(fnameout,
"RECREATE");
87 TTree *to = ti->CopyTree(
"");
89 cout <<
"to "<<fnameout<<
" ("<<to->GetNbranches()<<
" br, "<<to->GetEntriesFast()<<
" ev) "<<endl;
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Definition at line 13 of file production/scripts/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);