TH1F* mix(int run=21, int cut=1, int bin1=3, int bin2=1, int plot=1, int method=1, TH1F* mix0=0, TH1F* mix1=0){ readfile(OPT,run); TH1F* h1= (TH1F*)mTFile->Get(Form("phi1_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h2= (TH1F*)mTFile->Get(Form("phi2_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h3= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h4= (TH1F*)h3->Clone(Form("mix_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h5= (TH1F*)h3->Clone(Form("dphi_corr_%1d%1d_c%d",bin1,bin2,cut)); h4->Reset(); h5->Reset(); mixing(h1,h2,h3,h4,1); h5->Divide(h3,h4); mix0=h4; TH1F* h11= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin1,cut)); TH1F* h12= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin2,cut)); TH1F* h13= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h14= (TH1F*)h3->Clone(Form("mix2_%1d%1d_c%d",bin1,bin2,cut)); TH1F* h15= (TH1F*)h3->Clone(Form("dphi_corr2_%1d%1d_c%d",bin1,bin2,cut)); h14->Reset(); h15->Reset(); mixing(h11,h12,h13,h14,0); h15->Divide(h13,h14); mix1=h14; if(plot==1){ TText* t; gStyle->SetOptStat(0); c1->Divide(2,2); c1->cd(1); h1->SetMinimum(0); h1->SetLineWidth(2); h1->Draw(); h11->Scale(h1->GetEntries()/h11->GetEntries()); h11->SetLineWidth(2); h11->SetLineColor(6); h11->Draw("same"); t = new TText(0.2, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.06); t->SetTextColor(1); t->Draw(); c1->cd(2); h2->SetMinimum(0); h2->SetLineWidth(2); h2->Draw(); if(h11!=h12)h12->Scale(h2->GetEntries()/h12->GetEntries()); h12->SetLineWidth(2); h12->SetLineColor(6); h12->Draw("same"); float m4=h4->GetMaximum(); c1->cd(4); h4->SetMinimum(0); h4->SetLineWidth(2); h4->SetMaximum(m4*1.1); h4->Draw(); h14->SetLineWidth(2); h4->SetLineColor(6); h14->Draw("same"); c1->cd(3); h3->Rebin(2); h5->Rebin(2); h15->Rebin(2); float m3=h3->GetBinContent(h3->GetNbinsX()*3/4); h3->SetMinimum(0); h3->SetLineWidth(2); h3->SetMaximum(m3*1.5); h3->SetLineColor(1); h3->Draw(); h5->SetLineWidth(2); h5->SetLineColor(2); h5->Draw("same"); h15->SetLineWidth(2); h15->SetLineColor(6); h15->Draw("same"); t= new TText(0.20, 0.25,"UnCorrected"); t->SetTextSize(0.05); t->SetTextColor(1); t->SetNDC(); t->Draw(); t= new TText(0.20, 0.20,"Corrected"); t->SetTextSize(0.05); t->SetTextColor(2); t->SetNDC(); t->Draw(); t= new TText(0.20, 0.15,"Corrected2"); t->SetTextSize(0.05); t->SetTextColor(6); t->SetNDC(); t->Draw(); c1->SaveAs(Form("plot/mix_%s_%1d%1d_c%d.png",CBEAM,bin1,bin2,cut)); } if(method==0) return h5; else return h15; }
//-------------------------------------------------------------------------------------------------- void overlayFrame(TString text, bool align) { // Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text // Create new transparent pad for the text TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1); transPad->SetFillStyle(4000); transPad->Draw(); transPad->cd(); // Overlay the text in a well defined frame TText *plotText = new TText(); plotText->SetTextColor(kBlue); plotText->SetTextSize(0.04); plotText->SetNDC(); // Draw text at top right if (align) { plotText->SetTextColor(kBlack); plotText->SetTextAlign(33); plotText->DrawText(0.92,0.95,text.Data()); } // Draw text at bottom left else plotText->DrawText(0.01,0.01,text.Data()); return; }
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) { if (rPerformance){ TLatex *alice = new TLatex(0.65,0.47,"Performance"); alice->SetNDC(); alice->SetTextColor(myDarkRed); alice->SetTextFont(42); alice->SetTextSize(0.05); alice->SetLineWidth(2); alice->Draw(); TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2"); alice2->SetNDC(); alice2->SetTextColor(myDarkRed); alice->SetTextFont(42); alice2->SetTextSize(0.05); alice2->SetLineWidth(2); alice2->Draw(); TText *date = new TText(0.68,0.35,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); //Acquire canvas proportions Double_t AliLogo_LowX = 0.67; Double_t AliLogo_LowY = 0.53; Double_t AliLogo_Height = 0.22; //ALICE logo is a png file that is 821x798 pixels->should be wider than a square Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! myPadSetUp(myPadLogo,0,0,0,0); //myPadLogo->SetFixedAspectRatio(1); myPadLogo->Draw(); myPadLogo->cd(); TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); myAliceLogo->Draw(); } if (rWrite == 1) c2->SaveAs(Form("%s.png",name)); if (rWrite == 2) c2->SaveAs(Form("%s.eps",name)); }
drawMultiplicity(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) { prepareAll(); TFile *f = new TFile(infilename, "read"); int minMultBin = 0; // 0, 2, 3 int maxMultBin = 6; // 2, 6, 8 double EvMultall = 0; for (int i = minMultBin; i < maxMultBin; i++) { if (i == minMultBin) TH1D* hEvMult =(TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)); else hEvMult->Add((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i))); EvMultall += ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries(); cout << "MultBin " << i << " " << ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries() << endl; //delete hEvMult; } cout << "Number of events (all bins): " << EvMultall << endl; TCanvas *c2 = new TCanvas("mult", "Event Multiplicity"); c2->SetGridx(); c2->SetGridy(); c2->SetFillColor(10); c2->SetLogy(); hEvMult->GetXaxis()->SetTitle("multiplicity"); hEvMult->GetYaxis()->SetTitle("number of events"); hEvMult->GetXaxis()->SetRangeUser(0,4000); hEvMult->Draw(""); if (rPerformance){ TLatex *alice = new TLatex(0.35,0.27,"Performance"); alice->SetNDC(); alice->SetTextColor(myDarkRed); alice->SetTextFont(42); alice->SetTextSize(0.05); alice->SetLineWidth(2); alice->Draw(); TLatex *alice2 = new TLatex(0.32,0.21,"LHC10h - Pass2"); alice2->SetNDC(); alice2->SetTextColor(myDarkRed); alice->SetTextFont(42); alice2->SetTextSize(0.05); alice2->SetLineWidth(2); alice2->Draw(); TText *date = new TText(0.38,0.15,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); //Acquire canvas proportions Double_t AliLogo_LowX = 0.37; Double_t AliLogo_LowY = 0.33; Double_t AliLogo_Height = 0.22; //ALICE logo is a png file that is 821x798 pixels->should be wider than a square Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! myPadSetUp(myPadLogo,0,0,0,0); //myPadLogo->SetFixedAspectRatio(1); myPadLogo->Draw(); myPadLogo->cd(); TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); myAliceLogo->Draw(); } if (rWrite == 1) c2->SaveAs(Form("multiplicity%s.png",system)); if (rWrite == 2) c2->SaveAs(Form("multiplicity%s.eps",system)); }
void memstat(double update=0.01, const char* fname="*") { // Open the memstat data file, then call TTree::Draw to precompute // the arrays of positions and nbytes per entry. // update is the time interval in the data file in seconds after which // the display is updated. For example is the job producing the memstat.root file // took 100s to execute, an update of 0.1s will generate 1000 time views of // the memory use. // if fname=="*" (default), the most recent file memstat*.root will be taken. TString s; if (!fname || strlen(fname) <5 || strstr(fname,"*")) { //take the most recent file memstat*.root s = gSystem->GetFromPipe("ls -lrt memstat*.root"); Int_t ns = s.Length(); fname = strstr(s.Data()+ns-25,"memstat"); } printf("Analyzing file: %s\n",fname); f = TFile::Open(fname); if (!f) { printf("Cannot open file %s\n",fname); return; } T = (TTree*)f->Get("T"); if (!T) { printf("cannot find the TMemStat TTree named T in file %s\n",fname); return; } if (update <= 0) { printf("Illegal update value %g, changed to 0.01\n",update); update = 0.01; } if (update < 0.001) printf("Warning update parameter is very small, processing may be slow\n"); Long64_t nentries = T->GetEntries(); T->SetEstimate(nentries+10); Long64_t nsel = T->Draw("pos:nbytes:time:btid","","goff"); //now we compute the best binning for the histogram Int_t nbytes; Double_t pos; V1 = T->GetV1(); V2 = T->GetV2(); V3 = T->GetV3(); V4 = T->GetV4(); Long64_t imean = (Long64_t)TMath::Mean(nsel,V1); Long64_t irms = (Long64_t)TMath::RMS(nsel,V1); //Long64_t bw = 10000; Long64_t bw = 1000; imean = imean - imean%bw; irms = irms -irms%bw; Int_t nbins = Int_t(4*irms/bw); Long64_t ivmin = imean -bw*nbins/2; Long64_t ivmax = ivmin+bw*nbins; if (ivmax > 2000000000 && ivmin <2000000000) { //the data set has been likely generated on a 32 bits machine //we are mostly interested by the small allocations, so we select //only values below 2 GBytes printf("memory locations above 2GBytes will be ignored\n"); nsel = T->Draw("pos:nbytes:time:btid","pos <2e9","goff"); V1 = T->GetV1(); V2 = T->GetV2(); V3 = T->GetV3(); V4 = T->GetV4(); imean = (Long64_t)TMath::Mean(nsel,V1); irms = (Long64_t)TMath::RMS(nsel,V1); bw = 10000; imean = imean - imean%bw; irms = irms -irms%bw; nbins = Int_t(4*irms/bw); ivmin = imean -bw*nbins/2; ivmax = ivmin+bw*nbins; } update *= 0.0001*V3[nsel-1]; //convert time per cent in seconds Long64_t nvm = Long64_t(ivmax-ivmin+1); Long64_t *nbold = new Long64_t[nvm]; Int_t *ientry = new Int_t[nvm]; memset(nbold,0,nvm*8); Double_t dv = (ivmax-ivmin)/nbins; h = new TH1D("h",Form("%s;pos;per cent of pages used",fname),nbins,ivmin,ivmax); TAxis *axis = h->GetXaxis(); gStyle->SetOptStat("ie"); h->SetFillColor(kRed); h->SetMinimum(0); h->SetMaximum(100); halloc = new TH1D("halloc",Form("%s;pos;number of mallocs",fname),nbins,ivmin,ivmax); hfree = new TH1D("hfree", Form("%s;pos;number of frees",fname),nbins,ivmin,ivmax); //open a canvas and draw the empty histogram TCanvas *c1 = new TCanvas("c1","c1",1200,600); c1->SetFrameFillColor(kYellow-3); c1->SetGridx(); c1->SetGridy(); h->Draw(); //create a TPaveText to show the summary results TPaveText *pvt = new TPaveText(.5,.9,.75,.99,"brNDC"); pvt->Draw(); //create a TPaveLabel to show the time TPaveLabel *ptime = new TPaveLabel(.905,.7,.995,.76,"time","brNDC"); ptime->SetFillColor(kYellow-3); ptime->Draw(); //draw producer identifier TNamed *named = (TNamed*)T->GetUserInfo()->FindObject("SysInfo"); TText tmachine; tmachine.SetTextSize(0.02); tmachine.SetNDC(); if (named) tmachine.DrawText(0.01,0.01,named->GetTitle()); //start loop on selected rows Int_t bin,nb=0,j; Long64_t ipos; Double_t dbin,rest,time; Double_t updateLast = 0; Int_t nleaks = 0; Int_t i; for (i=0;i<nsel;i++) { pos = V1[i]; ipos = (Long64_t)(pos-ivmin); nbytes = (Int_t)V2[i]; time = 0.0001*V3[i]; bin = axis->FindBin(pos); if (bin<1 || bin>nbins) continue; dbin = axis->GetBinUpEdge(bin)-pos; if (nbytes > 0) { halloc->Fill(pos); if (dbin > nbytes) dbin = nbytes; //fill bytes in the first page h->AddBinContent(bin,100*dbin/dv); //fill bytes in full following pages nb = Int_t((nbytes-dbin)/dv); if (bin+nb >nbins) nb = nbins-bin; for (j=1;j<=nb;j++) h->AddBinContent(bin+j,100); //fill the bytes remaining in last page rest = nbytes-nb*dv-dbin; if (rest > 0) h->AddBinContent(bin+nb+1,100*rest/dv); //we save nbytes at pos. This info will be used when we free this slot if (nbold[ipos] > 0) printf("reallocating %d bytes (was %lld) at %lld, entry=%d\n",nbytes,nbold[ipos],ipos,i); if (nbold[ipos] == 0) { nleaks++; //save the Tree entry number where we made this allocation ientry[ipos] = i; } nbold[ipos] = nbytes; } else { hfree->Fill(pos); nbytes = nbold[ipos]; if (bin+nb >nbins) nb = nbins-bin; nbold[ipos] = 0; nleaks--; if (nbytes <= 0) continue; //fill bytes free in the first page if (dbin > nbytes) dbin = nbytes; h->AddBinContent(bin,-100*dbin/dv); //fill bytes free in full following pages nb = Int_t((nbytes-dbin)/dv); if (bin+nb >nbins) nb = nbins-bin; for (j=1;j<=nb;j++) h->AddBinContent(bin+j,-100); //fill the bytes free in in last page rest = nbytes-nb*dv-dbin; if (rest > 0) h->AddBinContent(bin+nb+1,-100*rest/dv); } if (time -updateLast > update) { //update canvas at regular intervals updateLast = time; h->SetEntries(i); c1->Modified(); pvt->GetListOfLines()->Delete(); Double_t mbytes = 0; Int_t nonEmpty = 0; Double_t w; for (Int_t k=1;k<nbins;k++) { w = h->GetBinContent(k); if (w > 0) { nonEmpty++; mbytes += 0.01*w*dv; } } Double_t occupancy = mbytes/(nonEmpty*0.01*dv); pvt->AddText(Form("memory used = %g Mbytes",mbytes*1e-6)); pvt->AddText(Form("page occupancy = %f per cent",occupancy)); pvt->AddText("(for non empty pages only)"); ptime->SetLabel(Form("%g sec",time)); c1->Update(); gSystem->ProcessEvents(); } } h->SetEntries(nsel); Int_t nlmax = nleaks; nleaks += 1000; Int_t *lindex = new Int_t[nleaks]; Int_t *entry = new Int_t[nleaks]; Int_t *ileaks = new Int_t[nleaks]; nleaks =0; for (Int_t ii=0;ii<nvm;ii++) { if (nbold[ii] > 0) { ileaks[nleaks] = (Int_t)nbold[ii]; entry[nleaks] = ientry[ii]; nleaks++; if (nleaks > nlmax) break; } } TMath::Sort(nleaks,ileaks,lindex); hentry = new TH1I("hentry","leak entry index",nleaks,0,nleaks); hleaks = new TH1I("hleaks","leaks;leak number;nbytes in leak",nleaks,0,nleaks); for (Int_t k=0;k<nleaks;k++) { Int_t kk = lindex[k]; i = entry[kk]; hentry->SetBinContent(k+1,i); hleaks->SetBinContent(k+1,ileaks[kk]); } hentry->SetEntries(nleaks); hleaks->SetEntries(nleaks); //open a second canvas and draw the histogram with leaks in decreasing order TCanvas *c2 = new TCanvas("c2","c2",1200,600); c2->SetFrameFillColor(kCyan-6); c2->SetGridx(); c2->SetGridy(); c2->SetLogy(); hleaks->SetFillColor(kRed-3); if (nleaks > 1000) hleaks->GetXaxis()->SetRange(1,1000); hleaks->Draw(); //draw producer identifier if (named) tmachine.DrawText(0.01,0.01,named->GetTitle()); //construct the tooltip TRootCanvas *rc = (TRootCanvas *)c2->GetCanvasImp(); TGMainFrame *frm = dynamic_cast<TGMainFrame *>(rc); // create the tooltip with a timeout of 250 ms if (!gTip) gTip = new TGToolTip(gClient->GetDefaultRoot(), frm, "", 250); c2->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", 0, 0, "EventInfo(Int_t, Int_t, Int_t, TObject*)"); }
// input: - Input file (result from TMVA), // - normal/decorrelated/PCA // - use of TMVA plotting TStyle void variables( TString fin = "TMVA.root", TString dirName = "InputVariables_Id", TString title = "TMVA Input Variables", Bool_t isRegression = kFALSE, Bool_t useTMVAStyle = kTRUE ) { TString outfname = dirName; outfname.ToLower(); outfname.ReplaceAll( "input", "" ); // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // obtain shorter histogram title TString htitle = title; htitle.ReplaceAll("variables ","variable"); htitle.ReplaceAll("and target(s)",""); htitle.ReplaceAll("(training sample)",""); // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); TDirectory* dir = (TDirectory*)file->Get( dirName ); if (dir==0) { cout << "No information about " << title << " available in directory " << dirName << " of file " << fin << endl; return; } dir->cd(); // how many plots are in the directory? Int_t noPlots = TMVAGlob::GetNumberOfInputVariables( dir ) + TMVAGlob::GetNumberOfTargets( dir ); // define Canvas layout here! // default setting Int_t xPad; // no of plots in x Int_t yPad; // no of plots in y Int_t width; // size of canvas Int_t height; switch (noPlots) { case 1: xPad = 1; yPad = 1; width = 550; height = 0.90*width; break; case 2: xPad = 2; yPad = 1; width = 600; height = 0.50*width; break; case 3: xPad = 3; yPad = 1; width = 900; height = 0.4*width; break; case 4: xPad = 2; yPad = 2; width = 600; height = width; break; default: // xPad = 3; yPad = 2; width = 800; height = 0.55*width; break; xPad = 1; yPad = 1; width = 550; height = 0.90*width; break; } Int_t noPadPerCanv = xPad * yPad ; // counter variables Int_t countCanvas = 0; Int_t countPad = 0; // loop over all objects in directory TCanvas* canv = 0; TKey* key = 0; Bool_t createNewFig = kFALSE; TIter next(dir->GetListOfKeys()); while ((key = (TKey*)next())) { if (key->GetCycle() != 1) continue; if (!TString(key->GetName()).Contains("__Signal") && !(isRegression && TString(key->GetName()).Contains("__Regression"))) continue; // make sure, that we only look at histograms TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1")) continue; TH1 *sig = (TH1*)key->ReadObj(); TString hname(sig->GetName()); //normalize to 1 NormalizeHist(sig); // create new canvas if (countPad%noPadPerCanv==0) { ++countCanvas; canv = new TCanvas( Form("canvas%d", countCanvas), title, countCanvas*50+50, countCanvas*20, width, height ); canv->Divide(xPad,yPad); canv->SetFillColor(kWhite); canv->Draw(); } TPad* cPad = (TPad*)canv->cd(countPad++%noPadPerCanv+1); cPad->SetFillColor(kWhite); // find the corredponding backgrouns histo TString bgname = hname; bgname.ReplaceAll("__Signal","__Background"); TH1 *bgd = (TH1*)dir->Get(bgname); if (bgd == NULL) { cout << "ERROR!!! couldn't find background histo for" << hname << endl; exit; } //normalize to 1 NormalizeHist(bgd); // this is set but not stored during plot creation in MVA_Factory TMVAGlob::SetSignalAndBackgroundStyle( sig, (isRegression ? 0 : bgd) ); sig->SetTitle( TString( htitle ) + ": " + sig->GetTitle() ); TMVAGlob::SetFrameStyle( sig, 1.2 ); // normalise both signal and background // if (!isRegression) TMVAGlob::NormalizeHists( sig, bgd ); // else { // // change histogram title for target // TString nme = sig->GetName(); // if (nme.Contains( "_target" )) { // TString tit = sig->GetTitle(); // sig->SetTitle( tit.ReplaceAll("Input variable", "Regression target" ) ); // } // } sig->SetTitle( "" ); // finally plot and overlay Float_t sc = 1.1; if (countPad == 1) sc = 1.3; sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc ); sig->Draw( "hist" ); cPad->SetLeftMargin( 0.17 ); sig->GetYaxis()->SetTitleOffset( 1.50 ); if (!isRegression) { bgd->Draw("histsame"); TString ytit = TString("(1/N) ") + sig->GetYaxis()->GetTitle(); ytit = TString("Fraction of Events"); sig->GetYaxis()->SetTitle( ytit ); // histograms are normalised } if (countPad == 1) sig->GetXaxis()->SetTitle("Leading Lepton p_{T} [GeV/c]"); if (countPad == 2) sig->GetXaxis()->SetTitle("Trailing Lepton p_{T} [GeV/c]"); if (countPad == 3) sig->GetXaxis()->SetTitle("#Delta#phi(l,l)"); if (countPad == 4) sig->GetXaxis()->SetTitle("#Delta R(l,l)"); if (countPad == 5) sig->GetXaxis()->SetTitle("Dilepton Mass [GeV/c^{2}]"); if (countPad == 6) sig->GetXaxis()->SetTitle("Dilepton Flavor Final State"); if (countPad == 7) sig->GetXaxis()->SetTitle("M_{T} (Higgs) [GeV/c^{2}]"); if (countPad == 8) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, MET)"); if (countPad == 9) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, Jet)"); // Draw legend // if (countPad == 1 && !isRegression) { TLegend *legend= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.15, cPad->GetLeftMargin()+.4, 1-cPad->GetTopMargin() ); if(countPad == 1 || countPad == 2 ||countPad == 3 ||countPad == 4 ||countPad == 5 ||countPad == 7 ) { legend= new TLegend( 0.50, 1-cPad->GetTopMargin()-.15, 0.90, 1-cPad->GetTopMargin() ); } legend->SetFillStyle(0); legend->AddEntry(sig,"Signal","F"); legend->AddEntry(bgd,"Background","F"); legend->SetBorderSize(0); legend->SetMargin( 0.3 ); legend->SetTextSize( 0.03 ); legend->Draw("same"); // } // redraw axes sig->Draw("sameaxis"); // text for overflows Int_t nbin = sig->GetNbinsX(); Double_t dxu = sig->GetBinWidth(0); Double_t dxo = sig->GetBinWidth(nbin+1); TString uoflow = ""; if (isRegression) { uoflow = Form( "U/O-flow: %.1f%% / %.1f%%", sig->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100 ); } else { uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%", sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 ); } TText* t = new TText( 0.98, 0.14, uoflow ); t->SetNDC(); t->SetTextSize( 0.040 ); t->SetTextAngle( 90 ); // t->AppendPad(); // save canvas to file if (countPad%noPadPerCanv==0) { TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas ); TMVAGlob::plot_logo(); TMVAGlob::imgconv( canv, fname ); createNewFig = kFALSE; } else { createNewFig = kTRUE; } } if (createNewFig) { TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas ); TMVAGlob::plot_logo(); TMVAGlob::imgconv( canv, fname ); createNewFig = kFALSE; } return; }
void plot2d(int hid) { gStyle->SetOptStat(0); char c[50]; c1->Clear(); if(hid!=2 && hid!=4){ c1->Divide(2,3); for(int disc=0; disc<kFgtNumDiscs; disc++){ TPad *pad = c1->cd(disc+1); pad->SetLogz(1); pad->SetTopMargin(0.01); pad->SetBottomMargin(0.02); sprintf(c,"Disc%1d%s",disc+1,c2dHist[hid]); //printf("Getting %s\n",c); TH2F *h = hist2[disc][hid] = (TH2F*)file->Get(c); h->Draw("COLZ"); } }else if(hid==2){ // special case for timing per APVboard gStyle->SetOptTitle(0); gStyle->SetOptFit(0); c1->Divide(2,1); char txt[100]; //int disc=3; char name[100]="MaxAdc"; int disc=4; char name[100]="LandauMPV"; //int disc=5; char name[100]="LandauMPV-3Sing"; TVirtualPad *pad2 = c1->cd(1); pad2->Divide(1,2); TVirtualPad *pad3=pad2->cd(1); pad3->SetLogz(1); pad2->SetLogz(0); sprintf(c,"Disc%1d%s",disc,c2dHist[hid]); TH2F *h = hist2[disc][hid] = (TH2F*)file->Get(c); h->Draw("COLZ"); TText *tt1= new TText(0.05,0.1,"(RDO-1)*12+ARM*2+GRP"); tt1->SetTextAngle(90); tt1->SetNDC(); tt1->Draw(); sprintf(txt,"Tbin for %s",name); TText *tt2= new TText(0.3,0,txt); tt2->SetNDC(); tt2->Draw(); TVirtualPad* pad4 = c1->cd(2); pad4->SetTopMargin(0.01); pad4->SetBottomMargin(0.1); int maxid=0; float off,max=0; TH1D *h1[24]; float mean[24]; for(int i=0; i<24; i++){ char ccc[10]; sprintf(ccc,"_%d_%d",disc,i); h1[i] = h->ProjectionX(ccc,i+1,i+1); if(h1[i]->GetMaximum() > max && i!=0) {max=h1[i]->GetMaximum(); maxid=i; } } off=max/4.0; printf("max=%f off=%f\n",max,off); for(int i=0; i<24; i++){ h1[i]->GetXaxis()->SetRangeUser(2,11); int res = h1[i]->Fit("gaus","0Q"); TF1* f=h1[i]->GetFunction("gaus"); if(h1[i]->GetMaximum()>max/3 && res==0){ mean[i] = f->GetParameter(1); //mean[i]=h1[i]->GetMean(); }else{mean[i]=0;}; //printf("%d mean=%f\n",i,mean[i]); } //h1[maxid]->SetLineColor(maxid+1); h1[maxid]->SetLineWidth(2); h1[maxid]->Draw("PL"); for(int rdo=1; rdo<=2; rdo++){ for(int arm=0; arm<6; arm++){ for(int grp=0; grp<2; grp++){ i=(rdo-1)*12+arm*2+grp; int nb=h1[i]->GetNbinsX(); for(int t=0; t<nb; t++){ h1[i]->AddBinContent(t+1,off*i); } h1[i]->SetLineColor(i%6+1); h1[i]->SetLineWidth(3); if(i==0) { h1[i]->SetMinimum(0); h1[i]->SetMaximum(max*6.5); h1[i]->Draw("PL"); } else {h1[i]->Draw("PL same");} char name[100]; sprintf(name,"Rdo%1dArm%1dGrp%1d",rdo,arm,grp); TText *tx = new TText(8.5,(max/4.0)*(i+0.2),name); tx->SetTextColor(i%6+1); tx->SetTextSize(0.03); tx->Draw(); } } } // TText *tt3= new TText(0.95,0.1,"offsets added by (RDO-1)*12+ARM*2+GRP"); tt3->SetTextAngle(90); tt3->SetNDC(); tt3->Draw(); TText *tt4= new TText(0.4,0,txt); tt4->SetNDC(); tt4->Draw(); //correlation float t2[24]={-8.47, -5.16, -0.21, -2.23, 1.11, -4.09, -3.13, -9.08, -5.88, -7.01, -6.22, -9.79, 0.75, -8.91, 0.16, 1.12, -0.99, -4.56, 7.57, -3.68, 7.12, -6.54, -4.08, -8.21}; TGraph *g= new TGraph(1); int j=0; for(int i=0; i<24; i++){ if(mean[i]>0) {g->SetPoint(j,(mean[i]-6.0)*27,t2[i]); j++;} } TVirtualPad* pad5=pad2->cd(2); g->SetMarkerStyle(20+i/6); g->SetMarkerSize(1); g->Draw("ap"); for(int i=0; i<24; i++){ TGraph *g2= new TGraph(1); if(mean[i]>0) {g2->SetPoint(j,(mean[i]-6.0)*27,t2[i]); j++;} g2->SetMarkerStyle(20+i/6); g2->SetMarkerSize(2); g2->SetMarkerColor(i%6+1); g2->Draw("p"); } TText *tt5= new TText(0.05,0.1,"(VPHASE_ADC-1.2V)/0.95V*27nsec/2"); tt5->SetTextAngle(90); tt5->SetNDC(); tt5->Draw(); TText *tt6= new TText(0.5,0,"(Tbin-6)*27nsec"); tt6->SetNDC(); tt6->Draw(); }else{ // special case for timing per APVboard gStyle->SetOptTitle(0); gStyle->SetOptFit(0); c1->Divide(4,6); char txt[100]; //int disc=3; char name[100]="MaxAdc"; int disc=4; char name[100]="LandauMPV"; //int disc=5; char name[100]="LandauMPV-3Sing"; sprintf(c,"Disc%1d%s",disc,c2dHist[2]); TH2F *h = hist2[disc][2] = (TH2F*)file->Get(c); TH1D *h1[24]; float mean[24]; for(int rdo=1; rdo<=2; rdo++){ for(int arm=0; arm<6; arm++){ for(int grp=0; grp<2; grp++){ int i=(rdo-1)*12+arm*2+grp; TVirtualPad *pad2 = c1->cd(i+1); pad2->SetTopMargin(0.01); pad2->SetBottomMargin(0.1); char ccc[10]; sprintf(ccc,"_%d_%d",disc,i); h1[i]=h->ProjectionX(ccc,i+1,i+1); h1[i]->GetXaxis()->SetRangeUser(2,12); h1[i]->SetFillColor(4); h1[i]->GetXaxis()->SetLabelSize(0.1); h1[i]->GetYaxis()->SetLabelSize(0.1); h1[i]->Draw(); int res = h1[i]->Fit("gaus","Q"); TF1* f=h1[i]->GetFunction("gaus"); f->SetLineColor(2); f->SetLineWidth(2); if(res==0){ mean[i] = f->GetParameter(1); }else{mean[i]=0;}; char name[100]; sprintf(name,"Rdo%1dArm%1d-%1d",rdo,arm,grp); TText *tx = new TText(0.5,0.85,name); tx->SetTextSize(0.1); tx->SetNDC(); tx->Draw(); if(mean[i]>0){ sprintf(name,"peak=%4.1f",mean[i]); TText *tx2 = new TText(0.55,0.75,name); tx2->SetTextSize(0.12); tx2->SetNDC(); tx2->Draw(); } } } } } c1->Update(); save(c2dHist[hid]); }
void EMCDistribution_PeakSample_Fast(bool full_gain = false) { const TString gain = "RAW"; TString hname = "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts; TH2 *h2 = NULL; { if (full_gain) { h2 = new TH2F(hname, Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100, .05 * 100, 25 * 100, 64, -.5, 63.5); QAHistManagerDef::useLogBins(h2->GetXaxis()); } else { h2 = new TH2F(hname, Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260, -.2 * 100, 5 * 100, 64, -.5, 63.5); } T->Draw( "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>" + hname, "", "goff"); } TText *t; TCanvas *c1 = new TCanvas( "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts, "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts, 1800, 950); c1->Divide(8, 8, 0., 0.01); int idx = 1; TPad *p; for (int iphi = 8 - 1; iphi >= 0; iphi--) { for (int ieta = 0; ieta < 8; ieta++) { p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogy(); if (full_gain) { p->SetLogx(); } p->SetGridx(0); p->SetGridy(0); TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(full_gain ? "_FullGain" : ""); TH1 *h = h2->ProjectionX(hname, ieta + 8 * iphi + 1, ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1 h->SetLineWidth(0); h->SetLineColor(kBlue + 3); h->SetFillColor(kBlue + 3); h->GetXaxis()->SetTitleSize(.09); h->GetXaxis()->SetLabelSize(.08); h->GetYaxis()->SetLabelSize(.08); h->Draw(); if (full_gain) h->Fit("x*gaus", "M"); else h->Fit("landau", "M"); double peak = -1; TF1 *fit = ((TF1 *) (h->GetListOfFunctions()->At(0))); if (fit) { fit->SetLineColor(kRed); peak = fit->GetParameter(1); } cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak) << endl; TText *t = new TText(.9, .9, Form("<Col%d Row%d> = %.1f", ieta, iphi, peak)); t->SetTextAlign(33); t->SetTextSize(.15); t->SetNDC(); t->Draw(); } } SaveCanvas(c1, TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false); }
void EMCDistribution(TString gain = "CALIB", bool log_scale = false) { TText *t; TCanvas *c1 = new TCanvas( "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800, 1000); c1->Divide(8, 8, 0., 0.01); int idx = 1; TPad *p; for (int iphi = 8 - 1; iphi >= 0; iphi--) { for (int ieta = 0; ieta < 8; ieta++) { p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogy(); p->SetGridx(0); p->SetGridy(0); TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : ""); TH1 *h = NULL; if (log_scale) h = new TH1F(hname, Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 300, 5e-3, 3096); else // h = new TH1F(hname, // Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 196, // 1900, 2096); h = new TH1F(hname, Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 596, -96, 500); h->SetLineWidth(0); h->SetLineColor(kBlue + 3); h->SetFillColor(kBlue + 3); h->GetXaxis()->SetTitleSize(.09); h->GetXaxis()->SetLabelSize(.08); h->GetYaxis()->SetLabelSize(.08); if (log_scale) QAHistManagerDef::useLogBins(h->GetXaxis()); T->Draw( "TOWER_" + gain + "_CEMC[].get_energy_power_law_exp()>>" + hname, Form( "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d", gain.Data(), ieta, gain.Data(), iphi), ""); TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi)); t->SetTextAlign(33); t->SetTextSize(.15); t->SetNDC(); t->Draw(); // return; } } SaveCanvas(c1, TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false); }
void Plot::FitSignal(int mode, int fitMode) { const int nPar = 6; TRandom ran; if(mode==0) { gStyle->SetOptLogy(1); } else { gStyle->SetOptLogy(0); } gStyle->SetOptStat(0); gStyle->SetOptTitle(0); const float limitBinSize = 2.0; // **** bin size here TCanvas* c = NewCanvas(); c->Divide(1,2); gROOT->cd(); TH1F* cc = new TH1F("CCSignal","CC Signal",500,0.0,1000.0); TH1F* ccBg = new TH1F("CCBgFit","CC Bg Fit",500,0.0,1000.0); TH1F* ccBgErr = new TH1F("CCBgErr","CC Bg Err",500,0.0,1000.0); TH1F* ccBgP = new TH1F("CCBgPlus","CC Bg Plus",500,0.0,1000.0); TH1F* ccBgM = new TH1F("CCBgMinus","CC Bg Minus",500,0.0,1000.0); TH1F* cp = new TH1F("CPSignal","CP Signal",500,0.0,1000.0); TH1F* cpBg = new TH1F("CPBgFit","CP Bg Fit",500,0.0,1000.0); TH1F* cpBgErr = new TH1F("CPBgErr","CP Bg Err",500,0.0,1000.0); TH1F* cpBgP = new TH1F("CPBgPlus","CP Bg Plus",500,0.0,1000.0); TH1F* cpBgM = new TH1F("CPBgMinus","CP Bg Minus",500,0.0,1000.0); TMatrixD matrix(nPar,nPar); fd->cd(); TH1F* hInt,*hBgInt; char fitname[100]; for(int ind=0; ind<2; ind++) { if(debug) printf("starting ind %i\n",ind); c->cd(ind+1); gStyle->SetOptLogy(1); printf("Starting %i ######################################\n",ind); TH1F* h; //char cind[20]; //char handle[100]; //sprintf(handle,"side_1exp_%02i_%02i_%02i",ind,mode,fitMode); TF1* fits[4]; //TF1* dpx[4]; if(debug) printf("looking for h %i\n",int(fd)); if(ind==0) { h = (TH1F*)fd->FindObjectAny("pair_mass_2GeV1"); } else if(ind==1) { h = (TH1F*)fd->FindObjectAny("pair_mass_2GeV3"); } if(debug) printf("new h %i\n",int(h)); if(debug) printf("new fit\n"); sprintf(fitname,"hfit_%1i",ind); fits[ind] = new TF1(fitname,"([0]*pow((x-30.0),[1])+[3]*pow((x-30.0),0.2))*([2]*exp(-[2]*(x-30.0))+[4]*[5]*exp(-[5]*(x-30.0)))",30.0,500.0); //fits[ind] = new TF1(fitname,"([0]*((1-[3])*pow((x-30.0),[1])+[3]*pow((x-30.0),0.2)))*(exp(-[2]*(x-30.0))+[4]*exp(-[5]*(x-30.0)))",30.0,500.0); fits[ind]->SetParameter(0,0.0004); fits[ind]->SetParameter(1,2); fits[ind]->SetParameter(2,0.02); fits[ind]->SetParameter(3,0.005); //fits[ind]->SetParameter(3,0.5); fits[ind]->SetParameter(4,1.005); fits[ind]->SetParameter(5,0.05); float llim = 30.0; h->Fit(fits[ind],"LN","",llim,1000.0); double par[20],parMin[20],fval,fvalMin; for(int i=0; i<nPar; i++) parMin[i] = fits[ind]->GetParameter(i); gMinuit->Eval(nPar,0,fvalMin,parMin,0); //printf("got back %10.5f\n",fvalMin); // save the fit results in a histogram, for limit program for(int ibin=16; ibin<250; ibin++) { float xx = h->GetBinCenter(ibin); float yy = fits[ind]->Eval(xx); if(ind==0) { cc->SetBinContent(ibin,h->GetBinContent(ibin)); ccBg->SetBinContent(ibin,yy); ccBgErr->SetBinContent(ibin,0.0); ccBgP->SetBinContent(ibin,0.0); ccBgM->SetBinContent(ibin,99999.0); } else { cp->SetBinContent(ibin,h->GetBinContent(ibin)); cpBg->SetBinContent(ibin,yy); cpBgErr->SetBinContent(ibin,0.0); cpBgP->SetBinContent(ibin,0.0); cpBgM->SetBinContent(ibin,99999.0); } } //vary the parameters to find an error envelope double par2[20],fval2=1e10; int pslim = (ind==0?25000:150000); for(int ips=0; ips<pslim; ips++) { if(ips%10000==0) printf("Processing %d\n",ips); for(int i=0; i<nPar; i++) { par[i] = parMin[i]; } for(int i=0; i<nPar; i++) { //int i = (ips%2==0?0:3); par[i] = parMin[i]+(2.0*(ran.Uniform()-0.5))*fits[ind]->GetParError(i); } fval = 0.0; gMinuit->Eval(nPar,0,fval,par,0); if((fval-fvalMin)<1.0) { printf("Found nearby min %10.5f\n",fval-fvalMin); float eOld,eNew; for(int ibin=16; ibin<250; ibin++) { float xx = h->GetBinCenter(ibin); for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,par[i]); float yy = fits[ind]->Eval(xx); for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,parMin[i]); float yyMin = fits[ind]->Eval(xx); TH1F *hBgErr,*hBgP,*hBgM; if(ind==0) { hBgErr = ccBgErr; hBgP = ccBgP; hBgM = ccBgM; } else { hBgErr = cpBgErr; hBgP = cpBgP; hBgM = cpBgM; } eOld = hBgErr->GetBinContent(ibin); eNew = yy - yyMin; if(eOld>fabs(eNew)) hBgErr->SetBinContent(ibin,fabs(eNew)); eOld = hBgP->GetBinContent(ibin); if(yy>eOld) hBgP->SetBinContent(ibin,yy); eOld = hBgM->GetBinContent(ibin); if(yy<eOld) hBgM->SetBinContent(ibin,yy); } } // end if near maximum /* if(fval<fval2) { for(int i=0; i<nPar; i++) par2[i] = par[i]; fval2 = fval; } */ } /* printf("forcing new fit..\n"); for(int i=0; i<nPar; i++) { printf("old,new = %10.5f %10.5f\n",parMin[i],par2[i]); fits[ind]->SetParameter(i,par2[i]); } */ // restore original fit fval = 0.0; gMinuit->Eval(nPar,0,fval,parMin,0); for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,parMin[i]); //extract fit error matrix gMinuit->mnemat(matrix.GetMatrixArray(),nPar); matrix.Print(); for(int i=0; i<nPar; i++) { for(int j=0; j<nPar; j++) { printf("%10.5f",matrix(i,j)/sqrt(matrix(i,i)*matrix(j,j))); } printf("\n"); } //matrix.Draw("text"); float hm = h->GetMaximum(); if(mode==0) { //TAxis* ax = h->GetXaxis(); //ax->SetRangeUser(24.1,199.9); h->SetMaximum(1.2*hm); //h->SetMinimum(0.0); } else if(mode==1) { TAxis* ax = h->GetXaxis(); ax->SetRangeUser(20.0,500.0); h->SetMaximum(1.15*hm); h->SetMinimum(0.0); } h->Draw(); fits[ind]->SetLineColor(1); fits[ind]->SetLineWidth(2.0); fits[ind]->Draw("SAME"); // find chi2's and KS's //AnaChiKs(h,fits[ind]); TAxis* ax,*ay; ax = h->GetXaxis(); ay = h->GetYaxis(); ax->SetTitle("m(#gamma#gamma) (GeV/c^{2})"); ay->SetTitle("Entries/2 GeV/c^{2}"); ax->CenterTitle(); ay->CenterTitle(); ax->SetTitleOffset(0.9); ay->SetTitleOffset(1.0); ax->SetTitleSize(0.08); ay->SetTitleSize(0.07); ax->SetLabelSize(0.07); ay->SetLabelSize(0.07); gPad->SetLeftMargin(0.16); gPad->SetBottomMargin(0.16); TText* text; text = new TLatex(0.5,0.8,"Diphoton Data"); text->SetNDC(true); text->SetTextSize(0.06); text->Draw(); if(ind==0) text = new TLatex(0.5,0.72,"Central-Central"); else if(ind==1) text = new TLatex(0.5,0.72,"Central-Plug"); text->SetNDC(true); text->SetTextSize(0.06); text->Draw(); if(ind==0) { text = new TLatex(0.15,0.92,"W/Z H#rightarrow X(#gamma#gamma)"); text->SetNDC(true); text->SetTextSize(0.08); text->Draw(); text = new TLatex(0.5,0.92,"CDF Run II Preliminary, 2.0 fb^{-1}"); text->SetNDC(true); text->SetTextSize(0.06); text->Draw(); } /* if(debug) printf("start loop\n"); int ibin; for(ibin=16; ibin<=250; ibin++) { if(debug) printf("start bin %i\n",ibin); float xx = (ibin-0.5)*2.0; // *** bin width here if(debug) printf("-1 test ibin %i\n",ibin); float yy = fits[ind]->Eval(xx); //printf("%f yy= %f \n",xx,yy); // the derivative of this yield wrt parameters if(debug) printf("0 test ibin %i\n",ibin); double y0 = yy; if(debug) printf("1 test ibin %i\n",ibin); TMatrixD vv(nPar,1); float dirSize = 0.5; for(int i=0; i<nPar; i++){ int ipar = i; double par = fits[ind]->GetParameter(ipar); double spar = fits[ind]->GetParError(ipar); double parp = par + dirSize*spar; fits[ind]->SetParameter(ipar,parp); double yp = fits[ind]->Eval(xx); vv(i,0) = limitBinSize*(yp-y0)/(dirSize*spar); fits[ind]->SetParameter(ipar,par); //printf("%f %f %f\n",yp,y0,spar); } //vv.Print(); if(debug) printf("start matrix %i\n",ibin); TMatrixD tempM(matrix, TMatrixDBase::kMult, vv); //matrix.Print(); TMatrixD tempN(vv, TMatrixDBase::kTransposeMult, tempM); //tempN.Print(); float bgSig = 0.0; if(tempN(0,0)>0.0) bgSig = sqrt(tempN(0,0)); // ****** hack temp ********** bgSig = 0.3*y0; // file hists to be saved if(debug) printf("start fill %i\n",ibin); if(ind==0) { //printf("filling cc %i %f\n",ibin,h->GetBinContent(ibin)); cc->SetBinContent(ibin,h->GetBinContent(ibin)); //printf("getting cc %i %f\n",ibin,cc->GetBinContent(ibin)); ccBg->SetBinContent(ibin,yy); ccBgErr->SetBinContent(ibin,bgSig); ccBgP->SetBinContent(ibin,yy+bgSig); ccBgM->SetBinContent(ibin,TMath::Max(yy-bgSig,float(0.0))); //if(ibin==27) { //printf("bg %f %f \n",yy,bgSig); //} } else { cp->SetBinContent(ibin,h->GetBinContent(ibin)); cpBg->SetBinContent(ibin,yy); cpBgErr->SetBinContent(ibin,bgSig); cpBgP->SetBinContent(ibin,yy+bgSig); cpBgM->SetBinContent(ibin,TMath::Max(yy-bgSig,float(0.0))); } if(debug) printf("end fill %i\n",ibin); } */ } printf("cc plus BG=%f\n",ccBgP->GetSum()); printf("cc minus BG=%f\n",ccBgM->GetSum()); printf("cp plus BG=%f\n",cpBgP->GetSum()); printf("cp minus BG=%f\n",cpBgM->GetSum()); char fn[100]; if(mode==0) { sprintf(fn,"FitSignal_%d",fitMode); savePlot(c,fn); } else if(mode==1) { sprintf(fn,"FitSignalLin_%d",fitMode); savePlot(c,fn); } //if(mode!=0) return; // plot of fit results gStyle->SetOptLogy(0); c = NewCanvas(); c->Divide(1,2); c->cd(1); cc->Draw(); ccBg->Draw("SAME"); c->cd(2); ccBgErr->SetMinimum(0.0); ccBgErr->SetMaximum(4.0); ccBgErr->Draw(); ccBgP->SetLineStyle(2); ccBgP->Draw("SAME"); ccBgM->SetLineStyle(2); ccBgM->Draw("SAME"); savePlot(c,"FitSignalResultsCC"); c = NewCanvas(); c->Divide(1,2); c->cd(1); cp->Draw(); cpBg->Draw("SAME"); c->cd(2); cpBgErr->SetMinimum(0.0); cpBgErr->SetMaximum(4.0); cpBgErr->Draw(); cpBgP->SetLineStyle(2); cpBgP->Draw("SAME"); cpBgM->SetLineStyle(2); cpBgM->Draw("SAME"); savePlot(c,"FitSignalResultsCP"); char title[100]; if(name) { sprintf(title,"TPeaksHiggs_FitSignalHist_%s.root",name); TFile* ff = new TFile(title,"RECREATE"); gROOT->GetList()->Write(); ff->Close(); } }
int main(int argc, char *argv[]) { FILE *fp; RawDataPacket r; //char *filename; unsigned char buf[1024*1024]; int n; //if (argc != 2) { // usage(); // exit(1); //} //filename = argv[1]; //fp = fopen(filename, "r"); //if (fp == NULL) { //err(1, "fopen for %s", filename); //} fp = stdin; TApplication theApp("name", &argc, argv); TCanvas *c1 = new TCanvas("c1", "C1", 800, 600); int n_points = 1024; int x[n_points]; int y[n_points]; //TGraph *graph = new TGraph(n_points); TGraph *graph = new TGraph(); TText *text = new TText(); text->SetTextSize(0.05); text->SetTextColor(kBlack); text->SetNDC(1); for ( ; ; ) { n = fread(buf, 1, RawDataPacket::HEADER_SIZE, fp); if (n == 0) { if (feof(fp)) { break;; } else if (ferror(fp)) { exit(0); } } else if (n != RawDataPacket::HEADER_SIZE) { errx(1, "partial read %d bytes. Should be %d bytes", n, RawDataPacket::HEADER_SIZE); } r.set_buf(buf, n); if (! r.is_raw_data_packet()) { cout << "Not a RawDataPacket" << endl; exit(1); } int data_length = r.get_data_length(); cout << "data_length: " << data_length << endl; n = fread(&buf[RawDataPacket::HEADER_SIZE], 1, data_length, fp); if (n == 0) { if (feof(fp)) { break;; } else if (ferror(fp)) { exit(0); } } else if (n != data_length) { errx(1, "partial read %d bytes. Should be %d bytes", n, data_length); } int window_size = r.get_window_size(); int trigger_count = r.get_trigger_count(); //int n_ch = r.get_num_of_ch(); //cout << "window_size: " << window_size << endl; //cout << "trigger_count: " << trigger_count << endl; //for (int ch = 0; ch < n_ch; ch ++) { // for (int w = 0; w < window_size; w++) { // unsigned short data = r.get_data_at(ch, w); // cout << "trg: " << trigger_count; // cout << " ch: " << ch; // cout << " window: " << w; // cout << " data: " << data; // cout << endl; // } //} int ch = 0; for (int w = 0; w < window_size; w++) { x[w] = w; y[w] = r.get_data_at(ch, w); graph->SetPoint(w, x[w], y[w]); } graph->SetTitle(Form("Channel: %d", ch)); graph->SetMinimum(0.0); graph->SetMaximum(4096.0); graph->Draw("al*"); text -> DrawText(0.7, 0.92, Form("Trigger: %d", trigger_count)); c1->Update(); r.reset_buf(); usleep(500000); } return 0; }
void comp(int run, int pt1, int pt2, TCanvas* cvs, int fit=0){ int bin0=1; char c[100]; char c2[100]; readfile(OPT,run); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetOptTitle(0); cvs->Clear(); float ptcut[kNPtBin+1]={0.5,1.0,1.5,2.0,2.5,3.0,10.0}; float col[NCUT+1]={0,1,4,3,4,38,6,9,8,kGreen+3,kOrange,kPink+9,kOrange+7,kGreen+3,3,2,1,2}; memset(PAR,0,sizeof(PAR)); TText* t; int cmax=NCUT; if(run==20) cmax++; int iy=0; for(int cc=1; cc<cmax; cc++){ TH1F *h,*h2,*h3,*h4; if(run==11 && cc==5) continue; if(run==11 && cc>14) continue; //if(run==20 && cc!=2 && cc!=9 && cc!=10 && cc!=11 && cc!=cmax-3) continue; if(run==20 && cc!=2 && cc!=14 && cc!=cmax-3) continue; //get normalizations sprintf(c,"m0_%1d_c%d",pt1,cc); TH1F* h0 = (TH1F*)mTFile->Get(c); float norm0 = h0->GetEntries(); sprintf(c,"m1_%1d%1d_c%d",pt1,pt2,cc); TH1F* h1 = (TH1F*)mTFile->Get(c); float norm1 = h1->GetEntries(); float norm2=norm1/norm0; float norm3=norm2/ZggCut; printf("cut=%2d n0=%d n1=%d n2=%f\n",cc,norm0,norm1,norm2); sprintf(c,"dphi_%1d%1d_c%d",pt1,pt2,cc); h = (TH1F*)mTFile->Get(c); int nbin = h->GetNbinsX(); if(cc==cmax-3){ h->Scale(1.0/norm0*nbin/2.0/PI); }else{ h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut); } h->SetLineColor(col[cc]); h->SetLineWidth(2); h->SetMinimum(0.0); if(iy==0) { h->SetMaximum(h->GetMaximum()*1.5); h->Draw("l"); }else{ h->Draw("lsame"); } if(run==20 && cc==cmax-3) cc=cmax-1; t = new TText(0.7, 0.85-iy*0.03,CCUT[cc]); t->SetNDC(); t->SetTextSize(0.02); t->SetTextColor(col[cc]); t->Draw(); iy++; } float xx=0.45, yy=0.80, dy=0.03; t = new TText(xx, yy, Form("pT1=%3.1f-%3.1f",ptcut[pt1],ptcut[pt1+1])); t->SetNDC(); t->SetTextSize(0.03); t->Draw(); t = new TText(xx, yy-dy, Form("pT2=%3.1f-%3.1f",ptcut[pt2],ptcut[pt2+1])); t->SetNDC(); t->SetTextSize(0.03); t->Draw(); if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_compdphi.png");} else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau_compdphi.png");} else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_compdphi.png");} else if(run==20) {sprintf(c,"plot/dipi0_pythia_compdphi.png");} else {sprintf(c,"plot/dipi0_%d_compdphi.png",run);} printf("Saving %s\n",c); cvs->SaveAs(c); }
// input: - Input file (result from TMVA), // - use of colors or grey scale // - use of TMVA plotting TStyle void correlations( TString fin = "TMVA.root",TString outputdir="plots", Bool_t isRegression = kFALSE, Bool_t greyScale = kFALSE, Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); // signal and background or regression problem Int_t ncls = (isRegression ? 1 : 2 ); TString hName[2] = { "CorrelationMatrixS", "CorrelationMatrixB" }; if (isRegression) hName[0]= "CorrelationMatrix"; const Int_t width = 600; for (Int_t ic=0; ic<ncls; ic++) { TH2* h2 = file->Get( hName[ic] ); if(!h2) { cout << "Did not find histogram " << hName[ic] << " in " << fin << endl; continue; } TCanvas* c = new TCanvas( hName[ic], Form("Correlations between MVA input variables (%s)", (isRegression ? "" : (ic==0 ? "signal" : "background"))), ic*(width+5)+200, 0, width, width ); Float_t newMargin1 = 0.13; Float_t newMargin2 = 0.15; if (TMVAGlob::UsePaperStyle) newMargin2 = 0.13; c->SetGrid(); c->SetTicks(); c->SetLeftMargin ( newMargin2 ); c->SetBottomMargin( newMargin2 ); c->SetRightMargin ( newMargin1 ); c->SetTopMargin ( newMargin1 ); gStyle->SetPalette( 1, 0 ); gStyle->SetPaintTextFormat( "3g" ); h2->SetMarkerSize( 1.5 ); h2->SetMarkerColor( 0 ); Float_t labelSize = 0.040; h2->GetXaxis()->SetLabelSize( labelSize ); h2->GetYaxis()->SetLabelSize( labelSize ); h2->LabelsOption( "d" ); h2->SetLabelOffset( 0.011 );// label offset on x axis h2->Draw("colz"); // color pads c->Update(); // modify properties of paletteAxis TPaletteAxis* paletteAxis = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject( "palette" ); paletteAxis->SetLabelSize( 0.03 ); paletteAxis->SetX1NDC( paletteAxis->GetX1NDC() + 0.02 ); h2->Draw("textsame"); // add text // add comment TText* t = new TText( 0.53, 0.88, "Linear correlation coefficients in %" ); t->SetNDC(); t->SetTextSize( 0.026 ); t->AppendPad(); // TMVAGlob::plot_logo( ); c->Update(); TString fname = outputdir + TString("/"); fname += hName[ic]; TMVAGlob::imgconv( c, fname ); } }
void plot(char* v, int run, int cut, TCanvas* cvs, int fit=0, int bin1=-1, int bin2=-1, float ymax=0.0, int rebin=0){ int bin0=1; char c[100]; char c2[100]; readfile(OPT,run); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetOptTitle(0); cvs->Clear(); int b1=bin1, b2=bin1+1, b3=bin2, b4=b3; if(bin1<0) {cvs->Divide(kNPtBin-bin0,kNPtBin-bin0); b1=bin0; b2=kNPtBin; b3=bin0;} float ptcut[kNPtBin+1]={0.5,1.0,1.5,2.0,2.5,3.0,10.0}; memset(PAR,0,sizeof(PAR)); TText* t; for(int i=b1; i<b2; i++){ if(bin1<0) b4=i; for(int j=b3; j<=b4; j++){ int cc=cut; if(cut==99 && (v=="m1" || v=="m2")) cc=0; if(cut==99 && v=="dphi") cc=1; TH1F *h,*h2,*h3,*h4; TH2F *h2d; //get normalizations float norm0=1.0; float norm1=1.0; float norm2=1.0; float norm3=1.0; if(v=="m0" || v=="phi0"){} else{ sprintf(c,"m0_%1d_c%d",i,cc); TH1F* h0 = (TH1F*)mTFile->Get(c); norm0 = h0->GetEntries(); sprintf(c,"m2_%1d%1d_c%d",i,j,cc); TH1F* h1 = (TH1F*)mTFile->Get(c); norm1 = h1->GetEntries(); printf("n0=%d n1=%d\n",norm0,norm1); norm2=norm1/norm0; norm3=norm2/ZggCut; } int opt=1, log=0; if(v=="mix"){ h3=mix(run,cc,i,j,0,1,h,h2); h1->SetLineColor(1); h2->SetLineColor(6); }else if(v=="corr"){ h = mix(run,cc,i,j,0,1); if(rebin>0) h->Rebin(rebin); if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0); int nbin = h->GetNbinsX(); h->Sumw2(); if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);} else {h->Scale(1.0/norm0*nbin/2.0/PI);} }else if(v=="norm"){ sprintf(c,"dphi_%1d%1d_c%d",i,j,cc); h = (TH1F*)mTFile->Get(c); if(rebin>0) h->Rebin(rebin); if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0); int nbin = h->GetNbinsX(); h->Sumw2(); if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);} else {h->Scale(1.0/norm0*nbin/2.0/PI);} }else if(v=="mall"){ sprintf(c,"m0_%1d_c%d",i,0); sprintf(c2,"m0_%1d%1d_c%d",i,j,0); h4 = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2); float norm4 = h4->Integral(h4->GetXaxis()->FindBin(MassCut0),h4->GetXaxis()->FindBin(MassCut1)); h4->Scale(norm1/norm4); h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2); sprintf(c,"m0_%1d_c%d",i,cc); sprintf(c2,"m0_%1d%1d_c%d",i,j,cc); h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2); h->SetLineColor(6); h->Scale(norm2); sprintf(c,"m1_%1d%1d_c%d",i,j,cc); h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(2); sprintf(c,"m2_%1d%1d_c%d",i,j,cc); h3 = (TH1F*)mTFile->Get(c); h3->SetLineColor(4); }else if(v=="z12"){ sprintf(c,"z1_%1d%1d_c%d",i,j,cc); h = (TH1F*)mTFile->Get(c); h->SetLineColor(2); sprintf(c,"z2_%1d%1d_c%d",i,j,cc); h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(4); }else if(v=="m0" || v=="phi0"){ sprintf(c,"%s_%1d_c%d",v,i,cc); printf("%s\n",c); h = (TH1F*)mTFile->Get(c); }else if(v=="bbce"){ opt=1; log=1; sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc); printf("%s\n",c); h = (TH1F*)mTFile->Get(c); h->SetMinimum(0.1); }else if(v=="phi1" || v=="phi2"){ opt=1; sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc); printf("%s\n",c); h = (TH1F*)mTFile->Get(c); }else if(v=="phi1dphi"){ opt=2; sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc); printf("%s\n",c); h = (TH1F*)mTFile->Get(c); }else{ sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc); printf("%s\n",c); h = (TH1F*)mTFile->Get(c); } if(bin1<0){ TVirtualPad *pad = cvs->cd((i-bin0)*(kNPtBin-bin0)+(j-bin0)+1); pad->SetRightMargin(0.01); pad->SetLeftMargin(0); pad->SetTopMargin(0); pad->SetBottomMargin(0.01); pad->Draw(); } h->SetMinimum(0.0); if(ymax>0.0) h->SetMaximum(ymax); if(opt==0) h->Draw("e"); if(opt==1) h->Draw(); if(opt==2) h->Draw("colz"); if(v=="mall"){ h4->Draw("same"); h2->Draw("same"); h3->Draw("same"); } if(v=="z12" || v=="mix") h2->Draw("same"); TF1* f; if((v=="norm" || v=="corr") && fit==1){ f=new TF1("oneGaus",oneGaus,+PI/2.0,+PI*3.0/2.0,3); f->SetParameters(norm3/10.0,norm3/2.0,0.3); f->SetParNames("Const","IntFar","SigFar"); f->SetParLimits(0,0.0,1.0); f->SetParLimits(1,0.0,1.0); f->SetParLimits(2,0.0,3.0); f->SetLineColor(2); f->SetLineWidth(1); h->Fit("oneGaus","Q"); PAR[i][j][0]=f->GetParameter(0); PAR[i][j][1]=f->GetParameter(1); PAR[i][j][2]=f->GetParameter(2); printf("norm=%8.6f Int=%8.6f IntFar=%8.6 SigFar=%6.3f C=%8.6f\n", norm3,PAR[i][j][1]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][2],PAR[i][j][0]); } if((v=="norm" || v="corr") && fit==2){ f=new TF1("twoGaus",twoGaus,-PI/2.0,+PI*3.0/2.0,5); f->SetParameters(norm3/10.0,norm3/2.0,0.3,norm3/2.0,0.3); f->SetParNames("Const","IntNear","SigNear","IntFar","SigFar"); f->SetParLimits(0,0.0,1.0); f->SetParLimits(1,0.0,1.0); f->SetParLimits(2,0.0,3.0); f->SetParLimits(3,0.0,1.0); f->SetParLimits(4,0.0,3.0); f->SetLineColor(2); f->SetLineWidth(1); h->Fit("twoGaus","Q"); PAR[i][j][0]=f->GetParameter(0); PAR[i][j][1]=f->GetParameter(1); PAR[i][j][2]=f->GetParameter(2); PAR[i][j][3]=f->GetParameter(3); PAR[i][j][4]=f->GetParameter(4); printf("norm=%8.6f Int=%8.6f IntNear=%8.6f IntFar=%8.6f SigNear=%6.3f SigFar=%6.3f C=%8.6f\n", norm3,PAR[i][j][1]+PAR[i][j][3]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][3], PAR[i][j][2],PAR[i][j][4],PAR[i][j][0]); } float xx=0.60, yy=0.85, dy=0.04, size=0.04; if(bin1<0){xx=0.45, yy=0.90, dy=0.08, size=0.08;} if(v=="z12") {xx=0.1; yy=0.35;} t = new TText(xx, yy, Form("pT1=%3.1f-%3.1f",ptcut[i],ptcut[i+1])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy, Form("pT2=%3.1f-%3.1f",ptcut[j],ptcut[j+1])); t->SetNDC(); t->SetTextSize(size); t->Draw(); if(norm3>0.0){ t = new TText(xx, yy-dy*2, Form("P=%7.5f",norm3)); t->SetNDC(); t->SetTextSize(size); t->Draw(); } if((v=="norm" || v="corr") && fit==1){ t = new TText(xx, yy-dy*3, Form("PBg=%7.5f", PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*5, Form("Saway=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw(); } if((v=="norm" || v="corr") && fit==2){ t = new TText(xx, yy-dy*3, Form("Pnear=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][3])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*5, Form("PBg=%7.5f", PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*6, Form("Snear=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw(); t = new TText(xx, yy-dy*7, Form("Saway=%4.2f",PAR[i][j][4])); t->SetNDC(); t->SetTextSize(size); t->Draw(); } if(cut==88) h->SetLineColor(2); if(cut==99 && (v=="m1"|| v=="m2")){ sprintf(c,"%s_%1d%1d_c%d",v,i,j,1); h = (TH1F*)mTFile->Get(c); h->SetLineColor(4); h->Draw("same"); sprintf(c,"%s_%1d%1d_c%d",v,i,j,2); h = (TH1F*)mTFile->Get(c); h->SetLineColor(2); h->Draw("same"); } if(cut==99 && v=="dphi"){ h->SetLineColor(4); sprintf(c,"%s_%1d%1d_c%d",v,i,j,2); h = (TH1F*)mTFile->Get(c); h->SetLineColor(2); h->Draw("same"); } if(bin1>0){ t = new TText(0.1, 0.92,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(1); t->Draw(); if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d_bin%d%d.png",v,cut,i,j);} else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d_bin%d%d.png",v,cut,i,j);} else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d_bin%d%d.png",v,cut,i,j);} else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d_bin%d%d.png",v,cut,i,j);} else {sprintf(c,"plot/dipi0_%d_%s_c%d_bin%d%d.png",run,v,cut,i,j);} printf("Saving %s\n",c); cvs->SaveAs(c); } } } if(bin1<0){ cvs->cd(2); t = new TText(0.0, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(1); t->Draw(); } if(v=="mall"){ t = new TText(0.05, 0.65,"M1(no mass, scaled)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(1); t->Draw(); t = new TText(0.05, 0.55,"M1(without M2)/P"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(6); t->Draw(); t = new TText(0.05, 0.45,"M1(with M2)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw(); t = new TText(0.05, 0.35,"M2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw(); } if(v=="z12"){ t = new TText(0.05, 0.65,"Zgg1"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw(); t = new TText(0.05, 0.55,"Zgg2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw(); } if(cut==99) { t = new TText(0.0, 0.65, "Inclusive Pair"); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(4); t->Draw(); t = new TText(0.0, 0.45, "Exclusive Pair"); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(2); t->Draw(); } if(bin1<0){ if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d.png",v,cut);} else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d.png",v,cut);} else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d.png",v,cut);} else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d.png",v,cut);} else {sprintf(c,"plot/dipi0_%d_%s_c%d.png",run,v,cut);} printf("Saving %s\n",c); cvs->SaveAs(c); } }
void paulFit(TDirectory *mDir,TH1F* fMFitS,TH1F* hMFitS,TH2F* hFCovar, bool makePlots, string type){ std::string label[global_nMaxMassBins]={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14"}; TH1F *hMRaw[global_nMaxMassBins],*hMFit[global_nMaxMassBins]; TGraphErrors *hBRaw[global_nMaxBdtBins],*hBFit[global_nMaxBdtBins]; TH1F *fMRaw[global_nMaxMassBins],*fMFit[global_nMaxMassBins]; TGraphErrors *fBRaw[global_nMaxBdtBins],*fBFit[global_nMaxBdtBins]; TH2F *hFCorr; TH1F *fBPar,*fBErr; for(int i(0);i<global_nMassBins;i++) { hMRaw[i]=new TH1F((std::string("hMass")+label[i]+"Raw").c_str(), (std::string("Events Mass range ")+label[i]+" Raw ").c_str(), global_nBdtBins,0.0,global_nBdtBins); hMFit[i]=new TH1F((std::string("hMass")+label[i]+"Fit").c_str(), (std::string("Events Mass range ")+label[i]+" Fit ").c_str(), global_nBdtBins,0.0,global_nBdtBins); fMRaw[i]=new TH1F((std::string("fMass")+label[i]+"Raw").c_str(), (std::string("Fractions Mass range ")+label[i]+" Raw ").c_str(), global_nBdtBins,0.0,global_nBdtBins); fMFit[i]=new TH1F((std::string("fMass")+label[i]+"Fit").c_str(), (std::string("Fractions Mass range ")+label[i]+" Fit ").c_str(), global_nBdtBins,0.0,global_nBdtBins); for(int j(0);j<global_nBdtBins;j++) { hMRaw[i]->SetBinContent(j+1,global_parameters.fData[i][j]); hMRaw[i]->SetBinError(j+1,sqrt(global_parameters.fData[i][j])); fMRaw[i]->SetBinContent(j+1,double(global_parameters.fData[i][j])/global_parameters.nrm[i]); fMRaw[i]->SetBinError(j+1,sqrt(global_parameters.fData[i][j])/global_parameters.nrm[i]); } } for(int j(0);j<global_nBdtBins;j++) { hBRaw[j]=new TGraphErrors((std::string("hBDT")+label[j]+"Raw").c_str(), (std::string("Events BDT bin ")+label[j]+" Raw ").c_str()); hBRaw[j]->SetName((std::string("hBDT")+label[j]+"Raw").c_str()); hBFit[j]=new TGraphErrors((std::string("hBDT")+label[j]+"Fit").c_str(), (std::string("Events BDT bin ")+label[j]+" Fit ").c_str()); hBFit[j]->SetName((std::string("hBDT")+label[j]+"Fit").c_str()); fBRaw[j]=new TGraphErrors((std::string("fBDT")+label[j]+"Raw").c_str(), (std::string("Fractions BDT bin ")+label[j]+" Raw ").c_str()); fBRaw[j]->SetName((std::string("fBDT")+label[j]+"Raw").c_str()); fBFit[j]=new TGraphErrors((std::string("fBDT")+label[j]+"Fit").c_str(), (std::string("Fractions BDT bin ")+label[j]+" Fit ").c_str()); fBFit[j]->SetName((std::string("fBDT")+label[j]+"Fit").c_str()); for(int i(0);i<global_nMassBins;i++) { double xERR = global_parameters.fMass[i]*global_SIDEBANDWIDTH; hBRaw[j]->SetPoint(i,global_parameters.fMass[i],global_parameters.fData[i][j]); hBRaw[j]->SetPointError(i,xERR,sqrt(global_parameters.fData[i][j])); fBRaw[j]->SetPoint(i,global_parameters.fMass[i],double(global_parameters.fData[i][j])/global_parameters.nrm[i]); fBRaw[j]->SetPointError(i,xERR,sqrt(global_parameters.fData[i][j])/global_parameters.nrm[i]); } } hFCorr=new TH2F((std::string("fCorr")).c_str(), Form("Fraction correlation matrix m %3.1f",global_mH), global_nBdtBins,0.0,global_nBdtBins,global_nBdtBins,0.0,global_nBdtBins); fBPar=new TH1F((std::string("fBPar")).c_str(), (std::string("Relative fit slope ")).c_str(), global_nBdtBins,0.0,global_nBdtBins); fBErr=new TH1F((std::string("fBErr")).c_str(), (std::string("Fraction error ")).c_str(), global_nBdtBins,0.0,global_nBdtBins); // Function taken directly from P. Dauncey to Perform Fits TMinuit tMinuit(maxPar); tMinuit.mninit(5,6,7); tMinuit.SetFCN(fcnFit); int ell[5]={0,0,0,0,0}; static Double_t p0=0; static Double_t p1=1; static Double_t p3=3; static Double_t p5=5; for(int i(1);i<global_nMaxBdtBins;i++) { tMinuit.DefineParameter(2*i-2,(std::string("Par")+label[i]+"0").c_str(), global_parameters.npb[i]/global_parameters.ntot,global_parameters.npb[i]==0?1.0/global_parameters.ntot:sqrt(global_parameters.npb[i])/global_parameters.ntot,0.0,0.0); tMinuit.DefineParameter(2*i-1,(std::string("Par")+label[i]+"1").c_str(), 0.0,0.0001,0.0,0.0); if(i>=global_nBdtBins) { tMinuit.FixParameter(2*i-2); tMinuit.FixParameter(2*i-1); } } for(int i(0);i<global_nMaxMassBins;i++) { tMinuit.DefineParameter(i+2*(global_nMaxBdtBins-1),(std::string("Nrm")+label[i]).c_str(), global_parameters.nrm[i],sqrt(global_parameters.nrm[i]),0.0,0.0); if(i>global_nMassBins-1) tMinuit.FixParameter(i+2*(global_nMaxBdtBins-1)); } tMinuit.mnexcm("CALL FCN", &p1 ,1,ell[0]); tMinuit.mnexcm("SCAN" , &p1 ,0,ell[1]); ell[3]=tMinuit.Migrad(); if(ell[3]!=0) std::cout << "WARNING MINUIT ERROR FLAG = " << ell[3] << std::endl; /* for(int i(1);i<nPar[fitFcn];i+=2) { tMinuit.Release(i); tMinuit.Release(i+1); tMinuit.mnexcm("SCAN" , &p1 ,0,ell[1]); ell[3]=tMinuit.Migrad(); } */ tMinuit.mnexcm("CALL FCN", &p5 ,1,ell[4]); for(int i(0);i<maxPar;i++) { tMinuit.GetParameter(i,global_parameters.parAll[i],global_parameters.errAll[i]); std::cout << "AFTER MINUIT PAR " << i << " = " << global_parameters.parAll[i] << " +/- " << global_parameters.errAll[i] << std::endl; } tMinuit.mnemat(&(global_parameters.errMat[0][0]),maxPar); // for(int i(0);i<2*(global_nBdtBins-1)+nMassBins;i++) { // std::cout << "AFTER MNEMAT ERR2 " << i << " = " // << global_parameters.errMat[i][i] << ", ERR " << sqrt(global_parameters.errMat[i][i]) << std::endl; // } // std::cout << "ERRMAT" << std::endl; // for(int i(0);i<nBdtBins-1;i++) { // for(int j(0);j<nBdtBins-1;j++) { // std::cout << std::setw(14) << global_parameters.errMat[2*i][2*j]; // } // std::cout << std::endl; // } std::cout << "DQ/DP" << std::endl; double dqdp[global_nBdtBins-1][global_nBdtBins]; for(int i(0);i<global_nBdtBins-1;i++) { for(int j(0);j<global_nBdtBins;j++) { if(j==0) dqdp[i][j]=-1.0; else { if(i+1==j) dqdp[i][j]=1.0; else dqdp[i][j]=0.0; } std::cout << std::setw(14) << dqdp[i][j]; } std::cout << std::endl; } std::cout << "FRACERR" << std::endl; double fracErr[global_nBdtBins][global_nBdtBins]; for(int i(0);i<global_nBdtBins;i++) { for(int j(0);j<global_nBdtBins;j++) { fracErr[i][j]=0.0; for(int k(0);k<global_nBdtBins-1;k++) { for(int l(0);l<global_nBdtBins-1;l++) { fracErr[i][j]+=dqdp[k][i]*global_parameters.errMat[2*k][2*l]*dqdp[l][j]; } } //std::cout << std::setw(14) << fracErr[i][j]; } std::cout << std::endl; } // Add Global Error to error matrix -> Motivated from Bias studies of fits: for(int i(0);i<global_nBdtBins;i++) { for(int j(0);j<global_nBdtBins;j++) { fracErr[i][j]*=(1.+global_SYSTEMATICBIAS)*(1.+global_SYSTEMATICBIAS); std::cout << std::setw(14) << fracErr[i][j]; } std::cout << std::endl; } std::cout << "FRACCOR" << std::endl; double fracCor[global_nBdtBins][global_nBdtBins]; for(int i(0);i<global_nBdtBins;i++) { for(int j(0);j<global_nBdtBins;j++) { // Turns Error Matrix into Correlation Matrix fracCor[i][j]=fracErr[i][j]/sqrt(fracErr[i][i]*fracErr[j][j]); // Covariance Matrix //std::cout << std::setw(14) << fracCor[i][j]; hFCovar->SetBinContent(i+1,j+1,fracErr[i][j]); hFCorr->SetBinContent(i+1,j+1,fracCor[i][j]); } std::cout << std::endl; } for(int i(0);i<global_nBdtBins;i++) { std::cout << "AFTER DQ/DP ERR2 " << i << " = " << fracErr[i][i] << ", ERR " << sqrt(fracErr[i][i]) << std::endl; } for(int j(0);j<global_nBdtBins;j++) { fBErr->SetBinContent(j+1,sqrt(fracErr[j][j])); } double p00(1.0); double p01(0.0); // Extract fractions/yields for each mass and for each BDT bin for(int i(0);i<global_nMassBins;i++) { for(int j(1);j<global_nBdtBins;j++) { hMFit[i]->SetBinContent(j+1,global_parameters.parAll[i+2*(global_nMaxBdtBins-1)]*(global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH))); fMFit[i]->SetBinContent(j+1, global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH) ); // hBFit[j]->SetBinContent(i+1,global_parameters.parAll[i+2*(global_nMaxBdtBins-1)]*(global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH))); // fBFit[j]->SetBinContent(i+1, global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH) ); fBFit[j]->SetPoint(i,global_parameters.fMass[i],global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH)); hBFit[j]->SetPoint(i,global_parameters.fMass[i],global_parameters.parAll[i+2*(global_nMaxBdtBins-1)]*(global_parameters.parAll[2*j-2]+global_parameters.parAll[2*j-1]*(global_parameters.fMass[i]-global_mH))); if(i==0) { p00-=global_parameters.parAll[2*j-2]; p01-=global_parameters.parAll[2*j-1]; } } hMFit[i]->SetBinContent( 1,global_parameters.parAll[i+2*(global_nMaxBdtBins-1)]*(p00+p01*(global_parameters.fMass[i]-global_mH))); fMFit[i]->SetBinContent( 1, p00+p01*(global_parameters.fMass[i]-global_mH) ); hBFit[0]->SetPoint(i,global_parameters.fMass[i],global_parameters.parAll[i+2*(global_nMaxBdtBins-1)]*(p00+p01*(global_parameters.fMass[i]-global_mH))); fBFit[0]->SetPoint(i,global_parameters.fMass[i],p00+p01*(global_parameters.fMass[i]-global_mH) ); } double pS00(1.0); // We are interested in the BDT bins in the signal region, so need those histograms ie setting mH=m0 for(int j(1);j<global_nBdtBins;j++) { float binSFrac = global_parameters.parAll[2*(j-1)]; fMFitS->SetBinContent(j+1,binSFrac); fMFitS->SetBinError(j+1,fBErr->GetBinContent(j+1)); hMFitS->SetBinContent(j+1,binSFrac*global_nSignalRegion); hMFitS->SetBinError(j+1,global_nSignalRegion*fBErr->GetBinContent(j+1)); pS00-=binSFrac; } fMFitS->SetBinContent(1,pS00); fMFitS->SetBinError(1,fBErr->GetBinContent(1)); hMFitS->SetBinContent(1,pS00*global_nSignalRegion); hMFitS->SetBinError(1,global_nSignalRegion*fBErr->GetBinContent(1)); fBPar->SetBinContent(1,p01/p00); fBPar->SetBinError(1,0.0); for(int j(1);j<global_nBdtBins;j++) { fBPar->SetBinContent(j+1,global_parameters.parAll[2*j-1]/global_parameters.parAll[2*j-2]); fBPar->SetBinError(j+1,(global_parameters.parAll[2*j-1]/global_parameters.parAll[2*j-2])*sqrt((global_parameters.errAll[2*j-1]*global_parameters.errAll[2*j-1]/(global_parameters.parAll[2*j-1]*global_parameters.parAll[2*j-1]))+(global_parameters.errAll[2*j-2]*global_parameters.errAll[2*j-2]/(global_parameters.parAll[2*j-2]*global_parameters.parAll[2*j-2])))); } // Write out the histos mDir->cd(); for(int i(0);i<global_nMassBins;i++) { hMRaw[i]->Write(); hMFit[i]->Write(); fMRaw[i]->Write(); fMFit[i]->Write(); } for(int j(0);j<global_nBdtBins;j++) { hBRaw[j]->Write(); hBFit[j]->Write(); fBRaw[j]->Write(); fBFit[j]->Write(); } // Make a plot of the points Fitted and the fitted graph gROOT->SetBatch(true); gROOT->SetStyle("Plain"); for(int j(0);j<global_nBdtBins;j++) { TCanvas *can = new TCanvas(Form("Fit_BDT%d",j),"c1",305,95,800,550); // can->SetName(Form("Fit_BDT%d",j)); can->SetBottomMargin(0.12); can->SetGrid(); fBFit[j]->SetLineColor(4); fBFit[j]->SetLineWidth(3); fBRaw[j]->SetMarkerStyle(20); fBRaw[j]->SetMarkerSize(1.0); fBRaw[j]->GetXaxis()->SetTitle("m_{H} (GeV)"); fBRaw[j]->GetXaxis()->SetTitleSize(0.055); fBRaw[j]->GetXaxis()->SetLabelSize(0.045); fBRaw[j]->GetYaxis()->SetTitle(Form("Fraction in bin %d",j+1)); fBRaw[j]->GetYaxis()->SetTitleSize(0.05); fBRaw[j]->GetYaxis()->SetLabelSize(0.045); fBRaw[j]->GetYaxis()->SetNdivisions(508); //fBRaw[j]->SetTitle(Form("Fit BDT Mass %3.1f Bin %d",global_mH,j)); double FVal = fBFit[j]->Eval(global_mH); fBRaw[j]->GetYaxis()->SetRangeUser(floor(FVal*0.75*100)/100,floor(FVal*1.25*100)/100); TLine l(global_mH,floor(FVal*0.75*100)/100,global_mH,floor(FVal*1.25*100)/100); l.SetLineColor(46); l.SetLineStyle(7); l.SetLineWidth(3); fBRaw[j]->SetTitle(""); fBRaw[j]->Draw("AP"); fBFit[j]->Draw("L"); fBRaw[j]->Draw("sameP"); l.Draw(); TText *text = new TText(0.6,0.8,"CMS Preliminary"); text->SetNDC(); text->Draw(); text->SetTextSize(0.05); can->Write(); if (makePlots){ can->Print(Form("BMplots/%s/fit_m%3.1f_bin%d.png",type.c_str(),global_mH,j)); can->Print(Form("BMplots/%s/fit_m%3.1f_bin%d.pdf",type.c_str(),global_mH,j)); } } fMFitS->Write(); hMFitS->Write(); hFCorr->Write(); hFCovar->Write(); fBPar->Write(); fBErr->Write(); if (makePlots){ TCanvas *canv = new TCanvas(); gStyle->SetOptStat(0); gPad->SetRightMargin(5.); hFCorr->SetMarkerColor(kGray+2); hFCorr->Draw("colz text"); canv->Print(Form("BMplots/%s/fCorr_m%3.1f.png",type.c_str(),global_mH)); canv->Print(Form("BMplots/%s/fCorr_m%3.1f.pdf",type.c_str(),global_mH)); hFCovar->SetMarkerColor(kGray+2); hFCovar->Draw("colz text"); canv->Print(Form("BMplots/%s/fCovar_m%3.1f.png",type.c_str(),global_mH)); canv->Print(Form("BMplots/%s/fCovar_m%3.1f.pdf",type.c_str(),global_mH)); } }
void compareplots(){ vector<TFile*> files; files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbar2JetLO8TeVMECut50GeVCTEQ6M-extracted.root")); files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbarMergedMS100GeVMCCut50GeV8TeVCTEQ6M-extracted.root")); vector<TString> names; names.push_back("ttbar+2 Jets, in LO"); names.push_back("ttbar+1 Jet, FxFx-Merged"); vector<TString> titles; titles.push_back("Gen-Jet p_{T} with pos weights (GeV)"); titles.push_back("Gen-Jet p_{T} with neg weights (GeV)"); titles.push_back("Gen-Jet p_{T} (GeV)"); titles.push_back("Gen_Jet #phi with pos. weights"); titles.push_back("Gen_Jet #phi with neg. weights"); titles.push_back("Gen_Jet #phi"); titles.push_back("Gen Jet #theta with pos weights"); titles.push_back("Gen Jet #theta with neg weights"); titles.push_back("Gen Jet #theta"); titles.push_back("Gen Jet Energy with pos weights (GeV) "); titles.push_back("Gen Jet Energy with neg weights (GeV)"); titles.push_back("Gen Jet Energy (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet with pos weights (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet with neg weights (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet with pos weights (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet with neg weights (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet (GeV)"); titles.push_back("#eta of hardest Gen-Jets with pos weights"); titles.push_back("#eta of hardest Gen-Jets with neg weights"); titles.push_back("#eta of hardest Gen-Jets"); titles.push_back("Number of Gen-Jets with pos. weights"); titles.push_back("Number of Gen-Jets with neg. weights"); titles.push_back("Number of Gen-Jets"); TFile *vergleich = new TFile("vergleich_ttbar_Fx_vs_noFx.root","RECREATE"); // Show no statistics box gStyle->SetOptStat(0); TH1::SetDefaultSumw2(); // Main program part TIter nextkey(files.at(0)->GetListOfKeys()); TKey *key; bool first=true; TCanvas* c = new TCanvas(); c->Print("plots.pdf["); // Save also as pictures int pictureNumber = 0; int run = 0; while (key = (TKey*)nextkey()) { pictureNumber++; TString pictureName = TString::Format("%d.png",pictureNumber); vector<TH1F*> histos; histos.push_back((TH1F*)key->ReadObj()); for(size_t i=1;i<files.size();i++){ histos.push_back((TH1F*)files.at(i)->Get(histos.at(0)->GetName())); } for(size_t i=0;i<histos.size();i++){ if(i == 0){ histos.at(i)->SetLineColor(kBlack); } if(i == 1){ histos.at(i)->SetLineColor(kRed); } if(i == 2){ histos.at(i)->SetLineColor(kBlue); } if(i == 3){ histos.at(i)->SetLineColor(kGreen+2); } if(i == 4){ histos.at(i)->SetLineColor(kMagenta-7); } if(i == 5){ histos.at(i)->SetLineColor(kOrange+7); } } for(size_t i=0;i<histos.size();i++){ histos.at(i)->Sumw2(); histos.at(i)->Scale(1./histos.at(i)->Integral(),"width"); } // Set axis title histos.at(0)->GetYaxis()->SetTitle("Normalized units"); std::string const histogramName = histos.at(0)->GetName(); histos.at(0)->GetXaxis()->SetLabelSize(0.06); histos.at(0)->GetXaxis()->SetLabelOffset(0.006); histos.at(0)->GetYaxis()->SetLabelSize(0.06); histos.at(0)->GetYaxis()->SetLabelOffset(0.006); histos.at(0)->GetXaxis()->SetTitleSize(0.06); histos.at(0)->GetXaxis()->SetTitleOffset(1.1); histos.at(0)->GetYaxis()->SetTitleSize(0.06); histos.at(0)->GetYaxis()->SetTitleOffset(1.08); histos.at(0)->GetXaxis()->SetTitle(titles.at(run)); run = run+1; if(run == (3*8)){ run = 0; } // If only two histograms per plot make a ratio plot if(histos.size() == 2) { //create main pad TPad *mainPad = new TPad("","",0.0,0.3,1.0,1.0); mainPad->SetNumber(1); mainPad->SetBottomMargin(0.0); mainPad->SetRightMargin(0.04); mainPad->SetLeftMargin(0.13); mainPad->Draw(); //create ratio pad TPad *ratioPad = new TPad("","",0.0,0.0,1.0,0.3); ratioPad->SetTopMargin(0.0); ratioPad->SetBottomMargin(0.4); ratioPad->SetLeftMargin(0.13); ratioPad->SetRightMargin(0.04); gStyle->SetOptTitle(0); ratioPad->SetFillColor(0); ratioPad->SetNumber(2); ratioPad->SetGridy(); ratioPad->Draw(); // Draw both histograms first c->cd(1); histos.at(0)->Draw("histo E"); histos.at(1)->Draw("histo same E"); // Show legend and statistical tests in first pad for(size_t i=0;i<histos.size()-1;i=i+2){ double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1)); ksresult=floor(ksresult*1000+0.5)/1000; double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW"); chi2result=floor(chi2result*1000+0.5)/1000; stringstream ss; ss << " KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result << " Private Work"; const char * ch = & ss.str().c_str();; TLatex * ks = new TLatex(0.1, 0.9-0.03*i, ch ); ks->SetTextColor(histos.at(i)->GetLineColor()); ks->SetNDC(); ks->Draw(""); } TLegend* l = new TLegend(0.55,0.9,0.69,0.99); // Options for legend l->SetBorderSize(0); l->SetLineStyle(0); l->SetTextSize(0.049); l->SetFillStyle(0); for(size_t i=0;i<names.size();i++){ l->AddEntry(histos.at(i),names.at(i),"L"); } l->Draw("same"); // Clone histograms and draw ratio plot c->cd(2); TH1F* ratioHisto = (TH1F*)histos.at(0)->Clone(); ratioHisto->Divide(histos.at(1)); ratioHisto->SetLineColor(kBlue); ratioHisto->SetStats(false); ratioHisto->GetYaxis()->SetTitle("Ratio #frac{noFxFx}{FxFx}"); // Same Size like in histogram ratioHisto->SetLabelSize(histos.at(0)->GetLabelSize() * 0.7 / 0.3); ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("Y") * 0.3 / 0.7), "Y"); ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("Y") * 0.7 / 0.3), "Y"); ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("X")), "X"); ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("X") * 0.7 / 0.3), "X"); // Use nicer range ratioHisto->GetYaxis()->SetRangeUser(0, 2.2); ratioHisto->GetYaxis()->SetNdivisions(503); ratioHisto->GetYaxis()->SetLabelSize(0.06 * 0.7 / 0.3); ratioHisto->Draw(); } else { histos.at(0)->Draw("histo E"); for(size_t i=0;i<histos.size();i++){ histos.at(i)->Draw("histo same E"); } for(size_t i=0;i<histos.size()-1;i=i+2){ double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1)); ksresult=floor(ksresult*1000+0.5)/1000; double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW"); chi2result=floor(chi2result*1000+0.5)/1000; stringstream ss; ss << "KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result; const char * ch = & ss.str().c_str();; TText * ks = new TText(0.1, 0.9-0.03*i, ch ); ks->SetTextColor(histos.at(i)->GetLineColor()); ks->SetNDC(); ks->Draw(""); } TLegend* l = new TLegend(0.65,0.5,0.9,0.7); l->SetBorderSize(0); l->SetLineStyle(0); // l->SetTextSize(0.039); l->SetFillStyle(0); for(size_t i=0;i<names.size();i++){ l->AddEntry(histos.at(i),names.at(i),"L"); } l->Draw("same"); } c->Print("plots.pdf"); c->SaveAs(pictureName); vergleich->WriteTObject(c); } c->Print("plots.pdf]"); }
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance,const char* system) { if (rPerformance){ TLatex *alice = new TLatex(0.22,0.57,"Pb-Pb #sqrt{s_{NN}} = 2.76 TeV"); alice->SetNDC(); alice->SetTextColor(myDarkRed); // alice->SetTextFont(42); alice->SetTextSize(0.05); alice->SetLineWidth(2); alice->Draw(); TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2"); alice2->SetNDC(); alice2->SetTextColor(myDarkRed); // alice->SetTextFont(42); alice2->SetTextSize(0.05); alice2->SetLineWidth(2); // alice2->Draw(); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TText *date = new TText(0.67,0.48,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); // //Acquire canvas proportions // Double_t AliLogo_LowX = 0.67; // Double_t AliLogo_LowY = 0.53; // Double_t AliLogo_Height = 0.22; // //ALICE logo is a png file that is 821x798 pixels->should be wider than a square // Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); // TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! // myPadSetUp(myPadLogo,0,0,0,0); // //myPadLogo->SetFixedAspectRatio(1); // myPadLogo->Draw(); // myPadLogo->cd(); // // TASImage *myAliceLogo = new TASImage("alice_performance.png"); // TASImage *myAliceLogo = new TASImage("alice_performance.eps"); // // TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); // myAliceLogo->Draw(); DrawALICELogo(0,0.65,0.52,0.8,0.8); } if (rWrite == 1){ c2->SaveAs(Form("%s_%s.png",name,system)); //} //if (rWrite == 2) c2->SaveAs(Form("%s.eps",name)); } }
// infilename - root file with relevant histograms // system - PP,APAP,PP // status - Pass,Fail // rWrite - 0-no,1-png,2-eps // rPerformance - 0-no,1-yes (ALICE logo etc.) // bin: 0 - all, 1- 0:5, 2- 5:10, etc void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange) { myOptions(0); gROOT->ForceStyle(); gStyle->SetPalette(1.0); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TFile *f = new TFile(infilename, "read"); // DCA xy TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0)); if (!bin) { int minMultBin = 0; int maxMultBin = 6; // 8 } else { int minMultBin = bin-1; int maxMultBin = bin; // 8 } // int minMultBin = 0; // int maxMultBin = 0; // 8 double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i)); DCAxy->Add(DCAxyN); cout<<i<<" "<<DCAxyN->GetEntries()<<endl; //delete hEvMult; } if (!isMC) { TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim"); c2->SetGridx(); c2->SetGridy(); c2->SetFillColor(10); c2->SetRightMargin(1.9); c2->SetLogz(); DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)"); DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0); DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); // DCAxy->GetZaxis()->SetLabelSize(0.05); DCAxy->Draw("colz"); postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system); // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X"); // c4->SetGridx(); // c4->SetGridy(); // c4->SetFillColor(10); // c4->SetRightMargin(1.9); // c4->SetLogy(); gStyle->SetOptTitle(1); TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400); myCan->Draw(); myCan->cd(); TPad *myPad = new TPad("myPad", "The pad",0,0,1,1); myPadSetUp(myPad,0.15,0.04,0.04,0.15); myPad->Draw(); myPad->SetLogy(); myPad->cd(); if (ptrange == 0) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100); pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}"); } else if (ptrange == 1) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33); pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}"); } else if (ptrange == 2) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100); pripp->SetTitle("1 < #it{p}_{T} < 3 GeV/#it{c}"); } pripp->SetYTitle("Number of Entries (normalized)"); pripp->GetXaxis()->SetTitleSize(0.068); pripp->GetYaxis()->SetTitleSize(0.068); pripp->GetXaxis()->SetLabelSize(0.058); pripp->GetYaxis()->SetLabelSize(0.058); // pripp->SetLabelSize(0.05); // DCAxy->ProjectionX("asd",50,100)->SetYTitle("Number of Entries"); // DCAxy->ProjectionX("asd",50,100)->SetTitle("1.0 < p_{T} < 2.0 GeV"); // DCAxy->ProjectionX("asd",0,200)->SetTitle(""); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetNdivisions(8); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetNdivisions(8); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetTitleSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetTitleSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetLabelSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetLabelSize(0.05); pripp->Draw(""); //if (!isMC) { pripp->Scale(1./pripp->Integral()); TFile* fout = new TFile("dca.root","update"); pripp->SetName(Form("dcaxyMC%d",isMC)); pripp->Write(); //} postprocess(myCan,Form("DCAxy%sProX",status),rWrite,rPerformance,system); } else if (isMC) { TH2D* primp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dprim","Pass", system,0)); TH2D* weakp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dweak","Pass", system,0)); TH2D* matp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dmat","Pass", system,0)); // prim 2D TCanvas *c3prim = new TCanvas("DCA xy primary", "DCA xy primary"); c3prim->SetGridx(); c3prim->SetGridy(); c3prim->SetFillColor(10); c3prim->SetRightMargin(1.9); c3prim->SetLogz(); primp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); primp->GetXaxis()->SetRangeUser(-5.0,5.0); primp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); primp->GetZaxis()->SetLabelSize(0.03); primp->Draw("colz"); postprocess(c3prim,Form("DCAxy%s",status),rWrite,rPerformance,system); // weak 2D TCanvas *c3 = new TCanvas("DCA xy weak", "DCA xy weak"); c3->SetGridx(); c3->SetGridy(); c3->SetFillColor(10); c3->SetRightMargin(1.9); c3->SetLogz(); weakp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); weakp->GetXaxis()->SetRangeUser(-5.0,5.0); weakp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); weakp->GetZaxis()->SetLabelSize(0.03); weakp->Draw("colz"); postprocess(c3,Form("DCAxy%s",status),rWrite,rPerformance,system); // mat 2D TCanvas *c4 = new TCanvas("DCA xy mat", "DCA xy mat"); c4->SetGridx(); c4->SetGridy(); c4->SetFillColor(10); c4->SetRightMargin(1.9); c4->SetLogz(); matp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); matp->GetXaxis()->SetRangeUser(-5.0,5.0); matp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); matp->GetZaxis()->SetLabelSize(0.03); matp->Draw("colz"); postprocess(c4,Form("DCAxy%s",status),rWrite,rPerformance,system); // prim proj gStyle->SetOptTitle(1); TCanvas *myCan3prim = new TCanvas("myCan3prim",cStamp1); myCan3prim->Draw(); myCan3prim->cd(); TPad *myPad3prim = new TPad("myPad3prim", "The pad3prim",0,0,1,1); myPadSetUp(myPad3prim,0.15,0.04,0.04,0.15); myPad3prim->Draw(); myPad3prim->SetLogy(); myPad3prim->cd(); TH1D* primpp = (TH1D*)primp->ProjectionX("zxc22",0,100); primpp->Draw(""); cout << primpp->FindBin(-0.1) << endl; cout << primpp->FindBin(0.1) << endl; cout << "primary in cut- " << primpp->Integral(191,211) << endl; cout << "primary all- " << primpp->Integral(1,400) << endl; postprocess(myCan3prim,Form("DCAxy%sProX",status),rWrite,rPerformance,system); // weak proj TCanvas *myCan3 = new TCanvas("myCan3",cStamp1); myCan3->Draw(); myCan3->cd(); TPad *myPad3 = new TPad("myPad3", "The pad3",0,0,1,1); myPadSetUp(myPad3,0.15,0.04,0.04,0.15); myPad3->Draw(); myPad3->SetLogy(); myPad3->cd(); TH1D* weakpp = (TH1D*)weakp->ProjectionX("zxc2",0,100); weakpp->Draw(""); cout << "weak in cut- " << weakpp->Integral(191,211) << endl; cout << "weak all- " << weakpp->Integral(1,400) << endl; postprocess(myCan3,Form("DCAxy%sProX",status),rWrite,rPerformance,system); // mat proj gStyle->SetOptTitle(1); TCanvas *myCan4 = new TCanvas("myCan4",cStamp1); myCan4->Draw(); myCan4->cd(); TPad *myPad4 = new TPad("myPad4", "The pad4",0,0,1,1); myPadSetUp(myPad4,0.15,0.04,0.04,0.15); myPad4->Draw(); myPad4->SetLogy(); myPad4->cd(); TH1D* matpp = (TH1D*)matp->ProjectionX("zxc3",0,100); matpp->Draw(""); cout << "material in cut- " << matpp->Integral(191,211) << endl; cout << "material all- " << matpp->Integral(1,400) << endl; postprocess(myCan4,Form("DCAxy%sProX",status),rWrite,rPerformance,system); cout << "in cut: " << endl; cout << "prim - " << primpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << "weak - " << weakpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << "mat - " << matpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << endl << "in cut / all " << endl; cout << "prim - " << primpp->Integral(191,211) / primpp->Integral(1,400) << endl; cout << "weak - " << weakpp->Integral(191,211) / weakpp->Integral(1,400) << endl; cout << "mat - " << matpp->Integral(191,211) / matpp->Integral(1,400) << endl; // _____sum____ TH2D* psum = new TH2D("psum","",400, -2.0, 2.0, 100,0.0,2.0); psum->GetXaxis()->SetTitle("DCA_{xy} (cm)"); psum->GetYaxis()->SetTitle("Number of Entries (normalized)"); psum->GetXaxis()->SetLimits(-2,2); for (int i = 0; i < primp->GetNbinsX(); i++) { for (int j = 0; j < primp->GetNbinsY(); j++) { psum->SetBinContent(i,j,primp->GetBinContent(i,j)+weakp->GetBinContent(i,j)+matp->GetBinContent(i,j)); } } gStyle->SetOptStat(0); TCanvas *cansum = new TCanvas("cansum",cStamp1,600,400); cansum->Draw(); cansum->cd(); TPad *padsum = new TPad("padsum", "The pad4",0,0,1,1); myPadSetUp(padsum,0.15,0.04,0.04,0.15); padsum->Draw(); padsum->SetLogy(); padsum->cd(); // TCanvas* cansum = new TCanvas("cansum","cansum"); // cansum->SetLogy(); //psum->Draw("colz"); TH1D* asd0 = (TH1D*)psum->ProjectionX("zxc",0,100); // asd0->Scale(1./asd0->Integral()); // TFile* fout = new TFile("dca.root","update"); // asd0->SetName(Form("dcaxyMC%d",isMC)); // asd0->Write(); asd0->GetXaxis()->SetTitle("DCA_{xy} (cm)"); asd0->GetYaxis()->SetTitle("Number of Entries (normalized)"); //asd0->SetMaximum(5000); //asd0->SetMinimum(0.00008); asd0->GetXaxis()->SetNdivisions(8); asd0->GetYaxis()->SetNdivisions(8); //asd0->GetYaxis()->SetTitleOffset(1.4); asd0->GetXaxis()->SetTitleSize(0.068); asd0->GetYaxis()->SetTitleSize(0.068); asd0->GetXaxis()->SetLabelSize(0.058); asd0->GetYaxis()->SetLabelSize(0.058); asd0->SetFillColor(kBlack); Double_t norm = asd0->Integral(); //asd0->Scale(1./norm); //asd0->SetMinimum(0.00007); asd0->SetMarkerSize(1.3); asd0->SetMarkerColor(kBlack); asd0->SetMarkerStyle(20); asd0->Draw("pc"); primpp->SetFillColor(kGreen+2); //primpp->Scale(1./norm); primpp->SetMarkerSize(1.3); primpp->SetMarkerColor(kGreen+2); primpp->SetMarkerStyle(20); primpp->Draw("psame"); matpp->SetFillColor(kRed); //matpp->Scale(1./norm); matpp->SetMarkerSize(1.3); matpp->SetMarkerColor(kRed); matpp->SetMarkerStyle(20); matpp->Draw("psame"); weakpp->SetFillColor(kBlue); //weakpp->Scale(1./norm); weakpp->SetMarkerSize(1.3); weakpp->SetMarkerColor(kBlue); weakpp->SetMarkerStyle(20); weakpp->Draw("psame"); // _____endofsum____ TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89); myLegend->SetFillColor(10); myLegend->SetBorderSize(0); myLegend->AddEntry(asd0,"all","f"); myLegend->AddEntry(primpp,"primary","f"); myLegend->AddEntry(weakpp,"weak decay","f"); myLegend->AddEntry(matpp,"material","f"); //myLegend->Draw("same"); // logo TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV"); sys->SetNDC(); sys->SetTextFont(42); sys->SetTextSize(0.05); sys->SetTextColor(kRed+2); sys->Draw(); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TText *date = new TText(0.27,0.5,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); // //Acquire canvas proportions // Double_t AliLogo_LowX = 0.27; // Double_t AliLogo_LowY = 0.6; // Double_t AliLogo_Height = 0.22; // //ALICE logo is a png file that is 821x798 pixels->should be wider than a square // Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); // TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! // myPadSetUp(myPadLogo,0,0,0,0); // myPadLogo->SetFixedAspectRatio(1); // myPadLogo->Draw(); // myPadLogo->cd(); // // TASImage *myAliceLogo = new TASImage("alice_preliminary.eps"); // TASImage *myAliceLogo = new TASImage("alice_performance.eps"); // // TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); // myAliceLogo->Draw(); DrawALICELogo(0,0.27,0.55,0.7,0.8); //logo // postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system); cansum->SaveAs("DCAxyMC.png"); cansum->SaveAs("DCAxyMC.eps"); } //__________________________________________________ }
void categories_sig() { gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetCanvasColor(0); gStyle->SetFrameBorderMode(0); gStyle->SetPalette(1); TText *text = new TText(); text->SetNDC(); text->SetTextSize(0.05); TFile *file = TFile::Open("histograms_CMS-HGG_categories_sig.root"); file->cd(); TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output"); bdtout_all_tot = (TH1*)bdtout_cat0_tot->Clone(); bdtout_all_tot->Add(bdtout_cat1_tot); bdtout_all_tot->Add(bdtout_cat2_tot); bdtout_all_tot->Add(bdtout_cat3_tot); cout << bdtout_all_tot->Integral() << endl; cout << bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2. << endl; cout << bdtout_all_tot->GetBinLowEdge(49) << endl; cout << bdtout_all_tot->GetBinLowEdge(48) << endl; cout << (bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2.)/bdtout_all_tot->Integral() << endl; bdtout_passCiC_all_tot = (TH1*)bdtout_passCiC_cat0_tot->Clone(); bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat1_tot); bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat2_tot); bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat3_tot); bdtout_failpresel_cat0_tot->Rebin(2); bdtout_failpresel_cat1_tot->Rebin(2); bdtout_failpresel_cat2_tot->Rebin(2); bdtout_failpresel_cat3_tot->Rebin(2); bdtout_failpresel_all_tot = (TH1*)bdtout_failpresel_cat0_tot->Clone(); bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat1_tot); bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat2_tot); bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat3_tot); float nFail_m100180_bdtout005 = bdtout_all_tot->Integral(1,52) + bdtout_all_tot->GetBinContent(53)/2.; float nFail_m100180 = bdtout_all_tot->Integral(1,100); float frac_bdtout005 = nFail_m100180_bdtout005/nFail_m100180; float frac_bdtout005_err = frac_err(nFail_m100180_bdtout005,nFail_m100180); cout << bdtout_all_tot->Integral(1,52) << " " << bdtout_all_tot->GetBinContent(53)/2. << " " << bdtout_all_tot->Integral(1,100) << " " << bdtout_all_tot->GetBinLowEdge(53) << " " << frac_bdtout005 << " ± " << frac_bdtout005_err << endl; bdtout_all_tot->SetLineColor(1); bdtout_cat0_tot->SetLineColor(2); bdtout_cat1_tot->SetLineColor(3); bdtout_cat2_tot->SetLineColor(4); bdtout_cat3_tot->SetLineColor(6); bdtout_all_tot->SetLineWidth(2); bdtout_cat0_tot->SetLineWidth(2); bdtout_cat1_tot->SetLineWidth(2); bdtout_cat2_tot->SetLineWidth(2); bdtout_cat3_tot->SetLineWidth(2); bdtout_cat0_tot->SetMarkerColor(2); bdtout_cat1_tot->SetMarkerColor(3); bdtout_cat2_tot->SetMarkerColor(4); bdtout_cat3_tot->SetMarkerColor(6); bdtout_all_tot->SetMarkerStyle(20); bdtout_cat0_tot->SetMarkerStyle(20); bdtout_cat1_tot->SetMarkerStyle(20); bdtout_cat2_tot->SetMarkerStyle(20); bdtout_cat3_tot->SetMarkerStyle(20); bdtout_all_tot->SetMarkerSize(0.7); bdtout_cat0_tot->SetMarkerSize(0.7); bdtout_cat1_tot->SetMarkerSize(0.7); bdtout_cat2_tot->SetMarkerSize(0.7); bdtout_cat3_tot->SetMarkerSize(0.7); bdtout_passCiC_all_tot->SetLineColor(1); bdtout_passCiC_cat0_tot->SetLineColor(2); bdtout_passCiC_cat1_tot->SetLineColor(3); bdtout_passCiC_cat2_tot->SetLineColor(4); bdtout_passCiC_cat3_tot->SetLineColor(6); bdtout_passCiC_lowPt_cat0_tot->SetLineColor(2); bdtout_passCiC_lowPt_cat1_tot->SetLineColor(3); bdtout_passCiC_lowPt_cat2_tot->SetLineColor(4); bdtout_passCiC_lowPt_cat3_tot->SetLineColor(6); bdtout_passCiC_highPt_cat0_tot->SetLineColor(2); bdtout_passCiC_highPt_cat1_tot->SetLineColor(3); bdtout_passCiC_highPt_cat2_tot->SetLineColor(4); bdtout_passCiC_highPt_cat3_tot->SetLineColor(6); bdtout_failpresel_all_tot->SetLineColor(1); bdtout_failpresel_cat0_tot->SetLineColor(2); bdtout_failpresel_cat1_tot->SetLineColor(3); bdtout_failpresel_cat2_tot->SetLineColor(4); bdtout_failpresel_cat3_tot->SetLineColor(6); bdtout_all_tot->GetXaxis()->SetTitle("di-photon MVA output"); float boundaries[4] = {-0.05,0.49,0.79,.91}; float max = bdtout_all_tot->GetMaximum(); TBox* box = new TBox(-1.,0.,boundaries[0],max*1.05); box->SetFillColor(38); box->SetFillStyle(3002); bdtout_all_tot->Draw("hist"); box->Draw("hist,same"); bdtout_all_tot->Draw("hist,same"); bdtout_cat0_tot->Draw("hist,same"); bdtout_cat1_tot->Draw("hist,same"); bdtout_cat2_tot->Draw("hist,same"); bdtout_cat3_tot->Draw("hist,same"); TLegend *leg; leg = new TLegend(.14,.6,.46,.87); leg->SetBorderSize(0); leg->SetFillColor(10); leg->SetTextSize(.035); leg->AddEntry(bdtout_all_tot,"All"); leg->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94"); leg->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94"); leg->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94"); leg->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94"); leg->Draw("hist"); TLine* line[4]; for (int i=0; i<4; i++) { line[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05); line[i]->SetLineColor(4); line[i]->SetLineWidth(2); line[i]->SetLineStyle(9); line[i]->Draw("hist"); } gPad->RedrawAxis(); c_bdtout->SaveAs("categories_sig.png"); TCanvas *c_bdtout_passCiC = new TCanvas("c_bdtout_passCiC","BDT output, pass CiC"); bdtout_passCiC_cat0_tot_clone = (TH1*)bdtout_passCiC_cat0_tot->Clone(); bdtout_passCiC_cat1_tot_clone = (TH1*)bdtout_passCiC_cat1_tot->Clone(); bdtout_passCiC_cat2_tot_clone = (TH1*)bdtout_passCiC_cat2_tot->Clone(); bdtout_passCiC_cat3_tot_clone = (TH1*)bdtout_passCiC_cat3_tot->Clone(); bdtout_passCiC_all_tot->SetLineWidth(2); bdtout_passCiC_cat0_tot_clone->SetLineWidth(2); bdtout_passCiC_cat1_tot_clone->SetLineWidth(2); bdtout_passCiC_cat2_tot_clone->SetLineWidth(2); bdtout_passCiC_cat3_tot_clone->SetLineWidth(2); bdtout_passCiC_all_tot->GetXaxis()->SetTitle("di-photon MVA output"); max = bdtout_passCiC_all_tot->GetMaximum(); TBox* box_passCiC = new TBox(-1.,0.,boundaries[0],max*1.05); box_passCiC->SetFillColor(38); box_passCiC->SetFillStyle(3002); bdtout_passCiC_all_tot->Draw("hist"); box_passCiC->Draw("hist,same"); bdtout_passCiC_all_tot->Draw("hist,same"); bdtout_passCiC_cat0_tot_clone->Draw("hist,same"); bdtout_passCiC_cat1_tot_clone->Draw("hist,same"); bdtout_passCiC_cat2_tot_clone->Draw("hist,same"); bdtout_passCiC_cat3_tot_clone->Draw("hist,same"); leg->Draw("hist"); TLine* line_passCiC[4]; for (int i=0; i<4; i++) { line_passCiC[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05); line_passCiC[i]->SetLineColor(4); line_passCiC[i]->SetLineWidth(2); line_passCiC[i]->SetLineStyle(9); line_passCiC[i]->Draw("hist"); } gPad->RedrawAxis(); c_bdtout_passCiC->SaveAs("categories_passCiC_sig.png"); /* TCanvas *c_bdtout_failpresel = new TCanvas("c_bdtout_failpresel","BDT output, pass CiC, fail presel"); bdtout_failpresel_cat0_tot_clone = (TH1*)bdtout_failpresel_cat0_tot->Clone(); bdtout_failpresel_cat1_tot_clone = (TH1*)bdtout_failpresel_cat1_tot->Clone(); bdtout_failpresel_cat2_tot_clone = (TH1*)bdtout_failpresel_cat2_tot->Clone(); bdtout_failpresel_cat3_tot_clone = (TH1*)bdtout_failpresel_cat3_tot->Clone(); bdtout_failpresel_all_tot->SetLineWidth(2); bdtout_failpresel_cat0_tot_clone->SetLineWidth(2); bdtout_failpresel_cat1_tot_clone->SetLineWidth(2); bdtout_failpresel_cat2_tot_clone->SetLineWidth(2); bdtout_failpresel_cat3_tot_clone->SetLineWidth(2); bdtout_failpresel_all_tot->GetXaxis()->SetTitle("di-photon MVA output"); max = bdtout_failpresel_all_tot->GetMaximum(); TBox* box_failpresel = new TBox(-1.,0.,boundaries[0],max*1.05); box_failpresel->SetFillColor(38); box_failpresel->SetFillStyle(3002); bdtout_failpresel_all_tot->Draw("hist"); box_failpresel->Draw("hist,same"); bdtout_failpresel_all_tot->Draw("hist,same"); bdtout_failpresel_cat0_tot_clone->Draw("hist,same"); bdtout_failpresel_cat1_tot_clone->Draw("hist,same"); bdtout_failpresel_cat2_tot_clone->Draw("hist,same"); bdtout_failpresel_cat3_tot_clone->Draw("hist,same"); leg->Draw("hist"); TLine* line_failpresel[4]; for (int i=0; i<4; i++) { line_failpresel[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05); line_failpresel[i]->SetLineColor(4); line_failpresel[i]->SetLineWidth(2); line_failpresel[i]->SetLineStyle(9); line_failpresel[i]->Draw("hist"); } gPad->RedrawAxis(); c_bdtout_failpresel->SaveAs("categories_failpresel_sig.png"); */ TCanvas *c_bdtout_compareCiC = new TCanvas("c_bdtout_compareCiC","BDT output: pass CiC supertight",1000,650); c_bdtout_compareCiC->Divide(2,2); bdtout_passCiC_cat0_tot->SetFillColor(2); bdtout_passCiC_cat1_tot->SetFillColor(3); bdtout_passCiC_cat2_tot->SetFillColor(4); bdtout_passCiC_cat3_tot->SetFillColor(6); bdtout_passCiC_cat0_tot->SetFillStyle(3002); bdtout_passCiC_cat1_tot->SetFillStyle(3002); bdtout_passCiC_cat2_tot->SetFillStyle(3002); bdtout_passCiC_cat3_tot->SetFillStyle(3002); bdtout_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_cat0_tot->GetXaxis()->SetTitleSize(0.05); bdtout_cat1_tot->GetXaxis()->SetTitleSize(0.05); bdtout_cat2_tot->GetXaxis()->SetTitleSize(0.05); bdtout_cat3_tot->GetXaxis()->SetTitleSize(0.05); c_bdtout_compareCiC->cd(1); box_passCiC_cat0 = (TBox*)box->Clone(); box_passCiC_cat0->SetY2(bdtout_cat0_tot->GetMaximum()*1.05); bdtout_cat0_tot->Draw("hist"); box_passCiC_cat0->Draw("hist,same"); bdtout_cat0_tot->Draw("hist,same"); bdtout_passCiC_cat0_tot->Draw("hist,same"); TLine* line_passCiC_cat0[4]; for (int i=0; i<4; i++) { line_passCiC_cat0[i] = (TLine*)line[i]->Clone(); line_passCiC_cat0[i]->SetY2(bdtout_cat0_tot->GetMaximum()*1.05); line_passCiC_cat0[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC->cd(2); box_passCiC_cat1 = (TBox*)box->Clone(); box_passCiC_cat1->SetY2(bdtout_cat1_tot->GetMaximum()*1.05); bdtout_cat1_tot->Draw("hist"); box_passCiC_cat1->Draw("hist,same"); bdtout_cat1_tot->Draw("hist,same"); bdtout_passCiC_cat1_tot->Draw("hist,same"); TLine* line_passCiC_cat1[4]; for (int i=0; i<4; i++) { line_passCiC_cat1[i] = (TLine*)line[i]->Clone(); line_passCiC_cat1[i]->SetY2(bdtout_cat1_tot->GetMaximum()*1.05); line_passCiC_cat1[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC->cd(3); box_passCiC_cat2 = (TBox*)box->Clone(); box_passCiC_cat2->SetY2(bdtout_cat2_tot->GetMaximum()*1.05); bdtout_cat2_tot->Draw("hist"); box_passCiC_cat2->Draw("hist,same"); bdtout_cat2_tot->Draw("hist,same"); bdtout_passCiC_cat2_tot->Draw("hist,same"); TLine* line_passCiC_cat2[4]; for (int i=0; i<4; i++) { line_passCiC_cat2[i] = (TLine*)line[i]->Clone(); line_passCiC_cat2[i]->SetY2(bdtout_cat2_tot->GetMaximum()*1.05); line_passCiC_cat2[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC->cd(4); box_passCiC_cat3 = (TBox*)box->Clone(); box_passCiC_cat3->SetY2(bdtout_cat3_tot->GetMaximum()*1.05); bdtout_cat3_tot->Draw("hist"); box_passCiC_cat3->Draw("hist,same"); bdtout_cat3_tot->Draw("hist,same"); bdtout_passCiC_cat3_tot->Draw("hist,same"); TLine* line_passCiC_cat3[4]; for (int i=0; i<4; i++) { line_passCiC_cat3[i] = (TLine*)line[i]->Clone(); line_passCiC_cat3[i]->SetY2(bdtout_cat3_tot->GetMaximum()*1.05); line_passCiC_cat3[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC->SaveAs("categories_compareCiC_sig.png"); TCanvas *c_bdtout_lowPt = new TCanvas("c_bdtout_lowPt","BDT output: di-photon pT<40 GeV"); bdtout_lowPt_all_tot = (TH1*)bdtout_lowPt_cat0_tot->Clone(); bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat1_tot); bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat2_tot); bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat3_tot); bdtout_lowPt_all_tot->SetLineColor(1); bdtout_lowPt_cat0_tot->SetLineColor(2); bdtout_lowPt_cat1_tot->SetLineColor(3); bdtout_lowPt_cat2_tot->SetLineColor(4); bdtout_lowPt_cat3_tot->SetLineColor(6); bdtout_lowPt_all_tot->SetLineWidth(2); bdtout_lowPt_cat0_tot->SetLineWidth(2); bdtout_lowPt_cat1_tot->SetLineWidth(2); bdtout_lowPt_cat2_tot->SetLineWidth(2); bdtout_lowPt_cat3_tot->SetLineWidth(2); bdtout_lowPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_lowPt_all_tot->GetYaxis()->SetTitle("Events/0.02"); bdtout_lowPt_all_tot->GetXaxis()->SetTitleSize(0.05); bdtout_lowPt_all_tot->GetXaxis()->SetLabelSize(0.05); bdtout_lowPt_all_tot->GetYaxis()->SetTitleSize(0.05); bdtout_lowPt_all_tot->GetYaxis()->SetLabelSize(0.05); max = bdtout_lowPt_all_tot->GetMaximum(); TBox* box_lowPt = new TBox(-1.,0.,boundaries[0],max*1.05); box_lowPt->SetFillColor(38); box_lowPt->SetFillStyle(3002); bdtout_lowPt_all_tot->Draw("hist"); box_lowPt->Draw("hist,same"); bdtout_lowPt_all_tot->Draw("hist,same"); bdtout_lowPt_cat0_tot->Draw("hist,same"); bdtout_lowPt_cat1_tot->Draw("hist,same"); bdtout_lowPt_cat2_tot->Draw("hist,same"); bdtout_lowPt_cat3_tot->Draw("hist,same"); TLegend *leg_lowPt = (TLegend*)leg->Clone(); leg_lowPt->Clear(); leg_lowPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) < 40 GeV)"); leg_lowPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94"); leg_lowPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94"); leg_lowPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94"); leg_lowPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94"); leg_lowPt->Draw("hist"); TLine* line_lowPt[4]; for (int i=0; i<4; i++) { line_lowPt[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05); line_lowPt[i]->SetLineColor(4); line_lowPt[i]->SetLineWidth(2); line_lowPt[i]->SetLineStyle(9); line_lowPt[i]->Draw("hist"); } gPad->RedrawAxis(); c_bdtout_lowPt->SaveAs("categories_lowPt_sig.png"); TCanvas *c_bdtout_compareCiC_lowPt = new TCanvas("c_bdtout_compareCiC_lowPt","BDT output: di-photon pT<40 GeV, pass CiC supertight",1000,650); c_bdtout_compareCiC_lowPt->Divide(2,2); bdtout_passCiC_lowPt_cat0_tot->SetFillColor(2); bdtout_passCiC_lowPt_cat1_tot->SetFillColor(3); bdtout_passCiC_lowPt_cat2_tot->SetFillColor(4); bdtout_passCiC_lowPt_cat3_tot->SetFillColor(6); bdtout_passCiC_lowPt_cat0_tot->SetFillStyle(3002); bdtout_passCiC_lowPt_cat1_tot->SetFillStyle(3002); bdtout_passCiC_lowPt_cat2_tot->SetFillStyle(3002); bdtout_passCiC_lowPt_cat3_tot->SetFillStyle(3002); bdtout_lowPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_lowPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_lowPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_lowPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_lowPt_cat0_tot->GetXaxis()->SetTitleSize(0.05); bdtout_lowPt_cat1_tot->GetXaxis()->SetTitleSize(0.05); bdtout_lowPt_cat2_tot->GetXaxis()->SetTitleSize(0.05); bdtout_lowPt_cat3_tot->GetXaxis()->SetTitleSize(0.05); c_bdtout_compareCiC_lowPt->cd(1); box_passCiC_lowPt_cat0 = (TBox*)box->Clone(); box_passCiC_lowPt_cat0->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05); bdtout_lowPt_cat0_tot->Draw("hist"); box_passCiC_lowPt_cat0->Draw("hist,same"); bdtout_lowPt_cat0_tot->Draw("hist,same"); bdtout_passCiC_lowPt_cat0_tot->Draw("hist,same"); TLine* line_passCiC_lowPt_cat0[4]; for (int i=0; i<4; i++) { line_passCiC_lowPt_cat0[i] = (TLine*)line[i]->Clone(); line_passCiC_lowPt_cat0[i]->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05); line_passCiC_lowPt_cat0[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_lowPt->cd(2); box_passCiC_lowPt_cat1 = (TBox*)box->Clone(); box_passCiC_lowPt_cat1->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05); bdtout_lowPt_cat1_tot->Draw("hist"); box_passCiC_lowPt_cat1->Draw("hist,same"); bdtout_lowPt_cat1_tot->Draw("hist,same"); bdtout_passCiC_lowPt_cat1_tot->Draw("hist,same"); TLine* line_passCiC_lowPt_cat1[4]; for (int i=0; i<4; i++) { line_passCiC_lowPt_cat1[i] = (TLine*)line[i]->Clone(); line_passCiC_lowPt_cat1[i]->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05); line_passCiC_lowPt_cat1[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_lowPt->cd(3); box_passCiC_lowPt_cat2 = (TBox*)box->Clone(); box_passCiC_lowPt_cat2->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05); bdtout_lowPt_cat2_tot->Draw("hist"); box_passCiC_lowPt_cat2->Draw("hist,same"); bdtout_lowPt_cat2_tot->Draw("hist,same"); bdtout_passCiC_lowPt_cat2_tot->Draw("hist,same"); TLine* line_passCiC_lowPt_cat2[4]; for (int i=0; i<4; i++) { line_passCiC_lowPt_cat2[i] = (TLine*)line[i]->Clone(); line_passCiC_lowPt_cat2[i]->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05); line_passCiC_lowPt_cat2[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_lowPt->cd(4); box_passCiC_lowPt_cat3 = (TBox*)box->Clone(); box_passCiC_lowPt_cat3->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05); bdtout_lowPt_cat3_tot->Draw("hist"); box_passCiC_lowPt_cat3->Draw("hist,same"); bdtout_lowPt_cat3_tot->Draw("hist,same"); bdtout_passCiC_lowPt_cat3_tot->Draw("hist,same"); TLine* line_passCiC_lowPt_cat3[4]; for (int i=0; i<4; i++) { line_passCiC_lowPt_cat3[i] = (TLine*)line[i]->Clone(); line_passCiC_lowPt_cat3[i]->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05); line_passCiC_lowPt_cat3[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_lowPt->SaveAs("categories_compareCiC_lowPt_sig.png"); TCanvas *c_bdtout_highPt = new TCanvas("c_bdtout_highPt","BDT output: di-photon pT>40 GeV"); bdtout_highPt_all_tot = (TH1*)bdtout_highPt_cat0_tot->Clone(); bdtout_highPt_all_tot->Add(bdtout_highPt_cat1_tot); bdtout_highPt_all_tot->Add(bdtout_highPt_cat2_tot); bdtout_highPt_all_tot->Add(bdtout_highPt_cat3_tot); bdtout_highPt_all_tot->SetLineColor(1); bdtout_highPt_cat0_tot->SetLineColor(2); bdtout_highPt_cat1_tot->SetLineColor(3); bdtout_highPt_cat2_tot->SetLineColor(4); bdtout_highPt_cat3_tot->SetLineColor(6); bdtout_highPt_all_tot->SetLineWidth(2); bdtout_highPt_cat0_tot->SetLineWidth(2); bdtout_highPt_cat1_tot->SetLineWidth(2); bdtout_highPt_cat2_tot->SetLineWidth(2); bdtout_highPt_cat3_tot->SetLineWidth(2); bdtout_highPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_highPt_all_tot->GetYaxis()->SetTitle("Events/0.02"); bdtout_highPt_all_tot->GetXaxis()->SetTitleSize(0.05); bdtout_highPt_all_tot->GetXaxis()->SetLabelSize(0.05); bdtout_highPt_all_tot->GetYaxis()->SetTitleSize(0.05); bdtout_highPt_all_tot->GetYaxis()->SetLabelSize(0.05); max = 1.2*bdtout_highPt_all_tot->GetMaximum(); bdtout_highPt_all_tot->SetMaximum(max); TBox* box_highPt = new TBox(-1.,0.,boundaries[0],max); box_highPt->SetFillColor(38); box_highPt->SetFillStyle(3002); bdtout_highPt_all_tot->Draw("hist"); box_highPt->Draw("hist,same"); bdtout_highPt_all_tot->Draw("hist,same"); bdtout_highPt_cat0_tot->Draw("hist,same"); bdtout_highPt_cat1_tot->Draw("hist,same"); bdtout_highPt_cat2_tot->Draw("hist,same"); bdtout_highPt_cat3_tot->Draw("hist,same"); TLegend *leg_highPt = (TLegend*)leg->Clone(); leg_highPt->Clear(); leg_highPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) > 40 GeV)"); leg_highPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94"); leg_highPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94"); leg_highPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94"); leg_highPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94"); leg_highPt->Draw("hist"); TLine* line_highPt[4]; for (int i=0; i<4; i++) { line_highPt[i] = new TLine(boundaries[i],0.,boundaries[i],max); line_highPt[i]->SetLineColor(4); line_highPt[i]->SetLineWidth(2); line_highPt[i]->SetLineStyle(9); line_highPt[i]->Draw("hist"); } gPad->RedrawAxis(); c_bdtout_highPt->SaveAs("categories_highPt_sig.png"); TCanvas *c_bdtout_compareCiC_highPt = new TCanvas("c_bdtout_compareCiC_highPt","BDT output: di-photon pT>40 GeV, pass CiC supertight",1000,650); c_bdtout_compareCiC_highPt->Divide(2,2); bdtout_passCiC_highPt_cat0_tot->SetFillColor(2); bdtout_passCiC_highPt_cat1_tot->SetFillColor(3); bdtout_passCiC_highPt_cat2_tot->SetFillColor(4); bdtout_passCiC_highPt_cat3_tot->SetFillColor(6); bdtout_passCiC_highPt_cat0_tot->SetFillStyle(3002); bdtout_passCiC_highPt_cat1_tot->SetFillStyle(3002); bdtout_passCiC_highPt_cat2_tot->SetFillStyle(3002); bdtout_passCiC_highPt_cat3_tot->SetFillStyle(3002); bdtout_highPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_highPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_highPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_highPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output"); bdtout_highPt_cat0_tot->GetXaxis()->SetTitleSize(0.05); bdtout_highPt_cat1_tot->GetXaxis()->SetTitleSize(0.05); bdtout_highPt_cat2_tot->GetXaxis()->SetTitleSize(0.05); bdtout_highPt_cat3_tot->GetXaxis()->SetTitleSize(0.05); c_bdtout_compareCiC_highPt->cd(1); box_passCiC_highPt_cat0 = (TBox*)box->Clone(); box_passCiC_highPt_cat0->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05); bdtout_highPt_cat0_tot->Draw("hist"); box_passCiC_highPt_cat0->Draw("hist,same"); bdtout_highPt_cat0_tot->Draw("hist,same"); bdtout_passCiC_highPt_cat0_tot->Draw("hist,same"); TLine* line_passCiC_highPt_cat0[4]; for (int i=0; i<4; i++) { line_passCiC_highPt_cat0[i] = (TLine*)line[i]->Clone(); line_passCiC_highPt_cat0[i]->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05); line_passCiC_highPt_cat0[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_highPt->cd(2); box_passCiC_highPt_cat1 = (TBox*)box->Clone(); box_passCiC_highPt_cat1->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05); bdtout_highPt_cat1_tot->Draw("hist"); box_passCiC_highPt_cat1->Draw("hist,same"); bdtout_highPt_cat1_tot->Draw("hist,same"); bdtout_passCiC_highPt_cat1_tot->Draw("hist,same"); TLine* line_passCiC_highPt_cat1[4]; for (int i=0; i<4; i++) { line_passCiC_highPt_cat1[i] = (TLine*)line[i]->Clone(); line_passCiC_highPt_cat1[i]->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05); line_passCiC_highPt_cat1[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_highPt->cd(3); box_passCiC_highPt_cat2 = (TBox*)box->Clone(); box_passCiC_highPt_cat2->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05); bdtout_highPt_cat2_tot->Draw("hist"); box_passCiC_highPt_cat2->Draw("hist,same"); bdtout_highPt_cat2_tot->Draw("hist,same"); bdtout_passCiC_highPt_cat2_tot->Draw("hist,same"); TLine* line_passCiC_highPt_cat2[4]; for (int i=0; i<4; i++) { line_passCiC_highPt_cat2[i] = (TLine*)line[i]->Clone(); line_passCiC_highPt_cat2[i]->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05); line_passCiC_highPt_cat2[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_highPt->cd(4); box_passCiC_highPt_cat3 = (TBox*)box->Clone(); box_passCiC_highPt_cat3->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05); bdtout_highPt_cat3_tot->Draw("hist"); box_passCiC_highPt_cat3->Draw("hist,same"); bdtout_highPt_cat3_tot->Draw("hist,same"); bdtout_passCiC_highPt_cat3_tot->Draw("hist,same"); TLine* line_passCiC_highPt_cat3[4]; for (int i=0; i<4; i++) { line_passCiC_highPt_cat3[i] = (TLine*)line[i]->Clone(); line_passCiC_highPt_cat3[i]->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05); line_passCiC_highPt_cat3[i]->Draw("hist"); } text->DrawText(0.15,0.75,"!both EB, !both R9>0.94"); gPad->RedrawAxis(); c_bdtout_compareCiC_highPt->SaveAs("categories_compareCiC_highPt_sig.png"); TCanvas *c_ptVsBdtout = new TCanvas("c_ptVsBdtout","pT(#gamma#gamma) vs MVA output",1000,650); c_ptVsBdtout->Divide(2,2); pt_vs_bdtout_cat0_all = (TH2*)pt_vs_bdtout_cat0_ggh_m125_8TeV->Clone(); pt_vs_bdtout_cat1_all = (TH2*)pt_vs_bdtout_cat1_ggh_m125_8TeV->Clone(); pt_vs_bdtout_cat2_all = (TH2*)pt_vs_bdtout_cat2_ggh_m125_8TeV->Clone(); pt_vs_bdtout_cat3_all = (TH2*)pt_vs_bdtout_cat3_ggh_m125_8TeV->Clone(); pt_vs_bdtout_cat4_all = (TH2*)pt_vs_bdtout_cat4_ggh_m125_8TeV->Clone(); pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_vbf_m125_8TeV); pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_vbf_m125_8TeV); pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_vbf_m125_8TeV); pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_vbf_m125_8TeV); pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_vbf_m125_8TeV); pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_wzh_m125_8TeV); pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_wzh_m125_8TeV); pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_wzh_m125_8TeV); pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_wzh_m125_8TeV); pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_wzh_m125_8TeV); pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_tth_m125_8TeV); pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_tth_m125_8TeV); pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_tth_m125_8TeV); pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_tth_m125_8TeV); pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_tth_m125_8TeV); pt_vs_bdtout_cat0_all->GetXaxis()->SetTitle("di-photon MVA output"); pt_vs_bdtout_cat1_all->GetXaxis()->SetTitle("di-photon MVA output"); pt_vs_bdtout_cat2_all->GetXaxis()->SetTitle("di-photon MVA output"); pt_vs_bdtout_cat3_all->GetXaxis()->SetTitle("di-photon MVA output"); pt_vs_bdtout_cat0_all->GetXaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat1_all->GetXaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat2_all->GetXaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat3_all->GetXaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat0_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)"); pt_vs_bdtout_cat1_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)"); pt_vs_bdtout_cat2_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)"); pt_vs_bdtout_cat3_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)"); pt_vs_bdtout_cat0_all->GetYaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat1_all->GetYaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat2_all->GetYaxis()->SetTitleSize(0.05); pt_vs_bdtout_cat3_all->GetYaxis()->SetTitleSize(0.05); c_ptVsBdtout->cd(1); pt_vs_bdtout_cat0_all->Draw("colz"); box_ptVsBdtout = (TBox*)box->Clone(); box_ptVsBdtout->SetY2(200.); box_ptVsBdtout->Draw("hist"); pt_vs_bdtout_cat0_all->Draw("colz,same"); TLine* line_ptVsBdtout[4]; for (int i=0; i<4; i++) { line_ptVsBdtout[i] = (TLine*)line[i]->Clone(); line_ptVsBdtout[i]->SetY2(200.); line_ptVsBdtout[i]->Draw("hist"); } text->DrawText(0.15,0.75,"both EB, both R9>0.94"); gPad->RedrawAxis(); c_ptVsBdtout->cd(2); pt_vs_bdtout_cat1_all->Draw("colz"); box_ptVsBdtout->Draw("hist"); pt_vs_bdtout_cat1_all->Draw("colz,same"); for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist"); text->DrawText(0.15,0.75,"both EB, !both R9>0.94"); gPad->RedrawAxis(); c_ptVsBdtout->cd(3); pt_vs_bdtout_cat2_all->Draw("colz"); box_ptVsBdtout->Draw("hist"); pt_vs_bdtout_cat2_all->Draw("colz,same"); for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist"); text->DrawText(0.15,0.75,"!both EB, both R9>0.94"); gPad->RedrawAxis(); c_ptVsBdtout->cd(4); pt_vs_bdtout_cat3_all->Draw("colz"); box_ptVsBdtout->Draw("hist"); pt_vs_bdtout_cat3_all->Draw("colz,same"); for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist"); text->DrawText(0.15,0.75,"!both EB, !both R9>0.94"); gPad->RedrawAxis(); c_ptVsBdtout->SaveAs("ptVsBdtout_sig.png"); TCanvas *c_2D = new TCanvas("c_2D","min(R9) vs max(eta), sublead eta vs lead eta",1250,500); c_2D->Divide(4,2); minR9_vs_maxEta_cat2_all = (TH2*)minR9_vs_maxEta_cat2_ggh_m125_8TeV->Clone(); minR9_vs_maxEta_cat3_all = (TH2*)minR9_vs_maxEta_cat3_ggh_m125_8TeV->Clone(); minR9_vs_maxEta_cat4_all = (TH2*)minR9_vs_maxEta_cat4_ggh_m125_8TeV->Clone(); minR9_vs_maxEta_cat5_all = (TH2*)minR9_vs_maxEta_cat5_ggh_m125_8TeV->Clone(); minR9_vs_maxEta_cat6_all = (TH2*)minR9_vs_maxEta_cat6_ggh_m125_8TeV->Clone(); minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_vbf_m125_8TeV); minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_vbf_m125_8TeV); minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_vbf_m125_8TeV); minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_vbf_m125_8TeV); minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_vbf_m125_8TeV); minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_wzh_m125_8TeV); minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_wzh_m125_8TeV); minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_wzh_m125_8TeV); minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_wzh_m125_8TeV); minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_wzh_m125_8TeV); minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_tth_m125_8TeV); minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_tth_m125_8TeV); minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_tth_m125_8TeV); minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_tth_m125_8TeV); minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_tth_m125_8TeV); eta2_vs_eta1_cat2_all = (TH2*)eta2_vs_eta1_cat2_ggh_m125_8TeV->Clone(); eta2_vs_eta1_cat3_all = (TH2*)eta2_vs_eta1_cat3_ggh_m125_8TeV->Clone(); eta2_vs_eta1_cat4_all = (TH2*)eta2_vs_eta1_cat4_ggh_m125_8TeV->Clone(); eta2_vs_eta1_cat5_all = (TH2*)eta2_vs_eta1_cat5_ggh_m125_8TeV->Clone(); eta2_vs_eta1_cat6_all = (TH2*)eta2_vs_eta1_cat6_ggh_m125_8TeV->Clone(); eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_vbf_m125_8TeV); eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_vbf_m125_8TeV); eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_vbf_m125_8TeV); eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_vbf_m125_8TeV); eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_vbf_m125_8TeV); eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_wzh_m125_8TeV); eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_wzh_m125_8TeV); eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_wzh_m125_8TeV); eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_wzh_m125_8TeV); eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_wzh_m125_8TeV); eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_tth_m125_8TeV); eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_tth_m125_8TeV); eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_tth_m125_8TeV); eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_tth_m125_8TeV); eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_tth_m125_8TeV); minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitleSize(0.05); line_minr9 = new TLine(0.,0.94,2.5,0.94); line_maxeta = new TLine(1.479,0.5,1.479,1.); //line_minr9->SetLineColor(4); line_minr9->SetLineWidth(2); line_minr9->SetLineStyle(9); //line_maxeta->SetLineColor(4); line_maxeta->SetLineWidth(2); line_maxeta->SetLineStyle(9); c_2D->cd(1); minR9_vs_maxEta_cat2_all->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D->cd(2); minR9_vs_maxEta_cat3_all->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D->cd(3); minR9_vs_maxEta_cat4_all->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D->cd(4); minR9_vs_maxEta_cat5_all->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); //c_2D->cd(5); //minR9_vs_maxEta_cat6_all->Draw("colz"); //line_minr9->Draw("hist"); //line_maxeta->Draw("hist"); eta2_vs_eta1_cat2_all->GetYaxis()->SetTitle("sublead #eta"); eta2_vs_eta1_cat3_all->GetYaxis()->SetTitle("sublead #eta"); eta2_vs_eta1_cat4_all->GetYaxis()->SetTitle("sublead #eta"); eta2_vs_eta1_cat5_all->GetYaxis()->SetTitle("sublead #eta"); eta2_vs_eta1_cat6_all->GetYaxis()->SetTitle("sublead #eta"); eta2_vs_eta1_cat2_all->GetXaxis()->SetTitle("lead #eta"); eta2_vs_eta1_cat3_all->GetXaxis()->SetTitle("lead #eta"); eta2_vs_eta1_cat4_all->GetXaxis()->SetTitle("lead #eta"); eta2_vs_eta1_cat5_all->GetXaxis()->SetTitle("lead #eta"); eta2_vs_eta1_cat6_all->GetXaxis()->SetTitle("lead #eta"); eta2_vs_eta1_cat2_all->GetXaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat3_all->GetXaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat4_all->GetXaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat5_all->GetXaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat6_all->GetXaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat2_all->GetYaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat3_all->GetYaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat4_all->GetYaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat5_all->GetYaxis()->SetTitleSize(0.05); eta2_vs_eta1_cat6_all->GetYaxis()->SetTitleSize(0.05); c_2D->cd(5); eta2_vs_eta1_cat2_all->Draw("colz"); c_2D->cd(6); eta2_vs_eta1_cat3_all->Draw("colz"); c_2D->cd(7); eta2_vs_eta1_cat4_all->Draw("colz"); c_2D->cd(8); eta2_vs_eta1_cat5_all->Draw("colz"); //c_2D->cd(10); //eta2_vs_eta1_cat6_all->Draw("colz"); c_2D->SaveAs("categories_2D_sig.png"); /* TCanvas *c_2D_v2 = new TCanvas("c_2D_v2","min(R9) vs max(eta), |lead eta| vs |deltaEeta|",1500,500); c_2D_v2->Divide(5,2); minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitle("max(#eta)"); minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitle("min(R9)"); minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitleSize(0.05); minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitleSize(0.05); c_2D_v2->cd(1); minR9_vs_maxEta_cat2_tot->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D_v2->cd(2); minR9_vs_maxEta_cat3_tot->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D_v2->cd(3); minR9_vs_maxEta_cat4_tot->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D_v2->cd(4); minR9_vs_maxEta_cat5_tot->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); c_2D_v2->cd(5); minR9_vs_maxEta_cat6_tot->Draw("colz"); line_minr9->Draw("hist"); line_maxeta->Draw("hist"); eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitle("|lead #eta|"); eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitle("|lead #eta|"); eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitle("|lead #eta|"); eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitle("|lead #eta|"); eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitle("|lead #eta|"); eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitle("|#Delta#eta|"); eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitle("|#Delta#eta|"); eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitle("|#Delta#eta|"); eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitle("|#Delta#eta|"); eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitle("|#Delta#eta|"); eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitleSize(0.05); eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitleSize(0.05); c_2D_v2->cd(6); eta1_vs_deltaEta_cat2_tot->Draw("colz"); c_2D_v2->cd(7); eta1_vs_deltaEta_cat3_tot->Draw("colz"); c_2D_v2->cd(8); eta1_vs_deltaEta_cat4_tot->Draw("colz"); c_2D_v2->cd(9); eta1_vs_deltaEta_cat5_tot->Draw("colz"); c_2D_v2->cd(10); eta1_vs_deltaEta_cat6_tot->Draw("colz"); c_2D_v2->SaveAs("categories_2D_v2_sig.png"); */ }
void EMCDistribution_ADC(bool log_scale = true) { TString gain = "RAW"; TText *t; TCanvas *c1 = new TCanvas( "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts, "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800, 1000); c1->Divide(8, 8, 0., 0.01); int idx = 1; TPad *p; for (int iphi = 8 - 1; iphi >= 0; iphi--) { for (int ieta = 0; ieta < 8; ieta++) { p = (TPad *) c1->cd(idx++); c1->Update(); if (log_scale) { p->SetLogz(); } p->SetGridx(0); p->SetGridy(0); TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : ""); TH1 *h = NULL; if (log_scale) h = new TH2F(hname, Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 24, -.5, 23.5, // 128+64, 0, 3096); 4098, -1, 4097); // else // h = new TH2F(hname, // Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, // -.050, .5,128,0,2048); h->SetLineWidth(0); h->SetLineColor(kBlue + 3); h->SetFillColor(kBlue + 3); h->GetXaxis()->SetTitleSize(.09); h->GetXaxis()->SetLabelSize(.08); h->GetYaxis()->SetLabelSize(.08); h->GetYaxis()->SetRangeUser(0, 4096); // if (log_scale) // QAHistManagerDef::useLogBins(h->GetYaxis()); TString sdraw = "TOWER_" + gain + "_CEMC[].signal_samples[]:fmod(Iteration$,24)>>" + hname; TString scut = Form( "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d", gain.Data(), ieta, gain.Data(), iphi); cout << "T->Draw(\"" << sdraw << "\",\"" << scut << "\");" << endl; T->Draw(sdraw, scut, "colz"); TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi)); t->SetTextAlign(33); t->SetTextSize(.15); t->SetNDC(); t->Draw(); // return; } } SaveCanvas(c1, TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false); }
// input: - Input file (result from TMVA) // - use of TMVA plotting TStyle void mvas( TString fin = "TMVA.root", HistType htype = MVAType, Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // switches const Bool_t Save_Images = kTRUE; // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); // define Canvas layout here! Int_t xPad = 1; // no of plots in x Int_t yPad = 1; // no of plots in y Int_t noPad = xPad * yPad ; const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas *c = 0; // counter variables Int_t countCanvas = 0; // search for the right histograms in full list of keys TIter next(file->GetListOfKeys()); TKey *key(0); while ((key = (TKey*)next())) { if (!TString(key->GetName()).BeginsWith("Method_")) continue; if( ! gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory") ) continue; TString methodName; TMVAGlob::GetMethodName(methodName,key); TDirectory* mDir = (TDirectory*)key->ReadObj(); TIter keyIt(mDir->GetListOfKeys()); TKey *titkey; while ((titkey = (TKey*)keyIt())) { if (!gROOT->GetClass(titkey->GetClassName())->InheritsFrom("TDirectory")) continue; TDirectory *titDir = (TDirectory *)titkey->ReadObj(); TString methodTitle; TMVAGlob::GetMethodTitle(methodTitle,titDir); cout << "--- Found directory for method: " << methodName << "::" << methodTitle << flush; TString hname = "MVA_" + methodTitle; if (htype == ProbaType ) hname += "_Proba"; else if (htype == RarityType ) hname += "_Rarity"; TH1* sig = dynamic_cast<TH1*>(titDir->Get( hname + "_S" )); TH1* bgd = dynamic_cast<TH1*>(titDir->Get( hname + "_B" )); if (sig==0 || bgd==0) { if (htype == MVAType) cout << "mva distribution not available (this is normal for Cut classifier)" << endl; else if(htype == ProbaType) cout << "probability distribution not available (this is normal for Cut classifier)" << endl; else if(htype == RarityType) cout << "rarity distribution not available (this is normal for Cut classifier)" << endl; else if(htype == CompareType) cout << "overtraining check not available (this is normal for Cut classifier)" << endl; else cout << endl; } else { cout << endl; // chop off useless stuff sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); if (htype == ProbaType) sig->SetTitle( Form("TMVA probability for classifier: %s", methodTitle.Data()) ); else if (htype == RarityType) sig->SetTitle( Form("TMVA Rarity for classifier: %s", methodTitle.Data()) ); else if (htype == CompareType) sig->SetTitle( Form("TMVA overtraining check for classifier: %s", methodTitle.Data()) ); // create new canvas TString ctitle = ((htype == MVAType) ? Form("TMVA response %s",methodTitle.Data()) : (htype == ProbaType) ? Form("TMVA probability %s",methodTitle.Data()) : (htype == CompareType) ? Form("TMVA comparison %s",methodTitle.Data()) : Form("TMVA Rarity %s",methodTitle.Data())); TString cname = ((htype == MVAType) ? Form("output_%s",methodTitle.Data()) : (htype == ProbaType) ? Form("probability_%s",methodTitle.Data()) : (htype == CompareType) ? Form("comparison_%s",methodTitle.Data()) : Form("rarity_%s",methodTitle.Data())); c = new TCanvas( Form("canvas%d", countCanvas+1), ctitle, countCanvas*50+200, countCanvas*20, width, (Int_t)width*0.78 ); // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // frame limits (choose judicuous x range) Float_t nrms = 4; cout << "--- Mean and RMS (S): " << sig->GetMean() << ", " << sig->GetRMS() << endl; cout << "--- Mean and RMS (B): " << bgd->GetMean() << ", " << bgd->GetRMS() << endl; Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); Float_t ymin = 0; Float_t maxMult = (htype == CompareType) ? 1.3 : 1.2; Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; // build a frame Int_t nb = 500; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + ((htype == MVAType || htype == CompareType) ? " response" : "") ); if (htype == ProbaType ) frame->GetXaxis()->SetTitle( "Signal probability" ); else if (htype == RarityType ) frame->GetXaxis()->SetTitle( "Signal rarity" ); frame->GetYaxis()->SetTitle("Normalized"); TMVAGlob::SetFrameStyle( frame ); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + (htype == CompareType ? 0.40 : 0.3), 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal") + ((htype == CompareType) ? " (test sample)" : ""), "F"); legend->AddEntry(bgd,TString("Background") + ((htype == CompareType) ? " (test sample)" : ""), "F"); legend->SetBorderSize(1); legend->SetMargin( (htype == CompareType ? 0.2 : 0.3) ); legend->Draw("same"); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); if (htype == CompareType) { // if overtraining check, load additional histograms TH1* sigOv = 0; TH1* bgdOv = 0; TString ovname = hname += "_Train"; sigOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_S" )); bgdOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_B" )); if (sigOv == 0 || bgdOv == 0) { cout << "+++ Problem in \"mvas.C\": overtraining check histograms do not exist" << endl; } else { cout << "--- Found comparison histograms for overtraining check" << endl; TLegend *legend2= new TLegend( 1 - c->GetRightMargin() - 0.42, 1 - c->GetTopMargin() - 0.12, 1 - c->GetRightMargin(), 1 - c->GetTopMargin() ); legend2->SetFillStyle( 1 ); legend2->SetBorderSize(1); legend2->AddEntry(sigOv,"Signal (training sample)","P"); legend2->AddEntry(bgdOv,"Background (training sample)","P"); legend2->SetMargin( 0.1 ); legend2->Draw("same"); } Int_t col = sig->GetLineColor(); sigOv->SetMarkerColor( col ); sigOv->SetMarkerSize( 0.7 ); sigOv->SetMarkerStyle( 20 ); sigOv->SetLineWidth( 1 ); sigOv->SetLineColor( col ); sigOv->Draw("e1same"); col = bgd->GetLineColor(); bgdOv->SetMarkerColor( col ); bgdOv->SetMarkerSize( 0.7 ); bgdOv->SetMarkerStyle( 20 ); bgdOv->SetLineWidth( 1 ); bgdOv->SetLineColor( col ); bgdOv->Draw("e1same"); ymax = TMath::Max( ymax, TMath::Max( sigOv->GetMaximum(), bgdOv->GetMaximum() )*maxMult ); frame->GetYaxis()->SetLimits( 0, ymax ); // for better visibility, plot thinner lines sig->SetLineWidth( 1 ); bgd->SetLineWidth( 1 ); // perform K-S test cout << "--- Perform Kolmogorov-Smirnov tests" << endl; Double_t kolS = sig->KolmogorovTest( sigOv ); Double_t kolB = bgd->KolmogorovTest( bgdOv ); cout << "--- Goodness of signal (background) consistency: " << kolS << " (" << kolB << ")" << endl; TString probatext = Form( "Kolmogorov-Smirnov test: signal (background) probability = %5.3g (%5.3g)", kolS, kolB ); TText* tt = new TText( 0.12, 0.74, probatext ); tt->SetNDC(); tt->SetTextSize( 0.032 ); tt->AppendPad(); } // redraw axes frame->Draw("sameaxis"); // text for overflows Int_t nbin = sig->GetNbinsX(); Double_t dxu = sig->GetBinWidth(0); Double_t dxo = sig->GetBinWidth(nbin+1); TString uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%", sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 ); TText* t = new TText( 0.975, 0.115, uoflow ); t->SetNDC(); t->SetTextSize( 0.030 ); t->SetTextAngle( 90 ); t->AppendPad(); // update canvas c->Update(); // save canvas to file TMVAGlob::plot_logo(1.058); if (Save_Images) { if (htype == MVAType) TMVAGlob::imgconv( c, Form("plots/mva_%s", methodTitle.Data()) ); else if (htype == ProbaType) TMVAGlob::imgconv( c, Form("plots/proba_%s", methodTitle.Data()) ); else if (htype == CompareType) TMVAGlob::imgconv( c, Form("plots/overtrain_%s", methodTitle.Data()) ); else TMVAGlob::imgconv( c, Form("plots/rarity_%s", methodTitle.Data()) ); } countCanvas++; } } } }
void plot_xtalE(){ gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetTitleSize(0.08,"t"); // a list of runs corresponding to xtal0 to xtal53 int runlist[54] = {3295,3296,3297,3369,3300,3301,3302,3303,3368, 3244,3245,3246,3247,3248,3249,3250,3251,3252, 3240,3239,3238,3237,3236,3235,3232,3234,3233, 3267,3266,3265,3263,3258,3257,3256,3254,3253, 3268,3272,3274,3275,3276,3277,3278,3281,3283, 3294,3293,3292,3289,3288,3287,3286,3285,3284}; // for(int i=0;i<54;i++){ // runlist[i] = 3305; // } ofstream outfile("energycalibration.fcl"); TCanvas *c1 = new TCanvas("c1","c1",1800,1200); TH2D *xtalEnergy = new TH2D("xtalEnergy","xtalEnergy",9,0,9,6,0,6); outfile << "// constants from runs" <<endl;; for(int i=0;i<54;i++){ outfile << runlist[i] << " "; if(i%9==8 && i!=53) { outfile << endl; outfile << "// ";} } outfile << "\nBEGIN_PROLOG" << endl; outfile << "xtal_energy_response: {" << endl; double mean[54]; double rms[54]; double norm[54]; double index[54]; c1->Divide(9,6); for(int i=0;i<54;i++){ index[i]=i; c1->cd(54-i); c1->cd(54-i)->SetLogz(); //if(i==3 || i==8 || i==9) continue; // these are runs where the beams are at the wrong place TFile *file = new TFile(Form("run%d.root",runlist[i])); TH2D *beamEnergy2D = (TH2D*)file->Get("beamEnergy2D"); beamEnergy2D->Draw("colz text"); beamEnergy2D->SetMarkerSize(1); beamEnergy2D->SetMaximum(3000); beamEnergy2D->SetMinimum(1); beamEnergy2D->SetTitle(Form("Run %d",runlist[i])); double maxE = beamEnergy2D->GetMaximum(); int maxBin = beamEnergy2D->GetMaximumBin(); int x,y,z; beamEnergy2D->GetBinXYZ(maxBin,x,y,z); cout<<x<<" "<<y<<" "<<z<<" "<<(y-1)*9+9-x<<endl; int xtalNum = (y-1)*9+9-x; TH1D *beamEnergy = (TH1D*)file->Get(Form("beamEnergy%02d",xtalNum)); TH1D *beamTime = (TH1D*)file->Get(Form("beamTime%02d",xtalNum)); TH1D *beamTimeEnergy = (TH1D*)file->Get(Form("beamTimeEnergy%02d",xtalNum)); TH1D *syncEnergy = (TH1D*)file->Get(Form("syncEnergy%02d",xtalNum)); beamEnergy->Draw(); TF1 *fit = new TF1("fit","gaus(0)",1500,2800); fit->SetParLimits(1,1700,2500); fit->SetParLimits(2,50,150); fit->SetParameters(100,2100,100); beamEnergy->Fit("fit","REM"); norm[i]=fit->GetParameter(0); mean[i]=fit->GetParameter(1); rms[i]=fit->GetParameter(2); TF1 *refit = new TF1("refit","gaus(0)",mean[i]-2*rms[i], mean[i]+2*rms[i]); refit->SetParameters(norm[i],mean[i],rms[i]); beamEnergy->Fit("refit","REM"); norm[i]=refit->GetParameter(0); mean[i]=refit->GetParameter(1); rms[i]=refit->GetParameter(2); outfile << Form("xtal%d : %f",i,mean[i]) << endl; xtalEnergy->Fill(8-i%9,i/9,mean[i]); TText *text = new TText(0.15,0.75,Form("E%d=%.1f",xtalNum,mean[i])); text->SetTextSize(0.09); text->SetTextColor(2); text->SetNDC(); beamEnergy->GetListOfFunctions()->Add(text); } outfile << "}" << endl; outfile << "END_PROLOG" << endl; TCanvas *c2 = new TCanvas("c2","c2",900,600); xtalEnergy->Draw("colz text"); xtalEnergy->SetMarkerSize(1.5); xtalEnergy->SetMaximum(2500); xtalEnergy->SetMinimum(1700); TCanvas *c3 = new TCanvas("c3","c3",900,600); TGraph *g1 = new TGraph(54,index,mean); g1->SetMarkerStyle(20); g1->Draw("AP"); double avg=0; for(int i=0;i<54;i++){ if(mean[i]>0){ avg += mean[i]/54.; } } cout<<avg<<endl; TLine *linem5 = new TLine(0,0.95*avg,54,0.95*avg); TLine *linep5 = new TLine(0,1.05*avg,54,1.05*avg); linem5->SetLineWidth(2); linem5->SetLineStyle(7); linem5->SetLineColor(2); linep5->SetLineWidth(2); linep5->SetLineColor(2); linep5->SetLineStyle(7); linem5->Draw("same"); linep5->Draw("same"); TLine *line1 = new TLine(0,0.9*avg,54,0.9*avg); line1->SetLineWidth(2); line1->SetLineColor(4); line1->Draw("same"); TLine *line2 = new TLine(0,1.1*avg,54,1.1*avg); line2->SetLineWidth(2); line2->SetLineColor(4); line2->Draw("same"); TLegend *leg = new TLegend(0.7,0.1,0.9,0.3); leg->AddEntry(linem5,"#pm 5%","l"); leg->AddEntry(line1,"#pm 10%","l"); leg->Draw(); }