FairRoot/PandaRoot
outdated/run/check_complete.C
Go to the documentation of this file.
1 #include "TString.h"
2 #include "TFile.h"
3 #include "TCanvas.h"
4 #include "TKey.h"
5 #include <iostream>
6 #include "TH1F.h"
7 #include "TRandom.h"
8 
9 using std::cout;
10 using std::endl;
11 
12 bool check_complete(TString fn="output_ana.root", TString fn2="ana_target.root", double minP = 0.03, int minev = 3, int maxfail=3)
13 {
14  bool fTest=kFALSE;
15  TString templateFile = gSystem->Getenv("VMCWORKDIR");
16  templateFile += "/macro/run/";
17  templateFile += fn2;
18 
19  TFile *f=new TFile(fn,"READ");
20  if (!f->IsZombie())
21  {
22  TFile *f2=new TFile(templateFile,"READ");
23 
24  TKey *key;
25  TIter next(f->GetListOfKeys());
26 
27  int failcount = 0;
28 
29  while ( (key = (TKey*)next()) )
30  {
31  TObject *obj = key->ReadObj();
32 
33  // only check TH1Fs
34  if (!obj->InheritsFrom("TH1F")) continue;
35 
36  TString name = obj->GetName();
37  TH1F* h = (TH1F*) obj;
38  TH1F* h2 = (TH1F*) f2->Get(name);
39 
40  if ( h->GetEntries()<minev )
41  {
42  cout << "Histogram (almost) empty : " << name << " \"" << h2->GetTitle() << "\": N = " << h->GetEntries() << endl;
43  failcount++;
44  }
45  else
46  {
47  double P = h2->KolmogorovTest(h);
48  cout << "<DartMeasurement name=\""<<h2->GetTitle()<<"\" type=\"numeric/double\">";
49  cout << P;
50  cout << "</DartMeasurement>" << endl;
51  if ( P<minP )
52  {
53  cout << "Incompatible distribution: " << name << " \"" << h2->GetTitle() << "\": P = " << P << endl;
54  failcount++;
55  }
56  }
57 
58  }
59 
60  if (failcount<maxfail) fTest = kTRUE;
61  cout << "<DartMeasurement name=\"failcount\" type=\"numeric/int\">"<<failcount<<"</DartMeasurement>"<<endl;
62  }
63 
64  if (fTest){
65  cout << " Test passed" << endl;
66  cout << " All ok " << endl;
67  }else{
68  cout << " Test Failed" << endl;
69  cout << " Not Ok " << endl;
70  }
71 
72  exit(fTest);
73 }
exit(0)
TFile * f
Definition: bump_analys.C:12
bool check_complete(TString fn="output_ana.root", TString fn2="ana_target.root", double minP=0.03, int minev=3, int maxfail=3)
TString name
GeV c P
TFile * f2
static int next[96]
Definition: ranlxd.cxx:374