void DrawInsituCorr_vs_Eta(Str jetAlgo) { Nbins=sizeof(Ebins)/sizeof(double); myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,-4.8,4.8); h->SetXTitle("Jet #eta_{det}"); h->SetYTitle("Residual correction for data only"); h->SetMaximum(1.1); h->SetMinimum(0.85); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(-4.65,1,4.65,1); for (int i=0;i<Nbins;++i) { Graph *g = GetInsituGraph(Ebins[i]); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("p_{T} = %.0f GeV",Ebins[i]),x,y,i); } l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(1); tex->SetNDC(); tex->SetTextAlign(12); //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo)); }
void TrialVisualizer() { Double_t width = 20; Double_t xlow = 0; Double_t xhi = 50; Double_t x1=10; for (Int_t i=0; i<n; i++) { TH1F *h = new TH1F(TString::Format("h%i",i),"",50,0,50); Fill(h); TLine *ll = new TLine(x1, 0, x1, 20); ll->SetLineColor(3); ll->SetLineWidth(3); vlo.push_back(ll); TLine *lh = new TLine(x1+width, 0, x1+width, 20); lh->SetLineColor(3); lh->SetLineWidth(3); vhi.push_back(lh); } Visualizer vis; vis.SetNRows(1); vis.SetNColumns(4); vis.Draw("h%i"); vis.DrawLines(vlo,"canvas=h color=3"); vis.DrawLines(vhi,"canvas=h color=2"); }
void DrawInsituCorr_vs_Pt(Str jetAlgo) { myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,15,2500); h->SetXTitle("Jet p_{T}"); h->SetYTitle("Residual correction for data only"); h->SetMaximum(1.1); h->SetMinimum(0.85); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(16,1,2400,1); for (int i=0;i<6;++i) { double eta=4.0*i/5; Graph *g = GetInsituGraphVsPt(eta); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("#eta = %.1f",eta),x,y,i); } l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(1); tex->SetNDC(); tex->SetTextAlign(12); //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo)); }
void DrawFitValue( TH2* frame, Double_t mean, Double_t err ) { Int_t DarkColor = TColor::GetColor( "#115000" ); Int_t LightColor = TColor::GetColor( "#bdff66" ); Double_t xmin = mean - err; Double_t xmax = mean + err; Double_t ymin = frame->GetYaxis()->GetXmin(); Double_t ymax = frame->GetYaxis()->GetXmax(); Double_t x[5] = { xmin, xmin, xmax, xmax, xmin }; Double_t y[5] = { ymin, ymax, ymax, ymin, ymin }; TGraph *box = new TGraph( 5, x, y ); box->SetLineColor( DarkColor ); box->SetFillColor( LightColor ); box->Draw("F"); TLine* louter = new TLine; TLine* linner = new TLine; louter->SetLineWidth( 1 ); louter->SetLineColor( DarkColor ); linner->SetLineWidth( 1 ); linner->SetLineStyle( 3 ); linner->SetLineColor( DarkColor ); louter->DrawLine( xmin, ymin, xmin, ymax ); louter->DrawLine( xmax, ymin, xmax, ymax ); linner->DrawLine( mean, ymin, mean, ymax ); }
void PlotMinEtFromSim(Bool_t isPhos = kFALSE){ gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); Float_t min = 0; float max = 1; TString filename, detname; if(isPhos){ min = 0.655; max = 0.785; detname = "PHOS"; filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.PHOS.LHC11a10a_bis.Run139465.root"; } else{ min = 0.58; max = 0.725; filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.EMCal.LHC11a10a_bis.Run139465.root"; detname = "EMCal"; } TFile *f = TFile::Open(filename, "READ"); TList *l = dynamic_cast<TList*>(f->Get("out1")); TH1F *fHistSimulatedGammaEnergyAboveThreshold = l->FindObject("fHistSimulatedGammaEnergyAboveThreshold"); TH1F *fHistSimulatedGammaEnergy = l->FindObject("fHistSimulatedGammaEnergy"); SetStyles(fHistSimulatedGammaEnergyAboveThreshold,20,TColor::kRed); fHistSimulatedGammaEnergyAboveThreshold->Divide(fHistSimulatedGammaEnergy); TCanvas *c1 = new TCanvas("c1","Simulation",600,400); c1->SetTopMargin(0.02); c1->SetRightMargin(0.03); c1->SetLeftMargin(0.11745); c1->SetBottomMargin(0.11745); c1->SetBorderSize(0); c1->SetFillColor(0); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetFrameFillColor(0); c1->SetFrameBorderMode(0); fHistSimulatedGammaEnergyAboveThreshold->SetMaximum(max +0.1); fHistSimulatedGammaEnergyAboveThreshold->SetMinimum(min-0.1); fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitle("Centrality bin"); fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitle("f_{minEt}"); fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetLabelSize(0.06); fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetLabelSize(0.06); fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitleSize(0.06); fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitleSize(0.06); fHistSimulatedGammaEnergyAboveThreshold->Draw(); TLine *lineMin = new TLine(-0.5,min,19.5,min); lineMin->Draw(); TLine *lineMax = new TLine(-0.5,max,19.5,max); lineMax->Draw(); lineMin->SetLineColor(TColor::kBlue); lineMax->SetLineColor(TColor::kBlue); lineMin->SetLineStyle(2); lineMax->SetLineStyle(2); TString outfile = "/tmp/MinEtFromSim"+detname+".png"; c1->SaveAs(outfile.Data()); }
void drawcutline(double cutval, double maximum) { TLine *cut = new TLine(); cut->SetLineWidth(3); cut->SetLineColor(28); cut->DrawLine(cutval,0.,cutval,maximum); }
void myBoxText(Double_t x, Double_t y,Double_t boxsize,Int_t mcolor,char *text) { Double_t tsize=0.06; TLatex l; l.SetTextAlign(12); //l.SetTextSize(tsize); l.SetNDC(); l.DrawLatex(x,y,text); Double_t y1=y-0.25*tsize; Double_t y2=y+0.25*tsize; Double_t x2=x-0.3*tsize; Double_t x1=x2-boxsize; printf("x1= %f x2= %f y1= %f y2= %f \n",x1,x2,y1,y2); TPave *mbox= new TPave(x1,y1,x2,y2,0,"NDC"); mbox->SetFillColor(mcolor); mbox->SetFillStyle(1001); mbox->Draw(); TLine mline; mline.SetLineWidth(4); mline.SetLineColor(1); mline.SetLineStyle(1); Double_t y_new=(y1+y2)/2.; mline.DrawLineNDC(x1,y_new,x2,y_new); }
// Draw a 2-D plot within the specified Y range and superimpose its X profile, // setting as sigmas that of the fit (and not the error of the mean) void plotAndProfileXSpread (TH2* h2, float min, float max, bool profile=false, float ymin=-5., float ymax=5.) { setStyle(h2); gPad->SetGrid(1,1); gStyle->SetGridColor(15); gStyle->SetOptStat(0); // h2->RebinX(3); // h2->RebinY(2); // h2->SetXTitle("distance from anode (cm)"); // h2->SetYTitle("(d_{reco}-d_{sim})/#sigma_{reco}"); h2->SetMarkerColor(2); h2->SetLineColor(2); h2->GetYaxis()->SetTitleOffset(1.4); h2->GetXaxis()->SetRangeUser(min,max); h2->GetYaxis()->SetRangeUser(ymin,ymax); h2->DrawCopy("box"); if (profile) { TProfile* prof = h2->ProfileX("profile",-1,-1,"s"); prof->SetMarkerStyle(20); prof->SetMarkerSize(1.2); prof->SetMarkerColor(1); prof->SetLineColor(1); prof->SetLineWidth(2); prof->DrawCopy("same e1"); delete prof; } TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0); l->SetLineColor(3); l->Draw(); }
void plotLLRdistribution(TTree *tree_, TFile *fdata_){ TCanvas *c = new TCanvas("llr","",960,800); tree_->Draw("0*nll_nll0>>htemp_llr(100,0,4)","mu<0"); tree_->Draw("-2*nll_nll0>>htemp_llr_2(100,0,4)","mu>=0"); TH1F *ht0 = (TH1F*) gROOT->FindObject("htemp_llr"); TH1F *htmu = (TH1F*) gROOT->FindObject("htemp_llr_2"); ht0->Add(htmu); ht0->GetXaxis()->SetRangeUser(0,4); ht0->SetFillColor(kGray+3); ht0->SetLineColor(1); ht0->GetXaxis()->SetTitle("-2 #times llr"); ht0->SetTitle(""); ht0->Scale(1./ht0->Integral()); ht0->GetYaxis()->SetTitleOffset(1.2); ht0->GetYaxis()->SetTitle("probability"); ht0->Draw(); if (fdata_!=0) { TTree* trdata_ = (TTree*)fdata_->Get("tree_fit_sb"); double res; trdata_->SetBranchAddress("nll_nll0",&res); trdata_->GetEntry(0); double q0_obs = -2*res; TLine* ldata = new TLine(q0_obs,0,q0_obs,ht0->GetMaximum()); ldata->SetLineColor(2); ldata->SetLineWidth(2); ldata->Draw(); std::cout << "-2xllr observed = " << q0_obs << std::endl; } c->SetLogy(); c->SaveAs("llrdist.pdf"); }
void drawline(double xpos, int colour, int style) { TLine *line = new TLine(xpos,0,xpos,15); line->SetLineStyle(style); line->SetLineColor(colour); line->Draw(); }
void DrawJMS_vs_Eta(Str jetAlgo) { double massEbins[] = {50, 100, 250, 500, 750, 1500}; double massNbins = sizeof(massEbins)/sizeof(double); myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,-4.8,4.8); h->SetXTitle("Jet #eta_{det}"); h->SetYTitle("Jet mass response"); h->SetMaximum(1.4); h->SetMinimum(0.6); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(-4.65,1,4.65,1); for (int i=0;i<massNbins;++i) { Graph *g = GetJMSGraph(massEbins[i]); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("E = %.0f GeV",massEbins[i]),x,y,i); } tex->SetNDC(); tex->SetTextAlign(12); tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,jetAlgo); }
void loglikdistrib(Int_t ntrials = 10000, Bool_t print = kFALSE) { // compute distribution of log likelihood value TH1D * hmc = gStack[gPadNr][gOrder[gPadNr][0]]; TH1D * hdata = gStack[gPadNr][gMaxProcess-1]; Int_t nbins = hmc->GetNbinsX(); Double_t loglik = loglikelihood(hmc, hdata, 1, nbins); TH1D * htest = new TH1D(*hdata); TH1D * lldistrib = new TH1D("lldistrib", "log(Likelihood) distribution", 1000, loglik-200, loglik+200); setopt(lldistrib); for (Int_t n = 0; n < ntrials; n++) { // generate poisson around theorie for (Int_t i = 1; i <= nbins; i++) { htest->SetBinContent(i, gRandom->Poisson(hmc->GetBinContent(i))); } lldistrib->Fill(loglikelihood(hmc, htest, 1, nbins)); } TCanvas * llcanvas = new TCanvas("llcanvas", "Log(Likelihood) distribution", 40, 40, 800, 600); setopt(llcanvas); lldistrib->SetFillColor(kYellow); lldistrib->Draw(); lldistrib->GetYaxis()->SetTitle("Anzahl Ereignisse"); lldistrib->GetXaxis()->SetTitle("-ln L"); // autozoom Int_t lowbin = 1; while (lldistrib->GetBinContent(lowbin) == 0) lowbin++; Int_t highbin = lldistrib->GetNbinsX(); while (lldistrib->GetBinContent(highbin) == 0) highbin--; lldistrib->SetAxisRange(lldistrib->GetBinLowEdge(lowbin), lldistrib->GetBinLowEdge(highbin)); TH1D * hworse = (TH1D *) lldistrib->Clone(); for (Int_t nbin = 1; nbin < 501; nbin++) { hworse->SetBinContent(nbin, 0); } hworse->SetFillColor(95); hworse->Draw("same"); Double_t pvalue = lldistrib->Integral(501,1000) / lldistrib->Integral(); TLatex * tex = new TLatex(0.18, 0.96, Form("-ln L_{obs} = %5.2f", loglik)); tex->SetNDC(); tex->SetTextAlign(13); tex->Draw(); tex = new TLatex(0.18, 0.86, Form("CL_{obs} = %.3f", pvalue)); tex->SetNDC(); tex->SetTextAlign(13); tex->Draw(); TLine * l = new TLine(loglik, 0, loglik, lldistrib->GetMaximum()); l->SetLineWidth(3); l->SetLineColor(kBlue); l->Draw(); llcanvas->Modified(); llcanvas->Update(); if (print) llcanvas->Print("lldistrib.pdf"); cd(gPadNr+1); }
void TPTiming () { TAxis * ax = TPMatchEmul2D->GetZaxis() ; ax->SetRangeUser(-1,6) ; TCanvas* canv = new TCanvas("canv", "canv") ; canv->SetLogz(0) ; gStyle->SetOptStat(10) ; int color[10]= {1,10,3,4,5,6,7,8,9,2} ; gStyle->SetPalette(7, color) ; TPMatchEmul2D->GetXaxis()->SetTitle("Phi index"); TPMatchEmul2D->GetYaxis()->SetTitle("Eta index"); TPMatchEmul2D->Draw("colz") ; TH2I * label = new TH2I("label", "",72, 1, 73, 38, -19, 19) ; label->SetMarkerSize(0.6); label->SetBit(kCanDelete); for (int x=3 ; x<73 ; x+=4) { for (int y=21; y<=37; y++) { int towernb = 4*(y-21)+1 ; label->SetBinContent(x-1, y, towernb) ; //EB+ label->SetBinContent(x, 40-y, towernb) ; //EB- } } label->Draw("same text") ; TLatex txt; txt.SetTextSize(0.02); TLine line; line.SetLineColor(1) ; line.SetLineStyle(1) ; line.SetLineWidth(1) ; TAxis* xAxis = TPMatchEmul2D->GetXaxis(); TAxis* yAxis = TPMatchEmul2D->GetYaxis(); // draw SM borders and numbers float sm ; for (int i=0; i<36 ; i++ ) { if (i<18) { sm = 4*i+3 ; line.DrawLine(sm, 1, sm, 18) ; txt.SetTextAlign(32); txt.DrawText(sm-1+0.3, -17.7, Form("-%d",i+1)); } else { sm = 4*(i-18)+3 ; line.DrawLine(sm, 0, sm, -17) ; txt.SetTextAlign(12); txt.DrawText(sm-2+0.3, 18.5, Form("+%d",i-17)); } } line.DrawLine(1, 0, 73, 0) ; line.DrawLine(1, -17, 73, -17) ; line.DrawLine(1, 1, 73, 1) ; line.DrawLine(1, 18, 73, 18) ; }
void HiggsPlot::PlotBF(int iDecay, double tBmH_max, double BF_max){ if(iDecay<0 || iDecay>2) {cout<<"iDecay must be 0, 1 or 2"<<endl; return;} styles style; style.setPadsStyle(-1); style.setDefaultStyle(); int nBins = 1000; TString hName, epsName = "public_html/Higgs_BF_TEMP_BaBar.eps", label, Llabel, Rlabel; TString yTitle[] = {"BF(B#rightarrow#tau#nu) (10^{-5})", "R(D)", "R(D*)"}; TString TagDecay[] = {"BF", "R(D)", "R(D*)"}; TCanvas can; TH1F *hBF[2]; for(int his=0; his<1; his++) { hName = "hBF"; hName += his; hBF[his] = new TH1F(hName,"",nBins,0,tBmH_max); } double tBmH, BF[2]; for(int bin=1; bin<=nBins; bin++){ tBmH = hBF[0]->GetBinCenter(bin); Compute(tBmH,BF,iDecay); hBF[0]->SetBinContent(bin, BF[0]); hBF[0]->SetBinError(bin, BF[1]); } hBF[0]->SetFillColor(2); hBF[0]->SetLineColor(2); hName += "1"; hBF[1] = static_cast<TH1F*>(hBF[0]->Clone(hName)); for(int bin=1; bin<=nBins; bin++)hBF[1]->SetBinError(bin,0); hBF[1]->SetFillColor(0);hBF[1]->SetLineColor(1); hBF[1]->SetLineWidth(2); TBox box; box.SetLineColor(4);box.SetFillColor(4); TLine line; line.SetLineStyle(1); line.SetLineColor(4); line.SetLineWidth(3); if(BF_max>0) hBF[0]->SetMaximum(BF_max); hBF[0]->Draw("e3"); box.SetFillStyle(3002); box.DrawBox(0,Measurement[iDecay][0]-Measurement[iDecay][1], tBmH_max,Measurement[iDecay][0]+Measurement[iDecay][1]); line.DrawLine(0,Measurement[iDecay][0],tBmH_max,Measurement[iDecay][0]); hBF[0]->Draw("e3 same"); hBF[1]->Draw("c same"); Compute(0,BF,iDecay); label = "#splitline{"; label += TagDecay[iDecay]; label += "_{SM} = "; if(iDecay==0){ label+="(";label+=RoundNumber(BF[0],1); label+=" #pm "; label+=RoundNumber(BF[1],1); label+=")#times10^{-5}}{BF_{exp} = ("; label+=RoundNumber(Measurement[iDecay][0],1); label+=" #pm "; label+=RoundNumber(Measurement[iDecay][1],1); label+=")#times10^{-5}}"; Llabel = ""; Rlabel = label; } else { label+=RoundNumber(BF[0],3); label+=" #pm "; label+=RoundNumber(BF[1],3); label+="}{"; label += TagDecay[iDecay]; label += "_{exp} = "; label+=RoundNumber(Measurement[iDecay][0],3); label+=" #pm "; label+=RoundNumber(Measurement[iDecay][1],3); label+="}"; Rlabel = ""; Llabel = label; } style.setTitles(hBF[0],"tan#beta/m_{H^{+}} (GeV^{-1})",yTitle[iDecay],Llabel,Rlabel); epsName.ReplaceAll("TEMP",DecayName[iDecay]); can.SaveAs(epsName); for(int his=0; his<2; his++) hBF[his]->Delete(); }
void DrawShashlikModule(TPad* cc){ cc->cd(); for (int i=0; i<5; i++) { // TString name = Form ("vert_%d",i); // TLine* vert = new TLine (name.Data(),i*14-28,-28,i*14-28,28); TLine* vert = new TLine (i*14-28,-28,i*14-28,28); vert->SetLineColor(kRed); vert->DrawClone("same"); } for (int i=0; i<5; i++) { // TString name = Form ("oriz_%d",i); // TLine* oriz = new TLine (name.Data(),-28,i*14-28,28,i*14-28); TLine* oriz = new TLine (-28,i*14-28,28,i*14-28); oriz->SetLineColor(kRed); oriz->DrawClone("same"); } }
double Fit511Photopeak(TH1* h, double* error=0) { TSpectrum spec(1); spec.Search(h); h->GetXaxis()->SetTitle("Energy [photoelectrons]"); h->Draw("e"); TH1* bg = spec.Background(h); TH1* sig = (TH1*)(h->Clone()); sig->SetLineColor(kGreen); sig->Add(bg,-1); sig->Draw("same e"); sig->Fit("gaus","m","same e"); TF1* gaus = sig->GetFunction("gaus"); if(gaus) gaus->SetLineColor(kGreen); bg->SetLineColor(kRed); bg->Draw("same e"); TLine* line = new TLine(gaus->GetParameter(1),0, gaus->GetParameter(1),h->GetMaximum()); line->SetLineColor(kBlue); line->SetLineWidth(2); line->Draw(); double yield = spec.GetPositionX()[0]/epeak; double err = 0; cout<<"Results from TSpectrum: \n\t" <<"Peak = "<<spec.GetPositionX()[0]<<" p.e.; Light Yield = " <<yield<<" p.e./keV"<<endl; if(gaus){ yield = gaus->GetParameter(1)/epeak; err = gaus->GetParError(1)/epeak; cout<<"Results from BG Subtracted Gaus Fit: \n\t" <<"Peak = "<<gaus->GetParameter(1)<<" p.e.; Light Yield = " <<yield<<" +/- "<<err<<" p.e./keV"<<endl; err = max(err, TMath::Abs(yield-spec.GetPositionX()[0]/epeak)); } TLegend* leg = new TLegend(.6,.6,.9,.9); leg->AddEntry(h,"Raw Spectrum","lpe"); leg->AddEntry(bg,"Background","lpe"); leg->AddEntry(sig,"Signal","lpe"); char title[20]; sprintf(title,"Yield = %.2f pe/keV",yield); leg->AddEntry(line, title ,"l"); leg->Draw(); if(error) *error = err; return yield; }
//------------------------------------------------------------// // Make line //------------------------------------------------------------// TLine* makeLine(float x0, float x1, float y0, float y1, int color=kBlack, int style=1) { TLine* line = new TLine(x0,y0,x1,y1); line->SetLineWidth(1); line->SetLineColor(color); line->SetLineStyle(style); return line; }
void DrawLabel(TString txt, double x, double y, int mstyle, int col, double msize) { TMarker *m = new TMarker(x,y,mstyle); m->SetNDC(); m->SetMarkerSize(msize); m->SetMarkerColor(col); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(col); m->Draw(); tex->SetTextSize(0.04); tex->SetTextAlign(12); tex->SetTextColor(col); tex->DrawLatex(x+0.025,y,txt); tex->SetTextColor(kBlack); }
ExtraAxis anotherScale (const TH1* refHist, double scale, int color, const char* title, double offset) { ExtraAxis result; double x0 = refHist->GetXaxis()->GetXmin(); double x1 = refHist->GetXaxis()->GetXmax(); double y0 = refHist->GetMinimum(); double y1 = refHist->GetMaximum(); // double y0 = refHist->GetYaxis()->GetXmin(); // double y1 = refHist->GetYaxis()->GetXmax(); double xoffset = exp (log(x0) - (log(x1) - log(x0))*offset); TGaxis* axis = new TGaxis(xoffset, y0, xoffset, y1, y0*scale,y1*scale,510,"-GS"); axis->ImportAxisAttributes (refHist->GetXaxis()); axis->SetTitle(title); axis->SetTextColor (color); axis->SetLineColor (color); axis->SetLineWidth (1); axis->SetTextColor (color); axis->SetLabelColor (color); axis->SetLabelOffset (0.); axis->SetTitleOffset (0.65); axis->SetTickSize(0.015); result.Add (axis); TLine* line = new TLine (xoffset, y0, xoffset, y1); line->SetLineColor (color); line->SetLineWidth (2); result.Add (line); line = new TLine (x0, y0, xoffset, y0); line->SetLineColor (kGray); line->SetLineWidth (2); result.Add (line); line = new TLine (x0, y1, xoffset, y1); line->SetLineColor (kGray); line->SetLineWidth (2); result.Add (line); return result; }
void drawEventRPhi(double vxlb, double vylb, double vxl0, double vyl0, double pmu1, double phimu1, double pmu2, double phimu2, double ppr, double phipr, double ppi, double phipi, int colors = 0) { Color_t colMu1(1), colMu2(1), colPr(1), colPi(1), colL0(1), colLb(1); switch(colors) { case 0: colLb=1; colL0=2; colMu1=2; colMu2=2; colPr=3; colPi=4; break; case 1: colLb=11; colL0=50; colMu1=50; colMu2=50; colPr=8; colPi=9; break; } // draw the vertices TMarker *m; const double xlb = vxlb; const double ylb = vylb; m = new TMarker(xlb,ylb,7); m->SetMarkerColor(colLb); m->Draw(); const double xl0 = vxl0; const double yl0 = vyl0; m = new TMarker(xl0,yl0,7); m->SetMarkerColor(colL0); m->Draw(); // draw the l0 flight line TLine *l; l = new TLine(vxlb,vylb,vxl0,vyl0); l->SetLineColor(colL0); l->SetLineStyle(2); l->Draw(); // draw the muons TArrow *a; const double xmu1 = xlb + scalemu * pmu1 * TMath::Cos(phimu1); const double ymu1 = ylb + scalemu * pmu1 * TMath::Sin(phimu1); a = new TArrow(xlb,ylb,xmu1,ymu1,.01,">"); a->SetLineColor(colMu1); a->Draw(); const double xmu2 = xlb + scalemu * pmu2 * TMath::Cos(phimu2); const double ymu2 = ylb + scalemu * pmu2 * TMath::Sin(phimu2); a = new TArrow(xlb,ylb,xmu2,ymu2,.01,">"); a->SetLineColor(colMu2); a->Draw(); // draw the p and pi const double xpr = xl0 + scalepr * ppr * TMath::Cos(phipr); const double ypr = yl0 + scalepr * ppr * TMath::Sin(phipr); a = new TArrow(xl0,yl0,xpr,ypr,.01,">"); a->SetLineColor(colPr); a->Draw(); const double xpi = xl0 + scalepi * ppi * TMath::Cos(phipi); const double ypi = yl0 + scalepi * ppi * TMath::Sin(phipi); a = new TArrow(xl0,yl0,xpi,ypi,.01,">"); a->SetLineColor(colPi); a->Draw(); }
//======================================== void Draw2DHist(TH2F *h2D_Pt_Rap, Char_t *hltTag){ gStyle->SetOptStat(0); gStyle->SetPadRightMargin(0.12); Char_t name[100]; TCanvas *c2 = new TCanvas("c2a", "2D distribution", 600, 600); gPad->SetLogz(); // TH1F *hFrame = gPad->DrawFrame( // h2D_Pt_Rap->Draw("box"); h2D_Pt_Rap->GetYaxis()->SetTitleOffset(1.6); h2D_Pt_Rap->SetAxisRange(0,30.,"y"); h2D_Pt_Rap->SetMaximum(4000.); h2D_Pt_Rap->Draw("colz"); h2D_Pt_Rap->SetXTitle("y"); h2D_Pt_Rap->SetYTitle("p_{T} [GeV]"); TLine *lineV = new TLine(); lineV->SetLineColor(0); lineV->SetLineWidth(2); for(int iRap = 0; iRap < 2*onia::kNbRapBins+1; iRap++) lineV->DrawLine(onia::rapRange[iRap], 0., onia::rapRange[iRap], 30.); TLine *lineH = new TLine(); lineH->SetLineColor(0); lineH->SetLineWidth(2); for(int iRap = 1; iRap < onia::kNbRapForPTBins+1; iRap++){ for(int iPT = 1; iPT < onia::kNbPTBins[iRap]+1; iPT++){ lineH->DrawLine(onia::rapForPTRange[iRap-1], onia::pTRange[iRap][iPT], onia::rapForPTRange[iRap], onia::pTRange[iRap][iPT]); lineH->DrawLine(-onia::rapForPTRange[iRap-1], onia::pTRange[iRap][iPT], -onia::rapForPTRange[iRap], onia::pTRange[iRap][iPT]); } } // TLatex *tex = new TLatex(-2.3, 27., hltTag); // tex->SetTextSize(0.045); // tex->Draw(); // sprintf(name, "Figures/ptVsRap_%s.gif", hltTag); c2->Print(name); // sprintf(name, "Figures/ptVsRap_%s.pdf", hltTag); c2->Print(name); sprintf(name, "Figures/ptVsRap_Upsilons.gif"); c2->Print(name); sprintf(name, "Figures/ptVsRap_Upsilons.pdf"); c2->Print(name); }
pair <float,float> find_interpolated_point(TH2F* histo, int xbin, bool mSUGRA=true) { int minaccept=4; TCanvas *flatcan = new TCanvas("flatcan","flatcan"); stringstream histoname; histoname << "exclusion shape for x bin " << xbin; TH1F *flathisto; if(mSUGRA) flathisto = new TH1F("flat",histoname.str().c_str(),histo->GetNbinsY(),histo->GetYaxis()->GetBinLowEdge(1),histo->GetYaxis()->GetBinLowEdge(histo->GetNbinsY())+histo->GetYaxis()->GetBinWidth(histo->GetNbinsY())); else flathisto = new TH1F("flat",histoname.str().c_str(),histo->GetNbinsX(),histo->GetXaxis()->GetBinLowEdge(1),histo->GetXaxis()->GetBinLowEdge(histo->GetNbinsX())+histo->GetXaxis()->GetBinWidth(histo->GetNbinsX())); int acceptedpoints=0; int nbins=histo->GetNbinsY(); if(!mSUGRA) histo->GetNbinsX(); for(int i=1;i<nbins;i++) { float value=0; if(i<=nbins-2) value=((1/3.0)*(histo->GetBinContent(xbin,i)+histo->GetBinContent(xbin+1,i)+histo->GetBinContent(xbin+2,i))); if(i==nbins-1) value=((1/2.0)*(histo->GetBinContent(xbin,i)+histo->GetBinContent(xbin,i+1))); if(i==nbins) value=(histo->GetBinContent(xbin,i)); if(value<20&&value>0) { flathisto->SetBinContent(i,value); flathisto->SetBinError(i,TMath::Sqrt(value)); acceptedpoints++; } } float pointone=-100; TLine *excluded; if(acceptedpoints>minaccept) { flathisto->Fit("expo","Q"); TF1 *fitfunc = (TF1*)flathisto->GetFunction("expo"); pointone=-(fitfunc->GetParameter(0)/fitfunc->GetParameter(1)); excluded=new TLine(pointone,0,pointone,10); } pair <float,float> anything; anything.first=histo->GetXaxis()->GetBinCenter(xbin); anything.second=pointone; stringstream flatname; flathisto->GetYaxis()->SetRangeUser(0,10); flathisto->Draw(); if(acceptedpoints>minaccept) excluded->SetLineColor(kGreen); if(acceptedpoints>minaccept) excluded->SetLineStyle(2); if(acceptedpoints>minaccept) excluded->SetLineWidth(2); if(acceptedpoints>minaccept) excluded->Draw("same"); flatname << "Limits/partials/partial_" << xbin << "___" << histo->GetName() << ".png"; if(draweachone) CompleteSave(flatcan,flatname.str()); delete flatcan; delete flathisto; return anything; }
void drawTheory(int i, double mean, double nErr, double pErr, double vstep) { double lowY = (i+1)*vstep; // margins are 1 vstep each double uppY = (i+2)*vstep; TBox* band = new TBox(mean-nErr,lowY+0.1*vstep,mean+pErr,uppY-0.1*vstep); band->SetFillColor(kYellow-4); band->Draw(); TLine* center = new TLine(mean, 0, mean, 1); center->SetLineStyle(2); // dash center->SetLineWidth(4); center->SetLineColor(2); center->Draw(); return; }
void setCtauFrom2DRange(RooWorkspace& myws, RooPlot* frame, string dsName, bool setLogScale, vector<double> rangeErr, double excEvts) { // Find maximum and minimum points of Plot to rescale Y axis TH1* h = myws.data(dsName.c_str())->createHistogram("hist", *myws.var("ctau"), Binning(frame->GetNbinsX(),frame->GetXaxis()->GetXmin(),frame->GetXaxis()->GetXmax())); Double_t YMax = h->GetBinContent(h->GetMaximumBin()); Double_t YMin = 1e99; for (int i=1; i<=h->GetNbinsX(); i++) if (h->GetBinContent(i)>0) YMin = min(YMin, h->GetBinContent(i)); Double_t Yup(0.),Ydown(0.); if(setLogScale) { Yup = YMax*TMath::Power((YMax/0.1), 0.5); Ydown = 0.1; } else { Yup = YMax+(YMax-0.0)*0.5; Ydown = 0.0; } frame->GetYaxis()->SetRangeUser(Ydown,Yup); delete h; if (excEvts>0.0) { TLine *minline = new TLine(rangeErr[0], 0.0, rangeErr[0], (setLogScale?(Ydown*TMath::Power((Yup/Ydown),0.4)):(Ydown + (Yup-Ydown)*0.4))); minline->SetLineStyle(2); minline->SetLineColor(1); minline->SetLineWidth(3); frame->addObject(minline); TLine *maxline = new TLine(rangeErr[1], 0.0, rangeErr[1], (setLogScale?(Ydown*TMath::Power((Yup/Ydown),0.4)):(Ydown + (Yup-Ydown)*0.4))); maxline->SetLineStyle(2); maxline->SetLineColor(1); maxline->SetLineWidth(3); frame->addObject(maxline); } };
void DrawMeasurement( TH1 *h, Int_t nbin, Double_t val, Double_t err ) { TAxis *axis = h->GetYaxis(); Double_t dy; Double_t x1,y1,x2,y2, ymin; Int_t i = nbin; ymin = axis->GetBinCenter(i)+1; dy = axis->GetBinWidth(i); x1 = val - err; y1 = ymin - 0.05*dy; x2 = val + err; y2 = ymin + 0.05*dy; TLine* line = new TLine; TLine* lbar = new TLine; TLine* rbar = new TLine; TMarker* m2 = new TMarker( val, ymin, 20 ); Int_t color = 1; line->SetLineColor( color ); line->SetLineWidth( 2 ); lbar->SetLineColor( color ); lbar->SetLineWidth( 2 ); rbar->SetLineColor( color ); rbar->SetLineWidth( 2 ); m2->SetMarkerColor( color ); m2->SetMarkerSize( 1.2 ); m2->SetMarkerStyle( 21 ); line->DrawLine( x1, ymin, x2, ymin ); lbar->DrawLine( x1, y1, x1, y2 ); rbar->DrawLine( x2, y1, x2, y2 ); m2->Draw(); }
void plotAndProfileX (TH2* h2, float min, float max, bool profile) { setStyle(h2); gPad->SetGrid(1,1); gStyle->SetGridColor(15); h2->GetYaxis()->SetRangeUser(min,max); h2->Draw(); if (profile) { TProfile* prof = h2->ProfileX(); prof->SetMarkerColor(2); prof->SetLineColor(2); prof->Draw("same"); } TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0); l->SetLineColor(3); l->Draw(); }
void drawExperiments(){ TEllipse *eRHIC = new TEllipse(0.4, 0.55, 0.035, 0.13, 0., 165., 335.); // eRHIC->SetFillColor(0); eRHIC->SetNoEdges(); eRHIC->SetFillStyle(0); eRHIC->SetLineWidth(2); eRHIC->Draw(); TLine *lGarbage = new TLine(0.383507,0.595395,0.401148,0.546523); lGarbage->SetLineColor(17); lGarbage->SetLineWidth(3); lGarbage->Draw(); TArrow *aRHIC = new TArrow(0.385543,0.600282,0.382829,0.595395, 0.025, "|>"); aRHIC->Draw(); TLatex *xRHIC = new TLatex(0.417432, 0.679342, "RHIC"); xRHIC->SetTextSize(0.04); xRHIC->Draw(); }
void SetupTowerDisplay(TH2F *hist) { hist->SetStats(kFALSE); hist->SetXTitle("ieta"); hist->SetYTitle("iphi"); hist->GetXaxis()->CenterTitle(); hist->GetYaxis()->CenterTitle(); hist->GetXaxis()->SetNdivisions(65); hist->GetXaxis()->SetLabelColor(0); hist->GetXaxis()->SetTickLength(.78); hist->GetXaxis()->SetTitleOffset(0.95); hist->GetYaxis()->SetNdivisions(72); hist->GetYaxis()->SetLabelColor(0); hist->GetYaxis()->SetTitleOffset(0.85); TText *yLabel = new TText(); TLine *pLine = new TLine(); pLine->SetLineStyle(1); pLine->SetLineColor(1); pLine->SetLineWidth(1); yLabel->SetTextAlign(22); yLabel->SetTextSize(0.015); char phi_num[3]; char eta_num[3]; TText *xLabel = new TText(); xLabel->SetTextSize(0.015); xLabel->SetTextAlign(22); for (Int_t i=1; i<73; ++i) { sprintf(phi_num,"%d",i); if(TMath::Abs(i%2)==1) {yLabel->DrawText(-33,0.5+i,phi_num);} else {yLabel->DrawText(-34.5,0.5+i,phi_num);} pLine->DrawLine(-32,i,33,i); } for (Int_t i=-32; i<33;++i) { sprintf(eta_num,"%d",i); if(TMath::Abs(i%2)==0) {xLabel->DrawText(0.5+i,-0.5,eta_num);} else {xLabel->DrawText(0.5+i,-2,eta_num);} pLine->DrawLine(i,1,i,72); } }
void plotter::good_bad(vector<double> &vecx, vector<double> &best_gen, vector<double> &smeared_gen, string filename, string title, string xaxis_label) { cout << "scattering plot" << endl; int n = vecx.size(); double arrx[n]; double arry[n]; for (int i=0; i<n; i++){ //arrx[i] = log10(vecx.at(i)+1e-20); arrx[i] = vecx.at(i); double dif = abs(best_gen.at(i)) - abs(smeared_gen.at(i)); arry[i] = dif; } cout << "created arrs" << endl; TCanvas* canvas = new TCanvas("canvas"); TGraph *g = new TGraph(n, arrx, arry); g->SetMarkerStyle(2); cout << "getting axes" << endl; g->Draw("ap"); g->GetXaxis()->SetTitle(xaxis_label.c_str()); g->GetYaxis()->SetTitle("abs(best_gen) - abs(smeared_gen)"); //g->GetXaxis()->SetRangeUser(0,1); //g->GetYaxis()->SetRangeUser(0,20000); g->SetTitle((title).c_str()); canvas->Update(); TLine *l = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0); l->SetLineColor(kBlue); l->Draw(); cout << "before draw" << endl; //g->Draw("ap"); canvas->Update(); cout << "after draw" << endl; canvas->Print(filename.c_str()); cout << "after print" << endl; }
//------------------------------------------// // Problem 1: there is a function called // utctimes(...). I want to figure out // where I should place cuts to seperate // the various luminosities //------------------------------------------// void checkUTCTimes(TTree* tree) { // Variables to plot TString varx = "startUTCDaqTime_/1.e15"; // scale by 1e15 TString vary = "DetectorResponseEvent_.totalBestEstimatedNPE_/1000."; //TString vary = "AtwdResponseChannels_.estimatedNPE_"; // Make canvas TCanvas* c = makeCanvas("c"); // Make a histogram to save float xmin = isSC2 ? 279.98 : 276.67; float xmax = isSC2 ? 280.15 : 276.84; float ymin = 0; float ymax = isSC2 ? 900 : 160; TH2F* frame = new TH2F("frame","",1, xmin,xmax,1,ymin,ymax); setAtt(frame,"Start DAQ Time / 10^{14}","Total Best Estimated NPE / 10^{3}"); frame->Draw(); // Draw from tree tree->Draw((vary+":"+varx).Data(),"","same"); // Add constant functions of time vector<double> times = isSC2 ? getTimesSC2() : getTimesSC1(); TLine* line = new TLine(); line->SetLineWidth(1); line->SetLineColor(kBlue); for(unsigned int t=0; t<times.size(); ++t){ double time = times.at(t); line->DrawLine(time,ymin,time,ymax); line->Draw("same"); } // Save the plot TString pname = "timeVsAmp.png"; c->SaveAs((savedir+pname).Data()); }