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

Function Documentation

bool comp_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 comp_complete.C.

References c1, f, f2, h, h2, name, next, P, and TString.

13 {
14  TCanvas *c1 = new TCanvas();
15  c1->Divide(6,5);
16  bool fTest=kFALSE;
17  TString templateFile = gSystem->Getenv("VMCWORKDIR");
18  templateFile += "/macro/run/";
19  templateFile += fn2;
20 
21  TFile *f=new TFile(fn,"READ");
22  if (!f->IsZombie())
23  {
24  TFile *f2=new TFile(templateFile,"READ");
25 
26  TKey *key;
27  TIter next(f->GetListOfKeys());
28 
29  int failcount = 0;
30  Int_t yy = 0;
31  while ( (key = (TKey*)next()) )
32  {
33  c1->cd(yy+1);
34  TObject *obj = key->ReadObj();
35 
36  // only check TH1Fs
37  if (!obj->InheritsFrom("TH1F")) continue;
38 
39  TString name = obj->GetName();
40  TH1F* h = (TH1F*) obj;
41  TH1F* h2 = (TH1F*) f2->Get(name);
42  h->SetLineColor(2);
43  h->SetLineWidth(2);
44  h2->SetLineWidth(2);
45  if ( h->GetMaximum()< h2->GetMaximum())
46  {
47  h2->Draw(); h->Draw("same");
48  }
49  else
50  {
51  h->Draw(); h2->Draw("same");
52  }
53  if ( h->GetEntries()<minev )
54  {
55  cout << "Histogram (almost) empty : " << name << " \"" << h2->GetTitle() << "\": N = " << h->GetEntries() << endl;
56  failcount++;
57  }
58  else
59  {
60  double P = h2->KolmogorovTest(h);
61  if ( P<minP )
62  {
63  cout << "Incompatible distribution: " << name << " \"" << h2->GetTitle() << "\": P = " << P << endl;
64  failcount++;
65  }
66  }
67  yy++;
68  }
69 
70  if (failcount<maxfail) fTest = kTRUE;
71 
72  }
73 
74  if (fTest){
75  cout << " Test passed" << endl;
76  cout << " All ok " << endl;
77  }else{
78  cout << " Test Failed" << endl;
79  cout << " Not Ok " << endl;
80  }
81 
82 
83 }
TFile * f
Definition: bump_analys.C:12
c1
Definition: plot_dirc.C:35
TString name
GeV c P
TFile * f2
static int next[96]
Definition: ranlxd.cxx:374