void raaExpOpen_pt(const char* inputDir = "../macro_raa/outRoot", // the place where the input root files, with the histograms are bool bSavePlots = true, bool bDrawCh = true, double xMax = 30 // x-axis range limit (ALICE D has x-range maximum value at 36, CMS has it at 30) ) { // set the style gSystem->mkdir(Form("./figs/png"), kTRUE); gSystem->mkdir(Form("./figs/pdf"), kTRUE); setTDRStyle(); // read CMS graphs TFile *pgRaaCms_pt = new TFile(Form("%s/makeRaa_pt.root",inputDir)); // ##################### HIGH PT ############################ TGraphErrors *pgCms = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi"); TGraphErrors *pgCmsP = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP"); TGraphErrors *pgCmsSyst = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst"); pgCmsSyst->SetFillColorAlpha(kOrange-9,0.5); pgCms->SetName("gNonPrJpsi"); TBox *lumi = (TBox*)pgRaaCms_pt->Get("lumi"); lumi->SetFillColor(kOrange-9); lumi->SetFillStyle(1001); lumi->SetX1(xMax-0.75); lumi->SetX2(xMax); TBox *lumi_lowpt = (TBox*)lumi->Clone("lumi_lowpt"); lumi_lowpt->SetFillColor(kViolet-9); lumi_lowpt->SetFillStyle(1001); lumi_lowpt->SetX1(xMax-1.5); lumi_lowpt->SetX2(xMax-0.75); // ##################### LOW PT ############################ TGraphErrors *pgCms_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi_pt365y1624"); TGraphErrors *pgCmsP_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP_pt365y1624"); TGraphErrors *pgCmsSyst_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst_pt365y1624"); pgCmsSyst_lowpt->SetFillColorAlpha(kViolet-9,0.5); pgCms_lowpt->SetName("gNonPrJpsi_pt365y1624"); //-------------------------------------------------------------------- // *********** CMS Charged particle RAA TGraphAsymmErrors *p8165_d5x1y1 = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_ystatminus, p8165_d5x1y1_ystatplus); TGraphAsymmErrors *p8165_d5x1y1_syst = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_yerrminus, p8165_d5x1y1_yerrplus); p8165_d5x1y1->SetName("cms_ch_raa"); // X-axis errors will be discarded for (int i=0; i<p8165_d5x1y1_numpoints; i++) { p8165_d5x1y1->SetPointEXlow(i,0); p8165_d5x1y1->SetPointEXhigh(i,0); p8165_d5x1y1_syst->SetPointEXlow(i,0.5); p8165_d5x1y1_syst->SetPointEXhigh(i,0.5); } // *********** ALICE D RAA vs. pT TGraphAsymmErrors *p9059_d15x1y1 = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus); TGraphAsymmErrors *p9059_d15x1y1_syst = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus); p9059_d15x1y1->SetName("alice_d_raa"); // X-axis errors will be discarded for (int i=0; i<p9059_d15x1y1_numpoints; i++) { p9059_d15x1y1->SetPointEXlow(i,0); p9059_d15x1y1->SetPointEXhigh(i,0); p9059_d15x1y1_syst->SetPointEXlow(i,0.5); p9059_d15x1y1_syst->SetPointEXhigh(i,0.5); if (xMax<=30 && (i+1)==p9059_d15x1y1_numpoints) { double x,y; p9059_d15x1y1->GetPoint(i,x,y); p9059_d15x1y1->SetPoint(i,x+5,y); p9059_d15x1y1_syst->GetPoint(i,x,y); p9059_d15x1y1_syst->SetPoint(i,x+5,y); } } // Style for graphs p9059_d15x1y1->SetMarkerStyle(kOpenSquare); p9059_d15x1y1->SetMarkerSize(1.3); p9059_d15x1y1->SetMarkerColor(kBlack); p9059_d15x1y1->SetLineColor(kBlack); p9059_d15x1y1_syst->SetFillColorAlpha(kGray+1,0.5); p8165_d5x1y1->SetMarkerStyle(20); p8165_d5x1y1->SetMarkerSize(1.3); p8165_d5x1y1->SetMarkerColor(kTeal+3); p8165_d5x1y1->SetLineColor(kTeal+4); p8165_d5x1y1_syst->SetFillColorAlpha(kTeal-1,0.5); //--------------------------------------------------------- TLine *line = new TLine(0.,1,xMax,1); line->SetLineStyle(1); line->SetLineWidth(1); TCanvas *pc = new TCanvas("pc","pc"); TF1 *f4 = new TF1("f4","1",0,xMax); f4->SetLineWidth(1); f4->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f4->GetYaxis()->SetTitle("R_{AA}"); f4->GetXaxis()->SetRangeUser(0.0,xMax); f4->GetYaxis()->SetRangeUser(0.0,1.5); f4->GetXaxis()->CenterTitle(kTRUE); f4->Draw(); lumi->Draw(); lumi_lowpt->Draw(); pc->Update(); pgCmsSyst->Draw("2"); // for drawing x-axis p9059_d15x1y1_syst->Draw("2"); if (bDrawCh) p8165_d5x1y1_syst->Draw("2"); p9059_d15x1y1->Draw("pz"); if (bDrawCh) p8165_d5x1y1->Draw("pz"); pgCmsSyst->Draw("2"); pgCmsP->Draw("P"); pgCms->Draw("P"); pgCmsSyst_lowpt->Draw("2"); pgCmsP_lowpt->Draw("P"); pgCms_lowpt->Draw("P"); // additional info CMS_lumi(pc,12003000,0); TLegend *leg_cent = new TLegend(0.28,0.77,0.86,0.89,NULL,"brNDC"); // at top center leg_cent->SetMargin(0.12); leg_cent->SetBorderSize(0); leg_cent->SetTextFont(132); leg_cent->SetTextSize(0.03); leg_cent->SetLineColor(1); leg_cent->SetLineStyle(1); leg_cent->SetLineWidth(1); leg_cent->SetFillColor(19); leg_cent->SetFillStyle(0); TLegendEntry *entry_cent; entry_cent=leg_cent->AddEntry("raab","Open beauty: Nonprompt J/#psi",""); entry_cent->SetTextFont(132); entry_cent->SetTextSize(ltxSetTextSize3); entry_cent=leg_cent->AddEntry("gNonPrJpsi_pt365y1624", "1.6 < |y| < 2.4","p"); entry_cent->SetTextFont(42); entry_cent->SetTextSize(entrySize); entry_cent=leg_cent->AddEntry("gNonPrJpsi", "|y| < 2.4","p"); entry_cent->SetTextFont(42); entry_cent->SetTextSize(entrySize); TLegend *leg_ch = new TLegend(0.28,0.685,0.86,0.765,NULL,"brNDC"); leg_ch->SetMargin(0.12); leg_ch->SetBorderSize(0); leg_ch->SetTextFont(132); leg_ch->SetTextSize(0.03); leg_ch->SetLineColor(1); leg_ch->SetLineStyle(1); leg_ch->SetLineWidth(1); leg_ch->SetFillColor(19); leg_ch->SetFillStyle(0); if (bDrawCh) { TLegendEntry *entry_ch; entry_ch=leg_ch->AddEntry("cms_ch","Charged hadron",""); entry_ch->SetTextSize(ltxSetTextSize3); entry_ch->SetTextFont(132); entry_ch=leg_ch->AddEntry("cms_ch_raa","|#eta| < 1, Cent. 0-5%","p"); entry_ch->SetTextSize(entrySize); entry_ch->SetTextFont(42); } TLegend *leg_alice; if (bDrawCh) { leg_alice = new TLegend(0.28,0.60,0.86,0.68,NULL,"brNDC"); } else { leg_alice = new TLegend(0.28,0.685,0.86,0.765,NULL,"brNDC"); } leg_alice->SetMargin(0.12); leg_alice->SetBorderSize(0); leg_alice->SetTextFont(132); leg_alice->SetTextSize(0.03); leg_alice->SetLineColor(1); leg_alice->SetLineStyle(1); leg_alice->SetLineWidth(1); leg_alice->SetFillColor(kWhite); leg_alice->SetFillStyle(1000); TLegendEntry *entry_alice; entry_alice=leg_alice->AddEntry("alice_d","Open charm: Prompt D (ALICE)",""); entry_alice->SetTextSize(ltxSetTextSize3); entry_alice->SetTextFont(132); entry_alice=leg_alice->AddEntry("alice_d_raa","|y| < 0.5, Cent. 0-10%","p"); entry_alice->SetTextSize(entrySize); entry_alice->SetTextFont(42); TLatex *lat = new TLatex(); lat->SetNDC(); lat->SetTextFont(42); lat->SetTextSize(ltxSetTextSize2); if (bDrawCh) lat->DrawLatex(0.63,0.53,"Cent. 0-100%"); else lat->DrawLatex(0.63,0.58,"Cent. 0-100%"); line->Draw(); leg_cent->Draw(); if (bDrawCh) leg_ch->Draw(); leg_alice->Draw(); gPad->RedrawAxis(); if(bSavePlots) { pc->SaveAs(Form("figs/pdf/raaExpOpen_pt_RaaCh%d.pdf",bDrawCh)); pc->SaveAs(Form("figs/png/raaExpOpen_pt_RaaCh%d.png",bDrawCh)); } }
void HwwNoteFigs(TString filename = "../histo_tmva_new-ntuples-1_160_0.root", int mass = 170, int ReBin = 4, int ysel = 0) { TFile* infile = new TFile(filename.Data(),"READ"); setTDRStyle(0); //BDTD dists TCanvas* c1 = new TCanvas("c1","c1",0,-200,500,500); TH1F* histoBg = histo4->Clone(); histoBg->Add(histo3); histoBg->Add(histo2); histoBg->Add(histo1); TH1F* histo_4 = histo4->Clone(); histo3->Add(histo_4); TH1F* histo_3 = histo3->Clone(); histo2->Add(histo_3); TH1F* histo_2 = histo2->Clone(); histo1->Add(histo_2); histo1->Rebin(ReBin); histo1->SetFillColor(kBlue); histo1->SetFillStyle(1001); histo1->SetLineStyle(0); histo1->SetLineWidth(0); histo2->Rebin(ReBin); histo2->SetFillColor(kMagenta); histo2->SetFillStyle(1001); histo2->SetLineStyle(0); histo2->SetLineWidth(0); histo3->Rebin(ReBin); histo3->SetFillColor(kGreen); histo3->SetFillStyle(1001); histo3->SetLineStyle(0); histo3->SetLineWidth(0); histo4->Rebin(ReBin); histo4->SetFillColor(kCyan); histo4->SetFillStyle(1001); histo4->SetLineStyle(0); histo4->SetLineWidth(0); char YTitle[300]; sprintf(YTitle,"events / bin"); char XTitle[300]; sprintf(XTitle,"BDT Output"); histo0->SetYTitle(YTitle); histo1->SetYTitle(YTitle); histo2->SetYTitle(YTitle); histo3->SetYTitle(YTitle); histo4->SetYTitle(YTitle); histo0->SetXTitle(XTitle); histo1->SetXTitle(XTitle); histo2->SetXTitle(XTitle); histo3->SetXTitle(XTitle); histo4->SetXTitle(XTitle); histo1->SetTitleSize(0.05, "X"); histo1->GetXaxis()->SetTitleFont(62); histo1->GetXaxis()->SetLabelFont(61); histo1->GetYaxis()->SetLabelFont(61); histo1->GetYaxis()->SetTitleOffset(1.3); histo1->SetLabelSize(0.04, "Y"); histo1->SetLabelSize(0.04, "X"); int min = histoBg->FindBin(-1.5); int max = histoBg->FindBin(1.5); histoBg->GetXaxis()->SetRange(min,max); histoBg->SetMarkerStyle(20); histoBg->SetMarkerSize(1.0); histoBg->GetYaxis()->SetTitleOffset(1.40); histo0->SetMarkerStyle(21); histo0->SetMarkerSize(1.0); histoBg->Rebin(ReBin); histo0->Rebin(ReBin); histoBg->SetLineColor(4); histo0->SetLineColor(1); scaleHist(histoBg); scaleHist(histo0); cout << "bg events: " << histoBg->GetSumOfWeights() << endl; cout << "si events: " << histo0->GetSumOfWeights() << endl; histoBg->SetYTitle("Events"); histo1->SetMinimum(0.01); if(ysel == 0) { histo1->Draw("hist"); } else { histo0->Draw("E"); histo1->Draw("hist,same"); } histo2->Draw("hist,same"); histo3->Draw("hist,same"); histo4->Draw("hist,same"); histo0->Draw("E, same"); //histoBg->DrawCopy("hist"); //histo0->DrawCopy("hist,same"); TLegend* leg = new TLegend(0.63, 0.75, 0.92, 0.92); leg->SetFillColor(0); char theSLine[100]; if(mass != 999) sprintf(theSLine,"Signal, m_{H}=%d GeV",mass); else sprintf(theSLine,"WW"); cout << theSLine << endl; leg ->AddEntry(histo0,theSLine); leg ->AddEntry(histo4,"W+Jets, W#gamma","F"); leg ->AddEntry(histo3,"di-boson","F"); leg ->AddEntry(histo2,"t#bar{t}, tW","F"); leg ->AddEntry(histo1,"Drell-Yan","F"); leg->Draw("same"); TString fileOutput1(filename.Data()); TString theLine = "_"; theLine = theLine + "plot.eps"; fileOutput1.ReplaceAll(".root",theLine.Data()); fileOutput1.ReplaceAll("../",""); fileOutput1.ReplaceAll("rootfiles_fastsim/",""); fileOutput1.ReplaceAll("rootfiles_fullsim/",""); c1->SaveAs(fileOutput1.Data()); //return; //-------------------------------- TCanvas* c3 = new TCanvas("c3","c3",550,-200,500,500); c3->SetLogx(); c3->SetLogy(); gPad->SetGrid(1,1); TGraphErrors* gBDTD = makeGraphFromHists(histo0, histoBg); gBDTD->Draw("APXl"); TH1* zBDTD = gBDTD->GetHistogram(); zBDTD->SetXTitle("Signal Events"); zBDTD->SetYTitle("Signal/Background"); //zBDTD->SetYTitle("Background Events"); //zBDTD->DrawCopy(); TLegend* leg3 = new TLegend(0.7, 0.7, 0.9, 0.9); leg3->SetFillColor(0); leg3->AddEntry(gBDTD,theSLine,"lp"); leg3->Draw("same"); TString fileOutput2(filename.Data()); theLine = "_"; theLine = theLine + "counts.eps"; fileOutput2.ReplaceAll(".root",theLine.Data()); fileOutput2.ReplaceAll("../",""); fileOutput2.ReplaceAll("rootfiles_fastsim/",""); fileOutput2.ReplaceAll("rootfiles_fullsim/",""); c3->SaveAs(fileOutput2.Data()); }
void HypoTestInvDemo(const char * fileName ="GausModel_b.root", const char * wsName = "w", const char * modelSBName = "model_sb", const char * modelBName = "model_b", const char * dataName = "data_obs", int type = 0, // calculator type int testStatType = 0, // test stat type int npoints = 10, int ntoys=1000, bool useCls = true ) { /* type = 0 Freq calculator type = 1 Hybrid testStatType = 0 LEP = 1 Tevatron = 2 PL */ if (fileName==0) { std::cout << "give input filename " << std::endl; return; } TFile * file = new TFile(fileName); RooWorkspace * w = dynamic_cast<RooWorkspace*>( file->Get(wsName) ); if (!w) { return; } w->Print(); RooAbsData * data = w->data(dataName); if (!data) { Error("HypoTestDemo","Not existing data %s",dataName); } // get models from WS // get the modelConfig out of the file ModelConfig* bModel = (ModelConfig*) w->obj(modelBName); ModelConfig* sbModel = (ModelConfig*) w->obj(modelSBName); SimpleLikelihoodRatioTestStat slrts(*bModel->GetPdf(),*sbModel->GetPdf()); slrts.SetNullParameters(*bModel->GetSnapshot()); slrts.SetAltParameters(*sbModel->GetSnapshot()); RatioOfProfiledLikelihoodsTestStat ropl(*bModel->GetPdf(), *sbModel->GetPdf(), sbModel->GetSnapshot()); ropl.SetSubtractMLE(false); ProfileLikelihoodTestStat profll(*sbModel->GetPdf()); profll.SetOneSided(0); TestStatistic * testStat = &slrts; if (testStatType == 1) testStat = &ropl; if (testStatType == 2) testStat = &profll; HypoTestCalculatorGeneric * hc = 0; if (type == 0) hc = new FrequentistCalculator(*data, *sbModel, *bModel); else new HybridCalculator(*data, *sbModel, *bModel); ToyMCSampler *toymcs = (ToyMCSampler*)hc->GetTestStatSampler(); //toymcs->SetNEventsPerToy(1); toymcs->SetTestStatistic(testStat); if (type == 1) { HybridCalculator *hhc = (HybridCalculator*) hc; hhc->SetToys(ntoys,ntoys); // hhc->ForcePriorNuisanceAlt(*pdfNuis); // hhc->ForcePriorNuisanceNull(*pdfNuis); } else ((FrequentistCalculator*) hc)->SetToys(ntoys,ntoys); // Get the result RooMsgService::instance().getStream(1).removeTopic(RooFit::NumIntegration); TStopwatch tw; tw.Start(); const RooArgSet * poiSet = sbModel->GetParametersOfInterest(); RooRealVar *poi = (RooRealVar*)poiSet->first(); // fit the data first sbModel->GetPdf()->fitTo(*data); double poihat = poi->getVal(); //poi->setVal(30); //poi->setError(10); HypoTestInverter calc(*hc); // GENA: for two-sided interval //calc.SetConfidenceLevel(0.95); // GENA: for 95% upper limit calc.SetConfidenceLevel(0.90); calc.UseCLs(useCls); calc.SetVerbose(true); // can spped up using proof ProofConfig pc(*w, 2, "workers=2", kFALSE); //ProofConfig pc(*w, 30, "localhost", kFALSE); //ToyMCSampler * toymcs = dynamic_cast<ToyMCSampler *> (calc.GetHypoTestCalculator()->GetTestStatSampler() ); // GENA: disable proof for now //toymcs->SetProofConfig(&pc); // enable proof if (npoints > 0) { // GENA double poimin = TMath::Max(poihat - 4 * poi->getError(), 0.0); //poimin = poihat; double poimax = poihat + 4 * poi->getError(); poimin = 0; poimax = 20; //double poimin = poi->getMin(); //double poimax = poi->getMax(); std::cout << "Doing a fixed scan in interval : " << poimin << " , " << poimax << std::endl; calc.SetFixedScan(npoints,poimin,poimax); } HypoTestInverterResult * r = calc.GetInterval(); // write to a file the results TString resultFileName = (useCls) ? "CLs_" : "Cls+b_"; resultFileName += fileName; // GENA //TFile * file = new TFile(resultFileName,"RECREATE"); file = new TFile(resultFileName,"RECREATE"); r->Write(); file->Close(); double ulError = r->UpperLimitEstimatedError(); double upperLimit = r->UpperLimit(); std::cout << "The computed upper limit is: " << upperLimit << std::endl; std::cout << "an estimated error on this upper limit is: " << ulError << std::endl; // check using interpolation // double interpLimit = r->FindInterpolatedLimit(1.-r->ConfidenceLevel() ); // cout << "The computer interpolated limits is " << interpLimit << endl; const int nEntries = r->ArraySize(); std::vector<Double_t> xArray(nEntries); std::vector<Double_t> yArray(nEntries); std::vector<Double_t> yErrArray(nEntries); for (int i=0; i<nEntries; i++) { xArray[i] = r->GetXValue(i); yArray[i] = r->GetYValue(i); yErrArray[i] = r->GetYError(i); std::cout << xArray[i] << " , " << yArray[i] << " err = " << yErrArray[i] << std::endl; } // see expected result (bands) TGraph * g0 = new TGraph(nEntries); TGraphAsymmErrors * g1 = new TGraphAsymmErrors(nEntries); TGraphAsymmErrors * g2l = new TGraphAsymmErrors(nEntries); TGraphAsymmErrors * g2u = new TGraphAsymmErrors(nEntries); double p[7]; double q[7]; p[0] = ROOT::Math::normal_cdf(-2); p[1] = ROOT::Math::normal_cdf(-1.5); p[2] = ROOT::Math::normal_cdf(-1); p[3] = 0.5; p[4] = ROOT::Math::normal_cdf(1); p[5] = ROOT::Math::normal_cdf(1.5); p[6] = ROOT::Math::normal_cdf(2); for (int i=0; i<nEntries; i++) { SamplingDistribution * s = r->GetExpectedDistribution(i); // GENA //const std::vector<double> & values = s->GetSamplingDistribution(); const std::vector<Double_t> & cValues = s->GetSamplingDistribution(); std::vector<Double_t> values; for (std::vector<Double_t>::const_iterator val = cValues.begin(); val != cValues.end(); ++val) values.push_back(*val); TMath::Quantiles(values.size(), 7, &values[0],q,p,false); double p0 = q[3]; double p2l = q[1]; double p2u = q[5]; g0->SetPoint(i, r->GetXValue(i), p0 ) ; g1->SetPoint(i, r->GetXValue(i), p0); g2l->SetPoint(i, r->GetXValue(i), p2l); g2u->SetPoint(i, r->GetXValue(i), p2u); //g2->SetPoint(i, r->GetXValue(i), s->InverseCDF(0.50)); g1->SetPointEYlow(i, q[3] - q[2]); // -1 sigma errorr g1->SetPointEYhigh(i, q[4] - q[3]);//+1 sigma error g2l->SetPointEYlow(i, q[1]-q[0]); // -2 -- -1 sigma error g2l->SetPointEYhigh(i, q[2]-q[1]); g2u->SetPointEYlow(i, q[5]-q[4]); g2u->SetPointEYhigh(i, q[6]-q[5]); if (plotHypoTestResult) { HypoTestResult * hr = new HypoTestResult(); hr->SetNullDistribution( r->GetBackgroundDistribution() ); hr->SetAltDistribution( r->GetSignalAndBackgroundDistribution(i) ); new TCanvas(); HypoTestPlot * pl = new HypoTestPlot(*hr); pl->Draw(); } } HypoTestInverterPlot *plot = new HypoTestInverterPlot("result","",r); TGraphErrors * g = plot->MakePlot(); g->Draw("APL"); g2l->SetFillColor(kYellow); g2l->Draw("3"); g2u->SetFillColor(kYellow); g2u->Draw("3"); g1->SetFillColor(kGreen); g1->Draw("3"); g0->SetLineColor(kBlue); g0->SetLineStyle(2); g0->SetLineWidth(2); g0->Draw("L"); //g1->Draw("P"); //g2->Draw("P"); g->SetLineWidth(2); g->Draw("PL"); // GENA: two-sided interval //double alpha = 1.-r->ConfidenceLevel(); // GENA: upper limit double alpha = (1.-r->ConfidenceLevel())/2.0; double x1 = g->GetXaxis()->GetXmin(); double x2 = g->GetXaxis()->GetXmax(); TLine * line = new TLine(x1, alpha, x2,alpha); line->SetLineColor(kRed); line->Draw(); // see the expected limit and -1 +1 sigma bands // SamplingDistribution * limits = r->GetUpperLimitDistribution(); // std::cout << " expected limit (median) " << limits->InverseCDF(0.50) << std::endl; // std::cout << " expected limit (-1 sig) " << limits->InverseCDF((ROOT::Math::normal_cdf(-1))) << std::endl; // std::cout << " expected limit (+1 sig) " << limits->InverseCDF((ROOT::Math::normal_cdf(+1))) << std::endl; tw.Print(); }
void decovspeak(bool printgif = false){ //load macros and set style----------------------------------- //gROOT->SetStyle("Plain"); gStyle->SetPalette(1); //gStyle->SetOptStat("mr"); //gStyle->SetOptFit(0); gStyle->SetOptStat(0); int colors[] = {2,4,6,1}; vector<char*> filenames; vector<char*> types; //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_ALLPEAK/merged.root"); filenames.push_back("Commissioning10-GOODCOLL-v8_ALLPEAK/res/merged.root"); //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_copy/merged_2.root"); filenames.push_back("Commissioning10-GOODCOLL-v8/res/merged.root"); filenames.push_back("Commissioning10-GOODCOLL-v8_toblatebp06/res/merged.root"); //filenames.push_back("crabjobs/lpc/Spring10-START3X_V26A_356ReReco-v1_standard_geom_mintrkmom1/merged.root"); //filenames.push_back("crabjobs/lpc/Spring10-START3X_V26A_356ReReco-v1_standard_geom/merged.root"); //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_toblatebp063/merged.root"); types.push_back("peak"); types.push_back("deco"); types.push_back("deco (BP)"); //types.push_back("MC"); vector<char*> cantitles; //cantitles.push_back("du_dw"); //delta u, delta w TH1s //cantitles.push_back("duvsdth"); //v+/- split du vs. delta tan(theta) TH2s cantitles.push_back("duvsdth_tgraph"); //v+/- split du vs. delta tan(theta) TGraphs const unsigned int nfiles = filenames.size(); const unsigned int ncan = cantitles.size(); TCanvas *can[ncan]; int idx = 0; TFile* file[nfiles]; TH1F* hdu[nfiles]; TH1F* hdw[nfiles]; TH2F* hduthp[nfiles]; TH2F* hduthm[nfiles]; //dummy legend TLegend *leg1=new TLegend(0.15,0.65,0.35,0.85); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ TH1F *hdummy=new TH1F(Form("hdummy_%i",ifile),Form("hdummy_%i",ifile),1,0,1); hdummy->SetLineColor(colors[ifile]); hdummy->SetMarkerColor(colors[ifile]); leg1->AddEntry(hdummy,types.at(ifile)); } leg1->SetBorderSize(1); leg1->SetFillColor(0); cout << "Getting histos... " << endl; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ cout << "Opening " << types.at(ifile) <<" file " << filenames.at(ifile) << endl; file[ifile] = TFile::Open(filenames.at(ifile)); hdu[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/du_TIB"); hdw[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/dw_TIB"); // if( strcmp(types.at(ifile),"deco (BP)") == 0){ hduthp[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vp_wp_all"); TH2F* htp = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vp_wm_all"); hduthp[ifile] -> Add(htp); hduthm[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vm_wp_all"); TH2F* htm = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vm_wm_all"); hduthm[ifile] -> Add(htm); // }else{ // hduthp[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vp_wp"); // TH2F* htp = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vp_wm"); // hduthp[ifile] -> Add(htp); // hduthm[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vm_wp"); // TH2F* htm = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TIB_vm_wm"); // hduthm[ifile] -> Add(htm); // } } cout << "Plotting du, dw histos... " << endl; if(draw("du_dw",cantitles)){ can[idx]=new TCanvas(Form("can_%i",idx),"du_dw",1200,450); can[idx]->Divide(2,1); can[idx]->cd(1); setStats(hdu,nfiles,0.8,0.65,0.15); plotHists(hdu,nfiles,"TIB","#Delta u [#mum]",-1000,1000,10,3); leg1->Draw(); can[idx]->cd(2); setStats(hdw,nfiles,0.8,0.65,0.15); plotHists(hdw,nfiles,"TIB","#Delta w [#mum]",-2000,2000,10,3); leg1->Draw(); idx++; } cout << "Plotting du vs. delta tan theta split v+/v- histos... " << endl; //du vs. delta tan(theta) split v+/v- histos----------------------------------- if(draw("duvsdth",cantitles)){ can[idx]=new TCanvas(cantitles.at(idx),cantitles.at(idx),1200,450*nfiles); can[idx]->Divide(nfiles,2); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ plotHistsTH2(hduthp[ifile], Form("TIB %s (v+)",types.at(ifile)),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.3,0.5,-200,200,0,can[idx],ifile+1); plotHistsTH2(hduthm[ifile], Form("TIB %s (v-)",types.at(ifile)),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.5,0.3,-200,200,0,can[idx],ifile+2); } idx++; } cout << "Plotting du vs. delta tan theta split v+/v- TGraphs... " << endl; //TGraph du vs. delta tan theta---------------------------------------- if(draw("duvsdth_tgraph",cantitles)){ can[idx]=new TCanvas(cantitles.at(idx),cantitles.at(idx),1200,450); can[idx]->Divide(2,1); vector<float> thetabinsp; vector<float> thetabinsm; for(int ibin=14;ibin<=30;ibin++) thetabinsp.push_back(ibin*0.05-1); for(int ibin=10;ibin<=26;ibin++) thetabinsm.push_back(ibin*0.05-1); TLatex *t=new TLatex(); t->SetNDC(); TGraphErrors *gduthp[nfiles]; TGraphErrors *gduthm[nfiles]; TF1 *fduthp[nfiles]; TF1 *fduthm[nfiles]; stringstream sduthp1[nfiles]; stringstream sduthp2[nfiles]; stringstream sduthm1[nfiles]; stringstream sduthm2[nfiles]; bool fit = false; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); hduthp[ifile]->SetName(Form("hduthp_%i",ifile)); gduthp[ifile] = getTGraphFromTH2(hduthp[ifile],thetabinsp, colors[ifile] ); fduthp[ifile]=new TF1(Form("fduthp_%i",ifile),"pol1"); fduthp[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthp[ifile]->Fit(fduthp[ifile]); float dwp = fduthp[ifile]->GetParameter(1); float dwperr = fduthp[ifile]->GetParError(1); float bp = fduthp[ifile]->GetParameter(0); float bperr = fduthp[ifile]->GetParError(0); sduthp1[ifile] << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2[ifile] << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; gduthp[ifile]->SetTitle("TIB (V+)"); gduthp[ifile]->Draw("AP"); gduthp[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthp[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthp[ifile]->GetXaxis()->SetLimits(-1,1); gduthp[ifile]->SetMinimum(-25); gduthp[ifile]->SetMaximum(20); can[idx]->cd(2); hduthm[ifile]->SetName(Form("hduthm_%i",ifile)); gduthm[ifile] = getTGraphFromTH2(hduthm[ifile],thetabinsm, colors[ifile] ); fduthm[ifile]=new TF1(Form("fduthm_%i",ifile),"pol1"); fduthm[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthm[ifile]->Fit(fduthm[ifile]); float dwm = fduthm[ifile]->GetParameter(1); float dwmerr = fduthm[ifile]->GetParError(1); float bm = fduthm[ifile]->GetParameter(0); float bmerr = fduthm[ifile]->GetParError(0); sduthm1[ifile] << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2[ifile] << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; gduthm[ifile]->SetTitle("TIB (V-)"); gduthm[ifile]->Draw("AP"); gduthm[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthm[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthm[ifile]->GetXaxis()->SetLimits(-1,1); gduthm[ifile]->SetMinimum(-35); gduthm[ifile]->SetMaximum(15); //leg1->Draw(); } for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); if( ifile == 0 ) gduthp[ifile]->Draw("AP"); else gduthp[ifile]->Draw("sameP"); leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthp1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthp2[ifile].str().c_str()); } can[idx]->cd(2); if( ifile == 0 ) gduthm[ifile]->Draw("AP"); else gduthm[ifile]->Draw("sameP"); //leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthm1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthm2[ifile].str().c_str()); } } TCanvas *cdiff = new TCanvas("cdiff","duvsdtanthetadiff",1200,450); cdiff->Divide(2,1); cdiff->cd(1); TGraphErrors *gduthpdiff = diffTGraph(gduthp[0],gduthp[2],"TIB DECO - PEAK (v+)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthpdiff=new TF1("fduthpdiff","pol1",-0.5,0.5); gduthpdiff->Fit(fduthpdiff,"R"); gduthpdiff->Draw("AP"); float dwp = fduthpdiff->GetParameter(1); float dwperr = fduthpdiff->GetParError(1); float bp = fduthpdiff->GetParameter(0); float bperr = fduthpdiff->GetParError(0); stringstream sduthp1diff; stringstream sduthp2diff; sduthp1diff << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2diff << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; t->SetTextColor(1); t->DrawLatex(0.15,0.85,sduthp1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthp2diff.str().c_str()); cdiff->cd(2); TGraphErrors *gduthmdiff = diffTGraph(gduthm[0],gduthm[2],"TIB DECO - PEAK (v-)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthmdiff=new TF1("fduthmdiff","pol1",-0.5,0.5); gduthmdiff->Fit(fduthmdiff,"R"); gduthmdiff->Draw("AP"); float dwm = fduthmdiff->GetParameter(1); float dwmerr = fduthmdiff->GetParError(1); float bm = fduthmdiff->GetParameter(0); float bmerr = fduthmdiff->GetParError(0); stringstream sduthm1diff; stringstream sduthm2diff; sduthm1diff << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2diff << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; t->DrawLatex(0.15,0.85,sduthm1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthm2diff.str().c_str()); idx++; } for(unsigned int ican=0;ican<ncan;ican++){ can[ican]->Modified(); can[ican]->Update(); if(printgif) can[ican]->Print(Form("plots/%s_TIB.gif",cantitles.at(ican))); } }
int main(int argc, char** argv) { gROOT->SetStyle("Plain"); gStyle->SetPalette(1); TApplication* theApp = new TApplication("example",&argc, argv); // load ntuple TChain *chain = new TChain ("myanalysis/EcalAnalysisTree","EcalAnalysisTree") ; //FIXME EcalTreeContent treeVars; // setBranchAddresses(chain, treeVars); chain->Add("/gwpool/users/deguio/NTUPLES/SpikesCommissioning2010_GOODCOLL_May6_MERGED.root"); //dal run 134520: 7TeV phase 2 int nEntries = (int)chain->GetEntries() ; cout << "FOUND " << nEntries << " ENTRIES\n" << endl;; //ecalVariables variables unsigned int runId; unsigned int eventId; unsigned int eventNaiveId; int nEcalRecHits; float ecalRecHitType[100]; float ecalRecHitEnergy[100]; float ecalRecHitIEta[100]; float ecalRecHitIPhi[100]; float ecalRecHitTime[100]; int ecalRecHitRawId[100]; float ecalRecHitChi2[100]; float ecalRecHitOutOfTimeChi2[100]; int ecalRecHitRecoFlag[100]; float ecalRecHitMatrixFlag[100][5][5]; float ecalRecHitMatrix[100][5][5]; float ecalRecHitR9[100]; float ecalRecHitS4oS1[100]; int ecalDigis[100][10]; int ecalGainId[100][10]; int techL1Bit[64]; int algoL1Bit[128]; // Set branch addresses. chain -> SetBranchAddress("runId", &runId); chain -> SetBranchAddress("eventId", &eventId); chain -> SetBranchAddress("eventNaiveId", &eventNaiveId); chain -> SetBranchAddress("nEcalRecHits", &nEcalRecHits); chain -> SetBranchAddress("ecalRecHitType", ecalRecHitType); chain -> SetBranchAddress("ecalRecHitEnergy", ecalRecHitEnergy); chain -> SetBranchAddress("ecalRecHitIEta", ecalRecHitIEta); chain -> SetBranchAddress("ecalRecHitIPhi", ecalRecHitIPhi); chain -> SetBranchAddress("ecalRecHitTime", ecalRecHitTime); chain -> SetBranchAddress("ecalRecHitRawId", ecalRecHitRawId); chain -> SetBranchAddress("ecalRecHitChi2", ecalRecHitChi2); chain -> SetBranchAddress("ecalRecHitOutOfTimeChi2", ecalRecHitOutOfTimeChi2); chain -> SetBranchAddress("ecalRecHitRecoFlag", ecalRecHitRecoFlag); chain -> SetBranchAddress("ecalRecHitMatrixFlag", ecalRecHitMatrixFlag); chain -> SetBranchAddress("ecalRecHitMatrix", ecalRecHitMatrix); chain -> SetBranchAddress("ecalRecHitR9", ecalRecHitR9); chain -> SetBranchAddress("ecalRecHitS4oS1", ecalRecHitS4oS1); chain -> SetBranchAddress("ecalDigis", ecalDigis); chain -> SetBranchAddress("ecalGainId", ecalGainId); chain -> SetBranchAddress("techL1Bit", techL1Bit); chain -> SetBranchAddress("algoL1Bit", algoL1Bit); char outfileName[100]; sprintf(outfileName,"6May_fase_0ns.root"); TFile* saving = new TFile (outfileName,"recreate") ; saving->mkdir("shapes"); saving->cd ("shapes") ; TGraphErrors* gsample; char gname[100]; char gnameCanvas[100]; char gtitle[100]; int ievt=0; float EcalPhase; float tau = 43.; TH1F* spikeTime = new TH1F("spikeTime","spikeTime",100,-20.,20.); TH1F* goodTime = new TH1F("goodTime","goodTime",100,-20.,20); TH1F* spikeR9_goodDisc_Time = new TH1F("spikeR9_goodDisc_Time","spikeR9_goodDisc_Time",100,-20.,20); TH1F* goodR9_spikeDisc_Time = new TH1F("goodR9_spikeDisc_Time","goodR9_spikeDisc_Time",100,-20.,20); TH1F* deltaChi2 = new TH1F("deltaChi2","deltaChi2", 500, -50., 50.); TH1F* L_disc_spi = new TH1F("L_disc_spi","L_disc_spi", 200,0.,1.1); TH1F* L_disc_sci = new TH1F("L_disc_sci","L_disc_sci", 200,0.,1.1); TH2F* L_disc_vsTime_sci = new TH2F("L_disc_vsTime_sci","L_disc_vsTime_sci", 500,-50.,50.,110,0.,1.1); TH2F* L_disc_vsR9 = new TH2F("L_disc_vsR9","L_disc_vsR9", 110,0.,1.1,200,-0.5,1.5); TH2F* L_disc_vsTime_spi = new TH2F("L_disc_vsTime_spi","L_disc_vsTime_spi", 500,-50.,50.,110,0.,1.1); TH1F* sigmaIEtaIEtaDistr = new TH1F("sigmaIEtaIEtaDistr","sigmaIEtaIEtaDistr",10000.,0.,1000.); TGraph* eff = new TGraph; TGraph* effChi2; TGraph* effChi2OutOfTime; int nSpiTot = 0; int nSciTot = 0; int nSpiLdiscCut[100]; int nSciLdiscCut[100]; int nSpiChi2Cut[100]; int nSciChi2Cut[100]; int nSpiChi2OutOfTimeCut[100]; int nSciChi2OutOfTimeCut[100]; for (int count = 0; count < 100; ++count) { nSpiLdiscCut[count] = 0; nSciLdiscCut[count] = 0; nSpiChi2Cut[count] = 0; nSciChi2Cut[count] = 0; nSpiChi2OutOfTimeCut[count] = 0; nSciChi2OutOfTimeCut[count] = 0; } //loop over the events //for (int entry = 0 ; entry < nEntries; ++entry) { for (int entry = 0 ; entry < 150000; ++entry) { chain->GetEntry(entry) ; if (entry%10000==0) cout << " Analyzing entry " << entry << endl; //only 0ns phase if (runId > 134520) continue; for (int ihit =0 ; ihit < nEcalRecHits; ihit++) { if (ecalRecHitEnergy[ihit] < 3. ) continue; // E>3 GeV //if (ecalRecHitRecoFlag[ihit] == 2) continue; // not outOfTime //if (fabs(ecalRecHitTime[ihit]) > 4.) continue; // not outOfTime if (ecalRecHitType[ihit] != 0) continue; // solo barrel bool goodcluster = true; //tutti i cristalli intorno accesi e buoni! double e_5x5 = 0.; double meanDEta = 0; double meanDPhi = 0; for (int xx = 0; xx < 5; ++xx) { for (int yy = 0; yy < 5; ++yy) { if((ecalRecHitMatrixFlag[ihit][xx][yy] > 2 && ecalRecHitMatrixFlag[ihit][xx][yy] != 10) || ecalRecHitMatrixFlag[ihit][xx][yy] == -9999 ) { goodcluster = false; break; } e_5x5 += ecalRecHitMatrix[ihit][xx][yy]; meanDEta += ecalRecHitMatrix[ihit][xx][yy] * fabs(xx - 2); meanDPhi += ecalRecHitMatrix[ihit][xx][yy] * fabs(yy - 2); } if(goodcluster == false) break; } meanDEta /= e_5x5; meanDPhi /= e_5x5; // check gain switch bool gainSwitch = false; for (int isample = 0; isample < 10 ; isample++){ if ((isample > 0 && ecalGainId[ihit][isample] != ecalGainId[ihit][isample-1]) || ecalGainId[ihit][isample] !=1 ) { gainSwitch = true; break; } } // select on beam activity and gain and goodquality if ((techL1Bit[40]+techL1Bit[41])==0) continue; if (gainSwitch) continue; // reject pulses beyond G12 if (goodcluster == false) continue; //if all good -> cluster shape eval double numeratorIEtaIEta = 0; double numeratorIEtaIPhi = 0; double numeratorIPhiIPhi = 0; double denominator = 0; for (int xx = 0; xx < 5; ++xx) for (int yy = 0; yy < 5; ++yy) { double dEta = fabs(xx - 2) - meanDEta; //double w = std::max(0.0, w0 + log(ecalRecHitMatrix[ihit][xx][yy] / e_5x5)); double w = std::max(0.0, log(ecalRecHitMatrix[ihit][xx][yy] / e_5x5)); denominator += w; numeratorIEtaIEta += w * dEta*dEta; } double covIEtaIEta = 0.01745*0.01745 * numeratorIEtaIEta / denominator; double sigmaIEtaIEta = sqrt(covIEtaIEta); sigmaIEtaIEtaDistr->Fill(sigmaIEtaIEta); // graphs gsample = new TGraphErrors(); sprintf(gtitle,"shape_Run%d_Evt%d",runId,eventId ); sprintf(gname,"shape_%d",ievt); gsample->SetName(gname); gsample->SetTitle(gtitle); float ped = (ecalDigis[ihit][0] + ecalDigis[ihit][1] + ecalDigis[ihit][2])/3; int imax = 0; int maxAmpl = 0; int ithr = 0; for (int isample = 0; isample < 10 ; isample++) { // cerca il primo sample sopra soglia per definire il range di FIT if (ecalDigis[ihit][isample] >= ped+7.) ithr = isample; if (ecalDigis[ihit][isample] >= maxAmpl) { imax = isample; maxAmpl = ecalDigis[ihit][isample] ; } gsample->SetPoint(isample, double(isample)*25.,ecalDigis[ihit][isample]); gsample->SetPointError(isample,0.,0.9); } //tengo solo se il primo sopra soglia e' il quarto o il quinto //if (ithr > 4 || ithr < 3) continue; // fit functions //Ecal Shape with FLOATING phase TB shape //TF1 *fpulseShape = new TF1("fpulseShape",pulseShape,ithr*25-5.,240.,3); TF1 *fpulseShape = new TF1("fpulseShape",pulseShape,0.,240.,3); fpulseShape->SetLineColor(3); if (ecalRecHitS4oS1[ihit]>0.95) fpulseShape->SetLineColor(2); fpulseShape->SetParName(0,"Ped"); fpulseShape->SetParName(1,"A"); fpulseShape->SetParName(2,"T0"); fpulseShape->FixParameter(0,ped); // ped fpulseShape->SetParameter(1,maxAmpl - ped); // ampl fpulseShape->SetParameter(2,imax*25.); // T0 //fpulseShape->SetParLimits(2,2*25., 7*25.); // T0 lim fpulseShape->SetParLimits(2,0*25., 10*25.); // T0 lim gsample->Fit("fpulseShape","QSR+") ; // electonic pulse TF1 *fSinglePulse = new TF1("fSinglePulse",abnormalShape,0.,240.,4); //TF1 *fSinglePulse = new TF1("fSinglePulse",abnormalShape,ithr*25-5.,240.,4); //TF1 *fSinglePulse = new TF1("fSinglePulse",spikeShape,ithr*25-5.,230.,4); //marti - alessio fSinglePulse->SetLineColor(4); fSinglePulse->SetParName(0,"Ped"); fSinglePulse->SetParName(1,"A"); fSinglePulse->SetParName(2,"T0"); fSinglePulse->SetParName(3,"tau"); fSinglePulse->FixParameter(0,ped); // ped fSinglePulse->SetParameter(1,maxAmpl - ped); // amp fSinglePulse->SetParameter(2,imax*25.- tau); // T0 fSinglePulse->FixParameter(3,tau); // tau = 40.5 gsample->Fit("fSinglePulse","QSR+") ; //minimo taglio di qualita' sul fit float bloodi_sci = TMath::Prob(fpulseShape->GetChisquare(),fpulseShape->GetNDF()); float bloodi_spi = TMath::Prob(fSinglePulse->GetChisquare(),fSinglePulse->GetNDF()); if(bloodi_sci <= 0.00 && bloodi_spi <= 0.00) continue; //provo a discriminare //chi2 float chi2sci = fpulseShape->GetChisquare()/fpulseShape->GetNDF(); float chi2spi = fSinglePulse->GetChisquare()/fSinglePulse->GetNDF(); float deltachi2 = chi2spi-chi2sci; //if deltaChi2<0 -> spike //likelihood float Ldisc = 1./(1.+exp(-deltachi2/2.)); if(bloodi_sci <= 0.00) Ldisc = -0.2; if(bloodi_spi <= 0.00) Ldisc = 1.2; deltaChi2->Fill(deltachi2); L_disc_vsR9->Fill(ecalRecHitR9[ihit],Ldisc); if(ecalRecHitS4oS1[ihit] > 0.95) { ++nSpiTot; L_disc_spi->Fill(Ldisc); L_disc_vsTime_spi->Fill(ecalRecHitTime[ihit],Ldisc); } else if (ecalRecHitS4oS1[ihit] < 0.80) { if (fabs(ecalRecHitTime[ihit]) > 4.) continue; // not outOfTime FIXME ++nSciTot; L_disc_sci->Fill(Ldisc); L_disc_vsTime_sci->Fill(ecalRecHitTime[ihit],Ldisc); } for (int nn = 0; nn < 100; ++nn) { float discCut = (float)(nn+1)/100.; if(Ldisc > discCut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiLdiscCut[nn]; if(Ldisc > discCut && ecalRecHitS4oS1[ihit] < 0.80) ++nSciLdiscCut[nn]; float chi2Cut = (float)(nn+1) * 65/100.; if(ecalRecHitChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiChi2Cut[nn]; if(ecalRecHitOutOfTimeChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiChi2OutOfTimeCut[nn]; if(ecalRecHitChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] < 0.80) ++nSciChi2Cut[nn]; if(ecalRecHitOutOfTimeChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.80) ++nSciChi2OutOfTimeCut[nn]; } ievt++; delete gsample; delete fpulseShape; delete fSinglePulse; }//recHits }//event effChi2 = new TGraph(); effChi2OutOfTime = new TGraph(); //eff plots for (int nn = 0; nn < 100; ++nn) { eff->SetPoint(nn, (float)nSciLdiscCut[nn]/(float)nSciTot, 1. - (float)nSpiLdiscCut[nn]/(float)nSpiTot); effChi2->SetPoint(nn, (float)nSciChi2Cut[nn]/(float)nSciTot, 1. - (float)nSpiChi2Cut[nn]/(float)nSpiTot); effChi2OutOfTime->SetPoint(nn, (float)nSciChi2OutOfTimeCut[nn]/(float)nSciTot, 1. - (float)nSpiChi2OutOfTimeCut[nn]/(float)nSpiTot); } TCanvas* quadranti = new TCanvas("quadranti","quadranti"); quadranti->Divide(2,2); quadranti->cd(1); goodTime->GetXaxis()->SetTitle("Time (ns)"); goodTime->Draw(); quadranti->cd(2); spikeR9_goodDisc_Time->GetXaxis()->SetTitle("Time (ns)"); spikeR9_goodDisc_Time->Draw(); quadranti->cd(3); goodR9_spikeDisc_Time->GetXaxis()->SetTitle("Time (ns)"); goodR9_spikeDisc_Time->Draw(); quadranti->cd(4); spikeTime->GetXaxis()->SetTitle("Time (ns)"); spikeTime->Draw(); goodTime->Write(); spikeR9_goodDisc_Time->Write(); goodR9_spikeDisc_Time->Write(); spikeTime->Write(); TCanvas* c1 = new TCanvas("L_disc_vsR9","L_disc_vsR9"); L_disc_vsR9->GetXaxis()->SetTitle("R9"); L_disc_vsR9->GetYaxis()->SetTitle("disc = #frac{1}{1 + L1/L2}"); L_disc_vsR9->Draw("colz"); TCanvas* c2 = new TCanvas("L_disc","L_disc"); c2->SetLogy(); c2->SetGridy(); L_disc_spi->GetXaxis()->SetTitle("disc = #frac{1}{1 + L1/L2}"); L_disc_spi->SetLineColor(2); //L_disc_sci->SetFillColor(2); L_disc_spi->DrawNormalized(); L_disc_sci->SetLineColor(3); //L_disc_sci->SetFillColor(3); L_disc_sci->DrawNormalized("same"); deltaChi2->Write(); L_disc_vsR9->Write(); L_disc_spi->Write(); L_disc_sci->Write(); saving->cd(); effChi2->Write(); effChi2OutOfTime->Write(); sigmaIEtaIEtaDistr->Draw(); sigmaIEtaIEtaDistr->Write(); saving->Close () ; theApp->Run(); }
void scalefactor(int low_bin=2, int high_bin=30, float rho_start=4, float rho_end=12){ setStyle(); int Rlabel = 8; TFile* data_root = TFile::Open( Form("DataD_R%i.root", Rlabel) ); TFile* mc_root = TFile::Open( Form("MC_reweight_R%i.root", Rlabel) ); TString pf_type = "chs"; bool nPU_derived = false; bool rhoCentral = false; ifstream data_file("./plots/indirectRho/" + pf_type + Form("/Fall15_25nsV1_DATA_L1RC_AK%iPF", Rlabel) + pf_type + ".txt"); ifstream mc_file("./plots/indirectRho/" + pf_type + Form("/Fall15_25nsV1_MC_L1RC_AK%iPF", Rlabel) + pf_type + ".txt"); string data_line, mc_line; //read first line getline(data_file, data_line); getline(mc_file, mc_line); const int ETA_BINS = 82; double eta1[ETA_BINS], eta2[ETA_BINS], data_p0[ETA_BINS], data_p1[ETA_BINS], data_p2[ETA_BINS]; double mc_p0[ETA_BINS], mc_p1[ETA_BINS], mc_p2[ETA_BINS]; for (int i=0; getline(data_file,data_line); i++){ string str; int delim_pos; while (data_line.at(0) == ' ') //positive values of eta have space in front of them data_line.erase(0, 1); //loop over strings in data line for (int col_num=0; (delim_pos = data_line.find(' ')) != -1; col_num++){ str = data_line.substr(0, delim_pos); data_line.erase(0, delim_pos + 1); while (data_line.at(0) == ' ') //get rid of white space between columns data_line.erase(0, 1); if (col_num == 0) eta1[i] = stod(str); else if (col_num == 1) eta2[i] = stod(str); else if (col_num == 9) data_p0[i] = stod(str); else if (col_num == 10) data_p1[i] = stod(str); } //last column after loop data_p2[i] = stod(data_line); //mc line getline(mc_file, mc_line); while (mc_line.at(0) == ' ') //positive values of eta have space in front of them mc_line.erase(0, 1); //loop over strings in mc line for (int col_num=0; (delim_pos = mc_line.find(' ')) != -1; col_num++){ str = mc_line.substr(0, delim_pos); mc_line.erase(0, delim_pos + 1); while (mc_line.at(0) == ' ') //get rid of white space between columns mc_line.erase(0, 1); if (col_num == 9) mc_p0[i] = stod(str); else if (col_num == 10) mc_p1[i] = stod(str); } //last column after loop mc_p2[i] = stod(mc_line); } data_file.close(); mc_file.close(); TString hname; if (nPU_derived){ if (rhoCentral) hname = "p_rhoCentral0_nPU"; else hname = "p_rho_nPU"; } else{ if (rhoCentral) hname = "p_rhoCentral0_nPV"; else hname = "p_rho_nPV"; } TProfile* data_rho_nPU = (TProfile*) data_root->Get(hname); for (int i=1; i<=100; i++) cout << i << "\t" << data_rho_nPU->GetBinCenter(i) << "\t" << data_rho_nPU->GetBinContent(i) << endl; //int low_bin = 2, high_bin = 30; cout << low_bin << "\t" << high_bin << endl; TProfile* mc_rho_nPU = (TProfile*) mc_root->Get(hname); ofstream writeFile(Form("./plots/scalefactor/Fall15_25nsV1_DataMcSF_L1RC_AK%iPF", Rlabel) + pf_type + ".txt"); writeFile << "{1 JetEta 1 Rho [0]+[1]*x+[2]*pow(x,2) Data/MC L1FastJet}" << endl; TF1* fit = new TF1("fit", "1++x++x*x"); fit->SetLineColor(1); fit->SetLineWidth(2); //float rho_start = 4; //float rho_end = 12; int size; if (nPU_derived) size = (rho_end-rho_start+0.5)*2; else size = rho_end-rho_start+1; for (int i=0; i<ETA_BINS; i++){ vector<double> rho, scale_factor, sf_error; for (int j=0; j<size; j++){ double data_rho; if (nPU_derived) data_rho = rho_start+j/2.0; else data_rho = rho_start+j; // if (data_rho==9 || data_rho==9.5) continue; rho.push_back(data_rho); double data_offset = data_p0[i] + data_p1[i]*data_rho + data_p2[i]*data_rho*data_rho; int data_mu_bin = 0; data_rho_nPU->GetBinWithContent(data_rho, data_mu_bin, low_bin, high_bin, 1); double data_mu = data_rho_nPU->GetBinCenter( data_mu_bin ); double mc_rho = mc_rho_nPU->GetBinContent( mc_rho_nPU->FindBin( data_mu ) ); double mc_offset = mc_p0[i] + mc_p1[i]*mc_rho + mc_p2[i]*mc_rho*mc_rho; scale_factor.push_back( data_offset / mc_offset ); sf_error.push_back( 0.02*scale_factor.back() ); } TGraphErrors* graph = new TGraphErrors(rho.size(), &rho[0], &scale_factor[0], 0, &sf_error[0]); graph->Fit(fit, "Q"); writeFile << eta1[i] << setw(8) << eta2[i] << setw(8) << 5 << setw(6) << 0 << setw(6) << 200 << setw(15) << fit->GetParameter(0) << setw(15) << fit->GetParameter(1) << setw(15) << fit->GetParameter(2) << endl; TCanvas* c = new TCanvas("c", "c", 600, 600); TH1F* h = new TH1F("h", "h", size-1, rho_start, rho_end); int topY = 2; h->GetXaxis()->SetTitle("#rho_{Data} (GeV)"); h->GetYaxis()->SetTitle("Scale Factor"); h->GetYaxis()->SetTitleOffset(1.05); h->GetYaxis()->SetRangeUser(0, topY); h->Draw(); graph->SetMarkerStyle(20); graph->SetMarkerColor(1); graph->Draw("psame"); TLatex text; text.SetNDC(); text.SetTextSize(0.04); if (pf_type.EqualTo("all")) text.DrawLatex(0.17, 0.96, Form("AK%i PF %4.3f #leq #eta #leq %4.3f", Rlabel, eta1[i], eta2[i]) ); else text.DrawLatex(0.17, 0.96, Form("AK%i PF%s %4.3f #leq #eta #leq %4.3f", Rlabel, pf_type.Data(), eta1[i], eta2[i]) ); text.DrawLatex(0.2, 0.88, Form("#chi^{2}/ndof = %4.2f/%i", fit->GetChisquare(), fit->GetNDF() ) ); text.DrawLatex(0.2, 0.84, Form("p0 = %4.3f #pm %4.3f", fit->GetParameter(0), fit->GetParError(0) ) ); text.DrawLatex(0.2, 0.8, Form("p1 = %4.3f #pm %4.3f", fit->GetParameter(1), fit->GetParError(1) ) ); text.DrawLatex(0.2, 0.76, Form("p2 = %4.4f #pm %4.4f", fit->GetParameter(2), fit->GetParError(2) ) ); text.SetTextSize(0.035); text.SetTextColor(1); text.SetTextFont(42); text.DrawLatex(0.8, 0.96, "#sqrt{s} = 13 TeV"); cout << fit->GetChisquare() / fit->GetNDF() << endl; c->Print("./plots/scalefactor/scalefactor_PF" + pf_type + Form("_eta%4.3f.pdf", eta1[i]) ); delete h; delete c; } writeFile.close(); }
void Pythia8_Dijet30_result_JER_akPu4PF_((abs(refeta)<2)&&(hiBin>60))&&(refpt>30)_refeta() { //=========Macro generated from canvas: Can_result_3/ //========= (Mon Apr 18 04:08:04 2016) by ROOT version6.02/13 TCanvas *Can_result_3 = new TCanvas("Can_result_3", "",18,40,700,500); gStyle->SetOptFit(1); Can_result_3->Range(-2.75,0.1715425,2.75,0.2926317); Can_result_3->SetFillColor(0); Can_result_3->SetBorderMode(0); Can_result_3->SetBorderSize(2); Can_result_3->SetFrameBorderMode(0); Can_result_3->SetFrameBorderMode(0); TMultiGraph *multigraph = new TMultiGraph(); multigraph->SetName("name"); multigraph->SetTitle("JER_akPu4PF"); Double_t Graph_fx1007[9] = { -1.8, -1.4, -1, -0.6, -0.2, 0.2, 0.6, 1, 1.6}; Double_t Graph_fy1007[9] = { 0.2213775, 0.2313726, 0.212349, 0.1992318, 0.2015521, 0.2047929, 0.2065286, 0.2141753, 0.2298097}; Double_t Graph_fex1007[9] = { 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4}; Double_t Graph_fey1007[9] = { 0.001529502, 0.001378741, 0.001274153, 0.001286487, 0.00132694, 0.001354738, 0.001397823, 0.001305814, 0.001034891}; TGraphErrors *gre = new TGraphErrors(9,Graph_fx1007,Graph_fy1007,Graph_fex1007,Graph_fey1007); gre->SetName("Graph"); gre->SetTitle("some title_0"); gre->SetFillColor(1); gre->SetFillStyle(0); TH1F *Graph_Graph1007 = new TH1F("Graph_Graph1007","some title_0",100,-2.4,2.4); Graph_Graph1007->SetMinimum(0.1944648); Graph_Graph1007->SetMaximum(0.236232); Graph_Graph1007->SetDirectory(0); Graph_Graph1007->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); Graph_Graph1007->SetLineColor(ci); Graph_Graph1007->GetXaxis()->SetLabelFont(42); Graph_Graph1007->GetXaxis()->SetLabelSize(0.035); Graph_Graph1007->GetXaxis()->SetTitleSize(0.035); Graph_Graph1007->GetXaxis()->SetTitleFont(42); Graph_Graph1007->GetYaxis()->SetLabelFont(42); Graph_Graph1007->GetYaxis()->SetLabelSize(0.035); Graph_Graph1007->GetYaxis()->SetTitleSize(0.035); Graph_Graph1007->GetYaxis()->SetTitleFont(42); Graph_Graph1007->GetZaxis()->SetLabelFont(42); Graph_Graph1007->GetZaxis()->SetLabelSize(0.035); Graph_Graph1007->GetZaxis()->SetTitleSize(0.035); Graph_Graph1007->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1007); multigraph->Add(gre,""); Double_t Graph_fx1008[20] = { -1.9, -1.7, -1.5, -1.2, -0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 1}; Double_t Graph_fy1008[20] = { 0.2311591, 0.2477474, 0.2655955, 0.2576075, 0.2220231, 0.206768, 0.2064983, 0.2020811, 0.19917, 0.2115871, 0.1952014, 0.1965805, 0.2158946, 0.2003286, 0.213619, 0.213695, 0.2466632, 0.2597152, 0.2553281, 0.2344014}; Double_t Graph_fex1008[20] = { 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1}; Double_t Graph_fey1008[20] = { 0.009894431, 0.01000488, 0.01052403, 0.009913006, 0.008527985, 0.007570562, 0.007309829, 0.007320613, 0.00699798, 0.00776784, 0.007146697, 0.00713059, 0.007530691, 0.007364154, 0.007896077, 0.007855752, 0.009496669, 0.01034782, 0.01046585, 0.009252961}; gre = new TGraphErrors(20,Graph_fx1008,Graph_fy1008,Graph_fex1008,Graph_fey1008); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetFillStyle(0); gre->SetLineColor(2); gre->SetMarkerColor(2); TH1F *Graph_Graph1008 = new TH1F("Graph_Graph1008","Graph",100,-2.4,2.4); Graph_Graph1008->SetMinimum(0.1792482); Graph_Graph1008->SetMaximum(0.284926); Graph_Graph1008->SetDirectory(0); Graph_Graph1008->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1008->SetLineColor(ci); Graph_Graph1008->GetXaxis()->SetLabelFont(42); Graph_Graph1008->GetXaxis()->SetLabelSize(0.035); Graph_Graph1008->GetXaxis()->SetTitleSize(0.035); Graph_Graph1008->GetXaxis()->SetTitleFont(42); Graph_Graph1008->GetYaxis()->SetLabelFont(42); Graph_Graph1008->GetYaxis()->SetLabelSize(0.035); Graph_Graph1008->GetYaxis()->SetTitleSize(0.035); Graph_Graph1008->GetYaxis()->SetTitleFont(42); Graph_Graph1008->GetZaxis()->SetLabelFont(42); Graph_Graph1008->GetZaxis()->SetLabelSize(0.035); Graph_Graph1008->GetZaxis()->SetTitleSize(0.035); Graph_Graph1008->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1008); multigraph->Add(gre,""); multigraph->Draw("AP"); multigraph->GetXaxis()->SetTitle("refeta"); multigraph->GetXaxis()->SetLabelFont(42); multigraph->GetXaxis()->SetLabelSize(0.035); multigraph->GetXaxis()->SetTitleSize(0.035); multigraph->GetXaxis()->SetTitleFont(42); multigraph->GetYaxis()->SetTitle("#sigma_{Reco./Gen.}"); multigraph->GetYaxis()->SetLabelFont(42); multigraph->GetYaxis()->SetLabelSize(0.035); multigraph->GetYaxis()->SetTitleSize(0.035); multigraph->GetYaxis()->SetTitleFont(42); TLegend *leg = new TLegend(0.68,0.7,0.88,0.85,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("Graph","allJets","l"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph","from chris","l"); entry->SetLineColor(2); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TLatex * tex = new TLatex(0.35,0.8,"#bf{#color[2]{|#eta_{jet}|<2.0 & refpt>30}}"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(24); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.17,0.17,"Centrality:30-100%"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(24); tex->SetLineWidth(2); tex->Draw(); TPaveText *pt = new TPaveText(0.3743391,0.9365254,0.6256609,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); AText = pt->AddText("JER_akPu4PF"); pt->Draw(); Can_result_3->Modified(); Can_result_3->cd(); Can_result_3->SetSelected(Can_result_3); }
void minuitFit() { gStyle->SetOptFit(1111); gStyle->SetOptStat(0); Bool_t makePDF = checkMakePDF(); char name[1000]; sprintf(name,"/Users/zach/Research/pythia/ptHatTemplate/outputs/currentB.root"); TFile *fB = new TFile(name,"READ"); sprintf(name,"/Users/zach/Research/pythia/ptHatTemplate/outputs/currentC.root"); TFile *fC = new TFile(name,"READ"); sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root"); TFile *fD = new TFile(name,"READ"); if (fB->IsOpen()==kFALSE || fC->IsOpen()==kFALSE) { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl << "Looking for currentB.root, currentC.root, and currentData.root" << std::endl; exit(1); } // Set constants and projection bins (from header file anaConst, analysis constants) Float_t lowpt[numPtBins],highpt[numPtBins]; for(Int_t c=0; c< numPtBins; c++){ lowpt[c] = anaConst::lpt[c]; highpt[c] = anaConst::hpt[c]; } Float_t hptCut=anaConst::hptCut; Double_t p00[numPtBins],p01[numPtBins],p20[numPtBins],p21[numPtBins]; Double_t e00[numPtBins],e01[numPtBins],e20[numPtBins],e21[numPtBins]; Double_t pC0[numPtBins],pC1[numPtBins],eC0[numPtBins],eC1[numPtBins]; Double_t Rb0[numPtBins],Rb2[numPtBins],RbC[numPtBins],pT[numPtBins]; Double_t eb0[numPtBins],eb2[numPtBins],ebC[numPtBins],dx[numPtBins]; Double_t ptOFF1[numPtBins],ptOFF2[numPtBins]; Int_t plotCount0 = 0, plotCount2 = 0, plotCount = 0; // Make Canvases TCanvas* deltaPhi = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000); TCanvas* deltaPhi2 = new TCanvas("deltaPhi2","Pythia Delta Phi",150,0,1150,1000); TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000); TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000); TCanvas* fitResultC = new TCanvas("fitResultC","RB Extraction Combined Trigs",150,0,1150,1000); deltaPhi ->Divide(3,3); deltaPhi2 ->Divide(3,3); fitResult0->Divide(3,4); fitResult2->Divide(3,4); fitResultC->Divide(3,4); // Get and Draw histos TPaveText* lbl[numPtBins]; TPaveText* stat[3][numPtBins]; char statLabel[100]; char textLabel[100]; Int_t plotbin; Float_t norm0,norm2,normB,normC; // Get ptbin independent hists histoNorms = (TH1F*)fD->Get("histoNorms"); bPtNorms = (TH1F*)fB->Get("ptNorm"); cPtNorms = (TH1F*)fC->Get("ptNorm"); for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) { norm0 = histoNorms->GetBinContent(histoNorms->GetBin(1,ptbin+1)); norm2 = histoNorms->GetBinContent(histoNorms->GetBin(3,ptbin+1)); normB = bPtNorms->GetBinContent(bPtNorms->GetBin(ptbin+1)); normC = cPtNorms->GetBinContent(cPtNorms->GetBin(ptbin+1)); if(norm0 == 0) { cout << ptbin << " For this bin, some norm0 = 0" << endl; continue; } if( norm2 == 0 ) { cout << ptbin << " For this bin, some norm2 = 0" << endl; continue; } if( normB == 0 ) { cout << ptbin << " For this bin, some normB = 0" << endl; continue; } if(normC == 0) { cout << ptbin << " For this bin, some normC = 0" << endl; continue; } plotbin = ptbin; // Init necessary plotting tools lbl[ptbin] = new TPaveText(.15,.15,.35,.23,Form("NB NDC%i",ptbin)); sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]); lbl[ptbin]->AddText(textLabel); lbl[ptbin]->SetFillColor(kWhite); projB[ptbin] = (TH1D*)fB->Get(Form("delPhi_%i",ptbin)); projC[ptbin] = (TH1D*)fC->Get(Form("delPhi_%i",ptbin)); projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin)); projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin)); // Do any rebinning Int_t RB = 1; projB[ptbin]->Rebin(RB); projC[ptbin]->Rebin(RB); projData0[ptbin]->Rebin(RB); projData2[ptbin]->Rebin(RB); // Clone to make plots without effecting fits plotD0[ptbin] = (TH1D*) projData0[ptbin]->Clone(); plotD2[ptbin] = (TH1D*) projData2[ptbin]->Clone(); plotB[ptbin] = (TH1D*) projB[ptbin]->Clone(); plotC[ptbin] = (TH1D*) projC[ptbin]->Clone(); // Set features that are the same in plots projData0[ptbin]->SetLineColor(kBlue); projData2[ptbin]->SetLineColor(kGreen+3); projB[ptbin]->SetLineColor(kRed); projC[ptbin]->SetLineColor(kBlack); projC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5); plotD0[ptbin]->SetLineColor(kBlue); plotD2[ptbin]->SetLineColor(kGreen+3); plotD0[ptbin]->SetMarkerStyle(20); plotD0[ptbin]->SetMarkerColor(kBlue); plotD0[ptbin]->SetMarkerSize(0.4); plotB[ptbin]->SetLineColor(kRed); plotC[ptbin]->SetLineColor(kBlack); plotC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5); combData[ptbin] = (TH1D*) projData0[ptbin]->Clone(); combData[ptbin] -> Add(projData2[ptbin]); combData[ptbin]->SetLineColor(kBlue); combData[ptbin]->SetMarkerStyle(20); combData[ptbin]->SetMarkerColor(kBlue); combData[ptbin]->SetMarkerSize(0.4); combData[ptbin]->SetTitle(""); // Normalize projB[ptbin] -> Scale(1/normB); projC[ptbin] -> Scale(1/normC); projData0[ptbin] -> Scale(1/norm0); projData2[ptbin] -> Scale(1/norm2); plotD0[ptbin] -> Scale(1/norm0); plotD2[ptbin] -> Scale(1/norm2); plotB[ptbin] -> Scale(1/(normB)); plotC[ptbin] -> Scale(1/(normC)); combData[ptbin] -> Scale(1/(norm0+norm2)); /*projB[ptbin] -> Scale(projData0[ptbin]->GetBinContent(70)/projB[ptbin]->GetBinContent(70)); projC[ptbin] -> Scale(projData0[ptbin]->GetBinContent(70)/projC[ptbin]->GetBinContent(70)); plotB[ptbin] -> Scale(projData0[ptbin]->GetBinContent(70)/plotB[ptbin]->GetBinContent(70)); plotC[ptbin] -> Scale(projData0[ptbin]->GetBinContent(70)/plotC[ptbin]->GetBinContent(70)); */ // Draw Templates on own plots if(ptbin+1 <= 9) deltaPhi->cd(plotbin+1); if(ptbin+1 > 9) deltaPhi2->cd(ptbin-8); plotC[ptbin]->GetYaxis()->SetRangeUser(-.1,0.5); plotC[ptbin] -> Draw("hist"); plotB[ptbin] -> Draw("same hist"); plotD0[ptbin] -> Draw("same"); plotD2[ptbin] -> Draw("same"); lbl[ptbin] -> Draw("same"); TLegend* leg = new TLegend(0.65,0.6,0.85,0.85); leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe"); leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe"); leg->AddEntry(projData0[ptbin],"HT0","lpe"); leg->AddEntry(projData2[ptbin],"HT2","lpe"); leg->Draw(); ///////////////////// // Do the actual fits ///////////////////// cout << "!!!!!!! HT0 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; currentPtBin = ptbin; double arglist[10];int ierflg=0; TMinuit *gMinuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params gMinuit->SetMaxIterations(50000); gMinuit->SetFCN(chi2_0); arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma gMinuit->mnexcm("SET ERR",arglist,1,ierflg); //starting values double vstart[2]={0.3,1}; //frac double step[2]={0.01,0.01}; //starting step gMinuit->mnparm(0,"BtoNPE frac",vstart[0],step[0],0.000,2,ierflg); gMinuit->mnparm(1,"Scale Factor",vstart[1],step[1],0.000,2,ierflg); //simple scan to get better start values gMinuit->mnexcm("SCAN",arglist,0,ierflg); cout<<"done with first scan!"<<endl; //minimization arglist[0]=5000; //maxcalls arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before gMinuit->mnexcm("MINIMIZE",arglist,2,ierflg); cout<< "done with fit! Error Flag: " << ierflg << endl; //fit results double dum1,dum2; TString *str0 = new TString("BtoNPE frac"); TString *str1 = new TString("Scale Factor"); gMinuit->mnpout(0,*str0,p01[ptbin],e01[ptbin],dum1,dum2,ierflg); gMinuit->mnpout(1,*str1,p00[ptbin],e00[ptbin],dum1,dum2,ierflg); cout << endl << endl << "HT0 PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl << "rB: " << p01[ptbin] << " rC: " << p00[ptbin] << endl << "erB: " << e01[ptbin] << " erC: " << e00[ptbin] << endl << endl; //Print results double amin,edm,errdef; int nvpar,nparx,icstat; gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat); gMinuit->mnprin(4,amin); // assign to plotting variables if(highpt[ptbin] < 6) { pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; dx[plotCount0] = 0.; ptOFF1[plotCount0] = pT[ptbin]; Rb0[plotCount0] = p01[ptbin];///(p01[ptbin]+p00[ptbin]); eb0[plotCount0] = e01[ptbin]; plotCount0++; } // Plot results fitResult0->cd(ptbin+1); TH1D* dClone = (TH1D*) projData0[ptbin]->Clone(); TH1D* cClone = (TH1D*) projC[ptbin]->Clone(); TH1D* bClone = (TH1D*) projB[ptbin]->Clone(); stat[0][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin)); sprintf(statLabel,"Chi2/NDF: %.2f/%.0f",curChi2,curNDF); stat[0][ptbin]->InsertText(statLabel); stat[0][ptbin]->SetFillColor(kWhite); cClone->Scale((1.-p01[ptbin])*p00[ptbin]); bClone->Scale(p00[ptbin]*p01[ptbin]); // scale by contribution param cClone->Add(bClone); //cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.4); dClone->Draw(); cClone->Draw("same"); stat[0][ptbin]->Draw("same"); lbl[ptbin]->Draw("same"); cout << "!!!!!!! HT2 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; fitResult2->cd(ptbin+1); currentPtBin = ptbin; TMinuit *g2Minuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params g2Minuit->SetMaxIterations(50000); g2Minuit->SetFCN(chi2_2); arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma g2Minuit->mnexcm("SET ERR",arglist,1,ierflg); //starting values double vstart2[2]={0.3,1}; //frac double step2[2]={0.01,0.01}; //starting step g2Minuit->mnparm(0,"BtoNPE frac",vstart2[0],step2[0],0.000,2,ierflg); g2Minuit->mnparm(1,"Scale Factor",vstart2[1],step2[1],0.000,2,ierflg); //simple scan to get better start values g2Minuit->mnexcm("SCAN",arglist,0,ierflg); cout<<"done with first scan!"<<endl; //minimization arglist[0]=5000; //maxcalls arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before g2Minuit->mnexcm("MINIMIZE",arglist,2,ierflg); cout<< "done with fit! Error Flag: " << ierflg << endl; //fit results TString *str2 = new TString("BtoNPE frac"); TString *str3 = new TString("Scale Factor"); g2Minuit->mnpout(0,*str2,p21[ptbin],e21[ptbin],dum1,dum2,ierflg); g2Minuit->mnpout(1,*str3,p20[ptbin],e20[ptbin],dum1,dum2,ierflg); cout << endl << endl << "HT2 PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl << "rB: " << p21[ptbin] << " rC: " << p20[ptbin] << endl << "erB: " << e21[ptbin] << " erC: " << e20[ptbin] << endl << endl; //Print results g2Minuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat); g2Minuit->mnprin(4,amin); // assign to plotting variables if(highpt[ptbin] > 3.6) { pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; ptOFF2[plotCount2] = pT[ptbin]; Rb2[plotCount2] = p21[ptbin];///(p21[ptbin]+p20[ptbin]); eb2[plotCount2] = e21[ptbin]; plotCount2++; } // Plot results fitResult2->cd(ptbin+1); dClone = (TH1D*) projData2[ptbin]->Clone(); cClone = (TH1D*) projC[ptbin]->Clone(); bClone = (TH1D*) projB[ptbin]->Clone(); stat[2][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[2][ptbin]->InsertText(statLabel); stat[2][ptbin]->SetFillColor(kWhite); cClone->Scale((1.-p21[ptbin])*p20[ptbin]); bClone->Scale(p20[ptbin]*p21[ptbin]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.4); dClone->Draw(); cClone->Draw("same"); stat[2][ptbin]->Draw("same"); lbl[ptbin]->Draw("same"); cout << "!!!!!!! HT0&2 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; fitResultC->cd(ptbin+1); currentPtBin = ptbin; TMinuit *gCMinuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params gCMinuit->SetMaxIterations(50000); gCMinuit->SetFCN(chi2_C); arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma gCMinuit->mnexcm("SET ERR",arglist,1,ierflg); //starting values double vstartC[2]={0.3,1}; //frac double stepC[2]={0.01,0.01}; //starting step gCMinuit->mnparm(0,"BtoNPE frac",vstartC[0],stepC[0],0.000,2,ierflg); gCMinuit->mnparm(1,"Scale Factor",vstartC[1],stepC[1],0.000,2,ierflg); //simple scan to get better start values gCMinuit->mnexcm("SCAN",arglist,0,ierflg); cout<<"done with first scan!"<<endl; //minimization arglist[0]=5000; //maxcalls arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before gCMinuit->mnexcm("MINIMIZE",arglist,2,ierflg); cout<< "done with fit! Error Flag: " << ierflg << endl; //fit results TString *str4 = new TString("BtoNPE frac"); TString *str5 = new TString("Scale Factor"); gCMinuit->mnpout(0,*str4,pC1[ptbin],eC1[ptbin],dum1,dum2,ierflg); gCMinuit->mnpout(1,*str5,pC0[ptbin],eC0[ptbin],dum1,dum2,ierflg); cout << endl << endl << "HTC PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl << "rB: " << pC1[ptbin] << " rC: " << pC0[ptbin] << endl << "erB: " << eC1[ptbin] << " erC: " << eC0[ptbin] << endl << endl; //Print results gCMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat); gCMinuit->mnprin(4,amin); // assign to plotting variables pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; RbC[plotCount] = pC1[ptbin];///(p21[ptbin]+p20[ptbin]); ebC[plotCount] = eC1[ptbin]; plotCount++; } // Get FONLL Calc Int_t l=0; char line[1000]; Float_t xF[100],yF[100],minF[100],maxF[100]; ifstream fp("/Users/zach/Research/pythia/ptHatTemplate/FONLL.txt",ios::in); while (!fp.eof()){ fp.getline(line,1000); sscanf(line,"%f %f %f %f",&xF[l],&yF[l],&minF[l],&maxF[l]); // printf("L: %f %f\n",xF[l],yF[l]); l++; } fp.close(); // Get Previous Analysis Int_t p=0; Float_t xP[100],yP[100],dyP[100]; ifstream fp1("/Users/zach/Research/pythia/ptHatTemplate/run5_6.txt",ios::in); while (!fp1.eof()){ fp1.getline(line,1000); sscanf(line,"%f %f %f",&xP[p],&yP[p],&dyP[p]); // printf("L: %f %f\n",xF[l],yF[l]); p++; } fp1.close(); //cout << "at bottom contrib plot" << endl; TCanvas* c1 = new TCanvas("c1","Bottom Contribution",150,0,1150,1000); TGraphErrors *gr0 = new TGraphErrors(plotCount0-1,ptOFF1,Rb0,dx,eb0); TGraphErrors *gr2 = new TGraphErrors(plotCount2-1,ptOFF2,Rb2,dx,eb2); TGraphErrors *grC = new TGraphErrors(plotCount-1,pT,RbC,dx,ebC); TGraphErrors *grF = new TGraphErrors(l-1,xF,yF); TGraphErrors *grFmax = new TGraphErrors(l-1,xF,maxF); TGraphErrors *grFmin = new TGraphErrors(l-1,xF,minF); TGraphErrors *grP = new TGraphErrors(p-1,xP,yP,0,dyP); c1->cd(1); gr0->SetTitle("Bottom Contribution"); gr0->GetXaxis()->SetTitle("p_{T,e}"); gr0->GetYaxis()->SetTitle("#frac{r_{B}}{(r_{B}+r_{C})}"); gr0->SetMarkerStyle(20); gr0->SetMarkerSize(1); gr0->SetLineColor(kBlue); gr0->SetMarkerColor(kBlue); gr2->SetMarkerStyle(22); gr2->SetMarkerSize(1); gr2->SetLineColor(kRed); gr2->SetMarkerColor(kRed); grC->SetMarkerStyle(21); grC->SetMarkerSize(1); grC->SetLineColor(kRed); grC->SetMarkerColor(kRed); gr0->GetXaxis()->SetLimits(1,14); gr0->GetYaxis()->SetRangeUser(0,1); grF->SetLineStyle(1); grFmax->SetLineStyle(2); grFmin->SetLineStyle(2); grP->SetMarkerStyle(33); grP->SetMarkerColor(kBlack); gr0->Draw("AP"); // grC->Draw("same P"); gr2->Draw("same P"); grF->Draw("same"); grFmax->Draw("same"); grFmin->Draw("same"); grP->Draw("same P"); TLegend* leg2 = new TLegend(0.15,0.68,0.4,0.85); leg2->AddEntry(gr0,"High Tower 0 Trigs","pe"); leg2->AddEntry(gr2,"High Tower 2 Trigs","pe"); // leg2->AddEntry(grC,"Combined Trigs","pe"); leg2->AddEntry(grF,"FONLL (Uncertainty: Scale Only)","l"); leg2->AddEntry(grP,"Run 5/6 Analysis (Stat Uncertainty)","pe"); leg2->Draw("same"); // Make PDF with output canvases if(makePDF) { //Set front page TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900); fp->cd(); TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99); bLabel->SetFillColor(38); bLabel->Draw(); TLatex tl; tl.SetNDC(); tl.SetTextColor(kWhite); tl.SetTextSize(0.033); char tlName[100]; char tlName2[100]; TString titlename = FileName; int found = titlename.Last('/'); if(found >= 0){ titlename.Replace(0, found+1, ""); } sprintf(tlName, "RUN 12 NPE-h #Delta#phi Correlations"); tl.SetTextSize(0.05); tl.SetTextColor(kWhite); tl.DrawLatex(0.05, 0.92,tlName); TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12); bFoot->SetFillColor(38); bFoot->Draw(); tl.SetTextColor(kWhite); tl.SetTextSize(0.05); tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString()); tl.SetTextColor(kBlack); tl.SetTextSize(0.03); tl.DrawLatex(0.1, 0.14, titlename); sprintf(tlName,"TEST"); tl.DrawLatex(0.1, 0.8,tlName); // Place canvases in order TCanvas* temp = new TCanvas(); sprintf(name, "FFOutput/%s.pdf[", FileName); temp->Print(name); sprintf(name, "FFOutput/%s.pdf", FileName); temp = deltaPhi; temp->Print(name); temp = fitResult0; temp->Print(name); temp = fitResult2; temp->Print(name); temp = fitResultC; temp->Print(name); temp = c1; temp->Print(name); sprintf(name, "FFOutput/%s.pdf]", FileName); temp->Print(name); } }
void DrawClus(bool Flag_err,TTree* tree,Double_t *errx,char* varToPlot, char* cond, Int_t kColor, Int_t kMarker, char* Title,char* xTitle,char* yTitle, TLegend *leg, char* cLeg,Double_t downlim,Double_t uplim){ TGraphErrors* g; tree->Draw(varToPlot, cond,"goff"); cout << tree->GetSelectedRows() << endl; if(tree->GetSelectedRows()){ if(Flag_err) g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,tree->GetV3()); else g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,errx); g->SetMarkerStyle(kMarker); g->SetMarkerSize(0.9); g->SetMarkerColor(kColor); g->SetTitle(Title); g->GetXaxis()->SetTitle(xTitle); g->GetXaxis()->CenterTitle(); g->GetYaxis()->SetTitle(yTitle); g->GetYaxis()->CenterTitle(); g->GetYaxis()->SetRangeUser(downlim,uplim); g->Draw("Ap"); leg->AddEntry(g, cLeg,"p"); }else{ cout << "NO rows selected for leave " << varToPlot << endl; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // DY // // channel = SF, MuMu, EE // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void DY(Double_t &yield, Double_t &statError, Double_t &systError, Double_t &scaleFactor, Int_t njet, TString channel, TString directory, Bool_t useDataDriven, Int_t printLevel, Bool_t drawR = false) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Input files // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TString path = Form("%s/%djet/%s/", directory.Data(), njet, channel.Data()); TFile* inputDYSF = new TFile(path + "DY.root"); TFile* inputZZSF = new TFile(path + "ZZ.root"); TFile* inputWZSF = new TFile(path + "WZ.root"); TFile* inputDataSF = new TFile(path + "DataRun2012_Total.root"); TFile* inputDataOF = new TFile(Form("%s/%djet/OF/DataRun2012_Total.root", directory.Data(), njet)); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Input histograms // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TH1F* hNinDYSF [numberMetCuts]; TH1F* hNinWZSF [numberMetCuts]; TH1F* hNinZZSF [numberMetCuts]; TH1F* hNinDataSF[numberMetCuts]; TH1F* hNinDataOF[numberMetCuts]; TH1F* hNoutDYSF [numberMetCuts]; TH1F* hNoutWZSF [numberMetCuts]; TH1F* hNoutZZSF [numberMetCuts]; TH1F* hNoutDataSF[numberMetCuts]; TH1F* hNoutDataOF[numberMetCuts]; for (UInt_t nC=0; nC<numberMetCuts; nC++) { hNinDYSF [nC] = (TH1F*)inputDYSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinWZSF [nC] = (TH1F*)inputWZSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinZZSF [nC] = (TH1F*)inputZZSF ->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNinDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNinZevents%.2f", MetCuts[nC])); hNoutDYSF [nC] = (TH1F*)inputDYSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutWZSF [nC] = (TH1F*)inputWZSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutZZSF [nC] = (TH1F*)inputZZSF ->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNoutZevents%.2f", MetCuts[nC])); hNoutDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNoutZevents%.2f", MetCuts[nC])); } // Histogram at analysis level //---------------------------------------------------------------------------- TH1F* hExpectedDYSF = (TH1F*)inputDYSF->Get("hWTopTagging"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // k estimation // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TFile* inputDYmumu = new TFile(Form("%s/%djet/MuMu/DY.root", directory.Data(), njet)); TFile* inputDYee = new TFile(Form("%s/%djet/EE/DY.root", directory.Data(), njet)); TH1F* hNinDYmumu = (TH1F*)inputDYmumu->Get("hNinLooseZevents20.00"); TH1F* hNinDYee = (TH1F*)inputDYee ->Get("hNinLooseZevents20.00"); Double_t NinDYmumu = hNinDYmumu->GetBinContent(2); Double_t NinDYee = hNinDYee ->GetBinContent(2); Double_t k = 0.5 * (sqrt(NinDYmumu / NinDYee) + sqrt(NinDYee / NinDYmumu)); Double_t errk = errkSF(NinDYmumu, NinDYee); if (channel == "MuMu") { k = 0.5 * sqrt(NinDYmumu / NinDYee); errk = errkFunction(NinDYmumu, NinDYee); } else if (channel == "EE") { k = 0.5 * sqrt(NinDYee / NinDYmumu); errk = errkFunction(NinDYee, NinDYmumu); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Counters // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Double_t NinDYSF [numberMetCuts]; Double_t NinWZSF [numberMetCuts]; Double_t NinZZSF [numberMetCuts]; Double_t NinDataSF[numberMetCuts]; Double_t NinDataOF[numberMetCuts]; Double_t NoutDYSF [numberMetCuts]; Double_t NoutWZSF [numberMetCuts]; // Not used for now Double_t NoutZZSF [numberMetCuts]; // Not used for now Double_t NoutDataSF[numberMetCuts]; Double_t NoutDataOF[numberMetCuts]; for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { NinDYSF [nC] = hNinDYSF [nC]->GetBinContent(2); NinWZSF [nC] = hNinWZSF [nC]->GetBinContent(2); NinZZSF [nC] = hNinZZSF [nC]->GetBinContent(2); NinDataSF [nC] = hNinDataSF [nC]->GetBinContent(2); NinDataOF [nC] = hNinDataOF [nC]->GetBinContent(2); NoutDYSF [nC] = hNoutDYSF [nC]->GetBinContent(2); NoutWZSF [nC] = hNoutWZSF [nC]->GetBinContent(2); NoutZZSF [nC] = hNoutZZSF [nC]->GetBinContent(2); NoutDataSF[nC] = hNoutDataSF[nC]->GetBinContent(2); NoutDataOF[nC] = hNoutDataOF[nC]->GetBinContent(2); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // R estimation // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Double_t R [numberMetCuts]; Double_t RData [numberMetCuts]; Double_t errR [numberMetCuts]; Double_t errRData[numberMetCuts]; // Loop over the met cuts //---------------------------------------------------------------------------- for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { R [nC] = NoutDYSF[nC] / NinDYSF[nC]; errR[nC] = errRFunction(NoutDYSF[nC], NinDYSF[nC]); RData [nC] = RDataFunction (NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k); errRData[nC] = errRDataFunction(NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k, errk); if (printLevel > 2) { printf("\n %.0f < mpmet < %.0f GeV\n", MetCuts[nC], MetCuts[nC+1]); printf(" -------------------------------------------------\n"); printf(" N^{MC}_{out,SF} = %6.1f\n", NoutDYSF[nC]); printf(" N^{MC}_{in, SF} = %6.1f\n", NinDYSF[nC]); printf(" N^{data}_{out,SF} = %4.0f\n", NoutDataSF[nC]); printf(" N^{data}_{out,OF} = %4.0f\n", NoutDataOF[nC]); printf(" N^{data}_{in, SF} = %4.0f\n", NinDataSF[nC]); printf(" N^{data}_{in, OF} = %4.0f\n", NinDataOF[nC]); printf(" k = % 5.3f +- %5.3f\n", k, errk); printf(" R^{MC} = % 5.3f +- %5.3f\n", R[nC], errR[nC]); printf(" R^{data} = % 5.3f +- %5.3f\n", RData[nC], errRData[nC]); } } // Estimate the R systematic as the difference between R[2] and R[3] //---------------------------------------------------------------------------- Int_t iMaxR = 0; Int_t iMinR = 0; for (UInt_t nC=0; nC<numberMetCuts-1; nC++) { if (R[nC] > 0 && R[nC] > R[iMaxR]) iMaxR = nC; if (R[nC] > 0 && R[nC] < R[iMinR]) iMinR = nC; } Int_t theR = 2; Int_t sysR = 3; Double_t RelDiffR = (R[theR] > 0) ? fabs(R[theR] - R[sysR]) / R[theR] : -999; if (printLevel > 0) { printf("\n [%s] R systematic uncertainty\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" min R = %5.3f\n", R[iMinR]); printf(" max R = %5.3f\n", R[iMaxR]); printf(" R[%d] = %5.3f\n", theR, R[theR]); printf(" R[%d] = %5.3f\n", sysR, R[sysR]); printf(" |R[%d]-R[%d]| / R[%d] = %.1f%s\n", theR, sysR, theR, 1e2*RelDiffR, "%"); printf("\n"); } // Estimate Nout //---------------------------------------------------------------------------- Double_t NinCountedSFWZ = NinWZSF [sysR]; Double_t NinCountedSFZZ = NinZZSF [sysR]; Double_t NinCountedSFData = NinDataSF[sysR]; Double_t NinCountedOFData = NinDataOF[sysR]; Double_t NinEstSFFinal = NinCountedSFData - k*NinCountedOFData; Double_t errNinEstSFFinal = errNinEstFunction(NinCountedSFData, NinCountedOFData, k, errk); Double_t NestSFFinal = R[theR] * NinEstSFFinal; Double_t errNestSFFinal = errNestFunction(NestSFFinal, R[theR], errR[theR], NinEstSFFinal, errNinEstSFFinal); Double_t NinEstSFNoDibosonFinal = NinEstSFFinal - NinCountedSFWZ - NinCountedSFZZ; Double_t errNinEstSFNoDibosonFinal = errNinEstNoDibosonFunction(NinCountedSFData, k, errk, NinCountedOFData, NinCountedSFWZ, NinCountedSFZZ); Double_t NestSFNoDibosonFinal = R[theR] * NinEstSFNoDibosonFinal; Double_t errNestSFNoDibosonFinal = errNestFunction(NestSFNoDibosonFinal, R[theR], errR[theR], NinEstSFNoDibosonFinal, errNinEstSFNoDibosonFinal); Double_t totalError = sqrt(errNestSFNoDibosonFinal*errNestSFNoDibosonFinal + (RelDiffR*NestSFNoDibosonFinal)*(RelDiffR*NestSFNoDibosonFinal)); Double_t SFsf = NestSFNoDibosonFinal / hExpectedDYSF->GetBinContent(2); if (printLevel > 1) { printf("\n Analysis results\n"); printf(" -------------------------------------------------\n"); printf(" N^{data}_{in,SF} = %4.0f\n", NinCountedSFData); printf(" N^{data}_{in,OF} = %4.0f\n", NinCountedOFData); printf(" k = %5.3f +- %5.3f\n", k, errk); printf(" R[%d] = %5.3f +- %5.3f\n", theR, R[theR], errR[theR]); printf(" N^{WZ}_{in,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NinCountedSFWZ, sqrt(NinCountedSFWZ), 0.1*NinCountedSFWZ); printf(" N^{ZZ}_{in,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NinCountedSFZZ, sqrt(NinCountedSFZZ), 0.1*NinCountedSFZZ); printf(" N^{est}_{in, SF} = %7.2f +- %6.2f\n", NinEstSFFinal, errNinEstSFFinal); printf(" N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n", NestSFFinal, errNestSFFinal, RelDiffR*NestSFFinal); printf(" -------------------------------------------------\n"); printf(" [no VZ] N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.) = %7.2f +- %6.2f (stat. + syst.)\n", NestSFNoDibosonFinal, errNestSFNoDibosonFinal, RelDiffR*NestSFNoDibosonFinal, NestSFNoDibosonFinal, totalError); printf(" N^{MC}_{out,SF} = %7.2f +- %6.2f\n", hExpectedDYSF->GetBinContent(2), hExpectedDYSF->GetBinError(2)); printf(" *** scale factor = %.3f\n\n", SFsf); } // Save the result //---------------------------------------------------------------------------- yield = (useDataDriven) ? NestSFNoDibosonFinal : hExpectedDYSF->GetBinContent(2); statError = errNestSFNoDibosonFinal; systError = RelDiffR*NestSFNoDibosonFinal; scaleFactor = yield / hExpectedDYSF->GetBinContent(2); // For the note //---------------------------------------------------------------------------- if (printLevel > 0) { printf("\n [%s] DY values for the note\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" final state & R_{MC} & N^{control,data} & N_{DY}^{data} & N_{DY}^{MC} & data/MC\n"); printf(" same flavour & %5.3f $\\pm$ %5.3f & %4.0f & %5.1f $\\pm$ %4.1f & %5.1f $\\pm$ %4.1f & %4.1f\n\n", R[theR], errR[theR], NinCountedSFData, yield, statError, hExpectedDYSF->GetBinContent(2), hExpectedDYSF->GetBinError(2), scaleFactor); printf("\n [%s] DY relative systematic uncertainties\n", channel.Data()); printf(" -------------------------------------------------\n"); printf(" DY normalisation = %.0f (stat.) $\\bigoplus$ %.0f (syst.)\n\n", 1e2*statError/yield, 1e2*systError/yield); } // Check //---------------------------------------------------------------------------- Double_t check = hExpectedDYSF->GetBinContent(2) - NoutDYSF[sysR]; if (check != 0) printf(" WARNING: DY yields do not much by %f\n\n", check); // Draw histograms //---------------------------------------------------------------------------- if (drawR) { Double_t absoluteMin = 999; TGraphErrors* gR = new TGraphErrors(numberMetCuts-1); TGraphErrors* gRdata = new TGraphErrors(numberMetCuts-1); for (UInt_t i=0; i<numberMetCuts-1; i++) { gR->SetPoint (i, 0.5 * (MetDraw[i+1] + MetDraw[i]), R[i]); gR->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errR[i]); gRdata->SetPoint (i, 0.5 * (MetDraw[i+1] + MetDraw[i]), RData[i]); gRdata->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errRData[i]); if (absoluteMin > (R[i] - errR[i])) absoluteMin = R[i] - errR[i]; if (absoluteMin > (RData[i] - errRData[i])) absoluteMin = RData[i] - errRData[i]; } if (absoluteMin > 0) absoluteMin = 0; // Cosmetics //-------------------------------------------------------------------------- gR->SetMarkerSize (0.9); gR->SetMarkerStyle(kFullCircle); gRdata->SetLineColor (kRed+1); gRdata->SetMarkerColor(kRed+1); gRdata->SetMarkerSize (0.9); gRdata->SetMarkerStyle(kFullCircle); // Draw //-------------------------------------------------------------------------- canvas = new TCanvas(); TMultiGraph *mgR = new TMultiGraph(); mgR->Add(gRdata); mgR->Add(gR); mgR->Draw("ap"); mgR->GetYaxis()->SetTitle("R^{out/in}"); mgR->GetXaxis()->SetTitle("mpmet (GeV)"); mgR->SetMinimum(absoluteMin - 0.1); mgR->SetMaximum(1.0); // Legend //-------------------------------------------------------------------------- TLegend* lmgR = new TLegend(0.72, 0.68, 0.92, 0.88); lmgR->AddEntry(gR, " DY MC", "lp"); lmgR->AddEntry(gRdata," data", "lp"); lmgR->SetFillColor(0); lmgR->SetTextAlign(12); lmgR->SetTextFont (42); lmgR->SetTextSize (0.04); if (channel == "SF") lmgR->SetHeader("ee + #mu#mu"); else if (channel == "EE") lmgR->SetHeader("ee"); else if (channel == "MuMu") lmgR->SetHeader("#mu#mu"); lmgR->Draw("same"); // Line at zero //-------------------------------------------------------------------------- TLine* zeroLine = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0); zeroLine->SetLineStyle(3); zeroLine->SetLineWidth(2); zeroLine->Draw("same"); mgR->Draw("p,same"); // Save //-------------------------------------------------------------------------- canvas->SaveAs("R_" + channel + ".png"); } }
void fitwitherr2() { fetchpc3dphidz(); float pt[50]; float errx[50]; for (int ipt=0; ipt<50; ipt++) { pt[ipt] = ipt*0.1 + 0.05; errx[ipt] = 0.0; } gStyle->SetOptStat(kFALSE); //gStyle->SetOptFit(1101); ofstream fout("run16dAupc3matchingsmooth.h"); ofstream fout2("run16dAupc3matchingsmooth2.h"); for (int iarm=0; iarm<2; iarm++) { for (int ich=0; ich<2; ich++) { for(int ivz=0; ivz<10; ivz++){ string arm; string ch; if (iarm == 0) arm = "east"; else if (iarm == 1) arm = "west"; else arm = "err"; if (ich == 0) ch = "pos"; else if (ich == 1) ch = "neg"; else ch = "err"; string bbcz; if (ivz==0) bbcz = "-10 to -8"; else if (ivz==1) bbcz = "-8 to -6"; else if (ivz==2) bbcz = "-6 to -4"; else if (ivz==3) bbcz = "-4 to -2"; else if (ivz==4) bbcz = "-2 to 0"; else if (ivz==5) bbcz = "0 to 2"; else if (ivz==6) bbcz = "2 to 4"; else if (ivz==7) bbcz = "4 to 6"; else if (ivz==8) bbcz = "6 to 8"; else if (ivz==9) bbcz = "8 to 10"; else bbcz = "err"; TCanvas *c1 = new TCanvas("c1","c1",500,500); c1->SetGridx(); TGraphErrors* dphisigma = new TGraphErrors(50,pt,pc3dphisigma[iarm][ich][ivz],errx,pc3dphisigmaerr[iarm][ich][ivz]); dphisigma->SetTitle(Form("dphisigma_%s_%s_%s",arm,ch,bbcz)); dphisigma->SetLineColor(1); dphisigma->SetMarkerStyle(20); dphisigma->SetMarkerSize(0.8); dphisigma->GetXaxis()->SetRangeUser(0.2,5.0); dphisigma->GetHistogram()->SetMaximum(0.01); dphisigma->GetHistogram()->SetMinimum(-0.01); dphisigma->GetXaxis()->SetTitle("p_{T}"); dphisigma->GetYaxis()->SetTitle("dphi sigma"); dphisigma->Draw("AP"); TPaveText *p1 = new TPaveText(0.2,0.8,0.9,0.9,"NDC"); p1->AddText("Fit function: a+bx+cx^{2}+dx^{3}+ex^{4}+fx^{5}+#frac{g}{#sqrt{x}}+#frac{h}{x^{2}}"); p1->Draw("same"); TF1 *fdphisigma = new TF1("fdphisigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.3,5.0); //TF1 *fdphisigma2 = new TF1("fdphisigma2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.2,5.0); dphisigma->Fit("fdphisigma","Q0","",0.4,4.0); //double sigma_par[8]; //fdphisigma->GetParameters(sigma_par); //fdphisigma->SetParameters(sigma_par); //dphisigma->Fit("fdphisigma2","Q0","",0.3,5.0); fdphisigma->Draw("same"); fout << "fdphisigma->SetParameters(" << fdphisigma->GetParameter(0) << "," << fdphisigma->GetParameter(1) << "," << fdphisigma->GetParameter(2) << "," << fdphisigma->GetParameter(3) << "," << fdphisigma->GetParameter(4) << "," << fdphisigma->GetParameter(5) << "," << fdphisigma->GetParameter(6) << "," << fdphisigma->GetParameter(7) << ");" << endl; for(int ipar=0;ipar<8;ipar++){ fout2 << "PC3_dphisigma[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdphisigma->GetParameter(ipar) << ";" << endl; } c1->Print(Form("smooth/dphisigma_%d_%d_%d.png",iarm,ich,ivz)); delete c1; TCanvas *c3 = new TCanvas("c3","c3",500,500); c3->SetGridx(); TGraphErrors* dphimean = new TGraphErrors(50,pt,pc3dphimean[iarm][ich][ivz],errx,pc3dphimeanerr[iarm][ich][ivz]); dphimean->SetTitle(Form("dphimean_%s_%s_%s",arm,ch,bbcz)); dphimean->SetLineColor(1); dphimean->SetMarkerStyle(20); dphimean->SetMarkerSize(0.8); dphimean->GetXaxis()->SetRangeUser(0.2,5.0); dphimean->GetHistogram()->SetMaximum(0.01); dphimean->GetHistogram()->SetMinimum(-0.01); dphimean->GetXaxis()->SetTitle("p_{T}"); dphimean->GetYaxis()->SetTitle("dphi mean"); dphimean->Draw("AP"); TPaveText *p3 = new TPaveText(0.2,0.8,0.9,0.9,"NDC"); p3->AddText("Fit function: a+bx+#frac{c}{x}+#frac{d}{#sqrt{x}}+#frac{e}{x^{2}}+#frac{f}{x^{3}}+#frac{g}{x^{4}}"); p3->Draw("same"); TF1 *fdphimean = new TF1("fdphimean","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.3,5.0); //TF1 *fdphimean2 = new TF1("fdphimean2","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.2,5.0); dphimean->Fit("fdphimean","Q0","",0.4,4.0); double mean_par[7]; //fdphimean->GetParameters(mean_par); //fdphimean2->SetParameters(mean_par); //dphimean->Fit("fdphimean2","Q0","",0.3,5.0); fdphimean->Draw("same"); fout << "fdphimean->SetParameters(" << fdphimean->GetParameter(0) << "," << fdphimean->GetParameter(1) << "," << fdphimean->GetParameter(2) << "," << fdphimean->GetParameter(3) << "," << fdphimean->GetParameter(4) << "," << fdphimean->GetParameter(5) << "," << fdphimean->GetParameter(6) << ");" << endl; for(int ipar=0;ipar<7;ipar++){ fout2 << "PC3_dphimean[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdphimean->GetParameter(ipar) << ";" << endl; } c3->Print(Form("smooth/dphimean_%d_%d_%d.png",iarm,ich,ivz)); delete c3; TCanvas *c2 = new TCanvas("c2","c2",500,500); c2->SetGridx(); TGraphErrors* dzsigma = new TGraphErrors(50,pt,pc3dzsigma[iarm][ich][ivz],errx,pc3dzsigmaerr[iarm][ich][ivz]); dzsigma->SetTitle(Form("dzsigma_%s_%s_%s",arm,ch,bbcz)); dzsigma->SetLineColor(1); dzsigma->SetMarkerStyle(20); dzsigma->SetMarkerSize(0.8); dzsigma->GetXaxis()->SetRangeUser(0.2,5.0); dzsigma->GetHistogram()->SetMaximum(5); dzsigma->GetHistogram()->SetMinimum(0); dzsigma->GetXaxis()->SetTitle("p_{T}"); dzsigma->GetYaxis()->SetTitle("dz sigma"); dzsigma->Draw("AP"); TPaveText *p2 = new TPaveText(0.2,0.8,0.9,0.9,"NDC"); p2->AddText("Fit function: a+bx+cx^{2}+dx^{3}+ex^{4}+fx^{5}+#frac{g}{#sqrt{x}}+#frac{h}{x^{2}}"); p2->Draw("same"); //TF1 *fdzsigma = new TF1("fdzsigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]/TMath::Sqrt(x)+[6]/x/x",0.3,5.0); TF1 *fdzsigma = new TF1("fdzsigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.3,5.0); //TF1 *fdzsigma2 = new TF1("fdzsigma2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]/TMath::Sqrt(x)+[6]/x/x",0.2,5.0); dzsigma->Fit("fdzsigma","Q0","",0.4,4.0); //fdzsigma->GetParameters(sigma_par); //fdzsigma2->SetParameters(sigma_par); //dzsigma->Fit("fdzsigma2","Q0","",0.3,5.0); fdzsigma->Draw("same"); fout << "fdzsigma->SetParameters(" << fdzsigma->GetParameter(0) << "," << fdzsigma->GetParameter(1) << "," << fdzsigma->GetParameter(2) << "," << fdzsigma->GetParameter(3) << "," << fdzsigma->GetParameter(4) << "," << fdzsigma->GetParameter(5) << "," << fdzsigma->GetParameter(6) << ");" << endl; for(int ipar=0;ipar<8;ipar++){ fout2 << "PC3_dzsigma[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdzsigma->GetParameter(ipar) << ";" << endl; } c2->Print(Form("smooth/dzsigma_%d_%d_%d.png",iarm,ich,ivz)); delete c2; TCanvas *c4 = new TCanvas("c4","c4",500,500); c4->SetGridx(); TGraphErrors* dzmean = new TGraphErrors(50,pt,pc3dzmean[iarm][ich][ivz],errx,pc3dzmeanerr[iarm][ich][ivz]); dzmean->SetTitle(Form("dzmean_%s_%s_%s",arm,ch,bbcz)); dzmean->SetLineColor(1); dzmean->SetMarkerStyle(20); dzmean->SetMarkerSize(0.8); dzmean->GetXaxis()->SetRangeUser(0.2,5.0); dzmean->GetHistogram()->SetMaximum(3); dzmean->GetHistogram()->SetMinimum(-2); dzmean->GetXaxis()->SetTitle("p_{T}"); dzmean->GetYaxis()->SetTitle("dz mean"); dzmean->Draw("AP"); TPaveText *p4 = new TPaveText(0.2,0.8,0.9,0.9,"NDC"); p4->AddText("Fit function: a+bx+#frac{c}{x}+#frac{d}{#sqrt{x}}+#frac{e}{x^{2}}+#frac{f}{x^{3}}+#frac{g}{x^{4}}"); p4->Draw("same"); TF1 *fdzmean = new TF1("fdzmean","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.3,5.0); //TF1 *fdzmean2 = new TF1("fdzmean2","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.2,5.0); dzmean->Fit("fdzmean","Q0","",0.4,4.0); //fdzmean->GetParameters(mean_par); //fdzmean2->SetParameters(mean_par); //dzmean->Fit("fdzmean2","Q0","",0.3,5.0); fdzmean->Draw("same"); fout << "fdzmean->SetParameters(" << fdzmean->GetParameter(0) << "," << fdzmean->GetParameter(1) << "," << fdzmean->GetParameter(2) << "," << fdzmean->GetParameter(3) << "," << fdzmean->GetParameter(4) << "," << fdzmean->GetParameter(5) << "," << fdzmean->GetParameter(6) << ");" << endl; for(int ipar=0;ipar<7;ipar++){ fout2 << "PC3_dzmean[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdzmean->GetParameter(ipar) << ";" << endl; } c4->Print(Form("smooth/dzmean_%d_%d_%d.png",iarm,ich,ivz)); delete c4; } } } }
void MakeAmplitudeVsAbsorberThicknessGraph() { //use beam energy for xaxis const int nPoints = 5; float x[nPoints] = { 0.0, 1.0, 2.0, 4.0, 6.0 }; float xerr[nPoints] = { 0.1, 0.25, 0.25, 0.25, 0.25 }; float y_charge[nPoints] = { 6.5, 33, 57.0, 109, 106 }; float yerr_charge[nPoints] = { 1.4, 24, 22, 60, 46 }; float y_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; double chargePerMIP = 6.5; for (int i=0; i<nPoints; ++i) { y_MIP[i] = y_charge[i] / chargePerMIP; yerr_MIP[i] = yerr_charge[i] / chargePerMIP; } TGraphErrors *graphChargeVsAbsorber = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge); graphChargeVsAbsorber->SetLineWidth(3); TGraphErrors *graphMIPVsAbsorber = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP); graphMIPVsAbsorber->SetLineWidth(3); TCanvas *c = 0; TVirtualFitter *fitter = 0; c = new TCanvas("c","c",800,600); c->SetBottomMargin(0.12); graphChargeVsAbsorber->Draw("AP"); graphChargeVsAbsorber->SetTitle(""); graphChargeVsAbsorber->GetXaxis()->SetTitle("Tungsten Absorber Thickness [X_{0}]"); graphChargeVsAbsorber->GetXaxis()->SetTitleSize(0.045); graphChargeVsAbsorber->GetXaxis()->SetLabelSize(0.045); graphChargeVsAbsorber->GetXaxis()->SetTitleOffset(1.2); graphChargeVsAbsorber->GetYaxis()->SetTitle("Integrated Charge [pC]"); graphChargeVsAbsorber->GetYaxis()->SetTitleOffset(1.0); graphChargeVsAbsorber->GetYaxis()->SetTitleSize(0.05); graphChargeVsAbsorber->GetYaxis()->SetLabelSize(0.045); graphChargeVsAbsorber->GetXaxis()->SetRangeUser(0.0,8.0); graphChargeVsAbsorber->GetYaxis()->SetRangeUser(0,200); // graphChargeVsAbsorber->Fit("pol2","",""); // fitter = TVirtualFitter::GetFitter(); c->SaveAs( "ChargeVsAbsorberAt8GeV.gif" ); c->SaveAs( "ChargeVsAbsorberAt8GeV.pdf" ); c = new TCanvas("c","c",800,600); c->SetBottomMargin(0.12); c->SetLeftMargin(0.11); graphMIPVsAbsorber->Draw("AP"); graphMIPVsAbsorber->SetTitle(""); graphMIPVsAbsorber->GetXaxis()->SetTitle("Tungsten Absorber Thickness [X_{0}]"); graphMIPVsAbsorber->GetXaxis()->SetTitleSize(0.045); graphMIPVsAbsorber->GetXaxis()->SetLabelSize(0.045); graphMIPVsAbsorber->GetXaxis()->SetTitleOffset(1.2); graphMIPVsAbsorber->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]"); graphMIPVsAbsorber->GetYaxis()->SetTitleOffset(0.9); graphMIPVsAbsorber->GetYaxis()->SetTitleSize(0.05); graphMIPVsAbsorber->GetYaxis()->SetLabelSize(0.045); graphMIPVsAbsorber->GetXaxis()->SetRangeUser(0.0, 8.0); graphMIPVsAbsorber->GetYaxis()->SetRangeUser(0, 30); // graphMIPVsAbsorber->Fit("pol1","",""); // fitter = TVirtualFitter::GetFitter(); c->SaveAs( "MIPVsAbsorberAt8GeV.gif" ); c->SaveAs( "MIPVsAbsorberAt8GeV.pdf" ); }
void MakeAmplitudeVsBeamEnergyGraph() { //use beam energy for xaxis const int nPoints = 4; float x[nPoints] = { 4.0, 8.0, 16.0, 32.0 }; float xerr[nPoints] = { 0.027*4.0, 0.023*8.0, 0.045*16.0, 0.05*32.0 }; float y_charge[nPoints] = { 54.8, 106, 217, 350 }; float yerr_charge[nPoints] = { 19, 46, 46, 92 }; float y_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 }; float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 }; double chargePerMIP = 6.5; for (int i=0; i<nPoints; ++i) { y_MIP[i] = y_charge[i] / chargePerMIP; yerr_MIP[i] = yerr_charge[i] / chargePerMIP; } TGraphErrors *graphChargeVsEnergy = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge); graphChargeVsEnergy->SetLineWidth(3); TGraphErrors *graphMIPVsEnergy = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP); graphMIPVsEnergy->SetLineWidth(3); TCanvas *c = 0; TVirtualFitter *fitter = 0; c = new TCanvas("c","c",800,600); graphChargeVsEnergy->Draw("AP"); graphChargeVsEnergy->SetTitle(""); graphChargeVsEnergy->GetXaxis()->SetTitle("Electron Beam Energy [GeV/c^{2}]"); graphChargeVsEnergy->GetXaxis()->SetTitleSize(0.045); graphChargeVsEnergy->GetXaxis()->SetLabelSize(0.045); graphChargeVsEnergy->GetXaxis()->SetTitleOffset(1.0); graphChargeVsEnergy->GetYaxis()->SetTitle("Integrated Charge [pC]"); graphChargeVsEnergy->GetYaxis()->SetTitleOffset(1.0); graphChargeVsEnergy->GetYaxis()->SetTitleSize(0.05); graphChargeVsEnergy->GetYaxis()->SetLabelSize(0.045); graphChargeVsEnergy->GetXaxis()->SetRangeUser(0,40); graphChargeVsEnergy->GetYaxis()->SetRangeUser(0,500); graphChargeVsEnergy->Fit("pol1","",""); fitter = TVirtualFitter::GetFitter(); c->SaveAs( "ChargeVsEnergyAt6X0.gif" ); c->SaveAs( "ChargeVsEnergyAt6X0.pdf" ); c = new TCanvas("c","c",800,600); c->SetLeftMargin(0.11); graphMIPVsEnergy->Draw("AP"); graphMIPVsEnergy->SetTitle(""); graphMIPVsEnergy->GetXaxis()->SetTitle("Electron Beam Energy [GeV/c^{2}]"); graphMIPVsEnergy->GetXaxis()->SetTitleSize(0.045); graphMIPVsEnergy->GetXaxis()->SetLabelSize(0.045); graphMIPVsEnergy->GetXaxis()->SetTitleOffset(1.0); graphMIPVsEnergy->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]"); graphMIPVsEnergy->GetYaxis()->SetTitleOffset(0.9); graphMIPVsEnergy->GetYaxis()->SetTitleSize(0.05); graphMIPVsEnergy->GetYaxis()->SetLabelSize(0.045); graphMIPVsEnergy->GetXaxis()->SetRangeUser(0,40); graphMIPVsEnergy->GetYaxis()->SetRangeUser(0,80); graphMIPVsEnergy->Fit("pol1","",""); fitter = TVirtualFitter::GetFitter(); c->SaveAs( "MIPVsEnergyAt6X0.gif" ); c->SaveAs( "MIPVsEnergyAt6X0.pdf" ); }
void MakeAmplitudeVsBiasVoltageGraph() { //With the 600V point // const int nPoints = 5; // float x[nPoints] = { 200, 300, 400, 500, 600 }; // float xerr[nPoints] = { 0.01*200, 0.01*300, 0.01*400, 0.01*500, 0.01*600 }; // float y_charge[nPoints] = { 58.4, 68.0, 73.8, 77.1, 78.6 }; // float yerr_charge[nPoints] = { 1.0, 1.4, 1.3, 0.5, 1.4 }; // float y_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; // float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; //Without the 600V point const int nPoints = 5; float x[nPoints] = { 200, 300, 400, 500 }; float xerr[nPoints] = { 0.01*200, 0.01*300, 0.01*400, 0.01*500 }; float y_charge[nPoints] = { 58.4, 68.0, 73.8, 77.1 }; float yerr_charge[nPoints] = { 1.0, 1.4, 1.3, 0.5 }; float y_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 }; float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 }; double chargePerMIP = 1.3; for (int i=0; i<nPoints; ++i) { y_MIP[i] = y_charge[i] / chargePerMIP; yerr_MIP[i] = yerr_charge[i] / chargePerMIP; } TGraphErrors *graphChargeVsBiasVoltage = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge); graphChargeVsBiasVoltage->SetLineWidth(3); TGraphErrors *graphMIPVsBiasVoltage = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP); graphMIPVsBiasVoltage->SetLineWidth(3); TCanvas *c = 0; TVirtualFitter *fitter = 0; c = new TCanvas("c","c",800,600); graphChargeVsBiasVoltage->Draw("AP"); graphChargeVsBiasVoltage->SetTitle(""); graphChargeVsBiasVoltage->GetXaxis()->SetTitle("Bias Voltage [V]"); graphChargeVsBiasVoltage->GetXaxis()->SetTitleSize(0.045); graphChargeVsBiasVoltage->GetXaxis()->SetLabelSize(0.045); graphChargeVsBiasVoltage->GetXaxis()->SetTitleOffset(1.0); graphChargeVsBiasVoltage->GetYaxis()->SetTitle("Integrated Charge [pC]"); graphChargeVsBiasVoltage->GetYaxis()->SetTitleOffset(1.02); graphChargeVsBiasVoltage->GetYaxis()->SetTitleSize(0.045); graphChargeVsBiasVoltage->GetYaxis()->SetLabelSize(0.045); graphChargeVsBiasVoltage->GetXaxis()->SetRangeUser(0.0,700); graphChargeVsBiasVoltage->GetYaxis()->SetRangeUser(0,90); // graphChargeVsBiasVoltage->Fit("pol2","",""); // fitter = TVirtualFitter::GetFitter(); c->SaveAs( "ChargeVsBiasVoltageAt6X0_16GeV.gif" ); c->SaveAs( "ChargeVsBiasVoltageAt6X0_16GeV.pdf" ); c = new TCanvas("c","c",800,600); c->SetLeftMargin(0.11); graphMIPVsBiasVoltage->Draw("AP"); graphMIPVsBiasVoltage->SetTitle(""); graphMIPVsBiasVoltage->GetXaxis()->SetTitle("Bias Voltage [V]"); graphMIPVsBiasVoltage->GetXaxis()->SetTitleSize(0.045); graphMIPVsBiasVoltage->GetXaxis()->SetLabelSize(0.045); graphMIPVsBiasVoltage->GetXaxis()->SetTitleOffset(1.0); graphMIPVsBiasVoltage->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]"); graphMIPVsBiasVoltage->GetYaxis()->SetTitleOffset(1.02); graphMIPVsBiasVoltage->GetYaxis()->SetTitleSize(0.045); graphMIPVsBiasVoltage->GetYaxis()->SetLabelSize(0.045); graphMIPVsBiasVoltage->GetXaxis()->SetRangeUser(0.0, 700); graphMIPVsBiasVoltage->GetYaxis()->SetRangeUser(0, 70); // graphMIPVsBiasVoltage->Fit("pol1","",""); // fitter = TVirtualFitter::GetFitter(); c->SaveAs( "MIPVsBiasVoltageAt6X0_16GeV.gif" ); c->SaveAs( "MIPVsBiasVoltageAt6X0_16GeV.pdf" ); }
void vnpt_5panels_ratio() { gROOT->Reset(); gROOT->SetStyle("MyStyle"); // gROOT->LoadMacro("v2pt_12cen_MyDef.C"); // gROOT->LoadMacro("MyDef.C"); gStyle->SetTextFont(43); gStyle->SetLabelFont(43,"x"); gStyle->SetLabelFont(43,"y"); gStyle->SetLabelFont(43,"z"); gStyle->SetTitleFont(43,"x"); gStyle->SetTitleFont(43,"y"); gStyle->SetTitleFont(43,"z"); gStyle->SetEndErrorSize(0); double textsize = 19; //int mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray}; int mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray}; int mcol2[4]={6,2,4,8}; //int msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}}; int msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}}; //float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1}; float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6}; float msiz2[4]={1.5,1.5,1.5,1.5}; // // arrays // const int Mfiles=50; int ndp[Mfiles]; char *cfn[Mfiles]; char *cft[Mfiles]; const int Mpoints=40; double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints],xesys[Mfiles][Mpoints]; double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints],yesys[Mfiles][Mpoints]; double nAxa[Mfiles][Mpoints],nAxe[Mfiles][Mpoints]; double nAya[Mfiles][Mpoints],nAye[Mfiles][Mpoints]; double nBxa[Mfiles][Mpoints],nBxe[Mfiles][Mpoints]; double nBya[Mfiles][Mpoints],nBye[Mfiles][Mpoints]; double nARxa[Mfiles][Mpoints],nARxe[Mfiles][Mpoints]; double nARya[Mfiles][Mpoints],nARye[Mfiles][Mpoints]; double nBRxa[Mfiles][Mpoints],nBRxe[Mfiles][Mpoints]; double nBRya[Mfiles][Mpoints],nBRye[Mfiles][Mpoints]; double xa60[Mfiles][Mpoints],xe60[Mfiles][Mpoints],xesys60[Mfiles][Mpoints]; double ya60[Mfiles][Mpoints],ye60[Mfiles][Mpoints],yesys60[Mfiles][Mpoints]; double nAxa60[Mfiles][Mpoints],nAxe60[Mfiles][Mpoints]; double nAya60[Mfiles][Mpoints],nAye60[Mfiles][Mpoints]; double nBxa60[Mfiles][Mpoints],nBxe60[Mfiles][Mpoints]; double nBya60[Mfiles][Mpoints],nBye60[Mfiles][Mpoints]; double nARxa60[Mfiles][Mpoints],nARxe60[Mfiles][Mpoints]; double nARya60[Mfiles][Mpoints],nARye60[Mfiles][Mpoints]; double nBRxa60[Mfiles][Mpoints],nBRxe60[Mfiles][Mpoints]; double nBRya60[Mfiles][Mpoints],nBRye60[Mfiles][Mpoints]; const int Mpads=14; char *htit[Mpads]; char *htitc2[Mpads]; char *atit[Mpads][3]; double ptit[Mpads][2]; double hxmin[Mpads],hxmax[Mpads]; double hymin[Mpads],hymax[Mpads]; double lxmin[Mpads],lxmax[Mpads]; double lymin[Mpads],lymax[Mpads]; // // Data input // char *cjob="v2pt_12cen_4x3"; int i=-1; // histogram parameter htit[0]="(a) v_{4}{#Psi_{22}}"; htit[1]="(b) v_{5}{#Psi_{23}}"; htit[2]="(c) v_{6}{#Psi_{222}}"; htit[3]="(d) v_{6}{#Psi_{33}}"; htit[4]="(e) v_{7}{#Psi_{223}}"; htit[5]="25-30%"; htit[6]="30-35%"; htit[7]="35-40%"; htit[8]="40-50%"; htit[9]="50-60%"; htit[10]="60-70%"; htit[11]="70-80%"; htitc2[0]="(f) v_{4}{#Psi_{22}}"; htitc2[1]="(g) v_{5}{#Psi_{23}}"; htitc2[2]="(h) v_{6}{#Psi_{222}}"; htitc2[3]="(i) v_{6}{#Psi_{33}}"; htitc2[4]="(j) v_{7}{#Psi_{223}}"; for (int ip=0;ip<Mpads;ip++) { // hxmin[ip]=0.0; hxmax[ip]=11.9; hxmin[ip]=0.0001; hxmax[ip]=4.1; hymin[ip]=-0.003; hymax[ip]=0.0655; lxmin[ip]=0.24; lxmax[ip]=0.88; lymin[ip]=0.65; lymax[ip]=0.94; ptit[ip][0]=0.45; ptit[ip][1]=0.036;// position legends atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{n}"; } // // Read data and create vector files // double sysXYZ[5]={6,7,8,8,9}; //double sysXYZ[5]={8,9,12,12,15}; //double sysXYZ[5]={8,9,20,20,20}; double sysEach[5]={0.0002, 0.0002, 0.0002, 0.0003, 0.0002}; double tmp; const int nw=5; const int npt=20; ifstream inEP; inEP.open("./data_vnptcent020_5020gev.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j]; if(ye[i][j]<0) ye[i][j]=-ye[i][j]; xe[i][j]=0.0; } } inEP.close(); ifstream inEP; inEP.open("./data_vnptcent020_5020gev_vzA.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>nAxa[i][j]; inEP>>tmp; inEP>>nAya[i][j]; inEP>>nAye[i][j]; if(nAye[i][j]<0) nAye[i][j]=-nAye[i][j]; nAxe[i][j]=0.0; nARxa[i][j]=nAxa[i][j]; nARxe[i][j]=nAxe[i][j]; nARye[i][j]=nAya[i][j]/ya[i][j]*sqrt(ye[i][j]*ye[i][j]/ya[i][j]/ya[i][j] + nAye[i][j]*nAye[i][j]/nAya[i][j]/nAya[i][j] - 2.5*ye[i][j]*ye[i][j]/ya[i][j]/nAya[i][j] ); nARya[i][j]=nAya[i][j]/ya[i][j]; } } inEP.close(); ifstream inEP; inEP.open("./data_vnptcent020_5020gev_vzB.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>nBxa[i][j]; inEP>>tmp; inEP>>nBya[i][j]; inEP>>nBye[i][j]; if(nBye[i][j]<0) nBye[i][j]=-nBye[i][j]; nBxe[i][j]=0.0; nBRxa[i][j]=nBxa[i][j]; nBRxe[i][j]=nBxe[i][j]; nBRye[i][j]=nBya[i][j]/ya[i][j]*sqrt(ye[i][j]*ye[i][j]/ya[i][j]/ya[i][j] + nBye[i][j]*nBye[i][j]/nBya[i][j]/nBya[i][j] - 2.5*ye[i][j]*ye[i][j]/ya[i][j]/nBya[i][j] ); nBRya[i][j]=nBya[i][j]/ya[i][j]; } } inEP.close(); //20-60% ifstream inEP; inEP.open("./data_vnptcent2060_5020gev.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>xa60[i][j]; inEP>>tmp; inEP>>ya60[i][j]; inEP>>ye60[i][j]; if(ye60[i][j]<0) ye60[i][j]=-ye60[i][j]; xe60[i][j]=0.0; } } inEP.close(); ifstream inEP; inEP.open("./data_vnptcent2060_5020gev_vzA.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>nAxa60[i][j]; inEP>>tmp; inEP>>nAya60[i][j]; inEP>>nAye60[i][j]; if(nAye60[i][j]<0) nAye60[i][j]=-nAye60[i][j]; nAxe60[i][j]=0.0; nARxa60[i][j]=nAxa60[i][j]; nARxe60[i][j]=nAxe60[i][j]; nARye60[i][j]=nAya60[i][j]/ya60[i][j]*sqrt(ye60[i][j]*ye60[i][j]/ya60[i][j]/ya60[i][j] + nAye60[i][j]*nAye60[i][j]/nAya60[i][j]/nAya60[i][j] - 2.5*ye60[i][j]*ye60[i][j]/ya60[i][j]/nAya60[i][j] ); nARya60[i][j]=nAya60[i][j]/ya60[i][j]; } } inEP.close(); ifstream inEP; inEP.open("./data_vnptcent2060_5020gev_vzB.txt"); for(int i=0; i<nw; i++){ for(int j=0; j<npt; j++){ inEP>>tmp; inEP>>tmp; inEP>>nBxa60[i][j]; inEP>>tmp; inEP>>nBya60[i][j]; inEP>>nBye60[i][j]; if(nBye60[i][j]<0) nBye60[i][j]=-nBye60[i][j]; nBxe60[i][j]=0.0; nBRxa60[i][j]=nBxa60[i][j]; nBRxe60[i][j]=nBxe60[i][j]; nBRye60[i][j]=nBya60[i][j]/ya60[i][j]*sqrt(ye60[i][j]*ye60[i][j]/ya60[i][j]/ya60[i][j] + nBye60[i][j]*nBye60[i][j]/nBya60[i][j]/nBya60[i][j] - 2.5*ye60[i][j]*ye60[i][j]/ya60[i][j]/nBya60[i][j] ); nBRya60[i][j]=nBya60[i][j]/ya60[i][j]; } } inEP.close(); nBRya60[1][2]=1.06; TCanvas *can=new TCanvas("can","can",10,10,1050*0.8*1.3,800*0.3*1.3*1.8); can->Divide(5,2,0,0); //sticks the pads with no space inbetween TH1D *h1[nw]; for (int iw=0;iw<nw;iw++) { can->cd(iw+1); if(iw==4) gPad->SetRightMargin(0.02); //gPad->SetLogy(); char ch1[8]; sprintf(ch1,"h1_%d",iw); h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]); h1[iw]->SetMinimum(0.5); h1[iw]->SetMaximum(1.5); h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle("v_{n} ratio"); h1[iw]->GetXaxis()->CenterTitle(1); h1[iw]->GetYaxis()->CenterTitle(1); // futz with the axes h1[iw]->GetYaxis()->SetNdivisions(606); h1[iw]->GetXaxis()->SetNdivisions(606); h1[iw]->GetYaxis()->SetTitleSize(textsize*1.4); h1[iw]->GetYaxis()->SetTitleOffset(2.3); h1[iw]->GetYaxis()->SetLabelSize(textsize); h1[iw]->GetXaxis()->SetTitleSize(textsize*1.4); h1[iw]->GetXaxis()->SetTitleOffset(1.3); h1[iw]->GetXaxis()->SetLabelSize(textsize); // h1[iw]->GetXaxis()->SetLabelOffset(1.2); h1[iw]->Draw(); } TH1D *h2[nw]; for (int iw=0;iw<nw;iw++) { can->cd(iw+1+5); if(iw==4) gPad->SetRightMargin(0.02); //gPad->SetLogy(); char ch2[8]; sprintf(ch2,"h2_%d",iw); h2[iw] = new TH1D(ch2,"",500,hxmin[iw],hxmax[iw]); h2[iw]->SetMinimum(0.5); h2[iw]->SetMaximum(1.5); h2[iw]->SetXTitle(atit[iw][0]); h2[iw]->SetYTitle("v_{n} ratio"); h2[iw]->GetXaxis()->CenterTitle(1); h2[iw]->GetYaxis()->CenterTitle(1); // futz with the axes h2[iw]->GetYaxis()->SetNdivisions(606); h2[iw]->GetXaxis()->SetNdivisions(606); h2[iw]->GetYaxis()->SetTitleSize(textsize*1.4); h2[iw]->GetYaxis()->SetTitleOffset(2.3); h2[iw]->GetYaxis()->SetLabelSize(textsize*1.2); h2[iw]->GetXaxis()->SetTitleSize(textsize*1.4); h2[iw]->GetXaxis()->SetTitleOffset(1.9); h2[iw]->GetXaxis()->SetLabelSize(textsize*1.2); // h2[iw]->GetXaxis()->SetLabelOffset(1.2); h2[iw]->Draw(); } // // Draw! // const int nPlotBin = 40; double ptPlot[nPlotBin]; double vnPlot[nPlotBin]; double errPlot[nPlotBin]; cout << "Now Draw!" << endl; TGraphErrors *ge, *ge2, *ge3, *ge4; for (int iw=0;iw<nw;iw++) { can->cd(iw+1); // if (iw==0) { tex=new TLatex(0.6,0.0235*0.88*1.275*1.47*1.6,"CMS"); tex->SetTextSize(textsize*1.0); //tex->Draw(); tex=new TLatex(2.8,0.0235*0.88*1.275*1.47*1.6,"Preliminary"); tex->SetTextSize(textsize*1.0); //tex->Draw(); } if (iw==0) { tex=new TLatex(1.5,1.18,"0-20%"); tex->SetTextSize(textsize*1.0); tex->Draw(); tex=new TLatex(2.,0.021,"|#eta|<0.8"); tex->SetTextSize(textsize*1.0); //tex->Draw(); tex=new TLatex(0.5,0.02,"0.3<p_{T}<3.0 GeV/c"); tex->SetTextSize(textsize*1.0); //tex->Draw(); } //if (iw < 4) tex=new TLatex(ptit[iw][0]+2,0.27,htit[iw]); tex=new TLatex(2.1,1.4,htit[iw]); if ( iw == 0) tex->SetTextSize(textsize); else if (iw == 8) tex->SetTextSize(textsize); else tex->SetTextSize(textsize); tex->Draw(); // // Legend // TLegend *leg = new TLegend(lxmin[iw]*1.2,lymin[iw]*1.*0.75*0.1,lxmax[iw]*0.8,lymax[iw]*1.02*0.4*0.92); leg->SetFillColor(0); leg->SetTextSize(textsize); TLegend *leg2 = new TLegend(lxmin[iw]*1.2,lymin[iw]*1.*0.75*0.52,lxmax[iw]*0.8,lymax[iw]*1.02*0.56*0.92); leg2->SetFillColor(0); leg2->SetTextSize(textsize); // // Read data // for (int im=0;im<1;im++) { int j=im*5+iw; int col=2; //if (ndp[j]==0) continue; ge=new TGraphErrors(19,&nARxa[j][0],&nARya[j][0],&nARxe[j][0],&nARye[j][0]); ge->SetTitle(""); ge->SetMarkerStyle(24); // ge->SetMarkerStyle(msty[im]); ge->SetMarkerSize(msiz[im]); ge->SetMarkerColor(col); ge->SetLineWidth(1.2); ge->SetLineColor(col); //ge->Draw("pe"); leg->AddEntry(ge,"HF(3,4)/HF(3,5)","pl"); } for (int im=0;im<1;im++) { int j=im*5+iw; int col=4; //if (ndp[j]==0) continue; ge2=new TGraphErrors(19,&nBRxa[j][0],&nBRya[j][0],&nBRxe[j][0],&nBRye[j][0]); ge2->SetTitle(""); ge2->SetMarkerStyle(25); // ge2->SetMarkerStyle(msty[im]); ge2->SetMarkerSize(msiz[im]); ge2->SetMarkerColor(col); ge2->SetLineWidth(1.2); ge2->SetLineColor(col); //ge2->Draw("pe"); leg->AddEntry(ge2,"HF(4,5)/HF(3,5)","pl"); //drawSysBox(ge2,16,0.2, sysXYZ[j]); } ge2->Draw("pe"); ge->Draw("pe"); if (iw==0) leg->Draw(); TLine *lines = new TLine(0,1,4.0,1); lines->SetLineStyle(2); lines->SetLineWidth(1); lines->Draw(); if(iw==0||iw<6){ TF1 *fitFun = new TF1("fitFun","pol1", 0, 4); fitFun->SetLineColor(2); ge->Fit("fitFun","R+"); fitFun->Draw("same"); cout<<fitFun->Eval(0.4)<<", "<<fitFun->Eval(0.9)<<", "<<fitFun->Eval(1.9)<<", "<<fitFun->Eval(3.5)<<endl; double p0 = fitFun->GetParameter(0); double p0Err = fitFun->GetParError(0); double p1 = fitFun->GetParameter(1); double p1Err = fitFun->GetParError(1); //double p2 = fitFun->GetParameter(2); //double p2Err = fitFun->GetParError(2); //TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x+[2]*x*x", 0, 4); TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x", 0, 4); //fitFunE->SetParameters(p0+p0Err, p1+p1Err, p2+p2Err); fitFunE->SetParameters(p0+p0Err, p1); for(int ipt=0; ipt<nPlotBin; ipt++){ ptPlot[ipt] = ipt*0.1+0.05; vnPlot[ipt] = fitFun->Eval(ptPlot[ipt]); errPlot[ipt] = fitFunE->Eval(ptPlot[ipt]) - fitFun->Eval(ptPlot[ipt]); } TGraphErrors *graph = new TGraphErrors(nPlotBin,ptPlot,vnPlot,0,errPlot); graph->SetTitle(""); graph->SetMarkerStyle(20); graph->SetMarkerSize(1.0); graph->SetMarkerColor(1); graph->SetLineWidth(2); graph->SetLineColor(2); MyStyle->SetFillColor(kRed+1); graph->SetFillColor(kRed+1); graph->SetFillStyle(3002); graph->Draw("e3same"); } else { TF1 *fitFun = new TF1("fitFun","pol1", 0, 4); fitFun->SetLineColor(4); ge->Fit("fitFun","R+"); fitFun->Draw("same"); cout<<fitFun->Eval(0.4)<<", "<<fitFun->Eval(0.9)<<", "<<fitFun->Eval(1.9)<<", "<<fitFun->Eval(3.5)<<endl; } double chi2 = fitFun->GetChisquare(); double ndf = fitFun->GetNDF(); TLatex *tex = new TLatex(0.6,0.53,Form("#chi^{2}/ndf = %2.1f", chi2/ndf)); tex->SetTextColor(2); tex->SetTextSize(16); tex->Draw("same"); can->cd(iw+1+5); tex=new TLatex(2.1,1.4,htitc2[iw]); if ( iw == 0) tex->SetTextSize(textsize); else if (iw == 8) tex->SetTextSize(textsize); else tex->SetTextSize(textsize); tex->Draw(); for (int im=0;im<1;im++) { int j=im*5+iw; int col=2; //if (ndp[j]==0) continue; ge3=new TGraphErrors(19,&nARxa60[j][0],&nARya60[j][0],&nARxe60[j][0],&nARye60[j][0]); ge3->SetTitle(""); ge3->SetMarkerStyle(24); // ge3->SetMarkerStyle(msty[im]); ge3->SetMarkerSize(msiz[im]); ge3->SetMarkerColor(col); ge3->SetLineWidth(1.2); ge3->SetLineColor(col); //ge3->Draw("pe"); leg2->AddEntry(ge3,"HF(3,4)/HF(3,5)","pl"); } for (int im=0;im<1;im++) { int j=im*5+iw; int col=4; //if (ndp[j]==0) continue; ge4=new TGraphErrors(19,&nBRxa60[j][0],&nBRya60[j][0],&nBRxe60[j][0],&nBRye60[j][0]); ge4->SetTitle(""); ge4->SetMarkerStyle(25); // ge4->SetMarkerStyle(msty[im]); ge4->SetMarkerSize(msiz[im]); ge4->SetMarkerColor(col); ge4->SetLineWidth(1.2); ge4->SetLineColor(col); //ge4->Draw("pe"); leg2->AddEntry(ge4,"HF(4,5)/HF(3,5)","pl"); } ge4->Draw("pe"); ge3->Draw("pe"); TLine *lines = new TLine(0,1,4.0,1); lines->SetLineStyle(2); lines->SetLineWidth(1); lines->Draw(); if(iw==0) leg2->Draw(); if(iw==0||iw<6){ TF1 *fitFun = new TF1("fitFun","pol1", 0, 4); fitFun->SetLineColor(2); ge3->Fit("fitFun","R+"); fitFun->Draw("same"); cout<<fitFun->Eval(2.5)<<", "<<fitFun->Eval(7.5)<<", "<<fitFun->Eval(45)<<", "<<fitFun->Eval(55)<<endl; double p0 = fitFun->GetParameter(0); double p0Err = fitFun->GetParError(0); double p1 = fitFun->GetParameter(1); double p1Err = fitFun->GetParError(1); //double p2 = fitFun->GetParameter(2); //double p2Err = fitFun->GetParError(2); //TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x+[2]*x*x", 0, 4); TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x", 0, 4); //fitFunE->SetParameters(p0+p0Err, p1+p1Err, p2+p2Err); fitFunE->SetParameters(p0+p0Err, p1); for(int ipt=0; ipt<nPlotBin; ipt++){ ptPlot[ipt] = ipt*0.1+0.05; vnPlot[ipt] = fitFun->Eval(ptPlot[ipt]); errPlot[ipt] = fitFunE->Eval(ptPlot[ipt]) - fitFun->Eval(ptPlot[ipt]); } TGraphErrors *graph = new TGraphErrors(nPlotBin,ptPlot,vnPlot,0,errPlot); graph->SetTitle(""); graph->SetMarkerStyle(20); graph->SetMarkerSize(1.0); graph->SetMarkerColor(1); graph->SetLineWidth(2); graph->SetLineColor(2); MyStyle->SetFillColor(kRed+1); graph->SetFillColor(kRed+1); graph->SetFillStyle(3002); graph->Draw("e3same"); } else { TF1 *fitFun = new TF1("fitFun","pol1", 0, 4); fitFun->SetLineColor(4); ge3->Fit("fitFun","R+"); fitFun->Draw("same"); cout<<fitFun->Eval(2.5)<<", "<<fitFun->Eval(7.5)<<", "<<fitFun->Eval(45)<<", "<<fitFun->Eval(55)<<endl; } double chi2 = fitFun->GetChisquare(); double ndf = fitFun->GetNDF(); TLatex *tex = new TLatex(0.6,0.53,Form("#chi^{2}/ndf = %2.1f", chi2/ndf)); tex->SetTextColor(2); tex->SetTextSize(16); tex->Draw("same"); if(iw==0){ can->cd(iw+5+1); TLatex *tex=new TLatex(1.5,1.18,"20-60%"); tex->SetTextSize(textsize*1.0); tex->Draw(); } } can->cd(); TLatex * tex = new TLatex(0.06,0.96,"CMS"); tex->SetNDC(); tex->SetTextFont(62); tex->SetTextSize(0.038); tex->SetLineWidth(2); tex->Draw(); TLatex * tex = new TLatex(0.108,0.96,"Preliminary"); tex->SetNDC(); tex->SetTextFont(52); tex->SetTextSize(0.038); tex->SetLineWidth(2); //tex->Draw(); TLatex * tex = new TLatex(0.24,0.963,"|#eta|<0.8"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.038); tex->SetLineWidth(2); tex->Draw(); cout << "end of process" << endl; can->cd(); can->Print("./figures/plot_vnpt_5panels_hfSys_ratio.png"); can->Print("./figures/plot_vnpt_5panels_hfSys_ratio.pdf"); //can->Print("./figures/plot_vnpt_5panels.gif"); }
c523pt_compare() { gROOT->Reset(); gROOT->SetStyle("MyStyle"); // gROOT->LoadMacro("v2pt_12cen_MyDef.C"); // gROOT->LoadMacro("MyDef.C"); gStyle->SetTextFont(43); gStyle->SetLabelFont(43,"x"); gStyle->SetLabelFont(43,"y"); gStyle->SetLabelFont(43,"z"); gStyle->SetTitleFont(43,"x"); gStyle->SetTitleFont(43,"y"); gStyle->SetTitleFont(43,"z"); gStyle->SetEndErrorSize(0); double textsize = 19; //int mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray}; int mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray}; int mcol2[4]={6,2,4,8}; //int msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}}; int msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}}; //float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1}; float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6}; float msiz2[4]={1.5,1.5,1.5,1.5}; // // arrays // const int Mfiles=50; int ndp[Mfiles]; char *cfn[Mfiles]; char *cft[Mfiles]; const int Mpoints=40; double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints]; double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints]; double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints]; double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints]; double nxaB[Mfiles][Mpoints],nxeB[Mfiles][Mpoints]; double nyaB[Mfiles][Mpoints],nyeB[Mfiles][Mpoints]; double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints]; double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints]; double ra[Mfiles][Mpoints],re[Mfiles][Mpoints]; const int Mpads=14; char *htit[Mpads]; char *atit[Mpads][3]; double ptit[Mpads][2]; double hxmin[Mpads],hxmax[Mpads]; double hymin[Mpads],hymax[Mpads]; double lxmin[Mpads],lxmax[Mpads]; double lymin[Mpads],lymax[Mpads]; // // Data input // char *cjob="v2pt_12cen_4x3"; int i=-1; // histogram parameter htit[0]="0-5%"; htit[1]="5-10%"; htit[2]="10-15%"; htit[3]="15-20%"; htit[4]="20-25%"; htit[5]="25-30%"; htit[6]="30-35%"; htit[7]="35-40%"; htit[8]="40-50%"; htit[9]="50-60%"; htit[10]="60-70%"; htit[11]="70-80%"; for (int ip=0;ip<Mpads;ip++) { // hxmin[ip]=0.0; hxmax[ip]=11.9; hxmin[ip]=0.0001; hxmax[ip]=6.8; hymin[ip]=0.48; hymax[ip]=1.52; //hymin[ip]=-0.001; hymax[ip]=.079; lxmin[ip]=0.08; lxmax[ip]=0.35; lymin[ip]=0.4; lymax[ip]=0.65; ptit[ip][0]=1.6; ptit[ip][1]=1.368;// position legends //ptit[ip][0]=4.0; ptit[ip][1]=0.068;// position legends atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="#chi_{523}, ratio"; //atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{4}{#Psi_{2}}"; } // // Read data and create vector files // double tmp; const int nw=12; const int npt=15; ifstream inEP; inEP.open("../outchi523D_corrFlow.txt"); for(int i=0; i<nw; i++){ inEP>>tmp; inEP>>tmp; for(int j=0; j<npt+5; j++){ inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j]; //ya[i][j]=pow(fabs(ya[i][j]),1.0/2); ye[i][j]=0.5*ye[i][j]; if(ye[i][j]<0) ye[i][j]=-ye[i][j]; xe[i][j]=0.0; } } inEP.close(); ifstream inSP; inSP.open("/Users/shengquantuo/Downloads/tmp2/figures_-0.8_00.8/outc523steve.txt"); //inSP.open("../aug13L/outchi523D_corrFlow.txt"); for(int i=0; i<nw; i++){ //inSP>>tmp; inSP>>tmp; for(int j=0; j<npt+3; j++){ //inSP>>tmp; inSP>>tmp; inSP>>nxa[i][j]; inSP>>tmp; inSP>>nya[i][j]; inSP>>nye[i][j]; inSP>>nxa[i][j]; inSP>>nya[i][j]; inSP>>nye[i][j]; nxe[i][j]=0.0; nya[i][j]=nya[i][j]/ya[i][j]; nye[i][j]=ye[i][j]/ya[i][j]; if(nye[i][j]<0) nye[i][j]=-nye[i][j]; cout<<nya[i][j]<<endl; } } inSP.close(); /* inSP.open("../aug13T/outchi523D_corrFlow.txt"); for(int i=0; i<nw; i++){ inSP>>tmp; inSP>>tmp; for(int j=0; j<npt+5; j++){ inSP>>tmp; inSP>>tmp; inSP>>nxaB[i][j]; inSP>>tmp; inSP>>nyaB[i][j]; inSP>>nyeB[i][j]; nxeB[i][j]=0.0; nyaB[i][j]=nyaB[i][j]/ya[i][j]; nyeB[i][j]=ye[i][j]/ya[i][j]; if(nyeB[i][j]<0) nyeB[i][j]=-nyeB[i][j]; } } inSP.close(); */ TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85); can->Divide(4,3,0,0); //sticks the pads with no space inbetween TH1D *h1[nw]; for (int iw=0;iw<nw;iw++) { can->cd(iw+1); if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02); char ch1[8]; sprintf(ch1,"h1_%d",iw); h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]); h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]); h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]); h1[iw]->GetXaxis()->CenterTitle(1); h1[iw]->GetYaxis()->CenterTitle(1); // futz with the axes h1[iw]->GetYaxis()->SetNdivisions(606); h1[iw]->GetXaxis()->SetNdivisions(606); h1[iw]->GetYaxis()->SetTitleSize(textsize); h1[iw]->GetYaxis()->SetTitleOffset(3.0); h1[iw]->GetYaxis()->SetLabelSize(textsize); h1[iw]->GetXaxis()->SetTitleSize(textsize); h1[iw]->GetXaxis()->SetTitleOffset(3.0); h1[iw]->GetXaxis()->SetLabelSize(textsize); // h1[iw]->GetXaxis()->SetLabelOffset(1.2); h1[iw]->Draw(); } // // Draw! // cout << "Now Draw!" << endl; TGraphErrors *ge; for (int iw=0;iw<nw-2;iw++) { can->cd(iw+1); // if (iw==0) { tex=new TLatex(1.5,8.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV"); tex->SetTextSize(textsize); //tex->Draw(); tex=new TLatex(1.5,7.07,"|#eta|<0.8"); tex->SetTextSize(textsize); tex->Draw(); } if (iw < 4) tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]); else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]); if ( iw == 0) tex->SetTextSize(textsize); else if (iw == 8) tex->SetTextSize(textsize); else tex->SetTextSize(textsize); tex->Draw(); // // Legend // TLegend *leg = new TLegend(lxmin[iw]*1.3,lymin[iw]*0.35,lxmax[iw]*1.3,lymax[iw]*0.6); leg->SetTextSize(textsize); // // Read data // for (int im=0;im<1;im++) { int j=im*12+iw; int col=1; //if (ndp[j]==0) continue; ge=new TGraphErrors(16,&xa[j][0],&nya[j][0],&xe[j][0],&nye[j][0]); ge->SetTitle(""); ge->SetMarkerStyle(msty[im][1]); // ge->SetMarkerStyle(msty[im]); ge->SetMarkerSize(msiz[im]); ge->SetMarkerColor(col); ge->SetLineWidth(1.2); ge->SetLineColor(col); ge->Draw("pe"); leg->AddEntry(ge," Steve/Shengquan","p"); } if (iw==1) leg->Draw(); TLine *line = new TLine(0,1,6.8,1); line->SetLineStyle(2); line->Draw(); /* for (int im=0;im<1;im++) { int j=im*12+iw; int col=2; //if (ndp[j]==0) continue; ge=new TGraphErrors(16,&nxaB[j][0],&nyaB[j][0],&nxeB[j][0],&nyeB[j][0]); ge->SetTitle(""); ge->SetMarkerStyle(25); // ge->SetMarkerStyle(msty[im]); ge->SetMarkerSize(msiz[im]); ge->SetMarkerColor(col); ge->SetLineWidth(1.2); ge->SetLineColor(col); ge->Draw("pe"); leg->AddEntry(ge," Tight/Default","p"); } */ } cout << "end of process" << endl; can->cd(); can->Print("./figures/c523_pt_12cent.png"); can->Print("./figures/c523_pt_12cent.pdf"); }
int SteadyStateCorrellation() { TGraphErrors *graph = new TGraphErrors(); TGraphErrors *graph2 = new TGraphErrors(); vector<double> vec_errors; vector<std::string> file_names = { // "DataFile_2016-12-07_23-20-47.csv", "DataFile_2016-12-08_00-00-39.csv", "DataFile_2016-12-08_00-24-50.csv", "DataFile_2016-12-08_00-38-48.csv", "DataFile_2016-12-08_01-01-59.csv", "DataFile_2016-12-08_01-18-01.csv", "DataFile_2016-12-08_01-35-56.csv", "DataFile_2016-12-08_01-52-12.csv", "DataFile_2016-12-08_02-12-19.csv", "DataFile_2016-12-08_02-31-44.csv", "DataFile_2016-12-08_02-50-58.csv", "DataFile_2016-12-08_03-10-16.csv", "DataFile_2016-12-08_03-29-53.csv", "DataFile_2016-12-08_03-49-37.csv", "DataFile_2016-12-08_04-09-26.csv", "DataFile_2016-12-08_04-29-26.csv", "DataFile_2016-12-08_04-49-57.csv", "DataFile_2016-12-08_05-34-24.csv", "DataFile_2016-12-08_05-58-20.csv", "DataFile_2016-12-08_06-22-12.csv", "DataFile_2016-12-08_06-46-48.csv", "DataFile_2016-12-08_07-11-10.csv" }; for(int i = 0; i < file_names.size(); i++) { RampCorrellation_single(file_names[i], *graph, *graph2, vec_errors); } TCanvas *c = new TCanvas(); graph->GetXaxis()->SetTitle("Nominal External Field (mT)"); graph->GetYaxis()->SetTitle("| B_{1} / B_{2} |"); graph->Draw(); double ratio_mean = graph->GetMean(2); double ratio_std = graph->GetRMS(2); cout << "Average value: " << graph->GetMean(2) << " +/- " << ratio_std << endl; TCanvas *c2 = new TCanvas(); graph2->GetXaxis()->SetTitle("Nominal External Field (mT)"); graph2->GetYaxis()->SetTitle("B_{3} (mT)"); graph2->Draw(); double vec_average = 0; double vec_max = 0, vec_min = 999999999999999; for(int i =0; i< vec_errors.size(); i++) { // cout << vec_errors[i] << endl; if(vec_errors[i]>vec_max) vec_max = vec_errors[i]; if(vec_errors[i]<vec_min) vec_min = vec_errors[i]; vec_average = vec_average+vec_errors[i]; } vec_average = vec_average/vec_errors.size(); cout << "Average Error in (Non time dependant) measureemnts: " << vec_average << " mT" << endl; cout << " (Min/Max = " << vec_min << " / " << vec_max << ")" << endl; return 0; }
int main (int argc, char **argv) { /// Mc Ntuplas TString input = Form("/data1/rgerosa/NTUPLES_FINAL_CALIB/MC/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_All.root"); /// MC Calibration result E/p TString input2 = Form("/data1/rgerosa/L3_Weight/MC_WJets/EB_Z_recoFlag/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_Z_noEP.root"); TApplication* theApp = new TApplication("Application",&argc, argv); TFile *f = new TFile(input,""); TTree *inputTree = (TTree*)f->Get("ntu"); TFile *f2 = new TFile(input2,""); TH2F *h_scale_EB = (TH2F*)f2->Get("h_scale_EB"); TH2F *hcmap = (TH2F*) h_scale_EB->Clone("hcmap"); hcmap -> Reset("ICEMS"); hcmap -> ResetStats(); /// Taking infos std::vector<float>* ele1_recHit_E=0; std::vector<float>* ele2_recHit_E=0; std::vector<int>* ele1_recHit_hashedIndex=0; std::vector<int>* ele2_recHit_hashedIndex=0; std::vector<int>* ele1_recHit_flag=0; std::vector<int>* ele2_recHit_flag=0; float ele1_E_true,ele2_E_true; float ele1_tkP,ele2_tkP; int ele1_isEB, ele2_isEB; float ele1_fbrem,ele2_fbrem; int isW, isZ; inputTree->SetBranchAddress("ele1_recHit_E", &ele1_recHit_E); inputTree->SetBranchAddress("ele2_recHit_E", &ele2_recHit_E); inputTree->SetBranchAddress("ele1_recHit_hashedIndex", &ele1_recHit_hashedIndex); inputTree->SetBranchAddress("ele2_recHit_hashedIndex", &ele2_recHit_hashedIndex); inputTree->SetBranchAddress("ele1_recHit_flag", &ele1_recHit_flag); inputTree->SetBranchAddress("ele2_recHit_flag", &ele2_recHit_flag); inputTree->SetBranchAddress("ele1_E_true", &ele1_E_true); inputTree->SetBranchAddress("ele2_E_true", &ele2_E_true); inputTree->SetBranchAddress("ele1_tkP", &ele1_tkP); inputTree->SetBranchAddress("ele2_tkP", &ele2_tkP); inputTree->SetBranchAddress("ele1_isEB", &ele1_isEB); inputTree->SetBranchAddress("ele2_isEB", &ele2_isEB); inputTree->SetBranchAddress("ele1_fbrem", &ele1_fbrem); inputTree->SetBranchAddress("ele2_fbrem", &ele2_fbrem); inputTree->SetBranchAddress("isW", &isW); inputTree->SetBranchAddress("isZ", &isZ); TProfile2D* mapMomentum = new TProfile2D("mapMomentum","mapMomentum",360,0,360,170,-85,85); TProfile2D* mapfbrem = new TProfile2D("mapfbrem","mapfbrem",360,0,360,170,-85,85); /// Make fbrem and p/ptrue map cycling on MC --> all the events for(Long64_t i=0; i< inputTree->GetEntries(); i++) { inputTree->GetEntry(i); if (!(i%100000))std::cerr<<i; if (!(i%10000)) std::cerr<<"."; if (ele1_isEB == 1 && (isW==1 || isZ==1)) { double E_seed=0; int seed_hashedIndex=-1;// iseed; for (unsigned int iRecHit = 0; iRecHit < ele1_recHit_E->size(); iRecHit++ ) { if(ele1_recHit_E -> at(iRecHit) > E_seed && ele1_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good { seed_hashedIndex=ele1_recHit_hashedIndex -> at(iRecHit); // iseed=iRecHit; E_seed=ele1_recHit_E -> at(iRecHit); ///! Seed search } } int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex); int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex); if(ele1_tkP>0 && ele1_E_true>0 && abs(ele1_tkP/ele1_E_true)<2. && abs(ele1_tkP/ele1_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele1_tkP/ele1_E_true)); mapfbrem->Fill(phi_seed,eta_seed,abs(ele1_fbrem)); } if (ele2_isEB == 1 && isZ==1) { double E_seed=0; int seed_hashedIndex=-1;// iseed; for (unsigned int iRecHit = 0; iRecHit < ele2_recHit_E->size(); iRecHit++ ) { if(ele2_recHit_E -> at(iRecHit) > E_seed && ele2_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good { seed_hashedIndex=ele2_recHit_hashedIndex -> at(iRecHit); // iseed=iRecHit; E_seed=ele2_recHit_E -> at(iRecHit); ///! Seed search } } int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex); int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex); if(ele2_tkP>0 && ele2_E_true>0 && abs(ele2_tkP/ele2_E_true)<2. && abs(ele2_tkP/ele2_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele2_tkP/ele2_E_true)); mapfbrem->Fill(phi_seed,eta_seed,abs(ele2_fbrem)); } } /// Map of IC normalized in eta rings std::vector< std::pair<int,int> > TT_centre ; TT_centre.push_back(std::pair<int,int> (58,49)); TT_centre.push_back(std::pair<int,int> (53,109)); TT_centre.push_back(std::pair<int,int> (8,114)); TT_centre.push_back(std::pair<int,int> (83,169)); TT_centre.push_back(std::pair<int,int> (53,174)); TT_centre.push_back(std::pair<int,int> (63,194)); TT_centre.push_back(std::pair<int,int> (83,224)); TT_centre.push_back(std::pair<int,int> (73,344)); TT_centre.push_back(std::pair<int,int> (83,358)); TT_centre.push_back(std::pair<int,int> (-13,18)); TT_centre.push_back(std::pair<int,int> (-18,23)); TT_centre.push_back(std::pair<int,int> (-8,53)); TT_centre.push_back(std::pair<int,int> (-3,63)); TT_centre.push_back(std::pair<int,int> (-53,128)); TT_centre.push_back(std::pair<int,int> (-53,183)); TT_centre.push_back(std::pair<int,int> (-83,193)); TT_centre.push_back(std::pair<int,int> (-74,218)); TT_centre.push_back(std::pair<int,int> (-8,223)); TT_centre.push_back(std::pair<int,int> (-68,303)); TT_centre.push_back(std::pair<int,int> (-43,328)); /// Mean over phi corrected skipping dead channel for (int iEta = 1 ; iEta < h_scale_EB->GetNbinsY()+1; iEta ++) { float SumIC = 0; int numIC = 0; for(int iPhi = 1 ; iPhi < h_scale_EB->GetNbinsX()+1 ; iPhi++) { bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta); bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre); if(isGood && isGoodTT) { SumIC = SumIC + h_scale_EB->GetBinContent(iPhi,iEta); numIC ++ ; } } //fede: skip bad channels and bad TTs for (int iPhi = 1; iPhi< h_scale_EB->GetNbinsX()+1 ; iPhi++) { if(numIC==0 || SumIC==0) continue; bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta); bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre); if (!isGood || !isGoodTT) continue; hcmap->SetBinContent(iPhi,iEta,h_scale_EB->GetBinContent(iPhi,iEta)/(SumIC/numIC)); } } /// ratio map TH2F* ratioMap = (TH2F*) hcmap -> Clone("ratioMap"); ratioMap->Reset(); for( int i =0 ; i<hcmap->GetNbinsX() ; i++){ for( int j=0; j<hcmap->GetNbinsY() ; j++){ if(hcmap->GetBinContent(i,j)!=0 && mapMomentum->GetBinContent(i,j)!=0) ratioMap->SetBinContent(i+1,j+1,mapMomentum->GetBinContent(i,j)/hcmap->GetBinContent(i,j)); } } /// Profile along phi taking into account dead channels TGraphErrors *coeffEBp = new TGraphErrors(); TGraphErrors *coeffEBm = new TGraphErrors(); for (int iPhi =1; iPhi< hcmap->GetNbinsX()+1 ; iPhi++){ double SumEBp =0, SumEBm=0; double iEBp=0, iEBm=0; for(int iEta = 1; iEta<hcmap->GetNbinsY()+1 ; iEta++){ if(hcmap->GetBinContent(iPhi,iEta)==0)continue; if(iEta>85) {SumEBp=SumEBp+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta); iEBp++;} else{ SumEBm=SumEBm+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta); iEBm++;} } coeffEBp->SetPoint(iPhi-1,iPhi-1,SumEBp/iEBp); coeffEBm->SetPoint(iPhi-1,iPhi-1,SumEBm/iEBm); } TFile* outputGraph = new TFile("output/GraphFor_P_Correction.root","RECREATE"); outputGraph->cd(); coeffEBp->Write("coeffEBp"); coeffEBm->Write("coeffEBm"); outputGraph->Close(); gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetOptTitle(1); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetFitFormat("6.3g"); gStyle->SetPalette(1); gStyle->SetTextFont(42); gStyle->SetTextSize(0.05); gStyle->SetTitleFont(42,"xyz"); gStyle->SetTitleSize(0.05); gStyle->SetLabelFont(42,"xyz"); gStyle->SetLabelSize(0.05); gStyle->SetTitleXOffset(0.8); gStyle->SetTitleYOffset(1.1); gROOT->ForceStyle(); TCanvas* c1 = new TCanvas("mapMomentum","mapMomentum",1); c1->cd(); mapMomentum->GetXaxis()->SetTitle("#phi"); mapMomentum->GetXaxis()->SetNdivisions(20); c1->SetGridx(); mapMomentum->GetYaxis()->SetTitle("#eta"); mapMomentum->GetZaxis()->SetRangeUser(0.7,1.3); mapMomentum->Draw("colz"); TCanvas* c2 = new TCanvas("mapfbrem","mapfbrem",1); c2->cd(); mapfbrem->GetXaxis()->SetTitle("#phi"); mapfbrem->GetYaxis()->SetTitle("#eta"); mapfbrem->GetXaxis()->SetNdivisions(20); c2->SetGridx(); mapfbrem->GetZaxis()->SetRangeUser(0.,0.7); mapfbrem->Draw("colz"); TCanvas* c3 = new TCanvas("ratioMap","ratioMap",1); c3->cd(); ratioMap->GetXaxis()->SetTitle("#phi"); ratioMap->GetYaxis()->SetTitle("#eta"); ratioMap->GetXaxis()->SetNdivisions(20); c3->SetGridx(); ratioMap->GetZaxis()->SetRangeUser(0.7,1.3); ratioMap->Draw("colz"); TCanvas* c4 = new TCanvas("coeffEB","coeffEB",1); c4->cd(); coeffEBp->GetXaxis()->SetTitle("#phi"); coeffEBp->GetYaxis()->SetTitle("p/p_{true}"); coeffEBp -> SetMarkerStyle(20); coeffEBp -> SetMarkerSize(1); coeffEBp -> SetMarkerColor(kRed+1); coeffEBp -> SetLineColor(kRed+1); c4->SetGridx(); c4->SetGridy(); ratioMap->Draw("ap"); coeffEBm->GetXaxis()->SetTitle("#phi"); coeffEBm->GetYaxis()->SetTitle("p/p_{true}"); coeffEBm -> SetMarkerStyle(20); coeffEBm -> SetMarkerSize(1); coeffEBm -> SetMarkerColor(kBlue+1); coeffEBm -> SetLineColor(kBlue+1); coeffEBm->Draw("ap same"); theApp->Run(); return 0; }
void plotPatDep(Int_t slugNum, TString device, TString asymType){ gROOT->Reset(); gROOT->SetStyle("Plain"); const Double_t nonLin = -0.01; //relative MD:BCM non-linearity const Bool_t saveFile = kTRUE; //save canvases to a file const TString plotDir = "subblocks"; Int_t histPos[7] = {1,2,3,6,8,9,12}; //positioning scheme within the canvas TH1F *histoCharge[7]; //Aq histogram pointer array TH1F *histoDet[7]; //MD histogram pointer array TH1F *histoDetCorr[7]; //Aq-corrected MD histogram pointer array //arrays containing the mean and error for the pattern-history-dependent asymmetries, the ordering is the same as in plotTitles Double_t aqCorr[7]; Double_t aqErr[7]; Double_t detPatMean[7]; Double_t detPatErr[7]; Double_t detPatCorrMean[7]; Double_t detPatCorrErr[7]; //arrays to be used in graphing the relative sizes of the lowest-level pattern asymmetries Double_t patType[4] = {1,2,3,4}; // 1=(-++--++-) 2=(-++-+--+) 3=(+--+-++-) 4=(+--++--+) Double_t patTypeErr[4] = {0,0,0,0}; Double_t patAsymMean[4]; Double_t patAsymErr[4]; //temporary holders const TString cutList[7]={ "1", "pat_phase==2", "pat_phase==2 && actual_previous_pattern_polarity==0", "pat_phase==2 && actual_previous_pattern_polarity==1", "pat_phase==1", "pat_phase==1 && actual_previous_pattern_polarity==0", "pat_phase==1 && actual_previous_pattern_polarity==1" }; //cuts to impose pattern history cuts /* const TString cutList[7]={ "1", "actual_pattern_polarity==0", "actual_pattern_polarity==0 && actual_previous_pattern_polarity==0", "actual_pattern_polarity==0 && actual_previous_pattern_polarity==1", "actual_pattern_polarity==1", "actual_pattern_polarity==1 && actual_previous_pattern_polarity==0", "actual_pattern_polarity==1 && actual_previous_pattern_polarity==1" }; //cuts to impose pattern history cuts */ const TString plotTitles[7]={ "All Patterns", "-++-", "-++- -++-", "-++- +--+", "+--+", "+--+ -++-", "+--+ +--+" }; //titles corresponding to above cuts //open the file Char_t filename[100]; sprintf(filename,"/w/hallc/qweak/smacewan/scratch/slugrootfiles/QwPass3_slug%i.root",slugNum); f = new TFile(filename); if(!f->IsOpen()){ std::cerr<<"Error opening ROOTFile "<<filename<<".\n"<<std::endl; return 0; } std::cout<<"Successfully opened ROOTFile "<<filename<<".\n"<<std::endl; //grab the tree TTree *slugTree = f->Get("slug"); gStyle->SetOptStat("neMmRr"); gStyle->SetOptFit(1); gStyle->SetStatW(0.32); //---------------------------------------------------------------------------------------- //CHARGE ASYMMETRY TCanvas *cCharge = new TCanvas("cCharge","Pattern History Study: qwk_charge",1400,1100); cCharge->Divide(3,4); for (Int_t i=0; i<7; i++){ histoCharge[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0); cCharge->cd(histPos[i]); histoCharge[i]->SetDirectory(0); slugTree->Draw(Form("1e6*asym_qwk_charge>>slug%i_q_%s",slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_qwk_charge_Device_Error_Code==0",cutList[i].Data())); TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_q_%s",slugNum,plotTitles[i].Data())); aqCorr[i] = htemp->GetMean(); aqErr[i] = htemp->GetMeanError(); } cCharge->cd(10); patAsymMean[0] = aqCorr[2]; patAsymErr[0] = aqErr[2]; patAsymMean[1] = aqCorr[3]; patAsymErr[1] = aqErr[3]; patAsymMean[2] = aqCorr[5]; patAsymErr[2] = aqErr[5]; patAsymMean[3] = aqCorr[6]; patAsymErr[3] = aqErr[6]; TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr); grp->SetMarkerStyle(21); grp->Draw("ap"); grp->Fit("pol0"); grp->SetTitle("Asymmetry per pattern: --, -+ +- ++"); grp->GetYaxis()->SetTitle("Asymmetry (ppm)"); grp->GetYaxis()->SetTitleOffset(1.3); grp->GetXaxis()->SetTitle("Pattern"); cCharge->Update(); cCharge->Modified(); if(saveFile){ cCharge->SaveAs(Form("%s/%i_charge_%s.png",plotDir.Data(),slugNum,asymType.Data())); } //---------------------------------------------------------------------------------------- //DEVICE TCanvas *cDet = new TCanvas("cDet",Form("Pattern History Study: %s",device.Data()),1400,1100); cDet->Divide(3,4); for (Int_t i=0; i<7; i++){ histoDet[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0); cDet->cd(histPos[i]); histoDet[i]->SetDirectory(0); slugTree->Draw(Form("1e6*%s_%s>>slug%i_det_%s",asymType.Data(),device.Data(),slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_%s_Device_Error_Code==0",cutList[i].Data(),device.Data())); TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_det_%s",slugNum,plotTitles[i].Data())); detPatMean[i] = htemp->GetMean(); detPatErr[i] = htemp->GetMeanError(); } cDet->cd(10); patAsymMean[0] = detPatMean[2]; patAsymErr[0] = detPatErr[2]; patAsymMean[1] = detPatMean[3]; patAsymErr[1] = detPatErr[3]; patAsymMean[2] = detPatMean[5]; patAsymErr[2] = detPatErr[5]; patAsymMean[3] = detPatMean[6]; patAsymErr[3] = detPatErr[6]; TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr); grp->SetMarkerStyle(21); grp->Draw("ap"); grp->Fit("pol0"); grp->SetTitle("Asymmetry per pattern: --, -+ +- ++"); grp->GetYaxis()->SetTitle("Asymmetry (ppm)"); grp->GetYaxis()->SetTitleOffset(1.3); grp->GetXaxis()->SetTitle("Pattern"); cDet->Update(); cDet->Modified(); if(saveFile){ cDet->SaveAs(Form("%s/%i_%s_%s.png",plotDir.Data(),slugNum,asymType.Data(),device.Data())); } //---------------------------------------------------------------------------------------- //AQ-CORRECTED DEVICE TCanvas *cDetCorr = new TCanvas("cDetCorr",Form("Pattern History Study: corrected %s",device.Data()),1400,1100); cDetCorr->Divide(3,4); for (Int_t i=0; i<7; i++){ // std::cout<<"i="<<i<<" histPos[i]="<<histPos[i]<<std::endl; histoDetCorr[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0); cDetCorr->cd(histPos[i]); histoDetCorr[i]->SetDirectory(0); slugTree->Draw(Form("1e6*%s_%s-%f*%f>>slug%i_detcorr_%s",asymType.Data(),device.Data(),nonLin,aqCorr[i],slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_%s_Device_Error_Code==0",cutList[i].Data(),device.Data())); TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_detcorr_%s",slugNum,plotTitles[i].Data())); detPatCorrMean[i] = htemp->GetMean(); detPatCorrErr[i] = htemp->GetMeanError(); } cDetCorr->cd(10); patAsymMean[0] = detPatCorrMean[2]; patAsymErr[0] = detPatCorrErr[2]; patAsymMean[1] = detPatCorrMean[3]; patAsymErr[1] = detPatCorrErr[3]; patAsymMean[2] = detPatCorrMean[5]; patAsymErr[2] = detPatCorrErr[5]; patAsymMean[3] = detPatCorrMean[6]; patAsymErr[3] = detPatCorrErr[6]; TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr); grp->SetMarkerStyle(21); grp->Draw("ap"); grp->Fit("pol0"); grp->SetTitle("Asymmetry per pattern: --, -+ +- ++"); grp->GetYaxis()->SetTitle("Asymmetry (ppm)"); grp->GetYaxis()->SetTitleOffset(1.3); grp->GetXaxis()->SetTitle("Pattern"); cDetCorr->Update(); cDetCorr->Modified(); for (Int_t i=0; i<4; i++){ std::cout<<patAsymMean[i]<<" "<<patAsymErr[i]<<std::endl; } if(saveFile){ cDetCorr->SaveAs(Form("%s/%i_%s_%sCorrected.png",plotDir.Data(),slugNum,asymType.Data(),device.Data())); } }
void DrawNCLUSTER() { //=========Macro generated from canvas: r1/Energy //========= (Fri Apr 6 17:14:48 2012) by ROOT version5.28/00g TCanvas *r1 = new TCanvas("r1", "Ncluster",12,24,550,741); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetFrameLineWidth(1); r1->Range(0,0,1,1); r1->SetFillColor(0); r1->SetBorderMode(0); r1->SetBorderSize(0); r1->SetTickx(1); r1->SetTicky(1); r1->SetLeftMargin(0.16); r1->SetRightMargin(0.01); r1->SetTopMargin(0.0256917); r1->SetBottomMargin(0.07692308); r1->SetFrameBorderMode(); // ------------>Primitives in pad: r1_1 TPad *r1_1 = new TPad("r1_1", "Energy_1",0.02,0.37,0.95,0.99); r1_1->Draw(); r1_1->cd(); r1_1->Range(-19,0.01,95,95); r1_1->SetFillColor(0); r1_1->SetBorderMode(0); r1_1->SetBorderSize(2); r1_1->SetTickx(1); r1_1->SetTicky(1); r1_1->SetLeftMargin(0.16); r1_1->SetRightMargin(0.01); r1_1->SetTopMargin(0.02); r1_1->SetBottomMargin(0); r1_1->SetFrameBorderMode(0); r1_1->SetFrameBorderMode(0); TH1D *he = new TH1D("he"," ",55,0,55); he->SetMinimum(0.01); he->SetMaximum(70); he->SetStats(0); he->GetXaxis()->SetTitle("E_{beam} [GeV]"); he->GetXaxis()->SetLabelFont(43); he->GetXaxis()->SetLabelSize(0); he->GetXaxis()->SetTitleFont(43); he->GetXaxis()->SetTitleSize(0); he->GetYaxis()->SetTitle("<N_{cluster}>"); he->GetYaxis()->SetLabelFont(43); he->GetYaxis()->SetTitleSize(30); he->GetYaxis()->SetLabelSize(20); he->GetYaxis()->SetTitleFont(43); he->GetYaxis()->SetTitleOffset(1.7); he->GetZaxis()->SetLabelFont(42); he->GetZaxis()->SetTitleSize(0.05); he->GetZaxis()->SetTitleFont(42); he->Draw(""); std::vector<result> resultData=readTXT(std::string("ncluster_augsep2012_electron.txt")); TGraphErrors *gre = new TGraphErrors(resultData.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetLineColor(1); gre->SetFillStyle(1); gre->SetFillColor(1); gre->SetLineWidth(2); gre->SetMarkerColor(1); gre->SetMarkerStyle(34); gre->SetMarkerSize(1.2); for(unsigned int i=0; i<resultData.size(); i++){ gre->SetPoint(i,resultData.at(i).ebeam,resultData.at(i).ncluster); gre->SetPointError(i,0,resultData.at(i).nclusterError); } TH1F *Graph_Graph3 = new TH1F("Graph_Graph3","Graph",100,0,87.5); Graph_Graph3->SetMinimum(0); Graph_Graph3->SetMaximum(1193.483); Graph_Graph3->SetDirectory(0); Graph_Graph3->SetStats(0); Graph_Graph3->GetXaxis()->SetLabelFont(42); Graph_Graph3->GetXaxis()->SetTitleSize(0.05); Graph_Graph3->GetXaxis()->SetTitleFont(42); Graph_Graph3->GetYaxis()->SetLabelFont(42); Graph_Graph3->GetYaxis()->SetTitleSize(0.05); Graph_Graph3->GetYaxis()->SetTitleFont(42); Graph_Graph3->GetZaxis()->SetLabelFont(42); Graph_Graph3->GetZaxis()->SetTitleSize(0.05); Graph_Graph3->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph3); gre->Draw("p"); std::vector<result> resultFTFP=readTXT(std::string("ncluster_ftfp_bert_hp_electron.txt")); gre = new TGraphErrors(resultFTFP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetFillColor(kRed-3); gre->SetMarkerColor(kRed-3); gre->SetLineWidth(2); gre->SetMarkerStyle(20); for(unsigned int i=0; i<resultFTFP.size(); i++){ gre->SetPoint(i,resultFTFP.at(i).ebeam,resultFTFP.at(i).ncluster); gre->SetPointError(i,0,resultFTFP.at(i).nclusterError); } TH1F *Graph1 = new TH1F("Graph1","Graph",100,0,87.17072); Graph1->SetMinimum(2.655724); Graph1->SetMaximum(88.56778); Graph1->SetDirectory(0); Graph1->SetStats(0); Graph1->GetXaxis()->SetLabelFont(42); Graph1->GetXaxis()->SetTitleSize(0.05); Graph1->GetXaxis()->SetTitleFont(42); Graph1->GetYaxis()->SetLabelFont(42); Graph1->GetYaxis()->SetTitleSize(0.05); Graph1->GetYaxis()->SetTitleFont(42); Graph1->GetZaxis()->SetLabelFont(42); Graph1->GetZaxis()->SetTitleSize(0.05); Graph1->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph1); gre->Draw("p"); std::vector<result> resultQGSP=readTXT(std::string("ncluster_qgsp_bert_hp_electron.txt")); gre = new TGraphErrors(resultQGSP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); gre->SetFillColor(kBlue-6); gre->SetMarkerColor(kBlue-6); gre->SetLineWidth(2); gre->SetMarkerStyle(25); for(unsigned int i=0; i<resultQGSP.size(); i++){ gre->SetPoint(i,resultQGSP.at(i).ebeam,resultQGSP.at(i).ncluster); gre->SetPointError(i,0,resultQGSP.at(i).nclusterError); } TH1F *Graph_Graph2 = new TH1F("Graph_Graph2","Graph",100,0,87.5); Graph_Graph2->SetMinimum(0); Graph_Graph2->SetMaximum(1193.483); Graph_Graph2->SetDirectory(0); Graph_Graph2->SetStats(0); Graph_Graph2->GetXaxis()->SetLabelFont(42); Graph_Graph2->GetXaxis()->SetTitleSize(0.05); Graph_Graph2->GetXaxis()->SetTitleFont(42); Graph_Graph2->GetYaxis()->SetLabelFont(42); Graph_Graph2->GetYaxis()->SetTitleSize(0.05); Graph_Graph2->GetYaxis()->SetTitleFont(42); Graph_Graph2->GetZaxis()->SetLabelFont(42); Graph_Graph2->GetZaxis()->SetTitleSize(0.05); Graph_Graph2->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph2); gre->Draw("p"); TLegend *leg = new TLegend(0.15,0.7,0.75,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("Graph_Graph3","SDHCAL DATA (H6 Cern SPS)","p"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(34); entry->SetMarkerSize(1.2); entry=leg->AddEntry("Graph1","FTFP_BERT_HP","p"); entry->SetLineColor(kRed-3); entry->SetLineStyle(kRed-3); entry->SetLineWidth(kRed-3); entry->SetMarkerColor(kRed-3); entry->SetMarkerStyle(20); entry->SetMarkerSize(1.0); entry=leg->AddEntry("Graph_Graph2","QGSP_BERT_HP","p"); entry->SetLineColor(kBlue-6); entry->SetLineStyle(kBlue-6); entry->SetLineWidth(kBlue-6); entry->SetMarkerColor(kBlue-6); entry->SetMarkerStyle(25); entry->SetMarkerSize(0.9); leg->Draw(); TText *tex=new TText(); tex->SetTextSize(0.05); tex->SetTextColor(kGray+2); //tex->DrawTextNDC(0.5,0.05,"SDHCAL Preliminary"); tex->DrawTextNDC(0.3,0.05,"CALICE Fe-SDHCAL Preliminary"); r1_1->Modified(); r1->cd(); // ------------>Primitives in pad: r1_2 TPad *r1_2 = new TPad("r1_2", "Energy_2",0.02,0.0,0.95,0.38); r1_2->Draw(); r1_2->cd(); r1_2->Range(-19,-0.06545455,95,0.048); r1_2->SetFillColor(0); r1_2->SetBorderMode(0); r1_2->SetBorderSize(2); r1_2->SetTickx(1); r1_2->SetTicky(1); r1_2->SetLeftMargin(0.16); r1_2->SetRightMargin(0.01); r1_2->SetTopMargin(0.0); r1_2->SetBottomMargin(0.23); r1_2->SetFrameBorderMode(0); r1_2->SetFrameBorderMode(0); TH1D *hd = new TH1D("hd"," ",55,0,55); hd->SetMinimum(-0.20); hd->SetMaximum(0.20); hd->SetStats(0); hd->GetXaxis()->SetTitle("E_{beam} [GeV]"); hd->GetXaxis()->SetLabelFont(43); hd->GetXaxis()->SetLabelSize(20); hd->GetXaxis()->SetTitleFont(43); hd->GetXaxis()->SetTitleSize(30); hd->GetXaxis()->SetTitleOffset(2.); hd->GetYaxis()->SetTitle("(#DeltaN_{cluster})/N_{data}"); hd->GetYaxis()->SetLabelFont(43); hd->GetYaxis()->SetLabelSize(20); hd->GetYaxis()->SetTitleSize(30); hd->GetYaxis()->SetTitleOffset(1.7); hd->GetYaxis()->SetTitleFont(43); hd->GetYaxis()->SetNdivisions(505); hd->GetZaxis()->SetLabelFont(42); hd->GetZaxis()->SetTitleSize(0.05); hd->GetZaxis()->SetTitleFont(42); hd->Draw(""); float deltaError; float delta; gre = new TGraphErrors(resultQGSP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); for(unsigned int i=0; i<resultQGSP.size(); i++){ delta=(resultQGSP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster; deltaError=1/resultData.at(i).ncluster* sqrt(pow(resultQGSP.at(i).nclusterError,2) + pow(resultQGSP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2)); gre->SetPoint(i,resultQGSP.at(i).ebeam,delta); gre->SetPointError(i,0,deltaError); } gre->SetLineWidth(2); gre->SetLineColor(kBlue-6); gre->SetMarkerColor(kBlue-6); gre->SetMarkerSize(1.0); gre->SetMarkerStyle(25); gre->Draw("p"); gre = new TGraphErrors(resultFTFP.size()); gre->SetName("Graph"); gre->SetTitle("Graph"); for(unsigned int i=0; i<resultFTFP.size(); i++){ delta=(resultFTFP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster; deltaError=1/resultData.at(i).ncluster* sqrt(pow(resultFTFP.at(i).nclusterError,2) + pow(resultFTFP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2)); gre->SetPoint(i,resultFTFP.at(i).ebeam,delta); gre->SetPointError(i,0,deltaError); } gre->SetLineWidth(2); gre->SetLineColor(kRed-3); gre->SetMarkerColor(kRed-3); gre->SetMarkerSize(1.0); gre->SetMarkerStyle(20); gre->Draw("p"); TF1 *lin1 = new TF1("lin1","0",-0.01,95); lin1->SetFillColor(19); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(1); lin1->SetLineColor(1); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); lin1 = new TF1("lin1","0.1",0.01,95); lin1->SetFillColor(1); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(2); lin1->SetLineColor(17); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); lin1 = new TF1("lin1","-0.1",0.01,95); lin1->SetFillColor(1); lin1->SetFillStyle(0); lin1->SetLineWidth(1); lin1->SetLineStyle(2); lin1->SetLineColor(17); lin1->GetXaxis()->SetLabelFont(42); lin1->GetXaxis()->SetTitleSize(0.05); lin1->GetXaxis()->SetTitleFont(42); lin1->GetYaxis()->SetLabelFont(42); lin1->GetYaxis()->SetTitleSize(0.05); lin1->GetYaxis()->SetTitleFont(42); lin1->Draw("same"); r1_2->Modified(); r1->cd(); r1->Modified(); r1->cd(); r1->SetSelected(r1); r1->SaveAs("../plots/NCLUSTERELECTRON.pdf"); }
void DrawKinvarPlot(TString filename="kinvarset/FMSOR_Pt_vs_run.root", TString classname="pi0") { TFile * infile = new TFile(filename.Data(),"READ"); char trig[32]; char typ[32]; char tmp[128]; TString tmpstr = filename; tmpstr.ReplaceAll("_"," "); TRegexp re("^.*\/"); tmpstr(re) = ""; cout << tmpstr << endl; sscanf(tmpstr.Data(),"%s %s",trig,typ); printf("%s %s\n",trig,typ); TString hname = "h2_"+classname; TH2D * h = (TH2D*)infile->Get(hname.Data()); TString gname = "g_"+classname; TGraphErrors * g = (TGraphErrors*)infile->Get(gname.Data()); TString gtname = "gt_"+classname; TGraphErrors * gt; if(!strcmp(typ,"Pt")) gt = (TGraphErrors*)infile->Get(gtname.Data()); char htitle[256]; char hnewtitle[512]; strcpy(htitle,h->GetTitle()); sprintf(hnewtitle,"%s -- %s triggers",htitle,trig); h->SetTitle(hnewtitle); h->SetMinimum(0.001); if(!strcmp(typ,"Pt")) { gt->SetLineWidth(2); gt->SetLineColor(kBlack); }; // temporary hack to cut out fluctuations of pt_thresh vs. run to 0 Double_t xx,yy; Int_t gtn = gt->GetN(); for(int ii=0; ii<gtn; ii++) { gt->GetPoint(ii,xx,yy); printf("xx=%f yy=%f\n",xx,yy); if(yy<0.001) gt->RemovePoint(ii); }; // drawing range Float_t xmin = h->GetXaxis()->GetXmin(); Float_t xmax = h->GetXaxis()->GetXmax(); xmax = 515; if(xmax<gtn) { fprintf(stderr,"\nWARNING: xmax < gt->GetN(); graphs will be cut off!\n\n"); }; TCanvas * c = new TCanvas("c","c",1500,700); c->Divide(1,2); gStyle->SetOptStat(0); for(int x=1; x<=2; x++) c->GetPad(x)->SetGrid(1,1); c->cd(1); c->GetPad(1)->SetLogz(); h->GetXaxis()->SetRangeUser(xmin,xmax); h->Draw("colz"); if(!strcmp(typ,"Pt")) gt->Draw("LX"); c->cd(2); g->SetFillColor(kGray); printf("%f %f\n",xmin,xmax); g->GetXaxis()->SetLimits(xmin,xmax); g->GetXaxis()->SetRangeUser(xmin,xmax); /* g->Draw("A3"); g->Draw("PLX"); */ g->Draw("APLX"); TString outname = filename.ReplaceAll(".root"," "+classname); outname = outname+".png"; c->Print(outname.Data(),"png"); };
/// /// Plot the discrepancy between the observable and the predicted /// observable when making predictions about observables by scanning /// them. This checks if the chi2 term of the observable is tight enough. /// This only works for 1D scans for now. /// void ParameterEvolutionPlotter::plotObsScanCheck() { vector<RooSlimFitResult*> results = curveResults; cout << "ParameterEvolutionPlotter::plotObsScanCheck() : plotting ..." << endl; TCanvas *c2 = newNoWarnTCanvas("plotObsScanCheck"+getUniqueRootName(), title, 800,600); c2->SetLeftMargin(0.2); // get observable TGraphErrors *g = new TGraphErrors(results.size()); int iGraph = 0; for ( int i=0; i<results.size(); i++ ){ assert(results[i]); // get value of observable float obsValue = results[i]->getParVal(scanVar1); float obsError = w->var(scanVar1)->getError(); // get value of theory prediction setParameters(w,parsName,results[i]); TString thName = scanVar1; thName.ReplaceAll("_obs","_th"); if ( !w->function(thName) ){ cout << "ParameterEvolutionPlotter::plotObsScanCheck() : ERROR : theory value not found: " << thName << endl; continue; } float thValue = w->function(thName)->getVal(); g->SetPoint(iGraph, iGraph, obsValue-thValue); g->SetPointError(iGraph, 0., obsError); iGraph++; } g->SetTitle(scanVar1); g->GetXaxis()->SetTitle("scan step"); g->GetYaxis()->SetTitleSize(0.06); g->GetYaxis()->SetLabelSize(0.04); g->GetYaxis()->SetTitleOffset(1.5); g->GetYaxis()->SetTitle(scanVar1); Int_t ci = 927; TColor *col = new TColor(ci, 0, 0, 1, " ", 0.5); g->SetFillColor(ci); g->SetFillStyle(1001); g->Draw("a3"); g->Draw("lxsame"); c2->Update(); savePlot(c2, "parEvolutionObsSanCheck_"+name+"_"+scanVar1); }
//_________________________________________________________________________________ void integratedSplinesV2a(double seed = 231) { //Load the data int nPoints = 9; vector <double> xData, yData, yErrorData; FillRandVectors(nPoints, xData, yData, yErrorData, seed); //create random vectors for y values and y error vector //Intialization of the variables const int npar = nPoints; const int orderSpline = 4; const int nbreak = npar+2-orderSpline; double stepSpline = 0.01; double xminBSplineWorkspace = 0; double xmaxBSplineWorkspace = 9; acc_GLOB = gsl_interp_accel_alloc (); spline_GLOB = gsl_spline_alloc (gsl_interp_cspline, nPoints); bw_GLOB = gsl_bspline_alloc(orderSpline, nbreak); //B-spline clock_t tbstart = clock(); TGraph *bGraph = bSpline(nPoints, npar, xData, yData, yErrorData, stepSpline, xminBSplineWorkspace, xmaxBSplineWorkspace); bGraph->SetTitle(""); bGraph->GetXaxis()->SetTitle("X-axis Arbitrary Units"); bGraph->GetYaxis()->SetTitle("Y-axis Arbirary Units"); clock_t tbstop = clock(); //C-spline clock_t tcstart = clock(); TGraph *cGraph = cSpline(nPoints, npar, xData, yData, yErrorData, stepSpline); clock_t tcstop = clock(); cGraph->SetLineColor(kRed); //Control points TGraphErrors *pGraph = new TGraphErrors(nPoints, &xData[0], &yData[0], 0 ,&yErrorData[0]); pGraph-> SetMarkerStyle(20); pGraph->SetMarkerColor(kBlue); //Free the memory for the spline gsl_spline_free (spline_GLOB); //frees the memory used by the spline gsl_interp_accel_free (acc_GLOB); gsl_bspline_free(bw_GLOB); // time histogram int nbins = 100; double xlow = 0; double xup = 0.001; TH1D *hello2 = new TH1D("TimeB","TimeB; time; number of runs", nbins, xlow, xup); double timeb = ((float)tbstop-(float)tbstart)/ CLOCKS_PER_SEC; hello2->Fill(timeb); TH1D *hello3 = new TH1D("TimeC","TimeC; time; number of runs", nbins, xlow, xup); hello3->SetLineColor(kRed); double timec = ((float)tcstop-(float)tcstart)/ CLOCKS_PER_SEC; hello3->Fill(timec); //Legends TLegend *leg = new TLegend(0.15,0.70,0.4,0.85); leg->SetLineColor(kWhite); leg->SetFillColor(kWhite); leg->SetMargin(0.3); leg->AddEntry(pGraph,"Simulated data","lp"); leg->AddEntry(bGraph,"b-spline","l"); leg->AddEntry(cGraph,"c-spline","l"); //Draw to canvas TCanvas *can1 = new TCanvas("c2", "Timing"); can1->cd(); hello2->Draw(""); hello3->Draw("same"); TCanvas *c1 = new TCanvas("c1", "Spline Comparison"); c1->cd(); bGraph->Draw("al"); cGraph->Draw("same l"); pGraph->Draw("same pz"); leg->Draw(); }
void para_12TeV_2Lep_plots_All() { //=========Macro generated from canvas: c1/Parameter1 //========= (Sun Nov 22 20:05:00 2015) by ROOT version6.02/12 TCanvas *c1 = new TCanvas("c1", "Parameter1",0,22,1000,600); gStyle->SetOptStat(0); c1->Range(-4.375,-0.2745458,39.375,2.490986); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetGridx(); c1->SetGridy(); c1->SetFrameBorderMode(0); c1->SetFrameBorderMode(0); TH1F *NuisanceParameterFreed2 = new TH1F("NuisanceParameterFreed2","Mu",35,0,35); NuisanceParameterFreed2->SetMinimum(0.00200744); NuisanceParameterFreed2->SetMaximum(2.214433); NuisanceParameterFreed2->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); NuisanceParameterFreed2->SetLineColor(ci); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(1,"MUONS_MS"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(2,"Luminosity"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(3,"XS_Zb"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(4,"FT_EFF_Eigen_C_2"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(5,"MUON_EFF_TrigStatUncertainty"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_C_3"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(7,"FT_EFF_Eigen_B_0"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(8,"MUON_EFF_SYS"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(9,"MUON_EFF_STAT"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_Light_3"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(11,"FT_EFF_Eigen_Light_4"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(12,"global"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(13,"MUONS_SCALE"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(14,"MUON_ISO_STAT"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_C_0"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(17,"FT_EFF_Eigen_B_1"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(18,"XS_diboson"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(19,"XS_st"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(20,"MUON_EFF_TrigSystUncertainty"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(21,"EG_RESOLUTION_ALL"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(22,"FT_EFF_Eigen_B_2"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(23,"MUONS_ID"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(24,"EL_EFF_Reco_TotalCorrUncertainty"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(25,"EG_SCALE_ALL"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(26,"FT_EFF_extrapolation"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(27,"FT_EFF_Eigen_Light_1"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_2"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(29,"FT_EFF_Eigen_C_1"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(30,"MUON_ISO_SYS"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(31,"FT_EFF_Eigen_Light_0"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(32,"EL_EFF_ID_TotalCorrUncertainty"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(33,"XS_Zl"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(34,"XS_Zc"); NuisanceParameterFreed2->GetXaxis()->SetBinLabel(35,"XS_ttbar"); NuisanceParameterFreed2->GetXaxis()->SetLabelFont(42); NuisanceParameterFreed2->GetXaxis()->SetLabelSize(0.035); NuisanceParameterFreed2->GetXaxis()->SetTitleSize(0.035); NuisanceParameterFreed2->GetXaxis()->SetTitleFont(42); NuisanceParameterFreed2->GetYaxis()->SetTitle("#mu_{best}"); NuisanceParameterFreed2->GetYaxis()->SetLabelFont(42); NuisanceParameterFreed2->GetYaxis()->SetLabelSize(0.035); NuisanceParameterFreed2->GetYaxis()->SetTitleSize(0.035); NuisanceParameterFreed2->GetYaxis()->SetTitleFont(42); NuisanceParameterFreed2->GetZaxis()->SetLabelFont(42); NuisanceParameterFreed2->GetZaxis()->SetLabelSize(0.035); NuisanceParameterFreed2->GetZaxis()->SetTitleSize(0.035); NuisanceParameterFreed2->GetZaxis()->SetTitleFont(42); NuisanceParameterFreed2->Draw("hist"); Double_t _fx1002[37] = { 0, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 30.5, 31.5, 32.5, 33.5, 34.5, 0 }; Double_t _fy1002[37] = { 0, 0.00200744, 2.065197, 2.090439, 2.097085, 2.102307, 2.102459, 2.103994, 2.109032, 2.110826, 2.110827, 2.110944, 2.111107, 2.111297, 2.111303, 2.111389, 2.11147, 2.1115, 2.112008, 2.112152, 2.112174, 2.112884, 2.113456, 2.113847, 2.114265, 2.114548, 2.11588, 2.116422, 2.117402, 2.123061, 2.129504, 2.131184, 2.133743, 2.13776, 2.138737, 2.214433, 0 }; Double_t _fex1002[37] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Double_t _fey1002[37] = { 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; TGraphErrors *gre = new TGraphErrors(37,_fx1002,_fy1002,_fex1002,_fey1002); gre->SetName(""); gre->SetTitle(""); gre->SetFillColor(1); gre->SetMarkerStyle(20); gre->SetMarkerSize(1.2); TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","",100,0,37.95); Graph_Graph1002->SetMinimum(-12.22144); Graph_Graph1002->SetMaximum(14.43588); Graph_Graph1002->SetDirectory(0); Graph_Graph1002->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1002->SetLineColor(ci); Graph_Graph1002->GetXaxis()->SetLabelFont(42); Graph_Graph1002->GetXaxis()->SetLabelSize(0.035); Graph_Graph1002->GetXaxis()->SetTitleSize(0.035); Graph_Graph1002->GetXaxis()->SetTitleFont(42); Graph_Graph1002->GetYaxis()->SetLabelFont(42); Graph_Graph1002->GetYaxis()->SetLabelSize(0.035); Graph_Graph1002->GetYaxis()->SetTitleSize(0.035); Graph_Graph1002->GetYaxis()->SetTitleFont(42); Graph_Graph1002->GetZaxis()->SetLabelFont(42); Graph_Graph1002->GetZaxis()->SetLabelSize(0.035); Graph_Graph1002->GetZaxis()->SetTitleSize(0.035); Graph_Graph1002->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1002); gre->Draw("p"); TLegend *leg = new TLegend(0.1,0.4,0.4,0.95,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(72); leg->SetTextSize(0.015); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("","global","P"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(1.2); entry->SetTextFont(72); leg->Draw(); TPaveText *pt = new TPaveText(0.4694177,0.94,0.5305823,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("Mu"); pt->Draw(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void draw(){ TGraphErrors *gll = new TGraphErrors(); TGraphErrors *gjj = new TGraphErrors(); for (int i = 0 ; i < 15 ; ++i){ float content = h_lep_m_signal->GetBinContent(i) + h_lep_m_background->GetBinContent(i) + h_lep_m_wjets->GetBinContent(i); gll -> SetPoint(i,i*100-50.,content); float errorb = h_lep_m_background->GetBinContent(i)*0.08*h_lep_m_background->GetBinContent(i); float errors = h_lep_m_signal->GetBinContent(i)*0.08*h_lep_m_signal->GetBinContent(i); float errorw = 0.40 * h_lep_m_wjets->GetBinContent(i)*h_lep_m_wjets->GetBinContent(i); float pesi = h_lep_m_background->GetBinContent(i) + h_lep_m_signal->GetBinContent(i) + h_lep_m_wjets->GetBinContent(i); float error = sqrt(errorb*errorb + errorw*errorw + errors*errors) / pesi; gll -> SetPointError(i,100/2.,error); } for (int i = 0 ; i < 10 ; ++i){ float content = h_jet_m_signal->GetBinContent(i) + h_jet_m_background->GetBinContent(i) + h_jet_m_wjets->GetBinContent(i); gjj -> SetPoint(i,i*500-250.,content); float errorb = h_jet_m_background->GetBinContent(i)*0.08*h_jet_m_background->GetBinContent(i); float errors = h_jet_m_signal->GetBinContent(i)*0.08*h_jet_m_signal->GetBinContent(i); float errorw = 0.40 * h_jet_m_wjets->GetBinContent(i)*h_jet_m_wjets->GetBinContent(i); float pesi = h_jet_m_background->GetBinContent(i) + h_jet_m_signal->GetBinContent(i) + h_jet_m_wjets->GetBinContent(i); float error = sqrt(errorb*errorb + errorw*errorw + errors*errors) / pesi; gjj -> SetPointError(i,500/2.,error); } gll->SetFillStyle(3002); gjj->SetFillStyle(3002); gll -> SetFillColor(kBlack); gjj -> SetFillColor(kBlack); cout<<"signal tot = "<<scontTot<<endl; cout<<"signal mjj = "<<scontMjj<<endl; cout<<"signal deta = "<<scontDeta<<endl; cout<<"signal mll = "<<scontMll<<endl; cout<<"signal dy = "<<scontDY<<endl; cout<<"signal met = "<<scontMET<<"\n"<<endl; cout<<"background tot = "<<contTot<<endl; cout<<"background mjj = "<<contMjj<<endl; cout<<"background deta = "<<contDeta<<endl; cout<<"background mll = "<<contMll<<endl; cout<<"background dy = "<<contDY<<endl; cout<<"background met = "<<contMET<<"\n"<<endl; cout<<"wjets tot = "<<wcontTot<<endl; cout<<"wjets mjj = "<<wcontMjj<<endl; cout<<"wjets deta = "<<wcontDeta<<endl; cout<<"wjets mll = "<<wcontMll<<endl; cout<<"wjets dy = "<<wcontDY<<endl; cout<<"wjets met = "<<wcontMET<<"\n"<<endl; TH1F *axis = new TH1F ("mll Signal & Backgrounds","mll Signal & Backgrounds",15,0.,1500.); axis -> GetXaxis() -> SetRangeUser(0.,1500.); axis -> GetYaxis() -> SetRangeUser(0.,120.); axis -> GetXaxis () -> SetTitle("Leptons Invariant Mass [GeV]"); axis -> GetYaxis () -> SetTitle("Counts per Bin"); axis -> GetYaxis () -> SetTitleOffset(1.3); axis -> SetStats(0); TH1F *axis2 = new TH1F ("mjj Signal & Backgrounds","mjj Signal & Backgrounds",10,0.,5000.); axis2 -> GetXaxis() -> SetRangeUser(0.,5000.); axis2 -> GetYaxis() -> SetRangeUser(0.,105.); axis2 -> GetXaxis () -> SetTitle("Tag Jets Invariant Mass [GeV]"); axis2 -> GetYaxis () -> SetTitle("Counts per Bin"); axis2 -> GetYaxis () -> SetTitleOffset(1.3); axis2 -> SetStats(0); THStack* hs = new THStack("hs","mll Signal & Background"); h_lep_m_signal -> SetFillColor(kGreen+1); h_lep_m_background -> SetFillColor(kRed+1); h_lep_m_wjets -> SetFillColor(kBlue+1); hs -> Add ( h_lep_m_background ); hs -> Add ( h_lep_m_wjets ); hs -> Add ( h_lep_m_signal ); TCanvas *c1 = new TCanvas("c1","c1",600.,600.); c1 -> cd(); axis -> Draw(); //c1 -> DrawFrame(0.,0.,1500.,40.); hs -> Draw("same"); hs -> GetXaxis () -> SetTitle("Leptons Invariant Mass [GeV]"); hs -> GetYaxis () -> SetRangeUser(0.,40.); TLegend *leg = new TLegend(0.54,0.3,0.89,0.5); leg->SetHeader("Luminosity = 300fb^{-1} @ 13TeV"); leg->AddEntry(h_lep_m_signal,"Signal","f"); leg->AddEntry(h_lep_m_background,"QCD Background","f"); leg->AddEntry(h_lep_m_wjets,"W + Jets Background","f"); leg->SetFillColor(kWhite); leg->SetLineColor(kWhite); leg->Draw(); gll->Draw("same,2"); c1 -> Print("stack.C"); c1 -> Print("stack.pdf","pdf"); c1 -> Print("stack.png","png"); TCanvas *c2 = new TCanvas("c2","c2",600.,600.); c2 -> cd(); hs -> Draw("nostack"); hs -> GetXaxis () -> SetTitle("Leptons Invariant Mass [GeV]"); hs -> GetYaxis () -> SetRangeUser(0.,20.); c2 -> Print("nostack.C"); c2 -> Print("nostack.pdf","pdf"); THStack* hs2 = new THStack("hs2","mjj Signal & Background"); h_jet_m_signal -> SetFillColor(kGreen+1); h_jet_m_background -> SetFillColor(kRed+1); h_jet_m_wjets -> SetFillColor(kBlue+1); hs2 -> Add ( h_jet_m_background ); hs2 -> Add ( h_jet_m_wjets ); hs2 -> Add ( h_jet_m_signal ); TCanvas *c12 = new TCanvas("c12","c12",600.,600.); c12 -> cd(); axis2 -> Draw(); //c12 -> DrawFrame(0.,0.,5000.,35.); hs2 -> Draw("same"); hs2 -> GetXaxis () -> SetTitle("Tag Jets Invariant Mass [GeV]"); hs2 -> GetYaxis () -> SetRangeUser(0.,35.); TLegend *leg2 = new TLegend(0.54,0.3,0.89,0.5); leg2->SetHeader("Luminosity = 300fb^{-1} @ 13TeV"); leg2->AddEntry(h_jet_m_signal,"Signal","f"); leg2->AddEntry(h_jet_m_background,"QCD Background","f"); leg2->AddEntry(h_jet_m_wjets,"W + Jets Background","f"); leg2->SetFillColor(kWhite); leg2->SetLineColor(kWhite); leg2->Draw(); gjj->Draw("same,2"); c12 -> Print("stack_mjj.C"); c12 -> Print("stack_mjj.pdf","pdf"); c12 -> Print("stack_mjj.png","png"); TCanvas *c22 = new TCanvas("c22","c22",600.,600.); c22 -> cd(); hs2 -> Draw("nostack"); hs2 -> GetXaxis () -> SetTitle("Tag Jet Invariant Mass [GeV]"); hs2 -> GetYaxis () -> SetRangeUser(0.,20.); c22 -> Print("nostack_mjj.C"); c22 -> Print("nostack_mjj.pdf","pdf"); THStack* hs3 = new THStack("hs3","BDT Signal & Background"); h_BDT_signal -> SetFillColor(kGreen+1); h_BDT_background -> SetFillColor(kRed+1); h_BDT_wjets -> SetFillColor(kBlue+1); hs3 -> Add ( h_BDT_background ); hs3 -> Add ( h_BDT_wjets ); hs3 -> Add ( h_BDT_signal ); TCanvas *c13 = new TCanvas("c13","c13",600.,600.); c13 -> cd(); hs3 -> Draw(); hs3 -> GetXaxis () -> SetTitle("BDT discriminant"); hs3 -> GetYaxis () -> SetRangeUser(0.,60.); TLegend *leg3 = new TLegend(0.54,0.3,0.89,0.5); leg3->SetHeader("Luminosity = 300fb^{-1} @ 13TeV"); leg3->AddEntry(h_BDT_signal,"Signal","f"); leg3->AddEntry(h_BDT_background,"QCD Background","f"); leg3->AddEntry(h_BDT_wjets,"W + Jets Background","f"); leg3->SetFillColor(kWhite); leg3->SetLineColor(kWhite); leg3->Draw(); c13 -> Print("stack_BDT.C"); c13 -> Print("stack_BDT.pdf","pdf"); TCanvas *c23 = new TCanvas("c23","c23",600.,600.); c23 -> cd(); hs3 -> Draw("nostack"); hs3 -> GetXaxis () -> SetTitle("BDT discriminant"); hs3 -> GetYaxis () -> SetRangeUser(0.,20.); c23 -> Print("nostack_BDT.C"); c23 -> Print("nostack_BDT.pdf","pdf"); THStack* hs4 = new THStack("hs4","BDT Signal & Backgrounds Before Cuts"); h_BDT_signalNoCuts -> SetFillColor(kGreen+1); h_BDT_backgroundNoCuts -> SetFillColor(kRed+1); h_BDT_wjetsNoCuts -> SetFillColor(kBlue+1); hs4 -> Add ( h_BDT_backgroundNoCuts ); hs4 -> Add ( h_BDT_wjetsNoCuts ); hs4 -> Add ( h_BDT_signalNoCuts ); TCanvas *c14 = new TCanvas("c14","c14",600.,600.); c14 -> cd(); hs4 -> Draw(); hs4 -> GetXaxis () -> SetTitle("BDT discriminant"); hs4 -> GetYaxis () -> SetRangeUser(0.,60.); TLegend *leg4 = new TLegend(0.54,0.3,0.89,0.5); leg4->SetHeader("Luminosity = 300fb^{-1} @ 13TeV"); leg4->AddEntry(h_BDT_signal,"Signal","f"); leg4->AddEntry(h_BDT_background,"QCD Background","f"); leg4->AddEntry(h_BDT_wjets,"W + Jets Background","f"); leg4->SetFillColor(kWhite); leg4->SetLineColor(kWhite); leg4->Draw(); c14 -> Print("stack_BDT_nocuts.C"); c14 -> Print("stack_BDT_nocuts.pdf","pdf"); TCanvas *c24 = new TCanvas("c24","c24",600.,600.); c24 -> cd(); hs4 -> Draw("nostack"); hs4 -> GetXaxis () -> SetTitle("BDT discriminant"); hs4 -> GetYaxis () -> SetRangeUser(0.,20.); c24 -> Print("nostack_BDT_nocuts.C"); c24 -> Print("nostack_BDT_nocuts.pdf","pdf"); //TFile *outMVA = new TFile("outMVA_EWK_BDT_norm.root","RECREATE"); //TFile *outMVA = new TFile("outMVA_EWK_Fisher.root","RECREATE"); //TFile *outMVA = new TFile("outMVA_QCD_Fisher.root","RECREATE"); }
int postprocessingSysError(){ cout<<endl<<endl<<endl<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Postproccess all systematic uncertainties! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl; gErrorIgnoreLevel = 1001; const TString method = "RMS99"; const TString type = "PFCHS"; const int nEta =4; double eta_bins[5] = {0., 0.5, 1.1, 1.7, 2.3}; // For looking at different systematic uncertainties independently const bool QCD = true; const bool JEC = true; const bool flavor = true; const bool PU = true; const bool MC = true; TString etaString, filename; TString rootFiles, AuxString; TString JetType = "PFCHS"; TString Method = "RMS99"; double *ratioEtaBinnedX = new double[nEta]; double *ratioEtaBinnedY = new double[nEta]; double *ratioEtaBinnedEX = new double[nEta]; double *ratioEtaBinnedEY = new double[nEta]; double *ratioEtaBinnedQCDUpY = new double[nEta]; double *ratioEtaBinnedQCDDownY = new double[nEta]; TF1 *QCDuncertainty; if(QCD){ rootFiles = (TString) "scripts/plotsQCD/FinalErrorsQCD_" + type + (TString) "_" + method + (TString) ".root"; TFile *_file = TFile::Open(rootFiles); _file->GetObject("function",QCDuncertainty); } for(int eta = 0; eta < nEta; eta++){ //cout<< endl<<endl<<endl<<eta+1<<". eta Bin!!"<<endl; // Read the MC and data results rootFiles = (TString) "root_files_FINAL_data/Resolution_for_" + (long) (eta+1) + (TString) "_eta_bin_" + JetType + (TString) "_data_" + Method + (TString) ".root"; TGraphErrors* JERData = readTGraphErrors(rootFiles,"Graph;1","Graph"); rootFiles = (TString) "root_files_FINAL_mc/Resolution_for_" + (long) (eta+1) + (TString) "_eta_bin_" + JetType + (TString) "_mc_" + Method + (TString) ".root"; TGraphErrors* JERMC = readTGraphErrors(rootFiles,"Graph","Graph"); if(eta+1 == 1) etaString = Form("JER for |#eta| < %4.1f",etaBins[eta+1]); else etaString = Form("JER for %4.1f <|#eta|< %4.1f",etaBins[eta+1],etaBins[eta+2]); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 1.) Calculate the ratio w/o systematic Uncertainties int nData = JERData->GetN(); double *dataX = JERData->GetX(); double *dataY = JERData->GetY(); double *dataEX = JERData->GetEX(); double *dataEY = JERData->GetEY(); double *mcX = new double[nData]; double *mcY = new double[nData]; double *mcEX = new double[nData]; double *mcEY = new double[nData]; double *ratioX = new double[nData]; double *ratioY = new double[nData]; double *ratioEX = new double[nData]; double *ratioEY = new double[nData]; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Initialize some stuff for QCD uncertainty double *ratioQCDUpY = new double[nData]; double *ratioQCDDownY = new double[nData]; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int idx = 0; for(int i=0; i<nData; i++){ JERMC -> GetPoint(idx,mcX[i],mcY[i]); mcEX[i] = JERMC -> GetErrorX(idx); mcEY[i] = JERMC -> GetErrorY(idx); idx += 1; if(TMath::Abs(dataX[i]/mcX[i] - 1.) > 0.1){ i -= 1; continue; } ratioX[i] = 1./2.*(dataX[i] + mcX[i]); ratioY[i] = dataY[i]/mcY[i]; ratioEX[i] = 1./2.*TMath::Sqrt(TMath::Power(dataEX[i],2)+TMath::Power(mcEX[i],2)); ratioEY[i] = TMath::Sqrt(TMath::Power((1./mcY[i]),2)*TMath::Power(dataEY[i],2)+TMath::Power((dataY[i]/(TMath::Power(mcY[i],2))),2)*TMath::Power(mcEY[i],2)); if(QCD){ // For QCD ratioQCDUpY[i] = ratioY[i]*(1. + QCDuncertainty->Eval(ratioX[i])); ratioQCDDownY[i] = ratioY[i]*(1. - QCDuncertainty->Eval(ratioX[i])); //cout<<"QCDuncertainty->Eval(ratioX[i]) = "<<QCDuncertainty->Eval(ratioX[i])<<endl; } } TGraphErrors *Ratio = new TGraphErrors(nData,ratioX,ratioY,ratioEX,ratioEY); // For QCD TGraphErrors *QCDUp = new TGraphErrors(nData,ratioX,ratioQCDUpY,ratioEX,ratioEY); TGraphErrors *QCDDown = new TGraphErrors(nData,ratioX,ratioQCDDownY,ratioEX,ratioEY); if(eta+1 == 1 ) AuxString = Form("Ratio between Data and MC for |#eta| < %4.1f",etaBins[eta+1]); else AuxString = Form("Ratio between Data and MC for %4.1f <|#eta|<%4.1f",etaBins[eta+1],etaBins[eta+2]); Ratio -> SetTitle(AuxString); Ratio -> GetXaxis() -> SetTitle("Photon pT"); Ratio -> GetXaxis() -> SetTitleOffset(1.1); Ratio -> GetYaxis() -> SetTitle("Ratio of JER (DATA/MC)"); Ratio -> GetYaxis() -> SetTitleOffset(1.2); Ratio -> GetXaxis() -> SetLimits(0,600); TF1* f1 = new TF1("name","pol0",0,600); Ratio -> Fit("name","QR"); TF1* fitQCDUp = new TF1("fitQCDUp","pol0",0,600); TF1* fitQCDDown = new TF1("fitQCDDown","pol0",0,600); if(QCD){ // For QCD QCDUp -> Fit("fitQCDUp","QR"); QCDDown -> Fit("fitQCDDown","QR"); } TLegend *legend = 0; legend = new TLegend(0.55,0.8,0.9,0.9); legend -> SetFillColor(0); legend -> SetHeader(Form(" %4.3f #pm %4.3f", f1 -> GetParameter(0), f1->GetParError(0))); TCanvas *c11 = new TCanvas("c11",AuxString,200,10,500,500); c11 -> cd(); Ratio -> SetMinimum(0.5); Ratio -> SetMaximum(2.0); Ratio -> Draw("AP"); legend -> Draw("same"); TLatex* info = new TLatex(); info-> SetNDC(); info->SetTextSize(0.045); info->DrawLatex(0.22,0.84,Form("#splitline{#chi^{2} = %4.2f}{dof = %i}",f1 -> GetChisquare(),f1 -> GetNDF())); filename = (TString) "plots/Ratio_Resolution_for_" + (long) (eta+1) + (TString) "_eta_bin_" + type + (TString) "_data_comparison_" + method + (TString) ".pdf"; c11 -> SaveAs(filename); delete c11; ratioEtaBinnedX[eta] = (eta_bins[eta+1] + eta_bins[eta])/2.; ratioEtaBinnedY[eta] = f1 -> GetParameter(0); ratioEtaBinnedEX[0]=0.25; ratioEtaBinnedEX[1]=0.3; ratioEtaBinnedEX[2]=0.3; ratioEtaBinnedEX[3]=0.3; ratioEtaBinnedEY[eta] = f1->GetParError(0); if(QCD){ ratioEtaBinnedQCDUpY[eta] = fitQCDUp -> GetParameter(0); ratioEtaBinnedQCDDownY[eta]= fitQCDDown -> GetParameter(0); // Some additional stuff for QCD uncertainty TCanvas *plotsQCD = new TCanvas("plotsQCD","plotsQCD",200,10,500,500); plotsQCD -> cd(); Ratio -> SetMarkerColor(1); Ratio -> SetLineColor(1); Ratio -> SetMarkerStyle(20); Ratio -> GetFunction("name")->SetLineColor(1); QCDUp -> SetMarkerColor(3); QCDDown -> SetMarkerColor(3); QCDUp -> SetLineColor(3); QCDDown -> SetLineColor(3); QCDUp -> SetMarkerStyle(20); QCDDown -> SetMarkerStyle(20); QCDUp -> SetMarkerSize(0.8); QCDDown -> SetMarkerSize(0.8); QCDUp -> GetFunction("fitQCDUp")->SetLineColor(3); QCDDown -> GetFunction("fitQCDDown")->SetLineColor(3); Ratio -> Draw("AP"); QCDUp -> Draw("sameP"); QCDDown -> Draw("sameP"); delete legend; legend = new TLegend(0.4,0.8,0.9,0.9); legend -> SetFillColor(0); legend -> SetTextSize(0.045); legend -> AddEntry(Ratio,"Central Value","l"); legend -> AddEntry(QCDUp,Form("Upward variation: + %4.3f",abs(ratioEtaBinnedQCDUpY[eta]/ratioEtaBinnedY[eta]-1.)),"l"); legend -> AddEntry(QCDDown,Form("Downward variation: - %4.3f",abs(ratioEtaBinnedQCDDownY[eta]/ratioEtaBinnedY[eta]-1.)),"l"); legend -> Draw("same"); filename = (TString) "plots/plotsQCD_for_" + (long) (eta+1) + (TString) "_bin_" + type + (TString) "_" + method + (TString) ".pdf"; plotsQCD -> SaveAs(filename); delete plotsQCD; } } TGraphErrors* ratioEtaBinned = new TGraphErrors(nEta,ratioEtaBinnedX,ratioEtaBinnedY,ratioEtaBinnedEX,ratioEtaBinnedEY); filename = (TString) "plots/RatioEtaBinned_" + type + (TString) "_" + method + (TString) ".root"; TFile *f = new TFile(filename,"RECREATE"); f -> WriteTObject(ratioEtaBinned,"Graph"); f->Close(); delete f; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 1.) Calculate sys Error from QCD contamination //cout<<endl; double deltaRatioUpQCD[nEta] = {0.}; double deltaRatioDownQCD[nEta] = {0.}; if(QCD){ for(int eta = 0; eta<nEta; eta++){ deltaRatioUpQCD[eta] = abs(ratioEtaBinnedQCDUpY[eta]/ratioEtaBinnedY[eta]-1.); deltaRatioDownQCD[eta] = abs(ratioEtaBinnedQCDDownY[eta]/ratioEtaBinnedY[eta]-1.); //cout<<"ratioEtaBinnedQCDDownY[eta]"<<ratioEtaBinnedQCDDownY[eta]<<endl; //cout<<"ratioEtaBinnedY[eta]"<<ratioEtaBinnedY[eta]<<endl; //cout<<"deltaRatioUpQCD["<<eta<<"] = "<<deltaRatioUpQCD[eta]<<endl; //cout<<"deltaRatioDownQCD["<<eta<<"] = "<<deltaRatioDownQCD[eta]<<endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 2.) Calculate sys Error from JEC uncertainty (percentage change of MC result) //cout<<endl; double deltaRatioUpJEC[nEta] = {0.}; double deltaRatioDownJEC[nEta] = {0.}; if(JEC){ rootFiles = (TString) "scripts/plotsJEC/FinalEtaBinnedErrorsJECUp_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *JECuncertaintyUp = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelJECUp = JECuncertaintyUp -> GetY(); rootFiles = (TString) "scripts/plotsJEC/FinalEtaBinnedErrorsJECLow_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *JECuncertaintyLow = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelJECLow = JECuncertaintyLow -> GetY(); for(int eta = 0; eta<nEta; eta++){ deltaRatioUpJEC[eta] = sysRelJECUp[eta]; deltaRatioDownJEC[eta] = sysRelJECLow[eta]; //cout<<"deltaRatioUpJEC["<<eta<<"] = "<<deltaRatioUpJEC[eta]<<endl; //cout<<"deltaRatioDownJEC["<<eta<<"] = "<<deltaRatioDownJEC[eta]<<endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 3.) Calculate sys Error from Flavor uncertainty (percentage change of MC result) //cout<<endl; // Multiply on mc (as symmetric Error) // ratioUp = 1/(1 - delta) * ratio // ratioLow = 1/(1 + delta) * ratio double deltaRatioUpFlavor[nEta] = {0.}; double deltaRatioDownFlavor[nEta] = {0.}; if(flavor){ rootFiles = (TString) "scripts/plotsFlavor/FinalEtaBinnedErrorsFlavorUp_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *FlavoruncertaintyUp = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelFlavorUp = FlavoruncertaintyUp -> GetY(); rootFiles = (TString) "scripts/plotsFlavor/FinalEtaBinnedErrorsFlavorLow_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *FlavoruncertaintyLow = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelFlavorLow = FlavoruncertaintyLow -> GetY(); for(int eta = 0; eta<nEta; eta++){ deltaRatioUpFlavor[eta] = sysRelFlavorUp[eta]; deltaRatioDownFlavor[eta] = sysRelFlavorLow[eta]; //cout<<"deltaRatioUpFlavor["<<eta<<"] = "<<deltaRatioUpFlavor[eta]<<endl; //cout<<"deltaRatioDownFlavor["<<eta<<"] = "<<deltaRatioDownFlavor[eta]<<endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 4.) Calculate sys Error from PU uncertainty (percentage change of MC result) //cout<<endl; double deltaRatioUpPU[nEta] = {0.}; double deltaRatioDownPU[nEta] = {0.}; if(PU){ rootFiles = (TString) "scripts/plotsPU/FinalEtaBinnedErrorsPUUp_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *PUuncertaintyUp = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelPUUp = PUuncertaintyUp -> GetY(); rootFiles = (TString) "scripts/plotsPU/FinalEtaBinnedErrorsPULow_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *PUuncertaintyLow = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelPULow = PUuncertaintyLow -> GetY(); // Multiply on mc (as symmetric Error) // ratioUp = 1/(1 - delta) * ratio // ratioUp = 1/(1 + delta) * ratio for(int eta = 0; eta<nEta; eta++){ deltaRatioUpPU[eta] = sysRelPUUp[eta]; deltaRatioDownPU[eta] = sysRelPULow[eta]; //cout<<"deltaRatioUpPU["<<eta<<"] = "<<deltaRatioUpPU[eta]<<endl; //cout<<"deltaRatioDownPU["<<eta<<"] = "<<deltaRatioDownPU[eta]<<endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 5.) Calculate sys Error from Out-of Cone showering simulation (percentage change of full ratio result) //cout<<endl; double deltaRatioUpMC[nEta] = {0.}; double deltaRatioDownMC[nEta] = {0.}; if(MC){ rootFiles = (TString) "scripts/plotsMC/FinalErrorsMC_" + type + (TString) "_" + method + (TString) ".root"; TGraphErrors *MCuncertainty = readTGraphErrors(rootFiles,"graph","Graph"); double *sysRelMC = MCuncertainty -> GetY(); // Percentage change is only in one direction, to take this into account keep deltaRatioDownMC = 0 for(int eta = 0; eta<nEta; eta++){ deltaRatioUpMC[eta] = sysRelMC[eta]; deltaRatioDownMC[eta] = sysRelMC[eta]; //cout<<"deltaRatioUpMC["<<eta<<"] = "<<deltaRatioUpMC[eta]<<endl; //cout<<"deltaRatioDownMC["<<eta<<"] = "<<deltaRatioDownMC[eta]<<endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Take all systematic Uncertainties together and plot //cout<<endl; double *deltaTotalSysUp = new double[nEta]; double *deltaTotalSysDown = new double[nEta]; double *DeltaTotalSysUp = new double[nEta]; double *DeltaTotalSysDown = new double[nEta]; double *DeltaTotalDown = new double[nEta]; double *DeltaTotalUp = new double[nEta]; for(int eta = 0; eta<nEta; eta++){ // Add all systematic Uncertainties in quadrature (delta is relative Uncertainty) deltaTotalSysUp[eta] = sqrt(TMath::Power(deltaRatioUpJEC[eta],2) + TMath::Power(deltaRatioUpFlavor[eta],2) + TMath::Power(deltaRatioUpPU[eta],2) + TMath::Power(deltaRatioUpMC[eta],2) + TMath::Power(deltaRatioUpQCD[eta],2)); deltaTotalSysDown[eta] = sqrt(TMath::Power(deltaRatioDownJEC[eta],2) + TMath::Power(deltaRatioDownFlavor[eta],2) + TMath::Power(deltaRatioDownPU[eta],2) + TMath::Power(deltaRatioDownMC[eta],2) + TMath::Power(deltaRatioDownQCD[eta],2)); // Calculation of the absolute Uncertainty with Delta = ratio * delta DeltaTotalSysUp[eta] = deltaTotalSysUp[eta] * ratioEtaBinnedY[eta]; DeltaTotalSysDown[eta] = deltaTotalSysDown[eta] * ratioEtaBinnedY[eta]; // Calculate Systematic plus staistical Uncertainty DeltaTotalUp[eta] = sqrt(pow(DeltaTotalSysUp[eta],2) + pow(ratioEtaBinnedEY[eta],2)); DeltaTotalDown[eta] = sqrt(pow(DeltaTotalSysDown[eta],2) + pow(ratioEtaBinnedEY[eta],2)); cout<<endl<<"relative: deltaTotalSysUp["<<eta<<"] = "<<fixed<<setprecision(3)<<deltaTotalSysUp[eta]<<endl; cout<<"relative: deltaTotalSysDown["<<eta<<"] = "<<deltaTotalSysDown[eta]<<endl; cout<<endl<<"absolute: DeltaTotalSysUp["<<eta<<"] = "<<DeltaTotalSysUp[eta]<<endl; cout<<"absolute: DeltaTotalSysDown["<<eta<<"] = "<<DeltaTotalSysDown[eta]<<endl; } double ex[nEta] ={0.25,0.3,0.3,0.3}; TGraphAsymmErrors* ratioEtaBinnedSys = new TGraphAsymmErrors(nEta,ratioEtaBinnedX,ratioEtaBinnedY,ex,ex,DeltaTotalSysDown,DeltaTotalSysUp); double *TotalSysUp = new double[nEta]; double *TotalSysDown = new double[nEta]; for(int i=0; i<nEta; i++){ TotalSysUp[i] = ratioEtaBinnedY[i]+DeltaTotalSysUp[i]; TotalSysDown[i] = ratioEtaBinnedY[i]-DeltaTotalSysDown[i]; } TGraph* ratioSysBorderUp = new TGraph(nEta, ratioEtaBinnedX, TotalSysUp); TGraph* ratioSysBorderDown = new TGraph(nEta, ratioEtaBinnedX, TotalSysDown); TGraph* ratioRelativeErrorsUp = new TGraph(nEta,ratioEtaBinnedX,deltaTotalSysUp); TGraph* ratioRelativeErrorsDown = new TGraph(nEta,ratioEtaBinnedX,deltaTotalSysDown); TGraphErrors* ratioEtaBinnedStat = new TGraphErrors(nEta,ratioEtaBinnedX,ratioEtaBinnedY,ratioEtaBinnedEX,ratioEtaBinnedEY); TGraphAsymmErrors* ratioEtaBinnedStatPlusSys = new TGraphAsymmErrors(nEta,ratioEtaBinnedX,ratioEtaBinnedY,ex,ex,DeltaTotalDown,DeltaTotalUp); TCanvas *cFinal = new TCanvas("cFinal","cFinal",200,10,500,500); cFinal -> cd(); ratioEtaBinnedSys -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); ratioEtaBinnedSys -> GetXaxis() -> SetTitle("|#eta|"); if(PU && flavor && JEC && MC && QCD) etaString = "All sys. Uncertainties"; else if(PU && !flavor && !JEC && !MC && !QCD) etaString = "Only PU uncert."; else if(!PU && flavor && !JEC && !MC && !QCD) etaString = "Only flavor uncert."; else if(!PU && !flavor && JEC && !MC && !QCD) etaString = "Only JEC uncert."; else if(!PU && !flavor && !JEC && MC && !QCD) etaString = "Only Out-of-Cone sim. uncert."; else if(!PU && !flavor && !JEC && MC && !QCD) etaString = "Only Out-of-Cone sim. uncert."; else if(!PU && !flavor && !JEC && !MC && QCD) etaString = "Only QCD uncert."; else if(PU && flavor && JEC && !MC && QCD) etaString = "All besides MC uncertainty."; else etaString = "Strange set of systematic uncertainties."; cout<<endl<<etaString<<endl<<endl; ratioEtaBinnedSys -> SetMarkerStyle(20); ratioEtaBinnedSys -> SetMarkerSize(1.4); ratioEtaBinnedSys -> SetFillColor(kGray); ratioEtaBinnedSys -> SetFillStyle(3001); ratioEtaBinnedSys -> SetLineColor(kGray); ratioEtaBinnedSys -> SetMinimum(0.8); ratioEtaBinnedSys -> SetMaximum(1.5); ratioEtaBinnedSys -> GetXaxis() -> SetLimits(0., 2.3); ratioEtaBinnedSys -> GetXaxis() -> SetNdivisions(6,6,0, "X"); ratioEtaBinnedSys -> DrawClone("Ae3p"); //ratioEtaBinnedSys -> SetPointError(0, 0., 0., 0., 0.); //ratioEtaBinnedSys -> SetPointError(1, 0., 0., 0., 0.); //ratioEtaBinnedSys -> SetPointError(2, 0., 0., 0., 0.); //ratioEtaBinnedSys -> SetPointError(3, 0., 0., 0., 0.); //ratioEtaBinnedSys -> SetPointError(4, 0., 0., 0., 0.); ratioEtaBinnedStat -> SetMarkerStyle(20); ratioEtaBinnedStat -> SetMarkerSize(1.4); ratioEtaBinnedStat -> SetFillColor(kGray); ratioEtaBinnedStat -> SetFillStyle(3001); ratioEtaBinnedStat -> SetLineColor(1); ratioEtaBinnedStat -> Draw("psame"); TLatex *infoFinal = new TLatex(); infoFinal -> SetTextFont(132); infoFinal -> SetNDC(); infoFinal -> SetTextSize(0.045); infoFinal -> DrawLatex(0.2,0.8,etaString); filename = (TString) "plots/FinalErrorPlot_" + type + (TString) "_" + method + (TString) ".pdf"; cFinal -> Print(filename,"pdf"); filename = (TString) "plots/FinalErrorPlot_" + type + (TString) "_" + method + (TString) ".pdf"; cFinal -> SaveAs(filename,"pdf"); delete cFinal; filename = (TString) "plots/FinalRelativeErrorsUp_" + type + (TString) "_" + method + (TString) ".root"; f = new TFile(filename,"RECREATE"); f -> WriteTObject(ratioRelativeErrorsUp,"graph"); f->Close(); delete f; filename = (TString) "plots/FinalRelativeErrorsLow_" + type + (TString) "_" + method + (TString) ".root"; f = new TFile(filename,"RECREATE"); f -> WriteTObject(ratioRelativeErrorsDown,"graph"); f->Close(); delete f; ofstream RelativeErrors; RelativeErrors.open("plots/Errors.txt"); RelativeErrors<<"Relative Errors: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<fixed<<setprecision(3)<<(deltaTotalSysDown[i]*100)<<"% / +"<<(deltaTotalSysUp[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<"Absolute Errors: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(DeltaTotalSysDown[i])<<" / +"<<(DeltaTotalSysUp[i])<<endl; } RelativeErrors<<endl<<endl<<"Relative Errors JEC: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(deltaRatioDownJEC[i]*100)<<"% / +"<<(deltaRatioUpJEC[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<endl<<"Relative Errors Flavor: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(deltaRatioDownFlavor[i]*100)<<"% / +"<<(deltaRatioUpFlavor[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<endl<<"Relative Errors Out-of-Cone showering simulation: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(deltaRatioDownMC[i]*100)<<"% / +"<<(deltaRatioUpMC[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<endl<<"Relative Errors QCD: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(deltaRatioDownQCD[i]*100)<<"% / +"<<(deltaRatioUpQCD[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<endl<<"Relative Errors PU reweighing: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(deltaRatioDownPU[i]*100)<<"% / +"<<(deltaRatioUpPU[i]*100)<<"%"<<endl; } RelativeErrors<<endl<<endl<<"Central values and statistical Uncertainty: "<<endl; for(int i=0; i<nEta; i++){ RelativeErrors<<i+1<<". Eta bin: "<<"-"<<(ratioEtaBinnedY[i])<<" +/- "<<ratioEtaBinnedEY[i]<<endl; } RelativeErrors.close(); // Write directly full latex table with systematic and statistical unceratinty ofstream latexTable; latexTable.open("plots/latexTable.txt"); latexTable<<"\\renewcommand{\\arraystretch}{2.0}"<<endl; latexTable<<"\\begin{center}"<<endl; latexTable<<"\\begin{tabular}{ | c | c c c| }"<<endl; latexTable<<"$|\\eta^{\\text{Jet}}|$ & Ratio & stat. & sys. \\\\\\hline"<<endl; for(int z=0;z<nEta;z++){ latexTable<<"$"<<fixed<<setprecision(1)<<etaBins[z]<<" - "<<etaBins[z+1]<<"$ &"<<fixed<<setprecision(3)<<ratioEtaBinnedY[z]<<" & $\\pm "<<ratioEtaBinnedEY[z]<<"$ & $^{+"<<DeltaTotalSysUp[z]<<"}_{-"<<DeltaTotalSysDown[z]<<"}$ \\\\"<<endl; } latexTable<<"\\hline"<<endl; latexTable<<"\\end{tabular}"<<endl; latexTable<<"\\end{center}"<<endl<<endl<<endl<<endl<<endl; latexTable<<"\\begin{center}"<<endl; latexTable<<"\\begin{tabular}{ l| c | c | c | c |}"<<endl; latexTable<<"\\multicolumn{1}{c}{} & \\multicolumn{4}{c}{$|\\eta^{\\text{Jet}}|$}\\\\\\hline"<<endl<<fixed<<setprecision(1); for(int z=0;z<nEta;z++) latexTable<<"& \\textbf{"<<etaBins[z]<<" - "<<etaBins[z+1]<<"}"; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{Multijet contamination}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaRatioUpQCD[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $-"<<deltaRatioDownQCD[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{Flavor uncertainty}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaRatioUpFlavor[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $"<<deltaRatioDownFlavor[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{JEC uncertainty}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaRatioUpJEC[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $"<<deltaRatioDownJEC[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{Out-of-Cone showering simulation}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaRatioUpMC[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $-"<<deltaRatioDownMC[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{PU uncertainty}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaRatioUpPU[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $"<<deltaRatioDownPU[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline\\hline"<<endl; latexTable<<"\\multirow{2}{*}{\\textbf{Total}}"; for(int z=0;z<nEta;z++) latexTable<<"& $+"<<deltaTotalSysUp[z]*100<<" \\% $ "; latexTable<<"\\\\"<<endl; for(int z=0;z<nEta;z++) latexTable<<"& $-"<<deltaTotalSysDown[z]*100<<" \\% $ "; latexTable<<"\\\\\\hline"<<endl; latexTable<<"\\end{tabular}"<<endl; latexTable<<"\\end{center}"<<endl; latexTable.close(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Comparison to 2011 Data cout<<endl; gROOT->LoadMacro("tdrstyle_mod14.C"); setTDRStyle(); gROOT->LoadMacro("CMS_lumi.C"); writeExtraText = true; // if extra text extraText = "Preliminary"; // default extra text is "Preliminary" lumi_8TeV = "19.7 fb^{-1}"; // default is "19.7 fb^{-1}" lumi_7TeV = "4.9 fb^{-1}"; // default is "5.1 fb^{-1}" int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV gStyle->SetHatchesLineWidth(1); gStyle->SetHatchesSpacing(2.2); //----------------------------------------------------- TCanvas *cFinal2 = new TCanvas("cFinal2","cFinal2",200,10,1000,1000); cFinal2 -> cd(); double x_2011[4]; x_2011[0]=0.25; x_2011[1]=0.80; x_2011[2]=1.40; x_2011[3]=2.00; double y_2011[4]; y_2011[0]=1.052; y_2011[1]=1.057; y_2011[2]=1.096; y_2011[3]=1.134; double yErrStat_2011[4]; yErrStat_2011[0]=0.012; yErrStat_2011[1]=0.012; yErrStat_2011[2]=0.017; yErrStat_2011[3]=0.035; double yErrSysHigh_2011[4]; yErrSysHigh_2011[0]=0.062; yErrSysHigh_2011[1]=0.056; yErrSysHigh_2011[2]=0.063; yErrSysHigh_2011[3]=0.087; double yErrSysLow_2011[4]; yErrSysLow_2011[0]=0.061; yErrSysLow_2011[1]=0.055; yErrSysLow_2011[2]=0.062; yErrSysLow_2011[3]=0.085; double xErrLow_2011[4]; xErrLow_2011[0]=0.25; xErrLow_2011[1]=0.3; xErrLow_2011[2]=0.3; xErrLow_2011[3]=0.3; double xErrHigh_2011[4]; xErrHigh_2011[0]=0.25; xErrHigh_2011[1]=0.3; xErrHigh_2011[2]=0.3; xErrHigh_2011[3]=0.3; double yErrTotalHigh_2011[4]; double yErrTotalLow_2011[4]; for(int i=0; i<4; i++){ yErrTotalHigh_2011[i]=sqrt(pow(yErrStat_2011[i],2) + pow(yErrSysHigh_2011[i],2)); yErrTotalLow_2011[i]=sqrt(pow(yErrStat_2011[i],2) + pow(yErrSysLow_2011[i],2)); } TGraphAsymmErrors *Res_2011_stat = new TGraphAsymmErrors(4,x_2011,y_2011,xErrLow_2011,xErrHigh_2011,yErrStat_2011,yErrStat_2011); Res_2011_stat->SetName("Res_2011_stat"); TGraphAsymmErrors *Res_2011_sys = new TGraphAsymmErrors(4,x_2011,y_2011,xErrLow_2011,xErrHigh_2011,yErrSysLow_2011,yErrSysHigh_2011); Res_2011_sys->SetName("Res_2011_sys"); TGraphAsymmErrors *Res_2011_total = new TGraphAsymmErrors(4,x_2011,y_2011,xErrLow_2011,xErrHigh_2011,yErrTotalLow_2011,yErrTotalHigh_2011); Res_2011_sys->SetName("Res_2011_total"); //----------------------------------------------------- ratioEtaBinnedStatPlusSys -> GetXaxis() -> SetTitle("|#eta|"); ratioEtaBinnedStatPlusSys -> GetXaxis() -> SetRangeUser(0., 2.3); ratioEtaBinnedStatPlusSys -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); ratioEtaBinnedSys -> GetXaxis() -> SetTitle("|#eta|"); ratioEtaBinnedSys -> GetXaxis() -> SetRangeUser(0., 2.3); ratioEtaBinnedSys -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); ratioEtaBinnedStat -> GetXaxis() -> SetTitle("|#eta|"); ratioEtaBinnedStat -> GetXaxis() -> SetRangeUser(0., 2.3); ratioEtaBinnedStat -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); ratioEtaBinnedStat -> GetYaxis() -> SetRangeUser(0.8, 1.6); Res_2011_stat -> GetXaxis() -> SetTitle("|#eta|"); Res_2011_stat -> GetXaxis() -> SetLimits(0., 2.3); Res_2011_stat -> GetXaxis() -> SetNdivisions(505, "X"); Res_2011_stat -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); Res_2011_sys -> GetXaxis() -> SetTitle("|#eta|"); Res_2011_sys -> GetXaxis() -> SetLimits(0., 2.3); Res_2011_sys -> GetXaxis() -> SetNdivisions(505, "X"); Res_2011_sys -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); Res_2011_total -> GetXaxis() -> SetTitle("|#eta|"); Res_2011_total -> GetXaxis() -> SetLimits(0., 2.3); Res_2011_total -> GetXaxis() -> SetNdivisions(505, "X"); Res_2011_total -> GetYaxis() -> SetTitle("Data/MC ratio for JER"); Res_2011_total -> GetYaxis() -> SetRangeUser(0.8, 1.5); ratioEtaBinnedStatPlusSys -> SetMarkerStyle(20); ratioEtaBinnedStatPlusSys -> SetMarkerSize(2.0); ratioEtaBinnedStatPlusSys -> SetLineColor(kPink-8); ratioEtaBinnedStatPlusSys -> SetLineWidth(2); ratioEtaBinnedStatPlusSys -> SetMarkerColor(kPink-8); ratioEtaBinnedStatPlusSys -> SetFillColor(kPink-8); ratioEtaBinnedStatPlusSys -> SetName("statPlusSys_2012"); ratioEtaBinnedStat -> SetMarkerStyle(20); ratioEtaBinnedStat -> SetMarkerSize(2.0); ratioEtaBinnedStat -> SetLineColor(kPink-8); ratioEtaBinnedStat -> SetLineWidth(2); ratioEtaBinnedStat -> SetMarkerColor(kPink-8); ratioEtaBinnedStat -> SetFillColor(kPink-8); ratioEtaBinnedStat -> SetName("Stat_2012"); ratioEtaBinnedStatPlusSys -> SetFillStyle(3244); ratioEtaBinnedStat -> SetFillStyle(3144); Res_2011_stat->SetMarkerStyle(24); Res_2011_stat->SetMarkerSize(2.0); Res_2011_stat->SetLineColor(kGray+2); Res_2011_stat->SetLineWidth(2); Res_2011_stat->SetLineWidth(2); Res_2011_stat->SetFillStyle(1001); Res_2011_total->SetMarkerStyle(24); Res_2011_total->SetMarkerSize(2.0); Res_2011_total->SetLineColor(1); Res_2011_total->SetLineWidth(2); Res_2011_total->SetFillColor(kGray); Res_2011_total->SetFillStyle(1001); Res_2011_total->SetLineColor(kGray+2); Res_2011_total->Draw("a2"); Res_2011_stat->Draw("esame"); ratioEtaBinnedStatPlusSys -> Draw("2same"); Res_2011_stat->Draw("pXsame"); Res_2011_stat->SetMarkerSize(1.9); Res_2011_stat->Draw("pXsame"); Res_2011_stat->SetMarkerSize(1.7); Res_2011_stat->Draw("pXsame"); ratioEtaBinnedStatPlusSys -> Draw("pXsame"); ratioEtaBinnedStat -> Draw("esame"); TLegend *leg = new TLegend(0.18, 0.60, 0.55, 0.75); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextSize(0.045); leg->AddEntry(Res_2011_total,"5/fb (7 TeV)", "pfl"); leg->AddEntry(ratioEtaBinnedStatPlusSys,"20/fb (8 TeV)", "pfl"); leg->Draw("same"); TLatex *info = new TLatex(); info->SetNDC(); info->DrawLatex(0.67,0.83,"Anti-k_{T} R=0.5"); info->DrawLatex(0.67,0.77,"PF+CHS"); CMS_lumi( cFinal2, iPeriod, 11 ); cFinal2->Print("plots/resultsComparisonFINAL.pdf","pdf"); cFinal2->SaveAs("plots/resultsComparisonFINAL.C"); return 0; }
void IsoMultipole(Char_t* Mlp, Char_t* Iso, Bool_t SAVE=false, Double_t Lo=0.0, Double_t Hi=0.0) { if(SAVE) TCanvas* Canvas = new TCanvas(); //if(SAVE) SetBit(TH1::kNoTitle); FILE* InPlots; FILE* InModel_0; FILE* InModel_p; Char_t Buffer[256]; Char_t M, p; Int_t l; Double_t PlRe[N_MAX]; Double_t PlIm[N_MAX]; Double_t PlDRe[N_MAX]; Double_t PlDIm[N_MAX]; Double_t PlW[N_MAX]; Double_t MoRe_0[N_MAX]; Double_t MoRe_p[N_MAX]; Double_t MoIm_0[N_MAX]; Double_t MoIm_p[N_MAX]; Double_t MoW_0[N_MAX]; Double_t MoW_p[N_MAX]; Double_t MoRe[N_MAX]; Double_t MoIm[N_MAX]; Int_t PlPts; Int_t MoPts_0, MoPts_p; Double_t W, Re, DRe, Im, DIm; Double_t Min = 0.0; Double_t Max = 0.0; TGraphErrors* PlotsRe; TGraphErrors* PlotsIm; TGraph* ModelRe; TGraph* ModelIm; //Decompose multipole name sscanf(Mlp, "%c%d%c", &M, &l, &p); //Open text file with fit results for given multipole sprintf(Buffer, "isospin/%s_%s.txt", Mlp, Iso); InPlots = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InPlots); fgets(Buffer, sizeof(Buffer), InPlots); //Read multipole fit values from file PlPts = 0; while(!feof(InPlots)) { if(fscanf(InPlots, "%lf %lf %lf %lf %lf", &W, &Re, &DRe, &Im, &DIm)==5) { //Look for maximum & minimum of values to adjust plotting range if(Re+DRe > Max) Max = Re+DRe; if(Im+DIm > Max) Max = Im+DIm; if(Re-DRe < Min) Min = Re-DRe; if(Im-DIm < Min) Min = Im-DIm; //Add real and imaginary parts of multipole (w/ errors) to graph PlW[PlPts] = W; PlRe[PlPts] = Re; PlIm[PlPts] = Im; PlDRe[PlPts] = DRe; PlDIm[PlPts] = DIm; PlPts++; } } //Close file with fit values fclose(InPlots); //Create graphs for real and imaginary parts of fitted multipole PlotsRe = new TGraphErrors(PlPts, PlW, PlRe, NULL, PlDRe); PlotsIm = new TGraphErrors(PlPts, PlW, PlIm, NULL, PlDIm); //Color, line size, marker style adjustments PlotsRe->SetLineColor(kRed+2); PlotsIm->SetLineColor(kBlue+2); PlotsRe->SetMarkerColor(kRed+2); PlotsIm->SetMarkerColor(kBlue+2); PlotsRe->SetMarkerStyle(21); PlotsIm->SetMarkerStyle(21); PlotsRe->SetMarkerSize(0.7); PlotsIm->SetMarkerSize(0.7); //Set plot titles and object names sprintf(Buffer, "%s_%s", Mlp, Iso); PlotsRe->SetTitle(Buffer); PlotsIm->SetTitle(Buffer); sprintf(Buffer, "Fit_Re%s_%s", Mlp, Iso); PlotsRe->SetName(Buffer); sprintf(Buffer, "Fit_Im%s_%s", Mlp, Iso); PlotsIm->SetName(Buffer); PlotsRe->Draw("APZ"); //Plot with x,y axis, points and small error bars PlotsIm->Draw("PZ"); //Plot with points and small error bars, into existing frame //x-axis labeling PlotsRe->GetXaxis()->SetTitle("W / MeV"); //y-axis labeling sprintf(Buffer, "%c_{%1d%c}", M, l, p); for(Int_t n=0; n<strlen(Buffer); n++) { if(Buffer[n]=='p') Buffer[n] = '+'; if(Buffer[n]=='m') Buffer[n] = '-'; } if(!strcmp(Iso, "32")) sprintf(Buffer, "%s^{3/2}", Buffer, Iso); if(!strcmp(Iso, "p12")) sprintf(Buffer, "%s^{p1/2}", Buffer, Iso); PlotsRe->GetYaxis()->SetTitle(Buffer); //Open text file with model values for given p pi0 multipole sprintf(Buffer, "model/ppi0/%s.txt", Mlp); InModel_0 = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InModel_0); fgets(Buffer, sizeof(Buffer), InModel_0); //Read multipole model values from file MoPts_0 = 0; while(!feof(InModel_0)) { if(fscanf(InModel_0, "%lf %lf %lf", &W, &Re, &Im)==3) { MoW_0[MoPts_0] = W; MoRe_0[MoPts_0] = Re; MoIm_0[MoPts_0] = Im; MoPts_0++; } } //Close file with model values fclose(InModel_0); //Open text file with model values for given n pi+ multipole sprintf(Buffer, "model/npip/%s.txt", Mlp); InModel_p = fopen(Buffer, "r"); //Skip two lines with table header fgets(Buffer, sizeof(Buffer), InModel_p); fgets(Buffer, sizeof(Buffer), InModel_p); //Read multipole model values from file MoPts_p = 0; while(!feof(InModel_p)) { if(fscanf(InModel_p, "%lf %lf %lf", &W, &Re, &Im)==3) { MoW_p[MoPts_p] = W; MoRe_p[MoPts_p] = Re; MoIm_p[MoPts_p] = Im; MoPts_p++; } } //Close file with model values fclose(InModel_p); //Create selected isospin multipole from p pi0 and n pi+ multipoles for(Int_t wp=0; wp<MoPts_p; wp++) { //Find corresponding energy bin between n pi+ and p pi0 multipoles Int_t w0; for(Int_t w0=0; w0<MoPts_0; w0++) if(MoW_p[wp]==MoW_0[w0]) break; //Create isospin multipoles if(!strcmp(Iso, "32")) { MoRe[wp] = A_32(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_32(MoIm_0[w0], MoIm_p[wp]); } if(!strcmp(Iso, "p12")) { MoRe[wp] = A_12(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_12(MoIm_0[w0], MoIm_p[wp]); } } //Create graphs for real and imaginary parts of model multipole ModelRe = new TGraph(MoPts_p, MoW_p, MoRe); ModelIm = new TGraph(MoPts_p, MoW_p, MoIm); //Color, line size adjustments ModelRe->SetLineColor(kRed); ModelIm->SetLineColor(kBlue); ModelRe->SetLineWidth(2); ModelIm->SetLineWidth(2); //Set plot titles and object names sprintf(Buffer, "%s_%s", Mlp, Iso); ModelRe->SetTitle(Buffer); ModelIm->SetTitle(Buffer); sprintf(Buffer, "Model_Re%s_%s", Mlp, Iso); ModelRe->SetName(Buffer); sprintf(Buffer, "Model_Im%s_%s", Mlp, Iso); ModelIm->SetName(Buffer); //Plot graphs ModelRe->Draw("L"); //Plot as line, into same frame ModelIm->Draw("L"); //Plot as line, into same frame //Adjust drawing ranges for y-axis if((Lo==0.0) && (Hi==0.0)) { PlotsRe->SetMinimum(Min*1.05); PlotsRe->SetMaximum(Max*1.05); } else { PlotsRe->SetMinimum(Lo); PlotsRe->SetMaximum(Hi); } if(SAVE) PlotsRe->SetTitle(""); if(SAVE) sprintf(Buffer, "isospin/%s_%s.eps", Mlp, Iso); if(SAVE) Canvas->SaveAs(Buffer); }
void DeltaPhi(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){ cout<<"#### DeltaPhi(MET,H) #####"<<endl; gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TLegend* leg = new TLegend(0.13,0.6,0.67,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); TLegend* leg_norm = new TLegend(0.20,0.5,0.74,0.87); leg_norm->SetNColumns(2); leg_norm->SetBorderSize(0); leg_norm->SetFillStyle(0); TCanvas *c1 = new TCanvas("c1","",500,600); TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3); mainPad->SetBottomMargin(0.015); smallPad->SetTopMargin(0.05); smallPad->SetBottomMargin(0.25); c1->cd(); mainPad->Draw(); mainPad->cd(); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut mggblind = "((mgg<115)||(mgg>135))"; TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; TCut pt1cut = Form("pt1/mgg>%lf",pt1_cutIN); TCut pt2cut = Form("pt2/mgg>%lf",pt2_cutIN); TCut METcutD = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1)>%lf",MET_cutIN); TCut METcut = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0)>%lf",MET_cutIN); TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>%lf",DPHI_cutIN); TCut DPHIcutD = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>%lf",DPHI_cutIN); TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); cout<<"check1"<<endl; TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10= (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); cout<<"check2"<<endl; tree_data->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>>hdata(15,0,3.5)",(mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcutD&& DPHIcutD)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(20); hdata->SetLineColor(kBlack); tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12(15,0,3.5)","weight*(weight>0.)"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); cout<<"check3"<<endl; /* h1->Scale(0.00009338); h2->Scale(0.00010348); h3->Scale(0.00008394); h4->Scale(0.00006352); h5->Scale(0.00004712); h6->Scale(0.00003020); h7->Scale(0.00000972); */ h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); //only for 15ns samples h6->SetLineColor(kPink+7); //only for 15ns samples h7->SetLineColor(kMagenta+2); //only for 15ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 15ns samples h6->SetLineWidth(2); //only for 15ns samples h7->SetLineWidth(2); //only for 15ns samples THStack *hs=new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+2); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); cout<<"check4"<<endl; TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hdata->SetMaximum(5000); // hs->SetMinimum(0.0001); hdata->SetTitle(""); hdata->Draw("e1"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3002); hs->Draw("same hist"); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); //only for 15ns samples h6->Draw("same hist"); //only for 15ns samples h7->Draw("same hist"); //only for 15ns samples hdata->Draw("same e1"); hdata->GetXaxis()->SetLabelOffset(999); hdata->GetYaxis()->SetTitle("Events/0.4"); hdata->GetYaxis()->SetTitleOffset(1.6); hdata->GetYaxis()->SetTitle("Events/0.23 GeV"); gPad->Modified(); /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l"); leg->AddEntry(h2,"m_{#chi} = 10 GeV","l"); leg->AddEntry(h3,"m_{#chi} = 100 GeV","l"); leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/ leg->AddEntry(hdata,"Data","elp"); // leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); // leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); // leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); // leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); // leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 15ns samples leg->AddEntry(hbkg4,"ggH","f"); // leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 15ns samples leg->AddEntry(hbkg6,"VH","f"); // leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->Draw("same"); cout<<"check5"<<endl; gStyle->SetOptStat(0); c1->cd(); smallPad->Draw(); smallPad->cd(); TGraphErrors *gr = new TGraphErrors(0); double integralData=hdata->Integral(); double integralBKG=hsum->Integral(); double error, ratio; for(int w=1; w<15; w++){ if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){ gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w))); ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w)); error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w)); std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl; gr->SetPointError(w, hdata->GetBinWidth(w)/2,error); }else{ gr->SetPoint(w, hdata->GetBinCenter(w),10); } } gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gr->GetHistogram()->SetMaximum(2); gr->GetHistogram()->SetMinimum(0.1); gStyle->SetTextSize(14); gROOT->ForceStyle(); gr->GetXaxis()->SetLabelFont(43); gr->GetXaxis()->SetLabelSize(15); gr->GetYaxis()->SetLabelFont(43); gr->GetYaxis()->SetLabelSize(15); gr->GetXaxis()->SetLimits(0,3.5); gPad->SetGrid(); gStyle->SetStripDecimals(kTRUE); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("AZP"); gr->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E^{miss}_{T})|"); gr->GetXaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetNdivisions(505); gr->GetXaxis()->SetTitleOffset(1); gr->GetYaxis()->SetTitle("Data/MC"); gr->GetYaxis()->SetTitleOffset(0.4); gr->SetTitle(""); smallPad->Update(); TF1* line = new TF1("line","1",0,3.5); line->SetLineColor(kRed); line->SetLineWidth(2); line->Draw("L same"); gr->Draw("ZP SAME"); TCanvas *c2 = new TCanvas("c2","",500,500); tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm"); tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm"); tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm"); tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm"); tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm"); tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm"); tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm"); tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm"); tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm"); tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm"); tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4_norm =(TH1F*)gPad->GetPrimitive("hbkg4_norm"); tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm"); tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6_norm =(TH1F*)gPad->GetPrimitive("hbkg6_norm"); tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7_norm =(TH1F*)gPad->GetPrimitive("hbkg7_norm"); tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8_norm =(TH1F*)gPad->GetPrimitive("hbkg8_norm"); tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm"); tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10_norm =(TH1F*)gPad->GetPrimitive("hbkg10_norm"); tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11_norm =(TH1F*)gPad->GetPrimitive("hbkg11_norm"); tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12_norm =(TH1F*)gPad->GetPrimitive("hbkg12_norm"); for(int i = 0; i<26;i++){ if(hbkg1_norm->GetBinContent(i) < 0.) hbkg1_norm->SetBinContent(i,0.); if(hbkg2_norm->GetBinContent(i) < 0.) hbkg2_norm->SetBinContent(i,0.); if(hbkg3_norm->GetBinContent(i) < 0.) hbkg3_norm->SetBinContent(i,0.); if(hbkg4_norm->GetBinContent(i) < 0.) hbkg4_norm->SetBinContent(i,0.); if(hbkg5_norm->GetBinContent(i) < 0.) hbkg5_norm->SetBinContent(i,0.); if(hbkg6_norm->GetBinContent(i) < 0.) hbkg6_norm->SetBinContent(i,0.); if(hbkg7_norm->GetBinContent(i) < 0.) hbkg7_norm->SetBinContent(i,0.); if(hbkg8_norm->GetBinContent(i) < 0.) hbkg8_norm->SetBinContent(i,0.); if(hbkg9_norm->GetBinContent(i) < 0.) hbkg9_norm->SetBinContent(i,0.); if(hbkg10_norm->GetBinContent(i) < 0.) hbkg10_norm->SetBinContent(i,0.); if(hbkg11_norm->GetBinContent(i) < 0.) hbkg11_norm->SetBinContent(i,0.); if(hbkg12_norm->GetBinContent(i) < 0.) hbkg12_norm->SetBinContent(i,0.); } double norm = 1./h1_norm->Integral(); h1_norm->Scale(norm); norm = 1./h2_norm->Integral(); h2_norm->Scale(norm); norm = 1./h3_norm->Integral(); h3_norm->Scale(norm); norm = 1./h4_norm->Integral(); h4_norm->Scale(norm); norm = 1./h5_norm->Integral(); //only for 50ns samples h5_norm->Scale(norm); //only for 50ns samples norm = 1./h6_norm->Integral(); //only for 50ns samples h6_norm->Scale(norm); //only for 50ns samples norm = 1./h7_norm->Integral(); //only for 50ns samples h7_norm->Scale(norm); //only for 50ns samples norm = 1./hbkg1_norm->Integral(); hbkg1_norm->Scale(norm); norm = 1./hbkg2_norm->Integral(); hbkg2_norm->Scale(norm); norm = 1./hbkg3_norm->Integral(); hbkg3_norm->Scale(norm); norm = 1./hbkg4_norm->Integral(); hbkg4_norm->Scale(norm); norm = 1./hbkg5_norm->Integral(); hbkg5_norm->Scale(norm); norm = 1./hbkg6_norm->Integral(); hbkg6_norm->Scale(norm); norm = 1./hbkg7_norm->Integral(); hbkg7_norm->Scale(norm); norm = 1./hbkg8_norm->Integral(); hbkg8_norm->Scale(norm); norm = 1./hbkg9_norm->Integral(); hbkg9_norm->Scale(norm); norm = 1./hbkg10_norm->Integral(); hbkg10_norm->Scale(norm); norm = 1./hbkg11_norm->Integral(); hbkg11_norm->Scale(norm); norm = 1./hbkg12_norm->Integral(); hbkg12_norm->Scale(norm); h1_norm->SetLineColor(kRed+3); h2_norm->SetLineColor(kRed+1); h3_norm->SetLineColor(kRed); h4_norm->SetLineColor(kPink+2); h5_norm->SetLineColor(kPink+4); //only for 25ns samples h6_norm->SetLineColor(kPink+7); //only for 25ns samples h7_norm->SetLineColor(kMagenta+2); //only for 25ns samples h1_norm->SetLineWidth(2); h2_norm->SetLineWidth(2); h3_norm->SetLineWidth(2); h4_norm->SetLineWidth(2); h5_norm->SetLineWidth(2); //only for 25ns samples h6_norm->SetLineWidth(2); //only for 25ns samples h7_norm->SetLineWidth(2); //only for 25ns samples hbkg7_norm->SetLineColor(kGreen+2); hbkg6_norm->SetLineColor(kGreen); hbkg8_norm->SetLineColor(kYellow); hbkg4_norm->SetLineColor(kOrange); hbkg9_norm->SetLineColor(kOrange+7); hbkg10_norm->SetLineColor(kOrange+4); hbkg11_norm->SetLineColor(kCyan); hbkg12_norm->SetLineColor(kCyan+1); hbkg5_norm->SetLineColor(kBlue+3); hbkg2_norm->SetLineColor(kBlue); hbkg3_norm->SetLineColor(kMagenta-2); hbkg1_norm->SetLineColor(kViolet); hbkg1_norm->SetFillStyle(0); hbkg2_norm->SetFillStyle(0); hbkg3_norm->SetFillStyle(0); hbkg4_norm->SetFillStyle(0); hbkg5_norm->SetFillStyle(0); hbkg6_norm->SetFillStyle(0); hbkg7_norm->SetFillStyle(0); hbkg8_norm->SetFillStyle(0); hbkg9_norm->SetFillStyle(0); hbkg10_norm->SetFillStyle(0); hbkg11_norm->SetFillStyle(0); hbkg12_norm->SetFillStyle(0); h1_norm->SetTitle(""); h1_norm->SetMaximum(1); h1_norm->SetMinimum(0.001); h1_norm->Draw("HIST"); hbkg1_norm->Draw("same HIST"); hbkg2_norm->Draw("same HIST"); hbkg3_norm->Draw("same HIST"); hbkg5_norm->Draw("same HIST"); hbkg4_norm->Draw("same HIST"); hbkg6_norm->Draw("same HIST"); hbkg7_norm->Draw("same HIST"); hbkg8_norm->Draw("same HIST"); hbkg9_norm->Draw("same HIST"); hbkg10_norm->Draw("same HIST"); hbkg11_norm->Draw("same HIST"); hbkg12_norm->Draw("same HIST"); h1_norm->Draw("same hist"); h2_norm->Draw("same hist"); h3_norm->Draw("same hist"); h4_norm->Draw("same hist"); h5_norm->Draw("same hist"); h6_norm->Draw("same hist"); h7_norm->Draw("same hist"); h1_norm->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E_{T}^{miss})|"); h1_norm->GetYaxis()->SetTitle("Normalized events"); h1_norm->GetYaxis()->SetTitleOffset(1.2); gPad->Modified(); gStyle->SetOptStat(0); //int iPos =0; // CMS_lumi(p1,true,iPos,true); // CMS_lumi(p2,true,iPos,true); leg_norm->AddEntry(h1_norm,"m_{Z'} = 600 GeV","l"); leg_norm->AddEntry(hbkg1_norm,"#gamma #gamma","l"); leg_norm->AddEntry(h2_norm,"m_{Z'} = 800 GeV","l"); leg_norm->AddEntry(hbkg2_norm,"Drell Yann","l"); leg_norm->AddEntry(h3_norm,"m_{Z'} = 1000 GeV","l"); leg_norm->AddEntry(hbkg3_norm,"#gamma + Jets","l"); leg_norm->AddEntry(h4_norm,"m_{Z'} = 1200 GeV","l"); leg_norm->AddEntry(hbkg5_norm,"QCD","l"); leg_norm->AddEntry(h5_norm,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg4_norm,"ggH","l"); leg_norm->AddEntry(h6_norm,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg6_norm,"VH","l"); leg_norm->AddEntry(h7_norm,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg7_norm,"ttH","l"); leg_norm->AddEntry(hbkg8_norm,"VBF H","l"); leg_norm->AddEntry(hbkg9_norm,"t + #gamma + Jets","l"); leg_norm->AddEntry(hbkg10_norm,"tt + #gamma +Jets","l"); leg_norm->AddEntry(hbkg11_norm,"#gamma+W","l"); leg_norm->AddEntry(hbkg12_norm,"#gamma+Z","l"); leg_norm->Draw("same"); if(pt1_cutIN==0. && pt2_cutIN == 0. && MET_cutIN == 0.){ c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.png"); c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.pdf"); c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.png"); c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.pdf"); } }
void plotRatioDoubleratio(TString varname_="", TString vartex_="") { gStyle->SetTextSize(0.05); gStyle->SetTextFont(42); gStyle->SetPadRightMargin(0.05); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadTopMargin(0.1); gStyle->SetPadBottomMargin(0.145); gStyle->SetTitleX(.0f); gStyle->SetOptStat(0); gStyle->SetMarkerStyle(20); gStyle->SetMarkerSize(0.8); varname=varname_; vartex=vartex_; TFile* infPP = new TFile(Form("outfDoubleratio/fPP_%s_DoubleRatio.root",varname.Data())); TH1D* hPP = (TH1D*)infPP->Get("hDoubleRatio"); hPP->SetName(Form("hPP_%.0f",varname.Data())); TFile* infPbPb = new TFile(Form("outfDoubleratio/fPbPb_%s_DoubleRatio.root",varname.Data())); TH1D* hPbPb = (TH1D*)infPbPb->Get("hDoubleRatio"); hPbPb->SetName(Form("hPbPb_%.0f",varname.Data())); TFile* infPPMB = new TFile(Form("outfDoubleratio/fPPMB_%s_DoubleRatio.root",varname.Data())); TH1D* hPPMB = (TH1D*)infPPMB->Get("hDoubleRatio"); hPPMB->SetName(Form("hPPMB_%.0f",varname.Data())); TFile* infPbPbMB = new TFile(Form("outfDoubleratio/fPbPbMB_%s_DoubleRatio.root",varname.Data())); TH1D* hPbPbMB = (TH1D*)infPbPbMB->Get("hDoubleRatio"); hPbPbMB->SetName(Form("hPbPbMB_%.0f",varname.Data())); TH1F* hRatio = (TH1F*)hPbPb->Clone("hRatio"); hRatio->Divide(hPP); TH1F* hRatioMB = (TH1F*)hPbPbMB->Clone("hRatioMB"); hRatioMB->Divide(hPPMB); Int_t varbins = hRatio->GetNbinsX(); Float_t varstep = hRatio->GetBinWidth(1); Float_t varmin = hRatio->GetBinCenter(1)-0.5*varstep; Float_t varmax = hRatio->GetBinCenter(varbins)-0.5*varstep; Float_t aRatio[varbins],aRatioErr[varbins]; Float_t aRatioMB[varbins],aRatioMBErr[varbins]; Float_t aX[varbins],aZero[varbins]; for(int i=0;i<varbins;i++) { aX[i] = hRatio->GetBinCenter(i+1)-0.5*varstep; aZero[i] = 0; aRatio[i] = hRatio->GetBinContent(i+1); aRatioErr[i] = hRatio->GetBinError(i+1); aRatioMB[i] = hRatioMB->GetBinContent(i+1); aRatioMBErr[i] = hRatioMB->GetBinError(i+1); } TGraphErrors* gRatio = new TGraphErrors(varbins,aX,aRatio,aZero,aRatioErr); TH2F* hemptyRatio = new TH2F("hemptyRatio","",20,varmin-0.5*varstep,varmax+0.5*varstep,10.,0.7,1.3); hemptyRatio->GetXaxis()->SetTitle(Form("%s",vartex.Data())); hemptyRatio->GetYaxis()->SetTitle("DoubleRatio^{PbPb} / DoubleRatio^{PP}"); hemptyRatio->GetXaxis()->SetTitleOffset(1.); hemptyRatio->GetYaxis()->SetTitleOffset(.9); hemptyRatio->GetXaxis()->SetTitleSize(0.045); hemptyRatio->GetYaxis()->SetTitleSize(0.045); hemptyRatio->GetXaxis()->SetTitleFont(42); hemptyRatio->GetYaxis()->SetTitleFont(42); hemptyRatio->GetXaxis()->SetLabelFont(42); hemptyRatio->GetYaxis()->SetLabelFont(42); hemptyRatio->GetXaxis()->SetLabelSize(0.04); hemptyRatio->GetYaxis()->SetLabelSize(0.04); TCanvas* cRatio = new TCanvas("cRatio","",600,600); hemptyRatio->Draw(); gRatio->Draw("psame"); cRatio->SaveAs(Form("plotRatios/cRatio_%s.pdf",varname.Data())); TGraphErrors* gRatioMB = new TGraphErrors(varbins,aX,aRatioMB,aZero,aRatioMBErr); TH2F* hemptyRatioMB = new TH2F("hemptyRatioMB","",20,varmin-0.5*varstep,varmax+0.5*varstep,10.,0.7,1.3); hemptyRatioMB->GetXaxis()->SetTitle(Form("%s",vartex.Data())); hemptyRatioMB->GetYaxis()->SetTitle("DoubleRatio^{PbPb} / DoubleRatio^{PP}"); hemptyRatioMB->GetXaxis()->SetTitleOffset(1.); hemptyRatioMB->GetYaxis()->SetTitleOffset(.9); hemptyRatioMB->GetXaxis()->SetTitleSize(0.045); hemptyRatioMB->GetYaxis()->SetTitleSize(0.045); hemptyRatioMB->GetXaxis()->SetTitleFont(42); hemptyRatioMB->GetYaxis()->SetTitleFont(42); hemptyRatioMB->GetXaxis()->SetLabelFont(42); hemptyRatioMB->GetYaxis()->SetLabelFont(42); hemptyRatioMB->GetXaxis()->SetLabelSize(0.04); hemptyRatioMB->GetYaxis()->SetLabelSize(0.04); TCanvas* cRatioMB = new TCanvas("cRatioMB","",600,600); hemptyRatioMB->Draw(); gRatioMB->Draw("psame"); cRatioMB->SaveAs(Form("plotRatios/cRatioMB_%s.pdf",varname.Data())); }
void Overlay_NeutralEnergyMeanNeutralEfficient() { std::string canvasName = "canvas"; std::string canvasTitle = "Neutral energy mean, N_{n} != 0"; int canvasX1 = 200; int canvasY1 = 52; int canvasX2 = 700; int canvasY2 = 650; int nPoints = 6; int nGraphs = 5; int neutralEnergy = 10; double zero [] = {0, 0, 0, 0, 0, 0, 0, 0}; double energies[] = {10, 20, 30, 40, 50}; double distances[] = {5, 10, 15, 20, 25, 30}; std::string graphXTitle = "Distance between showers [cm]"; std::string graphYTitle = "<E_{neutral}> with N_{n}!=0"; double rangeUserXMin = 0; double rangeUserXMax = 35; double rangeUserYMin = 0.0001; double rangeUserYMax = 20; TCanvas *pCanvas = new TCanvas(canvasName.c_str(), canvasTitle.c_str(), canvasX1, canvasY1, canvasX2, canvasY2); pCanvas->SetFillColor(0); pCanvas->SetBorderMode(0); pCanvas->SetBorderSize(2); pCanvas->SetTickx(1); pCanvas->SetTicky(1); pCanvas->SetLeftMargin(0.15); pCanvas->SetRightMargin(0.03); pCanvas->SetTopMargin(0.05); pCanvas->SetBottomMargin(0.14); pCanvas->SetFrameBorderMode(0); pCanvas->SetFrameBorderMode(0); TH1F *pH = new TH1F("pouette", "", rangeUserXMax-rangeUserXMin, rangeUserXMin, rangeUserXMax); pH->SetMinimum(rangeUserYMin); pH->SetMaximum(rangeUserYMax); pH->Draw(); gStyle->SetOptStat(0); pH->GetYaxis()->SetTitle(graphYTitle.c_str()); pH->GetXaxis()->SetTitle(graphXTitle.c_str()); pH->GetYaxis()->SetLabelFont(42); pH->GetYaxis()->SetTitleSize(0.05); pH->GetYaxis()->SetTitleOffset(1); pH->GetYaxis()->SetTitleFont(42); pH->GetYaxis()->SetLabelSize(0.045); TLegend *leg = new TLegend(0.3,0.55,0.8,0.8,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetTextSize(0.03); int currentColor = 1; for(unsigned int e=0 ; e<nGraphs ; e++) { int energy = energies[e]; double *data = new double[nPoints]; double *dataError = zero;//new double[nPoints]; std::stringstream fileName; fileName << "data_neutralERecNeutralEfficient_ArborPFA_Test\ Beam_" << energy << "Gev.txt"; readData(fileName.str(), data, nPoints); // fileName.str(""); // fileName << "fichier_data_error_energy_" << energy << "GeV.txt"; // readData(fileName.str(), dataError, nPoints); TGraphErrors *gre = 0; std::stringstream graphName; graphName << "Charged particle energy = " << energy << " GeV"; gre = new TGraphErrors(nPoints, distances, data, zero, dataError); gre->SetName(graphName.str().c_str()); gre->SetTitle(graphName.str().c_str()); gre->SetLineColor(currentColor); gre->SetMarkerColor(currentColor); gre->SetMarkerStyle(23); gre->SetMarkerSize(1.2); gre->Draw("lp same"); TLegendEntry *entry = 0; entry=leg->AddEntry(gre, graphName.str().c_str(), "lp"); entry->SetFillStyle(1001); entry->SetMarkerColor(currentColor); entry->SetMarkerStyle(23); entry->SetMarkerSize(1); currentColor++; } TPaveText *pt = new TPaveText(0.55, 0.2, 0.93, 0.3, "tbNDC"); pt->SetTextSize(0.05); pt->SetTextColor(kGray+2); pt->SetFillColor(0); pt->SetLineWidth(0); pt->SetBorderSize(0); pt->AddText("CALICE Preliminary"); pt->SetTextFont(62); pt->Draw(); leg->Draw(); pCanvas->Modified(); pCanvas->cd(); pCanvas->SetSelected(pCanvas); }