simple_FC_validation.C
Go to the documentation of this file.
1 #include "TFile.h"
2 #include "TTree.h"
3 #include <iostream>
4 
5 struct FC{
6  double truechi;
7  double bestchi;
8 };
9 
10 bool operator==(FC & A, FC & B) {
11  return A.truechi == B.truechi && A.bestchi == B.bestchi;
12 }
13 
14 void fill_exps(TString file, std::map<double,FC> & exps ) {
15 
16  TFile *f = TFile::Open(file);
17  TTree *fcTree = (TTree*)f->Get("fc");
18 
19  double truechi = -1;
20  double bestchi = -1;
21  double seed = -1;
22 
23  fcTree->SetBranchStatus("*",0);
24  fcTree->SetBranchStatus("truechi",1);
25  fcTree->SetBranchStatus("bestchi",1);
26  fcTree->SetBranchStatus("loadtime",1);
27 
28  fcTree->SetBranchAddress("truechi",&truechi);
29  fcTree->SetBranchAddress("bestchi",&bestchi);
30  fcTree->SetBranchAddress("loadtime",&seed);
31 
32  Int_t numberOfEntries = fcTree->GetEntriesFast();
33  for (Int_t event = 0; event < numberOfEntries; ++event)
34  {
35  fcTree->GetEntry(event);
36  FC tmp_fc = {truechi,bestchi};
37  exps.insert(std::make_pair(seed,
38  tmp_fc));
39  }
40  f->Close();
41 }
42 
43 void simple_FC_validation(TString fileA, TString fileB, double tolerance=0){
44 
45  std::cout << "Comparing FCs :" << std::endl;
46 
47  std::map<double, FC> FC_A;
48  std::map<double, FC> FC_B;
49 
50  fill_exps(fileA, FC_A);
51  fill_exps(fileB, FC_B);
52 
53  for(auto & it : FC_A) {
54  double seed = it.first;
55  if(it.second==FC_B.at(seed))
56  std::cout << "Validated!" << std::endl;
57  else
58  std::cout << "Not validated!" << std::endl;
59  }
60 
61 }
double bestchi
set< int >::iterator it
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
unsigned int seed
Definition: runWimpSim.h:102
bool operator==(FC &A, FC &B)
OStream cout
Definition: OStream.cxx:6
static const double A
Definition: Units.h:82
void fill_exps(TString file, std::map< double, FC > &exps)
TFile * file
Definition: cellShifts.C:17
void simple_FC_validation(TString fileA, TString fileB, double tolerance=0)
double truechi