FairRoot/PandaRoot
Functions
dec13/tut_ana.C File Reference

Go to the source code of this file.

Functions

bool checkfile (TString fn)
 
void attachFiles (FairRunAna *fRun, TString pref, int min, int max)
 
void tut_ana (TString pref="pid_complete.root", int min=-1, int max=1, int nevts=0)
 

Function Documentation

void attachFiles ( FairRunAna *  fRun,
TString  pref,
int  min,
int  max 
)

Definition at line 19 of file dec13/tut_ana.C.

References checkfile(), i, max(), and TString.

20 {
21  bool firstfile=true;
22  for (int i=min;i<=max;++i) {
23  TString fname = TString::Format("%s_%d_pid.root",pref.Data(),i);
24 
25  if (checkfile(fname) ) {
26  if (firstfile) fRun->SetInputFile(fname);
27  else fRun->AddFile(fname);
28  firstfile=false;
29  }
30  }
31 }
Int_t i
Definition: run_full.C:25
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
FairRunAna * fRun
Definition: hit_dirc.C:58
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
bool checkfile(TString fn)
bool checkfile ( TString  fn)

Definition at line 4 of file dec13/tut_ana.C.

References t, and x0.

5 {
6  bool fileok=true;
7  TFile fff(fn, "READ");
8  if (fff.IsZombie()) fileok=false;
9  TTree *t=(TTree*)fff.Get("pndsim");
10  if (t==0x0) fileok=false;
11 
12  if (!fileok) cout <<"Skipping broken file '"<<fn<<"'"<<endl;
13  fff.Close();
14 
15  return fileok;
16 }
Double_t x0
Definition: checkhelixhit.C:70
TTree * t
Definition: bump_analys.C:13
void tut_ana ( TString  pref = "pid_complete.root",
int  min = -1,
int  max = 1,
int  nevts = 0 
)

Definition at line 33 of file dec13/tut_ana.C.

References attachFiles(), fRun, PndAnalysis::GetEntries(), PndAnalysis::GetEvent(), i, max(), min(), out, rtdb, and TString.

34 {
35  TString OutFile, inParFile;
36 
37  // *** add input files
38  FairRunAna *fRun= new FairRunAna();
39 
40  // *** just open one file
41  if (min<0)
42  {
43  // *** set input file, output file and par file
44  OutFile = "ana.root";
45  inParFile = "simparams.root";
46 
47  fRun->SetInputFile(pref);
48  }
49  // *** attach many input files
50  else {
51  // *** set output file and par file
52  OutFile = TString::Format("%s_ana_%d_%d.root",pref.Data(), min, max);
53  inParFile = TString::Format("%s_%d_par.root",pref.Data(), min);
54 
55  attachFiles(fRun, pref, min, max);
56  }
57 
58  // *** PID table with selection thresholds; can be modified by the user
59  TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";
60 
61  // *** initialization
62  FairLogger::GetLogger()->SetLogToFile(kFALSE);
63  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
64 
65  // *** setup parameter database
66  FairParRootFileIo* parIO = new FairParRootFileIo();
67  parIO->open(inParFile);
68  FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
69  parIOPid->open(pidParFile.Data(),"in");
70 
71  rtdb->setFirstInput(parIO);
72  rtdb->setSecondInput(parIOPid);
73  rtdb->setOutput(parIO);
74 
75  fRun->SetOutputFile("dummyout.root");
76  fRun->Init();
77 
78  // *** create an output file for all histograms
79  TFile *out = TFile::Open(OutFile,"RECREATE");
80 
81  // *** the data reader object
82  PndAnalysis* theAnalysis = new PndAnalysis();
83  if (nevts==0) nevts= theAnalysis->GetEntries();
84 
85  int i=0;
86 
87  // *** the event loop
88  while (theAnalysis->GetEvent() && i++<nevts)
89  {
90  if ((i%100)==0) cout<<"evt " << i << endl;
91 
92  // ***
93  // *** HERE YOUR ANALYSIS CODE GOES!
94  // ***
95 
96  }
97 
98  // *** write out all the histos
99  out->cd();
100  out->Save();
101  out->Close();
102 
103 }
Int_t GetEntries()
Int_t i
Definition: run_full.C:25
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
FairRunAna * fRun
Definition: hit_dirc.C:58
void attachFiles(FairRunAna *fRun, TString pref, int min, int max)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
TFile * out
Definition: reco_muo.C:20
Int_t GetEvent(Int_t n=-1)