FairRoot/PandaRoot
Functions
QA/run3/check_complete.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_complete (TString fn="output_ana.root", TString fn2="ana_target.root", double minP=0.03, int minev=3, int maxfail=3)
 

Function Documentation

bool check_complete ( TString  fn = "output_ana.root",
TString  fn2 = "ana_target.root",
double  minP = 0.03,
int  minev = 3,
int  maxfail = 3 
)

Definition at line 12 of file QA/run3/check_complete.C.

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

13 {
14  TStopwatch fTimer;
15  bool fTest=kFALSE;
16  TString templateFile = gSystem->Getenv("VMCWORKDIR");
17  templateFile += "/macro/QA/run3/";
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  fTimer.Stop();
77  Double_t rtime = fTimer.RealTime();
78  Double_t ctime = fTimer.CpuTime();
79 
80  Float_t cpuUsage=ctime/rtime;
81  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
82  cout << cpuUsage;
83  cout << "</DartMeasurement>" << endl;
84 
85  cout << endl;
86  cout << "Real time " << rtime << " s, CPU time " << ctime
87  << "s" << endl;
88  cout << "CPU usage " << cpuUsage*100. << "%" << endl;
89  cout << "Max Memory " << maxMemory << " MB" << endl;
90 
91  if (fTest)
92  {
93  cout << " Macro finished successfully" << endl;
94  cout << " All ok " << endl;
95  }
96  else
97  {
98  cout << " Test Failed" << endl;
99  cout << " Not Ok " << endl;
100  }
101 
102  return fTest;
103 }
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
PndAnaPidSelector *& obj