FairRoot/PandaRoot
Functions
tracking/trackingQA/comp_recoqa.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

TCanvas * createCanvas (int picpercan)
 
int comp_recoqa (TString fn="QA_histograms.root", TString fn2="QA_histograms_test.root", int picpercan=9, double minP=0.03, int minev=3, int maxfail=3)
 

Function Documentation

int comp_recoqa ( TString  fn = "QA_histograms.root",
TString  fn2 = "QA_histograms_test.root",
int  picpercan = 9,
double  minP = 0.03,
int  minev = 3,
int  maxfail = 3 
)

Definition at line 22 of file tracking/trackingQA/comp_recoqa.C.

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

24  {
25  // fn -> red
26  // fn2 -> blue
27  std::vector<TCanvas*> canvasses;
28  TCanvas *c1 = new TCanvas();
29  c1->Divide(6, 6);
30  bool fTest = kFALSE;
31 
32  TFile *f = new TFile(fn, "READ");
33  if (!f->IsZombie()) {
34  TFile *f2 = new TFile(fn2, "READ");
35 
36  TKey *key;
37  TIter next(f->GetListOfKeys());
38 
39  int failcount = 0;
40  Int_t histoCount = 0;
41  Int_t actualCanvas = 0;
42  Int_t actualPad = 0;
43  while ((key = (TKey*) next())) {
44  actualCanvas = TMath::Floor((double)histoCount / picpercan);
45  actualPad = (histoCount % picpercan) + 1;
46  cout << histoCount << " : " << actualCanvas << "/" << actualPad << endl;
47  if (!(canvasses.size() > actualCanvas)){
48  cout << "New canvas" << endl;
49  canvasses.push_back(createCanvas(picpercan));
50  }
51  canvasses[actualCanvas]->cd(actualPad);
52  TObject *obj = key->ReadObj();
53 
54  // only check TH1Fs
55  if (!obj->InheritsFrom("TH1F"))
56  continue;
57 
58  TString name = obj->GetName();
59  TH1F* h = (TH1F*) obj;
60  TH1F* h2 = (TH1F*) f2->Get(name);
61  h->SetLineColor(2);
62  h->SetLineWidth(2);
63  h2->SetLineWidth(2);
64  if (h->GetMaximum() < h2->GetMaximum()) {
65  h2->Draw();
66  h->Draw("same");
67  } else {
68  h->Draw();
69  h2->Draw("same");
70  }
71  if (h->GetEntries() < minev) {
72  cout << "Histogram (almost) empty : " << name << " \""
73  << h2->GetTitle() << "\": N = " << h->GetEntries()
74  << endl;
75  failcount++;
76  } else {
77  double P = h2->KolmogorovTest(h);
78  if (P < minP) {
79  cout << "Incompatible distribution: " << name << " \""
80  << h2->GetTitle() << "\": P = " << P << endl;
81  failcount++;
82  }
83  }
84 
85  auto legend = new TLegend(0.1,0.7,0.48,0.9);
86  legend->SetHeader("File Comparison","C"); // option "C" allows to center the header
87  legend->AddEntry(h,fn.Data(),"f");
88  legend->AddEntry(h2,fn2.Data(),"f");
89  legend->Draw();
90  histoCount++;
91  }
92 
93  if (failcount < maxfail)
94  fTest = kTRUE;
95 
96  }
97 
98  if (fTest) {
99  cout << " Test passed" << endl;
100  cout << " All ok " << endl;
101  } else {
102  cout << " Test Failed" << endl;
103  cout << " Not Ok " << endl;
104  }
105  return 0;
106 }
TCanvas * createCanvas(int picpercan)
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
TCanvas* createCanvas ( int  picpercan)

Definition at line 12 of file tracking/trackingQA/comp_recoqa.C.

References CAMath::Sqrt().

12  {
13  double division = TMath::Sqrt((double)picpercan);
14  int first = ceil(division);
15  int second = round(division);
16  cout << "createCanvas: " << picpercan << " : " << first << "/" << second << endl;
17  TCanvas* newCan = new TCanvas();
18  newCan->Divide(first, second);
19  return newCan;
20 }
static T Sqrt(const T &x)
Definition: PndCAMath.h:37