/* Dati vs. MC */ #include "TFile.h" #include "TDirectory.h" #include "TTree.h" #include "TColor.h" #include "TString.h" #define NBINS 20 #include "string.h" #include "vector.h" using namespace std ; void confronto () { gROOT->SetStyle("Plain") ; string bs[10] ; bs[0] = "nome0" ; bs[1] = "nome1" ; bs[2] = "nome2" ; bs[3] = "nome3" ; bs[4] = "nome4" ; bs[5] = "nome5" ; bs[6] = "nome6" ; bs[7] = "nome7" ; bs[8] = "nome8" ; bs[9] = "nome9" ; char titolo[40] ; TColor *colore = new TColor[10] colore[0] = gROOT->GetColor(2) ; colore[1] = gROOT->GetColor(3) ; colore[2] = gROOT->GetColor(4) ; colore[3] = gROOT->GetColor(5) ; colore[4] = gROOT->GetColor(6) ; colore[5] = gROOT->GetColor(7) ; colore[6] = gROOT->GetColor(8) ; colore[7] = gROOT->GetColor(9) ; colore[8] = gROOT->GetColor(41) ; colore[9] = gROOT->GetColor(1) ; string v[10] ; v[0] = "nome0.root" ; v[1] = "nome1.root" ; v[2] = "nome2.root" ; v[3] = "nome3.root" ; v[4] = "nome4.root" ; v[5] = "nome5.root" ; v[6] = "nome6.root" ; v[7] = "nome7.root" ; v[8] = "nome8.root" ; v[9] = "nome9.root" ; char filename[100] ; string var[14] ; var[0] = "variabile0" ; var[1] = "variabile1" ; var[2] = "variabile2" ; var[3] = "variabile3" ; var[4] = "variabile4" ; var[5] = "variabile5" ; var[6] = "variabile6" ; var[7] = "variabile7" ; var[8] = "variabile8" ; var[9] = "variabile9" ; var[10] = "variabile10" ; var[11] = "variabile11" ; var[12] = "variabile12" ; var[13] = "variabile13" ; char varname[30] ; Int_t i , j , k , cut1, cut2 , cut3 ; Float_t variabile0, variabile1 , variabile2 , variabile3 , variabile4, variabile5, variabile6 , variabile7 , variabile8, variabile9 , variabile10 , variabile11, variabile12 , variabile13 ; float variabile[14] ; variabile[0] = variabile0 = 0.0 ; variabile[1] = variabile1 = 0.0 ; variabile[2] = variabile2 = 0.0 ; variabile[3] = variabile3 = 0.0 ; variabile[4] = variabile4 = 0.0 ; variabile[5] = variabile5 = 0.0 ; variabile[6] = variabile6 = 0.0 ; variabile[7] = variabile7 = 0.0 ; variabile[8] = variabile8 = 0.0 ; variabile[9] = variabile9 = 0.0 ; variabile[10] = variabile10 = 0.0 ; variabile[11] = variabile11 = 0.0 ; variabile[12] = variabile12 = 0.0 ; variabile[13] = variabile13 = 0.0 ; float xmax[14] ; xmax[0] = 1000.0 ; xmax[1] = 3.2 ; xmax[2] = 1.0 ; xmax[3] = 10.0 ; xmax[4] = 1.1 ; xmax[5] = 500.0 ; xmax[6] = 800.0 ; xmax[7] = 1000.0 ; xmax[8] = 1000.0 ; xmax[9] = 1000.0 ; xmax[10] = 300.0 ; xmax[11] = 1000.0 ; xmax[12] = 1000.0 ; xmax[13] = 10.0 ; Double_t fs = (Double_t) 43.2/500 ; TH1F *h = new TH1F[14] ; THStack *hs = new THStack[14] ; TCanvas *c = new TCanvas[14] ; TLegend *leg = new TLegend[14] ; for (j = 0 ; j<14 ; j++) { sprintf(varname,var[%d],j) ; h[j]->SetName(varname) ; h[j]->SetBins(NBINS,0.0,xmax[j]) ; c[j]->SetName(varname) ; for (i = 0 ; i < 10 ; i++) { sprintf(filename,v[%d],j) ; sprintf(titolo,bs[%d],j) ; TFile *f = new TFile(filename,"READ") ; TTree *t = (TTree*)f->Get("Analysis") ; t->SetBranchAddress(varname,&variabile[j]) ; t->SetBranchAddress("cut2",&cut2) ; t->SetBranchAddress("cut3",&cut3) ; t->SetBranchAddress("cut1",&cut1) ; Int_t nentries = (Int_t)t->GetEntries(); for (k = 0 ; kGetEntry(k); if(cut1>0 && cut2==2 && cut3==0) h[j]->Fill(variabile[j]) ; } h[j]->SetLineColor(colore[j]) ; if (i!=9) { h[j]->Scale(fs) ; hs[j]->Add(h[j]) ; hs[j]->Draw() ; } else { h[j]->GetXaxis()->SetTitle(varname) ; h[j]->Draw("same") ; } leg[j]->AddEntry(h[j],titolo,"l") ; leg[j]->SetFillColor(0) ; leg[j]->SetTextFont(132) ; leg[j]->Draw() ; } } }