FairRoot/PandaRoot
Functions
QA/run4/check_pid.C File Reference
#include "TString.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TKey.h"
#include <iostream>
#include "TH1F.h"
#include "TRandom.h"

Go to the source code of this file.

Functions

bool check_pid (TString fn="pid_plot.root", TString fn2="pid_target.root", double minP=0.03, int minev=3, int maxfail=3)
 

Function Documentation

bool check_pid ( TString  fn = "pid_plot.root",
TString  fn2 = "pid_target.root",
double  minP = 0.03,
int  minev = 3,
int  maxfail = 3 
)

Definition at line 12 of file QA/run4/check_pid.C.

References ctime, Double_t, f, f2, h, h2, name, next, P, rtime, and TString.

13 {
14  TStopwatch fTimer;
15  bool fTest=kFALSE;
16  TString templateFile = gSystem->Getenv("VMCWORKDIR");
17  templateFile += "/macro/QA/run4/";
18  templateFile += fn2;
19 
20  TFile *f=new TFile(fn,"READ");
21  if (!f->IsZombie())
22  {
23  TFile *f2=new TFile(templateFile,"READ");
24 
25  TKey *key;
26  TIter next(f->GetListOfKeys());
27 
28  int failcount = 0;
29 
30  while ( (key = (TKey*)next()) )
31  {
32  TObject *obj = key->ReadObj();
33 
34  // only check TH1Fs
35  if (!obj->InheritsFrom("TH1F")) continue;
36 
37  TString name = obj->GetName();
38  TH1F* h = (TH1F*) obj;
39  TH1F* h2 = (TH1F*) f2->Get(name);
40 
41  if ( h->GetEntries()<minev )
42  {
43  cout << "Histogram (almost) empty : " << name << " \"" << h2->GetTitle() << "\": N = " << h->GetEntries() << endl;
44  failcount++;
45  }
46  else
47  {
48  double P = h2->KolmogorovTest(h);
49  TString htitile=h2->GetTitle();
50  htitile.ReplaceAll(" ","");htitile.ReplaceAll("#","");htitile.ReplaceAll("(","");htitile.ReplaceAll(")","");
51  htitile.ReplaceAll("/","");htitile.ReplaceAll("^","");htitile.ReplaceAll("[","");htitile.ReplaceAll("]","");
52  htitile.ReplaceAll(":","");htitile.ReplaceAll(".","");htitile.ReplaceAll("{","");htitile.ReplaceAll("}","");
53  cout << "<DartMeasurement name=\""<<htitile.Data()<<"\" type=\"numeric/double\">";
54  cout << P;
55  cout << "</DartMeasurement>" << endl;
56  if ( P<minP )
57  {
58  cout << "Incompatible distribution: " << name << " \"" << h2->GetTitle() << "\": P = " << P << endl;
59  failcount++;
60  }
61  }
62 
63  }
64 
65  if (failcount<maxfail) fTest = kTRUE;
66  cout << "<DartMeasurement name=\"failcount\" type=\"numeric/int\">"<<failcount<<"</DartMeasurement>"<<endl;
67  }
68 
69  // Extract the maximal used memory an add is as Dart measurement
70  // This line is filtered by CTest and the value send to CDash
71  FairSystemInfo sysInfo;
72  Float_t maxMemory=sysInfo.GetMaxMemory();
73  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
74  cout << maxMemory;
75  cout << "</DartMeasurement>" << endl;
76 
77  fTimer.Stop();
78  Double_t rtime = fTimer.RealTime();
79  Double_t ctime = fTimer.CpuTime();
80 
81  Float_t cpuUsage=ctime/rtime;
82  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
83  cout << cpuUsage;
84  cout << "</DartMeasurement>" << endl;
85 
86  cout << endl;
87  cout << "Real time " << rtime << " s, CPU time " << ctime
88  << "s" << endl;
89  cout << "CPU usage " << cpuUsage*100. << "%" << endl;
90  cout << "Max Memory " << maxMemory << " MB" << endl;
91 
92  if (fTest){
93  cout << " Macro finished successfully" << endl;
94  cout << " All ok " << endl;
95  }else{
96  cout << " Test Failed" << endl;
97  cout << " Not Ok " << endl;
98  }
99 
100  return fTest;
101 }
Double_t
TFile * f
Definition: bump_analys.C:12
TString name
Double_t ctime
Definition: hit_dirc.C:114
GeV c P
TFile * f2
Double_t rtime
Definition: hit_dirc.C:113
static int next[96]
Definition: ranlxd.cxx:374