//-------------------------------------------------------------------------------------------------- void overlayFrame(TString text) { // 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(0.01,0.01,text.Data()); plotText->SetTextSize(0.04); plotText->SetTextColor(kBlue); plotText->Draw(); return; }
void first() { TCanvas *nut = new TCanvas("nut", "FirstSession",100,10,700,900); nut->Range(0,0,20,24); nut->SetFillColor(10); nut->SetBorderSize(2); TPaveLabel *pl = new TPaveLabel(3,22,17,23.7, "My first ROOT interactive session","br"); pl->SetFillColor(18); pl->Draw(); TText t(0,0,"a"); t.SetTextFont(62); t.SetTextSize(0.025); t.SetTextAlign(12); t.DrawText(2,20.3,"ROOT is based on CINT, a powerful C/C++ interpreter."); t.DrawText(2,19.3,"Blocks of lines can be entered within {...}."); t.DrawText(2,18.3,"Previous typed lines can be recalled."); t.SetTextFont(72); t.SetTextSize(0.026); t.DrawText(3,17,"Root > float x=5; float y=7;"); t.DrawText(3,16,"Root > x*sqrt(y)"); t.DrawText(3,14, "Root > for (int i=2;i<7;i++) printf(\"sqrt(%d) = %f\\n\",i,sqrt(i));"); t.DrawText(3,10,"Root > TF1 f1(\"f1\",\"sin(x)/x\",0,10)"); t.DrawText(3, 9,"Root > f1.Draw()"); t.SetTextFont(81); t.SetTextSize(0.018); t.DrawText(4,15,"(float) 13.2288f"); t.DrawText(4,13.3,"sqrt(2) = 1.414214"); t.DrawText(4,12.7,"sqrt(3) = 1.732051"); t.DrawText(4,12.1,"sqrt(4) = 2.000000"); t.DrawText(4,11.5,"sqrt(5) = 2.236068"); t.DrawText(4,10.9,"sqrt(6) = 2.449490"); TPad *pad = new TPad("pad","pad",.2,.05,.8,.35); pad->Draw(); pad->cd(); pad->SetGrid(); TF1 *f1 = new TF1("f1","sin(x)/x",0,10); f1->Draw(); }
TH1F* GetHisto(TFile* fin, string region, string process, string varname, float& norm, bool do_norm, float input_norm) { string cname = CHANNEL_NAME+string("/")+region+"/"+varname; TCanvas* c = (TCanvas*) fin->Get(cname.c_str()); string hname = "v:"+varname+"|p:"+process+"|r:"+region+string("|c:")+CHANNEL_NAME+string("|t:1DEntries"); TH1F* h = 0; if(VERBOSE>0){ cerr<<"cname :"<<cname<<endl; cerr<<"histo name: "<<hname<<endl; cerr<<"pointer: "<<c<<endl; } TList* l = c->GetListOfPrimitives(); TPad* pad = (TPad*) l->At(0); THStack* stack = (THStack*) pad->GetPrimitive(""); h = (TH1F*) stack->GetHists()->FindObject(hname.c_str()); if(do_norm) h->Scale(input_norm/h->Integral()); norm = h->Integral(); return (TH1F*) h->Clone(); }
// Render a TF2 looking like a rose. // Author: Timur Pocheptsov void glrose() { //Define and set user's palette, //use polar system. const Int_t paletteSize = 10; Float_t rgb[paletteSize * 3] = {0.80f, 0.55f, 0.40f, 0.85f, 0.60f, 0.45f, 0.90f, 0.65f, 0.50f, 0.95f, 0.70f, 0.55f, 1.f, 0.75f, 0.60f, 1.f, 0.80f, 0.65f, 1.f, 0.85f, 0.70f, 1.f, 0.90f, 0.75f, 1.f, 0.95f, 0.80f, 1.f, 1.f, 0.85f}; Int_t palette[paletteSize] = {0}; for (Int_t i = 0; i < paletteSize; ++i) palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]); gStyle->SetPalette(paletteSize, palette); gStyle->SetCanvasPreferGL(1); TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550); TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98, "\"glsurf2pol\" option + user defined palette."); title->SetFillColor(32); title->Draw(); TPad *rosePad = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8); rosePad->Draw(); TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6); fun->SetContour(paletteSize); fun->SetNpx(30); fun->SetNpy(30); rosePad->cd(); fun->Draw("glsurf2pol"); }
TCanvas* createCanvas(TString name,int xlen,int ylen,int xDiv,bool logOn) { TCanvas* aCanvas = new TCanvas(name,name,xlen,ylen); float xstep = 1./xDiv; for (int i1=1; i1<=xDiv; i1++) { TPad *mainPad = new TPad("","",0.01+((i1-1)*xstep),0.25,(i1*xstep)-0.01,0.99); mainPad->SetNumber(i1); mainPad->Draw(); TPad *ratioPad = new TPad("","",0.01+((i1-1)*xstep),0.01,(i1*xstep)-0.01,0.25); ratioPad->SetNumber(i1+xDiv); ratioPad->Draw(); } if (logOn==true) { gPad->SetLogy(); } aCanvas->SetFillColor(0); aCanvas->SetBottomMargin(0.125); aCanvas->SetLeftMargin(0.125); aCanvas->SetFrameFillColor(0); aCanvas->SetFrameBorderMode(0); aCanvas->SetFrameLineWidth(2); return aCanvas; }
void draw_activation(TCanvas* c, Double_t cx, Double_t cy, Double_t radx, Double_t rady, Int_t whichActivation) { TImage *activation = NULL; switch (whichActivation) { case 0: activation = TImage::Open("sigmoid-small.png"); break; case 1: activation = TImage::Open("line-small.png"); break; default: cout << "Activation index " << whichActivation << " is not known." << endl; cout << "You messed up or you need to modify network.C to introduce a new " << "activation function (and image) corresponding to this index" << endl; } if (activation == NULL) { cout << "Could not create an image... exit" << endl; return; } activation->SetConstRatio(kFALSE); radx *= 0.7; rady *= 0.7; TString name = Form("activation%f%f", cx, cy); TPad* p = new TPad(name+"", name+"", cx-radx, cy-rady, cx+radx, cy+rady); p->Draw(); p->cd(); activation->Draw(); c->cd(); }
void root_util::set_box(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t lstyle, Double_t lwidth, Double_t lcolor, Double_t fcolor, Int_t fptn, Char_t *loctype, Int_t gnum, Int_t xonly, Int_t yonly){ //cout << pad_size <<endl; Int_t clen = clst.size(); //cout << clen<<endl; Int_t cnum = gnum / pad_size; cout << "fcolor"<< fcolor<<endl; Int_t pad_num = gnum % pad_size + 1; //cout << pad_num<<endl; //cout << xmin <<endl; //cout << xmax <<endl; //cout << ymin <<endl; //cout << ymax <<endl; TPad *b; //b = new TEllipse(xmin, ymin, xmin, ymax); b = new TPad("box","box", xmin, ymin, xmax, ymax); b->SetFillColor(fcolor); clst[cnum]->cd(pad_num); b->Draw(); // clst[cnum]->UseCurrentStyle(); }
TPad* plot_ratio(TCanvas *canv, bool up){ canv->SetFillColor (0); canv->SetBorderMode (0); canv->SetBorderSize (10); // Set margins to reasonable defaults canv->SetLeftMargin (0.18); canv->SetLeftMargin (0.17); canv->SetRightMargin (0.05); canv->SetTopMargin (0.12); canv->SetBottomMargin (0.18); // Setup a frame which makes sense canv->SetFrameFillStyle (0); canv->SetFrameLineStyle (0); canv->SetFrameBorderMode(0); canv->SetFrameBorderSize(10); canv->SetFrameFillStyle (0); canv->SetFrameLineStyle (0); canv->SetFrameBorderMode(0); canv->SetFrameBorderSize(10); canv->cd(); TPad *pad = 0; if (up){ pad = new TPad("upper","pad",0, 0.26 ,1 ,1); pad->SetBottomMargin(0.05); pad->SetTopMargin(0.09); pad->Draw(); pad->cd(); return pad; } else { pad = new TPad("lower","pad",0, 0,1 ,0.26); pad->SetTopMargin(0.05); pad->SetBottomMargin(0.24); pad->Draw(); pad->cd(); return pad; } };
void DrawALICELogo(Bool_t prel, Float_t x1, Float_t y1, Float_t x2, Float_t y2) { // correct for aspect ratio of figure plus aspect ratio of pad (coordinates are NDC!) x2 = x1 + (y2 - y1) * (466. / 523) * gPad->GetWh() * gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetWw()); // Printf("%f %f %f %f", x1, x2, y1, y2); TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo", x1, y1, x2, y2); myPadLogo->SetLeftMargin(0); myPadLogo->SetTopMargin(0); myPadLogo->SetRightMargin(0); myPadLogo->SetBottomMargin(0); myPadLogo->Draw(); myPadLogo->cd(); TASImage *myAliceLogo = new TASImage((prel) ? "~/alice_logo_preliminary.eps" : "~/alice_logo_performance.eps"); myAliceLogo->Draw(); }
void DrawALICELogo(Float_t x1, Float_t y1, Float_t x2, Float_t y2) { // Correct for aspect ratio of figure plus aspect ratio of pad. // Coordinates are NDC! x2 = x1 + (y2 - y1)*0.891*gPad->GetCanvas()->GetWindowHeight()*gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetCanvas()->GetWindowWidth()); TPad *myPadLogo = new TPad("myPadLogo","Pad for ALICE Logo", x1, y1, x2, y2); myPadLogo->SetLeftMargin(0); myPadLogo->SetTopMargin(0); myPadLogo->SetRightMargin(0); myPadLogo->SetBottomMargin(0); myPadLogo->Draw(); myPadLogo->cd(); TASImage *myAliceLogo = new TASImage("alice_logo_preliminary.eps"); myAliceLogo->Draw("same"); }
void DrawGraph(string name, TGraphErrors* graph) { TCanvas* canvas = new TCanvas(name.c_str(),"",1200,900); canvas->SetFillColor(kWhite); canvas->cd(); TPad* pad = new TPad(); // left right bottom top pad->SetMargin(0.15,0.05,0.15,0.05); pad->SetTicks(1,1); pad->SetFillColor(kWhite); pad->Draw(); pad->cd(); TGraphErrors* oldgraph = graph; graph = new TGraphErrors(*graph); delete oldgraph; float textsize = 0.055; graph->SetMinimum(0); graph->SetMaximum(100); graph->SetTitle(""); graph->GetXaxis()->SetTitle("#it{m}(#it{K^{#plus}K^{#minus}}) [MeV/#it{c}^{2}]"); graph->GetYaxis()->SetTitle("Efficiency [%]"); graph->SetLineColor(kBlack); graph->SetLineWidth(1); graph->SetMarkerSize(1); graph->SetMarkerStyle(8); graph->SetMarkerColor(kBlack); graph->Draw("AP"); graph->GetXaxis()->SetTitleSize(textsize*1.2); graph->GetYaxis()->SetTitleSize(textsize*1.2); graph->GetXaxis()->SetLabelSize(textsize); graph->GetYaxis()->SetLabelSize(textsize); graph->GetXaxis()->SetTitleFont(132); graph->GetYaxis()->SetTitleFont(132); graph->GetXaxis()->SetLabelFont(132); graph->GetYaxis()->SetLabelFont(132); graph->GetYaxis()->CenterTitle(); double _blurbx = 0.75; double _blurby = 0.80; string _blurbtext = "#splitline{LHCb}{#scale[0.75]{Preliminary}}"; TLatex* _blurb = new TLatex(_blurbx,_blurby,_blurbtext.c_str()); _blurb->SetTextFont(132); _blurb->SetTextColor(1); _blurb->SetNDC(kTRUE); _blurb->SetTextAlign(11); _blurb->SetTextSize(0.07); _blurb->Draw(); canvas->SaveAs((name+".pdf").c_str()); canvas->Write(); }
//___________________________ void RangeClicked() { TPad *pad = (TPad *) gCanvas->GetSelectedPad(); if (!pad) return; int eventtype = pad->GetEvent(); if ( pad->GetEvent() == 12 && !gMinimumIsSet && !gMaximumIsSet) { // kButton1Down //kButton1Double=61 //middle button 1 click = 12 //Get the abscissa gMin = pad->GetEventX(); gMin = pad->AbsPixeltoX(gMin); printf(" [ %.3f , \n",gMin); gMinimumIsSet = true ; gMaximumIsSet = false ; return ; // after this return the condition of the block below will be satisfied } if ( pad->GetEvent() == 12 && gMinimumIsSet && !gMaximumIsSet) { //Get the abscissa gMax = pad->GetEventX(); gMax = pad->AbsPixeltoX(gMax); //print the values if(gMin>=gMax) { cout << " WARNING : Min >= Max , "<< " choose a value > "<< gMin << " \n" << endl ; return ; } else printf(" [ %.3f , %.3f ]\n",gMin,gMax); //reset gMinimumIsSet=false ; gMaximumIsSet=false ; return ; } return ; }
void na49view() { // // This macro generates // a begin_html <a href="gif/na49canvas.gif">Canvas</a> end_html // with 2 views of the NA49 detector using the old obsolete geometry package. // Author: Rene Brun TCanvas *c1 = new TCanvas("c1", "The NA49 canvas", 200, 10, 700, 780); gBenchmark->Start("na49view"); TPad *all = new TPad("all", "A Global view of NA49", 0.02, 0.02, 0.48, 0.82, 28); TPad *tof = new TPad("tof", "One Time Of Flight element", 0.52, 0.02, 0.98, 0.82, 28); all->Draw(); tof->Draw(); TPaveLabel *na49title = new TPaveLabel(0.04, 0.86, 0.96, 0.98, "Two views of the NA49 detector"); na49title->SetFillColor(32); na49title->Draw(); // TFile *nageom = new TFile("na49.root"); if (!nageom || nageom->IsZombie()) return; TGeometry *n49 = (TGeometry *)gROOT->FindObject("na49"); n49->SetBomb(1.2); n49->cd(); // Set current geometry all->cd(); // Set current pad n49->Draw(); c1->Update(); tof->cd(); TNode *TOFR1 = n49->GetNode("TOFR1"); TOFR1->Draw(); c1->Update(); gBenchmark->Show("na49view"); // To have a better and dynamic view of any of these pads, // you can click with the middle button of your mouse to select it. // Then select "View with x3d" in the VIEW menu of the Canvas. // Once in x3d, you are in wireframe mode by default. // You can switch to: // - Hidden Line mode by typing E // - Solid mode by typing R // - Wireframe mode by typing W // - Stereo mode by clicking S (and you need special glasses) // - To leave x3d type Q }
void DrawGrid() { Int_t ncol = 100; Int_t nrow = 200; TPad *grid = new TPad("grid","",0,0,1,1); grid->Draw(); grid->cd(); grid->SetGrid(); grid->SetFillStyle(4000); grid->SetFrameFillStyle(0); TH2 *hgrid = new TH2C("hgrid","", ncol+1, -5, ncol+5, nrow, -5, nrow-1+5); hgrid->Draw(); hgrid->GetXaxis()->SetNdivisions(6,100); hgrid->GetYaxis()->SetNdivisions(200); hgrid->GetYaxis()->SetLabelOffset(999.); hgrid->GetXaxis()->SetLabelOffset(999.); }
TCanvas* example_plot( int iPeriod, int iPos ) { // if( iPos==0 ) relPosX = 0.12; int W = 800; int H = 600; // // Simple example of macro: plot with CMS name and lumi text // (this script does not pretend to work in all configurations) // iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV) + 4*(0/1 13 TeV) // For instance: // iPeriod = 3 means: 7 TeV + 8 TeV // iPeriod = 7 means: 7 TeV + 8 TeV + 13 TeV // Initiated by: Gautier Hamel de Monchenault (Saclay) // Updated by: Dinko Ferencek (Rutgers) // int H_ref = 600; int W_ref = 800; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.12*H_ref; float L = 0.12*W_ref; float R = 0.04*W_ref; TString canvName = "FigExample_"; canvName += W; canvName += "-"; canvName += H; canvName += "_"; canvName += iPeriod; if( writeExtraText ) canvName += "-prelim"; if( iPos%10==0 ) canvName += "-out"; else if( iPos%10==1 ) canvName += "-left"; else if( iPos%10==2 ) canvName += "-center"; else if( iPos%10==3 ) canvName += "-right"; TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H); canv->SetFillColor(0); canv->SetBorderMode(0); canv->SetFrameFillStyle(0); canv->SetFrameBorderMode(0); canv->SetLeftMargin( L/W ); canv->SetRightMargin( R/W ); canv->SetTopMargin( T/H ); canv->SetBottomMargin( B/H ); canv->SetTickx(0); canv->SetTicky(0); TH1* h = new TH1F("h","h",40,70,110); h->GetXaxis()->SetNdivisions(6,5,0); h->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV)"); h->GetYaxis()->SetNdivisions(6,5,0); h->GetYaxis()->SetTitleOffset(1); h->GetYaxis()->SetTitle("Events / 0.5 GeV"); h->SetMaximum( 260 ); if( iPos==1 ) h->SetMaximum( 300 ); h->Draw(); int histLineColor = kOrange+7; int histFillColor = kOrange-2; float markerSize = 1.0; { TLatex latex; int n_ = 2; float x1_l = 0.92; float y1_l = 0.60; float dx_l = 0.30; float dy_l = 0.18; float x0_l = x1_l-dx_l; float y0_l = y1_l-dy_l; TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l ); // legend->SetFillColor( kGray ); legend->Draw(); legend->cd(); float ar_l = dy_l/dx_l; float x_l[1]; float ex_l[1]; float y_l[1]; float ey_l[1]; // float gap_ = 0.09/ar_l; float gap_ = 1./(n_+1); float bwx_ = 0.12; float bwy_ = gap_/1.5; x_l[0] = 1.2*bwx_; // y_l[0] = 1-(1-0.10)/ar_l; y_l[0] = 1-gap_; ex_l[0] = 0; ey_l[0] = 0.04/ar_l; TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l ); gStyle->SetEndErrorSize(0); gr_l->SetMarkerSize(0.9); gr_l->Draw("0P"); latex.SetTextFont(42); latex.SetTextAngle(0); latex.SetTextColor(kBlack); latex.SetTextSize(0.25); latex.SetTextAlign(12); TLine line_; TBox box_; float xx_ = x_l[0]; float yy_ = y_l[0]; latex.DrawLatex(xx_+1.*bwx_,yy_,"Data"); yy_ -= gap_; box_.SetLineStyle( kSolid ); box_.SetLineWidth( 1 ); // box_.SetLineColor( kBlack ); box_.SetLineColor( histLineColor ); box_.SetFillColor( histFillColor ); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); box_.SetFillStyle(0); box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 ); latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)"); canv->cd(); } { // Observed data TFile file_("histo.root","READ"); TH1F *data = static_cast<TH1F*>(file_.Get("data")->Clone()); data->SetDirectory(0); data->SetMarkerStyle(20); data->SetMarkerSize(markerSize); TH1F *MC = static_cast<TH1F*>(file_.Get("MC")->Clone()); MC->SetDirectory(0); MC->SetLineColor(histLineColor); MC->SetFillColor(histFillColor); MC->Draw("histsame"); data->Draw("esamex0"); file_.Close(); } // writing the lumi information and the CMS "logo" CMS_lumi( canv, iPeriod, iPos ); canv->Update(); canv->RedrawAxis(); canv->GetFrame()->Draw(); canv->Print(canvName+".pdf",".pdf"); canv->Print(canvName+".png",".png"); return canv; }
TCanvas *drawRatioPlot(TH1D *prediction, TH1D *sr, TH1D *data, TString xTitle, TString filename, double ecaloCut){ gStyle -> SetPadLeftMargin(0.20); data->SetMarkerStyle(20); data->SetMarkerColor(kGreen); data->SetLineColor(kGreen); TCanvas *c = new TCanvas("c"+filename,"c",0,0,500,500); float y = 0.3; TPad *pad1 = new TPad("pad1", "Control Plots 1", 0.01, y, 0.99, 0.99); TPad *padRatio = new TPad("rp1", "Ratio1", 0.01, 0.01, 0.99, y-0.01); pad1->SetNumber(100); pad1->SetTicks(0,1); cout<<"number pad1 = "<<pad1->GetNumber()<<endl; cout<<"number padRatio = "<<padRatio->GetNumber()<<endl; TH1D *ratio = 0; //ratio = (TH1D*) sr->Clone(); //ratio->Divide(prediction); ratio = (TH1D*) prediction->Clone(); ratio->Divide(data); for(int i=1; i<=ratio->GetNbinsX();i++){ if(ratio->GetBinContent(i) != 0){ cout<<"N in CR in "<<i<<". bin ="<<prediction->GetBinContent(i)<<endl; cout<<"N in SR in "<<i<<". bin ="<<sr->GetBinContent(i)<<endl; cout<<"Rel. difference in "<<i<<". bin ="<<(1./ratio->GetBinContent(i)-1.)*100<<"%"<<endl; } else if(sr->GetBinContent(i) == 0 && prediction->GetBinContent(i) !=0) cout<<"Scaling Factor in "<<i<<". bin <"<<prediction->GetBinContent(i)/1.15<<" +/- "<<ratio->GetBinError(i)<<endl; else if(sr->GetBinContent(i) != 0 && prediction->GetBinContent(i) ==0) cout<<"Scaling Factor in "<<i<<". bin <"<<(sr->GetEntries()/prediction->GetEntries())/sr->GetBinContent(i)<<" +/- "<<ratio->GetBinError(i)<<endl; } ratio->GetYaxis()->SetTitle("#frac{CR (MC)}{CR (data)}"); ratio->SetTitle(""); ratio->SetLabelSize(0.1,"X"); ratio->SetLabelSize(0.1,"Y"); ratio->SetTitleOffset(0.5,"Y"); ratio->SetTitleSize(0.15,"Y"); padRatio->cd(); //ratio->GetYaxis()->SetRangeUser(0,2); ratio->Draw("e"); // Draw line at one! float xmin = ratio->GetXaxis()->GetXmin(); float xmax = ratio->GetXaxis()->GetXmax(); TLine *line = new TLine(xmin,1,xmax,1); line->SetLineWidth(2); line->Draw("same"); padRatio->Modified(); TLegend *leg = new TLegend(0.5,0.7,0.9,0.9); leg->AddEntry(sr,"SR (MC)","l"); leg->AddEntry(prediction,"lepton CR (MC)","pel"); pad1->cd(); pad1->SetLogy(); // pad1->SetLogx(); sr->SetLineColor(kRed); sr->SetMarkerColor(kRed); sr->SetMarkerStyle(20); sr->SetTitle(""); prediction->SetMarkerStyle(20); prediction->SetTitle(""); prediction->GetXaxis()->SetTitle(xTitle); sr->GetXaxis()->SetTitle(xTitle); prediction->SetTitleSize(0.07,"X"); prediction->GetXaxis()->SetTitleOffset(0.7); sr->SetTitleSize(0.07,"X"); sr->GetXaxis()->SetTitleOffset(0.7); double maximum = 0; double minimum = 1000000; if(sr->GetMinimum()!=0 && sr->GetMinimum()<minimum){ minimum=sr->GetMinimum()*0.5; } if(prediction->GetMinimum()!=0 && prediction->GetMinimum()<minimum){ minimum=prediction->GetMinimum()*0.5; } if(data->GetMinimum()!=0 && data->GetMinimum()<minimum){ minimum=data->GetMinimum()*0.5; } if(sr->GetMaximum()>maximum){ maximum=sr->GetMaximum()*2.5; } if(prediction->GetMaximum()>maximum){ maximum=prediction->GetMaximum()*2.5; } if(data->GetMaximum()>maximum){ maximum=data->GetMaximum()*2.5; } prediction->GetYaxis()->SetRangeUser(minimum,maximum); ratio->GetYaxis()->SetRangeUser(0,2); prediction->Draw("e"); sr->Draw("e same"); leg->AddEntry(data,"lepton CR (data)","pel"); data->Draw("e same"); leg->Draw("same"); TLatex* info1 = new TLatex(); info1->SetTextFont(132); info1-> SetNDC(); info1->SetTextSize(0.06); info1->DrawLatex(0.55,0.62,Form("E_{calo}<%.0fGeV",ecaloCut)); // Draw both pads to canvas c->cd(); pad1->Draw(); padRatio->SetGridy(); padRatio->Draw(); c->SaveAs(filename); return c; }
// draws the decay vertices of the Lambda_s void genDisplay(std::string fullPath, int iGen, int iReco = -1, bool savePdf = false) { const int fVerbose(0); setTDRStyle(); //gStyle->SetOptStat(112211); gStyle->SetOptStat(0); gStyle->SetPalette(1); // Canvases crz = new TCanvas("crz","crz",1000,600); TPad* padrz = (TPad*)crz->cd(1); setPadMargins(padrz, 0.02, 0.05, 0.02, 0.05); crphi = new TCanvas("crphi","crphi",600,600); TPad* padrphi = (TPad*)crphi->cd(1); setPadMargins(padrphi, 0.02, 0.05, 0.02, 0.05); // Open file TFile *f = TFile::Open(fullPath.c_str()); if (f==0) { cout << "File " << fullPath << " not found -- exiting" << endl; return; } if(fVerbose>0) cout << "Succesfully opened file " << fullPath << endl; // Get TTree with GenEvents TTree* tgen = (TTree*) f->Get("genevents"); if(fVerbose>0) cout << "Got TTree with " << tgen->GetEntries() << " entries" << endl; // Do a cut, if needed tgen->Draw(">>lst","ptmu1>3&&ptmu2>3&&TMath::Abs(etamu1)<2.5&&TMath::Abs(etamu2)<2.5"); TEventList *lst; lst = (TEventList*)gDirectory->Get("lst"); tgen->SetEventList(lst); // Get TTree with iRecoEvents TTree* treco = (TTree*) f->Get("events"); if(fVerbose>0) cout << "Got TTree with " << treco->GetEntries() << " entries" << endl; // Do plots const int nbins(30); const double rangeR(30), rangeZ(100); // standard //const double rangeR(60), rangeZ(200); // zoomed out //const double rangeR(100), rangeZ(200); // zoomed in //const double rangeR(12), rangeZ(30); // zoomed further in padrz->cd(); TH2F *hrz = new TH2F("hdisp","", nbins,-rangeZ,rangeZ,nbins,-rangeR,rangeR); hrz->Draw(); padrphi->cd(); TH2F *hrphi = new TH2F("hdisp","", nbins,-rangeR,rangeR,nbins,-rangeR,rangeR); hrphi->Draw(); // add tracker padrz->Modified(); padrz->Update(); drawTrackerRZ(padrz); padrphi->Modified(); padrphi->Update(); drawTrackerRPhi(padrphi); // set branch addresses for gentree double vrl0,vxl0,vyl0,vzl0,vrlb,vxlb,vylb,vzlb; double pmu1,phimu1,etamu1,pmu2,phimu2,etamu2; double ppr,ppi,phipr,phipi,etapr,etapi; tgen->SetBranchAddress("vrl0",&vrl0); tgen->SetBranchAddress("vxl0",&vxl0); tgen->SetBranchAddress("vyl0",&vyl0); tgen->SetBranchAddress("vzl0",&vzl0); tgen->SetBranchAddress("vrlb",&vrlb); tgen->SetBranchAddress("vxlb",&vxlb); tgen->SetBranchAddress("vylb",&vylb); tgen->SetBranchAddress("vzlb",&vzlb); tgen->SetBranchAddress("pmu1",&pmu1); tgen->SetBranchAddress("etamu1",&etamu1); tgen->SetBranchAddress("phimu1",&phimu1); tgen->SetBranchAddress("pmu2",&pmu2); tgen->SetBranchAddress("etamu2",&etamu2); tgen->SetBranchAddress("phimu2",&phimu2); tgen->SetBranchAddress("ppr",&ppr); tgen->SetBranchAddress("etapr",&etapr); tgen->SetBranchAddress("phipr",&phipr); tgen->SetBranchAddress("ppi",&ppi); tgen->SetBranchAddress("etapi",&etapi); tgen->SetBranchAddress("phipi",&phipi); int genrun, genls, genevt; tgen->SetBranchAddress("run",&genrun); tgen->SetBranchAddress("LS",&genls); tgen->SetBranchAddress("event",&genevt); // set branch addresses for recotree double rvrl0,rvxl0,rvyl0,rvzl0,rvrlb,rvxlb,rvylb,rvzlb; double rpmu1,retamu1,rphimu1,rpmu2,retamu2,rphimu2; double rppr,rppi,retapr,retapi,rphipr,rphipi; treco->SetBranchAddress("vrl0",&rvrl0); treco->SetBranchAddress("vxl0",&rvxl0); treco->SetBranchAddress("vyl0",&rvyl0); treco->SetBranchAddress("vzl0",&rvzl0); treco->SetBranchAddress("vrlb",&rvrlb); treco->SetBranchAddress("vxlb",&rvxlb); treco->SetBranchAddress("vylb",&rvylb); treco->SetBranchAddress("vzlb",&rvzlb); treco->SetBranchAddress("rpt1m",&rpmu1); treco->SetBranchAddress("reta1m",&retamu1); treco->SetBranchAddress("rphi1m",&rphimu1); treco->SetBranchAddress("rpt2m",&rpmu2); treco->SetBranchAddress("reta2m",&retamu2); treco->SetBranchAddress("rphi2m",&rphimu2); treco->SetBranchAddress("rptpr",&rppr); treco->SetBranchAddress("retapr",&retapr); treco->SetBranchAddress("rphipr",&rphipr); treco->SetBranchAddress("rptpi",&rppi); treco->SetBranchAddress("retapi",&retapi); treco->SetBranchAddress("rphipi",&rphipi); drawArrowLegend(padrz); drawArrowLegend(padrphi,.8); // write the event indices writeLatex(padrz,.1,.9,("iGen: " + toString(iGen)).c_str()); writeLatex(padrphi,.1,.9,("iGen: " + toString(iGen)).c_str()); if (iReco >= 0) { writeLatex(padrz,.1,.85,("iReco: " + toString(iReco)).c_str()); writeLatex(padrphi,.1,.85,("iReco: " + toString(iReco)).c_str()); } if (iGen<0) return; if (iGen>tgen->GetEntries()) return; if (iReco>treco->GetEntries()) return; tgen->GetEntry(iGen); cout << "iGen: " << iGen << " - " << genrun << " " << genls << " " << genevt << endl; padrz->cd(); drawEventZR(vrlb, vzlb, vrl0, vzl0, pmu1, etamu1, pmu2, etamu2, ppr, etapr, ppi, etapi, 0); padrphi->cd(); drawEventRPhi(vxlb, vylb, vxl0, vyl0, pmu1, phimu1, pmu2, phimu2, ppr, phipr, ppi, phipi, 0); if(iReco>=0) { treco->GetEntry(iReco); cout << "iReco: " << iReco << endl; padrz->cd(); drawEventZR(rvrlb, rvzlb, rvrl0, rvzl0, rpmu1, retamu1, rpmu2, retamu2, rppr, retapr, rppi, retapi, 1); padrphi->cd(); drawEventRPhi(rvxlb, rvylb, rvxl0, rvyl0, rpmu1, rphimu1, rpmu2, rphimu2, rppr, rphipr, rppi, rphipi, 1); cout << phimu1 << " " << rphimu1 << endl; } if(savePdf) { padrz->Update(); padrphi->Update(); std::string filename = "genDisplay_" + toString(iGen); if(iReco >= 0) filename += "_" + toString(iReco); crz->SaveAs((filename+"_rz.pdf").c_str()); crphi->SaveAs((filename+"_rphi.png").c_str()); // weiss der Geier warum auf PDF die Kreise und die Skala fehlen... } return; }
void QA_Draw_Calorimeter_Sum_TrackProjEP( const char * qa_file_name_new = "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi-_eta0.30_32GeV-0000.root_qa.root", const char * qa_file_name_ref = "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi+_eta0.30_32GeV-0000.root_qa.root") //QA_Draw_Calorimeter_Sum_TrackProjEP(const char * qa_file_name_new = // "data/G4sPHENIXCells_100e24GeV.root_qa.root", // const char * qa_file_name_ref = // "data/G4Hits_sPHENIX_e-_eta0_24GeV-0000.root_qa.root") { SetOKStyle(); gStyle->SetOptStat(0); gStyle->SetOptFit(1111); TVirtualFitter::SetDefaultFitter("Minuit2"); TFile * qa_file_new = new TFile(qa_file_name_new); assert(qa_file_new->IsOpen()); TFile * qa_file_ref = NULL; if (qa_file_name_ref) { qa_file_ref = new TFile(qa_file_name_ref); assert(qa_file_ref->IsOpen()); } // obtain normalization double Nevent_new = 1; double Nevent_ref = 1; // obtain normalization double Ntrack_new = 0; double Ntrack_ref = 0; if (qa_file_new) { TH1D * h_norm = (TH1D *) qa_file_new->GetObjectChecked( TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D"); assert(h_norm); Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event")); Ntrack_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track")); } if (qa_file_ref) { TH1D * h_norm = (TH1D *) qa_file_ref->GetObjectChecked( TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D"); assert(h_norm); Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event")); Ntrack_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track")); } TCanvas *c1 = new TCanvas("QA_Draw_Calorimeter_Sum_TrackProjEP", "QA_Draw_Calorimeter_Sum_TrackProjEP", 1800, 600); c1->Divide(3, 1); int idx = 1; TPad * p; p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogy(); if (Ntrack_new>0) { TH1F * h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_TrackProj_3x3Tower_EP", "TH1F"); assert(h_new); h_new->Sumw2(); h_new->Scale(1. / Ntrack_new); TH1F * h_ref = NULL; if (qa_file_ref) { TH1F * h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_TrackProj_3x3Tower_EP", "TH1F"); assert(h_ref); h_ref->Scale(1. / Ntrack_ref); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Count / track / bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogy(); if (Ntrack_new>0) { TH1F * h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_TrackProj_5x5Tower_EP", "TH1F"); assert(h_new); h_new->Sumw2(); h_new->Scale(1. / Ntrack_new); TH1F * h_ref = NULL; if (qa_file_ref) { TH1F * h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_TrackProj_5x5Tower_EP", "TH1F"); assert(h_ref); h_ref->Scale(1. / Ntrack_ref); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Count / track / bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogy(); if (Nevent_new>0) { TH1F * h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F"); if (h_new) { h_new->Sumw2(); h_new->Scale(1. / Nevent_new); TH1F * h_ref = NULL; if (qa_file_ref) { TH1F * h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F"); assert(h_ref); h_ref->Scale(1. / Nevent_ref); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Count / event / bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } } PutInputFileName(c1,0.07, qa_file_name_new, qa_file_name_ref); SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true); }
int makeInvMassHistosNoBGKK(){ //Set global style stuff gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetCanvasColor(kWhite); gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); gStyle->SetTitleBorderSize(0); gStyle->SetOptStat(0); gStyle->SetOptFit(1); gStyle->SetErrorX(0); gStyle->SetTitleW(0.9); gStyle->SetTitleSize(0.05, "xyz"); gStyle->SetTitleSize(0.06, "h"); int NUM_PT_BINS = 20; int NUM_MASS_BINS = 1000; double MASS_LOW = 0.0; double MASS_HIGH = 2.0; string particles [8]; particles[0] = "K*^{+} + K*^{0}"; particles[1] = "K*^{-} + #bar{K}*^{0}"; particles[2] = "K*^{+}"; particles[3] = "K*^{-}"; particles[4] = "K*^{0}"; particles[5] = "#bar{K}*^{0}"; particles[6] = "K*^{0} + #bar{K}*^{0}"; particles[7] = "K*^{+} + K*^{-}"; //at decay point // string folder = "/Users/jtblair/Downloads/kstar_data/decayed/pt02/"; //reconstructed string folder = "/Users/jtblair/Downloads/kstar_data/reconstructed/pt02/"; string files[20]; files[0] = "invm_[0.0,0.2].dat"; files[1] = "invm_[0.2,0.4].dat"; files[2] = "invm_[0.4,0.6].dat"; files[3] = "invm_[0.6,0.8].dat"; files[4] = "invm_[0.8,1.0].dat"; files[5] = "invm_[1.0,1.2].dat"; files[6] = "invm_[1.2,1.4].dat"; files[7] = "invm_[1.4,1.6].dat"; files[8] = "invm_[1.6,1.8].dat"; files[9] = "invm_[1.8,2.0].dat"; files[10] = "invm_[2.0,2.2].dat"; files[11] = "invm_[2.2,2.4].dat"; files[12] = "invm_[2.4,2.6].dat"; files[13] = "invm_[2.6,2.8].dat"; files[14] = "invm_[2.8,3.0].dat"; files[15] = "invm_[3.0,3.2].dat"; files[16] = "invm_[3.2,3.4].dat"; files[17] = "invm_[3.4,3.6].dat"; files[18] = "invm_[3.6,3.8].dat"; files[19] = "invm_[3.8,4.0].dat"; /* string files[8]; files[0] = "invm_[0.0,0.5].dat"; files[1] = "invm_[0.5,1.0].dat"; files[2] = "invm_[1.0,1.5].dat"; files[3] = "invm_[1.5,2.0].dat"; files[4] = "invm_[2.0,2.5].dat"; files[5] = "invm_[2.5,3.0].dat"; files[6] = "invm_[3.0,3.5].dat"; files[7] = "invm_[3.5,4.0].dat"; */ Int_t PARTICLE_NUM = 5; TFile *output = new TFile("20170721_KKbarAdded2_fixedwidth42_recon_pf100_scaled_error05.root", "RECREATE"); TH1D *kstar0mass = new TH1D("kstar0mass", Form("Fit value of M*_{0} vs. p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS, 0.0, 4.0); TH1D *kstar0width = new TH1D("kstar0width", Form("#Gamma_{tot}(M=M*_{0}) vs p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS, 0.0, 4.0); TH1D *kstar0collWidth = new TH1D("kstar0collWidth", Form("Fit value of #Gamma_{coll} component vs. p_{T} for %s", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS,0.0, 4.0); TH1D *kstar0decWidth = new TH1D("kstar0decWidth", Form("#Gamma_{dec}(M=M*_{0}) component vs. p_{T} for %s;p_{T} (GeV/c);Width (GeV/c^2)", particles[PARTICLE_NUM].c_str()), NUM_PT_BINS,0.0, 4.0); kstar0mass->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0mass->GetYaxis()->SetTitle("Mass (GeV/c^{2})"); kstar0width->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0width->GetYaxis()->SetTitle("Width (GeV/c^2)"); kstar0collWidth->GetXaxis()->SetTitle("p_{T} (GeV/c)"); kstar0collWidth->GetYaxis()->SetTitle("Width (GeV/c^2)"); kstar0mass->SetStats(kFALSE); kstar0width->SetStats(kFALSE); kstar0collWidth->SetStats(kFALSE); kstar0decWidth->SetStats(kFALSE); TF1 *massline = new TF1("massline", "[0]", 0.0, 4.0); massline->SetParameter(0, 0.892); massline->SetLineColor(2); massline->SetLineStyle(7); TF1 *widthline = new TF1("widthline", "[0]", 0.0, 4.0); widthline->SetParameter(0, 0.042); double mass = 0.0, width = 0.0, collWidth = 0.0, massBG=0.0; double massError = 0.0, widthError= 0.0, collWidthError = 0.0, massBGError=0.0; TCanvas *canvas[9]; TCanvas *diffCanvas[9]; TPaveStats *st; TPad *pad; //ofstream integrals; //integrals.open("kstarbar_integrals.txt"); for(int nfile = 0; nfile < NUM_PT_BINS; nfile++){ double meanPT = (double)(nfile*2+1)/10.0; string filename = folder+files[nfile]; string ptLower = filename.substr(filename.find("[")+1, 3); string ptHigher = filename.substr(filename.find(",")+1, 3); TH1D* histos[8]; TH1D* newHistos[8]; TH1D* diffHistos[8]; TH1D* bg[8]; for(int i=0; i<8; i++){ if(nfile<5){ histos[i] = new TH1D(Form("ptbin0%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), NUM_MASS_BINS, MASS_LOW, MASS_HIGH); newHistos[i] = new TH1D(Form("newptbin0%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), 250, MASS_LOW, MASS_HIGH); }else{ histos[i] = new TH1D(Form("ptbin%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), NUM_MASS_BINS, MASS_LOW, MASS_HIGH); newHistos[i] = new TH1D(Form("newptbin%dparticle%d",nfile*2+1, i), Form("Invariant Mass for (%s), %s < p_{T} < %s",particles[i].c_str(), ptLower.c_str(), ptHigher.c_str()), 250, MASS_LOW, MASS_HIGH); } histos[i]->GetXaxis()->SetTitle("Invariant Mass (GeV/c^{2})"); histos[i]->GetYaxis()->SetTitle("Counts"); } ifstream input; input.open(filename.c_str()); string line = ""; if(input.good()){ getline(input, line); } double massBin=0.0; double invMass[8]; for(int i=0; i<8; i++){ invMass[i] = 0.0; } int lineNumber = 1; while(1){ input >> massBin >> invMass[0] >> invMass[1] >> invMass[2] >> invMass[3] >> invMass[4] >> invMass[5] >> invMass[6] >> invMass[7]; if(!input.good())break; for(int i =0; i<8; i++){ histos[i]->SetBinContent(lineNumber, invMass[i]/500.0); } if(lineNumber > 440 && lineNumber < 460 && nfile==6){ // printf("mass: %.12f invMass[6]: %.12f\n", massBin, invMass[6]); } lineNumber++; } printf("****** Fits for file: %s ******\n", filename.c_str()); for(int i=PARTICLE_NUM; i<PARTICLE_NUM+1; i++){ //add the K*0 distribution to the K*0bar (K*0 = 4 for decay, K*0 = 3 for reconstructed) histos[i]->Add(histos[3]); if(nfile==0){ canvas[i] = new TCanvas(Form("c%i", i),Form("c%i", i), 0,0,900,900); canvas[i]->Divide(5,4); diffCanvas[i] = new TCanvas(Form("diffC%i", i),Form("diffC%i", i), 0,0,900,900); diffCanvas[i]->Divide(5,4); } //rebin //histos[i]->Sumw2(); histos[i]->Rebin(4); //Fixing the errors to a percentage of the signal region: for(int ibin=1; ibin < histos[i]->GetNbinsX(); ibin++){ histos[i]->SetBinError(ibin, histos[i]->GetBinContent((int)(0.892*(250.0/2.0)))*0.05); newHistos[i]->SetBinContent(ibin, histos[i]->GetBinContent(ibin)); newHistos[i]->SetBinError(ibin, histos[i]->GetBinError(ibin)); } pad = (TPad*)canvas[i]->cd(nfile+1); histos[i]->SetLineColor(1); histos[i]->SetLineWidth(1); histos[i]->GetXaxis()->SetRangeUser(0.7, 1.2); histos[i]->GetYaxis()->SetRangeUser(0, 1.5*histos[i]->GetBinContent(histos[i]->GetMaximumBin())); //histos[i]->SetStats(kFALSE); //histos[i]->Draw("HIST"); printf("mean PT: %f\n", meanPT); TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), FitFunRelBW, 0.68, 1.05, 5); //TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), "gaus(0)", 0.86, 0.92); fit->SetParNames("BW Area", "Mass", "Width", "PT", "Temp"); fit->SetParameters(TMath::Power(10.0, (float)(nfile)/1.7), 0.89, 0.1, 0.5, 0.130); //fit->SetParNames("BW Area", "Mass", "Width"); //fit->SetParameters(100, 0.89, 0.0474); //fit->SetParLimits(0, -10, 1.5e9); Float_t max = histos[i]->GetXaxis()->GetBinCenter(histos[i]->GetMaximumBin()); //if(max < 0.91 && max > 0.892){ // fit->SetParLimits(1, max-0.001, max+0.001); //}else{ fit->SetParLimits(1, 0.82, 0.98); //} //fit->SetParLimits(2, 0.005, 0.15); fit->FixParameter(2, 0.042); fit->FixParameter(3, meanPT); //fit->SetParLimits(4, 0.05, 0.2); fit->FixParameter(4, 0.100001); fit->SetLineColor(2); printf("%s\n", fit->GetName()); histos[i]->Fit(Form("fitPTbin%d00particle%d", nfile*2+1, i), "BRIM", "SAME"); TVirtualFitter *fitter = TVirtualFitter::GetFitter(); histos[i]->SetStats(1); histos[i]->Draw(); gPad->Update(); pad->Update(); st = (TPaveStats*)histos[i]->FindObject("stats"); st->SetX1NDC(0.524); st->SetY1NDC(0.680); st->SetX2NDC(0.884); st->SetY2NDC(0.876); //fit->Draw("SAME"); //histos[i]->Draw(); gPad->Update(); pad->Update(); printf("\n"); diffHistos[i] = (TH1D*)histos[i]->Clone(Form("diffPTbin%d00particl%d", nfile*2+1, i)); diffHistos[i]->Add(fit, -1); diffCanvas[i]->cd(nfile+1); diffHistos[i]->Draw("HIST E"); diffHistos[i]->Write(); //counting bins Float_t integral = histos[i]->Integral(1, 500)*500.0; //integrals << integral <<" \n"; histos[i]->Write(); fit->Write(); //Do mass and width vs. pT plots just for K*0 if(i==PARTICLE_NUM){ mass = fit->GetParameter(1); massError = fit->GetParError(1); collWidth = fit->GetParameter(2); collWidthError = fit->GetParError(2); width = Gamma(mass, collWidth); kstar0mass->SetBinContent(nfile+1, mass); kstar0mass->SetBinError(nfile+1, massError); kstar0width->SetBinContent(nfile+1, width); Double_t widthError = TMath::Sqrt((GammaDerivative(mass)**2)*fitter->GetCovarianceMatrixElement(1,1) + fitter->GetCovarianceMatrixElement(2,2) + 2.0*GammaDerivative(mass)*fitter->GetCovarianceMatrixElement(1,2)); kstar0width->SetBinError(nfile+1, widthError); kstar0collWidth->SetBinContent(nfile+1, collWidth); kstar0collWidth->SetBinError(nfile+1, collWidthError); kstar0decWidth->SetBinContent(nfile+1, width - collWidth); Double_t decWidthError = TMath::Sqrt((GammaDerivative(mass)**2)*fitter->GetCovarianceMatrixElement(1,1)); kstar0decWidth->SetBinError(nfile+1, decWidthError); if(nfile==4){ TCanvas *singlecanvas = new TCanvas("singlecanvas", "singlecanvas", 0,0,600,600); singlecanvas->cd(); printf("Got here! \n"); histos[i]->Draw("HIST E SAME"); fit->SetLineColor(8); fit->SetLineStyle(1); fit->Draw("SAME"); if(fitter){ printf("sig11: %f, sig12: %f, sig21: %f, sig22: %f GammaDer(0.8): %f GammaDer(0.85): %f GammaDer(0.9): %f\n", TMath::Sqrt(fitter->GetCovarianceMatrixElement(1,1)), fitter->GetCovarianceMatrixElement(2,1), fitter->GetCovarianceMatrixElement(1,2), TMath::Sqrt(fitter->GetCovarianceMatrixElement(2,2)), GammaDerivative(0.8), GammaDerivative(0.85), GammaDerivative(0.9)); } } } } printf("************************************************************\n"); } //integrals.close(); /* TH2D *gammaPlot = new TH2D("gammaPlot", "#Gamma_{tot}(M_{0}*);M_{0}*;#Gamma_{coll};#Gamma_{tot}", 100, 0.82, 0.9, 100, 0.0, 0.08); for(int im = 0; im<100; im++){ for(int ig = 0; ig < 100; ig++){ gammaPlot->SetBinContent(im+1, ig+1, Gamma(((0.9-0.82)/(100.0))*((double)(im)) + 0.82, ((0.08)/100.0)*((double)(ig)))); } } TH1D *gammaMassDpnd = gammaPlot->ProjectionX("gammaMassDpnd"); */ TCanvas *masscanvas = new TCanvas("masscanvas", "masscanvas", 50,50, 600, 600); masscanvas->cd(); kstar0mass->Draw(); massline->Draw("SAME"); masscanvas->Write(); for(int i=PARTICLE_NUM; i<PARTICLE_NUM+1; i++){ canvas[i]->Write(); } kstar0mass->Write(); kstar0collWidth->Write(); kstar0decWidth->Write(); kstar0width->Write(); // gammaPlot->Write(); // gammaMassDpnd->Write(); }
//______________________________________________________________________________ void KVCanvas::HandleInput(EEventType event, Int_t px, Int_t py) { // Handle Input Events. // // Handle input events, like button up/down in current canvas. if (fFreezed) return; TPad* pad; TPad* prevSelPad = (TPad*) fSelectedPad; TObject* prevSelObj = fSelected; fPadSave = (TPad*)gPad; cd(); // make sure this canvas is the current canvas fEvent = event; fEventX = px; fEventY = py; Int_t sign = 0; Bool_t sendOrder = true; if (fHasDisabledClasses && fSelected) { if (fDisabledClasses.Contains(fSelected->ClassName())) sendOrder = false; } if (fHasDisabledObject && fSelected) { if (fDisabledObjects.Contains(fSelected)) sendOrder = false; } switch (event) { case kMouseMotion: // highlight object tracked over pad = Pick(px, py, prevSelObj); if (!pad) return; EnterLeave(prevSelPad, prevSelObj); gPad = pad; // don't use cd() we will use the current // canvas via the GetCanvas member and not via // gPad->GetCanvas if (sendOrder) fSelected->ExecuteEvent(event, px, py); RunAutoExec(); if (fAgeOfEmpire && (fSelected->InheritsFrom("TH2"))) { TH2* TheHisto = (TH2*) FindHisto();//fSelected; Double_t size = 0.4 - 0.35 * fVenerMode; Int_t dX = 0; Int_t dY = 0; Double_t ppx = AbsPixeltoX(px); Double_t ppy = AbsPixeltoY(py); TAxis* ax = TheHisto->GetXaxis(); Int_t X0 = ax->GetFirst(); Int_t X1 = ax->GetLast(); Int_t NbinsX = ax->GetNbins(); px = ax->FindBin(ppx); Double_t ddX = (X1 + X0) * 0.5 - px; Double_t distX = TMath::Abs(ddX) / (X1 - X0); if (distX >= 0.5) return; TAxis* ay = TheHisto->GetYaxis(); Int_t Y0 = ay->GetFirst(); Int_t Y1 = ay->GetLast(); Int_t NbinsY = ay->GetNbins(); py = ay->FindBin(ppy); Double_t ddY = (Y1 + Y0) * 0.5 - py; Double_t distY = TMath::Abs(ddY) / (Y1 - Y0); if (distY >= 0.5) return; if ((distX <= size) && (distY <= size)) return; dX = TMath::Nint(ddX * (0.05 + 0.05 * fVenerMode)); dY = TMath::Nint(ddY * (0.05 + 0.05 * fVenerMode)); if (TMath::Abs(dX) < 1) dX = TMath::Sign(1., ddX); if (TMath::Abs(dY) < 1) dY = TMath::Sign(1., ddY); Bool_t up = false; if ((X0 - dX > 0) && (X1 - dX < NbinsX)) { ax->SetRange(X0 - dX, X1 - dX); up = true; } if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) { ay->SetRange(Y0 - dY, Y1 - dY); up = true; } if (up) { Modified(); Update(); } } break; case kMouseEnter: // mouse enters canvas if (!fDoubleBuffer) FeedbackMode(kTRUE); break; case kMouseLeave: // mouse leaves canvas { // force popdown of tooltips TObject* sobj = fSelected; TPad* spad = fSelectedPad; fSelected = 0; fSelectedPad = 0; EnterLeave(prevSelPad, prevSelObj); fSelected = sobj; fSelectedPad = spad; if (!fDoubleBuffer) FeedbackMode(kFALSE); } break; case kButton1Double: // triggered on the second button down within 350ms and within // 3x3 pixels of the first button down, button up finishes action case kButton1Down: // find pad in which input occured pad = Pick(px, py, prevSelObj); if (!pad) return; gPad = pad; // don't use cd() because we won't draw in pad // we will only use its coordinate system if (fSelected) { FeedbackMode(kTRUE); // to draw in rubberband mode fSelected->ExecuteEvent(event, px, py); RunAutoExec(); if (fSelected->InheritsFrom("TH2")) { oldx = GetEventX(); oldy = GetEventY(); xmin = AbsPixeltoX(oldx); ymin = AbsPixeltoY(oldy); gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow); } } break; case kButton1Motion: if (fSelected) { if (fSelected->InheritsFrom("TH2")) { gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow); oldx = GetEventX(); oldy = GetEventY(); gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow); moved = true; } } case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier if (fSelected) { gPad = fSelectedPad; if (sendOrder) fSelected->ExecuteEvent(event, px, py); gVirtualX->Update(); if (!fSelected->InheritsFrom(TAxis::Class())) { Bool_t resize = kFALSE; if (fSelected->InheritsFrom(TBox::Class())) resize = ((TBox*)fSelected)->IsBeingResized(); if (fSelected->InheritsFrom(TVirtualPad::Class())) resize = ((TVirtualPad*)fSelected)->IsBeingResized(); if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) { gPad = fPadSave; Update(); FeedbackMode(kTRUE); } } RunAutoExec(); } break; case kButton1Up: if (fSelected) { gPad = fSelectedPad; if (sendOrder) fSelected->ExecuteEvent(event, px, py); RunAutoExec(); if (fPadSave) gPad = fPadSave; else { gPad = this; fPadSave = this; } if (fSelected->InheritsFrom("TH2") && moved && !fSelected->InheritsFrom("TH3")) { xmax = AbsPixeltoX(GetEventX()); ymax = AbsPixeltoY(GetEventY()); Double_t toto = 0; if (xmax < xmin) { toto = xmax; xmax = xmin; xmin = toto; } if (ymax < ymin) { toto = ymax; ymax = ymin; ymin = toto; } ZoomSelected((TH2*)FindHisto()); // ZoomSelected((TH2*)fSelected); moved = false; } Update(); // before calling update make sure gPad is reset } break; //*-*---------------------------------------------------------------------- case kButton2Down: // find pad in which input occured pad = Pick(px, py, prevSelObj); if (!pad) return; gPad = pad; // don't use cd() because we won't draw in pad // we will only use its coordinate system FeedbackMode(kTRUE); if (!fSelected->InheritsFrom("TH1")) fSelected->Pop(); // pop object to foreground pad->cd(); // and make its pad the current pad if (fSelected->InheritsFrom("TH2") && !fSelected->InheritsFrom("TH3")) { // implement pan & scan X0 = px; Y0 = py; // u clikd here theXaxis = ((TH2*)FindHisto())->GetXaxis(); theYaxis = ((TH2*)FindHisto())->GetYaxis(); NXbins = theXaxis->GetNbins(); // maximum bin number in X NYbins = theYaxis->GetNbins(); // maximum bin number in Y Xf1 = Xfirst0 = theXaxis->GetFirst(); // initial displayed bin range in X Xl1 = Xlast0 = theXaxis->GetLast(); Yf1 = Yfirst0 = theYaxis->GetFirst(); // initial displayed bin range in Y Yl1 = Ylast0 = theYaxis->GetLast(); // size of axes in pixels Int_t pixelWidthX = gPad->XtoAbsPixel(gPad->GetUxmax()) - gPad->XtoAbsPixel(gPad->GetUxmin()); Int_t pixelWidthY = gPad->YtoAbsPixel(gPad->GetUymax()) - gPad->YtoAbsPixel(gPad->GetUymin()); // sizes of bins in pixels NdisXbins = Xlast0 - Xfirst0 + 1; NdisYbins = Ylast0 - Yfirst0 + 1; XbinPixel = pixelWidthX / (1.0 * NdisXbins); YbinPixel = pixelWidthY / (1.0 * NdisYbins); } if (gDebug) printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle()); // loop over all canvases to make sure that only one pad is highlighted { TIter next(gROOT->GetListOfCanvases()); TCanvas* tc; while ((tc = (TCanvas*)next())) tc->Update(); } /*if (pad->GetGLDevice() != -1 && fSelected) fSelected->ExecuteEvent(event, px, py);*/ break; // don't want fPadSave->cd() to be executed at the end case kButton2Motion: //was empty! if (fSelected && fSelected->InheritsFrom("TH2") && !fSelected->InheritsFrom("TH3")) { // implement pan & scan Int_t dX = px - X0; // how far have i moved ? Int_t dY = py - Y0; Int_t dXbins = dX / XbinPixel; Int_t dYbins = dY / YbinPixel; Bool_t changed = kFALSE; Int_t newXfirst = Xfirst0 - dXbins; Int_t newXlast; if (newXfirst < 1) { newXfirst = 1; newXlast = NdisXbins; } else { newXlast = Xlast0 - dXbins; if (newXlast > NXbins) { newXlast = NXbins; newXfirst = newXlast - NdisXbins + 1; } } if (newXfirst != Xf1) { Xf1 = newXfirst; Xl1 = newXlast; theXaxis->SetRange(Xf1, Xl1); changed = kTRUE; } Int_t newYfirst = Yfirst0 - dYbins; Int_t newYlast; if (newYfirst < 1) { newYfirst = 1; newYlast = NdisYbins; } else { newYlast = Ylast0 - dYbins; if (newYlast > NYbins) { newYlast = NYbins; newYfirst = newYlast - NdisYbins + 1; } } if (newYfirst != Yf1) { Yf1 = newYfirst; Yl1 = newYlast; theYaxis->SetRange(Yf1, Yl1); changed = kTRUE; } if (changed) { Modified(); Update(); } } case kButton2Up: if (fSelected) { gPad = fSelectedPad; if (sendOrder) fSelected->ExecuteEvent(event, px, py); RunAutoExec(); } break; case kButton2Double: break; //*-*---------------------------------------------------------------------- case kButton3Down: // popup context menu pad = Pick(px, py, prevSelObj); if (!pad) return; if (!fDoubleBuffer) FeedbackMode(kFALSE); if (fContextMenu && !fSelected->TestBit(kNoContextMenu) && !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu)) { if (sendOrder) fContextMenu->Popup(px, py, fSelected, this, pad); else fSelected->ExecuteEvent(event, px, py); } break; case kButton3Motion: break; case kButton3Up: if (!fDoubleBuffer) FeedbackMode(kTRUE); break; case kButton3Double: break; case kKeyDown: // Info("HandleInput","Key down: %d %d",px,py); break; case kKeyUp: // Info("HandleInput","Key up: %d %d",px,py); break; case kKeyPress: if (!fSelectedPad || !fSelected) return; gPad = fSelectedPad; // don't use cd() because we won't draw in pad // we will only use its coordinate system fSelected->ExecuteEvent(event, px, py); HandleKey(px, py); RunAutoExec(); break; case kButton1Shift: // Try to select pad = Pick(px, py, prevSelObj); if (!pad) return; EnterLeave(prevSelPad, prevSelObj); gPad = pad; // don't use cd() we will use the current // canvas via the GetCanvas member and not via // gPad->GetCanvas fSelected->ExecuteEvent(event, px, py); RunAutoExec(); break; case kWheelUp: case kWheelDown: pad = Pick(px, py, prevSelObj); if (!pad) return; sign = (event == kWheelUp ? 1 : -1); gPad = pad; if (fSelected->InheritsFrom("TAxis")) fSelected->ExecuteEvent(event, px, py); else if (fSelected->InheritsFrom("TH2")) DynamicZoom(sign, px, py); RunAutoExec(); break; default: break; } if (fPadSave && event != kButton2Down) fPadSave->cd(); if (event != kMouseLeave) { // signal was already emitted for this event ProcessedEvent(event, px, py, fSelected); // emit signal DrawEventStatus(event, px, py, fSelected); } }
void archi() { TCanvas *c1 = new TCanvas("c1","Dictionary Architecture",20,10,750,930); c1->SetBorderSize(0); c1->Range(0,0,20.5,26); TPaveLabel *title = new TPaveLabel(4,24,16,25.5,c1->GetTitle()); title->SetFillColor(46); title->Draw(); TPavesText *dll = new TPavesText(0.5,19,4.5,23,5,"tr"); dll->SetFillColor(39); dll->SetTextSize(0.023); dll->AddText(" "); dll->AddText("Dynamically"); dll->AddText("Linked"); dll->AddText("Libraries"); dll->Draw(); TPaveLabel *dlltitle = new TPaveLabel(1.5,22.6,3.5,23.3,"DLLs"); dlltitle->SetFillColor(28); dlltitle->Draw(); TPavesText *cpp = new TPavesText(5.5,19,9.5,23,5,"tr"); cpp->SetTextSize(0.023); cpp->AddText(" "); cpp->AddText("Commented"); cpp->AddText("Header"); cpp->AddText("Files"); cpp->Draw(); TPaveLabel *cpptitle = new TPaveLabel(6.5,22.6,8.5,23.3,"C++"); cpptitle->SetFillColor(28); cpptitle->Draw(); TPavesText *odl = new TPavesText(10.5,19,14.5,23,5,"tr"); odl->SetTextSize(0.023); odl->AddText(" "); odl->AddText("Objects"); odl->AddText("Description"); odl->AddText("Files"); odl->Draw(); TPaveLabel *odltitle = new TPaveLabel(11.5,22.6,13.5,23.3,"ODL"); odltitle->SetFillColor(28); odltitle->Draw(); TPavesText *idl = new TPavesText(15.5,19,19.5,23,5,"tr"); idl->SetTextSize(0.023); idl->AddText(" "); idl->AddText("Interface"); idl->AddText("Definition"); idl->AddText("Language"); idl->Draw(); TPaveLabel *idltitle = new TPaveLabel(16.5,22.6,18.5,23.3,"IDL"); idltitle->SetFillColor(28); idltitle->Draw(); TWbox *p1 = new TWbox(7.8,10,13.2,17,11,12,1); p1->Draw(); TText *pro1 = new TText(10.5,15.8,"Process 1"); pro1->SetTextAlign(21); pro1->SetTextSize(0.03); pro1->Draw(); TPaveText *p1dict = new TPaveText(8.8,13.8,12.2,15.6); p1dict->SetTextSize(0.023); p1dict->AddText("Dictionary"); p1dict->AddText("in memory"); p1dict->Draw(); TPavesText *p1object = new TPavesText(8.6,10.6,12.1,13.0,5,"tr"); p1object->SetTextSize(0.023); p1object->AddText("Objects"); p1object->AddText("in memory"); p1object->Draw(); TWbox *p2 = new TWbox(15.5,10,20,17,11,12,1); p2->Draw(); TText *pro2 = new TText(17.75,15.8,"Process 2"); pro2->SetTextAlign(21); pro2->SetTextSize(0.03); pro2->Draw(); TPaveText *p2dict = new TPaveText(16,13.8,19.5,15.6); p2dict->SetTextSize(0.023); p2dict->AddText("Dictionary"); p2dict->AddText("in memory"); p2dict->Draw(); TPavesText *p2object = new TPavesText(16.25,10.6,19.25,13.0,5,"tr"); p2object->SetTextSize(0.023); p2object->AddText("Objects"); p2object->AddText("in memory"); p2object->Draw(); TWbox *stub1 = new TWbox(12.9,11.5,13.6,15.5,49,3,1); stub1->Draw(); TText *tstub1 = new TText(13.25,13.5,"Stub1"); tstub1->SetTextSize(0.025); tstub1->SetTextAlign(22); tstub1->SetTextAngle(90); tstub1->Draw(); TWbox *stub2 = new TWbox(15.1,11.5,15.8,15.5,49,3,1); stub2->Draw(); TText *tstub2 = new TText(15.45,13.5,"Stub2"); tstub2->SetTextSize(0.025); tstub2->SetTextAlign(22); tstub2->SetTextAngle(-90); tstub2->Draw(); TArrow *ar1 = new TArrow(); ar1->SetLineWidth(6); ar1->SetLineColor(1); ar1->SetFillStyle(1001); ar1->SetFillColor(1); ar1->DrawArrow(13.5,14,15,14,0.012,"|>"); ar1->DrawArrow(15.1,13,13.51,13,0.012,"|>"); TPaveText *cint = new TPaveText(1.0,15.0,8.0,17.5); cint->SetFillColor(39); cint->SetBorderSize(1); cint->SetTextSize(0.023); cint->AddText("C++ Interpreter"); cint->AddText("and program builder"); cint->Draw(); TPaveText *command = new TPaveText(2.5,13.4,8.0,14.5); command->SetTextSize(0.023); command->SetFillColor(39); command->SetBorderSize(1); command->AddText("Command Thread"); command->Draw(); TPavesText *view = new TPavesText(1.0,9.5,7.7,12.6,3,"tr"); view->SetFillColor(39); view->SetBorderSize(2); view->SetTextSize(0.023); view->AddText("Viewer Thread(s)"); view->AddText("Picking"); view->AddText("Context Menus"); view->AddText("Inspector/Browser"); view->Draw(); TPavesText *web = new TPavesText(0.5,5,6,8.5,5,"tr"); web->SetTextSize(0.023); web->AddText(" "); web->AddText("generated"); web->AddText("automatically"); web->AddText("from dictionary"); web->AddText("and source files"); web->Draw(); TPaveLabel *webtitle = new TPaveLabel(1.5,8.1,5.0,8.8,"HTML Files"); webtitle->SetFillColor(28); webtitle->Draw(); TPavesText *printed = new TPavesText(0.5,1.0,6,4,5,"tr"); printed->SetTextSize(0.023); printed->AddText(" "); printed->AddText("generated"); printed->AddText("automatically"); printed->AddText("from HTML files"); printed->Draw(); TPaveLabel *printedtitle = new TPaveLabel(1.5,3.6,5.0,4.3,"Printed Docs"); printedtitle->SetFillColor(28); printedtitle->Draw(); TBox *box1 = new TBox(0.2,9.2,14.25,17.8); box1->SetFillStyle(0); box1->SetLineStyle(2); box1->Draw(); TBox *box2 = new TBox(10.2,18.7,20.2,23.6); box2->SetFillStyle(0); box2->SetLineStyle(3); box2->Draw(); ar1->DrawArrow(2.5,17.5,2.5,18.9,0.012,"|>"); ar1->DrawArrow(5.5,9.2,5.5,8.7,0.012,"|>"); ar1->DrawArrow(5.5,5,5.5,4.2,0.012,"|>"); ar1->DrawArrow(8.5,9.2,8.5,8.2,0.012,"|>"); ar1->DrawArrow(9.5,8.1,9.5,9.0,0.012,"|>"); ar1->DrawArrow(6.5,19,6.5,17.6,0.012,"|>"); ar1->DrawArrow(8.5,19,8.5,17.1,0.012,"|>"); ar1->DrawArrow(11.5,19,11.5,17.1,0.012,"|>"); TPaveLabel *ootitle = new TPaveLabel(10.5,7.8,17,8.8,"Objects Data Base"); ootitle->SetFillColor(28); ootitle->Draw(); TPad *pio = new TPad("pio","pio",0.37,0.02,0.95,0.31,49); pio->Range(0,0,12,8); pio->Draw(); pio->cd(); TPavesText *raw = new TPavesText(0.5,1,2.5,6,7,"tr"); raw->Draw(); TPavesText *dst1 = new TPavesText(4,1,5,3,7,"tr"); dst1->Draw(); TPavesText *dst2 = new TPavesText(6,1,7,3,7,"tr"); dst2->Draw(); TPavesText *dst3 = new TPavesText(4,4,5,6,7,"tr"); dst3->Draw(); TPavesText *dst4 = new TPavesText(6,4,7,6,7,"tr"); dst4->Draw(); Float_t xlow = 8.5; Float_t ylow = 1; Float_t dx = 0.5; Float_t dy = 0.5; for (Int_t j=1;j<9;j++) { Float_t y0 = ylow + (j-1)*0.7; Float_t y1 = y0 + dy; for (Int_t i=1;i<5;i++) { Float_t x0 = xlow +(i-1)*0.6; Float_t x1 = x0 + dx; TPavesText *anal = new TPavesText(x0,y0,x1,y1,7,"tr"); anal->Draw(); } } TText *daq = new TText(); daq->SetTextSize(0.07); daq->SetTextAlign(22); daq->DrawText(1.5,7.3,"DAQ"); daq->DrawText(6,7.3,"DST"); daq->DrawText(10.,7.3,"Physics Analysis"); daq->DrawText(1.5,0.7,"Events"); daq->DrawText(1.5,0.3,"Containers"); daq->DrawText(6,0.7,"Tracks/Hits"); daq->DrawText(6,0.3,"Containers"); daq->DrawText(10.,0.7,"Attributes"); daq->DrawText(10.,0.3,"Containers"); c1->cd(); }
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ){ //-------------------------------------- // define histograms and TGraphs //-------------------------------------- TH1F* hdata = new TH1F(Form("hdata_%i" , iplot),Form("hdata_%i" , iplot),nbins,xmin,xmax); TH1F* hmc = new TH1F(Form("hmc_%i" , iplot),Form("hmc_%i" , iplot),nbins,xmin,xmax); TH1F* hmc_novtx = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax); hdata->Sumw2(); hmc->Sumw2(); TGraphAsymmErrors* grdata = new TGraphAsymmErrors(); TGraphAsymmErrors* grmc = new TGraphAsymmErrors(); TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax); TH1F* hmc_denom = new TH1F(Form("hmc_denom_%i" ,iplot),"",nbins,xmin,xmax); //-------------------------------------- // set up canvas and pads //-------------------------------------- TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); can->cd(); if( log ) gPad->SetLogy(); TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); if( residual ){ mainpad->Draw(); mainpad->cd(); if( log ) mainpad->SetLogy(); } //-------------------------------------- // fill histos and TGraphs //-------------------------------------- data->Draw(Form("min(%s,%f)>>hdata_%i" , var,xmax-0.0001,iplot),sel); mc ->Draw(Form("min(%s,%f)>>hmc_%i" , var,xmax-0.0001,iplot),sel*vtxweight); mc ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel); for( int ibin = 1 ; ibin <= nbins ; ibin++ ){ hdata_denom->SetBinContent(ibin,hdata->Integral()); hmc_denom->SetBinContent(ibin,hmc->Integral()); } grdata->BayesDivide(hdata,hdata_denom); grmc->BayesDivide(hmc_novtx,hmc_denom); //-------------------------------------- // get efficiencies and errors //-------------------------------------- /* float ndata1 = (float) hdata->GetBinContent(1); float ndata = (float) hdata->Integral(); float effdata = 1-ndata1 / ndata; // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors(); // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1); // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1); // hdata_num_temp->SetBinContent(1,ndata-ndata1); // hdata_den_temp->SetBinContent(1,ndata); // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp); //float effdataerr = sqrt(ndata1) / ndata; float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) ); //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) ); float nmc1 = (float) hmc->GetBinContent(1); float nmc = (float) hmc->Integral(); float effmc = 1-nmc1 / nmc; //float effmcerr = hmc->GetBinError(1) / nmc; float effmcerr = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) ); float datatot = hdata->Integral(); float mctot = hmc->Integral(); cout << endl; cout << plottitle << endl; cout << "Data eff " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl; cout << "MC eff " << Form("%.2f +/- %.3f",effmc ,effmcerr) << endl; cout << "Data/MC " << Form("%.2f +/- %.2f",ratio ,ratioerr) << endl; */ float ndata = hdata->Integral(); float ndata1 = hdata->Integral(2,20); float ndata2 = hdata->Integral(3,20); float ndata3 = hdata->Integral(4,20); float ndata4 = hdata->Integral(5,20); float ndata5 = hdata->Integral(6,20); float nmc = hmc->Integral(); float nmc1 = hmc->Integral(2,20); float nmc2 = hmc->Integral(3,20); float nmc3 = hmc->Integral(4,20); float nmc4 = hmc->Integral(5,20); float nmc5 = hmc->Integral(6,20); float effdata1 = ndata1/ndata; float effdata2 = ndata2/ndata; float effdata3 = ndata3/ndata; float effdata4 = ndata4/ndata; float effdata5 = ndata5/ndata; float effmc1 = nmc1/nmc; float effmc2 = nmc2/nmc; float effmc3 = nmc3/nmc; float effmc4 = nmc4/nmc; float effmc5 = nmc5/nmc; float effdata1err = getBinomialError(ndata1,ndata); float effdata2err = getBinomialError(ndata2,ndata); float effdata3err = getBinomialError(ndata3,ndata); float effdata4err = getBinomialError(ndata4,ndata); float effdata5err = getBinomialError(ndata5,ndata); float effmc1err = getBinomialError(nmc1,nmc); float effmc2err = getBinomialError(nmc2,nmc); float effmc3err = getBinomialError(nmc3,nmc); float effmc4err = getBinomialError(nmc4,nmc); float effmc5err = getBinomialError(nmc5,nmc); float ratio1 = effdata1/effmc1; float ratio2 = effdata2/effmc2; float ratio3 = effdata3/effmc3; float ratio4 = effdata4/effmc4; float ratio5 = effdata5/effmc5; float ratio1err = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2)); float ratio2err = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2)); float ratio3err = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2)); float ratio4err = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2)); float ratio5err = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2)); cout << endl << endl << plottitle << endl; int left = 20; // char* delimstart = "|"; // char* delim = "|"; // char* delimend = "|"; // char* pm = "+/-"; char* delimstart = ""; char* delim = "&"; char* delimend = "\\\\"; char* pm = "$\\pm$"; cout << delimstart << setw(10) << "" << setw(4) << delim << setw(left) << "$>$ 1 GeV" << setw(4) << delim << setw(left) << "$>$ 2 GeV" << setw(4) << delim << setw(left) << "$>$ 3 GeV" << setw(4) << delim << setw(left) << "$>$ 4 GeV" << setw(4) << delim << setw(left) << "$>$ 5 GeV" << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "mc" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data/mc" << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4) << delimend << endl; //-------------------------------------- // draw stuff //-------------------------------------- hdata->Scale(1.0/hdata->Integral()); hmc->Scale(1.0/hmc->Integral()); if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5); else hmc->GetYaxis()->SetRangeUser(0.0,1); hmc->GetXaxis()->SetTitle(xtitle); hmc->SetLineColor(2); hmc->SetMarkerColor(2); hmc->DrawNormalized("hist"); hmc->DrawNormalized("sameE1"); hdata->SetLineColor(4); hdata->SetMarkerColor(4); hdata->Draw("sameE1"); grdata->SetLineColor(6); grmc->SetLineColor(7); //grdata->Draw("sameP"); //grmc->Draw("sameP"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.9); leg->AddEntry(hdata , "data" , "lp"); leg->AddEntry(hmc , "MC" , "lp"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons"); if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons"); if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0"); if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1"); if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2"); if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3"); if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4"); //-------------------------------------- // draw residual plots //-------------------------------------- if( residual ){ can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot)); hratio->Divide(hmc); hratio->SetMarkerColor(1); hratio->SetLineColor(1); hratio->Draw(); hratio->GetYaxis()->SetRangeUser(0.5,1.5); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetXaxis()->SetLabelSize(0.0); TLine line; line.DrawLine(xmin,1.0,xmax,1.0); } //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20"); //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel); if( printplot ) can->Print(Form("plots/%s.pdf",plottitle)); iplot++; // TCanvas *c2 = new TCanvas(); // c2->cd(); // grdata->Draw("AP"); }
void printHisto( TCanvas *can , TChain *data , TChain *mc , TCut num , TCut denom , char* var , int nbins , float xmin , float xmax , char* xtitle , char* ytitle){ can->cd(); TPad *plotpad = new TPad("plotpad","plotpad",0.0,0.0,1.0,0.8); plotpad->Draw(); plotpad->cd(); float ptbin[] = {30., 40., 60. , 80. , 100. , 120. , 150. , 200 , 300 }; int nptbin = 8; //TH1F* hpass = new TH1F(Form("hpass_%i",iplot),Form("hpass_%i",iplot),nptbin,ptbin); //TH1F* hall = new TH1F(Form("hall_%i" ,iplot),Form("hall_%i" ,iplot),nptbin,ptbin); // TH1F* hpass_data = new TH1F(Form("hpass_data_%i",iplot),Form("hpass_data_%i",iplot),nbins,xmin,xmax); // TH1F* hall_data = new TH1F(Form("hall_data_%i" ,iplot),Form("hall_data_%i" ,iplot),nbins,xmin,xmax); // TH1F* hpass_mc = new TH1F(Form("hpass_mc_%i" ,iplot),Form("hpass_mc_%i" ,iplot),nbins,xmin,xmax); // TH1F* hall_mc = new TH1F(Form("hall_mc_%i" ,iplot),Form("hall_mc_%i" ,iplot),nbins,xmin,xmax); TH1F* hpass_data = new TH1F(Form("hpass_data_%i" ,iplot),Form("hpass_data_%i" ,iplot),nptbin,ptbin); TH1F* hall_data = new TH1F(Form("hall_data_%i" ,iplot),Form("hall_data_%i" ,iplot),nptbin,ptbin); TH1F* hratio_data = new TH1F(Form("hratio_data_%i" ,iplot),Form("hratio_data_%i" ,iplot),nptbin,ptbin); TH1F* hpass_mc = new TH1F(Form("hpass_mc_%i" ,iplot),Form("hpass_mc_%i" ,iplot),nptbin,ptbin); TH1F* hall_mc = new TH1F(Form("hall_mc_%i" ,iplot),Form("hall_mc_%i" ,iplot),nptbin,ptbin); TH1F* hratio_mc = new TH1F(Form("hratio_mc_%i" ,iplot),Form("hratio_mc_%i" ,iplot),nptbin,ptbin); TH1F* hsf = new TH1F(Form("hsf_%i" ,iplot),Form("hsf_%i" ,iplot),nptbin,ptbin); hpass_data->Sumw2(); hall_data->Sumw2(); hratio_data->Sumw2(); hpass_mc->Sumw2(); hall_mc->Sumw2(); hratio_mc->Sumw2(); hsf->Sumw2(); //TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); //can->cd(); data->Draw(Form("min(%s,%f)>>hpass_data_%i" , var,xmax-0.0001,iplot),denom+num); data->Draw(Form("min(%s,%f)>>hall_data_%i" , var,xmax-0.0001,iplot),denom); mc->Draw (Form("min(%s,%f)>>hpass_mc_%i" , var,xmax-0.0001,iplot),denom+num); mc->Draw (Form("min(%s,%f)>>hall_mc_%i" , var,xmax-0.0001,iplot),denom); TGraphAsymmErrors *grdata = new TGraphAsymmErrors(); grdata->BayesDivide(hpass_data,hall_data); TGraphAsymmErrors *grmc = new TGraphAsymmErrors(); grmc->BayesDivide(hpass_mc,hall_mc); // cout << "data all " << hall_data->GetBinContent(8) << endl; // cout << "data pass " << hpass_data->GetBinContent(8) << endl; // cout << "data eff " << hpass_data->GetBinContent(8) / hall_data->GetBinContent(8) << endl; // Double_t x; // Double_t y; // grdata->GetPoint(7,x,y); // cout << "data eff2 " << y << endl; gPad->SetGridx(); gPad->SetGridy(); grdata->SetMarkerColor(2); grdata->SetLineColor(2); grmc->SetMarkerColor(4); grmc->SetLineColor(4); grmc->SetMarkerStyle(25); grdata->GetXaxis()->SetRangeUser(30,300); grdata->GetYaxis()->SetRangeUser(0.6,1.0); grdata->GetXaxis()->SetTitle(xtitle); grdata->GetYaxis()->SetTitle(ytitle); grdata->Draw("AP"); grmc->Draw("sameP"); TLegend *leg = new TLegend(0.5,0.2,0.7,0.4); leg->AddEntry(grdata ,"data","lp"); leg->AddEntry(grmc ,"mc" ,"lp"); leg->SetBorderSize(1); leg->SetFillColor(0); //leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(denom.GetTitle()).Contains("njets==0") ) t->DrawLatex(0.2,0.2,"n_{jets}=0"); if( TString(denom.GetTitle()).Contains("njets==1") ) t->DrawLatex(0.2,0.2,"n_{jets}=1"); if( TString(denom.GetTitle()).Contains("njets==2") ) t->DrawLatex(0.2,0.2,"n_{jets}=2"); if( TString(denom.GetTitle()).Contains("njets==3") ) t->DrawLatex(0.2,0.2,"n_{jets}=3"); if( TString(denom.GetTitle()).Contains("njets>=4") ) t->DrawLatex(0.2,0.2,"n_{jets}#geq4"); can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); // TGraphAsymmErrors* gr_ratio = (TGraphAsymmErrors*) grdata->Clone("gr_ratio"); // gr_ratio->Divide(grmc); // gr_ratio->Draw(); hratio_data->Divide(hpass_data,hall_data,1,1,"B"); hratio_mc ->Divide(hpass_mc ,hall_mc,1,1,"B"); hsf ->Divide(hratio_data,hratio_mc,1,1); hsf->GetYaxis()->SetRangeUser(0.8,1.2); hsf->GetYaxis()->SetNdivisions(5); hsf->GetYaxis()->SetLabelSize(0.2); hsf->GetXaxis()->SetLabelSize(0.0); hsf->Draw("E1"); iplot ++; }
void HiggsPlot::PlotChi2(){ styles style; style.setPadsStyle(1); style.PadLeftMargin = 0.14; style.PadBottomMargin = 0.17; style.yTitleOffset = 0.7; style.xTitleOffset = 0.7; style.TitleSize = 0.1; style.LabelSize = 0.1; style.setDefaultStyle(); TCanvas can("can","Likelihood scan"); TPad *cPad = static_cast<TPad *>(can.cd(0)); TString xTitle[] = {"R(D)", "R(D*)"}; double nSig = 4.2; int nBins = 60; _varyRD = 0; double RD[2], RDs[2], frac=0.018; Compute(0,RD,1); Compute(0,RDs,2); double Limit[2][2] = {{Measurement[1][0]-nSig*Measurement[1][1], Measurement[1][0]+nSig*Measurement[1][1]}, {Measurement[2][0]-nSig*Measurement[2][1], Measurement[2][0]+nSig*Measurement[2][1]}}; TH2F hChi2("hChi2","",nBins, Limit[0][0],Limit[0][1], nBins, Limit[1][0],Limit[1][1]); for(int iRD=1; iRD<=nBins; iRD++){ for(int iRDs=1; iRDs<=nBins; iRDs++){ RD[0] = hChi2.GetXaxis()->GetBinCenter(iRD); RDs[0] = hChi2.GetYaxis()->GetBinCenter(iRDs); hChi2.SetBinContent(iRD, iRDs, ProbChi2(3, 0, RD, RDs)); //cout<<1-ProbChi2(3, 0, RD, RDs)<<endl; } //cout<<endl; } hChi2.SetXTitle(xTitle[0]); hChi2.SetYTitle(xTitle[1]); //int colors[] = {kBlue+2, kBlue+1, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0}; int colors[] = {kBlue-3, kBlue-4, kBlue-7, kBlue-9, kBlue-10, 0}; gStyle->SetPalette(Nsigma, colors); double zCont[Nsigma]; for(int ns=1; ns<=Nsigma; ns++) zCont[ns] = IntG(0,1,-ns,ns);//cout<<endl<<zCont[ns]<<endl;} hChi2.SetContour(Nsigma,zCont); hChi2.GetXaxis()->CenterTitle(true); hChi2.GetYaxis()->CenterTitle(true); hChi2.SetLabelOffset(0.009,"xy"); hChi2.SetLabelSize(0.09,"xy"); hChi2.SetTitleOffset(1,"x"); hChi2.SetTitleOffset(0.6,"y"); hChi2.Draw("cont4"); double padL[2][2] = {{cPad->GetLeftMargin(), 1-cPad->GetRightMargin()}, // Margins are reversed for x-y! {cPad->GetBottomMargin(), 1-cPad->GetTopMargin()}}; double SMyield[2]; Compute(0,RD,1); Compute(0,RDs,2); RD[1] = RDs[0]; TLine line; line.SetLineWidth(2); line.SetLineColor(1); for(int chan=0; chan<2; chan++){ double range = Limit[chan][1]-Limit[chan][0]; SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(RD[chan]-Limit[chan][0])/range; } line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]); line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac); TLatex latex; latex.SetNDC(kTRUE); latex.SetTextAlign(33); latex.SetTextSize(style.TitleSize); latex.DrawLatex(SMyield[0]-frac,SMyield[1]-frac,"SM"); line.SetLineColor(0); for(int chan=0; chan<2; chan++){ double range = Limit[chan][1]-Limit[chan][0]; SMyield[chan] = padL[chan][0] + (padL[chan][1]-padL[chan][0])*(Measurement[1+chan][0]-Limit[chan][0])/range; } line.DrawLineNDC(SMyield[0]-frac, SMyield[1], SMyield[0]+frac, SMyield[1]); line.DrawLineNDC(SMyield[0], SMyield[1]-2*frac, SMyield[0], SMyield[1]+2*frac); TH1F *histo[Nsigma]; double legW = 0.08, legH = 0.07*Nsigma; double legX = 1-style.PadRightMargin-0.02, legY = 1-style.PadTopMargin-0.02; TLegend *leg = new TLegend(legX-legW, legY-legH, legX, legY); leg->SetTextSize(0.08); leg->SetFillColor(0); leg->SetTextFont(style.nFont); for(int ileg=0; ileg<Nsigma-1; ileg++) { TString label = "histo"; label += ileg+1; histo[ileg] = new TH1F(label,"histo",10,0,10); histo[ileg]->SetLineColor(colors[ileg]);histo[ileg]->SetFillColor(colors[ileg]); label = " "; label += ileg+1; label += "#sigma"; leg->AddEntry(histo[ileg],label); } leg->Draw(); TString pName = "public_html/Higgs_Chi2.eps"; can.SaveAs(pName); for(int ileg=0; ileg<Nsigma-1; ileg++) histo[ileg]->Delete(); }
void QA_Draw_CEMC_G4Hit( const char *qa_file_name_new = "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi-_eta0.30_32GeV-0000.root_qa.root", const char *qa_file_name_ref = "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi+_eta0.30_32GeV-0000.root_qa.root") { SetsPhenixStyle(); TVirtualFitter::SetDefaultFitter("Minuit2"); TFile *qa_file_new = new TFile(qa_file_name_new); assert(qa_file_new->IsOpen()); TFile *qa_file_ref = NULL; if (qa_file_name_ref) { qa_file_ref = new TFile(qa_file_name_ref); assert(qa_file_ref->IsOpen()); } TCanvas *c1 = new TCanvas("QA_Draw_CEMC_G4Hit", "QA_Draw_CEMC_G4Hit", 1800, 900); c1->Divide(4, 2); int idx = 1; TPad *p; p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogz(); TH2F *h_QAG4Sim_CEMC_G4Hit_XY = (TH2F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_XY", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_XY); h_QAG4Sim_CEMC_G4Hit_XY->GetYaxis()->SetTitleOffset(1.5); h_QAG4Sim_CEMC_G4Hit_XY->Draw("COLZ"); p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogz(); TH2F *h_QAG4Sim_CEMC_G4Hit_RZ = (TH2F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_RZ", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_RZ); h_QAG4Sim_CEMC_G4Hit_RZ->GetYaxis()->SetTitleOffset(1.5); h_QAG4Sim_CEMC_G4Hit_RZ->Draw("COLZ"); p = (TPad *) c1->cd(idx++); c1->Update(); // p->SetLogz(); { TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection = (TH2F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection); TH1D *proj_new = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionX( "qa_file_new_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_px"); proj_new->Scale(1. / proj_new->GetSum()); TH1D *proj_ref = NULL; if (qa_file_ref) { TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection = (TH2F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection); proj_ref = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionX( "qa_file_ref_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_px"); proj_ref->Scale(1. / proj_ref->GetSum()); } proj_new->GetYaxis()->SetTitle("Normalized energy distribution"); proj_new->GetXaxis()->SetRangeUser(-10, 10); DrawReference(proj_new, proj_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); // p->SetLogz(); { TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection = (TH2F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection); TH1D *proj_new = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionY( "qa_file_new_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_py"); proj_new->Scale(1. / proj_new->GetSum()); TH1D *proj_ref = NULL; if (qa_file_ref) { TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection = (TH2F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F"); assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection); proj_ref = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionY( "qa_file_ref_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_py"); proj_ref->Scale(1. / proj_ref->GetSum()); } proj_new->GetYaxis()->SetTitle("Normalized energy distribution"); proj_new->GetXaxis()->SetRangeUser(-10, 10); DrawReference(proj_new, proj_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); p->SetLogx(); p->SetLogy(); { TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_HitTime", "TH1F"); assert(h_new); h_new->Rebin(5); h_new->Scale(1. / h_new->GetSum()); TH1F *h_ref = NULL; if (qa_file_ref) { h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_HitTime", "TH1F"); assert(h_ref); h_ref->Rebin(5); h_ref->Scale(1. / h_ref->GetSum()); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Normalized energy per bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); // p->SetLogx(); p->SetLogy(); { TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_FractionTruthEnergy", "TH1F"); assert(h_new); h_new->Rebin(20); h_new->Sumw2(); h_new->Scale(1. / h_new->GetSum()); TH1F *h_ref = NULL; if (qa_file_ref) { h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_FractionTruthEnergy", "TH1F"); assert(h_ref); h_ref->Rebin(20); h_ref->Scale(1. / h_ref->GetSum()); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Probability per bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); // p->SetLogz(); { TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_VSF", "TH1F"); assert(h_new); h_new->Rebin(2); h_new->Sumw2(); h_new->Scale(1. / h_new->GetSum()); TH1F *h_ref = NULL; if (qa_file_ref) { h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_VSF", "TH1F"); assert(h_ref); h_ref->Rebin(2); h_ref->Sumw2(); h_ref->Scale(1. / h_ref->GetSum()); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Probability per bin"); h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } p = (TPad *) c1->cd(idx++); c1->Update(); // p->SetLogz(); { TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_FractionEMVisibleEnergy", "TH1F"); assert(h_new); h_new->Rebin(4); h_new->Sumw2(); h_new->Scale(1. / h_new->GetSum()); TH1F *h_ref = NULL; if (qa_file_ref) { h_ref = (TH1F *) qa_file_ref->GetObjectChecked( "h_QAG4Sim_CEMC_G4Hit_FractionEMVisibleEnergy", "TH1F"); assert(h_ref); h_ref->Rebin(4); h_ref->Scale(1. / h_ref->GetSum()); } h_new->GetYaxis()->SetTitleOffset(1.5); h_new->GetYaxis()->SetTitle("Probability per bin"); // h_new->GetXaxis()->SetRangeUser(-0, .1); DrawReference(h_new, h_ref); } // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref); SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true); }
void plottingmacro_IVF() { double fa = 0.46502; double fb = 0.53498; bool debug_ = true; // std::string path("Nov10thFall11Plots/"); // std::string path("Nov10Fall1160MTopSlimPlots/"); std::string path("Nov10Fall1160MTopIVFPlots_b/"); if(debug_) std::cout << "Init the style form setTDRStyle" << std::endl; setTDRStyle(); gStyle->SetErrorX(0.5); gROOT->ForceStyle(); initOptions(); if(debug_) std::cout << "Init the sample" << std::endl; // std::vector<Sample> s = Nov10thDiJetPtUpdatedSlimHistos(); //std::vector<Sample> s = Nov10Fall1160MTopSlimHistos(); std::vector<Sample> s = Nov10Fall1160MTopIVFHistos(); Sample data(1,"fake data","S1.root",0,true,1000); if(debug_) std::cout << "Init the data sample" << std::endl; for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;} if(debug_) std::cout << "Ls data sample" << std::endl; data.file()->ls(); if(debug_) std::cout << "Init the mc sample" << std::endl; for(size_t i=0;i< s.size();i++) s[i].dump(1,fa,fb); std::vector<std::string> names; if(debug_) std::cout << "Get List of Keys" << std::endl; TList * subs = data.file()->GetListOfKeys(); for(size_t i=0;i< subs->GetSize();i++) { TString nn = subs->At(i)->GetName(); if( nn.Contains(TRegexp("Count*")) ) continue; if(debug_) std::cout << "Get List of Keys in subdirs" << std::endl; TList * objs = ((TDirectoryFile *)data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys(); for(size_t j=0;j< objs->GetSize();j++) { if(debug_) std::cout << "Name = " << subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName() << std::endl; names.push_back(subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName()); // std::cout << subs->At(i)->GetName() << "/" << objs->At(j)->GetName() << std::endl; //TODO: select plots via regexp } } if(debug_) std::cout << "Starting plotting" << std::endl; std::string process; for(size_t i = 0 ; i < names.size() ; i++) { std::map<std::string,TH1F *> grouped; TString n=names[i]; // if(!n.Contains(TRegexp("VlightRegionHZee/HiggsPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee/ZPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZmmSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZeeSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVPureRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVTTbarPureRegionZcombSV"))) continue; if(!n.Contains(TRegexp("TTbarRegionZeeSVJets"))) continue; if(n.Contains(TRegexp("RegionHZcomb"))) process = "Z(l^{+}l^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZmm"))) process = "Z(#mu^{+}#mu^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZee"))) process = "Z(e^{+}e^{-})H(b#bar{b})"; if(debug_) std::cout << "Creating the Canvas" << std::endl; TCanvas *c = new TCanvas(); c->SetLogy(false); c->SetTitle(names[i].c_str()); if(debug_) std::cout << "Creating histograms" << std::endl; TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str())); hd->Sumw2(); Options o=options[names[i]]; // hd->Rebin(o.rebin); hd->SetMarkerStyle(20); hd->GetXaxis()->SetLabelOffset(99); hd->SetYTitle(o.yaxis.c_str()); double nbin = hd->GetNbinsX(); double min_bin = hd->GetXaxis()->GetXmin(); double max_bin = hd->GetXaxis()->GetXmax(); TH1F *hmc = new TH1F("hmc","hmc", nbin, min_bin, max_bin); hmc->SetFillColor(kWhite); hmc->Sumw2(); // hmc->Rebin(o.rebin); if(debug_) std::cout << "Creating the THStack and Legend" << std::endl; THStack * sta = new THStack("sta",hd->GetTitle()); TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6); l->SetFillColor(kWhite); l->SetBorderSize(0); l->SetTextFont(62); l->SetTextSize(0.03); if(debug_) std::cout << "Adding data to the legend" << std::endl; l->AddEntry(hd, "Data","P"); if(debug_) std::cout << "Adding MC to the THStack" << std::endl; //with the proper trigger eff // double SF[] = {1.01,1.03,1.00}; // double SF[] = {1.03,1.054,1.032}; double SF[] = {1.0,1.0,1.0}; if(debug_){ for(int i = 0; i< 3; ++i) std::cout << "SF [" << i << "] = " << SF[i] << std::endl; } double mcIntegral=0; for(size_t j=0;j< s.size() ;j++) { if(!s[j].data) { if(debug_) std::cout << "Creating TH1F from file " << s[j].name << std::endl; TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str())); h->Sumw2(); if(debug_){ std::cout << "TH1F created from file " << s[j].name << std::endl; std::cout << "Scaling : " << s[j].scale(data.lumi(),fa,fb) << std::endl; std::cout << "Scaling with SF : " << s[j].scale(data.lumi(),fa,fb,SF) << std::endl; std::cout << "Histo integral before scaling = " << h->Integral() << std::endl; } h->Scale(s[j].scale(data.lumi(),fa,fb,SF)); if(debug_){ std::cout << "Histo integral after scaling = " << h->Integral() << std::endl; std::cout << "Managing style... " << std::endl; } h->SetLineWidth(1.); h->SetFillColor(s[j].color); h->SetLineColor(s[j].color); // h->Rebin(options[names[i]].rebin); if(debug_) std::cout << "Cloning and update legend " << std::endl; if(grouped.find(s[j].name) == grouped.end()){ l->AddEntry(h,s[j].name.c_str(),"F"); } std::cout << "Sample : " << s[j].name << " - Integral for plot " << names[i] << " = " << h->Integral(-10000,10000) << std::endl; mcIntegral += h->Integral(); sta->Add(h); hmc->Add(h); //TO FIX grouped map // sovrascrive histo con lo stesso nome tipo VV o ST etc... grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str()); } } if(debug_){ std::cout << "Data total = " << hd->Integral() << std::endl; std::cout << "MC = " << mcIntegral << std::endl; std::cout << "Data/MC = " << hd->Integral()/mcIntegral << std::endl; } TPad * TopPad = new TPad("TopPad","Top Pad",0.,0.3,1.,1. ) ; TPad * BtmPad = new TPad("BtmPad","Bottom Pad",0.,0.,1.,0.313 ) ; TopPad->SetBottomMargin(0.02); BtmPad->SetTopMargin(0.0); BtmPad->SetFillStyle(4000); TopPad->SetFillStyle(4000); BtmPad->SetFillColor(0); BtmPad->SetBottomMargin(0.35); TopPad->Draw() ; BtmPad->Draw() ; std::cout << "hd maximum = " << hd->GetMaximum() << " sta maximum = " << sta->GetMaximum() << std::endl; double maxY; if(hd->GetMaximum() > sta->GetMaximum()) maxY = (hd->GetMaximum())*1.5; else maxY = (sta->GetMaximum())*1.5; TopPad->cd(); hd->Draw("E1X0"); sta->Draw("sameHIST"); hmc->Draw("sameE2"); hmc->SetFillColor(2); hmc->SetMarkerSize(0); hmc->SetFillStyle(3013); hd->Draw("E1X0same"); l->Draw("same"); std::cout << "Set Maximum to = " << maxY << std::endl; hd->GetYaxis()->SetRangeUser(0.,maxY); hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); BtmPad->cd(); std::cout << "Division" << std::endl; TH1D * divisionErrorBand = (TH1D*)(hmc)->Clone("divisionErrorBand"); divisionErrorBand->Sumw2(); divisionErrorBand->Divide(hmc); divisionErrorBand->Draw("E2"); divisionErrorBand->SetMaximum(2.49); divisionErrorBand->SetMinimum(0); divisionErrorBand->SetMarkerStyle(20); divisionErrorBand->SetMarkerSize(0.55); divisionErrorBand->GetXaxis()->SetTitleOffset(1.12); divisionErrorBand->GetXaxis()->SetLabelSize(0.12); divisionErrorBand->GetXaxis()->SetTitleSize(0.5); divisionErrorBand->GetYaxis()->SetTitle("Data/MC"); divisionErrorBand->GetYaxis()->SetLabelSize(0.12); divisionErrorBand->GetYaxis()->SetTitleSize(0.12); divisionErrorBand->GetYaxis()->SetTitleOffset(0.40); divisionErrorBand->GetYaxis()->SetNdivisions(505); //divisionErrorBand->UseCurrentStyle(); divisionErrorBand->SetFillColor(2); divisionErrorBand->SetFillStyle(3001); divisionErrorBand->SetMarkerSize(0.); TH1D * division = (TH1D*)(hd)->Clone("division"); division->Sumw2(); division->Divide(hmc); // division->SetMaximum(2.5); // division->SetMinimum(0); // division->SetMarkerStyle(20); // division->SetMarkerSize(0.55); // division->GetXaxis()->SetLabelSize(0.12); // division->GetXaxis()->SetTitleSize(0.14); // division->GetYaxis()->SetLabelSize(0.10); // division->GetYaxis()->SetTitleSize(0.10); // division->GetYaxis()->SetTitle("Data/MC"); Double_t min = division->GetXaxis()->GetXmin(); Double_t max = division->GetXaxis()->GetXmax(); division->Draw("E1X0same"); TLine *line = new TLine(min, 1.0, max, 1.0); line->SetLineColor(kRed); line->Draw("same"); TLegend * leg3 =new TLegend(0.50,0.86,0.69,0.96); leg3->AddEntry(divisionErrorBand,"MC uncert. (stat.)","f"); leg3->SetFillColor(0); leg3->SetLineColor(0); leg3->SetShadowColor(0); leg3->SetTextFont(62); leg3->SetTextSize(0.06); leg3->Draw(); TPaveText *pave = new TPaveText(0.15,0.85,0.32,0.96,"brNDC"); pave->SetTextAlign(12); pave->SetLineColor(0); pave->SetFillColor(0); pave->SetShadowColor(0); //TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",histDt->Chi2Test(histCopyMC5,"UWCHI2/NDF"),histDt->KolmogorovTest(histCopyMC5))); // stat + sys TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",hd->Chi2Test(hmc,"UWCHI2/NDF"),hd->KolmogorovTest(hmc))); // stat only text->SetTextFont(62); text->SetTextSize(0.08); pave->Draw(); TopPad->cd(); TLatex latex; latex.SetNDC(); latex.SetTextAlign(12); latex.SetTextSize(0.052); latex.DrawLatex(0.17,0.89,"CMS Preliminary"); latex.SetTextSize(0.04); latex.DrawLatex(0.17,0.84,"#sqrt{s} = 7 TeV, L = 4.7 fb^{-1}"); // latex.DrawLatex(0.17,0.79,"Z(e^{+}e^{-})H(b#bar{b})"); latex.DrawLatex(0.17,0.79,process.c_str()); c->Update(); std::string cName= hd->GetName(); cName += "_bare.pdf"; cName = path+cName; c->Print(cName.c_str(),"pdf"); // std::cout << names[i] << " d: " << hd->Integral() << " "; // THStack * sta2 = new THStack("sta2",hd->GetTitle()); // float tot=0; // float toterr2=0; // if(debug_) // std::cout << "Putting the iterator in the for loop" << std::endl; // for(std::map<std::string,TH1F *>::reverse_iterator it=grouped.rbegin(); it!=grouped.rend();++it) // { // if(debug_) // std::cout << "Using the iterator" << std::endl; // std::cout << (*it).first << " " << (*it).second->Integral() << " | " << std::endl ; // if((*it).second->GetEntries() > 0) { // float er=1.*sqrt((*it).second->GetEntries())/(*it).second->GetEntries()*(*it).second->Integral(); // toterr2+=er*er; // } // tot+=(*it).second->Integral(); // sta2->Add(it->second); // } // std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) << " SF: " << hd->Integral()/tot << std::endl; // TCanvas *c2 = new TCanvas(); // c2->SetTitle(names[i].c_str()); // std::cout << "hd maximum = " << hd->GetMaximum() << " sta2 maximum = " << sta2->GetMaximum() << std::endl; // if(hd->GetMaximum() > sta2->GetMaximum()) maxY = hd->GetBinContent(hd->GetMaximumBin()) * 1.5; // else maxY = ( sta2->GetMaximum())*1.5; // // hd->Draw("E1"); // sta2->Draw("PADSHIST"); // // hd->Draw("E1same"); // // l->Draw("same"); // std::cout << "Set Maximum to = " << maxY << std::endl; // hd->GetYaxis()->SetRangeUser(0.,maxY); // hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); // c2->Update(); // std::string c2Name = hd->GetName(); // c2Name = path+c2Name; // c2Name += "_norm.pdf"; // c2->Print(c2Name.c_str(),"pdf"); } }
void showHistograms(double canvasSizeX, double canvasSizeY, TH1* histogram_ref, const std::string& legendEntry_ref, double integral_ref, TH1* histogram2, const std::string& legendEntry2, double integral2, TH1* histogram3, const std::string& legendEntry3, double integral3, TH1* histogram4, const std::string& legendEntry4, double integral4, TH1* histogram5, const std::string& legendEntry5, double integral5, TH1* histogram6, const std::string& legendEntry6, double integral6, const std::string& xAxisTitle, double xAxisOffset, bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { if ( !(histogram_ref && histogram2) ) return; TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.35, 1.00, 1.00); topPad->SetFillColor(10); topPad->SetTopMargin(0.04); topPad->SetLeftMargin(0.15); topPad->SetBottomMargin(0.03); topPad->SetRightMargin(0.05); topPad->SetLogy(useLogScale); TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35); bottomPad->SetFillColor(10); bottomPad->SetTopMargin(0.02); bottomPad->SetLeftMargin(0.15); bottomPad->SetBottomMargin(0.24); bottomPad->SetRightMargin(0.05); bottomPad->SetLogy(false); canvas->cd(); topPad->Draw(); topPad->cd(); //int colors[6] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7, kCyan - 6, kRed - 6 }; int colors[6] = { kBlack, kRed, kBlue - 7, kMagenta - 7, kCyan - 6, kRed - 6 }; int markerStyles[6] = { 24, 25, 20, 21, 22, 23 }; int markerSizes[6] = { 1, 1, 1, 1, 1, 1 }; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.61, legendY0 + 0.21, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); histogram_ref->SetTitle(""); histogram_ref->SetStats(false); histogram_ref->SetMinimum(yMin); histogram_ref->SetMaximum(yMax); histogram_ref->SetLineColor(colors[0]); histogram_ref->SetLineWidth(2); histogram_ref->SetMarkerColor(colors[0]); histogram_ref->SetMarkerStyle(markerStyles[0]); histogram_ref->SetMarkerSize(markerSizes[0]); histogram_ref->Draw("e1p"); //if ( integral_ref >= 0. ) legend->AddEntry(histogram_ref, Form("%s: %1.2f", legendEntry_ref.data(), integral_ref), "p"); //else legend->AddEntry(histogram_ref, legendEntry_ref.data(), "p"); legend->AddEntry(histogram_ref, Form("%s: %1.2f", legendEntry_ref.data(), integral_ref), "p"); TAxis* xAxis_top = histogram_ref->GetXaxis(); xAxis_top->SetTitle(xAxisTitle.data()); xAxis_top->SetTitleOffset(xAxisOffset); xAxis_top->SetLabelColor(10); xAxis_top->SetTitleColor(10); TAxis* yAxis_top = histogram_ref->GetYaxis(); yAxis_top->SetTitle(yAxisTitle.data()); yAxis_top->SetTitleOffset(yAxisOffset); if ( histogram2 ) { histogram2->SetLineColor(colors[1]); histogram2->SetLineWidth(2); histogram2->SetMarkerColor(colors[1]); histogram2->SetMarkerStyle(markerStyles[1]); histogram2->SetMarkerSize(markerSizes[1]); histogram2->Draw("e1psame"); //if ( integral2 >= 0. ) legend->AddEntry(histogram2, Form("%s: %1.2f", legendEntry2.data(), integral2), "p"); //else legend->AddEntry(histogram2, legendEntry2.data(), "p"); legend->AddEntry(histogram2, Form("%s: %1.2f", legendEntry2.data(), integral2), "p"); } if ( histogram3 ) { histogram3->SetLineColor(colors[2]); histogram3->SetLineWidth(2); histogram3->SetMarkerColor(colors[2]); histogram3->SetMarkerStyle(markerStyles[2]); histogram3->SetMarkerSize(markerSizes[2]); histogram3->Draw("e1psame"); //if ( integral3 >= 0. ) legend->AddEntry(histogram3, Form("%s: %1.2f", legendEntry3.data(), integral3), "p"); //else legend->AddEntry(histogram3, legendEntry3.data(), "p"); legend->AddEntry(histogram3, Form("%s: %1.2f", legendEntry3.data(), integral3), "p"); } if ( histogram4 ) { histogram4->SetLineColor(colors[3]); histogram4->SetLineWidth(2); histogram4->SetMarkerColor(colors[3]); histogram4->SetMarkerStyle(markerStyles[3]); histogram4->SetMarkerSize(markerSizes[3]); histogram4->Draw("e1psame"); if ( integral4 >= 0. ) legend->AddEntry(histogram4, Form("%s: %1.2f", legendEntry4.data(), integral4), "p"); else legend->AddEntry(histogram4, legendEntry4.data(), "p"); } if ( histogram5 ) { histogram5->SetLineColor(colors[4]); histogram5->SetLineWidth(2); histogram5->SetMarkerColor(colors[4]); histogram5->SetMarkerStyle(markerStyles[4]); histogram5->SetMarkerSize(markerSizes[4]); histogram5->Draw("e1psame"); if ( integral5 >= 0. ) legend->AddEntry(histogram5, Form("%s: %1.2f", legendEntry5.data(), integral5), "p"); else legend->AddEntry(histogram5, legendEntry5.data(), "p"); } if ( histogram6 ) { histogram6->SetLineColor(colors[5]); histogram6->SetLineWidth(2); histogram6->SetMarkerColor(colors[5]); histogram6->SetMarkerStyle(markerStyles[5]); histogram6->SetMarkerSize(markerSizes[5]); histogram6->Draw("e1psame"); if ( integral6 >= 0. ) legend->AddEntry(histogram6, Form("%s: %1.2f", legendEntry6.data(), integral6), "p"); else legend->AddEntry(histogram6, legendEntry6.data(), "p"); } legend->Draw(); canvas->cd(); bottomPad->Draw(); bottomPad->cd(); TH1* histogram2_div_ref = 0; if ( histogram2 ) { std::string histogramName2_div_ref = std::string(histogram2->GetName()).append("_div_").append(histogram_ref->GetName()); histogram2_div_ref = compRatioHistogram(histogramName2_div_ref, histogram2, histogram_ref); if ( histogram2_div_ref ) { histogram2_div_ref->SetTitle(""); histogram2_div_ref->SetStats(false); histogram2_div_ref->SetMinimum(-0.50); histogram2_div_ref->SetMaximum(+0.50); TAxis* xAxis_bottom = histogram2_div_ref->GetXaxis(); xAxis_bottom->SetTitle(xAxis_top->GetTitle()); xAxis_bottom->SetLabelColor(1); xAxis_bottom->SetTitleColor(1); xAxis_bottom->SetTitleOffset(1.20); xAxis_bottom->SetTitleSize(0.08); xAxis_bottom->SetLabelOffset(0.02); xAxis_bottom->SetLabelSize(0.08); xAxis_bottom->SetTickLength(0.055); TAxis* yAxis_bottom = histogram2_div_ref->GetYaxis(); yAxis_bottom->SetTitle(Form("#frac{%s - %s}{%s}", legendEntry2.data(), legendEntry_ref.data(), legendEntry_ref.data())); yAxis_bottom->SetTitleOffset(0.85); yAxis_bottom->SetNdivisions(505); yAxis_bottom->CenterTitle(); yAxis_bottom->SetTitleSize(0.08); yAxis_bottom->SetLabelSize(0.08); yAxis_bottom->SetTickLength(0.04); histogram2_div_ref->Draw("e1p"); } } TH1* histogram3_div_ref = 0; if ( histogram3 ) { std::string histogramName3_div_ref = std::string(histogram3->GetName()).append("_div_").append(histogram_ref->GetName()); histogram3_div_ref = compRatioHistogram(histogramName3_div_ref, histogram3, histogram_ref); if ( histogram3_div_ref ) { histogram3_div_ref->SetTitle(""); histogram3_div_ref->SetStats(false); histogram3_div_ref->SetMinimum(-0.50); histogram3_div_ref->SetMaximum(+0.50); TAxis* xAxis_bottom = histogram3_div_ref->GetXaxis(); xAxis_bottom->SetTitle(xAxis_top->GetTitle()); xAxis_bottom->SetLabelColor(1); xAxis_bottom->SetTitleColor(1); xAxis_bottom->SetTitleOffset(1.20); xAxis_bottom->SetTitleSize(0.08); xAxis_bottom->SetLabelOffset(0.02); xAxis_bottom->SetLabelSize(0.08); xAxis_bottom->SetTickLength(0.055); TAxis* yAxis_bottom = histogram3_div_ref->GetYaxis(); yAxis_bottom->SetTitle(Form("#frac{%s - %s}{%s}", legendEntry3.data(), legendEntry_ref.data(), legendEntry_ref.data())); yAxis_bottom->SetTitleOffset(0.85); yAxis_bottom->SetNdivisions(505); yAxis_bottom->CenterTitle(); yAxis_bottom->SetTitleSize(0.08); yAxis_bottom->SetLabelSize(0.08); yAxis_bottom->SetTickLength(0.04); if ( histogram2 ) histogram3_div_ref->Draw("e1psame"); else histogram3_div_ref->Draw("e1p"); } } TGraph* graph_line = new TGraph(2); graph_line->SetPoint(0, xAxis_top->GetXmin(), 0.); graph_line->SetPoint(1, xAxis_top->GetXmax(), 0.); graph_line->SetLineColor(8); graph_line->SetLineWidth(1); graph_line->Draw("L"); if ( histogram2_div_ref ) histogram2_div_ref->Draw("e1psame"); if ( histogram3_div_ref ) histogram3_div_ref->Draw("e1psame"); TH1* histogram4_div_ref = 0; if ( histogram4 ) { std::string histogramName4_div_ref = std::string(histogram4->GetName()).append("_div_").append(histogram_ref->GetName()); histogram4_div_ref = compRatioHistogram(histogramName4_div_ref, histogram4, histogram_ref); if ( histogram4_div_ref ) { histogram4_div_ref->Draw("e1psame"); } } TH1* histogram5_div_ref = 0; if ( histogram5 ) { std::string histogramName5_div_ref = std::string(histogram5->GetName()).append("_div_").append(histogram_ref->GetName()); histogram5_div_ref = compRatioHistogram(histogramName5_div_ref, histogram5, histogram_ref); if ( histogram5_div_ref ) { histogram5_div_ref->Draw("e1psame"); } } TH1* histogram6_div_ref = 0; if ( histogram6 ) { std::string histogramName6_div_ref = std::string(histogram6->GetName()).append("_div_").append(histogram_ref->GetName()); histogram6_div_ref = compRatioHistogram(histogramName6_div_ref, histogram6, histogram_ref); if ( histogram6_div_ref ) { histogram6_div_ref->Draw("e1psame"); } } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( useLogScale ) outputFileName_plot.append("_log"); else outputFileName_plot.append("_linear"); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); //canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); //canvas->Print(std::string(outputFileName_plot).append(".root").data()); delete legend; delete histogram2_div_ref; delete histogram3_div_ref; delete histogram4_div_ref; delete histogram5_div_ref; delete histogram6_div_ref; delete topPad; delete bottomPad; delete canvas; }
void RDK2AnalysisPlotter::makeEPPlot(CoDet detType) { gROOT->cd(); TCanvas* theCanvas; TPad* mainPad; TPad* titlePad; TPad* pTPad; TPad* eEPad; TPad* pEPad; TPad* pTPadSubs[3]; TPad* eEPadSubs[3]; TPad* pEPadSubs[3]; int numTitleLines=getTitleBoxLines( detType); int canvasNumPixelsYPlot=600; int canvasNumPixelsYPlots=3*canvasNumPixelsYPlot; int canvasNumPixelsYTitle=40*numTitleLines; int canvasNumPixelsY=canvasNumPixelsYPlots+canvasNumPixelsYTitle; theCanvas = new TCanvas("EPExpMCAnalysisComparisonPlot","EPExpMCAnalysisComparisonPlot",10,10,1200,canvasNumPixelsY); mainPad=(TPad*) theCanvas->GetPad(0); double ylow,yhigh; yhigh=1; ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY; titlePad=new TPad("titlePad", "titlePad", 0., ylow, 1., yhigh, -1, 1, 1); yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY; ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY; pTPad=new TPad("pTPad", "pTPad", 0., ylow, 1., yhigh, -1, 1, 1); yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY; ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY- 2*canvasNumPixelsYPlot/(double)canvasNumPixelsY; eEPad=new TPad("eEPad", "eEPad", 0., ylow, 1., yhigh, -1, 1, 1); yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-2*canvasNumPixelsYPlot/(double)canvasNumPixelsY; ylow=0; pEPad=new TPad("pEPad", "pEPad", 0., ylow, 1., yhigh, -1, 1, 1); titlePad->Draw(); pTPad->Draw(); eEPad->Draw(); pEPad->Draw(); // titlePad=(TPad*) theCanvas->GetPad(1); // pTPad=(TPad*) theCanvas->GetPad(2); // eEPad=(TPad*) theCanvas->GetPad(3); // pEPad=(TPad*) theCanvas->GetPad(4); titlePad->SetMargin(0.05,0.0,0.0,0.0); pTPad->SetMargin(0.05,0.0,0.0,0.05); pEPad->SetMargin(0.05,0.0,0.0,0.05); eEPad->SetMargin(0.05,0.0,0.0,0.05); if(numExp+numMC >1) { pTPad->Divide(2); eEPad->Divide(2); pEPad->Divide(2); pTPadSubs[0]=(TPad*) pTPad->GetPad(1); eEPadSubs[0]=(TPad*) eEPad->GetPad(1); pEPadSubs[0]=(TPad*) pEPad->GetPad(1); TPad* tempPad; tempPad=(TPad*) pTPad->GetPad(2); tempPad->Divide(1,2); pTPadSubs[1]=(TPad*) tempPad->GetPad(1); pTPadSubs[2]=(TPad*) tempPad->GetPad(2); tempPad=(TPad*) pEPad->GetPad(2); tempPad->Divide(1,2); pEPadSubs[1]=(TPad*) tempPad->GetPad(1); pEPadSubs[2]=(TPad*) tempPad->GetPad(2); tempPad=(TPad*) eEPad->GetPad(2); tempPad->Divide(1,2); eEPadSubs[1]=(TPad*) tempPad->GetPad(1); eEPadSubs[2]=(TPad*) tempPad->GetPad(2); TPad* allBasePads[10]={titlePad,pTPadSubs[0],pTPadSubs[1],pTPadSubs[2],eEPadSubs[0],eEPadSubs[1],eEPadSubs[2],pEPadSubs[0],pEPadSubs[1],pEPadSubs[2]}; for (int i = 1;i< 10;i++) { allBasePads[i]->SetGrid(1,1); allBasePads[i]->SetTickx(1); allBasePads[i]->SetTicky(1); } pTPadSubs[0]->SetMargin(0.13,0.1,.1,0.1); pEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1); eEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1); pTPadSubs[1]->SetMargin(0.1,0.1,.1,0.1); pEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1); eEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1); pTPadSubs[2]->SetMargin(0.1,0.1,.1,0.1); pEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1); eEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1); //Plot pT pTPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP); pTPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_RESID); pTPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_NORMRESID); //Plot eE eEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP); eEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_RESID); eEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_NORMRESID); //Plot pE pEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP); pEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_RESID); pEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_NORMRESID); } else { TPad* allBasePads[4]={titlePad,pTPad,eEPad,pEPad}; for (int i = 1;i< 4;i++) { allBasePads[i]->SetGrid(1,1); allBasePads[i]->SetTickx(1); allBasePads[i]->SetTicky(1); } pTPad->SetMargin(0.13,0.1,.1,0.1); pEPad->SetMargin(0.13,0.1,.1,0.1); eEPad->SetMargin(0.13,0.1,.1,0.1); pTPad->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP); eEPad->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP); pEPad->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP); } mainPad->SetFillColor(kGray); ///Make Title box titlePad->cd(); titlePad->SetFillColor(kGray); TPaveText* titleBox = makeTitleBox( detType); titleBox->Draw(); TString coTypeString; if(detType==DET_EP) { coTypeString="EP"; } else if(detType==DET_EPG) { coTypeString="EPG"; } else if(detType==DET_EPBG) { coTypeString="EPBG"; } TString imagePath=GRAPHS_DIR; imagePath+="layouts/PlotLayout"; if(numMC>0) imagePath+="_MC"; for (int i = 0;i< numMC;i++) { imagePath+=TString("_")+mc[i]->GetName(); } if(numExp>0) imagePath+="_Exp"; for (int i = 0;i< numExp;i++) { imagePath+=TString("_")+exp[i]->GetName(); } imagePath+="_"+coTypeString+"_EPPlots.pdf"; theCanvas->SaveAs(imagePath); delete theCanvas; clearPlotHists(); }
void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) { TPad* fullpad = new TPad(); TPad* plotpad = new TPad(); TPad* respad = new TPad(); fullpad = new TPad("fullpad","fullpad",0,0,1,1); fullpad->Draw(); fullpad->cd(); plotpad = new TPad("plotpad","plotpad",0,0,1,0.8); plotpad->Draw(); plotpad->cd(); if (dolog) plotpad->SetLogy(); h_dt->GetYaxis()->SetTitle("Entries"); h_dt->GetXaxis()->SetTitle(Form("%s", label)); h_dt->GetYaxis()->SetTitleSize(0.05); h_dt->GetXaxis()->SetTitleSize(0.05); h_dt->GetYaxis()->SetTitleOffset(1.5); h_dt->GetXaxis()->SetTitleOffset(1.3); if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum()); h_dt->SetLineColor(kBlack); h_dt->SetMarkerColor(kBlack); h_mc->SetLineColor(kBlue); h_mc->SetMarkerColor(kBlue); h_extra->SetLineColor(kRed); h_extra->SetLineWidth(2); h_mc->SetLineWidth(2); h_dt->Draw(); h_mc->Draw("HISTSAME"); if (drawbkg) h_extra->Draw("HISTSAME"); h_dt->Draw("ESAME"); TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870); legComp->AddEntry(h_dt, "Data", "lp"); legComp->AddEntry(h_mc, "MC", "l"); if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l"); legComp->SetFillColor(0); legComp->SetBorderSize(0); legComp->Draw(); TLatex *text = new TLatex(); text->SetNDC(); text->SetTextSize(0.04); // float xtex = 0.65; // text->DrawLatex(xtex,0.88,"1 lepton + jets Sample"); fullpad->cd(); respad = new TPad("respad","respad",0,0.8,1,1); respad->Draw(); respad->cd(); //gPad->SetGridy(); TH1F* ratio = (TH1F*) h_dt->Clone("ratio"); ratio->Divide(h_mc); ratio->GetYaxis()->SetTitleOffset(0.3); ratio->GetYaxis()->SetTitleSize(0.2); ratio->GetYaxis()->SetNdivisions(5); ratio->GetYaxis()->SetLabelSize(0.2); if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5); else ratio->GetYaxis()->SetRangeUser(0.7,1.3); ratio->GetYaxis()->SetTitle("Ratio "); ratio->GetXaxis()->SetLabelSize(0); ratio->GetXaxis()->SetTitleSize(0); ratio->SetMarkerSize(1); ratio->SetLineWidth(2); ratio->SetLineColor(kBlue); ratio->SetMarkerColor(kBlue); ratio->SetFillColor(kBlue); ratio->SetFillStyle(3002); ratio->Draw("E2"); TLine line; line.SetLineWidth(2); line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1); }
void RDK2AnalysisPlotter::makeEPGPlot(CoDet detType) { gROOT->cd(); TCanvas* theCanvas; TPad* mainPad; TPad* titlePad; TPad* gEPad; TPad* detPad; TPad* gEPadSubs[3]; int numTitleLines=getTitleBoxLines( detType); int canvasNumPixelsYPlot=600; int canvasNumPixelsYPlots=2*canvasNumPixelsYPlot; int canvasNumPixelsYTitle=40*numTitleLines; int canvasNumPixelsY=canvasNumPixelsYPlots+canvasNumPixelsYTitle; theCanvas = new TCanvas("EPGExpMCAnalysisComparisonPlot","EPGExpMCAnalysisComparisonPlot",10,10,1200,canvasNumPixelsY); mainPad=(TPad*) theCanvas->GetPad(0); double ylow,yhigh; yhigh=1; ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY; titlePad=new TPad("titlePad", "titlePad", 0., ylow, 1., yhigh, -1, 1, 1); yhigh=ylow; ylow=ylow-canvasNumPixelsYPlot/(double)canvasNumPixelsY; gEPad=new TPad("gEPad", "gEPad", 0., ylow, 1., yhigh, -1, 1, 1); yhigh=ylow; ylow=0; detPad=new TPad("detPad", "detPad", 0., ylow, 1., yhigh, -1, 1, 1); titlePad->Draw(); gEPad->Draw(); detPad->Draw(); // titlePad=(TPad*) theCanvas->GetPad(1); // gEPad=(TPad*) theCanvas->GetPad(2); // detPad=(TPad*) theCanvas->GetPad(3); // egTPad=(TPad*) theCanvas->GetPad(4); titlePad->SetMargin(0.05,0.0,0.0,0.0); gEPad->SetMargin(0.05,0.0,0.0,0.05); if(numExp>1 && numMC>1) { gEPad->Divide(2); gEPadSubs[0]=(TPad*) gEPad->GetPad(1); TPad* tempPad; tempPad=(TPad*) gEPad->GetPad(2); tempPad->Divide(1,2); gEPadSubs[1]=(TPad*) tempPad->GetPad(1); gEPadSubs[2]=(TPad*) tempPad->GetPad(2); TPad* allBasePads[5]={titlePad,gEPadSubs[0],gEPadSubs[1],gEPadSubs[2],detPad}; for (int i = 1;i< 5;i++) { allBasePads[i]->SetGrid(1,1); allBasePads[i]->SetTickx(1); allBasePads[i]->SetTicky(1); } gEPadSubs[2]->SetLogx(); gEPadSubs[0]->SetMargin(0.15,0.1,.1,0.1); gEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1); gEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1); //Plot gE gEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_COMP); gEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_RESID); gEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_GEVAR,PLOT_NORMRESID); } else { TPad* allBasePads[3]={titlePad,gEPad,detPad}; for (int i = 1;i< 3;i++) { allBasePads[i]->SetGrid(1,1); allBasePads[i]->SetTickx(1); allBasePads[i]->SetTicky(1); } gEPad->SetMargin(0.13,0.1,.1,0.1); //Plot gE gEPad->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_COMP); } mainPad->SetFillColor(kGray); ///Make Title box titlePad->cd(); titlePad->SetFillColor(kGray); TPaveText* titleBox = makeTitleBox( detType); titleBox->Draw(); detPad->SetMargin(0.1,0.05,.1,0.1); //Plot det detPad->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_DETS); TString coTypeString; if(detType==DET_EP) { coTypeString="EP"; } else if(detType==DET_EPG) { coTypeString="EPG"; } else if(detType==DET_EPBG) { coTypeString="EPBG"; } TString imagePath=GRAPHS_DIR; imagePath+="layouts/PlotLayout"; if(numMC) imagePath+="_MC"; for (int i = 0;i< numMC;i++) { imagePath+=TString("_")+mc[i]->GetName(); } if(numExp) imagePath+="_Exp"; for (int i = 0;i< numExp;i++) { imagePath+=TString("_")+exp[i]->GetName(); } imagePath+="_"+coTypeString+"_EPGPlots.pdf"; theCanvas->SaveAs(imagePath); delete theCanvas; clearPlotHists(); }