FairRoot/PandaRoot
Functions
prod_myana.C File Reference

Go to the source code of this file.

Functions

bool checkfile (TString fn)
 
int prod_myana (TString prefix="", int from=1, int to=1, int mode=0, int nevts=0)
 

Function Documentation

bool checkfile ( TString  fn)

Definition at line 1 of file prod_myana.C.

References t, and x0.

2 {
3  bool fileok=true;
4  TFile fff(fn);
5  if (fff.IsZombie()) fileok=false;
6  TTree *t=(TTree*)fff.Get("pndsim");
7  if (t==0x0) fileok=false;
8 
9  if (!fileok) cout <<"Skipping broken file '"<<fn<<"'"<<endl;
10  return fileok;
11 }
Double_t x0
Definition: checkhelixhit.C:70
TTree * t
Definition: bump_analys.C:13
int prod_myana ( TString  prefix = "",
int  from = 1,
int  to = 1,
int  mode = 0,
int  nevts = 0 
)

Definition at line 13 of file prod_myana.C.

References checkfile(), ctime, Double_t, RhoCalculationTools::ForceConstantBz(), fRun, i, mode, outFile, rtime, and TString.

14 {
15  if (prefix=="")
16  {
17  cout << "Example analysis macro using PndSimpleCombiner(Task). !! MODIFY for your purpose !!\n\n";
18  cout << "USAGE:\n";
19  cout << "prod_myana.C( <pref>, <from>, <to>, [nevt] )\n\n";
20  cout << " <pref> : output file names prefix\n";
21  cout << " <from> : first run number\n";
22  cout << " <to> : last run number\n";
23  cout << " [mode] : arbitrary mode number; default: 0\n";
24  cout << " [nevt] : number of events; default: 0 = all\n\n";
25  return 0;
26  }
27 
28  bool fastsim = true;
29 
30  // --------------------------------
31  // Set Pid Algos for full or fast sim
32  // --------------------------------
33  TString pidalgo = "PidAlgoEmcBayes;PidAlgoDrc;PidAlgoDisc;PidAlgoStt;PidAlgoMdtHardCuts;PidAlgoRich;PidAlgoSciT";
34  if (fastsim) pidalgo = "PidChargedProbability";
35 
36  // --------------------------------
37  // Prepare input file naming
38  // --------------------------------
39  TString suffix = fastsim ? "fsim" : "pid";
40 
41  TString outFile = TString::Format("%s_ana_%d_%d.root",prefix.Data(), from, to);
42  TString firstFile = TString::Format("%s_%d_%s.root",prefix.Data(),from,suffix.Data());
43 
44  // if prefix is a full file name, we skip the run number in the name
45  if (prefix.EndsWith(".root"))
46  {
47  firstFile = prefix;
48  outFile = prefix; outFile.ReplaceAll(".root","_ana.root");
49  //inParFile = prefix; inParFile.ReplaceAll("_pid.root","_par.root");
50  to = from;
51  }
52  // if only one file, we name outfile to 'prefix_<run>_ana.root'
53  else if (from==to) outFile = TString::Format("%s_%d_ana.root", prefix.Data(), from);
54 
55 
56  // --------------------------------
57  // Start a stop watch
58  // --------------------------------
59  TStopwatch fTimer;
60  fTimer.Start();
61 
62  // --------------------------------
63  // Create the Analysis run manager
64  // --------------------------------
65  FairRunAna *fRun = new FairRunAna();
66  FairFileSource *fSrc = new FairFileSource(firstFile);
67 
68  // Add pid files
69  for (int i=from+1;i<=to;++i)
70  {
71  TString fname = TString::Format("%s_%d_%s.root",prefix.Data(),i,suffix.Data());
72  if ( checkfile(fname) ) fSrc->AddFile(fname);
73  }
74 
75  fRun->SetSource(fSrc);
76 
77  // *** PID table with selection thresholds; can be modified by the user
78  TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";
79 
80  // *** initialization
81  FairLogger::GetLogger()->SetLogToFile(kFALSE);
82  fRun->SetOutputFile(outFile);
83 
84  //---------------------Create and Set the Field(s)----------
85 
87 
88  // ***
89  // *** HERE YOUR TASK/CODE CODE GOES!
90  // ***
91 
92  PndProdAnaTask *prodTask = new PndProdAnaTask(mode, pidalgo);
93  fRun->AddTask(prodTask);
94 
95 
96  // --------------------------------
97  // ... and run analysis
98  // --------------------------------
99  fRun->Init();
100  fRun->Run(0,nevts);
101 
102  //------------------------Print some info and exit----------------
103  fTimer.Stop();
104  FairSystemInfo sysInfo;
105  Float_t maxMemory=sysInfo.GetMaxMemory();
106  Double_t rtime = fTimer.RealTime();
107  Double_t ctime = fTimer.CpuTime();
108 
109  Float_t cpuUsage=ctime/rtime;
110 
111  cout << endl;
112  cout << "[INFO ] Macro call : prod_fsim.C(\""<<prefix<<"\", "<<from<<", "<<to<<", "<<mode<<", "<<nevts<<")" <<endl;
113  cout << "[INFO ] Output file : " << outFile << endl;
114  cout << "[INFO ] Real time : " << rtime << " s, CPU time " << ctime << "s" << endl;
115  cout << "[INFO ] CPU usage : " << cpuUsage*100. << "%" << endl;
116  cout << "[INFO ] Max Memory : " << maxMemory << " MB" << endl;
117  cout << "[INFO ] Macro finished successfully." << endl<<endl;
118 
119  return 0;
120 }
Int_t i
Definition: run_full.C:25
TString outFile
Definition: hit_dirc.C:17
static void ForceConstantBz(Double_t bz=0.)
Force a constant B field value for all positions.
FairRunAna * fRun
Definition: hit_dirc.C:58
Int_t mode
Definition: autocutx.C:47
Double_t
Double_t ctime
Definition: hit_dirc.C:114
bool checkfile(TString fn)
Double_t rtime
Definition: hit_dirc.C:113