FairRoot/PandaRoot
Typedefs | Functions
softrig/compress.C File Reference
#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.

Typedefs

typedef std::vector< TStringStrVec
 

Functions

int SplitString (TString s, TString delim, StrVec &toks)
 
int compress (TString ntp, TString fnamein, TString fnameout, TString bnames="", TString precut="tag")
 

Typedef Documentation

typedef std::vector<TString> StrVec

Definition at line 11 of file softrig/compress.C.

Function Documentation

int compress ( TString  ntp,
TString  fnamein,
TString  fnameout,
TString  bnames = "",
TString  precut = "tag" 
)

Definition at line 26 of file softrig/compress.C.

References fi, i, mode, SplitString(), and TString.

27 {
28  if (bnames=="*" && precut=="")
29  {
30  cout <<"Nothing to compress. Exiting."<<endl;
31  return;
32  }
33 
34  TString smode = ntp(1,ntp.Length());
35  int mode = smode.Atoi()/10;
36  bool dst = (mode == 11 || mode == 13 || mode == 15);
37 
38  // default branches for SoftTrigger
39  if (bnames=="")
40  {
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";
44 
45  // vetos
46  bnames +=" !*beam* !*vx !*vy !*vz !t* !*pdg* !*pocmag tag";
47  }
48 
49  StrVec toks;
50  if (bnames.Index(" ")>=0) SplitString(bnames," ", toks);
51  else SplitString(bnames,"§", toks);
52 
53  TFile *fi = new TFile(fnamein,"READ");
54  TTree *ti = (TTree*) fi->Get(ntp);
55 
56  cout <<"Converting tree '"<<ntp<<"': "<<fnamein<<" ("<<ti->GetNbranches()<<" br, "<<ti->GetEntriesFast()<<" ev) ... "<<flush;
57 
58  ti->Draw(">>el",precut);
59  TEventList *el = (TEventList*)gDirectory->Get("el");
60 
61  ti->SetBranchStatus("*",0);
62  for (int i=0;i<toks.size();++i)
63  {
64  if (toks[i].BeginsWith("!"))
65  {
66  TString tmp=toks[i](1,100);
67  ti->SetBranchStatus(tmp,0);
68  }
69  else
70  ti->SetBranchStatus(toks[i].Data(),1);
71  }
72 
73  ti->SetEventList(el);
74 
75  TFile *fo = new TFile(fnameout, "RECREATE");
76  TTree *to = ti->CopyTree("");
77 // to->SetEventList(el);
78 
79  cout <<"to "<<fnameout<<" ("<<to->GetNbranches()<<" br, "<<to->GetEntriesFast()<<" ev) "<<endl;
80 
81  fo->Write();
82  fo->Close();
83  fi->Close();
84  return 0;
85 }
int SplitString(TString s, TString delim, StrVec &toks)
Int_t i
Definition: run_full.C:25
Int_t mode
Definition: autocutx.C:47
TFile * fi
std::vector< TString > StrVec
int SplitString ( TString  s,
TString  delim,
StrVec toks 
)

Definition at line 13 of file softrig/compress.C.

References i, and TString.

Referenced by compress().

14 {
15  toks.clear();
16  TObjArray *tok = s.Tokenize(delim);
17  int N = tok->GetEntries();
18  for (int i=0;i<N;++i)
19  {
20  TString token = (((TObjString*)tok->At(i))->String()).Strip(TString::kBoth);
21  toks.push_back(token);
22  }
23  return toks.size();
24 }
Int_t i
Definition: run_full.C:25
TLorentzVector s
Definition: Pnd2DStar.C:50