FairRoot/PandaRoot
Functions
tut_ana_task_d0.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_task_d0 (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 tut_ana_task_d0.C.

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

Referenced by tut_ana_task_d0().

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
bool checkfile(TString fn)
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)

Definition at line 4 of file tut_ana_task_d0.C.

References t, and x0.

Referenced by attachFiles().

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_task_d0 ( TString  pref = "pid_complete.root",
int  min = -1,
int  max = 1,
int  nevts = 0 
)

Definition at line 33 of file tut_ana_task_d0.C.

References attachFiles(), RhoCalculationTools::ForceConstantBz(), fRun, max(), min(), rtdb, and TString.

34 {
35  TString OutFile, inParFile;
36 
37  // pbarmom for analysis task
38  double pbarmom = 9.808065;
39 
40  // *** add input files
41  FairRunAna *fRun= new FairRunAna();
42 
43  // *** just open one file
44  if (min<0)
45  {
46  // *** set input file, output file and par file
47  OutFile = "ana.root";
48  inParFile = "simparams.root";
49 
50  fRun->SetInputFile(pref);
51  }
52  // *** attach many input files
53  else {
54  // *** set output file and par file
55  OutFile = TString::Format("%s_ana_%d_%d.root",pref.Data(), min, max);
56  inParFile = TString::Format("%s_%d_par.root",pref.Data(), min);
57 
58  attachFiles(fRun, pref, min, max);
59  }
60 
61  // *** PID table with selection thresholds; can be modified by the user
62  TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";
64 
65  // *** initialization
66  FairLogger::GetLogger()->SetLogToFile(kFALSE);
67  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
68 
69  // *** setup parameter database
70  FairParRootFileIo* parIO = new FairParRootFileIo();
71  parIO->open(inParFile);
72  FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
73  parIOPid->open(pidParFile.Data(),"in");
74 
75  rtdb->setFirstInput(parIO);
76  rtdb->setSecondInput(parIOPid);
77  rtdb->setOutput(parIO);
78 
79  fRun->SetOutputFile(OutFile);
80 
81  // *** HERE OUR TASK GOES!
82  PndTutAnaTaskD0 *anaTask = new PndTutAnaTaskD0(pbarmom);
83  fRun->AddTask(anaTask);
84 
85  // *** and run analysis
86  fRun->Init();
87  fRun->Run(0,nevts);
88 }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
static void ForceConstantBz(Double_t bz=0.)
Force a constant B field value for all positions.
FairRunAna * fRun
Definition: hit_dirc.C:58
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
void attachFiles(FairRunAna *fRun, TString pref, int min, int max)