void annconvergencetest( TDirectory *lhdir ) { TCanvas* c = new TCanvas( "MLPConvergenceTest", "MLP Convergence Test", 150, 0, 600, 580*0.8 ); TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" ); TH1* estimatorHistTest = (TH1*)lhdir->Get( "estimatorHistTest" ); Double_t m1 = estimatorHistTrain->GetMaximum(); Double_t m2 = estimatorHistTest ->GetMaximum(); Double_t max = TMath::Max( m1, m2 ); m1 = estimatorHistTrain->GetMinimum(); m2 = estimatorHistTest ->GetMinimum(); Double_t min = TMath::Min( m1, m2 ); estimatorHistTrain->SetMaximum( max + 0.1*(max - min) ); estimatorHistTrain->SetMinimum( min - 0.1*(max - min) ); estimatorHistTrain->SetLineColor( 2 ); estimatorHistTrain->SetLineWidth( 2 ); estimatorHistTrain->SetTitle( TString("MLP Convergence Test") ); estimatorHistTest->SetLineColor( 4 ); estimatorHistTest->SetLineWidth( 2 ); estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" ); estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" ); estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 ); estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 ); estimatorHistTrain->Draw(); estimatorHistTest ->Draw("same"); // need a legend TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20, 1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 ); legend->AddEntry(estimatorHistTrain,"Training Sample","l"); legend->AddEntry(estimatorHistTest,"Test sample","l"); legend->Draw("same"); legend->SetMargin( 0.3 ); c->cd(); TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-( c->Update(); TString fname = "plots/annconvergencetest"; TMVAGlob::imgconv( c, fname ); }
// Draw pT balance plots void PlotOnCanvas(TH1& genHist, TH1& recoHist, TString plotname) { gROOT->ProcessLine(".L mystyle.C"); setTDRStyle(); tdrStyle->SetErrorX(0.5); tdrStyle->SetPadLeftMargin(0.14); tdrStyle->SetPadRightMargin(0.10); tdrStyle->SetLegendBorderSize(0); tdrStyle->SetTitleYOffset(1.5); TCanvas canvas("canvas", "", 500, 500); gStyle->SetOptStat(0); genHist.SetMinimum(0); genHist.Draw(); genHist.Draw("hist same"); recoHist.Draw("same"); recoHist.Draw("HIST same"); leg_hist = new TLegend(0.6,0.7,0.89,0.89); leg_hist->AddEntry(&genHist,"Generator level","l"); leg_hist->AddEntry(&recoHist,"Calorimeter level","l"); leg_hist->SetFillColor(0); leg_hist->Draw(); canvas.SaveAs(plotname+TString(".eps")); canvas.SaveAs(plotname+TString(".gif")); canvas.SaveAs(plotname+TString(".root")); canvas.Close(); // delete leg_hist; }
void showGraph(double canvasSizeX, double canvasSizeY, TGraph* graph, bool useLogScaleX, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset, bool useLogScaleY, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetTopMargin(0.05); canvas->SetLeftMargin(0.19); canvas->SetBottomMargin(0.19); canvas->SetRightMargin(0.05); canvas->SetLogx(useLogScaleX); canvas->SetLogy(useLogScaleY); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 10, xMin, xMax); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); dummyHistogram->Draw("axis"); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); xAxis->SetTitleSize(0.065); xAxis->SetLabelSize(0.055); xAxis->SetLabelOffset(0.01); xAxis->SetTickLength(0.055); xAxis->SetNdivisions(505); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); yAxis->SetTitleSize(0.070); yAxis->SetLabelSize(0.055); yAxis->SetLabelOffset(0.01); yAxis->SetTickLength(0.055); yAxis->SetNdivisions(505); graph->SetMarkerColor(1); graph->SetLineColor(1); graph->Draw("p"); canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( useLogScaleY ) 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 dummyHistogram; delete canvas; }
TH1 *computeEffVsCut(TH1 *discrShape, double total) { TH1 *h = discrShape->Clone(Form("%s_effVsCut", discrShape->GetName())); h->Sumw2(); h->SetMaximum(1.5); h->SetMinimum(1e-3); unsigned int n = h->GetNbinsX(); for(unsigned int bin = 1; bin <= n; bin++) { double efficiency = h->Integral(bin, n + 1) / total; double error = sqrt(efficiency * (1 - efficiency) / total); h->SetBinContent(bin, efficiency); h->SetBinError(bin, error); } return h; }
void TestShaping(int max=4) { TArrayI adcs(10); TGraph* orig = new TGraph(adcs.fN); orig->SetName("Original"); orig->SetTitle("Original"); orig->SetMarkerStyle(25); orig->SetMarkerColor(1); orig->SetMarkerSize(2); orig->SetLineColor(1); for (Int_t i = 0; i < adcs.fN; i++) { adcs.fArray[i] = Int_t(gRandom->Uniform(0, 1023)); orig->SetPoint(i, i, adcs.fArray[i]); } TCanvas* c = new TCanvas("c", "c"); c->SetFillColor(0); c->SetTopMargin(.02); c->SetRightMargin(.02); TH1* h = new TH1F("frame","frame", adcs.fN+1, -2, adcs.fN); h->SetMinimum(0); h->SetMaximum(1300); h->SetStats(0); h->Draw(""); orig->Draw("pl same"); TLegend* l = new TLegend(adcs.fN*3./4, 1023, adcs.fN, 1300, "", ""); l->SetFillColor(0); l->SetBorderSize(1); l->AddEntry(orig, orig->GetTitle(), "lp"); for (int i = 1; i <= max; i++) { TGraph* g = makeGraph(adcs, i); g->Draw("pl same"); l->AddEntry(g, g->GetTitle(), "lp"); } l->Draw(); c->Modified(); c->Update(); c->cd(); }
TH1 *computeEffVsBEff(TH1 *effVsCut, TH1 *effVsCutB) { TH1 *h = new TH1F(Form("%s_effVsBEff", effVsCut->GetName()), "effVsBEff", 100, 0, 1); h->SetMaximum(1.5); h->SetMinimum(1e-3); unsigned int n = effVsCut->GetNbinsX(); for(unsigned int bin = 1; bin <= n; bin++) { double eff = effVsCut->GetBinContent(bin); double error = effVsCut->GetBinError(bin); double effB = effVsCutB->GetBinContent(bin); h->SetBinContent(h->FindBin(effB), eff); h->SetBinError(h->FindBin(effB), error); // FIXME: The error in effB is not propagated } return h; }
void drawTimeDifference (TDirectory* directory, TH1* refHisto, const char* fname=0) { TGraphErrors* graphX = (TGraphErrors*)directory->Get("x"); if ( graphX==0 ) return; TH1I* hFirst = (TH1I*)directory->Get("firstTime"); TH1I* hLast = (TH1I*)directory->Get("lastTime"); if ( hFirst==0 || hLast==0 ) return; std::string fullName("cDeltaT"); if ( fname ) fullName += fname; else fullName += directory->GetName(); TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str()); TH1* h = refHisto->Clone("DeltaT"); h->Reset(); h->SetTitle("DeltaT"); TGraph* graph = new TGraph(); graph->SetName("gDeltaT"); double xg,yg; for ( unsigned int i=1; i<=hFirst->GetNbinsX(); ++i ) { std::time_t t1 = hFirst->GetAt(i); std::time_t t2 = hLast->GetAt(i); TTimeStamp ts1(hFirst->GetAt(i)); std::cout << "Fit started at " << ts1.AsString() << std::endl; graphX->GetPoint(i-1,xg,yg); graph->SetPoint(i-1,xg,difftime(t2,t1)); } double xmin,xmax,ymin,ymax; graph->ComputeRange(xmin,ymin,xmax,ymax); h->SetMinimum(0.); h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.); h->Draw(); graph->SetMarkerStyle(20); // graph->SetMarkerColor(2); // graph->SetLineColor(2); graph->Draw("P"); }
void boostcontrolplots( TDirectory *boostdir ) { const Int_t nPlots = 4; Int_t width = 900; Int_t height = 600; char cn[100]; const TString titName = boostdir->GetName(); sprintf( cn, "cv_%s", titName.Data() ); TCanvas *c = new TCanvas( cn, Form( "%s Control Plots", titName.Data() ), width, height ); c->Divide(2,2); const TString titName = boostdir->GetName(); TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"}; for (Int_t i=0; i<nPlots; i++){ Int_t color = 4; TPad * cPad = (TPad*)c->cd(i+1); TH1 *h = (TH1*) boostdir->Get(hname[i]); TString plotname = h->GetName(); h->SetMaximum(h->GetMaximum()*1.3); h->SetMinimum( 0 ); h->SetMarkerColor(color); h->SetMarkerSize( 0.7 ); h->SetMarkerStyle( 24 ); h->SetLineWidth(1); h->SetLineColor(color); h->Draw(); c->Update(); } // write to file TString fname = Form( "plots/%s_ControlPlots", titName.Data() ); TMVAGlob::imgconv( c, fname ); }
void axesStyle(TH1& hist, const char* titleX, const char* titleY, float yMin, float yMax, float yTitleSize, float yTitleOffset) { hist.SetTitle(""); hist.GetXaxis()->SetTitle(titleX); hist.GetXaxis()->CenterTitle(); hist.GetXaxis()->SetTitleSize ( 0.06); hist.GetXaxis()->SetTitleColor ( 1); hist.GetXaxis()->SetTitleOffset( 1.0); hist.GetXaxis()->SetTitleFont ( 62); hist.GetXaxis()->SetLabelSize ( 0.05); hist.GetXaxis()->SetLabelFont ( 62); hist.GetXaxis()->SetNdivisions ( 505); hist.GetYaxis()->SetTitle(titleY); hist.GetYaxis()->SetTitleSize ( yTitleSize ); hist.GetYaxis()->SetTitleColor ( 1); hist.GetYaxis()->SetTitleOffset(yTitleOffset); hist.GetYaxis()->SetTitleFont ( 62); hist.GetYaxis()->SetLabelSize ( 0.04); hist.GetYaxis()->SetLabelFont ( 62); hist.GetYaxis()->CenterTitle ( true); if(yMin!=-123) hist.SetMinimum(yMin); if(yMax!=-123) hist.SetMaximum(yMax); }
void drawEventDifference (TDirectory* directory, TH1* refHisto, const char* fname=0) { TGraphErrors* graphX = (TGraphErrors*)directory->Get("x"); if ( graphX==0 ) return; TH1I* hFirst = (TH1I*)directory->Get("firstEvent"); TH1I* hLast = (TH1I*)directory->Get("lastEvent"); if ( hFirst==0 || hLast==0 ) return; std::string fullName("cDeltaE"); if ( fname ) fullName += fname; else fullName += directory->GetName(); TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str()); TH1* h = refHisto->Clone("DeltaE"); h->Reset(); h->SetTitle("DeltaE"); TGraph* graph = new TGraph(); graph->SetName("gDeltaE"); double xg,yg; for ( unsigned int i=1; i<=hFirst->GetNbinsX(); ++i ) { int e1 = hFirst->GetAt(i); int e2 = hLast->GetAt(i); graphX->GetPoint(i-1,xg,yg); graph->SetPoint(i-1,xg,e2-e1); } double xmin,xmax,ymin,ymax; graph->ComputeRange(xmin,ymin,xmax,ymax); h->SetMinimum(0.); h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.); h->Draw(); graph->SetMarkerStyle(20); // graph->SetMarkerColor(2); // graph->SetLineColor(2); graph->Draw("P"); }
void LEPStyle::draw() { if( _canv==0 ) { setCanvas(); setHist(); _canv->Draw(); if( _ymin==0 ) _ymin = 0.2; // _ymax = _n*1.5; if( _ymax==0 ) _ymax = _n+_upDy; _hist->SetMinimum( _ymin ); _hist->SetMaximum( _ymax ); _hist->Draw(); if( _cmsPrelim ) cmsPrelim( _intLumi ); } // size_t n_ = _entry.size(); _n = _entry.size(); if( _extraBand ) { drawExtraBand(); } if( _band ) { Double_t xx_[5] = { _bxmin, _bxmax, _bxmax, _bxmin, _bxmin }; float eps1_ = _eps1*(_ymax-_ymin); float eps2_ = _eps2*(_ymax-_ymin); Double_t yy_[5] = { _ymin+eps1_, _ymin+eps1_, _ymax-eps2_, _ymax-eps2_, _ymin+eps1_ }; TPolyLine* pl_ = new TPolyLine( 5, xx_, yy_ ); pl_->SetFillStyle(_bandFillStyle); pl_->SetFillColor(_bandFillColor); pl_->SetLineWidth(3); pl_->SetLineColor( kOrange ); pl_->DrawClone("FSame"); TLine* l_ = new TLine( _bx0, _ymin+eps1_, _bx0, _ymax-eps2_ ); l_->SetLineWidth(4); l_->SetLineColor( kOrange ); l_->DrawClone(); if( _hasLegend ) { cout << "HELLO!!!!" << endl; // _y0 = 4.0; if( _y0==0 ) _y0 = _n+2*_upDy/3.; if( _dy==0 ) _dy = 0.06; _x0 = _xmax - 0.05*(_xmax-_xmin); TLatex leg1_; leg1_.SetTextSize(_scale*0.05); leg1_.SetTextAlign(31); leg1_.DrawLatex( _x0, _y0+_dy, _legend ); TLatex leg2_; leg2_.SetTextSize(_scale*0.05); leg2_.SetTextAlign(23); leg2_.DrawLatex( _bx0, _y0-_dy, _theory ); } // TLegend* legend=new TLegend(_x0,_y0, _x0+_dx, _y0+_dy ); // legend->SetLineColor(0); // legend->SetFillColor(0); // // legend->AddEntry(pl_,_legend,"lf"); // legend->AddEntry(pl_,_legend,""); // legend->Draw("same"); } for( size_t ii=0; ii<_entry.size(); ii++ ) { if( _entry[ii]==("SPACE") ) continue; Float_t xval_[1]; Float_t yval_[1]; Float_t ey_[1]; Float_t estatup_[1]; Float_t ecombup_[1]; Float_t etotup_[1]; Float_t estatlo_[1]; Float_t ecomblo_[1]; Float_t etotlo_[1]; float yy_ = _n-(Float_t)ii; xval_[0] = _val[ii]; yval_[0] = yy_; ey_[0] = 0; estatup_[0] = _statup[ii]; ecombup_[0] = sqrt( pow( _statup[ii],2 ) + pow( _systup[ii],2 ) ); etotup_[0] = ecombup_[0] + _lumi[ii]; estatlo_[0] = _statlo[ii]; ecomblo_[0] = sqrt( pow( _statlo[ii],2 ) + pow( _systlo[ii],2 ) ); etotlo_[0] = ecomblo_[0] + _lumi[ii]; TGraphAsymmErrors* gtot_ = new TGraphAsymmErrors( 1, xval_, yval_, etotlo_, etotup_, ey_, ey_ ); gtot_->SetLineColor( kGreen ); TGraphAsymmErrors* gcomb_ = new TGraphAsymmErrors( 1, xval_, yval_, ecomblo_, ecombup_, ey_, ey_ ); gcomb_->SetLineColor( kRed ); TGraphAsymmErrors* gstat_ = new TGraphAsymmErrors( 1, xval_, yval_, estatlo_, estatup_, ey_, ey_ ); gstat_->SetLineColor( kBlack ); gstat_->SetLineWidth( 2 ); gstat_->SetMarkerStyle( _marker[ii] ); gstat_->SetMarkerSize( _size[ii] ); gstat_->SetMarkerColor( _color[ii] ); gcomb_->SetLineWidth( 2 ); gtot_->SetLineWidth( 2 ); if( _lumi[ii]>0 ) gtot_->Draw(); gcomb_->DrawClone(); gstat_->DrawClone("P"); if( !_writeText ) continue; // align = 10*HorizontalAlign + VerticalAlign // For Horizontal alignment the following convention applies: // 1=left adjusted, 2=centered, 3=right adjusted // For Vertical alignment the following convention applies: // 1=bottom adjusted, 2=centered, 3=top adjusted float xtxt_ = _xmin + 0.05*(_xmax-_xmin); TLatex ltx1_; ltx1_.SetTextSize(_scale*_size1); ltx1_.SetTextAlign(_align1); if( _specifyPlacement ) ltx1_.DrawLatex( _xx1, yy_+_e1, _entry[ii] ); else ltx1_.DrawLatex( xtxt_, yy_+E_+e_, _entry[ii] ); TLatex ltx2_; char line_[512]; TString str_; TString pmstr_(" #pm "); TString format_("%-4."); format_ += _ndigit[ii]; format_ += "f"; TString valstr_; TString statstr_; TString syststr_; TString lumistr_; sprintf( line_, format_.Data(), _val[ii] ); // sprintf( line_, "%-4.3f", _val[ii] ); valstr_ = line_; if( fabs( _statup[ii]-_statlo[ii] )<0.01 ) { sprintf( line_, format_.Data(), _statlo[ii] ); } else { sprintf( line_, "#scale[0.7]{#splitline{+%-4.3f}{-%-4.3f}}_{ stat.}", _statup[ii], _statlo[ii] ); } statstr_ = line_; str_ = valstr_ + pmstr_ + statstr_; str_ += "_{ "; str_ += _firstError; str_ += "}"; if( _systup[ii]>0 ) { if( fabs( _systup[ii]-_systlo[ii] )<0.01 ) { sprintf( line_, format_.Data(), _systlo[ii] ); } else { sprintf( line_, "#scale[0.7]{#splitline{+%-4.3f}{- %-4.3f}}_", _systup[ii], _systlo[ii] ); } syststr_ = line_; str_ += pmstr_; str_ += syststr_; str_ += "_{ "; str_ += _secondError; str_ += "}"; } if( _lumi[ii]>0 ) { sprintf( line_, format_.Data(), _lumi[ii] ); lumistr_ = line_; lumistr_ += "_{lumi.}"; str_ += pmstr_ + lumistr_; } // TString str_(line_); str_ += _unit; cout << str_ << endl; ltx2_.SetTextSize(_scale*_size2); ltx2_.SetTextAlign(_align2); if( _specifyPlacement ) ltx2_.DrawLatex( _xx2, yy_+_e2, str_ ); else ltx2_.DrawLatex( xtxt_+0.02*(_xmax-_xmin), yy_+E_-e_, str_ ); } _hist->Draw("Same"); _canv->RedrawAxis(); }
//________________________________________________________ void GFHistManager::DrawReally(Int_t layer) { if(layer < 0 || layer > fDepth-1) { this->Warning("DrawReally","Layer %d does not exist, possible are 0 to %d.", layer, fDepth-1); return; } this->MakeCanvases(layer); TIter canIter(static_cast<TObjArray*>(fCanArrays->At(layer))); TIter histIter(static_cast<TObjArray*>(fHistArrays->At(layer))); Int_t histNo = 0; // becomes number of histograms in layer while(TCanvas* can = static_cast<TCanvas*>(canIter.Next())){ Int_t nPads = this->NumberOfSubPadsOf(can); if (fNoX[layer] * fNoY[layer] != nPads && !(nPads == 0 && fNoX[layer] * fNoY[layer] == 1)) { this->Warning("Update", "inconsistent number of pads %d, expect %d*%d", nPads, fNoX[layer], fNoY[layer]); } for(Int_t i = 0; i <= nPads; ++i){ if (i == 0 && nPads != 0) i = 1; can->cd(i); if(GFHistArray* histsOfPad = static_cast<GFHistArray*>(histIter.Next())){ TIter hists(histsOfPad); TH1* firstHist = static_cast<TH1*>(hists.Next()); firstHist->Draw(); this->DrawFuncs(firstHist); while(TH1* h = static_cast<TH1*>(hists.Next())){ h->Draw(Form("SAME%s%s", (fSameWithStats ? "S" : ""), h->GetOption())); this->DrawFuncs(h); } if(histsOfPad->GetEntriesFast() > 1){ const Double_t max = this->MaxOfHists(histsOfPad); if(//firstHist->GetMaximumStored() != -1111. && ???? max > firstHist->GetMaximumStored()){ firstHist->SetMaximum((fLogY[layer] ? 1.1 : 1.05) * max); } const Double_t min = this->MinOfHists(histsOfPad); if(!(gStyle->GetHistMinimumZero() && min > 0.)) { firstHist->SetMinimum(min * 1.05); } } if(fLogY[layer] && (firstHist->GetMinimum() > 0. || (firstHist->GetMinimum() == 0. && firstHist->GetMinimumStored() == -1111.)))gPad->SetLogy(); // draw other objects: this->DrawObjects(layer, histNo); // make hist style differ if(fDrawDiffStyle) GFHistManager::MakeDifferentStyle(histsOfPad); // draw legends on top of all if(fLegendArrays && layer <= fLegendArrays->GetLast() && fLegendArrays->At(layer)){ this->DrawLegend(layer, histNo); } gPad->Modified(); this->ColourFuncs(histsOfPad); if (fSameWithStats) { gPad->Update(); // not nice to need this here, makes use over network impossible... this->ColourStatsBoxes(histsOfPad); } histNo++; } } // loop over pads } // loop over canvases }
void makePlot(TCanvas* canvas, const std::string& outputFileName, TTree* testTree, const std::string& varName, unsigned numBinsX, double xMin, double xMax) { std::cout << "creating histogramTauIdPassed..." << std::endl; TString histogramTauIdPassedName = TString("histogramTauIdPassed").Append("_").Append(varName.data()); TH1* histogramTauIdPassed = fillHistogram(testTree, varName, "type==1", "", histogramTauIdPassedName.Data(), numBinsX, xMin, xMax); std::cout << "--> histogramTauIdPassed = " << histogramTauIdPassed << ":" << " integral = " << histogramTauIdPassed->Integral() << std::endl; std::cout << "creating histogramTauIdFailed..." << std::endl; TString histogramTauIdFailedName = TString("histogramTauIdFailed").Append("_").Append(varName.data()); TH1* histogramTauIdFailed = fillHistogram(testTree, varName, "type==0", "", histogramTauIdFailedName.Data(), numBinsX, xMin, xMax); std::cout << "--> histogramTauIdFailed = " << histogramTauIdFailed << " integral = " << histogramTauIdFailed->Integral() << std::endl; std::cout << "creating histogramTauIdDenominator..." << std::endl; TString histogramTauIdDenominatorName = TString("histogramTauIdDenominator").Append("_").Append(varName.data()); TH1* histogramTauIdDenominator = new TH1F(histogramTauIdDenominatorName.Data(), histogramTauIdDenominatorName.Data(), numBinsX, xMin, xMax); histogramTauIdDenominator->Add(histogramTauIdPassed); histogramTauIdDenominator->Add(histogramTauIdFailed); std::cout << "--> histogramTauIdDenominator = " << histogramTauIdDenominator << " integral = " << histogramTauIdDenominator->Integral() << std::endl; std::cout << "creating histogramFakeRate..." << std::endl; TString histogramFakeRateName = TString("histogramFakeRate").Append("_").Append(varName.data()); TH1* histogramFakeRate = new TH1F(histogramFakeRateName.Data(), histogramFakeRateName.Data(), numBinsX, xMin, xMax); histogramFakeRate->Add(histogramTauIdPassed); histogramFakeRate->Divide(histogramTauIdDenominator); std::cout << "--> histogramFakeRate = " << histogramFakeRate << " integral = " << histogramFakeRate->Integral() << std::endl; std::cout << "creating histogramFakeRateWeighted..." << std::endl; TString histogramFakeRateWeightedName = TString("histogramFakeRateWeighted").Append("_").Append(varName.data()); TH1* histogramFakeRateWeighted = fillHistogram(testTree, varName, "", "MVA_KNN", histogramFakeRateWeightedName.Data(), numBinsX, xMin, xMax); histogramFakeRateWeighted->Divide(histogramTauIdDenominator); std::cout << "--> histogramFakeRateWeighted = " << histogramFakeRateWeighted << " entries = " << histogramFakeRateWeighted->GetEntries() << "," << " integral = " << histogramFakeRateWeighted->Integral() << std::endl; // Scale the weighted fake rate histogram histogramFakeRate->SetTitle(varName.data()); histogramFakeRate->SetStats(false); histogramFakeRate->SetMinimum(1.e-4); histogramFakeRate->SetMaximum(1.e+1); histogramFakeRate->SetLineColor(2); histogramFakeRate->SetLineWidth(2); histogramFakeRate->SetMarkerStyle(20); histogramFakeRate->SetMarkerColor(2); histogramFakeRate->SetMarkerSize(1); histogramFakeRate->Draw("e1p"); histogramFakeRateWeighted->SetLineColor(4); histogramFakeRateWeighted->SetLineWidth(2); histogramFakeRateWeighted->SetMarkerStyle(24); histogramFakeRateWeighted->SetMarkerColor(4); histogramFakeRateWeighted->SetMarkerSize(1); histogramFakeRateWeighted->Draw("e1psame"); TLegend legend(0.11, 0.73, 0.31, 0.89); legend.SetBorderSize(0); legend.SetFillColor(0); legend.AddEntry(histogramFakeRate, "Tau id. discr.", "p"); legend.AddEntry(histogramFakeRateWeighted, "Fake-Rate weight", "p"); legend.Draw(); canvas->Update(); canvas->Print(outputFileName.data()); }
void makePlot(double canvasSizeX, double canvasSizeY, TH1* histogramTTH, TH1* histogramData, TH1* histogramTT, TH1* histogramTTV, TH1* histogramEWK, TH1* histogramRares, TH1* histogramBgrSum, TH1* histogramBgrUncertainty, const std::string& xAxisTitle, double xAxisOffset, bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, const std::string& outputFileName) { TH1* histogramTTH_density = 0; if ( histogramTTH ) { if ( histogramData ) checkCompatibleBinning(histogramTTH, histogramData); histogramTTH_density = divideHistogramByBinWidth(histogramTTH); } TH1* histogramData_density = 0; if ( histogramData ) { histogramData_density = divideHistogramByBinWidth(histogramData); } TH1* histogramTT_density = 0; if ( histogramTT ) { if ( histogramData ) checkCompatibleBinning(histogramTT, histogramData); histogramTT_density = divideHistogramByBinWidth(histogramTT); } TH1* histogramTTV_density = 0; if ( histogramTTV ) { if ( histogramData ) checkCompatibleBinning(histogramTTV, histogramData); histogramTTV_density = divideHistogramByBinWidth(histogramTTV); } TH1* histogramEWK_density = 0; if ( histogramEWK ) { if ( histogramData ) checkCompatibleBinning(histogramEWK, histogramData); histogramEWK_density = divideHistogramByBinWidth(histogramEWK); } TH1* histogramRares_density = 0; if ( histogramRares ) { if ( histogramData ) checkCompatibleBinning(histogramRares, histogramData); histogramRares_density = divideHistogramByBinWidth(histogramRares); } TH1* histogramBgrSum_density = 0; if ( histogramBgrSum ) { if ( histogramData ) checkCompatibleBinning(histogramBgrSum, histogramData); histogramBgrSum_density = divideHistogramByBinWidth(histogramBgrSum); } TH1* histogramBgrUncertainty_density = 0; if ( histogramBgrUncertainty ) { if ( histogramData ) checkCompatibleBinning(histogramBgrUncertainty, histogramData); histogramBgrUncertainty_density = divideHistogramByBinWidth(histogramBgrUncertainty); } TCanvas* canvas = new TCanvas("canvas", "", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetFillStyle(4000); canvas->SetFillColor(10); canvas->SetTicky(); 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.065); 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.31); bottomPad->SetRightMargin(0.05); bottomPad->SetLogy(false); canvas->cd(); topPad->Draw(); topPad->cd(); TAxis* xAxis_top = histogramData_density->GetXaxis(); xAxis_top->SetTitle(xAxisTitle.data()); xAxis_top->SetTitleOffset(xAxisOffset); xAxis_top->SetLabelColor(10); xAxis_top->SetTitleColor(10); TAxis* yAxis_top = histogramData_density->GetYaxis(); yAxis_top->SetTitle(yAxisTitle.data()); yAxis_top->SetTitleOffset(yAxisOffset); yAxis_top->SetTitleSize(0.085); yAxis_top->SetLabelSize(0.05); yAxis_top->SetTickLength(0.04); TLegend* legend = new TLegend(0.66, 0.45, 0.94, 0.92, NULL, "brNDC"); legend->SetFillStyle(0); legend->SetBorderSize(0); legend->SetFillColor(10); legend->SetTextSize(0.055); histogramData_density->SetTitle(""); histogramData_density->SetStats(false); histogramData_density->SetMaximum(yMax); histogramData_density->SetMinimum(yMin); histogramData_density->SetMarkerStyle(20); histogramData_density->SetMarkerSize(2); histogramData_density->SetMarkerColor(kBlack); histogramData_density->SetLineColor(kBlack); legend->AddEntry(histogramData_density, "Observed", "p"); histogramData_density->Draw("ep"); legend->AddEntry(histogramTTH_density, "t#bar{t}H", "l"); histogramTT_density->SetTitle(""); histogramTT_density->SetStats(false); histogramTT_density->SetMaximum(yMax); histogramTT_density->SetMinimum(yMin); histogramTT_density->SetFillColor(kMagenta - 10); legend->AddEntry(histogramTT_density, "t#bar{t}+jets", "f"); histogramTTV_density->SetFillColor(kOrange - 4); legend->AddEntry(histogramTTV_density, "t#bar{t}+V", "f"); histogramEWK_density->SetFillColor(kRed + 2); legend->AddEntry(histogramEWK_density, "EWK", "f"); histogramRares_density->SetFillColor(kBlue - 8); legend->AddEntry(histogramRares_density, "Rares", "f"); THStack* histogramStack_density = new THStack("stack", ""); histogramStack_density->Add(histogramRares_density); histogramStack_density->Add(histogramEWK_density); histogramStack_density->Add(histogramTTV_density); histogramStack_density->Add(histogramTT_density); histogramStack_density->Draw("histsame"); histogramBgrUncertainty_density->SetFillColor(kBlack); histogramBgrUncertainty_density->SetFillStyle(3344); histogramBgrUncertainty_density->Draw("e2same"); legend->AddEntry(histogramBgrUncertainty_density, "Uncertainty", "f"); histogramTTH_density->SetLineWidth(2); histogramTTH_density->SetLineStyle(1); histogramTTH_density->SetLineColor(kBlue); histogramTTH_density->Draw("histsame"); histogramData_density->Draw("epsame"); histogramData_density->Draw("axissame"); legend->Draw(); addLabel_CMS_luminosity(0.2050, 0.9225, 0.6850); canvas->cd(); bottomPad->Draw(); bottomPad->cd(); TH1* histogramRatio = (TH1*)histogramData->Clone("histogramRatio"); histogramRatio->Reset(); if ( !histogramRatio->GetSumw2N() ) histogramRatio->Sumw2(); checkCompatibleBinning(histogramRatio, histogramBgrSum); histogramRatio->Divide(histogramData, histogramBgrSum); int numBins_bottom = histogramRatio->GetNbinsX(); for ( int iBin = 1; iBin <= numBins_bottom; ++iBin ) { double binContent = histogramRatio->GetBinContent(iBin); if ( histogramData && histogramData->GetBinContent(iBin) >= 0. ) histogramRatio->SetBinContent(iBin, binContent - 1.0); else histogramRatio->SetBinContent(iBin, -10.); } histogramRatio->SetTitle(""); histogramRatio->SetStats(false); histogramRatio->SetMinimum(-0.50); histogramRatio->SetMaximum(+0.50); histogramRatio->SetMarkerStyle(histogramData_density->GetMarkerStyle()); histogramRatio->SetMarkerSize(histogramData_density->GetMarkerSize()); histogramRatio->SetMarkerColor(histogramData_density->GetMarkerColor()); histogramRatio->SetLineColor(histogramData_density->GetLineColor()); histogramRatio->Draw("ep"); TAxis* xAxis_bottom = histogramRatio->GetXaxis(); xAxis_bottom->SetTitle(xAxis_top->GetTitle()); xAxis_bottom->SetLabelColor(1); xAxis_bottom->SetTitleColor(1); xAxis_bottom->SetTitleOffset(1.20); xAxis_bottom->SetTitleSize(0.13); xAxis_bottom->SetLabelOffset(0.02); xAxis_bottom->SetLabelSize(0.10); xAxis_bottom->SetTickLength(0.055); TAxis* yAxis_bottom = histogramRatio->GetYaxis(); yAxis_bottom->SetTitle("#frac{Data - Simulation}{Simulation}"); yAxis_bottom->SetTitleOffset(0.80); yAxis_bottom->SetNdivisions(505); yAxis_bottom->CenterTitle(); yAxis_bottom->SetTitleSize(0.09); yAxis_bottom->SetLabelSize(0.10); yAxis_bottom->SetTickLength(0.04); TH1* histogramRatioUncertainty = (TH1*)histogramBgrUncertainty->Clone("histogramRatioUncertainty"); if ( !histogramRatioUncertainty->GetSumw2N() ) histogramRatioUncertainty->Sumw2(); checkCompatibleBinning(histogramRatioUncertainty, histogramBgrUncertainty); histogramRatioUncertainty->Divide(histogramBgrSum); int numBins = histogramRatioUncertainty->GetNbinsX(); for ( int iBin = 1; iBin <= numBins; ++iBin ) { double binContent = histogramRatioUncertainty->GetBinContent(iBin); histogramRatioUncertainty->SetBinContent(iBin, binContent - 1.0); } histogramRatioUncertainty->SetFillColor(histogramBgrUncertainty_density->GetFillColor()); //histogramRatioUncertainty->SetFillStyle(histogramBgrUncertainty_density->GetFillStyle()); histogramRatioUncertainty->SetFillStyle(3644); TF1* line = new TF1("line","0", xAxis_bottom->GetXmin(), xAxis_bottom->GetXmax()); line->SetLineStyle(3); line->SetLineWidth(1); line->SetLineColor(kBlack); line->Draw("same"); histogramRatioUncertainty->Draw("e2same"); histogramRatio->Draw("epsame"); canvas->Update(); size_t idx = outputFileName.find("."); std::string outputFileName_plot(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 histogramTTH_density; delete histogramData_density; delete histogramTT_density; delete histogramTTV_density; delete histogramEWK_density; delete histogramRares_density; delete histogramBgrSum_density; //delete histogramBgrUncertainty_density; delete histogramStack_density; delete legend; delete topPad; delete histogramRatio; delete histogramRatioUncertainty; delete line; delete bottomPad; delete canvas; }
void makeStack(TString myVar, TString myCut, TString myName, TString myAxisNameX, TString myAxisNameY, vector<const Sample*>& listOfSignals, vector<const Sample*>& listOfSamples, vector<const Sample*> listOfDatasets, TString inFileName, bool isBlind, bool isLog, bool drawSignal, bool drawLegend, int nBins, float xLow, float xHigh, float* xlowVec) { // prepare the input file TFile* infile = new TFile(inFileName, "READ"); infile -> cd(); // prepare the stack THStack *hs = new THStack("hs",""); // prepare the histos pointers TH1F* hist[20]; // prepare the tree pointers TTree* tree[20]; // prepare the legend TLegend* leg = new TLegend(.7485,.7225,.9597,.9604); leg->SetFillColor(0); // prepare the colors Int_t col[20] = {46,2,12,5,3,4,9,7,47,49,49,50,51,52,53,54,55,56,57,58}; // prepare the cut if (isBlind) myCut += "*(phoMetDeltaPhi < 2.9)"; // prepare the Y axis lable if (xlowVec != 0) myAxisNameY = "Events/" + myAxisNameY; else { float binWidth = (xHigh-xLow)/nBins; TString tempString; tempString.Form("%.2f ",binWidth); myAxisNameY = "Events/" + tempString + myAxisNameY; } // prepare the legend strings vector<TString> theLegends; // loop through the datasets and produce the plots TH1F* hdata; TH1F* hsignal; //prepare data and signal histos if (xlowVec != 0) hdata = new TH1F("hdata","",nBins,xlowVec); else hdata = new TH1F("hdata","",nBins,xLow,xHigh); if (xlowVec != 0) hsignal = new TH1F("hsignal","",nBins,xlowVec); else hsignal = new TH1F("hsignal","",nBins,xLow,xHigh); TTree* treedata[20]; for (UInt_t iDatas=0; iDatas < listOfDatasets.size(); iDatas++) { //get the tree treedata[iDatas] = (TTree*) infile -> Get(listOfDatasets.at(iDatas)->Name()->Data()); //fill the histogram if ( iDatas == 0 ) treedata[iDatas] -> Draw(myVar + " >> hdata","evt_weight*kf_weight*pu_weight" + myCut); else treedata[iDatas] -> Draw(myVar + " >>+ hdata","evt_weight*kf_weight*pu_weight" + myCut); if ( isBlind && iDatas == 0 ) leg -> AddEntry(hdata, "DATA (19.8 fb^{-1})", "pl"); }//end loop on datasets if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hdata->SetBinError (iBin,hdata->GetBinError(iBin)/hdata->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hdata->SetBinContent(iBin,hdata->GetBinContent(iBin)/hdata->GetBinWidth(iBin)); } TTree* treesignal[20]; for (UInt_t iSignal=0; iSignal < listOfSignals.size(); iSignal++) { //get the tree treesignal[iSignal] = (TTree*) infile -> Get(listOfSignals.at(iSignal)->Name()->Data()); //fill the histogram TString thisScale = Form("%f *", *(listOfSignals.at(iSignal)->Scale())); if ( iSignal == 0 ) treesignal[iSignal] -> Draw(myVar + " >> hsignal",thisScale + "evt_weight*kf_weight*pu_weight" + myCut); else treesignal[iSignal] -> Draw(myVar + " >>+ hsignal",thisScale + "evt_weight*kf_weight*pu_weight" + myCut); if ( drawSignal && iSignal == 0 ) leg -> AddEntry(hsignal, "Signal", "l"); }//end loop on signals if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hsignal->SetBinError (iBin,hsignal->GetBinError(iBin)/hsignal->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hsignal->SetBinContent(iBin,hsignal->GetBinContent(iBin)/hsignal->GetBinWidth(iBin)); } hsignal -> SetLineColor(49); hsignal -> SetLineWidth(4.0); int theHistCounter = 0; // loop through the samples and produce the plots for (UInt_t iSample=0; iSample < listOfSamples.size(); iSample++) { //determine if the histo is first of the series bool isFirstOfSerie = (*listOfSamples.at(iSample)->Legend()).CompareTo(" "); bool isLastOfSerie = false; if (iSample == listOfSamples.size() - 1) isLastOfSerie = true; if (iSample < listOfSamples.size() - 1 && (*listOfSamples.at(iSample+1)->Legend()).CompareTo(" ") != 0) isLastOfSerie = true; //get the tree tree[iSample] = (TTree*) infile -> Get(listOfSamples.at(iSample)->Name()->Data()); //if sample first of the list create a new histogram if (isFirstOfSerie) { TString thisHistName = "h_" + *(listOfSamples.at(iSample)->Name()); //variable bin histo if (xlowVec != 0) hist[theHistCounter] = new TH1F(thisHistName,thisHistName,nBins,xlowVec); //fixed bin histo else hist[theHistCounter] = new TH1F(thisHistName,thisHistName,nBins,xLow,xHigh); hist[theHistCounter] -> Sumw2(); hist[theHistCounter] -> SetFillColor(col[theHistCounter]); hist[theHistCounter] -> SetFillStyle(1001); theLegends.push_back(*listOfSamples.at(iSample)->Legend()); } //fill the histogram TString thisScale = Form("%f *", *(listOfSamples.at(iSample)->Scale())); if (isFirstOfSerie) tree[iSample] -> Draw(myVar + " >> " + TString(hist[theHistCounter] -> GetName()),thisScale + "evt_weight*kf_weight*pu_weight" + myCut); else tree[iSample] -> Draw(myVar + " >>+ " + TString(hist[theHistCounter] -> GetName()),thisScale + "evt_weight*kf_weight*pu_weight" + myCut); //add the histogram to the stack if the last of the series: //either last sample or ~ sample followed by non ~ sample if (isLastOfSerie) { if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinError (iBin,hist[theHistCounter]->GetBinError(iBin)/hist[theHistCounter]->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinContent(iBin,hist[theHistCounter]->GetBinContent(iBin)/hist[theHistCounter]->GetBinWidth(iBin)); } hs -> Add(hist[theHistCounter]); theHistCounter++; } }//end loop on samples //Fix the legend for (int iHisto = theHistCounter-1; iHisto >= 0; iHisto--) { leg -> AddEntry(hist[iHisto], theLegends[iHisto], "f"); } //get the maximum to properly set the frame float theMax = hdata -> GetBinContent(hdata -> GetMaximumBin()) + hdata -> GetBinError(hdata -> GetMaximumBin()); TH1* theMCSum = (TH1*) hs->GetStack()->Last(); float theMaxMC = theMCSum->GetBinContent(theMCSum->GetMaximumBin()) + theMCSum->GetBinError(theMCSum->GetMaximumBin()); if (theMaxMC > theMax) theMax = theMaxMC; //prepare the ratio band and plot TH1* theMCRatioBand = makeRatioBand(theMCSum); TH1* theRatioPlot = makeRatioPlot(hdata,theMCSum); TCanvas* can = new TCanvas(); can -> SetLogy(isLog); TPad *pad1 = new TPad("pad1","top pad",0,0.30,1,1); pad1->SetBottomMargin(0.02); pad1->SetLeftMargin(0.13); pad1->Draw(); TPad *pad2 = new TPad("pad2","bottom pad",0,0.0,1,0.30); pad2->SetTopMargin(0.02); pad2->SetLeftMargin(0.13); pad2->SetBottomMargin(0.4); pad2->SetGridy(); pad2->Draw(); pad1->cd(); hs->Draw("hist"); hdata->Draw("same,pe"); if (drawSignal) hsignal->Draw("same,hist"); if (drawLegend) leg->Draw("same"); //hs->GetXaxis()->SetTitle(myAxisNameX); hs->GetYaxis()->SetTitle(myAxisNameY); hs->GetXaxis()->SetLabelSize(0.04); hs->GetYaxis()->SetLabelSize(0.04); hs->GetXaxis()->SetLabelOffset(0.025); hs->GetYaxis()->SetLabelOffset(0.035); //hs->GetXaxis()->SetTitleOffset(1.1); hs->GetYaxis()->SetTitleOffset(1.1); hs->SetMaximum(theMax); if (isLog) hs->SetMinimum(0.01); pad2->cd(); theMCRatioBand->GetXaxis()->SetTitle(myAxisNameX); theMCRatioBand->GetXaxis()->SetTitleSize(0.16); theMCRatioBand->GetXaxis()->SetTitleOffset(1.1); theMCRatioBand->GetXaxis()->SetLabelSize(0.12); theMCRatioBand->GetXaxis()->SetLabelOffset(0.07); theMCRatioBand->GetYaxis()->SetTitle("Data/MC"); theMCRatioBand->GetYaxis()->SetTitleSize(0.10); theMCRatioBand->GetYaxis()->SetTitleOffset(0.6); theMCRatioBand->GetYaxis()->SetLabelSize(0.06); theMCRatioBand->GetYaxis()->SetLabelOffset(0.03); theMCRatioBand->SetFillStyle(3001); theMCRatioBand->SetFillColor(kBlue); theMCRatioBand->SetLineWidth(1); theMCRatioBand->SetLineColor(kBlack); theMCRatioBand->SetMarkerSize(0.1); theMCRatioBand->SetMaximum(4.); theMCRatioBand->SetMinimum(0.); theMCRatioBand->Draw("E2"); TLine *line = new TLine(xLow,1,xHigh,1); line->SetLineColor(kBlack); line->Draw("same"); theRatioPlot->Draw("same,pe"); can->cd(); can->Modified(); can -> SaveAs(myName + ".pdf","pdf"); //cleanup the memory allocation delete theMCSum; delete hs; delete leg; delete hdata; delete pad1; delete pad2; delete can; delete theMCRatioBand; delete theRatioPlot; infile -> Close(); delete infile; return; }
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& sample, int massPoint, const std::string& channel, double k, const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName) { std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data()); TFile* inputFile = new TFile(inputFileName_full.data()); if ( !inputFile ) { std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl; assert(0); } inputFile->ls(); TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data())); if ( !canvas ) { std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl; assert(0); } int idxPad = -1; if ( massPoint == 90 ) idxPad = 1; if ( massPoint == 125 ) idxPad = 2; if ( massPoint == 200 ) idxPad = 3; if ( massPoint == 300 ) idxPad = 4; if ( massPoint == 500 ) idxPad = 5; if ( massPoint == 800 ) idxPad = 6; if ( !(idxPad >= 1 && idxPad <= 6) ) { std::cerr << "Invalid sample = " << sample << " !!" << std::endl; assert(0); } TVirtualPad* pad = canvas->GetPad(idxPad); std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl; TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 800); canvas_new->SetFillColor(10); canvas_new->SetBorderSize(2); canvas_new->SetTopMargin(0.065); canvas_new->SetLeftMargin(0.17); canvas_new->SetBottomMargin(0.165); canvas_new->SetRightMargin(0.015); canvas_new->SetLogx(true); canvas_new->SetLogy(true); canvas_new->Draw(); canvas_new->cd(); //TList* pad_primitives = canvas->GetListOfPrimitives(); TList* pad_primitives = pad->GetListOfPrimitives(); TH1* histogramCA = 0; TH1* histogramSVfit = 0; TH1* histogramSVfitMEMkEq0 = 0; TH1* histogramSVfitMEMkNeq0 = 0; TIter pad_nextObj(pad_primitives); while ( TObject* obj = pad_nextObj() ) { std::string objName = ""; if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName(); std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl; TH1* tmpHistogram = dynamic_cast<TH1*>(obj); if ( tmpHistogram ) { std::cout << "tmpHistogram:" << " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << "," << " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << "," << " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << "," << " integral = " << tmpHistogram->Integral() << std::endl; std::cout << "(mean = " << tmpHistogram->GetMean() << ", rms = " << tmpHistogram->GetRMS() << ": rms/mean = " << (tmpHistogram->GetRMS()/tmpHistogram->GetMean()) << ")" << std::endl; if ( tmpHistogram->GetLineColor() == 416 ) histogramCA = tmpHistogram; if ( tmpHistogram->GetLineColor() == 600 ) histogramSVfit = tmpHistogram; if ( tmpHistogram->GetLineColor() == 616 ) histogramSVfitMEMkEq0 = tmpHistogram; if ( tmpHistogram->GetLineColor() == 632 ) histogramSVfitMEMkNeq0 = tmpHistogram; } } if ( !(histogramCA && histogramSVfit && histogramSVfitMEMkEq0 && histogramSVfitMEMkNeq0) ) { std::cerr << "Failed to load histograms !!" << std::endl; assert(0); } //gStyle->SetLineStyleString(2,"40 10 10 10 10 10 10 10"); //gStyle->SetLineStyleString(3,"25 15"); //gStyle->SetLineStyleString(4,"60 25"); //int colors[4] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7 }; int colors[4] = { 28, kGreen - 6, kBlue - 7, kBlack }; //int lineStyles[4] = { 2, 3, 4, 1 }; int lineStyles[4] = { 7, 1, 1, 1 }; //int lineWidths[4] = { 3, 3, 4, 3 }; int lineWidths[4] = { 3, 3, 1, 1 }; int markerStyles[4] = { 20, 25, 21, 24 }; int markerSizes[4] = { 2, 2, 2, 2 }; histogramCA->SetFillColor(0); histogramCA->SetFillStyle(0); histogramCA->SetLineColor(colors[0]); histogramCA->SetLineStyle(lineStyles[0]); histogramCA->SetLineWidth(lineWidths[0]); histogramCA->SetMarkerColor(colors[0]); histogramCA->SetMarkerStyle(markerStyles[0]); histogramCA->SetMarkerSize(markerSizes[0]); histogramSVfit->SetFillColor(0); histogramSVfit->SetFillStyle(0); histogramSVfit->SetLineColor(colors[1]); histogramSVfit->SetLineStyle(lineStyles[1]); histogramSVfit->SetLineWidth(lineWidths[1]); histogramSVfit->SetMarkerColor(colors[1]); histogramSVfit->SetMarkerStyle(markerStyles[1]); histogramSVfit->SetMarkerSize(markerSizes[1]); histogramSVfitMEMkEq0->SetFillColor(0); histogramSVfitMEMkEq0->SetFillStyle(0); histogramSVfitMEMkEq0->SetLineColor(colors[2]); histogramSVfitMEMkEq0->SetLineStyle(lineStyles[2]); histogramSVfitMEMkEq0->SetLineWidth(lineWidths[2]); histogramSVfitMEMkEq0->SetMarkerColor(colors[2]); histogramSVfitMEMkEq0->SetMarkerStyle(markerStyles[2]); histogramSVfitMEMkEq0->SetMarkerSize(markerSizes[2]); // CV: fix pathological bins at high mass for which dN/dm increases int numBins = histogramSVfitMEMkEq0->GetNbinsX(); for ( int idxBin = 1; idxBin <= numBins; ++idxBin ) { double binCenter = histogramSVfitMEMkEq0->GetBinCenter(idxBin); if ( (channel == "#tau_{h}#tau_{h}" && massPoint == 500 && binCenter > 1500.) || (channel == "#tau_{h}#tau_{h}" && massPoint == 800 && binCenter > 2000.) || (channel == "#mu#tau_{h}" && massPoint == 500 && binCenter > 1500.) || (channel == "#mu#tau_{h}" && massPoint == 800 && binCenter > 2500.) ) { histogramSVfitMEMkEq0->SetBinContent(idxBin, 0.); } } histogramSVfitMEMkNeq0->SetFillColor(0); histogramSVfitMEMkNeq0->SetFillStyle(0); histogramSVfitMEMkNeq0->SetLineColor(colors[3]); histogramSVfitMEMkNeq0->SetLineStyle(lineStyles[3]); histogramSVfitMEMkNeq0->SetLineWidth(lineWidths[3]); histogramSVfitMEMkNeq0->SetMarkerColor(colors[3]); histogramSVfitMEMkNeq0->SetMarkerStyle(markerStyles[3]); histogramSVfitMEMkNeq0->SetMarkerSize(markerSizes[3]); TAxis* xAxis = histogramCA->GetXaxis(); xAxis->SetTitle("m_{#tau#tau} [GeV]"); xAxis->SetTitleOffset(1.15); xAxis->SetTitleSize(0.070); xAxis->SetTitleFont(42); xAxis->SetLabelOffset(0.010); xAxis->SetLabelSize(0.055); xAxis->SetLabelFont(42); xAxis->SetTickLength(0.040); xAxis->SetNdivisions(510); //double xMin = 20.; //double xMax = xAxis->GetXmax(); //xAxis->SetRangeUser(xMin, xMax); TAxis* yAxis = histogramCA->GetYaxis(); yAxis->SetTitle("dN/dm_{#tau#tau} [1/GeV]"); yAxis->SetTitleOffset(1.20); yAxis->SetTitleSize(0.070); yAxis->SetTitleFont(42); yAxis->SetLabelOffset(0.010); yAxis->SetLabelSize(0.055); yAxis->SetLabelFont(42); yAxis->SetTickLength(0.040); yAxis->SetNdivisions(505); double massPoint_double = 0.; if ( massPoint == 90 ) massPoint_double = 91.2; else massPoint_double = massPoint; double dLog = (TMath::Log(5.*massPoint_double) - TMath::Log(50.))/25.; // xMin = 50, xMax = 5*massPoint, numBins = 25 double binWidth = TMath::Exp(TMath::Log(massPoint_double) + 0.5*dLog) - TMath::Exp(TMath::Log(massPoint_double) - 0.5*dLog); double sf_binWidth = 1./binWidth; std::cout << "massPoint = " << massPoint << ": sf_binWidth = " << sf_binWidth << std::endl; histogramCA->SetTitle(""); histogramCA->SetStats(false); histogramCA->SetMaximum(sf_binWidth*0.79); histogramCA->SetMinimum(sf_binWidth*1.1e-4); histogramCA->Draw("hist"); histogramSVfit->Draw("histsame"); //histogramSVfitMEMkEq0->Draw("histsame"); histogramSVfitMEMkEq0->Draw("epsame"); //histogramSVfitMEMkNeq0->Draw("histsame"); histogramSVfitMEMkNeq0->Draw("epsame"); histogramCA->Draw("axissame"); //TPaveText* label_sample = new TPaveText(0.21, 0.86, 0.46, 0.94, "NDC"); TPaveText* label_sample = new TPaveText(0.1700, 0.9475, 0.4600, 1.0375, "NDC"); label_sample->SetFillStyle(0); label_sample->SetBorderSize(0); label_sample->AddText(sample.data()); label_sample->SetTextFont(42); label_sample->SetTextSize(0.055); label_sample->SetTextColor(1); label_sample->SetTextAlign(13); label_sample->Draw(); //TLegend* legend_new = new TLegend(0.225, 0.52, 0.41, 0.82, NULL, "brNDC"); TLegend* legend_new = new TLegend(0.30, 0.30, 0.80, 0.80, NULL, "brNDC"); legend_new->SetFillColor(10); legend_new->SetFillStyle(0); legend_new->SetBorderSize(0); legend_new->SetTextFont(42); legend_new->SetTextSize(0.055); legend_new->SetTextColor(1); legend_new->SetMargin(0.20); legend_new->AddEntry(histogramCA, "CA", "l"); legend_new->AddEntry(histogramSVfit, "SVfit", "l"); //legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "l"); legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "p"); //legend_new->AddEntry(histogramSVfitMEMkNeq0, Form("SVfitMEM(k=%1.0f)", k), "l"); legend_new->AddEntry(histogramSVfitMEMkNeq0, Form("SVfitMEM (k=%1.0f)", k), "p"); //legend_new->Draw(); double label_channel_y0; if ( channel == "e#mu" ) label_channel_y0 = 0.9275; else if ( channel == "#mu#tau_{h}" ) label_channel_y0 = 0.9400; else if ( channel == "#tau_{h}#tau_{h}" ) label_channel_y0 = 0.9350; else { std::cerr << "Invalid channel = " << channel << " !!" << std::endl; assert(0); } TPaveText* label_channel = new TPaveText(0.895, label_channel_y0, 0.975, label_channel_y0 + 0.055, "NDC"); label_channel->SetFillStyle(0); label_channel->SetBorderSize(0); label_channel->AddText(channel.data()); label_channel->SetTextFont(62); label_channel->SetTextSize(0.055); label_channel->SetTextColor(1); label_channel->SetTextAlign(31); label_channel->Draw(); canvas_new->Update(); std::string outputFileName_full = Form("%s%s", outputFilePath.data(), outputFileName.data()); size_t idx = outputFileName_full.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName_full, 0, idx); canvas_new->Print(std::string(outputFileName_plot).append(".pdf").data()); canvas_new->Print(std::string(outputFileName_plot).append(".root").data()); std::string channel_string; if ( channel == "e#mu" ) channel_string = "emu"; else if ( channel == "#mu#tau_{h}" ) channel_string = "muhad"; else if ( channel == "#tau_{h}#tau_{h}" ) channel_string = "hadhad"; else { std::cerr << "Invalid channel = " << channel << " !!" << std::endl; assert(0); } std::string outputFileName_legend = Form("makeSVfitMEM_PerformancePlots_legend_%s.pdf", channel_string.data()); makePlot_legend(legend_new, outputFilePath, outputFileName_legend); delete label_sample; delete legend_new; delete label_channel; delete canvas_new; delete inputFile; }
void showGraph(TGraph* graph, const std::string& xAxisTitle, Float_t* genX, double yMin, double yMax, const std::string& yAxisTitle, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetTopMargin(0.10); canvas->SetLeftMargin(0.16); canvas->SetRightMargin(0.14); canvas->SetBottomMargin(0.12); int numPoints = graph->GetN(); double xMin, xMax, yDummy; graph->GetPoint(0, xMin, yDummy); graph->GetPoint(numPoints - 1, xMax, yDummy); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", numPoints/100, xMin, xMax); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(1.15); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(1.15); dummyHistogram->Draw("axis"); TGraph* genMarker = 0; if ( genX ) { genMarker = new TGraph(2); genMarker->SetPoint(0, xMin, *genX); genMarker->SetPoint(1, xMax, *genX); genMarker->SetLineColor(8); genMarker->SetLineWidth(1); genMarker->SetMarkerColor(8); genMarker->SetMarkerStyle(20); genMarker->SetMarkerSize(1); genMarker->Draw("L"); } graph->SetLineColor(1); graph->SetLineWidth(2); graph->SetMarkerColor(1); graph->SetMarkerStyle(20); graph->SetMarkerSize(1); graph->Draw("L"); canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); 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 dummyHistogram; delete genMarker; delete canvas; }
void exclusiongraph2() { TCanvas *c = new TCanvas("c", "Charged Higgs L300 Contour",0,0,700,700); c->SetTickx(); c->SetTicky(); c->SetGridx(); c->SetGridy(); TH1 *frame = new TH1F("frame","",1000,50,500); frame->SetMinimum(1); frame->SetMaximum(50); frame->SetDirectory(0); frame->SetStats(0); frame->GetXaxis()->SetTitle("m_{A} (GeV)"); frame->GetXaxis()->SetTickLength(0.02); frame->GetXaxis()->SetLabelSize(0.03); frame->GetYaxis()->SetTitle("tan#beta"); frame->GetYaxis()->SetMoreLogLabels(); frame->GetYaxis()->SetLabelSize(0.03); frame->Draw(" "); c->SetLogy(); TGraph *gr1 = new TGraph(10); gr1->SetFillColor(6); gr1->SetFillStyle(3005); gr1->SetLineColor(6); gr1->SetLineWidth(603); gr1->SetPoint(0,140,0.5); gr1->SetPoint(1,130,2.9); gr1->SetPoint(2,124.677,3.83726); gr1->SetPoint(3,113.362,6.06903); gr1->SetPoint(4,108.513,8.00221); gr1->SetPoint(5,111.746,10.0272); gr1->SetPoint(6,119.828,12.8419); gr1->SetPoint(7,135.991,30.0872); gr1->SetPoint(8,140,40); gr1->SetPoint(9,135,60); gr1->Draw("C"); TLatex *tex = new TLatex(140.841,37.9762, "#leftarrow t #rightarrow bH^{+}, H^{+} #rightarrow #tau#nu"); tex->SetTextColor(6); tex->Draw(); TGraph *gr2 = new TGraph(15); gr2->SetName("Graph"); gr2->SetTitle("Graph"); gr2->SetFillColor(1); gr2->SetFillStyle(3005); gr2->SetLineWidth(3); gr2->SetPoint(0,499.192,3.02622); gr2->SetPoint(1,427.748,3.06233); gr2->SetPoint(2,358.244,3.10722); gr2->SetPoint(3,305.711,3.24589); gr2->SetPoint(4,244.289,3.36617); gr2->SetPoint(5,206.304,3.7544); gr2->SetPoint(6,178.017,4.50347); gr2->SetPoint(7,148.114,6.20297); gr2->SetPoint(8,131.142,8.00221); gr2->SetPoint(9,111.746,8.48188); gr2->SetPoint(10,102.047,9.52921); gr2->SetPoint(11,96.3901,13.2212); gr2->SetPoint(12,92.3491,19.0232); gr2->SetPoint(13,90.7328,26.3935); gr2->SetPoint(14,93.1573,50.4385); gr2->Draw("L"); tex = new TLatex(346.929,6.62281,"ATLAS"); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(328.341,5.24703,"#intLdt = 300 fb^{-1}"); tex->SetTextSize(0.0297619); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(340.463,4.1874,"Maximal mixing"); tex->SetTextSize(0.0297619); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(413.2,2.51608,"LEP 2000"); tex->SetTextSize(0.0297619); tex->SetLineWidth(2); tex->Draw(); TGraph *gr3 = new TGraph(10); gr3->SetName("Graph"); gr3->SetTitle("Graph"); gr3->SetFillColor(2); gr3->SetFillStyle(3004); gr3->SetLineColor(2); gr3->SetLineWidth(603); gr3->SetPoint(0,176.84,10.7499); gr3->SetPoint(1,190.575,11.9912); gr3->SetPoint(2,211.58,12.7108); gr3->SetPoint(3,243.088,12.3457); gr3->SetPoint(4,279.443,12.6185); gr3->SetPoint(5,302.065,12.9916); gr3->SetPoint(6,331.957,13.7713); gr3->SetPoint(7,369.928,14.2821); gr3->SetPoint(8,425.673,16.1651); gr3->SetPoint(9,499.192,18.1635); gr3->Draw("C"); tex = new TLatex(188.151,9.36035, "gb #rightarrow tH^{+}, H^{+} #rightarrow #tau#nu"); tex->SetTextColor(2); tex->Draw(); TGraph *gr4 = new TGraph(10); gr4->SetName("Graph"); gr4->SetTitle("Graph"); gr4->SetFillColor(4); gr4->SetFillStyle(3004); gr4->SetLineColor(4); gr4->SetLineWidth(-603); gr4->SetPoint(0,178.456,2.91797); gr4->SetPoint(1,200.269,3.40033); gr4->SetPoint(2,229.354,3.96243); gr4->SetPoint(3,249.551,4.07959); gr4->SetPoint(4,269.749,3.71097); gr4->SetPoint(5,298.025,3.09308); gr4->SetPoint(6,341.652,2.89679); gr4->SetPoint(7,378.007,2.57808); gr4->SetPoint(8,441.023,2.16454); gr4->SetPoint(9,499.677,1.76145); gr4->Draw("C"); tex = new TLatex(165.,1.15498, "gb #rightarrow tH^{+}, H^{+} #rightarrow tb"); tex->SetTextColor(4); tex->Draw(); TGraph *gr5 = new TGraph(10); gr5->SetName("Graph"); gr5->SetTitle("Graph"); gr5->SetFillColor(4); gr5->SetFillStyle(3004); gr5->SetLineColor(4); gr5->SetLineWidth(603); gr5->SetPoint(0,152.603,23.0996); gr5->SetPoint(1,188.151,18.8373); gr5->SetPoint(2,239.048,15.2499); gr5->SetPoint(3,264.901,15.8156); gr5->SetPoint(4,299.641,18.8373); gr5->SetPoint(5,334.381,20.7085); gr5->SetPoint(6,360.233,22.4362); gr5->SetPoint(7,396.589,24.4859); gr5->SetPoint(8,433.752,25.7669); gr5->SetPoint(9,499.192,27.3132); gr5->Draw("C"); }
void comparisonJetMCData(string plot,int rebin){ string tmp; string dir="/gpfs/cms/data/2011/Observables/Approval/"; if (isAngularAnalysis){ mcfile=dir+"MC_zjets"+version; back_w=dir+"MC_wjets"+version; back_ttbar=dir+"MC_ttbar"+version; WW=dir+"MC_diW"+version; ZZ=dir+"MC_siZ"+version; WZ=dir+"MC_diWZ"+version; datafile=dir+"DATA"+version; mcfiletau=dir+"MC_zjetstau"+version; } // List of files TFile *dataf = TFile::Open(datafile.c_str()); //data file TFile *mcf = TFile::Open(mcfile.c_str()); //MC file TFile *mcftau = TFile::Open(mcfiletau.c_str()); //MC file TFile *ttbarf = TFile::Open(back_ttbar.c_str()); //MC background file TFile *wf = TFile::Open(back_w.c_str()); TFile *qcd23emf = TFile::Open(qcd23em.c_str()); TFile *qcd38emf = TFile::Open(qcd38em.c_str()); TFile *qcd817emf = TFile::Open(qcd817em.c_str()); TFile *qcd23bcf = TFile::Open(qcd23bc.c_str()); TFile *qcd38bcf = TFile::Open(qcd38bc.c_str()); TFile *qcd817bcf = TFile::Open(qcd817bc.c_str()); TFile *WZf = TFile::Open(WZ.c_str()); TFile *ZZf = TFile::Open(ZZ.c_str()); TFile *WWf = TFile::Open(WW.c_str()); // Canvas if (CanvPlot) delete CanvPlot; CanvPlot = new TCanvas("CanvPlot","CanvPlot",0,0,800,600); // Getting, defining ... dataf->cd("validationJEC"); if (isMu && isAngularAnalysis) dataf->cd("validationJECmu"); TObject * obj; gDirectory->GetObject(plot.c_str(),obj); TH1 *data; TH2F *data2; TH1D *data3; THStack *hs = new THStack("hs","Total MC"); int flag=-1; if ((data = dynamic_cast<TH1F *>(obj)) ){ flag=1; gROOT->Reset(); gROOT->ForceStyle(); gStyle->SetPadRightMargin(0.03); gPad->SetLogy(1); gPad->Modified(); gPad->Update(); } if ((data2 = dynamic_cast<TH2F *>(obj)) ){ flag=2; gStyle->SetPalette(1); gStyle->SetPadRightMargin(0.15); gPad->Modified(); } //=================== // Dirty jobs :) if (flag==1){ CanvPlot->cd(); TPad *pad1 = new TPad("pad1","pad1",0.01,0.33,0.99,0.99); pad1->Draw(); pad1->cd(); pad1->SetTopMargin(0.1); pad1->SetBottomMargin(0.01); pad1->SetRightMargin(0.1); pad1->SetFillStyle(0); pad1->SetLogy(1); TString str=data->GetTitle(); if (str.Contains("jet") && !str.Contains("zMass") && !str.Contains("Num") && !str.Contains("Eta") && !str.Contains("Phi") && !str.Contains("eld") && !str.Contains("meanPtZVsNjet")) { if (!isAngularAnalysis) rebin=1; } //====================== // DATA Double_t dataint = data->Integral(); data->SetLineColor(kBlack); data->Rebin(rebin); if(str.Contains("nJetVtx")) data->GetXaxis()->SetRangeUser(0,10); if(str.Contains("zMass")) data->GetXaxis()->SetRangeUser(70,110); data->SetMinimum(1.); data->Sumw2(); //Canvas style copied from plotsHistsRatio.C data->SetLabelSize(0.0); data->GetXaxis()->SetTitleSize(0.00); data->GetYaxis()->SetLabelSize(0.07); data->GetYaxis()->SetTitleSize(0.08); data->GetYaxis()->SetTitleOffset(0.76); data->SetTitle(""); gStyle->SetOptStat(0); data->GetYaxis()->SetLabelSize(0.06); data->GetYaxis()->SetTitleSize(0.06); data->GetYaxis()->SetTitleOffset(0.8); data->Draw("E1"); TLegend* legend = new TLegend(0.725,0.27,0.85,0.72); legend->SetFillColor(0); legend->SetFillStyle(0); legend->SetBorderSize(0); legend->SetTextSize(0.060); legend->AddEntry(data,"data","p"); // hack to calculate some yields in restricted regions... int num1=0, num2=0, num3=0, num4=0, num5=0; if(str.Contains("invMass") && !str.Contains("PF")){ for(int j=1;j<=data->GetNbinsX();j++){ num1 += data->GetBinContent(j); //conto quante Z ci sono tra 60 e 120 GeV if(j>10&&j<=50) num2 += data->GetBinContent(j); // ... tra 70 e 110 if(j>15&&j<=45) num3 += data->GetBinContent(j); // ... tra 75 e 105 } cout << "\n"; cout << data->GetNbinsX() <<" Number of bins of the invmass histo\n"; printf("Number of Z in 60-120 %i --- 70-110 %i --- 75-105 %i \n",num1,num2,num3); cout << "\n"; } if(str.Contains("zYieldVsjets") && !str.Contains("Vtx")){ for(int j=1;j<=data->GetNbinsX();j++){ num1 += data->GetBinContent(j); //conto quante Z if(j>1) num2 += data->GetBinContent(j); // ... +1,2,3,4... jets if(j>2) num3 += data->GetBinContent(j); // ... +2,3,4... jets if(j>3) num4 += data->GetBinContent(j); // .. if(str=="jet_pT"){ if(j>4) num5 += data->GetBinContent(j); // ... +4... jets } cout << "\n"; cout << data->GetNbinsX() <<" Number of bins of the zYieldVsjets histo\n"; printf("Number of Z+n jet %i --- >1 %i --- >2 %i --- >3 %i --- >4 %i \n",num1,num2,num3,num4,num5); cout << "\n"; } //====================== // Z + jets signal mcf->cd("validationJEC"); if (isMu) mcf->cd("validationJECmu/"); if (isAngularAnalysis) { mcf->cd("validationJEC/"); if (isMu) mcf->cd("validationJECmu/"); } TH1F* mc; gDirectory->GetObject(plot.c_str(),mc); TH1F * hsum; if(mc){ hsum = (TH1F*) mc->Clone(); hsum->SetTitle("hsum"); hsum->SetName("hsum"); hsum->Reset(); Double_t mcint = mc->Integral(); mc->SetFillColor(kRed); mc->Sumw2(); if(lumiweights==0) mc->Scale(dataint/mcint); // Blocco da propagare negli altri MC if(zNumEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) mc->Scale( dataLumi2011pix / (zNumEvents / zjetsXsect)); else mc->Scale( dataLumi2011 / (zNumEvents / zjetsXsect)); } else{ if (RunA){ if (lumiPixel) mc->Scale( dataLumi2011Apix / (zNumEvents / zjetsXsect)); else mc->Scale( dataLumi2011A / (zNumEvents / zjetsXsect)); } if (!RunA){ if (lumiPixel) mc->Scale( dataLumi2011Bpix / (zNumEvents / zjetsXsect)); else mc->Scale( dataLumi2011B / (zNumEvents / zjetsXsect)); } } } } else { if(lumiweights==1) mc->Scale(zjetsScale); } // fin qui if(lumiweights==1) mc->Scale(1./zwemean); // perche' i Weights non fanno 1... mc->Rebin(rebin); if(lumiweights==0) mc->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(mc); legend->AddEntry(mc,"Z+jets","f"); } //====================== // ttbar ttbarf->cd("validationJEC"); if (isMu) ttbarf->cd("validationJECmu/"); if (isAngularAnalysis) { ttbarf->cd("validationJEC/"); if (isMu) ttbarf->cd("validationJECmu/"); } TH1F* ttbar; gDirectory->GetObject(plot.c_str(),ttbar); if(ttbar){ ttbar->SetFillColor(kBlue); ttbar->Sumw2(); if(ttNumEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) ttbar->Scale( dataLumi2011pix / (ttNumEvents / ttbarXsect)); else ttbar->Scale( dataLumi2011 / (ttNumEvents / ttbarXsect)); } else{ if (RunA){ if (lumiPixel) ttbar->Scale( dataLumi2011Apix / (ttNumEvents / ttbarXsect)); else ttbar->Scale( dataLumi2011A / (ttNumEvents / ttbarXsect)); } if (!RunA){ if (lumiPixel) ttbar->Scale( dataLumi2011Bpix / (ttNumEvents / ttbarXsect)); else ttbar->Scale( dataLumi2011B / (ttNumEvents / ttbarXsect)); } } } } else { if(lumiweights==1) ttbar->Scale(ttwemean); } // fin qui if(lumiweights==1) ttbar->Scale(1./ttwemean); // perche' i Weights non fanno 1... ttbar->Rebin(rebin); if(lumiweights==0) ttbar->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(ttbar); if(lumiweights==1)legend->AddEntry(ttbar,"ttbar","f"); ////////// //Storing the bckgrounds! ////////// cout<<str<<endl; if (isAngularAnalysis){ if(str=="jet_pT") evaluateAndFillBackgrounds(ttbar,"jet_pT"); if(str=="jet_pT2") evaluateAndFillBackgrounds(ttbar,"jet_pT2"); if(str=="jet_pT3") evaluateAndFillBackgrounds(ttbar,"jet_pT3"); if(str=="jet_pT4") evaluateAndFillBackgrounds(ttbar,"jet_pT4"); if(str=="Jet_multi") evaluateAndFillBackgrounds(ttbar,"jet_Multiplicity"); if(str=="jet_eta") evaluateAndFillBackgrounds(ttbar,"jet_eta"); if(str=="jet_eta2") evaluateAndFillBackgrounds(ttbar,"jet_eta2"); if(str=="jet_eta3") evaluateAndFillBackgrounds(ttbar,"jet_eta3"); if(str=="jet_eta4") evaluateAndFillBackgrounds(ttbar,"jet_eta4"); if(str=="HT") evaluateAndFillBackgrounds(ttbar,"HT"); if(str=="HT_1j") evaluateAndFillBackgrounds(ttbar,"HT1"); if(str=="HT_2j") evaluateAndFillBackgrounds(ttbar,"HT2"); if(str=="HT_3j") evaluateAndFillBackgrounds(ttbar,"HT3"); if(str=="HT_4j") evaluateAndFillBackgrounds(ttbar,"HT4"); if(str=="Phi_star") evaluateAndFillBackgrounds(ttbar,"PhiStar"); } } //====================== // w+jets wf->cd("validationJEC"); if (isMu) wf->cd("validationJECmu/"); if (isAngularAnalysis) { wf->cd("validationJEC/"); if (isMu) wf->cd("validationJECmu/"); } TH1F* w; gDirectory->GetObject(plot.c_str(),w); if(w){ w->SetFillColor(kViolet+2); w->Sumw2(); if(wNumEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) w->Scale( dataLumi2011pix / (wNumEvents / wjetsXsect)); else w->Scale( dataLumi2011 / (wNumEvents / wjetsXsect)); } else{ if (RunA){ if (lumiPixel) w->Scale( dataLumi2011Apix / (wNumEvents / wjetsXsect)); else w->Scale( dataLumi2011A / (wNumEvents / wjetsXsect)); } if (!RunA){ if (lumiPixel) w->Scale( dataLumi2011Bpix / (wNumEvents / wjetsXsect)); else w->Scale( dataLumi2011B / (wNumEvents / wjetsXsect)); } } } } else { if(lumiweights==1) w->Scale(wwemean); } // fin qui if(lumiweights==1) w->Scale(1./wwemean); // perche' i Weights non fanno 1... w->Rebin(rebin); if(lumiweights==0) w->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(w); if(lumiweights==1)legend->AddEntry(w,"W+jets","f"); } //====================== // wz+jets WZf->cd("validationJEC"); if (isMu) WZf->cd("validationJECmu/"); if (isAngularAnalysis) { WZf->cd("validationJEC/"); if (isMu) WZf->cd("validationJECmu/"); } TH1F* wz; gDirectory->GetObject(plot.c_str(),wz); if(wz){ wz->SetFillColor(kYellow+2); wz->Sumw2(); if(wzEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) wz->Scale( dataLumi2011pix / (wzEvents / WZXsect)); else wz->Scale( dataLumi2011 / (wzEvents / WZXsect)); } else{ if (RunA){ if (lumiPixel) wz->Scale( dataLumi2011Apix / (wzEvents / WZXsect)); else wz->Scale( dataLumi2011A / (wzEvents / WZXsect)); } if (!RunA){ if (lumiPixel) wz->Scale( dataLumi2011Bpix / (wzEvents / WZXsect)); else wz->Scale( dataLumi2011B / (wzEvents / WZXsect)); } } } } else { if(lumiweights==1) wz->Scale(wzjetsScale); } // fin qui if(lumiweights==1) wz->Scale(1./wzwemean); // perche' i Weights non fanno 1... wz->Rebin(rebin); if(lumiweights==0) wz->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(wz); legend->AddEntry(wz,"WZ+jets","f"); ////////// //Storing the bckgrounds! ////////// if (isAngularAnalysis){ if(str=="jet_pT") evaluateAndFillBackgrounds(wz,"jet_pT"); if(str=="jet_pT2") evaluateAndFillBackgrounds(wz,"jet_pT2"); if(str=="jet_pT3") evaluateAndFillBackgrounds(wz,"jet_pT3"); if(str=="jet_pT4") evaluateAndFillBackgrounds(wz,"jet_pT4"); if(str=="jet_eta") evaluateAndFillBackgrounds(wz,"jet_eta"); if(str=="jet_eta2") evaluateAndFillBackgrounds(wz,"jet_eta2"); if(str=="jet_eta3") evaluateAndFillBackgrounds(wz,"jet_eta3"); if(str=="jet_eta4") evaluateAndFillBackgrounds(wz,"jet_eta4"); if(str=="Jet_multi") evaluateAndFillBackgrounds(wz,"jet_Multiplicity"); if(str=="HT") evaluateAndFillBackgrounds(wz,"HT"); if(str=="HT_1j") evaluateAndFillBackgrounds(wz,"HT1"); if(str=="HT_2j") evaluateAndFillBackgrounds(wz,"HT2"); if(str=="HT_3j") evaluateAndFillBackgrounds(wz,"HT3"); if(str=="HT_4j") evaluateAndFillBackgrounds(wz,"HT4"); if(str=="Phi_star") evaluateAndFillBackgrounds(wz,"PhiStar"); } } //====================== // zz+jets ZZf->cd("validationJEC"); if (isMu) ZZf->cd("validationJECmu/"); if (isAngularAnalysis) { ZZf->cd("validationJEC/"); if (isMu) ZZf->cd("validationJECmu/"); } TH1F* zz; gDirectory->GetObject(plot.c_str(),zz); if(zz){ zz->SetFillColor(kOrange+2); zz->Sumw2(); if(zzEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) zz->Scale( dataLumi2011pix / (zzEvents / ZZXsect)); else zz->Scale( dataLumi2011 / (zzEvents / ZZXsect)); } else{ if (RunA){ if (lumiPixel) zz->Scale( dataLumi2011Apix / (zzEvents / ZZXsect)); else zz->Scale( dataLumi2011A / (zzEvents / ZZXsect)); } if (!RunA){ if (lumiPixel) zz->Scale( dataLumi2011Bpix / (zzEvents / ZZXsect)); else zz->Scale( dataLumi2011B / (zzEvents / ZZXsect)); } } } } else { if(lumiweights==1) zz->Scale(zzjetsScale); } // fin qui if(lumiweights==1) zz->Scale(1./zzwemean); // perche' i Weights non fanno 1... zz->Rebin(rebin); if(lumiweights==0) zz->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(zz); legend->AddEntry(zz,"ZZ+jets","f"); ////////// //Storing the bckgrounds! ////////// if (isAngularAnalysis){ if(str=="jet_pT") evaluateAndFillBackgrounds(zz,"jet_pT"); if(str=="jet_pT2") evaluateAndFillBackgrounds(zz,"jet_pT2"); if(str=="jet_pT3") evaluateAndFillBackgrounds(zz,"jet_pT3"); if(str=="jet_pT4") evaluateAndFillBackgrounds(zz,"jet_pT4"); if(str=="jet_eta") evaluateAndFillBackgrounds(zz,"jet_eta"); if(str=="jet_eta2") evaluateAndFillBackgrounds(zz,"jet_eta2"); if(str=="jet_eta3") evaluateAndFillBackgrounds(zz,"jet_eta3"); if(str=="jet_eta4") evaluateAndFillBackgrounds(zz,"jet_eta4"); if(str=="Jet_multi") evaluateAndFillBackgrounds(zz,"jet_Multiplicity"); if(str=="HT") evaluateAndFillBackgrounds(zz,"HT"); if(str=="HT_1j") evaluateAndFillBackgrounds(zz,"HT1"); if(str=="HT_2j") evaluateAndFillBackgrounds(zz,"HT2"); if(str=="HT_3j") evaluateAndFillBackgrounds(zz,"HT3"); if(str=="HT_4j") evaluateAndFillBackgrounds(zz,"HT4"); if(str=="Phi_star") evaluateAndFillBackgrounds(zz,"PhiStar"); } } //====================== // ww+jets WWf->cd("validationJEC"); if (isMu) WWf->cd("validationJECmu/"); if (isAngularAnalysis) { WWf->cd("validationJEC/"); if (isMu) WWf->cd("validationJECmu/"); } TH1F* ww; gDirectory->GetObject(plot.c_str(),ww); if(ww){ ww->SetFillColor(kBlack); ww->Sumw2(); if(wwEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) ww->Scale( dataLumi2011pix / (wwEvents / WWXsect)); else ww->Scale( dataLumi2011 / (wwEvents / WWXsect)); } else{ if (RunA){ if (lumiPixel) ww->Scale( dataLumi2011Apix / (wwEvents / WWXsect)); else ww->Scale( dataLumi2011A / (wwEvents / WWXsect)); } if (!RunA){ if (lumiPixel) ww->Scale( dataLumi2011Bpix / (wwEvents / WWXsect)); else ww->Scale( dataLumi2011B / (wwEvents / WWXsect)); } } } } else { if(lumiweights==1) ww->Scale(wwjetsScale); } // fin qui if(lumiweights==1) ww->Scale(1./wwwemean); // perche' i Weights non fanno 1... ww->Rebin(rebin); if(lumiweights==0) ww->Draw("HISTO SAMES"); hsum->Rebin(rebin); hsum->Add(ww); legend->AddEntry(ww,"WW+jets","f"); ////////// //Storing the bckgrounds! ////////// if (isAngularAnalysis){ if(str=="jet_pT") evaluateAndFillBackgrounds(ww,"jet_pT"); if(str=="jet_pT2") evaluateAndFillBackgrounds(ww,"jet_pT2"); if(str=="jet_pT3") evaluateAndFillBackgrounds(ww,"jet_pT3"); if(str=="jet_pT4") evaluateAndFillBackgrounds(ww,"jet_pT4"); if(str=="jet_eta") evaluateAndFillBackgrounds(ww,"jet_eta"); if(str=="jet_eta2") evaluateAndFillBackgrounds(ww,"jet_eta2"); if(str=="jet_eta3") evaluateAndFillBackgrounds(ww,"jet_eta3"); if(str=="jet_eta4") evaluateAndFillBackgrounds(ww,"jet_eta4"); if(str=="Jet_multi") evaluateAndFillBackgrounds(ww,"jet_Multiplicity"); if(str=="HT") evaluateAndFillBackgrounds(ww,"HT"); if(str=="HT_1j") evaluateAndFillBackgrounds(ww,"HT1"); if(str=="HT_2j") evaluateAndFillBackgrounds(ww,"HT2"); if(str=="HT_3j") evaluateAndFillBackgrounds(ww,"HT3"); if(str=="HT_4j") evaluateAndFillBackgrounds(ww,"HT4"); if(str=="Phi_star") evaluateAndFillBackgrounds(ww,"PhiStar"); } } /// Tau //====================== mcftau->cd("validationJEC"); if (isMu) mcftau->cd("validationJECmu/"); if (isAngularAnalysis) { mcftau->cd("validationJEC/"); if (isMu) mcftau->cd("validationJECmu/"); } TH1F* tau; gDirectory->GetObject(plot.c_str(),tau); if(tau){ tau->SetFillColor(kGreen); tau->Sumw2(); if(zNumEvents>0.){ if(lumiweights==1) { if (WholeStat){ if (lumiPixel) tau->Scale( dataLumi2011pix / (zNumEvents / zjetsXsect)); else tau->Scale( dataLumi2011 / (zNumEvents / zjetsXsect)); } else{ if (RunA){ if (lumiPixel) tau->Scale( dataLumi2011Apix / (zNumEvents / zjetsXsect)); else tau->Scale( dataLumi2011A / (zNumEvents / zjetsXsect)); } if (!RunA){ if (lumiPixel) tau->Scale( dataLumi2011Bpix / (zNumEvents / zjetsXsect)); else tau->Scale( dataLumi2011B / (zNumEvents / zjetsXsect)); } } } } else { if(lumiweights==1) tau->Scale(zjetsScale); } // fin qui if(lumiweights==1) tau->Scale(1./zwemean); // perche' i Weights non fanno 1... tau->Rebin(rebin); if(lumiweights==0) tau->Draw("HISTO SAMES"); hsum->Rebin(rebin); tau->Scale(1./1000.); //aaaaaaa hsum->Add(tau); legend->AddEntry(tau,"#tau#tau+jets","f"); ////////// //Storing the bckgrounds! ////////// if (isAngularAnalysis){ if(str=="jet_pT") evaluateAndFillBackgrounds(tau,"jet_pT"); if(str=="jet_pT2") evaluateAndFillBackgrounds(tau,"jet_pT2"); if(str=="jet_pT3") evaluateAndFillBackgrounds(tau,"jet_pT3"); if(str=="jet_pT4") evaluateAndFillBackgrounds(tau,"jet_pT4"); if(str=="jet_eta") evaluateAndFillBackgrounds(tau,"jet_eta"); if(str=="jet_eta2") evaluateAndFillBackgrounds(tau,"jet_eta2"); if(str=="jet_eta3") evaluateAndFillBackgrounds(tau,"jet_eta3"); if(str=="jet_eta4") evaluateAndFillBackgrounds(tau,"jet_eta4"); if(str=="Jet_multi") evaluateAndFillBackgrounds(tau,"jet_Multiplicity"); if(str=="HT") evaluateAndFillBackgrounds(tau,"HT"); if(str=="HT_1j") evaluateAndFillBackgrounds(tau,"HT1"); if(str=="HT_2j") evaluateAndFillBackgrounds(tau,"HT2"); if(str=="HT_3j") evaluateAndFillBackgrounds(tau,"HT3"); if(str=="HT_4j") evaluateAndFillBackgrounds(tau,"HT4"); if(str=="Phi_star") evaluateAndFillBackgrounds(tau,"PhiStar"); } } ///////// // Print the bkg contributions //////// for(int j=0;j<bckg_leadingJetPt.size();j++){ cout<<bckg_leadingJetPt[j]<<endl; } //====================== // QCD EM enriched qcd23emf->cd("validationJEC"); TH1F* qcd23emp; gDirectory->GetObject(plot.c_str(),qcd23emp); if(qcd23emp){ TH1D * qcdTotEM = (TH1D*) qcd23emp->Clone(); qcdTotEM->SetTitle("qcd em"); qcdTotEM->SetName("qcd em"); qcdTotEM->Reset(); qcdTotEM->Rebin(rebin); qcd38emf->cd("validationJEC"); TH1F* qcd38emp; gDirectory->GetObject(plot.c_str(),qcd38emp); qcd817emf->cd("validationJEC"); TH1F* qcd817emp; gDirectory->GetObject(plot.c_str(),qcd817emp); qcd23emp->Rebin(rebin); qcd23emp->Sumw2(); qcd23emp->Scale(qcd23emScale); qcd38emp->Rebin(rebin); qcd38emp->Sumw2(); qcd38emp->Scale(qcd38emScale); qcd817emp->Rebin(rebin); qcd817emp->Sumw2(); qcd817emp->Scale(qcd817emScale); qcdTotEM->SetFillColor(kOrange+1); qcdTotEM->Add(qcd23emp); qcdTotEM->Add(qcd38emp); qcdTotEM->Add(qcd817emp); hsum->Add(qcdTotEM); //if(lumiweights==1)legend->AddEntry(qcdTotEM,"QCD em","f"); } //====================== // QCD bc qcd23bcf->cd("validationJEC"); TH1F* qcd23bcp; TH1D * qcdTotBC; bool qcdbcempty=true; gDirectory->GetObject(plot.c_str(),qcd23bcp); if(qcd23bcp){ qcdTotBC = (TH1D*) qcd23bcp->Clone(); qcdTotBC->SetTitle("qcd bc"); qcdTotBC->SetName("qcd bc"); qcdTotBC->Reset(); qcdTotBC->Rebin(rebin); qcd38bcf->cd("validationJEC"); TH1F* qcd38bcp; gDirectory->GetObject(plot.c_str(),qcd38bcp); qcd817bcf->cd("validationJEC"); TH1F* qcd817bcp; gDirectory->GetObject(plot.c_str(),qcd817bcp); qcd23bcp->Rebin(rebin); qcd23bcp->Sumw2(); qcd23bcp->Scale(qcd23bcScale); qcd38bcp->Rebin(rebin); qcd38bcp->Sumw2(); qcd38bcp->Scale(qcd38bcScale); qcd817bcp->Rebin(rebin); qcd817bcp->Sumw2(); qcd817bcp->Scale(qcd817bcScale); qcdTotBC->SetFillColor(kGreen+2); qcdTotBC->Add(qcd23bcp); qcdTotBC->Add(qcd38bcp); qcdTotBC->Add(qcd817bcp); hsum->Add(qcdTotBC); if (qcdTotBC->GetEntries()>0) qcdbcempty=false; //if(lumiweights==1)legend->AddEntry(qcdTotBC,"QCD bc","f"); } //====================== // Add here other backgrounds //====================== // Stacked Histogram //if(qcd23em) hs->Add(qcdTotEM); if(!qcdbcempty) hs->Add(qcdTotBC); if(w) hs->Add(w); if (ww) hs->Add(ww); if(tau) hs->Add(tau); //Z+Jets if (zz) hs->Add(zz); if (wz) hs->Add(wz); if (ttbar) hs->Add(ttbar); if(mc) hs->Add(mc); //Z+Jets // per avere le statistiche if(lumiweights==1) hsum->Draw("HISTO SAME"); //====================== // Setting the stats //pad1->Update(); // altrimenti non becchi la stat //TPaveStats *r2; //if(lumiweights==0) r2 = (TPaveStats*)mc->FindObject("stats"); //if(lumiweights==1) r2 = (TPaveStats*)hsum->FindObject("stats"); //r2->SetY1NDC(0.875); //Uncomment if you wonna add your statistics in the top right corner //r2->SetY2NDC(0.75); //r2->SetTextColor(kRed); if(lumiweights==1) hs->Draw("HISTO SAME"); gPad->RedrawAxis(); data->Draw("E1 SAME"); //r2->Draw(); //here to reactivate the stats legend->Draw(); TLegend* lumi = new TLegend(0.45,0.3,0.75,0.2); lumi->SetFillColor(0); lumi->SetFillStyle(0); lumi->SetBorderSize(0); //lumi->AddEntry((TObject*)0,"#int L dt =4.9 1/fb",""); lumi->Draw(); string channel; if (isMu) channel="Z#rightarrow#mu#mu"; if (!isMu) channel="Z#rightarrow ee"; TLatex *latexLabel=CMSPrel(4.890,channel,0.55,0.85); // make fancy label latexLabel->Draw("same"); CanvPlot->Update(); //===============// // RATIO DATA MC // //===============// CanvPlot->cd(); TPad *pad2 = new TPad("pad2","pad2",0.01,0.01,0.99,0.32); pad2->Draw(); pad2->cd(); pad2->SetTopMargin(0.01); pad2->SetBottomMargin(0.3); pad2->SetRightMargin(0.1); pad2->SetFillStyle(0); TH1D * ratio = (TH1D*) data->Clone(); ratio->SetTitle(""); ratio->SetName("ratio"); ratio->Reset(); ratio->Sumw2(); //data->Sumw2(); hsum->Sumw2(); // FIXME controlla che sia corretto questo... ratio->SetMarkerSize(.5); ratio->SetLineColor(kBlack); ratio->SetMarkerColor(kBlack); //gStyle->SetOptStat("m"); TH1F* sumMC; hs->Draw("nostack"); sumMC=(TH1F*) hs->GetHistogram(); cout<<sumMC->GetEntries()<<endl; ratio->Divide(data,hsum,1.,1.); ratio->GetYaxis()->SetRangeUser(0.5,1.5); ratio->SetMarkerSize(0.8); //pad2->SetTopMargin(1); //Canvas style copied from plotsHistsRatio.C ratio->GetYaxis()->SetNdivisions(5); ratio->GetXaxis()->SetTitleSize(0.14); ratio->GetXaxis()->SetLabelSize(0.14); ratio->GetYaxis()->SetLabelSize(0.11); ratio->GetYaxis()->SetTitleSize(0.11); ratio->GetYaxis()->SetTitleOffset(0.43); ratio->GetYaxis()->SetTitle("ratio data/MC"); ratio->Draw("E1"); TLine *OLine = new TLine(ratio->GetXaxis()->GetXmin(),1.,ratio->GetXaxis()->GetXmax(),1.); OLine->SetLineColor(kBlack); OLine->SetLineStyle(2); OLine->Draw(); TLegend* label = new TLegend(0.60,0.9,0.50,0.95); label->SetFillColor(0); label->SetFillStyle(0); label->SetBorderSize(0); //horrible mess double binContent = 0; double binSum = 0; double weightSum = 0; double binError = 1; double totalbins = ratio->GetSize() -2; for(unsigned int bin=1;bin<=totalbins;bin++){ binContent = ratio->GetBinContent(bin); binError = ratio->GetBinError(bin); if(binError!=0){ binSum += binContent/binError; weightSum += 1./binError; } } double ymean = binSum / weightSum; //double ymean = ratio->GetMean(2); stringstream sYmean; sYmean << ymean; string labeltext=sYmean.str()+" mean Y"; //label->AddEntry((TObject*)0,labeltext.c_str(),""); // mean on Y //label->Draw(); //TPaveStats *r3 = (TPaveStats*)ratio->FindObject("stats"); //r3->SetX1NDC(0.01); //r3->SetX2NDC(0.10); //r3->SetY1NDC(0.20); //r3->SetY2NDC(0.50); //gStyle->SetOptStat("mr"); //r3->SetTextColor(kWhite); //r3->SetLineColor(kWhite); //r3->Draw(); CanvPlot->Update(); tmp=plotpath+plot+".png"; CanvPlot->Print(tmp.c_str()); } else if (flag==2){ //CanvPlot.Divide(2,1); //CanvPlot.cd(1); // data dataf->cd("validationJEC"); if (isMu && isAngularAnalysis) dataf->cd("validationJECmu"); gDirectory->GetObject(plot.c_str(),data2); data2->Draw("COLZ"); gPad->Update(); // altrimenti non becchi la stat TPaveStats *r1 = (TPaveStats*)data2->FindObject("stats"); //r1->SetX1NDC(0.70); Uncomment if you wonna draw your stat in the top right corner //r1->SetX2NDC(0.85); //r1->Draw(); CanvPlot->Update(); tmp=plotpath+plot+"data.png"; CanvPlot->Print(tmp.c_str()); //CanvPlot.cd(2); // montecarlo mcf->cd("validationJEC"); if (isMu) mcf->cd("validationJECmu/"); if (isAngularAnalysis) { mcf->cd("validationJEC/"); if (isMu) mcf->cd("validationJECmu/"); } gDirectory->GetObject(plot.c_str(),data2); data2->SetMinimum(1); data2->Draw("COLZ"); gPad->Update(); // altrimenti non becchi la stat //TPaveStats *r2 = (TPaveStats*)data2->FindObject("stats"); //r2->SetX1NDC(0.70); //r2->SetX2NDC(0.85); //r2->Draw(); CanvPlot->Update(); tmp=plotpath+plot+"mc.png"; CanvPlot->Print(tmp.c_str()); } // else { cout << "You're getting an exception! Most likely there's no histogram here... \n"; } delete data; delete data2; delete hs; //delete CanvPlot; dataf->Close(); mcf->Close(); ttbarf->Close(); wf->Close(); qcd23emf->Close(); qcd38emf->Close(); qcd817emf->Close(); qcd23bcf->Close(); qcd38bcf->Close(); qcd817bcf->Close(); WZf->Close(); ZZf->Close(); if (isAngularAnalysis){ if (bckg_leadingJetPt.size()>0 && bckg_2leadingJetPt.size()>0 && bckg_3leadingJetPt.size()>0 && bckg_4leadingJetPt.size()>0 && bckg_JetMultiplicity.size()>0 && bckg_HT.size()>0 && bckg_leadingJetEta.size()>0 && bckg_PhiStar.size()>0 && cold){ fzj->cd(); treeBKG_->Fill(); treeBKG_->Write(); TH1F *leadhisto=new TH1F("leadhisto","leading jet background contribution",bckg_leadingJetPt.size(),0,bckg_leadingJetPt.size()); TH1F *leadhisto2=new TH1F("leadhisto2","subleading jet background contribution",bckg_leadingJetPt.size(),0,bckg_leadingJetPt.size()); TH1F *leadhisto3=new TH1F("leadhisto3","subsubleading jet background contribution",bckg_leadingJetPt.size(),0,bckg_leadingJetPt.size()); TH1F *leadhisto4=new TH1F("leadhisto4","subsubsubleading jet background contribution",bckg_leadingJetPt.size(),0,bckg_leadingJetPt.size()); TH1F *multiphisto=new TH1F("multiphisto","jet multiplicity background contribution",bckg_JetMultiplicity.size(),0,bckg_JetMultiplicity.size()); TH1F *HT=new TH1F("HT","HT background contribution",bckg_HT.size(),0,bckg_HT.size()); TH1F *HT1=new TH1F("HT1","HT background contribution when >= 1 jet",bckg_HT1.size(),0,bckg_HT1.size()); TH1F *HT2=new TH1F("HT2","HT background contribution when >= 2 jets",bckg_HT2.size(),0,bckg_HT2.size()); TH1F *HT3=new TH1F("HT3","HT background contribution when >= 3 jets",bckg_HT3.size(),0,bckg_HT3.size()); TH1F *HT4=new TH1F("HT4","HT background contribution when >= 4 jets",bckg_HT4.size(),0,bckg_HT4.size()); TH1F *leadhistoeta=new TH1F("leadhistoeta","leading jet background contribution",bckg_leadingJetEta.size(),0,bckg_leadingJetEta.size()); TH1F *leadhistoeta2=new TH1F("leadhistoeta2","subleading jet background contribution",bckg_leadingJetEta.size(),0,bckg_leadingJetEta.size()); TH1F *leadhistoeta3=new TH1F("leadhistoeta3","subsubleading jet background contribution",bckg_leadingJetEta.size(),0,bckg_leadingJetEta.size()); TH1F *leadhistoeta4=new TH1F("leadhistoeta4","subsubsubleading jet background contribution",bckg_leadingJetEta.size(),0,bckg_leadingJetEta.size()); TH1F *PhiStar=new TH1F("PhiStar","PhiStar background contribution",bckg_PhiStar.size(),0,bckg_PhiStar.size()); for (int i=0; i< bckg_leadingJetPt.size(); i++){ leadhisto->Fill(i,bckg_leadingJetPt[i]); leadhisto2->Fill(i,bckg_2leadingJetPt[i]); leadhisto3->Fill(i,bckg_3leadingJetPt[i]); leadhisto4->Fill(i,bckg_4leadingJetPt[i]); } leadhisto->Write(); leadhisto2->Write(); leadhisto3->Write(); leadhisto4->Write(); for (int i=0; i< bckg_leadingJetEta.size(); i++){ leadhistoeta->Fill(i,bckg_leadingJetEta[i]); leadhistoeta2->Fill(i,bckg_2leadingJetEta[i]); leadhistoeta3->Fill(i,bckg_3leadingJetEta[i]); leadhistoeta4->Fill(i,bckg_4leadingJetEta[i]); } leadhistoeta->Write(); leadhistoeta2->Write(); leadhistoeta3->Write(); leadhistoeta4->Write(); //fzj->Close(); for (int i=0; i< bckg_JetMultiplicity.size(); i++){ multiphisto->Fill(i,bckg_JetMultiplicity[i]); } multiphisto->Write(); /////////////// for (int i=0; i< bckg_HT.size(); i++){ HT->Fill(i,bckg_HT[i]); } HT->Write(); for (int i=0; i< bckg_HT1.size(); i++){ HT1->Fill(i,bckg_HT1[i]); } HT1->Write(); for (int i=0; i< bckg_HT2.size(); i++){ HT2->Fill(i,bckg_HT2[i]); } HT2->Write(); for (int i=0; i< bckg_HT3.size(); i++){ HT3->Fill(i,bckg_HT3[i]); } HT3->Write(); for (int i=0; i< bckg_HT4.size(); i++){ HT4->Fill(i,bckg_HT4[i]); } HT4->Write(); //Phi star for (int i=0; i< bckg_PhiStar.size(); i++){ PhiStar->Fill(i,bckg_PhiStar[i]); } PhiStar->Write(); cold=false; } } return; }
void plotVariable(string variable = "Elec_Fbrem", const TString& category = "TauNoGammas", const TString& xAxisTitle = "Fbrem", const TString& yAxisTitle = "a.u.", float xMin = -0.2, float xMax = 1, int nBins = 100, int numPVMin = 0, int numPVMax = 50, float PtMin = 10, float PtMax = 60, const TString& Region = "Endcap" ) { string discriminator = ""; // string discriminator = "-AntiEMed"; float AbsEtaMin = 0; float AbsEtaMax = 3.0; if(Region == "Barrel"){ AbsEtaMin = 0; AbsEtaMax = 1.479; } if(Region == "Endcap"){ AbsEtaMin = 1.479; AbsEtaMax = 3.0; } TCanvas *c1 = new TCanvas("c1","",5,30,650,600); c1->SetGrid(0,0); c1->SetFillStyle(4000); c1->SetFillColor(10); c1->SetTicky(); c1->SetObjectStat(0); gStyle->SetOptStat(0); gStyle->SetTitleFillColor(0); gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasColor(0); gStyle->SetPadBorderMode(0); gStyle->SetPadColor(0); gStyle->SetTitleFillColor(0); gStyle->SetTitleBorderSize(0); gStyle->SetTitleH(0.07); gStyle->SetTitleFontSize(0.1); gStyle->SetTitleStyle(0); gStyle->SetTitleOffset(1.3,"y"); TLegend* leg = new TLegend(0.6,0.75,0.8,0.88,NULL,"brNDC"); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetFillColor(10); leg->SetTextSize(0.03); //leg->SetHeader("#splitline{CMS Preliminary}{ #sqrt{s}=7 TeV}"); // std::string inputFileName = "/data_CMS/cms/ivo/AntiEMVA/Trees/AntiEMVA_Fall11DYJetsToLL-iter4.root"; // std::string inputFileName = "/data_CMS/cms/ivo/AntiEMVA/Trees/Trees_ForV4/AntiEMVA_AntiEMVATrees-DYJetsToLL-madgraph-PUS6.root"; std::string inputFileName = "/data_CMS/cms/ivo/AntiEMVA/Trees/Trees_ForV4/AntiEMVA_V4.root"; TFile* inputFile = new TFile (inputFileName.data(),"READ"); if(inputFile->IsZombie()){ cout << "No such file!" << endl; return; } TTree* inputTree = (TTree*)inputFile->Get("AntiEMVAAnalyzer2/tree"); // TTree* inputTree = (TTree*)inputFile->Get("AntiEMVAAnalyzer/tree"); std::vector<TH1*> histograms; std::vector<std::string> matchings ; matchings.push_back("GenHadMatch"); matchings.push_back("GenEleMatch"); for ( std::vector<std::string>::const_iterator matching = matchings.begin(); matching != matchings.end(); ++matching ) { TCut PUSelection(Form("NumPV>%i && NumPV<%i",numPVMin,numPVMax)); TCut ElecPtSelection (Form("Elec_Pt>%0f && Elec_Pt<%0f",PtMin,PtMax)); TCut TauPtSelection (Form("Tau_Pt>%0f && Tau_Pt<%0f",PtMin,PtMax)); TCut ElecAbsEtaSelection (Form("Elec_AbsEta>%0f && Elec_AbsEta<%0f",AbsEtaMin,AbsEtaMax)); TCut TauAbsEtaSelection = ""; if(Region == "Barrel"){ TauAbsEtaSelection = "Tau_Eta>-1.479 && Tau_Eta<1.479"; } if(Region == "Endcap"){ TauAbsEtaSelection = "(Tau_Eta>1.479 && Tau_Eta<3.0) || (Tau_Eta>-3.0 && Tau_Eta<-1.479)"; } // TCut TauAbsEtaSelection (Form("Tau_AbsEta>%0f && Tau_AbsEta<%0f",AbsEtaMin,AbsEtaMax)); TCut ElecMatchSelection (Form("Elec_%s == 1",matching->data())); // TCut ElecMatchSelection (Form("Elec_PFTauMatch && Elec_%s",matching->data())); TCut TauMatchSelection (Form("Tau_%s",matching->data())); TCut CategorySelection = ""; if(discriminator == ""){ if (category == "NoEleMatch") CategorySelection = "Tau_GsfEleMatch<0.5"; if (category == "woG") CategorySelection = "Tau_NumGammaCands<0.5"; if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf<0.5"; if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1"; if (category == "wGwGSFwPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1"; } if(discriminator == "-AntiEMed"){ if (category == "NoEleMatch") CategorySelection = "Tau_GsfEleMatch<0.5"; if (category == "woG") CategorySelection = "Tau_NumGammaCands<0.5"; if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && (Tau_HasGsf<0.5 || (Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1))"; if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1"; } TCut ElecSelection = CategorySelection && PUSelection && ElecPtSelection && ElecAbsEtaSelection && ElecMatchSelection ; TCut TauSelection = CategorySelection && PUSelection && TauPtSelection && TauAbsEtaSelection && TauMatchSelection ; TCut Selection; if (variable.find("Elec")!=std::string::npos)Selection = ElecSelection; if (variable.find("Tau")!=std::string::npos)Selection = TauSelection; TH1F* hVariable = new TH1F( "hVariable" ,"" , nBins ,xMin, xMax); hVariable->SetXTitle(Form("%s",variable.data())); if (matching->find("EleMatch")!=std::string::npos){ // hVariable->SetFillColor(kRed); // hVariable->SetFillStyle(3345); hVariable->SetLineColor(kRed); hVariable->SetLineWidth(2); } if (matching->find("HadMatch")!=std::string::npos){ // hVariable->SetFillColor(kBlue); // hVariable->SetFillStyle(3354); hVariable->SetLineColor(kBlue); hVariable->SetLineWidth(2); } inputTree->Draw(Form("%s>>hVariable",variable.data())); cout<<"Variable plotted : "<<variable<<endl; cout<<"Matching applied : "<<matching->data()<<endl; cout<<" Total number of Candidates : "<<hVariable->GetEntries()<<endl; inputTree->Draw(Form("%s>>hVariable",variable.data()),Selection); cout<<" Number of Cantidates after selection: "<<hVariable->GetEntries()<<endl; hVariable->Scale(1./hVariable->Integral()); leg->AddEntry(hVariable,Form("%s",matching->data())); histograms.push_back(hVariable); c1->Clear(); } // double yMin = +1.e+6; // double yMax = -1.e+6; TH1* refHistogram = histograms.front(); refHistogram->SetStats(false); refHistogram->SetTitle(""); // refHistogram->SetMinimum(yMin); // refHistogram->SetMaximum(yMax); if (xAxisTitle == "HoHplusE" ) { refHistogram->SetMaximum(1.0); refHistogram->SetMinimum(0.01); c1->SetLogy(); } if(xAxisTitle == "E_{#gamma}/(P_{in}-P_{out})" ){ refHistogram->SetMaximum(0.03); refHistogram->SetMinimum(0.0); } if(xAxisTitle == "HadrMva(#tau)" ){ refHistogram->SetMaximum(0.25); refHistogram->SetMinimum(0.0); } TAxis* xAxis = refHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.Data()); xAxis->SetTitleOffset(1.15); //if(variable.find("AbsEta")!=std::string::npos)xAxis->SetLimits(AbsEtaMin, AbsEtaMax); TAxis* yAxis = refHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.Data()); yAxis->SetTitleOffset(1.30); int numHistograms = histograms.size(); float YMax = 0; for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) { TH1* histogram = histograms[iHistogram]; if(histogram->GetMaximum()>YMax) YMax = histogram->GetMaximum(); } for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) { TH1* histogram = histograms[iHistogram]; yAxis->SetRangeUser(0.,YMax+0.10*YMax); std::string drawOption = "hist"; if ( iHistogram > 0 ) drawOption.append("same"); histogram->Draw(drawOption.data()); leg->Draw(); }//loop matchings string outputName = Form("plots/plotVariablesAntiEMVA/%s/plotVariablesAntiEMVA_v4_%s_%s_%s",category.Data(),category.Data(),variable.data(),Region.Data()); c1->Print(std::string(outputName).append(".png").data()); c1->Print(std::string(outputName).append(".pdf").data()); }
void likelihoodrefs( TDirectory *lhdir ) { Bool_t newCanvas = kTRUE; const UInt_t maxCanvas = 200; TCanvas** c = new TCanvas*[maxCanvas]; Int_t width = 670; Int_t height = 380; // avoid duplicated printing std::vector<std::string> hasBeenUsed; const TString titName = lhdir->GetName(); UInt_t ic = -1; TIter next(lhdir->GetListOfKeys()); TKey *key; while ((key = TMVAGlob::NextKey(next,"TH1"))) { // loop over all TH1 TH1 *h = (TH1*)key->ReadObj(); TH1F *b( 0 ); TString hname( h->GetName() ); // avoid duplicated plotting Bool_t found = kFALSE; for (UInt_t j = 0; j < hasBeenUsed.size(); j++) { if (hasBeenUsed[j] == hname.Data()) found = kTRUE; } if (!found) { // draw original plots if (hname.EndsWith("_sig_nice")) { if (newCanvas) { char cn[20]; sprintf( cn, "cv%d_%s", ic+1, titName.Data() ); ++ic; TString n = hname; c[ic] = new TCanvas( cn, Form( "%s reference for variable: %s", titName.Data(),(n.ReplaceAll("_sig","")).Data() ), ic*50+50, ic*20, width, height ); c[ic]->Divide(2,1); newCanvas = kFALSE; } // signal Int_t color = 4; TPad * cPad = (TPad*)c[ic]->cd(1); TString plotname = hname; h->SetMaximum(h->GetMaximum()*1.3); h->SetMinimum( 0 ); h->SetMarkerColor(color); h->SetMarkerSize( 0.7 ); h->SetMarkerStyle( 24 ); h->SetLineWidth(1); h->SetLineColor(color); color++; h->Draw("e1"); Double_t hSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1)); TLegend *legS= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.14, cPad->GetLeftMargin()+.77, 1-cPad->GetTopMargin() ); legS->SetBorderSize(1); legS->AddEntry(h,"Input data (signal)","p"); // background TString bname( hname ); b = (TH1F*)lhdir->Get( bname.ReplaceAll("_sig","_bgd") ); cPad = (TPad*)c[ic]->cd(2); color = 2; b->SetMaximum(b->GetMaximum()*1.3); b->SetMinimum( 0 ); b->SetLineWidth(1); b->SetLineColor(color); b->SetMarkerColor(color); b->SetMarkerSize( 0.7 ); b->SetMarkerStyle( 24 ); b->Draw("e1"); Double_t hBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1)); TLegend *legB= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.14, cPad->GetLeftMargin()+.77, 1-cPad->GetTopMargin() ); legB->SetBorderSize(1); legB->AddEntry(b,"Input data (backgr.)","p"); // register hasBeenUsed.push_back( bname.Data() ); // the PDFs -------------- // check for splines h = 0; b = 0; TString pname = hname; pname.ReplaceAll("_nice",""); for (int i=0; i<= 5; i++) { TString hspline = pname + Form( "_smoothed_hist_from_spline%i", i ); h = (TH1F*)lhdir->Get( hspline ); if (h) { b = (TH1F*)lhdir->Get( hspline.ReplaceAll("_sig","_bgd") ); break; } } // check for KDE if (h == 0 && b == 0) { TString hspline = pname +"_smoothed_hist_from_KDE"; h = (TH1F*)lhdir->Get( hspline ); if (h) { b = (TH1F*)lhdir->Get( hspline.ReplaceAll("_sig","_bgd") ); } } // found something ? if (h == 0 || b == 0) { cout << "--- likelihoodrefs.C: did not find spline for histogram: " << pname.Data() << endl; } else { Double_t pSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1)); h->Scale( pSscale/hSscale ); color = 4; c[ic]->cd(1); h->SetLineWidth(2); h->SetLineColor(color); legS->AddEntry(h,"Estimated PDF (norm. signal)","l"); h->Draw("histsame"); legS->Draw(); Double_t pBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1)); b->Scale( pBscale/hBscale ); color = 2; c[ic]->cd(2); b->SetLineColor(color); b->SetLineWidth(2); legB->AddEntry(b,"Estimated PDF (norm. backgr.)","l"); b->Draw("histsame"); // draw the legends legB->Draw(); hasBeenUsed.push_back( pname.Data() ); } c[ic]->Update(); // write to file TString fname = Form( "root_mva/plots/%s_refs_c%i", titName.Data(), ic+1 ); TMVAGlob::imgconv( c[ic], fname ); // c[ic]->Update(); newCanvas = kTRUE; hasBeenUsed.push_back( hname.Data() ); } } } }
void makeNeuralMtautauPerformancePlots() { std::string inputFileName = "../test/testNeuralMtautau.root"; TFile* inputFile = TFile::Open(inputFileName.data()); std::string histogramName = "histogramRecVsGenMass"; TH2* histogram2d = dynamic_cast<TH2*>(getHistogram(inputFile, "", histogramName.data())); const int numGenMassBins = 17; double genMassBins[] = { 0., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 160., 200., 250., 300., 350., 400., 500. }; int genMassBin_index = 0; TH1* histogram1dTruncatedSum = 0; TGraphErrors* graph_mean = new TGraphErrors(numGenMassBins); TGraphErrors* graph_rms = new TGraphErrors(numGenMassBins); int numBins2dX = histogram2d->GetNbinsX(); for ( int iBin2dX = 1; iBin2dX <= numBins2dX; ++iBin2dX ) { std::string histogram1dName = std::string(histogram2d->GetName()).append(Form("BinX%i", iBin2dX)); TH1* histogram1d = histogram2d->ProjectionX(histogram1dName.data(), iBin2dX, iBin2dX); std::string histogram1dTruncatedName = std::string(histogram2d->GetName()).append(Form("BinX%i_truncated", iBin2dX)); TH1* histogram1dTruncated = new TH1D(histogram1dTruncatedName.data(), histogram1dTruncatedName.data(), 200, 0., 2.); double mTauTau_gen = histogram2d->GetXaxis()->GetBinCenter(iBin2dX); //if ( mTauTau_gen > 100. ) continue; //std::cout << "iBin2dX = " << iBin2dX << ": mTauTau(gen) = " << mTauTau_gen << std::endl; //std::cout << "histogram1d: mean = " << histogram1d->GetMean() << "," // << " rms = " << histogram1d->GetRMS() << std::endl; int numBins1d = histogram1d->GetNbinsX(); for ( int iBin1d = 1; iBin1d <= numBins1d; ++iBin1d ) { double mTauTau_rec = histogram1d->GetBinCenter(iBin1d); //std::cout << "iBin1d = " << iBin1d << ": mTauTau(rec) = " << mTauTau_rec << std::endl; double ratio = mTauTau_rec/mTauTau_gen; //std::cout << "ratio = " << ratio << std::endl; double binContent = histogram1d->GetBinContent(iBin1d); if ( binContent > 1.e-2 ) histogram1dTruncated->Fill(ratio, binContent); } //std::cout << "histogram1dTruncated: mean = " << histogram1dTruncated->GetMean() << "," // << " rms = " << histogram1dTruncated->GetRMS() << std::endl; delete histogram1d; if ( mTauTau_gen > genMassBins[genMassBin_index + 1] && mTauTau_gen < genMassBins[numGenMassBins - 1] ) { double x = 0.5*(genMassBins[genMassBin_index] + genMassBins[genMassBin_index + 1]); double xErr = 0.5*(genMassBins[genMassBin_index + 1] - genMassBins[genMassBin_index]); double y_mean = histogram1dTruncatedSum->GetMean(); double yErr_mean = histogram1dTruncatedSum->GetMeanError(); double y_rms = histogram1dTruncatedSum->GetRMS(); double yErr_rms = histogram1dTruncatedSum->GetRMSError(); //std::cout << "mTauTau(gen) = " << x << ": mean = " << y_mean << " +/- " << yErr_mean << "," // << " rms = " << y_rms << " +/- " << yErr_rms << std::endl; graph_mean->SetPoint(genMassBin_index, x, y_mean); graph_mean->SetPointError(genMassBin_index, xErr, yErr_mean); graph_rms->SetPoint(genMassBin_index, x, y_rms); graph_rms->SetPointError(genMassBin_index, xErr, yErr_rms); delete histogram1dTruncatedSum; histogram1dTruncatedSum = 0; ++genMassBin_index; } if ( !histogram1dTruncatedSum ) { histogram1dTruncatedSum = histogram1dTruncated; } else { histogram1dTruncatedSum->Add(histogram1dTruncated); delete histogram1dTruncated; } } delete histogram1dTruncatedSum; TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); canvas->SetLogy(); TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 50, 0., 500.); dummyHistogram->SetStats(false); dummyHistogram->SetTitle(""); dummyHistogram->SetMinimum(1.e-2); dummyHistogram->SetMaximum(1.e+1); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle("M_{#tau#tau}^{gen} / GeV"); xAxis->SetTitleOffset(1.15); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle("M_{#tau#tau}^{rec} / GeV"); yAxis->SetTitleOffset(1.30); dummyHistogram->Draw("axis"); graph_mean->SetMarkerStyle(20); graph_mean->SetMarkerColor(1); graph_mean->Draw("P"); graph_rms->SetMarkerStyle(20); graph_rms->SetMarkerColor(2); graph_rms->Draw("P"); TLegend* legend = new TLegend(0.64, 0.69, 0.88, 0.87, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); legend->AddEntry(graph_mean, "<M_{#tau#tau}^{rec}/M_{#tau#tau}^{gen}>", "p"); legend->AddEntry(graph_rms, "#sigma(M_{#tau#tau}^{rec}/M_{#tau#tau}^{gen})", "p"); legend->Draw(); canvas->Update(); std::string outputFileName = "neuralMtautauPerformancePlot.eps"; size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); 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()); delete graph_mean; delete graph_rms; delete dummyHistogram; delete legend; delete canvas; }
void proc_pileup(const AliVdMMetaData& vdmMetaData, AliVdMScanData& allData, const char* classAC, const char* classAnotC, const char* classCnotA, const std::vector<Double_t>& par0) { typedef std::map<Short_t, TGraphErrors> map_t; // BCID -> TGraphErrors map_t gAnotC, gCnotA; // one-arm/two-arm ratios // (1) fill one-arm/two-arm ratio graphs for all BCIDs for (Int_t iScan=0; iScan<4; ++iScan) { AliVdMTree& vtAND = allData.GetMap(iScan)[classAC]; AliVdMTree& vtAnotC = allData.GetMap(iScan)[classAnotC]; AliVdMTree& vtCnotA = allData.GetMap(iScan)[classCnotA]; vtAND.Zip3([&gAnotC,&gCnotA](const AliVdMTree::DefaultBranchData& d, AliVdMTree::branchMap_t& mapAC, AliVdMTree::branchMap_t& mapAnotC, AliVdMTree::branchMap_t& mapCnotA) { AliVdMTree::ValErr v1 = mapAnotC["rate"]; v1 /= mapAC["rate"]; // v1 /= mapAC["relBkgd"]; v1 *= mapAnotC["relBkgd"]; if (!v1.isInf() && v1.val()) { const Int_t m1 = gAnotC[d.BCID()].GetN(); gAnotC[d.BCID()].SetPoint (m1, mapAC["mu"].val(), v1.val()); gAnotC[d.BCID()].SetPointError(m1, mapAC["mu"].err(), v1.err()); } AliVdMTree::ValErr v2 = mapCnotA["rate"]; v2 /= mapAC["rate"]; // v2 /= mapAC["relBkgd"]; v2 *= mapCnotA["relBkgd"]; if (!v2.isInf() && v2.val()) { const Int_t m2 = gCnotA[d.BCID()].GetN(); gCnotA[d.BCID()].SetPoint (m2, mapAC["mu"].val(), v2.val()); gCnotA[d.BCID()].SetPointError(m2, mapAC["mu"].err(), v2.err()); } }, vtAnotC, vtCnotA); } // (2) fit model AliVdMPileup pileupModel; TString pn = TString::Format("pileup_%s.pdf", classAC); TCanvas *c1 = new TCanvas; c1->SaveAs(pn+"["); const AliTriggerBCMask& bcMask = vdmMetaData.GetTriggerBCMask(); const Int_t nBCs = bcMask.GetNUnmaskedBCs(); TH1 *hPar[5] = { SetAttr(new TH1D("hrA", ";BCID;r_{A}", nBCs,0,nBCs), kRed), SetAttr(new TH1D("hrC", ";BCID;r_{C}", nBCs,0,nBCs), kBlue), SetAttr(new TH1D("hbkgdA", ";BCID;bkgd_{A}", nBCs,0,nBCs), kRed), SetAttr(new TH1D("hbkgdC", ";BCID;bkgd_{C}", nBCs,0,nBCs), kBlue), SetAttr(new TH1D("hChi2NDF", ";BCID;#chi^{2}/n.d.f.", nBCs,0,nBCs), kBlue) }; for (Int_t bc=0, counter=0; bc<3564; ++bc) { if (bcMask.GetMask(bc)) continue; const TString binLabel = TString::Format("%d", bc); for (Int_t i=0; i<5; ++i) hPar[i]->GetXaxis()->SetBinLabel(1+counter, binLabel); c1->Clear(); c1->SetLogx(); c1->SetLogy(); TH1 *hf = c1->DrawFrame(1e-6, 0.01, 0.5, 20); hf->SetTitle(TString::Format("BCID=%d %s;two-arm #mu;one-arm/two-arm", bc, classAC)); pileupModel.DoFit(&gAnotC[bc], &gCnotA[bc], &par0[0]); SetAttr(&gAnotC[bc], kBlue); SetAttr(&gCnotA[bc], kRed); gAnotC[bc].Draw("PE"); gCnotA[bc].Draw("PE"); TF1 *fAnotC = SetAttr(new TF1("fAnotC", &pileupModel, &AliVdMPileup::fcnAnotC, 1e-6, 0.5, 5), kBlue); fAnotC->SetParameters(pileupModel.GetPar()); fAnotC->SetNpx(1000); fAnotC->Draw("same"); TF1 *fCnotA = SetAttr(new TF1("fCnotA", &pileupModel, &AliVdMPileup::fcnCnotA, 1e-6, 0.5, 5), kRed); fCnotA->SetParameters(pileupModel.GetPar()); fCnotA->SetNpx(1000); fCnotA->Draw("same"); TLegend *leg = new TLegend(0.6, 0.75, 0.9, 0.9); leg->AddEntry(&gCnotA[bc], "AnotC/AandC", "PEL"); leg->AddEntry(&gAnotC[bc], "CnotA/AandC", "PEL"); leg->Draw(); TPaveText *pt = new TPaveText(0.6, 0.4, 0.9, 0.7, "NDC NB"); pt->SetFillStyle(0); pt->AddText(TString::Format("#chi^{2}/n.d.f = %.0f/%.0f = %.2f", pileupModel.GetChi2(), pileupModel.GetNDF(), pileupModel.GetChi2()/pileupModel.GetNDF())); { double curval,err, lowlim, uplim; int iuint; TString name; for (Int_t ivar=0; ivar<4; ++ivar) { gMinuit->mnpout(ivar, name, curval, err, lowlim, uplim,iuint); hPar[ivar]->SetBinContent(1+counter, curval); hPar[ivar]->SetBinError(1+counter, err); if (ivar==0) { hf->SetMinimum(0.5*curval); } if (ivar==1) { hf->SetMinimum(TMath::Min(hf->GetMinimum(), 0.5*curval)); } if (ivar < 2) pt->AddText(TString::Format("%s = %.4f#pm%.4f", name.Data(), curval, err)); else pt->AddText(TString::Format("%s = %.1e#pm%.1e", name.Data(), curval, err)); pt->GetLine(1+ivar)->SetTextColor(ivar%2 ? kRed : kBlue); } hPar[4]->SetBinContent(1+counter, pileupModel.GetChi2()/pileupModel.GetNDF()); } pt->Draw(); c1->SaveAs(pn); Printf("%f / %f", pileupModel.GetChi2(), pileupModel.GetNDF()); ++counter; } gStyle->SetOptStat("n"); gStyle->SetOptFit(111); TCanvas *c2 = new TCanvas; for (Int_t i=0; i<4; ++i) { FitPol0(hPar[i])->Draw(); c2->SaveAs(pn); } hPar[4]->SetMinimum(0); hPar[4]->Draw(); c2->SaveAs(pn+")"); }
void showGraphs(double canvasSizeX, double canvasSizeY, TGraph* graph1, const std::string& legendEntry1, TGraph* graph2, const std::string& legendEntry2, TGraph* graph3, const std::string& legendEntry3, TGraph* graph4, const std::string& legendEntry4, TGraph* graph5, const std::string& legendEntry5, TGraph* graph6, const std::string& legendEntry6, int colors[], int markerStyles[], double legendTextSize, double legendPosX, double legendPosY, double legendSizeX, double legendSizeY, std::vector<std::string>& labelTextLines, double labelTextSize, double labelPosX, double labelPosY, double labelSizeX, double labelSizeY, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.14); canvas->SetBottomMargin(0.12); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 100, xMin, xMax); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleSize(0.045); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleSize(0.045); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw("axis"); graph1->SetLineColor(colors[0]); graph1->SetLineWidth(2); graph1->SetMarkerColor(colors[0]); graph1->SetMarkerStyle(markerStyles[0]); graph1->SetMarkerSize(2); graph1->Draw("p"); if ( graph2 ) { graph2->SetLineColor(colors[1]); graph2->SetLineWidth(2); graph2->SetMarkerColor(colors[1]); graph2->SetMarkerStyle(markerStyles[1]); graph2->SetMarkerSize(2); graph2->Draw("p"); } if ( graph3 ) { graph3->SetLineColor(colors[2]); graph3->SetLineWidth(2); graph3->SetMarkerColor(colors[2]); graph3->SetMarkerStyle(markerStyles[2]); graph3->SetMarkerSize(2); graph3->Draw("p"); } if ( graph4 ) { graph4->SetLineColor(colors[3]); graph4->SetLineWidth(2); graph4->SetMarkerColor(colors[3]); graph4->SetMarkerStyle(markerStyles[3]); graph4->SetMarkerSize(2); graph4->Draw("p"); } if ( graph5 ) { graph5->SetLineColor(colors[4]); graph5->SetLineWidth(2); graph5->SetMarkerColor(colors[4]); graph5->SetMarkerStyle(markerStyles[4]); graph5->SetMarkerSize(2); graph5->Draw("p"); } if ( graph6 ) { graph6->SetLineColor(colors[5]); graph6->SetLineWidth(2); graph6->SetMarkerColor(colors[5]); graph6->SetMarkerStyle(markerStyles[5]); graph6->SetMarkerSize(2); graph6->Draw("p"); } TLegend* legend = new TLegend(legendPosX, legendPosY, legendPosX + legendSizeX, legendPosY + legendSizeY, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); legend->SetTextSize(legendTextSize); legend->AddEntry(graph1, legendEntry1.data(), "p"); if ( graph2 ) legend->AddEntry(graph2, legendEntry2.data(), "p"); if ( graph3 ) legend->AddEntry(graph3, legendEntry3.data(), "p"); if ( graph4 ) legend->AddEntry(graph4, legendEntry4.data(), "p"); if ( graph5 ) legend->AddEntry(graph5, legendEntry5.data(), "p"); if ( graph6 ) legend->AddEntry(graph6, legendEntry6.data(), "p"); legend->Draw(); TPaveText* label = 0; if ( labelTextLines.size() > 0 ) { label = new TPaveText(labelPosX, labelPosY, labelPosX + labelSizeX, labelPosY + labelSizeY, "brNDC"); for ( std::vector<std::string>::const_iterator labelTextLine = labelTextLines.begin(); labelTextLine != labelTextLines.end(); ++labelTextLine ) { label->AddText(labelTextLine->data()); } label->SetFillColor(10); label->SetBorderSize(0); label->SetTextColor(1); label->SetTextAlign(12); label->SetTextSize(labelTextSize); label->Draw(); } canvas->Update(); std::string outputFileName_plot = "plots/"; size_t idx = outputFileName.find_last_of('.'); outputFileName_plot.append(std::string(outputFileName, 0, idx)); 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()); delete dummyHistogram; delete label; delete legend; delete canvas; }
void cmsRAA(int version = 6) { double mymarkersize = 1.; bool bDo2PadZoo = true; //----------------------------------------- charged hadrons double ptBins_h[27]={0}; double ptError_h[27]={0}; double raa_h[27]; double raaStat_h[27]; double raaSyst_h[27]; double ptSystXlow_h[27]; double ptSystXhigh_h[27]; // reading numbers ifstream inData_h; TString inFile("raa_h05.dat"); inData_h.open(inFile); if(inData_h.fail()) { cerr << "unable to open file raa_h05.dat for reading" << endl; exit(1); } Int_t j=0; Double_t xx_low, xx_high,raa,raa_syst, raa_stat; while(!inData_h.eof()) { inData_h >> xx_low >> xx_high >> raa >> raa_syst >> raa_stat; ptBins_h[j] = xx_low+ (xx_high-xx_low)/2; raa_h[j] = raa; raaStat_h[j] = raa_syst; raaSyst_h[j] = raa_stat; ptSystXlow_h[j] = (xx_high-xx_low)/2; ptSystXhigh_h[j]= (xx_high-xx_low)/2; // cout<<"pT"<<ptBins_h[j]<<"\t raa= "<<raa_h[j]<<"\t syst= "<<raaStat_h[j]<<"\t stat ="<<raaSyst_h[j]<<"\t x_low= "<<ptSystXlow_h[j]<<"\t high= "<<ptSystXhigh_h[j]<<endl; j++; } inData_h.close(); // done reading numebrs TGraphErrors *pgRaa_h = new TGraphErrors(27, ptBins_h, raa_h, ptError_h, raaStat_h); TGraphAsymmErrors *pgRaaSyst_h = new TGraphAsymmErrors(27, ptBins_h, raa_h, ptSystXlow_h,ptSystXhigh_h,raaSyst_h,raaSyst_h); pgRaa_h->SetName("pgRaa_h"); pgRaa_h->SetMarkerStyle(kFullCircle); pgRaa_h->SetMarkerSize(1.); //systm error pgRaaSyst_h->SetName("pgRaaSyst_h"); pgRaaSyst_h->SetFillColor(TColor::GetColor("#33ccff")); //----------------------------------------- jet RAA double ptBins_jet[] = {105,115,125,135,145,155,165,175,190,220,270}; double ptError_jet[] = {0.0, 0.0, 0.0, 0.0, 0.0,0,0,0,0,0,0}; double raa_jet[] = {0.47, 0.47, 0.46, 0.44, 0.43, 0.47, 0.52, 0.51, 0.44, 0.42, 0.58}; double raaStat_jet[] = {0.0076, 0.0098, 0.013, 0.016, 0.021, 0.028, 0.038, 0.045, 0.035, 0.039, 0.098}; double raaSyst_jet[] = {0.07, 0.07, 0.08, 0.09, 0.08, 0.08, 0.08, 0.08, 0.07, 0.07, 0.10 }; double ptSystXlow_jet[] = {5, 5, 5, 5, 5,5,5,5,10,20,30}; double ptSystXhigh_jet[] = {5, 5, 5, 5, 5,5,5,5,10,20,30}; TGraphErrors *pgRaa_jet = new TGraphErrors(11, ptBins_jet, raa_jet, ptError_jet, raaStat_jet); TGraphAsymmErrors *pgRaaSyst_jet = new TGraphAsymmErrors(11, ptBins_jet, raa_jet, ptSystXlow_jet,ptSystXhigh_jet,raaSyst_jet,raaSyst_jet); pgRaa_jet->SetName("pgRaa_jet"); pgRaa_jet->SetMarkerStyle(22); pgRaa_jet->SetMarkerSize(1.); //systm error pgRaaSyst_jet->SetName("pgRaaSyst_jet"); pgRaaSyst_jet->SetFillColor(TColor::GetColor("#00FF60")); //----------------------------------------- b-jet RAA double ptBins_bjet[5] = {85,100,120,150,210}; double ptError_bjet[5] = {0,0,0,0,0}; double raa_bjet[5] = {0.3927,0.3277,0.4598,0.4034,0.4214}; double raaStat_bjet[5] = {0.0179,0.0178,0.0374,0.0625,0.1589}; double raaSyst_bjet[5] = {0.0917,0.0923,0.1272,0.1529,0.2771}; double ptSystXlow_bjet[5] = {5,10,10,20,40}; double ptSystXhigh_bjet[5] = {5,10,10,20,40}; TGraphErrors *pgRaa_bjet = new TGraphErrors(5, ptBins_bjet, raa_bjet, ptError_bjet, raaStat_bjet); TGraphAsymmErrors *pgRaaSyst_bjet = new TGraphAsymmErrors(5, ptBins_bjet, raa_bjet, ptSystXlow_bjet,ptSystXhigh_bjet,raaSyst_bjet,raaSyst_bjet); pgRaa_bjet->SetName("pgRaa_bjet"); pgRaa_bjet->SetMarkerStyle(21); pgRaa_bjet->SetMarkerColor(kRed); pgRaa_bjet->SetMarkerSize(1.); //systm error pgRaaSyst_bjet->SetName("pgRaaSyst_bjet"); pgRaaSyst_bjet->SetFillColor(TColor::GetColor("#FFBF00")); //----------------------------------------- photon double ptBins_photon[] = {22.26, 27.30, 34.35, 44.45, 61.72}; double ptError_photon[] = {0.0, 0.0, 0.0, 0.0, 0.0}; double raa_photon[] = {1.03, 0.84, 1.37, 0.98, 0.99}; double raaStat_photon[] = {0.12 ,0.14, 0.22, 0.24, 0.31 }; double raaSyst_photon[] = {0.29, 0.27, 0.25, 0.22, 0.21}; double ptSystXlow_photon[] = {2.5, 2.5, 5, 5, 15}; double ptSystXhigh_photon[] = {2.5, 2.5, 5, 5, 15}; TGraphErrors *pgRaa_photon = new TGraphErrors(5, ptBins_photon, raa_photon, ptError_photon, raaStat_photon); TGraphAsymmErrors *pgRaaSyst_photon = new TGraphAsymmErrors(5, ptBins_photon, raa_photon, ptSystXlow_photon,ptSystXhigh_photon,raaSyst_photon,raaSyst_photon); pgRaa_photon->SetName("pgRaa_photon"); pgRaa_photon->SetMarkerStyle(23); pgRaa_photon->SetMarkerSize(1.); //systm error pgRaaSyst_photon->SetName("pgRaaSyst_photon"); pgRaaSyst_photon->SetFillColor(TColor::GetColor("#ffff00")); //----------------------------------------- Z double ptBins_z[] = {91.19}; //double ptBins_z[7] = {2.5,7.5,15,25,35,45,75}; double ptError_z[] = {0.0}; //double ptError_z[7] = {0.0}; double raa_z[] = {1.06}; double raaStat_z[] = {0.05}; double raaSyst_z[] = {0.08}; double ptSystXlow_z[] = {4}; double ptSystXhigh_z[] = {4}; //double raa_z[7] = {0.88,1.20,1.00,1.35,1.11,1.35,0.78}; //double raaStat_z[7] = {0.09,0.13,0.11,0.22,0.27,0.42,0.20}; //double raaSyst_z[7] = {0.06,0.08,0.07,0.09,0.08,0.09,0.05}; //double ptSystXlow_z[7] = {2.5,2.5,5,5,5,5,25}; //double ptSystXhigh_z[7] = {2.5,2.5,5,5,5,5,25}; TGraphErrors *pgRaa_z = new TGraphErrors(1, ptBins_z, raa_z, ptError_z, raaStat_z); TGraphAsymmErrors *pgRaaSyst_z = new TGraphAsymmErrors(1, ptBins_z, raa_z, ptSystXlow_z,ptSystXhigh_z,raaSyst_z,raaSyst_z); pgRaa_z->SetName("pgRaa_z"); pgRaa_z->SetMarkerStyle(kFullCircle); pgRaa_z->SetMarkerSize(1.); pgRaa_z->SetMarkerStyle(22); //systm error pgRaaSyst_z->SetName("pgRaaSyst_z"); pgRaaSyst_z->SetFillColor(TColor::GetColor("#ff8888")); // ----------------------------------------- W raa double ptBins_w[] = {80.38}; double ptError_w[] = {0.0}; double raa_w[] = {1.04}; double raaStat_w[] = {0.07}; double raaSyst_w[] = {0.12}; double ptSystXlow_w[] = {4}; double ptSystXhigh_w[] = {4}; TGraphErrors *pgRaa_w = new TGraphErrors(1, ptBins_w, raa_w, ptError_w, raaStat_w); TGraphAsymmErrors *pgRaaSyst_w = new TGraphAsymmErrors(1, ptBins_w, raa_w, ptSystXlow_w,ptSystXhigh_w,raaSyst_w,raaSyst_w); pgRaa_w->SetName("pgRaa_w"); pgRaa_w->SetMarkerStyle(kFullCircle); pgRaa_w->SetMarkerSize(1.); pgRaa_w->SetMarkerStyle(21); //systm error pgRaaSyst_w->SetName("pgRaaSyst_w"); pgRaaSyst_w->SetFillColor(TColor::GetColor("#ff88ff")); // ----------------------------------------- 2012 non-prompt Jpsi double ptBins_npjpsi[] = {7.31,8.97,11.32,16.52}; double ptError_npjpsi[] = {0.0,0.0,0.0,0.0}; double raa_npjpsi[] = {0.52,0.43,0.43,0.34}; double raaStat_npjpsi[] = {0.12,0.08,0.09,0.07}; double raaSyst_npjpsi[] = {0.06,0.05,0.05,0.04}; double ptSystXlow_npjpsi[] = {0.81, 0.97, 1.32, 3.52}; double ptSystXhigh_npjpsi[] = {0.69, 1.03, 1.68, 13.48}; TGraphErrors *pgRaa_npjpsi = new TGraphErrors(4, ptBins_npjpsi, raa_npjpsi, ptError_npjpsi, raaStat_npjpsi); TGraphAsymmErrors *pgRaaSyst_npjpsi = new TGraphAsymmErrors(4, ptBins_npjpsi, raa_npjpsi, ptSystXlow_npjpsi,ptSystXhigh_npjpsi,raaSyst_npjpsi,raaSyst_npjpsi); pgRaa_npjpsi->SetName("pgRaa_npjpsi"); pgRaa_npjpsi->SetMarkerStyle(29); pgRaa_npjpsi->SetMarkerSize(1.2); pgRaa_npjpsi->SetMarkerColor(kRed); //systm error pgRaaSyst_npjpsi->SetName("pgRaaSyst_npjpsi"); // pgRaaSyst_npjpsi->SetFillColor(TColor::GetColor("#ee7711")); pgRaaSyst_npjpsi->SetFillColor(TColor::GetColor("#ba8a98")); //--------------------------------------------------------- // lumi uncert. TBox *box = new TBox(0.9,0.9568966,2,1.043103); box->SetFillColor(kGray+1); box->SetFillStyle(1001); TBox *box_lin = new TBox(0.9,0.9568966,10,1.043103); box_lin->SetFillColor(kGray+1); box_lin->SetFillStyle(1001); //------------------------ single pannel: TCanvas *pc = new TCanvas("pc","pc"); TH1 *phAxis = new TH1D("phAxis",";p_{T} (m_{T}) [GeV];R_{AA}",1,0.9,300); phAxis->GetYaxis()->CenterTitle(true); phAxis->SetMinimum(0.); phAxis->SetMaximum(2.5); gPad->SetLogx(); phAxis->Draw(""); // drawing order: // A) stat boxes: pgRaaSyst_photon->Draw("2"); pgRaaSyst_npjpsi->Draw("2"); pgRaaSyst_h->Draw("2"); pgRaaSyst_z->Draw("2"); pgRaaSyst_w->Draw("2"); pgRaaSyst_bjet->Draw("2"); pgRaaSyst_jet->Draw("2"); //nominal+stat // photon pgRaa_photon->Draw("P z"); pgRaa_z->Draw("P z"); pgRaa_w->Draw("P z"); pgRaa_h->Draw("P z"); pgRaa_npjpsi->Draw("P z"); pgRaa_bjet->Draw("P z"); pgRaa_jet->Draw("P z"); TLine *line = new TLine(0.9,1,300,1); line->SetLineStyle(7); line->Draw(); //box->Draw(); // // legends and writings: TLegend *leg = new TLegend(0.05,0.87,0.39,0.95,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.029); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(19); leg->SetFillStyle(0); // TLegendEntry *entry=leg->AddEntry("hEtSIEIECorrected","CMS PRELIMINARY",""); // entry->SetLineWidth(1); // entry=leg->AddEntry("hEtSIEIECorrected","PbPb #sqrt{s_{NN}} = 2.76 TeV",""); // entry=leg->AddEntry("hEtSIEIECorrected","",""); // entry=leg->AddEntry("hEtSIEIECorrected","#int L dt = 7-150 #mub^{-1}",""); TLegendEntry *entry=leg->AddEntry("hEtSIEIECorrected","CMS *PRELIMINARY PbPb #sqrt{s_{NN}} = 2.76 TeV #int L dt = 7-150 #mub^{-1}",""); entry->SetLineWidth(1); // TAA // TAA only TLegend *leg_taa = new TLegend(0.15,0.5,0.5,0.55,NULL,"brNDC"); leg_taa->SetBorderSize(0); leg_taa->SetTextFont(62); leg_taa->SetTextSize(0.028); leg_taa->SetLineColor(1); leg_taa->SetLineStyle(1); leg_taa->SetLineWidth(1); leg_taa->SetFillColor(19); leg_taa->SetFillStyle(0); TLegendEntry *entry_taa= leg_taa->AddEntry("general","T_{AA} uncertainty","f"); entry_taa->SetFillColor(kGray+1); entry_taa->SetFillStyle(1001); entry_taa->SetLineColor(0); entry_taa->SetLineWidth(1); entry_taa->SetMarkerStyle(21); entry_taa->SetMarkerSize(1); // EWQ legend TLegend *leg_ewq = new TLegend(0.14,0.79,0.6,0.89,NULL,"brNDC"); leg_ewq->SetBorderSize(0); leg_ewq->SetTextFont(62); leg_ewq->SetTextSize(0.028); leg_ewq->SetLineColor(1); leg_ewq->SetLineStyle(1); leg_ewq->SetLineWidth(1); leg_ewq->SetFillColor(19); leg_ewq->SetFillStyle(0); TLegendEntry *entry_ewq=leg_ewq->AddEntry("raaz","*Z (0-100%) |y| < 2","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ff8888")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(22); entry_ewq->SetMarkerSize(1.); entry_ewq=leg_ewq->AddEntry("raaw","W (0-100%) p_{T}^{#mu} > 25 GeV/c^{^{ }}, |#eta^{#mu}| < 2.1","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ff88ff")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(21); entry_ewq->SetMarkerSize(1.); entry_ewq=leg_ewq->AddEntry("raaphoton","Isolated photon (0-10%) |#eta| < 1.44","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ffff00")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(23); entry_ewq->SetMarkerSize(1); // b and h TLegend *leg_q = new TLegend(0.14,0.72,0.6,0.79,NULL,"brNDC"); leg_q->SetBorderSize(0); leg_q->SetTextFont(62); leg_q->SetTextSize(0.028); leg_q->SetLineColor(1); leg_q->SetLineStyle(1); leg_q->SetLineWidth(1); leg_q->SetFillColor(19); leg_q->SetFillStyle(0); TLegendEntry *entry_q=leg_q->AddEntry("raah","Charged particles (0-5%) |#eta| < 1","lpf"); entry_q->SetFillColor(TColor::GetColor("#33ccff")); entry_q->SetFillStyle(1001); entry_q->SetLineColor(1); entry_q->SetLineStyle(1); entry_q->SetLineWidth(1); entry_q->SetMarkerStyle(kFullCircle); entry_q->SetMarkerSize(1); entry_q=leg_q->AddEntry("raab","*B #rightarrow J/#psi (0-100%) |#eta| < 2.4","lpf"); entry_q->SetFillColor(TColor::GetColor("#ba8a98")); entry_q->SetFillStyle(1001); entry_q->SetLineColor(1); entry_q->SetLineStyle(1); entry_q->SetLineWidth(1); entry_q->SetMarkerStyle(29); entry_q->SetMarkerColor(kRed); entry_q->SetMarkerSize(1.2); //entry_q=leg_q->AddEntry("raabjpsi", "(via secondary J/#psi)",""); // jet legend TLegend *leg_jet = new TLegend(0.14,0.65,0.6,0.72,NULL,"brNDC"); leg_jet->SetBorderSize(0); leg_jet->SetTextFont(62); leg_jet->SetTextSize(0.028); leg_jet->SetLineColor(1); leg_jet->SetLineStyle(1); leg_jet->SetLineWidth(1); leg_jet->SetFillColor(19); leg_jet->SetFillStyle(0); TLegendEntry *entry_jet=leg_jet->AddEntry("raaq","*q/g-jet (0-5%) |#eta| < 2","lpf"); entry_jet->SetFillColor(TColor::GetColor("#00FF60")); entry_jet->SetFillStyle(1001); entry_jet->SetLineColor(1); entry_jet->SetLineStyle(1); entry_jet->SetLineWidth(1); entry_jet->SetMarkerStyle(22); entry_jet->SetMarkerSize(1); entry_jet=leg_jet->AddEntry("raaheavy","*b-jet (0-10%) |#eta| < 2","lpf"); entry_jet->SetFillColor(TColor::GetColor("#FFBF00")); entry_jet->SetFillStyle(1001); entry_jet->SetLineColor(1); entry_jet->SetLineStyle(1); entry_jet->SetLineWidth(1); entry_jet->SetMarkerStyle(21); entry_jet->SetMarkerColor(kRed); entry_jet->SetMarkerSize(1); leg->Draw(); //leg_taa->Draw(); leg_ewq->Draw(); leg_q->Draw(); leg_jet->Draw(); gPad->RedrawAxis(); // save the work // pc->SaveAs("raaZoo_cms_log.pdf"); // pc->SaveAs("raaZoo_cms_log.png"); //-------------------------------------------------------------------------------- //-------------------------- 2TPad //double sizeincrease = 1.2; TH1 *phAxis_single = new TH1D("phAxis_single",";p_{T} (m_{T}) [GeV];R_{AA}",1,0,105); phAxis_single->GetYaxis()->CenterTitle(true); //phAxis_single->GetXaxis()->CenterTitle(true); //double defaxissize = phAxis_single->GetYaxis()->GetTitleSize(); //double defaxislabel = phAxis_single->GetYaxis()->GetLabelSize(); //phAxis_single->GetYaxis()->SetTitleSize(defaxissize*sizeincrease); //phAxis_single->GetXaxis()->SetTitleSize(defaxissize*sizeincrease); //phAxis_single->GetYaxis()->SetLabelSize(defaxislabel*sizeincrease); //phAxis_single->GetXaxis()->SetLabelSize(defaxislabel*sizeincrease); //phAxis_single->GetYaxis()->SetNdivisions(310); //phAxis_single->GetXaxis()->SetNdivisions(310); //phAxis_single->GetYaxis()->SetTitleOffset(0.85); //phAxis_single->GetXaxis()->SetTitleOffset(0.85); phAxis_single->SetMinimum(0.); phAxis_single->SetMaximum(2.5); TH1 *phAxis_jet = new TH1D("phAxis_jet",";p_{T} [GeV];",1,75,300); //phAxis_jet->GetYaxis()->CenterTitle(true); //phAxis_jet->GetXaxis()->CenterTitle(true); //phAxis_jet->GetYaxis()->SetTitleSize(defaxissize*sizeincrease); //phAxis_jet->GetXaxis()->SetTitleSize(defaxissize*sizeincrease); //phAxis_jet->GetYaxis()->SetLabelSize(defaxislabel*sizeincrease); phAxis_jet->GetYaxis()->SetLabelColor(0); //phAxis_jet->GetXaxis()->SetLabelSize(defaxislabel*sizeincrease); //phAxis_jet->GetYaxis()->SetNdivisions(310); //phAxis_jet->GetXaxis()->SetNdivisions(310); //phAxis_jet->GetYaxis()->SetTitleOffset(0.85); //phAxis_jet->GetXaxis()->SetTitleOffset(0.85); phAxis_jet->SetMinimum(0.); phAxis_jet->SetMaximum(2.5); // redefine legends: // TAA only /*TLegend *leg2_taa = new TLegend(0.15,0.85,0.5,0.9,NULL,"brNDC"); leg2_taa->SetBorderSize(0); leg2_taa->SetTextFont(62); leg2_taa->SetTextSize(0.028); leg2_taa->SetLineColor(1); leg2_taa->SetLineStyle(1); leg2_taa->SetLineWidth(1); leg2_taa->SetFillColor(19); leg2_taa->SetFillStyle(0); TLegendEntry *entry2_taa= leg2_taa->AddEntry("general","T_{AA} uncertainty (0-5%)","f"); entry2_taa->SetFillColor(kGray+1); entry2_taa->SetFillStyle(1001); entry2_taa->SetLineColor(0); entry2_taa->SetLineWidth(1); entry2_taa->SetMarkerStyle(21); entry2_taa->SetMarkerSize(1);*/ TLegend *leg2 = new TLegend(0.04,0.81,0.34,0.93,NULL,"brNDC"); leg2->SetBorderSize(0); leg2->SetTextFont(62); leg2->SetTextSize(0.03); //leg2->SetLineColor(1); //leg2->SetLineStyle(1); //leg2->SetLineWidth(1); //leg2->SetFillColor(19); leg2->SetFillStyle(0); TLegendEntry *entry2=leg2->AddEntry("general","CMS *PRELIMINARY PbPb #sqrt{s_{NN}} = 2.76 TeV",""); entry2=leg2->AddEntry("general","#int L dt = 7-150 #mub^{-1}",""); // jet leg2end TLegend *leg2_jet = new TLegend(0.08,0.73,0.64,0.81,NULL,"brNDC"); leg2_jet->SetBorderSize(0); leg2_jet->SetTextFont(62); leg2_jet->SetTextSize(0.028); leg2_jet->SetLineColor(1); leg2_jet->SetLineStyle(1); leg2_jet->SetLineWidth(1); leg2_jet->SetFillColor(19); leg2_jet->SetFillStyle(0); TLegendEntry *entry2_jet=leg2_jet->AddEntry("raaq","*q/g-jet (0-5%) |#eta| < 2","lpf"); entry2_jet->SetFillColor(TColor::GetColor("#00FF60")); entry2_jet->SetFillStyle(1001); entry2_jet->SetLineColor(1); entry2_jet->SetLineStyle(1); entry2_jet->SetLineWidth(1); entry2_jet->SetMarkerStyle(22); entry2_jet->SetMarkerSize(mymarkersize); if(version > 5) { entry2_jet=leg2_jet->AddEntry("raaheavy","*b-jet (0-10%) |#eta| < 2","lpf"); entry2_jet->SetFillColor(TColor::GetColor("#FFBF00")); entry2_jet->SetFillStyle(1001); entry2_jet->SetLineColor(1); entry2_jet->SetLineStyle(1); entry2_jet->SetLineWidth(1); entry2_jet->SetMarkerStyle(21); entry2_jet->SetMarkerColor(kRed); entry2_jet->SetMarkerSize(mymarkersize); } else entry2_jet=leg2_jet->AddEntry("raaheavy","",""); // EWQ legend TLegend *leg2_ewq = new TLegend(0.14,0.81,0.7,0.93,NULL,"brNDC"); leg2_ewq->SetBorderSize(0); leg2_ewq->SetTextFont(62); leg2_ewq->SetTextSize(0.028); leg2_ewq->SetLineColor(1); leg2_ewq->SetLineStyle(1); leg2_ewq->SetLineWidth(1); leg2_ewq->SetFillColor(19); leg2_ewq->SetFillStyle(0); TLegendEntry *entry2_ewq; if(version > 1) { entry2_ewq=leg2_ewq->AddEntry("raaz","*Z (0-100%) |y| < 2","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ff8888")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(22); entry2_ewq->SetMarkerSize(mymarkersize); } else entry2_ewq=leg2_ewq->AddEntry("raaz","",""); if(version > 2) { entry2_ewq=leg2_ewq->AddEntry("raaw","W (0-100%) p_{T}^{#mu} > 25 GeV/c^{^{ }}, |#eta^{#mu}| < 2.1","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ff88ff")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(21); entry2_ewq->SetMarkerSize(mymarkersize); } else entry2_ewq=leg2_ewq->AddEntry("raaw","",""); if(version > 0) { entry2_ewq=leg2_ewq->AddEntry("raaphoton","Isolated photon (0-10%) |#eta| < 1.44","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ffff00")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(23); entry2_ewq->SetMarkerSize(mymarkersize); } else entry2_ewq=leg2_ewq->AddEntry("raaphoton","",""); // B and h TLegend *leg2_q = new TLegend(0.14,0.74,0.7,0.81,NULL,"brNDC"); leg2_q->SetBorderSize(0); leg2_q->SetTextFont(62); leg2_q->SetTextSize(0.028); leg2_q->SetLineColor(1); leg2_q->SetLineStyle(1); leg2_q->SetLineWidth(1); leg2_q->SetFillColor(19); leg2_q->SetFillStyle(0); TLegendEntry *entry2_q; if(version > 3) { entry2_q=leg2_q->AddEntry("raah","Charged particles (0-5%) |#eta| < 1","lpf"); entry2_q->SetFillColor(TColor::GetColor("#33ccff")); entry2_q->SetFillStyle(1001); entry2_q->SetLineColor(1); entry2_q->SetLineStyle(1); entry2_q->SetLineWidth(1); entry2_q->SetMarkerStyle(kFullCircle); entry2_q->SetMarkerSize(mymarkersize); } else entry2_q=leg2_q->AddEntry("raah","",""); if(version > 5) { entry2_q=leg2_q->AddEntry("raab","*B #rightarrow J/#psi (0-100%) |y| < 2.4","lpf"); // entry2_q->SetFillColor(TColor::GetColor("#ee7711")); entry2_q->SetFillColor(TColor::GetColor("#ba8a98")); entry2_q->SetFillStyle(1001); entry2_q->SetLineColor(1); entry2_q->SetLineStyle(1); entry2_q->SetLineWidth(1); entry2_q->SetMarkerStyle(29); entry2_q->SetMarkerColor(kRed); entry2_q->SetMarkerSize(mymarkersize); //entry2_q=leg2_q->AddEntry("raabjpsi", "(via secondary J/#psi)",""); } else { entry2_q=leg2_q->AddEntry("raab","",""); entry2_q=leg2_q->AddEntry("raab","",""); } if(bDo2PadZoo) { TCanvas *pc2 = new TCanvas("pc2","pc2",1200,600); TPad *p_0 = new TPad("p_0","p_0",0,0,0.50,1); p_0->Draw(); p_0->cd(); p_0->SetRightMargin(0.03); phAxis_single->Draw(""); //box_lin->Draw(); pgRaa_photon->SetMarkerSize(mymarkersize); pgRaa_z->SetMarkerSize(mymarkersize); pgRaa_h->SetMarkerSize(mymarkersize); pgRaa_w->SetMarkerSize(mymarkersize); pgRaa_npjpsi->SetMarkerSize(mymarkersize); pgRaa_bjet->SetMarkerSize(mymarkersize); pgRaa_jet->SetMarkerSize(mymarkersize); if(version > 0) pgRaaSyst_photon->Draw("2"); if(version > 1) pgRaaSyst_z->Draw("2"); if(version > 3) pgRaaSyst_h->Draw("2"); if(version > 2) pgRaaSyst_w->Draw("2"); if(version > 5) pgRaaSyst_npjpsi->Draw("2"); if(version > 0) pgRaa_photon->Draw("P z"); if(version > 1) pgRaa_z->Draw("P z"); if(version > 3) pgRaa_h->Draw("P z"); if(version > 2) pgRaa_w->Draw("P z"); if(version > 5) pgRaa_npjpsi->Draw("P z"); TLine *line_single = new TLine(0,1,105,1); line_single->SetLineStyle(7); line_single->Draw(); // legends //leg2_taa->Draw(); leg2_q->Draw(); leg2_ewq->Draw(); TLine * midborder = new TLine(99.9,0,99.9,2); midborder->SetLineStyle(1); //if(version < 5) midborder->Draw(); pc2->cd(); // midborder->Draw(); if(version > 4) { // jet pad TPad *p_1 = new TPad("p_1","p_1",0.50,0,1,1); p_1->Draw(); p_1->cd(); p_1->SetLeftMargin(0.06); p_1->SetTickx(1); p_1->SetTicky(1); if(version > 4) phAxis_jet->Draw(""); if(version > 5) pgRaaSyst_bjet->Draw("2"); if(version > 4) pgRaaSyst_jet->Draw("2"); if(version > 5) pgRaa_bjet->Draw("P z"); if(version > 4) pgRaa_jet->Draw("P z"); TLine *line_jet = new TLine(75,1,300,1); line_jet->SetLineStyle(7); line_jet->Draw(); leg2->Draw(); leg2_jet->Draw(); } p_0->cd(); gPad->RedrawAxis(); //! adds the latex "100" joining the two pads //pc2->cd(); //TPad * blankpad = new TPad("b", "b",0.48,0.07,0.52,0.11); //blankpad->SetBorderMode(0); //blankpad->Draw(); //blankpad->cd(); //TLatex * test = new TLatex( 0.102843, 0.122822, Form("100")); //test->SetTextSize(test->GetTextSize()*26.0*sizeincrease); //test->Draw("same"); //blankpad->Update(); // pc2->SaveAs(Form("raaZoo_cms_2pads_%d.pdf",version)); //pc2->SaveAs(Form("raaZoo_cms_2pads_%d.png",version)); } }
void showEfficiency(const TString& title, double canvasSizeX, double canvasSizeY, const TH1* histogram1_numerator, const TH1* histogram1_denominator, const std::string& legendEntry1, const TH1* histogram2_numerator, const TH1* histogram2_denominator, const std::string& legendEntry2, const TH1* histogram3_numerator, const TH1* histogram3_denominator, const std::string& legendEntry3, const TH1* histogram4_numerator, const TH1* histogram4_denominator, const std::string& legendEntry4, const TH1* histogram5_numerator, const TH1* histogram5_denominator, const std::string& legendEntry5, const TH1* histogram6_numerator, const TH1* histogram6_denominator, const std::string& legendEntry6, 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) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); canvas->SetLogy(useLogScale); canvas->SetGridx(); canvas->SetGridy(); TH1* dummyHistogram = new TH1D("dummyHistogram_top", "dummyHistogram_top", 10, histogram1_numerator->GetXaxis()->GetXmin(), histogram1_numerator->GetXaxis()->GetXmax()); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMaximum(yMax); dummyHistogram->SetMinimum(yMin); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw(); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; int numGraphs = 1; if ( histogram2_numerator && histogram2_denominator ) ++numGraphs; if ( histogram3_numerator && histogram3_denominator ) ++numGraphs; if ( histogram4_numerator && histogram4_denominator ) ++numGraphs; if ( histogram5_numerator && histogram5_denominator ) ++numGraphs; if ( histogram6_numerator && histogram6_denominator ) ++numGraphs; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.18, legendY0 + 0.05*numGraphs, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); TGraphAsymmErrors* graph1 = getEfficiency(histogram1_numerator, histogram1_denominator); graph1->SetLineColor(colors[0]); graph1->SetMarkerColor(colors[0]); graph1->SetMarkerStyle(markerStyles[0]); graph1->Draw("p"); legend->AddEntry(graph1, legendEntry1.data(), "p"); TGraphAsymmErrors* graph2 = 0; if ( histogram2_numerator && histogram2_denominator ) { graph2 = getEfficiency(histogram2_numerator, histogram2_denominator); graph2->SetLineColor(colors[1]); graph2->SetMarkerColor(colors[1]); graph2->SetMarkerStyle(markerStyles[1]); graph2->Draw("p"); legend->AddEntry(graph2, legendEntry2.data(), "p"); } TGraphAsymmErrors* graph3 = 0; if ( histogram3_numerator && histogram3_denominator ) { graph3 = getEfficiency(histogram3_numerator, histogram3_denominator); graph3->SetLineColor(colors[2]); graph3->SetMarkerColor(colors[2]); graph3->SetMarkerStyle(markerStyles[2]); graph3->Draw("p"); legend->AddEntry(graph3, legendEntry3.data(), "p"); } TGraphAsymmErrors* graph4 = 0; if ( histogram4_numerator && histogram4_denominator ) { graph4 = getEfficiency(histogram4_numerator, histogram4_denominator); graph4->SetLineColor(colors[3]); graph4->SetMarkerColor(colors[3]); graph4->SetMarkerStyle(markerStyles[3]); graph4->Draw("p"); legend->AddEntry(graph4, legendEntry4.data(), "p"); } TGraphAsymmErrors* graph5 = 0; if ( histogram5_numerator && histogram5_denominator ) { graph5 = getEfficiency(histogram5_numerator, histogram5_denominator); graph5->SetLineColor(colors[4]); graph5->SetMarkerColor(colors[4]); graph5->SetMarkerStyle(markerStyles[4]); graph5->Draw("p"); legend->AddEntry(graph5, legendEntry5.data(), "p"); } TGraphAsymmErrors* graph6 = 0; if ( histogram6_numerator && histogram6_denominator ) { graph6 = getEfficiency(histogram6_numerator, histogram6_denominator); graph6->SetLineColor(colors[5]); graph6->SetMarkerColor(colors[5]); graph6->SetMarkerStyle(markerStyles[5]); graph6->Draw("p"); legend->AddEntry(graph6, legendEntry6.data(), "p"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); 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()); delete legend; delete label; delete dummyHistogram; delete canvas; }
/** * Extract ALICE PbPb @ 5.02TeV over |eta|<2 * * @param filename Input file name * @param outname Output file name * @param reweigh Whether it is reweighed */ void Extract(const char* filename="dndneta.pbpb502.20151124.root", const char* outname="TRACKLETS_5023_PbPb.input", Bool_t reweigh=false) { if (filename == 0) return; TFile* file = TFile::Open(filename, "READ"); TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray")); // Now count number of bins Int_t nBins = 0; TIter next(arr); TObject* obj = 0; while ((obj = next())) { if (TString(obj->GetName()).Contains("DataCorrSignal")) nBins++; } Info("ExtractdNdeta", "Defining %d centrality bins", nBins); TArrayD c(nBins+1); if (nBins == 5) { c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80; } else if (nBins >= 9) { c[0] = 0; c[1] = 5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40; c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80; if (nBins >= 10) c[10] = 90; if (nBins >= 11) c[11] = 100; } THStack* all = new THStack("all","all"); std::ofstream out(outname); std::ostream& o = out; // std::cout; // std::ostream& o = std::cout; o << "*author: SHAHOYAN : 2015\n" << "*title: Full centrality dependence of the charged " << "particle pseudo-rapidity density over the widest " << "possible pseudo-rapidity range in Pb-Pb collisions " << "at 5.02 TeV\n" << "*detector: TRACKLETS\n" << "*experiment: CERN-LHC-TRACKLETS\n" << "*comment: CERN-LHC: We present the charged particle pseudo-rapidity " << "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon " "= 5.02 over the widest possible pseudo-rapidity and centrality range " << "possible.\n" << std::endl; for (Int_t i = 0; i < nBins; i++) { TString hName = Form("bin%d_DataCorrSignal_PbPb",i); TH1* h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { hName.ReplaceAll("PbPb", "PBPB"); h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i); arr->Print(); continue; } } Color_t col = PbPbColor(c[i], c[i+1]); h->SetLineColor(col); h->SetMarkerColor(col); h->SetFillColor(col); all->Add(h); Info("","Making GSE for %0d%% to %3d%% (%d)", Int_t(c[i]), Int_t(c[i+1]), col); MakeGSE(o, h, c[i], c[i+1], reweigh); } // all->Draw("nostack"); o << "*E" << std::endl; out.close(); TCanvas* can = new TCanvas("c","C", 1600, 800); can->SetRightMargin(0.2); can->SetTopMargin(0.01); TLegend* cl = new TLegend(1-can->GetRightMargin(), can->GetBottomMargin(),.99, 1-can->GetTopMargin()); cl->SetFillStyle(0); cl->SetBorderSize(0); gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+"); TList* ll = GraphSysErr::Import(outname); // ll->ls(); TIter next(ll); TObject* obj = 0; Bool_t first = true; TH1* frame = 0; Double_t min=100000, max=0; Int_t i = 0; while ((obj = next())) { if (c[i+1] > 80) break; GraphSysErr* g = static_cast<GraphSysErr*>(obj); Color_t col = PbPbColor(c[i], c[i+1]); TLegendEntry* e = cl->AddEntry("", Form("%4.1f-%4.1f%%", c[i], c[i+1]), "F"); e->SetFillColor(col); e->SetFillStyle(1001); g->SetLineColor(col); g->SetMarkerColor(col); g->SetFillColor(col); // g->Print("qual"); g->SetDataOption(GraphSysErr::kNoTick); g->SetSumOption(GraphSysErr::kBox); g->SetSumLineColor(col); g->SetSumFillColor(col); g->SetCommonSumOption(GraphSysErr::kBox); g->SetCommonSumLineColor(col); g->SetCommonSumFillColor(col); g->SetName(Form("tracklets%03dd%02d_%03dd%02d", Int_t(c[i]), Int_t(c[i]*100) % 100, Int_t(c[i+1]), Int_t(c[i+1]*100) % 100)); g->SetTitle(Form("%4.1f - %4.1f%%", c[i], c[i+1])); if (first) g->Draw("combine stat quad axis xbase=2.5"); else g->Draw("combine stat quad xbase=2.5"); if (!frame) frame = g->GetMulti()->GetHistogram(); first = false; Double_t mn, mx; g->GetMinMax("combine stat quad", mn, mx); FindLeastLargest(g, c[i], c[i+1]); min = TMath::Min(min, mn); max = TMath::Max(max, mx); i++; } frame->SetMinimum(min*.9); frame->SetMaximum(max*1.1); cl->Draw(); TFile* outFile = TFile::Open(Form("PbPb5023midRapidity%s.root", reweigh ? "Reweighed" : "Normal"), "RECREATE"); ll->Write("container",TObject::kSingleKey); outFile->Write(); can->SaveAs(Form("PbPb5023midRapidity%s.png", reweigh ? "Reweighed" : "Normal")); }
void showGraphs(const TString& title, double canvasSizeX, double canvasSizeY, TGraph* graph1, const std::string& legendEntry1, TGraph* graph2, const std::string& legendEntry2, TGraph* graph3, const std::string& legendEntry3, TGraph* graph4, const std::string& legendEntry4, TGraph* graph5, const std::string& legendEntry5, TGraph* graph6, const std::string& legendEntry6, double xMin, double xMax, unsigned numBinsX, const std::string& xAxisTitle, double xAxisOffset, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", numBinsX, xMin, xMax); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw("axis"); graph1->SetLineColor(colors[0]); graph1->SetLineWidth(2); graph1->Draw("L"); legend->AddEntry(graph1, legendEntry1.data(), "l"); if ( graph2 ) { graph2->SetLineColor(colors[1]); graph2->SetLineWidth(2); graph2->Draw("L"); legend->AddEntry(graph2, legendEntry2.data(), "l"); } if ( graph3 ) { graph3->SetLineColor(colors[2]); graph3->SetLineWidth(2); graph3->Draw("L"); legend->AddEntry(graph3, legendEntry3.data(), "l"); } if ( graph4 ) { graph4->SetLineColor(colors[3]); graph4->SetLineWidth(2); graph4->Draw("L"); legend->AddEntry(graph4, legendEntry4.data(), "l"); } if ( graph5 ) { graph5->SetLineColor(colors[4]); graph5->SetLineWidth(2); graph5->Draw("L"); legend->AddEntry(graph5, legendEntry5.data(), "l"); } if ( graph6 ) { graph6->SetLineColor(colors[5]); graph6->SetLineWidth(2); graph6->Draw("L"); legend->AddEntry(graph6, legendEntry6.data(), "l"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); 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()); delete legend; delete label; delete dummyHistogram; delete canvas; }
CompareSpectra(Int_t part, Int_t charge, Int_t cent = -1, Int_t ratio = kFALSE, Int_t fitfunc = -1, Bool_t cutSpectra = kTRUE) { gROOT->LoadMacro("HistoUtils.C"); gStyle->SetOptStat(0); gStyle->SetOptFit(); LoadLibraries(); AliBWFunc bwf; bwf.SetVarType(AliBWFunc::kdNdpt); TF1 *fFitFunc = NULL; switch (fitfunc) { case 0: gROOT->LoadMacro("SpectraAnalysis.C"); fFitFunc = STAR_BlastWave("fBW", AliPID::ParticleMass(part), 0.9, 0.1, 1.); fBW->SetParLimits(3, 0.5, 1.5); // fBW->FixParameter(3, 1.); break; case 1: fFitFunc = bwf.GetLevi(AliPID::ParticleMass(part), AliPID::ParticleMass(part), 5., 1000.); break; case 2: fFitFunc = bwf.GetBoltzmann(AliPID::ParticleMass(part), AliPID::ParticleMass(part), 100.); break; case 3: fFitFunc = bwf.GetMTExp(AliPID::ParticleMass(part),AliPID::ParticleMass(part) , 100.); break; case 4: fFitFunc = bwf.GetPTExp(AliPID::ParticleMass(part), 100.); break; case 5: fFitFunc = bwf.GetBGBW(AliPID::ParticleMass(part), 0.5, 0.1, 1.e6); break; case 6: fFitFunc = new TF1("fpol9", "pol9", 0., 5.0); break; } if (fFitFunc) fFitFunc->SetLineWidth(2); TFile *itssafile = TFile::Open(ratio ? itssaratiofilename : itssafilename); // TFile *itstpcfile = TFile::Open(itstpcfilename); if (part / 3 == charge / 3) Char_t *tpctofratiofilename = tpctofratiofilenameA; else Char_t *tpctofratiofilename = tpctofratiofilenameB; TFile *tpctoffile = TFile::Open(ratio ? tpctofratiofilename : tpctoffilename); TFile *toffile = TFile::Open(ratio ? tofratiofilename : toffilename); // TFile *hydrofile = TFile::Open(hydrofilename); TCanvas *cCanvas = new TCanvas("cCanvas"); if (cent == -1) cCanvas->Divide(5, 2); TCanvas *cCanvasCombined = new TCanvas("cCanvasCombined"); TCanvas *cCanvasRatio = new TCanvas("cCanvasRatio"); if (cent == -1) cCanvasRatio->Divide(5, 2); TCanvas *cCanvasRatioComb = new TCanvas("cCanvasRatioComb"); if (cent == -1) cCanvasRatioComb->Divide(5, 2); TCanvas *cCanvasRatioFit = new TCanvas("cCanvasRatioFit"); if (cent == -1) cCanvasRatioFit->Divide(5, 2); TPad *curpad = NULL; TH1D *hITSsa, *hITSTPC, *hTPCTOF, *hTOF; TGraph *hHydro; TGraphErrors *gCombined[10]; TProfile *pCombined[10]; TH1D *hCombined[10]; TH1D *hRatio_ITSsa_ITSTPC[10]; TH1D *hRatio_ITSsa_TPCTOF[10]; TH1D *hRatio_ITSTPC_TPCTOF[10]; TH1D *hRatio_ITSTPC_TOF[10]; TH1D *hRatio_TPCTOF_TOF[10]; TH1D *hRatio_ITSsa_TOF[10]; for (Int_t icent = 0; icent < 10; icent++) { if (cent != -1 && icent != cent) continue; gCombined[icent] = new TGraphErrors(); pCombined[icent] = new TProfile(Form("pCombined_cent%d", icent), "", NptBins, ptBin); hCombined[icent] = new TH1D(Form("hCombined_cent%d", icent), "", NptBins, ptBin); TObjArray spectraArray; hITSsa = ratio ? GetITSsaRatio(itssafile, part, charge, icent, cutSpectra): GetITSsaSpectrum(itssafile, part, charge, icent, cutSpectra); // hITSTPC = GetITSTPCSpectrum(itstpcfile, part, charge, icent, cutSpectra); hTPCTOF = ratio ? GetTPCTOFRatio(tpctoffile, part, charge, icent, cutSpectra) : GetTPCTOFSpectrum(tpctoffile, part, charge, icent, cutSpectra); hTOF = ratio ? GetTOFRatio(toffile, part, charge, icent, cutSpectra) : GetTOFSpectrum(toffile, part, charge, icent, cutSpectra); // hHydro = GetHydroSpectrum(hydrofile, part, charge, icent); if (cent == -1) curpad = (TPad *)cCanvas->cd(icent + 1); else curpad = (TPad *)cCanvas->cd(); if (!ratio) TH1D *hArea = new TH1D(Form("hArea_%d", icent), Form("%s (%s);p_{T} (GeV/c);#frac{d^{2}N}{dy dp_{t}};", partChargeName[part][charge], centName[icent]), 100, 0., 5.); else TH1D *hArea = new TH1D(Form("hArea_%d", icent), Form("%s (%s);p_{T} (GeV/c);#frac{d^{2}N}{dy dp_{t}};", "generic ratio", centName[icent]), 100, 0., 5.); hArea->Draw(); Double_t minimum = 0.001; Double_t maximum = 1000.; if (hITSsa) { AddPointsToGraph(hITSsa, gCombined[icent]); AddPointsToProfile(hITSsa, pCombined[icent]); spectraArray.Add(hITSsa); hITSsa->DrawCopy("same"); if (hITSsa->GetMaximum() > maximum) maximum = hITSsa->GetMaximum(); if (hITSsa->GetMinimum() < minimum) minimum = hITSsa->GetMinimum(); } if (hITSTPC) { AddPointsToGraph(hITSTPC, gCombined[icent]); AddPointsToProfile(hITSTPC, pCombined[icent]); spectraArray.Add(hITSTPC); hITSTPC->DrawCopy("same"); if (hITSTPC->GetMaximum() > maximum) maximum = hITSTPC->GetMaximum(); if (hITSTPC->GetMinimum() < minimum) minimum = hITSTPC->GetMinimum(); } if (hTPCTOF) { AddPointsToGraph(hTPCTOF, gCombined[icent]); AddPointsToProfile(hTPCTOF, pCombined[icent]); spectraArray.Add(hTPCTOF); hTPCTOF->DrawCopy("same"); if (hTPCTOF->GetMaximum() > maximum) maximum = hTPCTOF->GetMaximum(); if (hTPCTOF->GetMinimum() < minimum) minimum = hTPCTOF->GetMinimum(); } if (hTOF) { AddPointsToGraph(hTOF, gCombined[icent]); AddPointsToProfile(hTOF, pCombined[icent]); spectraArray.Add(hTOF); hTOF->DrawCopy("same"); if (hTOF->GetMaximum() > maximum) maximum = hTOF->GetMaximum(); if (hTOF->GetMinimum() < minimum) minimum = hTOF->GetMinimum(); } if (hHydro) { ;//hHydro->Draw("c,same"); } TLegend *legend = curpad->BuildLegend(); legend->SetFillStyle(0); legend->SetFillColor(0); legend->DeleteEntry(); hArea->SetMaximum(maximum * 1.1); hArea->SetMinimum(0.01); // gPad->SetLogy(); /*** RATIOS ***/ /* switch canvas */ if (cent == -1) curpad = (TPad *)cCanvasRatio->cd(icent + 1); else curpad = (TPad *)cCanvasRatio->cd(); /* area histo */ if (!ratio) TH1D *hAreaRatio = new TH1D(Form("hAreaRatio_%d", icent), Form("%s (%s);p_{T} (GeV/c);ratio;", partChargeName[part][charge], centName[icent]), 100, 0., 5.); else TH1D *hAreaRatio = new TH1D(Form("hAreaRatio_%d", icent), Form("%s (%s);p_{T} (GeV/c);ratio;", "generic ratio", centName[icent]), 100, 0., 5.); hAreaRatio->SetMaximum(1.5); hAreaRatio->SetMinimum(0.5); hAreaRatio->Draw(); /* do ratios */ if (hITSsa && hITSTPC) { hRatio_ITSsa_ITSTPC[icent] = new TH1D(*hITSsa); hRatio_ITSsa_ITSTPC[icent]->Divide(hITSTPC); hRatio_ITSsa_ITSTPC[icent]->SetNameTitle(Form("hRatio_ITSsa_ITSTPC_cent%d", icent), "ITSsa / ITSTPC"); hRatio_ITSsa_ITSTPC[icent]->Draw("same"); } if (hITSsa && hTPCTOF) { hRatio_ITSsa_TPCTOF[icent] = new TH1D(*hITSsa); hRatio_ITSsa_TPCTOF[icent]->Divide(hTPCTOF); hRatio_ITSsa_TPCTOF[icent]->SetNameTitle(Form("hRatio_ITSsa_TPCTOF_cent%d", icent), "ITSsa / TPCTOF"); hRatio_ITSsa_TPCTOF[icent]->SetMarkerStyle(23); hRatio_ITSsa_TPCTOF[icent]->SetMarkerColor(4); hRatio_ITSsa_TPCTOF[icent]->Draw("same"); } if (hITSTPC && hTPCTOF) { hRatio_ITSTPC_TPCTOF[icent] = new TH1D(*hITSTPC); hRatio_ITSTPC_TPCTOF[icent]->Divide(hTPCTOF); hRatio_ITSTPC_TPCTOF[icent]->SetNameTitle(Form("hRatio_ITSTPC_TPCTOF_cent%d", icent), "ITSTPC / TPCTOF"); hRatio_ITSTPC_TPCTOF[icent]->Draw("same"); } if (hTPCTOF && hTOF) { hRatio_TPCTOF_TOF[icent] = new TH1D(*hTPCTOF); hRatio_TPCTOF_TOF[icent]->Divide(hTOF); hRatio_TPCTOF_TOF[icent]->SetNameTitle(Form("hRatio_TPCTOF_TOF_cent%d", icent), "TPCTOF / TOF"); hRatio_TPCTOF_TOF[icent]->Draw("same"); } if (hITSsa && hTOF) { hRatio_ITSsa_TOF[icent] = new TH1D(*hITSsa); hRatio_ITSsa_TOF[icent]->Divide(hTOF); hRatio_ITSsa_TOF[icent]->SetNameTitle(Form("hRatio_ITSsa_TOF_cent%d", icent), "ITSsa / TOF"); // hRatio_ITSsa_TOF[icent]->SetMarkerStyle(25); // hRatio_ITSsa_TOF[icent]->SetMarkerColor(2); hRatio_ITSsa_TOF[icent]->Draw("same"); } /* legend */ TLegend *legendRatio = curpad->BuildLegend(); legendRatio->SetFillStyle(0); legendRatio->SetFillColor(0); legendRatio->DeleteEntry(); CombineSpectra(hCombined[icent], &spectraArray); hCombined[icent]->SetFillStyle(0); hCombined[icent]->SetFillColor(kOrange + 1); hCombined[icent]->SetMarkerColor(kOrange+1); hCombined[icent]->SetMarkerStyle(24); hCombined[icent]->SetLineColor(kOrange+1); hCombined[icent]->SetLineWidth(2); hCombined[icent]->SetMarkerSize(0); // hCombined[icent]->DrawCopy("same,E2"); // pCombined[icent]->DrawCopy("same"); if (cent == -1) cCanvas->cd(icent + 1); else cCanvas->cd(); // hCombined[icent]->Draw("same, E2"); cCanvasCombined->cd(); if (cent == -1 && icent != 0) hCombined[icent]->Draw("E2,same"); else hCombined[icent]->Draw("E2"); // cCanvasCombined->DrawClonePad(); if (hITSsa) { hITSsa->DrawCopy("same"); } if (hITSTPC) { hITSTPC->DrawCopy("same"); } if (hTPCTOF) { hTPCTOF->DrawCopy("same"); } if (hTOF) { hTOF->DrawCopy("same"); } if (hHydro) { ;//hHydro->Draw("c,same"); } if (cent == -1) cCanvasRatioComb->cd(icent + 1); else cCanvasRatioComb->cd(); // hCombined[icent]->Draw("same, E2"); TH1 *hhr = HistoUtils_smartratio(hCombined[icent], hCombined[icent]); hhr->SetMaximum(1.25); hhr->SetMinimum(0.75); hhr->SetFillStyle(3001); hhr->SetTitle("combined error;p_{T} (GeV/c);ratio wrt. combined"); hhr->Draw("e2"); if (hITSsa) { hhr = HistoUtils_smartratio(hITSsa, hCombined[icent]); hhr->SetLineColor(1); hhr->SetLineWidth(2); hhr->Draw("e2,same"); } if (hITSTPC) { hhr = HistoUtils_smartratio(hITSTPC, hCombined[icent]); hhr->SetLineColor(1); hhr->SetLineWidth(2); hhr->Draw("e2,same"); } if (hTPCTOF) { hhr = HistoUtils_smartratio(hTPCTOF, hCombined[icent]); hhr->SetLineColor(8); hhr->SetLineWidth(2); hhr->Draw("e2,same"); } if (hTOF) { hhr = HistoUtils_smartratio(hTOF, hCombined[icent]); hhr->SetLineColor(4); hhr->SetLineWidth(2); hhr->Draw("e2,same"); } if (hHydro) { ;//hHydro->Draw("c,same"); } if (!fFitFunc) continue; // gCombined[icent]->Draw("p*"); // gCombined[icent]->Fit(fFitFunc, "0q", "", 0.5, 1.0); // gCombined[icent]->Fit(fFitFunc, "0q", "", 0.2, 1.5); hCombined[icent]->Fit(fFitFunc, "0q", "", 0., 5.); fFitFunc->DrawCopy("same"); printf("cent = %d, dNdy = %f +- %f\n", icent, fFitFunc->GetParameter(0), fFitFunc->GetParError(0)); if (cent == -1) cCanvas->cd(icent + 1); else cCanvas->cd(); fFitFunc->DrawCopy("same"); if (cent == -1) cCanvasRatioFit->cd(icent + 1); else cCanvasRatioFit->cd(); if (!ratio) TH1D *hAreaRatioFit = new TH1D(Form("hAreaRatioFit_%d", icent), Form("%s (%s);p_{T} (GeV/c);ratio wrt. fit;", partChargeName[part][charge], centName[icent]), 100, 0., 5.); else TH1D *hAreaRatioFit = new TH1D(Form("hAreaRatioFit_%d", icent), Form("%s (%s);p_{T} (GeV/c);ratio wrt. fit;", "generic ratio", centName[icent]), 100, 0., 5.); hAreaRatioFit->SetMaximum(1.5); hAreaRatioFit->SetMinimum(0.5); hAreaRatioFit->Draw(); legend->Draw("same"); if (hITSsa) { hITSsa->Divide(fFitFunc); hITSsa->DrawCopy("same"); } if (hITSTPC) { hITSTPC->Divide(fFitFunc); hITSTPC->DrawCopy("same"); } if (hTPCTOF) { hTPCTOF->Divide(fFitFunc); hTPCTOF->DrawCopy("same"); } if (hTOF) { hTOF->Divide(fFitFunc); hTOF->DrawCopy("same"); } } }
void cmsRAA() { bool bDo2PadZoo = false; //----------------------------------------- charged hadrons double ptBins_h[27]={0}; double ptError_h[27]={0}; double raa_h[27]; double raaStat_h[27]; double raaSyst_h[27]; double ptSystXlow_h[27]; double ptSystXhigh_h[27]; // reading numbers ifstream inData_h; TString inFile("raa_h05.dat"); inData_h.open(inFile); if(inData_h.fail()) { cerr << "unable to open file raa_h05.dat for reading" << endl; exit(1); } Int_t j=0; Double_t xx_low, xx_high,raa,raa_syst, raa_stat; while(!inData_h.eof()) { inData_h >> xx_low >> xx_high >> raa >> raa_syst >> raa_stat; ptBins_h[j] = xx_low+ (xx_high-xx_low)/2; raa_h[j] = raa; raaStat_h[j] = raa_syst; raaSyst_h[j] = raa_stat; ptSystXlow_h[j] = (xx_high-xx_low)/2; ptSystXhigh_h[j]= (xx_high-xx_low)/2; // cout<<"pT"<<ptBins_h[j]<<"\t raa= "<<raa_h[j]<<"\t syst= "<<raaStat_h[j]<<"\t stat ="<<raaSyst_h[j]<<"\t x_low= "<<ptSystXlow_h[j]<<"\t high= "<<ptSystXhigh_h[j]<<endl; j++; } inData_h.close(); // done reading numebrs TGraphErrors *pgRaa_h = new TGraphErrors(27, ptBins_h, raa_h, ptError_h, raaStat_h); TGraphAsymmErrors *pgRaaSyst_h = new TGraphAsymmErrors(27, ptBins_h, raa_h, ptSystXlow_h,ptSystXhigh_h,raaSyst_h,raaSyst_h); pgRaa_h->SetName("pgRaa_h"); pgRaa_h->SetMarkerStyle(24); pgRaa_h->SetMarkerSize(1.); //systm error pgRaaSyst_h->SetName("pgRaaSyst_h"); pgRaaSyst_h->SetFillColor(TColor::GetColor("#33ccff")); //----------------------------------------- jet RAA double ptBins_jet[] = {105,115,125,135,145,155,165,175,190,220,270}; double ptError_jet[] = {0.0, 0.0, 0.0, 0.0, 0.0,0,0,0,0,0,0}; double raa_jet[] = {0.47, 0.47, 0.46, 0.44, 0.43, 0.47, 0.52, 0.51, 0.44, 0.42, 0.58}; double raaStat_jet[] = {0.0076, 0.0098, 0.013, 0.016, 0.021, 0.028, 0.038, 0.045, 0.035, 0.039, 0.098}; double raaSyst_jet[] = {0.07, 0.07, 0.08, 0.09, 0.08, 0.08, 0.08, 0.08, 0.07, 0.07, 0.10 }; double ptSystXlow_jet[] = {5, 5, 5, 5, 5,5,5,5,10,20,30}; double ptSystXhigh_jet[] = {5, 5, 5, 5, 5,5,5,5,10,20,30}; TGraphErrors *pgRaa_jet = new TGraphErrors(11, ptBins_jet, raa_jet, ptError_jet, raaStat_jet); TGraphAsymmErrors *pgRaaSyst_jet = new TGraphAsymmErrors(11, ptBins_jet, raa_jet, ptSystXlow_jet,ptSystXhigh_jet,raaSyst_jet,raaSyst_jet); pgRaa_jet->SetName("pgRaa_jet"); pgRaa_jet->SetMarkerStyle(20); pgRaa_jet->SetMarkerSize(1.); //systm error pgRaaSyst_jet->SetName("pgRaaSyst_jet"); pgRaaSyst_jet->SetFillColor(TColor::GetColor("#00FFFF")); //----------------------------------------- b-jet RAA double ptBins_bjet[] = {108.3}; double ptError_bjet[] = {0.0}; double raa_bjet[] = {0.478}; double raaStat_bjet[] = {0.188}; double raaSyst_bjet[] = {0.413}; double ptSystXlow_bjet[] = {8.3}; double ptSystXhigh_bjet[] = {11.7}; TGraphErrors *pgRaa_bjet = new TGraphErrors(1, ptBins_bjet, raa_bjet, ptError_bjet, raaStat_bjet); TGraphAsymmErrors *pgRaaSyst_bjet = new TGraphAsymmErrors(1, ptBins_bjet, raa_bjet, ptSystXlow_bjet,ptSystXhigh_bjet,raaSyst_bjet,raaSyst_bjet); pgRaa_bjet->SetName("pgRaa_bjet"); pgRaa_bjet->SetMarkerStyle(21); pgRaa_bjet->SetMarkerSize(1.); //systm error pgRaaSyst_bjet->SetName("pgRaaSyst_bjet"); pgRaaSyst_bjet->SetFillColor(TColor::GetColor("#FFBF00")); //----------------------------------------- photon double ptBins_photon[] = {22.26, 27.30, 34.35, 44.45, 61.72}; double ptError_photon[] = {0.0, 0.0, 0.0, 0.0, 0.0}; double raa_photon[] = {1.03, 0.84, 1.37, 0.98, 0.99}; double raaStat_photon[] = {0.12 ,0.14, 0.22, 0.24, 0.31 }; double raaSyst_photon[] = {0.29, 0.27, 0.25, 0.22, 0.21}; double ptSystXlow_photon[] = {2.5, 2.5, 5, 5, 15}; double ptSystXhigh_photon[] = {2.5, 2.5, 5, 5, 15}; TGraphErrors *pgRaa_photon = new TGraphErrors(5, ptBins_photon, raa_photon, ptError_photon, raaStat_photon); TGraphAsymmErrors *pgRaaSyst_photon = new TGraphAsymmErrors(5, ptBins_photon, raa_photon, ptSystXlow_photon,ptSystXhigh_photon,raaSyst_photon,raaSyst_photon); pgRaa_photon->SetName("pgRaa_photon"); pgRaa_photon->SetMarkerStyle(20); pgRaa_photon->SetMarkerSize(1.); //systm error pgRaaSyst_photon->SetName("pgRaaSyst_photon"); pgRaaSyst_photon->SetFillColor(TColor::GetColor("#ffff00")); //----------------------------------------- Z double ptBins_z[] = {91.19}; double ptError_z[] = {0.0}; double raa_z[] = {0.95}; double raaStat_z[] = {0.034}; double raaSyst_z[] = {0.13}; double ptSystXlow_z[] = {2.5}; double ptSystXhigh_z[] = {2.5}; TGraphErrors *pgRaa_z = new TGraphErrors(1, ptBins_z, raa_z, ptError_z, raaStat_z); TGraphAsymmErrors *pgRaaSyst_z = new TGraphAsymmErrors(1, ptBins_z, raa_z, ptSystXlow_z,ptSystXhigh_z,raaSyst_z,raaSyst_z); pgRaa_z->SetName("pgRaa_z"); pgRaa_z->SetMarkerStyle(21); pgRaa_z->SetMarkerSize(1.); //systm error pgRaaSyst_z->SetName("pgRaaSyst_z"); pgRaaSyst_z->SetFillColor(TColor::GetColor("#ff8888")); // ----------------------------------------- W raa double ptBins_w[] = {80.38}; double ptError_w[] = {0.0}; double raa_w[] = {1.04}; double raaStat_w[] = {0.07}; double raaSyst_w[] = {0.12}; double ptSystXlow_w[] = {2.5}; double ptSystXhigh_w[] = {2.5}; TGraphErrors *pgRaa_w = new TGraphErrors(1, ptBins_w, raa_w, ptError_w, raaStat_w); TGraphAsymmErrors *pgRaaSyst_w = new TGraphAsymmErrors(1, ptBins_w, raa_w, ptSystXlow_w,ptSystXhigh_w,raaSyst_w,raaSyst_w); pgRaa_w->SetName("pgRaa_w"); pgRaa_w->SetMarkerStyle(29); pgRaa_w->SetMarkerSize(2.); //systm error pgRaaSyst_w->SetName("pgRaaSyst_w"); pgRaaSyst_w->SetFillColor(TColor::GetColor("#ff88ff")); // ----------------------------------------- 2012 non-prompt Jpsi double ptBins_npjpsi[] = {7.31,8.97,11.32,16.52}; double ptError_npjpsi[] = {0.0,0.0,0.0,0.0}; double raa_npjpsi[] = {0.52,0.43,0.43,0.34}; double raaStat_npjpsi[] = {0.12,0.08,0.09,0.07}; double raaSyst_npjpsi[] = {0.06,0.05,0.05,0.04}; double ptSystXlow_npjpsi[] = {0.81, 0.97, 1.32, 3.52}; double ptSystXhigh_npjpsi[] = {0.69, 1.03, 1.68, 13.48}; TGraphErrors *pgRaa_npjpsi = new TGraphErrors(4, ptBins_npjpsi, raa_npjpsi, ptError_npjpsi, raaStat_npjpsi); TGraphAsymmErrors *pgRaaSyst_npjpsi = new TGraphAsymmErrors(4, ptBins_npjpsi, raa_npjpsi, ptSystXlow_npjpsi,ptSystXhigh_npjpsi,raaSyst_npjpsi,raaSyst_npjpsi); pgRaa_npjpsi->SetName("pgRaa_npjpsi"); pgRaa_npjpsi->SetMarkerStyle(25); pgRaa_npjpsi->SetMarkerSize(1.); pgRaa_npjpsi->SetMarkerColor(1); //systm error pgRaaSyst_npjpsi->SetName("pgRaaSyst_npjpsi"); pgRaaSyst_npjpsi->SetFillColor(TColor::GetColor("#ee7711")); //--------------------------------------------------------- // lumi uncert. TBox *box = new TBox(0.9,0.9568966,2,1.043103); box->SetFillColor(kGray+1); box->SetFillStyle(1001); TBox *box_lin = new TBox(0.9,0.9568966,10,1.043103); box_lin->SetFillColor(kGray+1); box_lin->SetFillStyle(1001); //------------------------ single pannel: TCanvas *pc = new TCanvas("pc","pc"); TH1 *phAxis = new TH1D("phAxis",";p_{T} [GeV];R_{AA}",1,0.9,300); phAxis->GetYaxis()->CenterTitle(true); phAxis->SetMinimum(0.); phAxis->SetMaximum(2.5); gPad->SetLogx(); phAxis->Draw(""); // drawing order: // A) stat boxes: pgRaaSyst_photon->Draw("2"); pgRaaSyst_npjpsi->Draw("2"); pgRaaSyst_h->Draw("2"); pgRaaSyst_z->Draw("2"); pgRaaSyst_w->Draw("2"); pgRaaSyst_jet->Draw("2"); pgRaaSyst_bjet->Draw("2"); //nominal+stat // photon pgRaa_photon->Draw("P z"); pgRaa_z->Draw("P z"); pgRaa_w->Draw("P z"); pgRaa_h->Draw("P z"); pgRaa_npjpsi->Draw("P z"); pgRaa_jet->Draw("P z"); pgRaa_bjet->Draw("P z"); TLine *line = new TLine(0.9,1,300,1); line->SetLineStyle(7); line->Draw(); box->Draw(); // // legends and writings: TLegend *leg = new TLegend(0.07,0.87,0.46,0.95,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.028); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(19); leg->SetFillStyle(0); // TLegendEntry *entry=leg->AddEntry("hEtSIEIECorrected","CMS PRELIMINARY",""); // entry->SetLineWidth(1); // entry=leg->AddEntry("hEtSIEIECorrected","PbPb #sqrt{s_{NN}} = 2.76 TeV",""); // entry=leg->AddEntry("hEtSIEIECorrected","",""); // entry=leg->AddEntry("hEtSIEIECorrected","#int L dt = 7-150 #mub^{-1}",""); TLegendEntry *entry=leg->AddEntry("hEtSIEIECorrected","CMS PRELIMINARY PbPb #sqrt{s_{NN}} = 2.76 TeV #int L dt = 7-150 #mub^{-1}",""); entry->SetLineWidth(1); // TAA // TAA only TLegend *leg_taa = new TLegend(0.15,0.5,0.5,0.55,NULL,"brNDC"); leg_taa->SetBorderSize(0); leg_taa->SetTextFont(62); leg_taa->SetTextSize(0.025); leg_taa->SetLineColor(1); leg_taa->SetLineStyle(1); leg_taa->SetLineWidth(1); leg_taa->SetFillColor(19); leg_taa->SetFillStyle(0); TLegendEntry *entry_taa= leg_taa->AddEntry("general","T_{AA} uncertainty","f"); entry_taa->SetFillColor(kGray+1); entry_taa->SetFillStyle(1001); entry_taa->SetLineColor(0); entry_taa->SetLineWidth(1); entry_taa->SetMarkerStyle(21); entry_taa->SetMarkerSize(1); // EWQ legend TLegend *leg_ewq = new TLegend(0.35,0.75,0.8,0.85,NULL,"brNDC"); leg_ewq->SetBorderSize(0); leg_ewq->SetTextFont(62); leg_ewq->SetTextSize(0.025); leg_ewq->SetLineColor(1); leg_ewq->SetLineStyle(1); leg_ewq->SetLineWidth(1); leg_ewq->SetFillColor(19); leg_ewq->SetFillStyle(0); TLegendEntry *entry_ewq=leg_ewq->AddEntry("raaz","Z (0-100%) p_{T}^{#mu} > 20 GeV/c^{^{ }} |y|<2","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ff8888")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(21); entry_ewq->SetMarkerSize(1.); entry_ewq=leg_ewq->AddEntry("raaw","W (0-100%) p_{T}^{#mu} > 25 GeV/c^{^{ }} |#eta^{#mu}|<2.1","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ff88ff")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(29); entry_ewq->SetMarkerSize(1.5); entry_ewq=leg_ewq->AddEntry("raaphoton","Isolated photon (0-10%) |#eta|<1.44","lpf"); entry_ewq->SetFillColor(TColor::GetColor("#ffff00")); entry_ewq->SetFillStyle(1001); entry_ewq->SetLineColor(1); entry_ewq->SetLineWidth(1); entry_ewq->SetMarkerStyle(20); entry_ewq->SetMarkerSize(1); // b and h TLegend *leg_q = new TLegend(0.15,0.65,0.47,0.74,NULL,"brNDC"); leg_q->SetBorderSize(0); leg_q->SetTextFont(62); leg_q->SetTextSize(0.025); leg_q->SetLineColor(1); leg_q->SetLineStyle(1); leg_q->SetLineWidth(1); leg_q->SetFillColor(19); leg_q->SetFillStyle(0); TLegendEntry *entry_q=leg_q->AddEntry("raah","Charged particles^{^{ }} (0-5%) |#eta|<1","lpf"); entry_q->SetFillColor(TColor::GetColor("#33ccff")); entry_q->SetFillStyle(1001); entry_q->SetLineColor(1); entry_q->SetLineStyle(1); entry_q->SetLineWidth(1); entry_q->SetMarkerStyle(24); entry_q->SetMarkerSize(1); entry_q=leg_q->AddEntry("raab","b-quarks (0-100%)^{ } |#eta|<2.4","lpf"); entry_q->SetFillColor(TColor::GetColor("#ee7711")); entry_q->SetFillStyle(1001); entry_q->SetLineColor(1); entry_q->SetLineStyle(1); entry_q->SetLineWidth(1); entry_q->SetMarkerStyle(25); entry_q->SetMarkerSize(1); entry_q=leg_q->AddEntry("raabjpsi", "(via secondary J/#psi) ",""); // jet legend TLegend *leg_jet = new TLegend(0.57,0.69,0.95,0.74,NULL,"brNDC"); leg_jet->SetBorderSize(0); leg_jet->SetTextFont(62); leg_jet->SetTextSize(0.025); leg_jet->SetLineColor(1); leg_jet->SetLineStyle(1); leg_jet->SetLineWidth(1); leg_jet->SetFillColor(19); leg_jet->SetFillStyle(0); TLegendEntry *entry_jet=leg_jet->AddEntry("raaq","q/g-jet^{^{ }} (0-5%) |#eta|<2","lpf"); entry_jet->SetFillColor(TColor::GetColor("#00FFFF")); entry_jet->SetFillStyle(1001); entry_jet->SetLineColor(1); entry_jet->SetLineStyle(1); entry_jet->SetLineWidth(1); entry_jet->SetMarkerStyle(20); entry_jet->SetMarkerSize(1); entry_jet=leg_jet->AddEntry("raaheavy","b-jet (0-100%)^{ } |#eta|<2","lpf"); entry_jet->SetFillColor(TColor::GetColor("#FFBF00")); entry_jet->SetFillStyle(1001); entry_jet->SetLineColor(1); entry_jet->SetLineStyle(1); entry_jet->SetLineWidth(1); entry_jet->SetMarkerStyle(21); entry_jet->SetMarkerSize(1); leg->Draw(); leg_taa->Draw(); leg_ewq->Draw(); leg_q->Draw(); leg_jet->Draw(); gPad->RedrawAxis(); // save the work pc->SaveAs("raaZoo_cms_log.pdf"); pc->SaveAs("raaZoo_cms_log.png"); //-------------------------------------------------------------------------------- //-------------------------- 2TPad TH1 *phAxis_single = new TH1D("phAxis_single",";p_{T} [GeV/c];R_{AA}",1,0.9,100); phAxis_single->GetYaxis()->CenterTitle(true); phAxis_single->SetMinimum(0.); phAxis_single->SetMaximum(2.); TH1 *phAxis_jet = new TH1D("phAxis_jet",";p_{T} [GeV/c];",1,101,300); phAxis_jet->GetYaxis()->CenterTitle(true); phAxis_jet->SetMinimum(0.); phAxis_jet->SetMaximum(2.); // redefine legends: // TAA only TLegend *leg2_taa = new TLegend(0.15,0.85,0.5,0.9,NULL,"brNDC"); leg2_taa->SetBorderSize(0); leg2_taa->SetTextFont(62); leg2_taa->SetTextSize(0.025); leg2_taa->SetLineColor(1); leg2_taa->SetLineStyle(1); leg2_taa->SetLineWidth(1); leg2_taa->SetFillColor(19); leg2_taa->SetFillStyle(0); TLegendEntry *entry2_taa= leg2_taa->AddEntry("general","T_{AA} uncertainty","f"); entry2_taa->SetFillColor(kGray+1); entry2_taa->SetFillStyle(1001); entry2_taa->SetLineColor(0); entry2_taa->SetLineWidth(1); entry2_taa->SetMarkerStyle(21); entry2_taa->SetMarkerSize(1); TLegend *leg2 = new TLegend(0.03,0.7,0.46,0.93,NULL,"brNDC"); leg2->SetBorderSize(0); leg2->SetTextFont(62); leg2->SetTextSize(0.04); leg2->SetLineColor(1); leg2->SetLineStyle(1); leg2->SetLineWidth(1); leg2->SetFillColor(19); leg2->SetFillStyle(0); TLegendEntry *entry2=leg2->AddEntry("general","CMS PRELIMINARY",""); entry2->SetLineWidth(1); entry2=leg2->AddEntry("general","PbPb #sqrt{s_{NN}} = 2.76 TeV",""); entry2=leg2->AddEntry("general","",""); entry2=leg2->AddEntry("general","#int L dt = 7-150 #mub^{-1}",""); // jet leg2end TLegend *leg2_jet = new TLegend(0.45,0.55,0.9,0.65,NULL,"brNDC"); leg2_jet->SetBorderSize(0); leg2_jet->SetTextFont(62); leg2_jet->SetTextSize(0.03); leg2_jet->SetLineColor(1); leg2_jet->SetLineStyle(1); leg2_jet->SetLineWidth(1); leg2_jet->SetFillColor(19); leg2_jet->SetFillStyle(0); TLegendEntry *entry2_jet=leg2_jet->AddEntry("raaq","q/g-jet^{^{ }} (0-5%) |#eta|<2","lpf"); entry2_jet->SetFillColor(TColor::GetColor("#00FFFF")); entry2_jet->SetFillStyle(1001); entry2_jet->SetLineColor(1); entry2_jet->SetLineStyle(1); entry2_jet->SetLineWidth(1); entry2_jet->SetMarkerStyle(20); entry2_jet->SetMarkerSize(1); entry2_jet=leg2_jet->AddEntry("raaheavy","b-jet (0-100%)^{ } |#eta|<2","lpf"); entry2_jet->SetFillColor(TColor::GetColor("#FFBF00")); entry2_jet->SetFillStyle(1001); entry2_jet->SetLineColor(1); entry2_jet->SetLineStyle(1); entry2_jet->SetLineWidth(1); entry2_jet->SetMarkerStyle(21); entry2_jet->SetMarkerSize(1); // EWQ legend TLegend *leg2_ewq = new TLegend(0.47,0.8,0.9,0.95,NULL,"brNDC"); leg2_ewq->SetBorderSize(0); leg2_ewq->SetTextFont(62); leg2_ewq->SetTextSize(0.027); leg2_ewq->SetLineColor(1); leg2_ewq->SetLineStyle(1); leg2_ewq->SetLineWidth(1); leg2_ewq->SetFillColor(19); leg2_ewq->SetFillStyle(0); TLegendEntry *entry2_ewq=leg2_ewq->AddEntry("raaz","Z (0-100%) p_{T}^{#mu} > 20 GeV/c^{^{ }} |y|<2","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ff8888")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(21); entry2_ewq->SetMarkerSize(1.); entry2_ewq=leg2_ewq->AddEntry("raaw","W (0-100%) p_{T}^{#mu} > 25 GeV/c^{^{ }} |#eta^{#mu}|<2.1","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ff88ff")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(29); entry2_ewq->SetMarkerSize(1.5); entry2_ewq=leg2_ewq->AddEntry("raaphoton","Isolated photon (0-10%) |#eta|<1.44","lpf"); entry2_ewq->SetFillColor(TColor::GetColor("#ffff00")); entry2_ewq->SetFillStyle(1001); entry2_ewq->SetLineColor(1); entry2_ewq->SetLineWidth(1); entry2_ewq->SetMarkerStyle(20); entry2_ewq->SetMarkerSize(1); // B and h TLegend *leg2_q = new TLegend(0.47,0.15,0.89,0.3,NULL,"brNDC"); leg2_q->SetBorderSize(0); leg2_q->SetTextFont(62); leg2_q->SetTextSize(0.027); leg2_q->SetLineColor(1); leg2_q->SetLineStyle(1); leg2_q->SetLineWidth(1); leg2_q->SetFillColor(19); leg2_q->SetFillStyle(0); TLegendEntry *entry2_q=leg2_q->AddEntry("raah","Charged particles^{^{ }} (0-5%) |#eta|<1","lpf"); entry2_q->SetFillColor(TColor::GetColor("#33ccff")); entry2_q->SetFillStyle(1001); entry2_q->SetLineColor(1); entry2_q->SetLineStyle(1); entry2_q->SetLineWidth(1); entry2_q->SetMarkerStyle(24); entry2_q->SetMarkerSize(1); entry2_q=leg2_q->AddEntry("raab","b-quarks (0-100%)^{ } |y|<2.4","lpf"); entry2_q->SetFillColor(TColor::GetColor("#ee7711")); entry2_q->SetFillStyle(1001); entry2_q->SetLineColor(1); entry2_q->SetLineStyle(1); entry2_q->SetLineWidth(1); entry2_q->SetMarkerStyle(25); entry2_q->SetMarkerSize(1); entry2_q=leg2_q->AddEntry("raabjpsi", "(via secondary J/#psi) ",""); if(bDo2PadZoo) { TCanvas *pc2 = new TCanvas("pc2","pc2",1200,600); TPad *p_0 = new TPad("p_0","p_0",0,0,0.50,1); p_0->Draw(); p_0->cd(); p_0->SetRightMargin(0); phAxis_single->Draw(""); box_lin->Draw(); pgRaaSyst_photon->Draw("2"); pgRaaSyst_npjpsi->Draw("2"); pgRaaSyst_h->Draw("2"); pgRaaSyst_z->Draw("2"); pgRaaSyst_w->Draw("2"); pgRaa_photon->Draw("P z"); pgRaa_z->Draw("P z"); pgRaa_w->Draw("P z"); pgRaa_h->Draw("P z"); pgRaa_npjpsi->Draw("P z"); TLine *line_single = new TLine(0.9,1,100,1); line_single->SetLineStyle(7); line_single->Draw(); // legends leg2_taa->Draw(); leg2_q->Draw(); leg2_ewq->Draw(); pc2->cd(); // jet pad TPad *p_1 = new TPad("p_1","p_1",0.50,0,1,1); p_1->Draw(); p_1->cd(); p_1->SetLeftMargin(0.); p_1->SetTickx(1); p_1->SetTicky(1); phAxis_jet->Draw(""); pgRaaSyst_bjet->Draw("2"); pgRaaSyst_jet->Draw("2"); pgRaa_bjet->Draw("P z"); pgRaa_jet->Draw("P z"); TLine *line_jet = new TLine(100,1,300,1); line_jet->SetLineStyle(7); line_jet->Draw(); leg2->Draw(); leg2_jet->Draw(); p_0->cd(); gPad->RedrawAxis(); pc2->SaveAs("raaZoo_cms_2pads.pdf"); pc2->SaveAs("raaZoo_cms_2pads.png"); } }