15 void TMVA::likelihoodrefs(TString dataset, TDirectory *lhdir ) {
16 Bool_t newCanvas = kTRUE;
18 const UInt_t maxCanvas = 200;
19 TCanvas** c =
new TCanvas*[maxCanvas];
24 std::vector<std::string> hasBeenUsed;
25 const TString titName = lhdir->GetName();
28 TIter next(lhdir->GetListOfKeys());
30 while ((key = TMVAGlob::NextKey(next,
"TH1"))) {
31 TH1 *h = (TH1*)key->ReadObj();
33 TString hname( h->GetName() );
36 Bool_t found = kFALSE;
37 for (UInt_t j = 0; j < hasBeenUsed.size(); j++) {
38 if (hasBeenUsed[j] == hname.Data()) found = kTRUE;
43 if (hname.EndsWith(
"_sig_nice")) {
47 sprintf( cn,
"cv%d_%s", ic+1, titName.Data() );
50 c[ic] =
new TCanvas( cn, Form(
"%s reference for variable: %s",
51 titName.Data(),(n.ReplaceAll(
"_sig",
"")).Data() ),
52 ic*50+50, ic*20, width, height );
59 TPad * cPad = (TPad*)c[ic]->cd(1);
60 TString plotname = hname;
62 h->SetMaximum(h->GetMaximum()*1.3);
64 h->SetMarkerColor(color);
65 h->SetMarkerSize( 0.7 );
66 h->SetMarkerStyle( 24 );
68 h->SetLineColor(color);
71 Double_t hSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1));
73 TLegend *legS=
new TLegend( cPad->GetLeftMargin(),
74 1-cPad->GetTopMargin()-.14,
75 cPad->GetLeftMargin()+.77,
76 1-cPad->GetTopMargin() );
77 legS->SetBorderSize(1);
78 legS->AddEntry(h,
"Input data (signal)",
"p");
81 TString bname( hname );
82 b = (TH1F*)lhdir->Get( bname.ReplaceAll(
"_sig",
"_bgd") );
83 cPad = (TPad*)c[ic]->cd(2);
85 b->SetMaximum(b->GetMaximum()*1.3);
88 b->SetLineColor(color);
89 b->SetMarkerColor(color);
90 b->SetMarkerSize( 0.7 );
91 b->SetMarkerStyle( 24 );
93 Double_t hBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1));
94 TLegend *legB=
new TLegend( cPad->GetLeftMargin(),
95 1-cPad->GetTopMargin()-.14,
96 cPad->GetLeftMargin()+.77,
97 1-cPad->GetTopMargin() );
98 legB->SetBorderSize(1);
99 legB->AddEntry(b,
"Input data (backgr.)",
"p");
102 hasBeenUsed.push_back( bname.Data() );
109 TString pname = hname; pname.ReplaceAll(
"_nice",
"");
110 for (
int i=0; i<= 5; i++) {
111 TString hspline = pname + Form(
"_smoothed_hist_from_spline%i", i );
112 h = (TH1F*)lhdir->Get( hspline );
114 b = (TH1F*)lhdir->Get( hspline.ReplaceAll(
"_sig",
"_bgd") );
120 if (h == 0 && b == 0) {
121 TString hspline = pname +
"_smoothed_hist_from_KDE";
122 h = (TH1F*)lhdir->Get( hspline );
124 b = (TH1F*)lhdir->Get( hspline.ReplaceAll(
"_sig",
"_bgd") );
129 if (h == 0 || b == 0) {
130 cout <<
"--- likelihoodrefs.C: did not find spline for histogram: " << pname.Data() << endl;
134 Double_t pSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1));
135 h->Scale( pSscale/hSscale );
139 h->SetLineColor(color);
140 legS->AddEntry(h,
"Estimated PDF (norm. signal)",
"l");
144 Double_t pBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1));
145 b->Scale( pBscale/hBscale );
148 b->SetLineColor(color);
150 legB->AddEntry(b,
"Estimated PDF (norm. backgr.)",
"l");
156 hasBeenUsed.push_back( pname.Data() );
161 TString fname = Form(
"%s/plots/%s_refs_c%i",dataset.Data(), titName.Data(), ic+1 );
162 TMVAGlob::imgconv( c[ic], fname );
166 hasBeenUsed.push_back( hname.Data() );
172 void TMVA::likelihoodrefs(TString dataset, TString fin , Bool_t useTMVAStyle )
175 TMVAGlob::Initialize( useTMVAStyle );
178 TFile *file=TMVAGlob::OpenFile( fin );
182 TString metlike=
"Method_Likelihood";
183 UInt_t ninst = TMVAGlob::GetListOfTitles(metlike,titles,file->GetDirectory(dataset.Data()));
185 cout <<
"Could not locate directory 'Method_Likelihood' in file " << fin << endl;
189 TIter keyIter(&titles);
192 while ((key = TMVAGlob::NextKey(keyIter,
"TDirectory"))) {
193 lhdir = (TDirectory *)key->ReadObj();
194 likelihoodrefs(dataset, lhdir );