FairRoot/PandaRoot
tutorials/analysis/ana_example.C
Go to the documentation of this file.
1 void ana_example(TString fname="pid_tpccombi.root",int nevts=0)
2 {
3  TStopwatch timer;
4  timer.Start();
5 
6  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
7 
8  TCanvas *c1=new TCanvas("c1","c1",600,600);
9 
10  // the PndEventReader takes care about file/event handling
11  PndEventReader evr(fname);
12 
13  // to attach more files: evr.Add(fname2);evr.Add(fname3); ...
14 
15  TH1F *mom=new TH1F("mom","P(particle)",400,0.0,5.0);
16 
17  // the candidates lists we need
18  TCandList all;
19 
20 
21  if (nevts==0) nevts=evr.GetEntries();
22  int i=0,j;
23 
24  // *************
25  // this is the loop through the events ... as simple as this...
26  // ****************
27  while (evr.GetEvent() && i++<nevts)
28  {
29  evr.FillList(all,"Charged");
30  for (j=0;j<all.GetLength();++j)
31  {
32  mom->Fill(all[j].P());
33  }
34  }
35 
36  // ... and plot it
37 
38  c1->cd(); mom->Draw();
39 
40  // now take the time...
41  timer.Stop();
42  Double_t rtime = timer.RealTime();
43  Double_t ctime = timer.CpuTime();
44 
45  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
46 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t i
Definition: run_full.C:25
int ana_example(TString fname, int nevts=0)
Double_t mom
Definition: plot_dirc.C:14
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
GeV c P
Double_t rtime
Definition: hit_dirc.C:113