void decorate(TCanvas *can,TH2D &h, bool addLHC=true){ TLatex * tex = new TLatex(); tex->SetNDC(); tex->SetTextFont(42); tex->SetLineWidth(2); tex->SetTextSize(0.03); tex->DrawLatex(0.32,0.93,"4.9 fb^{-1} (7 TeV) + 19.7 fb^{-1} (8 TeV) + 2.3 fb^{-1} (13 TeV)"); tex->SetTextFont(42); tex->SetTextSize(0.06); //if (!addLHC){ // tex->SetTextSize(0.04); // tex->SetTextColor(kWhite); // if (isPrelim) tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}"); // else tex->DrawLatex(0.155, 0.85, "#bf{CMS}"); //} else { if (isPrelim) { tex->SetTextSize(0.04); tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}"); } else tex->DrawLatex(0.14, 0.93, "#bf{CMS}"); //} TGraph *SM = new TGraph(); SM->SetPoint(0,1,1); SM->SetMarkerColor(kOrange); SM->SetMarkerStyle(33); SM->SetMarkerSize(4); SM->Draw("Psame"); TLegend *leg; if (addLHC) { if (isPrelim) leg = new TLegend(0.14,0.56,0.4,0.83); else leg = new TLegend(0.14,0.62,0.4,0.89); } else leg = new TLegend(0.52,0.84,0.78,0.89); leg->SetTextSize(0.042); leg->SetFillStyle(0); leg->SetTextColor(kWhite); leg->SetBorderSize(0); TGraph *gr = new TGraph(); gr->SetLineWidth(2); gr->SetMarkerStyle(34); gr->SetLineColor(kWhite); gr->SetMarkerColor(kWhite); TGraph *gr2 = new TGraph(); gr2->SetLineWidth(2); gr2->SetLineColor(kWhite); gr2->SetLineStyle(2); gr->SetMarkerSize(2); if (addLHC){ leg->AddEntry(SM,"SM production","P"); leg->AddEntry(gr,"LHC best fit","P"); leg->AddEntry(gr, "68% CL","L"); leg->AddEntry(gr2,"95% CL","L"); leg->Draw(); } else { TLatex *lat = new TLatex(); lat->SetTextSize(0.04); lat->SetTextColor(kWhite); lat->DrawLatex(1.05,1.05,"SM production"); } can->SetTicky(); can->SetTickx(); can->RedrawAxis(); }
void DrawTree::setLegend(float xmin, float ymin, float xsize, float ysize,char* header) { _legend = new TLegend(xmin,ymin,xmin+xsize,ymin+ysize); _legend->SetTextAlign(12); _legend->SetTextColor(1); _legend->SetTextSize(0.03); _legend->SetFillStyle(0); _legend->SetFillColor(0); _legend->SetBorderSize(0); _legend->SetHeader(header); }
void Plots::Legend(TString histoname1,TString histoname2,TString histoname3, TString histoname4, TH1F *histo1, TH1F *histo2, TH1F *histo3, TH1F *histo4) { TLegend *leg = new TLegend(0.45,0.88,1.,1.0); leg->SetTextAlign(32); leg->SetTextColor(1); leg->SetTextSize(0.020); char label[128]; sprintf(label,"perfect alignment; mean = %1.3f, RMS = %1.3f",convert(histo1->GetMean()),convert(histo1->GetRMS())); leg->AddEntry(histoname1, label, "l"); sprintf(label,"SurveyLASCosmics alignment; mean = %1.3f, RMS = %1.3f",convert(histo2->GetMean()),convert(histo2->GetRMS())); leg->AddEntry(histoname2, label, "l"); sprintf(label,"10 pb-1 alignment; mean = %1.3f, RMS = %1.3f",convert(histo3->GetMean()),convert(histo3->GetRMS())); leg->AddEntry(histoname3, label, "l"); sprintf(label,"100 pb-1 alignment; mean = %1.3f, RMS = %1.3f",convert(histo4->GetMean()),convert(histo4->GetRMS())); leg->AddEntry(histoname4, label, "l"); leg->Draw(); }
void PlotADKNeon( const TString &opt="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PGlobals::Initialize(); // Palettes! gROOT->Macro("PPalettes.C"); gStyle->SetPadGridY(0); gStyle->SetPadGridX(0); gStyle->SetTextFont(42); gStyle->SetTitleFont(42,"xyz"); gStyle->SetLabelFont(42,"xyz"); gStyle->SetLabelOffset(0.014, "y"); gStyle->SetTextFont(42); gStyle->SetPadRightMargin(0.10); PUnits::UnitsTable::Get(); const Int_t Nat = 10; char atNames[Nat][10] = { "Ne^{+}", "Ne^{2+}", "Ne^{3+}", "Ne^{4+}", "Ne^{5+}", "Ne^{6+}", "Ne^{7+}", "Ne^{8+}", "Ne^{9+}", "Ne^{10+}"}; // Ionization levels from NIST: http://physics.nist.gov/cgi-bin/ASD/ie.pl Double_t atEion[Nat] = { 21.5645400, 40.962960, 63.42331, 97.1900, 126.247, 157.9340, 207.271, 239.0969, 1195.80779, 1362.199100}; Double_t atZ[Nat] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; TF1 **fADKvsE = new TF1*[Nat]; Int_t atColor[Nat] = {kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen,kGreen}; Int_t atStyle[Nat] = {1,2,3,4,5,6,7,8,9,10}; TLine *lineTh[Nat]; TMarker *markTh[Nat]; // Electric field range Double_t Emin[Nat] = { 40, 60,100,200, 220, 300, 1000,1000,10000,10000}; // PUnits::GV/PUnits::m; Double_t Emax[Nat] = {190,300,400,800,1000,1200,15000,50000,40000,40000}; // PUnits::GV/PUnits::m; const Int_t NPAR = 2; Double_t par[Nat][NPAR]; for(Int_t i=0; i<Nat; i++) { par[i][0] = atEion[i]; par[i][1] = atZ[i]; char name[24]; sprintf(name,"fADKvsE_%s",atNames[i]); fADKvsE[i] = new TF1(name,ADKfunction,Emin[i],1*Emax[i],NPAR); fADKvsE[i]->SetParameters(par[i]); } // Evaluate the function to find Ion thresholds Int_t Npoints = 10000; Float_t IonTh[Nat]; Bool_t found[Nat] = {0}; for(Int_t i=0; i<Npoints; i++) { for(Int_t j=0;j<Nat;j++) { Float_t E = (i+1)*(Emax[j]-Emin[j])/Npoints + Emin[j]; Float_t value = fADKvsE[j]->Eval(E); if(value>0.1 && !found[j]) { IonTh[j] = E; found[j] = 1; } } } // Dump physical constants cout << Form(" Physical constants") << endl; cout << Form(" e0 = %16.9e F/m", PConst::eps0 / (PUnits::farad / PUnits::meter)) << endl; cout << Form(" k0 = %16.9e m/F", PConst::k0 * (PUnits::farad / PUnits::meter)) << endl; cout << Form(" me = %16.9e Kg", PConst::ElectronMass/PUnits::kg) << endl; cout << Form(" qe = %16.9e C", PConst::ElectronCharge/PUnits::coulomb) << endl; cout << Form(" hbar = %16.9e J * s", PConst::hbar/ (PUnits::joule*PUnits::second)) << endl; cout << Form(" XiA = %16.9e eV", PConst::XiA/ (PUnits::eV)) << endl; cout << Form(" EA = %16.9e GV/m", PConst::EF0/ (PUnits::GV/PUnits::m)) << endl; cout << Form(" TA = %16.9e s", PConst::AT/ (PUnits::second)) << endl; cout << Form("\n Neon levels") << endl; for(Int_t j=0;j<Nat;j++) { // cout << Form("%s ion threshold: %.2f",atNames[j],IonTh[j]) << endl; // Compute OSIRIS parameters for Ionization Double_t Eion0 = atEion[j]; Int_t Z = atZ[j]; // Engineering formula // Double_t n = 3.69*Z/TMath::Sqrt(Eion0); // Double_t A = 1.52E15 * TMath::Power(4,n) * Eion0 / ( n * TMath::Gamma(2*n) ) // * TMath::Power(20.5 * TMath::Power(Eion0,3./2.),2*n-1); // Double_t B = 6.83 * TMath::Power(Eion0,3./2.); // Double_t C = 2*n-1; // Atomic units Double_t ei = Eion0/(PConst::XiA/PUnits::eV); Double_t efactor = 2 * ei; Double_t ns = Z / TMath::Sqrt(efactor); Double_t xi0 = TMath::Power(efactor,3./2.); Double_t C = 2*ns-1; Double_t A = ( (TMath::Power(4.0,ns) * ei) / ( ns * TMath::Gamma(2*ns)) ) * TMath::Power( 2 * xi0 * PConst::EF0 / (PUnits::GV / PUnits::meter),C) / (PConst::AT/PUnits::second) ; Double_t B = (2./3.) * xi0 * PConst::EF0 / (PUnits::GV / PUnits::meter); // cout << Form("OSIRIS coefficients") << endl; cout << Form(" %12.6f eV (Z = %2i) : ",Eion0,Z) ; cout << Form(" %e %e %e",A,B,C) << endl; } TCanvas *Canv = new TCanvas("Canv","Tunnel-ionization probability",1024,640); Canv->cd(); gPad->SetLogx(1); gPad->SetTickx(1); TH1F *hFrame = new TH1F("hFrame","",10,5.0,50000); hFrame->GetYaxis()->SetRangeUser(0.,10); hFrame->GetYaxis()->SetTitle("W_{ADK} [fs^{-1}]"); hFrame->GetXaxis()->SetTitle("E [GV/m]"); hFrame->GetXaxis()->CenterTitle(); hFrame->GetYaxis()->CenterTitle(); hFrame->Draw(); for(Int_t i=0; i<Nat; i++) { fADKvsE[i]->GetYaxis()->SetRangeUser(0.,10); fADKvsE[i]->SetLineWidth(2); fADKvsE[i]->SetLineColor(atColor[i]); fADKvsE[i]->SetLineStyle(atStyle[i]); fADKvsE[i]->Draw("C same"); } for(Int_t i=0; i<Nat; i++) { lineTh[i] = new TLine(IonTh[i],0.0,IonTh[i],0.3); lineTh[i]->SetLineColor(atColor[i]); lineTh[i]->SetLineWidth(1); lineTh[i]->Draw(); markTh[i] = new TMarker(IonTh[i],0.3,20); markTh[i]->SetMarkerColor(atColor[i]); markTh[i]->SetMarkerSize(1); markTh[i]->Draw(); } gPad->Update(); Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = gPad->GetLeftMargin(); // Float_t x2 = 1 - gPad->GetRightMargin(); TLegend *Leg = new TLegend(x1+0.05,y1+0.30,x1+0.24,y2-0.07); PGlobals::SetPaveStyle(Leg); for(Int_t i=0; i<Nat; i++) { Leg->AddEntry(fADKvsE[i],Form("%s (%.1f eV)",atNames[i],atEion[i]),"L"); } Leg->SetTextFont(82); Leg->SetTextColor(kGray+2); Leg->Draw(); // Print to a file PGlobals::imgconv(Canv,"./ADK-probabilities-Ne",opt); // --------------------------------------------------------- }
void fastEfficiencyNadir(unsigned int iEG, int iECAL1, int iColl1, int iECAL2, int iColl2, TString dirIn="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/EfficiencyStudy/SingEle-May10ReReco/UPDATE2/Tag80Probe95/", TString lumi="200 pb", int nCPU=4, int color1=kBlack, int style1=kFullCircle, int color2=kRed, int style2=kOpenSquare, TString probe="WP80", TString tag="WP80", TString fileIn="tree_effi_TagProbe.root") { // STYLE // gROOT->Reset(); loadPresentationStyle(); gROOT->ForceStyle(); // EG THRESHOLDS // const int nEG = 71; double thres[nEG]; for(int i=0 ; i<nEG ; i++) thres[i]=i; TString names[nEG]; ostringstream ossi; for(int i=0;i<(int)nEG;i++) { ossi.str(""); ossi << thres[i] ; names[i] = ossi.str(); } // NAMES // const int nECAL=2; const int nColl=2; TString name_leg_ecal[nECAL] = {"Barrel","Endcaps"}; TString name_leg_coll[nColl] = {"Online","Emulation"}; TString name_ecal[nECAL] = {"_EB","_EE"}; TString name_coll[nColl] = {"_N","_M"}; TString dirResults = dirIn + "/turnons/EG"+names[iEG]+"/" ; TString name_image = dirResults + "eff_EG"+names[iEG]+"_tag"+tag+"_probe"+probe+name_ecal[iECAL1]+name_coll[iColl1]+"_vs"+name_ecal[iECAL2]+name_coll[iColl2] ; // Output log // ofstream fichier(name_image+".txt", ios::out); // BINNING // const int nbins[nEG] = {29,29,29,29,21,21,21,22,22,21,22,21,22,18,19,18,18,18,18,20,20,20,20,19,20,20,20,20,21,21, 21,21,21,21,21,21,21,21,21,21, //EG30 22,22,22,22,22,22,22,22,22,22, //EG40 29,29,29,29,29,29,29,29,29,29, //EG50 29,29,29,29,29,29,29,29,29,29};//EG60 Double_t bins_0[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG0 Double_t bins_1[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG1 Double_t bins_2[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG2 Double_t bins_3[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG3 Double_t bins_4[21] = {1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 17, 19, 21, 27, 32, 41, 50, 60, 70, 150}; // EG4 Double_t bins_5[21] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 31, 40, 50, 60, 70, 150}; // EG5 Double_t bins_6[21] = {3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 23, 27, 32, 41, 50, 60, 70, 150}; // EG6 Double_t bins_7[22] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG7 Double_t bins_8[22] = {3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 32, 41, 50, 60, 70, 150}; // EG8 Double_t bins_9[21] = {4, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG9 Double_t bins_10[22] = {5, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG10 Double_t bins_11[21] = {6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 31, 40, 50, 60, 70, 150}; // EG11 Double_t bins_12[22] = {5, 7, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG12 Double_t bins_13[18] = {5, 7, 9, 11, 12, 13, 14, 15, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG13 Double_t bins_14[19] = {6, 8, 10, 12, 13, 14, 15, 16, 18, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG14 Double_t bins_15[18] = {5, 7, 9, 11, 13, 14, 15, 16, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG15 Double_t bins_16[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG16 Double_t bins_17[18] = {9, 11, 13, 15, 16, 17, 18, 19, 21, 23, 25, 30, 35, 40, 50, 60, 70, 150}; // EG17 Double_t bins_18[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG18 Double_t bins_19[20] = {9, 11, 13, 15, 17, 18, 19, 20, 21, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG19 Double_t bins_20[20] = {8, 10, 12, 14, 16, 18, 19, 20, 21, 22, 24, 26, 30, 35, 40, 45, 50, 60, 70, 100}; // EG20 Double_t bins_21[20] = {9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG21 Double_t bins_22[20] = {10, 12, 14, 16, 18, 20, 21, 22, 23, 24, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG22 Double_t bins_23[19] = {11, 13, 15, 17, 19, 21, 22, 23, 24, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG23 Double_t bins_24[20] = {10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG24 Double_t bins_25[20] = {11, 13, 15, 17, 19, 21, 23, 24, 25, 26, 27, 29, 30, 35, 40, 45, 50, 60, 70, 150}; // EG25 Double_t bins_26[20] = {10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG26 Double_t bins_27[20] = {11, 13, 15, 17, 19, 21, 23, 25, 26, 27, 28, 29, 33, 35, 40, 45, 50, 60, 70, 150}; // EG27 Double_t bins_28[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, 32, 35, 40, 45, 50, 60, 70, 150}; // EG28 Double_t bins_29[21] = {11, 13, 15, 17, 19, 21, 23, 25, 27, 28, 29, 30, 31, 33, 35, 40, 45, 50, 60, 70, 150}; // EG29 Double_t bins_30[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, 31, 32, 35, 40, 45, 50, 60, 70, 150}; // EG30 Double_t bins_40[22] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 39, 40, 42, 45, 50, 60, 70, 150}; // EG40 Double_t bins_50[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG50 Double_t bins_60[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG60 vector< Double_t* > bins; bins.push_back( bins_0 ); bins.push_back( bins_1 ); bins.push_back( bins_2 ); bins.push_back( bins_3 ); bins.push_back( bins_4 ); bins.push_back( bins_5 ); bins.push_back( bins_6 ); bins.push_back( bins_7 ); bins.push_back( bins_8 ); bins.push_back( bins_9 ); bins.push_back( bins_10 ); bins.push_back( bins_11 ); bins.push_back( bins_12 ); bins.push_back( bins_13 ); bins.push_back( bins_14 ); bins.push_back( bins_15 ); bins.push_back( bins_16 ); bins.push_back( bins_17 ); bins.push_back( bins_18 ); bins.push_back( bins_19 ); bins.push_back( bins_20 ); bins.push_back( bins_21 ); bins.push_back( bins_22 ); bins.push_back( bins_23 ); bins.push_back( bins_24 ); bins.push_back( bins_25 ); bins.push_back( bins_26 ); bins.push_back( bins_27 ); bins.push_back( bins_28 ); bins.push_back( bins_29 ); for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_30 ); for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_40 ); for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_50 ); for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_60 ); RooBinning binning = RooBinning(nbins[iEG]-1, bins[iEG], "binning"); // INPUT DATA // TFile* f1 = TFile::Open(dirIn+"/"+fileIn); TTree* treenew; TTree* treenew_2; treenew = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL1]+name_coll[iColl1] ) ; treenew_2 = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL2]+name_coll[iColl2] ) ; TString name_scet[2], name_scdr[2], name_l1bin[2]; name_scet[0] = "sc_et"+name_ecal[iECAL1]+name_coll[iColl1]; name_scet[1] = "sc_et"+name_ecal[iECAL2]+name_coll[iColl2]; name_scdr[0] = "sc_dr"+name_ecal[iECAL1]+name_coll[iColl1]; name_scdr[1] = "sc_dr"+name_ecal[iECAL2]+name_coll[iColl2]; name_l1bin[0] = "l1_"+names[iEG]+name_ecal[iECAL1]+name_coll[iColl1]; name_l1bin[1] = "l1_"+names[iEG]+name_ecal[iECAL2]+name_coll[iColl2]; RooRealVar et_plot(name_scet[0],name_scet[0],0,150) ; RooRealVar dr(name_scdr[0],name_scdr[0],0.5,1.5) ; RooRealVar et_plot2(name_scet[1],name_scet[1],0,150) ; RooRealVar dr2(name_scdr[1],name_scdr[1],0.5,1.5) ; // Acceptance state cut (1 or 0) RooCategory cut(name_l1bin[0],name_l1bin[0]) ; cut.defineType("accept",1) ; cut.defineType("reject",0) ; RooCategory cut2(name_l1bin[1],name_l1bin[1]) ; cut2.defineType("accept",1) ; cut2.defineType("reject",0) ; // PARAMETRES ROOFIT CRYSTAL BALL RooRealVar norm("norm","N",1,0.6,1); RooRealVar alpha("alpha","#alpha",0.671034,0.01,8); RooRealVar n("n","n",4.07846,1.1,35); RooRealVar mean("mean","mean",20.8,0,100); //mean.setVal(thres[iEG]); RooRealVar sigma("sigma","#sigma",0.972825,0.01,5); //RooRealVar pedestal("pedestal","pedestal",0.01,0,0.4); RooRealVar norm2("norm2","N",0.999069,0.6,1); RooRealVar alpha2("alpha2","#alpha",0.492303,0.01,8); RooRealVar n2("n2","n",11.6694,1.1,35); RooRealVar mean2("mean2","mean",21.4582,0,100); //mean2.setVal(thres[iEG]); RooRealVar sigma2("sigma2","#sigma",1.19,0.01,5); //RooRealVar pedestal2("pedestal2","pedestal",0.01,0,0.4); FuncCB cb("cb","Crystal Ball Integree",et_plot,mean,sigma,alpha,n,norm) ; FuncCB cb2("cb2","Crystal Ball Integree",et_plot2,mean2,sigma2,alpha2,n2,norm2) ; // EFFICIENCY // RooEfficiency eff("eff","efficiency",cb,cut,"accept"); RooEfficiency eff2("eff2","efficiency",cb2,cut2,"accept"); // DATASETS // RooDataSet dataSet("data","data",RooArgSet(et_plot, cut,dr),Import(*treenew)); RooDataSet dataSet2("data2","data2",RooArgSet(et_plot2, cut2,dr2),Import(*treenew_2)); dataSet.Print(); dataSet2.Print(); // PLOT // RooPlot* frame = et_plot.frame(Bins(18000),Title("Fitted efficiency")) ; RooPlot* frame2 = et_plot2.frame(Bins(18000),Title("Fitted efficiency")) ; dataSet.plotOn(frame, Binning(binning), Efficiency(cut), MarkerColor(color1), LineColor(color1), MarkerStyle(style1) ); dataSet2.plotOn(frame2, Binning(binning), Efficiency(cut2), MarkerColor(color2), LineColor(color2), MarkerStyle(style2) ); /////////////////////// FITTING ///////////////////////////// double fit_cuts_min = thres[iEG]-1.5 ; double fit_cuts_max = 150; et_plot.setRange("interesting",fit_cuts_min,fit_cuts_max); et_plot2.setRange("interesting",fit_cuts_min,fit_cuts_max); RooFitResult* roofitres1 = new RooFitResult("roofitres1","roofitres1"); RooFitResult* roofitres2 = new RooFitResult("roofitres2","roofitres2"); fichier << "Fit characteristics :" << endl ; fichier << "EG " << names[iEG] << endl ; fichier << "Fit Range , EB Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ; fichier << "Fit Range , EE Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ; fichier << "----------------------" << endl ; // Fit #1 // roofitres1 = eff.fitTo(dataSet,ConditionalObservables(et_plot),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE)); cb.plotOn(frame,LineColor(color1),LineWidth(2)); double res_norm1 = norm.getVal(); double err_norm1 = norm.getErrorLo(); double res_mean1 = mean.getVal(); double err_mean1 = mean.getError(); double res_sigma1 = sigma.getVal(); double err_sigma1 = sigma.getError(); double res_n1 = n.getVal(); double err_n1 = n.getError(); double res_alpha1 = alpha.getVal(); double err_alpha1 = alpha.getError(); fichier << "<----------------- EB ----------------->" << endl << "double res_mean=" << res_mean1 << "; " << "double res_sigma=" << res_sigma1 << "; " << "double res_alpha=" << res_alpha1 << "; " << "double res_n=" << res_n1 << "; " << "double res_norm=" << res_norm1 << "; " << endl << "double err_mean=" << err_mean1 << "; " << "double err_sigma=" << err_sigma1 << "; " << "double err_alpha=" << err_alpha1 << "; " << "double err_n=" << err_n1 << "; " << "double err_norm=" << err_norm1 << "; " << endl; // Fit #2 // roofitres2 = eff2.fitTo(dataSet2,ConditionalObservables(et_plot2),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE)); cb2.plotOn(frame2,LineColor(color2),LineWidth(2)); double res_norm2 = norm2.getVal(); double err_norm2 = norm2.getErrorLo(); double res_mean2 = mean2.getVal(); double err_mean2 = mean2.getError(); double res_sigma2 = sigma2.getVal(); double err_sigma2 = sigma2.getError(); double res_n2 = n2.getVal(); double err_n2 = n2.getError(); double res_alpha2 = alpha2.getVal(); double err_alpha2 = alpha2.getError(); fichier << "<----------------- EE ----------------->" << endl << "double res_mean=" << res_mean2 << "; " << "double res_sigma=" << res_sigma2 << "; " << "double res_alpha=" << res_alpha2 << "; " << "double res_n=" << res_n2 << "; " << "double res_norm=" << res_norm2 << "; " << endl << "double err_mean=" << err_mean2 << "; " << "double err_sigma=" << err_sigma2 << "; " << "double err_alpha=" << err_alpha2 << "; " << "double err_n=" << err_n2 << "; " << "double err_norm=" << err_norm2 << "; " << endl; //////////////////////////// DRAWING PLOTS AND LEGENDS ///////////////////////////////// TCanvas* ca = new TCanvas("ca","Trigger Efficiency") ; ca->SetGridx(); ca->SetGridy(); ca->cd(); gPad->SetLogx(); gPad->SetObjectStat(1); frame->GetYaxis()->SetRangeUser(0,1.05); frame->GetXaxis()->SetRangeUser(1,100.); frame->GetYaxis()->SetTitle("Efficiency"); frame->GetXaxis()->SetTitle("E_{T} [GeV]"); frame->Draw() ; frame2->GetYaxis()->SetRangeUser(0,1.05); frame2->GetXaxis()->SetRangeUser(1,100.); frame2->GetYaxis()->SetTitle("Efficiency"); frame2->GetXaxis()->SetTitle("E_{T} [GeV]"); frame2->Draw("same") ; TH1F *SCeta1 = new TH1F("SCeta1","SCeta1",50,-2.5,2.5); TH1F *SCeta2 = new TH1F("SCeta2","SCeta2",50,-2.5,2.5); SCeta1->SetLineColor(color1) ; SCeta1->SetMarkerColor(color1); SCeta1->SetMarkerStyle(style1); SCeta2->SetLineColor(color2) ; SCeta2->SetMarkerColor(color2); SCeta2->SetMarkerStyle(style2); TLegend *leg = new TLegend(0.246,0.435,0.461,0.560,NULL,"brNDC"); // mid : x=353.5 leg->SetLineColor(1); leg->SetTextColor(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetShadowColor(kWhite); leg->SetFillColor(kWhite); leg->SetMargin(0.25); TLegendEntry *entry=leg->AddEntry("NULL","L1_SingleEG"+names[iEG],"h"); // leg->AddEntry(SCeta1,name_leg_ecal[iECAL1]+" "+name_leg_coll[iColl1],"p"); // leg->AddEntry(SCeta2,name_leg_ecal[iECAL2]+" "+name_leg_coll[iColl2],"p"); leg->AddEntry(SCeta1,name_leg_ecal[iECAL1],"p"); leg->AddEntry(SCeta2,name_leg_ecal[iECAL2],"p"); leg->Draw(); leg = new TLegend(0.16,0.725,0.58,0.905,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.03); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry("NULL","CMS Preliminary 2012 pp #sqrt{s}=8 TeV","h"); leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h"); leg->AddEntry("NULL","Threshold : "+names[iEG]+" GeV","h"); leg->Draw(); TPaveText *pt2 = new TPaveText(0.220,0.605,0.487,0.685,"brNDC"); // mid : x=353.5 pt2->SetLineColor(1); pt2->SetTextColor(1); pt2->SetTextFont(42); pt2->SetTextSize(0.03); pt2->SetFillColor(kWhite); pt2->SetShadowColor(kWhite); pt2->AddText("L1 E/Gamma Trigger"); pt2->AddText("Electrons from Z"); pt2->Draw(); //TString name_image="eff_EG20_2012_12fb"; ca->Print(name_image+".cxx","cxx"); ca->Print(name_image+".png","png"); ca->Print(name_image+".gif","gif"); ca->Print(name_image+".pdf","pdf"); ca->Print(name_image+".ps","ps"); ca->Print(name_image+".eps","eps"); ///////////////////////////// // SAVE THE ROO FIT RESULT // ///////////////////////////// RooWorkspace *w = new RooWorkspace("workspace","workspace") ; w->import(dataSet); w->import(dataSet2); w->import(*roofitres1,"roofitres1"); w->import(*roofitres2,"roofitres2"); cout << "CREATES WORKSPACE : " << endl; w->Print(); w->writeToFile(name_image+"_fitres.root") ; //gDirectory->Add(w) ; //f1->Close(); }
void PlotPhaseVelocityFunctions( const TString &opt="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); gStyle->SetPadTopMargin(0.06); gStyle->SetPadGridY(0); gStyle->SetPadGridX(0); gStyle->SetFrameLineWidth(2); gStyle->SetLabelSize(0.04, "xyz"); gStyle->SetTitleOffset(1.2,"y"); gStyle->SetTitleOffset(1.2,"z"); gStyle->SetNdivisions(505,"xyz"); PUnits::UnitsTable::Get(); // // SPS parameters from Pukhov, Kumar et al. PRL107,145003(2011) // Double_t n0 = 7.76e14 / PUnits::cm3; // Double_t nb = 1.5e12 / PUnits::cm3; // Double_t lambda = PFunc::PlasmaWavelength(n0); // Double_t kp = PFunc::PlasmaWavenumber(n0); // Double_t skindepth = PFunc::PlasmaSkindepth(n0); // Double_t r0 = 0.19 * PUnits::mm; // Double_t z = 2.5 * PUnits::m; // Double_t zg = -28.6 * PUnits::mm; // Double_t E = 450 * PUnits::GeV; // Double_t gamma = E / PConst::ProtonMassE ; // SPS parameters from Schroeder et al. PRL107,145002(2011) // Double_t n0 = 1.0; // Double_t nb = 0.002; // Double_t lambda = TMath::TwoPi(); // Double_t kp = 1.0; // Double_t r0 = 1.0; // Double_t z = 13105; // Double_t E = 450 * PUnits::GeV; // Double_t gamma = E / PConst::ProtonMassE ; // PITZ parameters Double_t n0 = 1.0e15 / PUnits::cm3; Double_t nb = 1.05e13 / PUnits::cm3; Double_t lambda = PFunc::PlasmaWavelength(n0); Double_t kp = PFunc::PlasmaWavenumber(n0); Double_t skindepth = PFunc::PlasmaSkindepth(n0); Double_t r0 = 34.259 * PUnits::um; Double_t z = 150. * PUnits::mm; Double_t zg = -5. * PUnits::mm; Double_t E = 25 * PUnits::MeV; Double_t gamma = (E / PConst::ElectronMassE) + 1.0; Double_t vb = TMath::Sqrt(1. - (1./(gamma*gamma))); cout << " n0 = " << n0 * PUnits::cm3 << " e/cc" << endl; cout << " Wavelength = " << PUnits::BestUnit(lambda, "Length") << endl; cout << " Skindepth = " << PUnits::BestUnit(skindepth, "Length") << endl; cout << " Wavenumber = " << kp * PUnits::mm << " mm^-1" << endl; // Normalized variables if(!opt.Contains("units")){ r0 *= kp; nb /= n0; n0 = 1.0; z *= kp; zg *= kp; } Double_t N = PFunc::Nefoldings(z,zg,r0,gamma,nb,n0); Double_t r1 = (TMath::Power(3.,1./4.)/TMath::Power(8.*TMath::Pi()*N,1./2.)) * TMath::Exp(N) ; Double_t Gamma = PFunc::PhaseGamma(z,zg,r0,gamma,nb,n0); Double_t vph = PFunc::PhaseVelocity(z,zg,r0,gamma,nb,n0); Double_t vph2 = PFunc::PhaseVelocity2(z,zg,gamma,nb,n0); cout << " gamma beam = " << gamma << endl; cout << " zeta = " << z << endl; cout << " zeta comov. = " << zg << endl; cout << " r0 = " << r0 << endl; cout << " n_b0/n_0 = " << nb/n0 << endl; cout << " nu constant = " << PFunc::Nu(r0,n0) << endl; cout << " Number e-foldings = " << N << endl; cout << " r1 = " << r1 << endl; cout << " Gamma wake = " << Gamma << endl; cout << " Wake Phase velocity = " << vph << endl; cout << " Wake Phase velocity2 = " << vph2 << endl; cout << " Beam phase velocity = " << vb << endl; const Int_t NPAR = 5; Double_t par[NPAR] = {zg,r0,gamma,nb,n0}; TF1 *fPhaseVsZ2 = new TF1("fPhaseVsZ2",PhaseVelocityVsZ2,0,z,NPAR); fPhaseVsZ2->SetParameters(par); TF1 *fPhaseVsZ = new TF1("fPhaseVsZ",PhaseVelocityVsZ,0,z,NPAR); fPhaseVsZ->SetParameters(par); Double_t par2[NPAR] = {z,r0,gamma,nb,n0}; TF1 *fPhaseVsZg2 = new TF1("fPhaseVsZg2",PhaseVelocityVsZg2,zg,0.,NPAR); fPhaseVsZg2->SetParameters(par2); TF1 *fPhaseVsZg = new TF1("fPhaseVsZg",PhaseVelocityVsZg,zg,0.,NPAR); fPhaseVsZg->SetParameters(par2); const Int_t NPAR2D = 4; Double_t par3[NPAR2D] = {r0,gamma,nb,n0}; TF2 *fPhaseVsZVsZg2 = new TF2("fPhaseVsZVsZg2",PhaseVelocityVsZVsZg2,0.,z,zg,0.,NPAR2D); fPhaseVsZVsZg2->SetParameters(par3); TF2 *fPhaseVsZVsZg = new TF2("fPhaseVsZVsZg",PhaseVelocityVsZVsZg,0.,z,zg,0.,NPAR2D); fPhaseVsZVsZg->SetParameters(par3); char ctext[64]; TPaveText *textZetag = new TPaveText(0.13,0.85,0.38,0.92,"NDC"); PlasmaGlob::SetPaveTextStyle(textZetag,12); textZetag->SetTextColor(kGray+3); if(opt.Contains("units")) sprintf(ctext,"#zeta_{0} = %6.2f mm", zg / PUnits::mm); else sprintf(ctext,"#zeta_{0} = %6.2f c/#omega_{p}", zg); textZetag->AddText(ctext); TPaveText *textZeta = new TPaveText(0.13,0.85,0.38,0.92,"NDC"); PlasmaGlob::SetPaveTextStyle(textZeta,12); textZeta->SetTextColor(kGray+3); if(opt.Contains("units")) sprintf(ctext,"z_{0} = %6.2f mm", z / PUnits::mm); else sprintf(ctext,"z_{0} = %6.2f c/#omega_{p}", z); textZeta->AddText(ctext); // Graph for de-phasing: const Int_t NP = 100; TGraph *gPhase = new TGraph(NP); TGraph *gPhase2 = new TGraph(NP); Float_t phase = zg; Float_t phase2 = zg; Float_t Dz = z / NP; for(Int_t i=0;i<NP;i++) { Float_t zp = (i+1)*Dz; Float_t v = PFunc::PhaseVelocity(zp,phase,r0,gamma,nb,n0); phase += (v - vb) * Dz; // cout << " z = " << zp << " phase = " << phase << endl; if(opt.Contains("units")) gPhase->SetPoint(i,zp,(phase-zg)*kp); else gPhase->SetPoint(i,zp,(phase-zg)); v = PFunc::PhaseVelocity2(zp,phase2,gamma,nb,n0); phase2 += (v - 1) * Dz; // cout << " z = " << zp << " phase = " << phase << endl; if(opt.Contains("units")) gPhase2->SetPoint(i,zp,(phase2-zg)*kp); else gPhase2->SetPoint(i,zp,(phase2-zg)); } TCanvas *C = new TCanvas("C","Wake phase velocity",1000,750); C->Divide(2,2); TLegend *Leg = new TLegend(0.6,0.20,0.85,0.35); PlasmaGlob::SetPaveStyle(Leg); Leg->SetTextAlign(22); Leg->SetTextColor(kGray+3); Leg->SetLineColor(1); Leg->SetBorderSize(1); Leg->SetFillColor(0); Leg->SetFillStyle(1001); //Leg-> SetNColumns(2); Leg->AddEntry(fPhaseVsZ,"PRL 107,145002","L"); Leg->AddEntry(fPhaseVsZ2,"PRL 107,145003","L"); Leg->SetTextColor(kGray+3); C->cd(1); fPhaseVsZ->GetYaxis()->SetTitle("(v_{p} - c)/c"); if(opt.Contains("units")) fPhaseVsZ->GetXaxis()->SetTitle("z [m]"); else fPhaseVsZ->GetXaxis()->SetTitle("z [c/#omega_{p}]"); fPhaseVsZ->GetYaxis()->SetRangeUser(-3e-4,0.); fPhaseVsZ->GetXaxis()->CenterTitle(); fPhaseVsZ->GetYaxis()->CenterTitle(); fPhaseVsZ->SetLineWidth(2); fPhaseVsZ->Draw("C"); fPhaseVsZ2->SetLineWidth(2); fPhaseVsZ2->SetLineStyle(2); fPhaseVsZ2->Draw("C same"); textZetag->Draw(); Leg->Draw(); C->cd(2); fPhaseVsZg->GetYaxis()->SetTitle("(v_{p} - c)/c"); if(opt.Contains("units")) fPhaseVsZg->GetXaxis()->SetTitle("#zeta [m]"); else fPhaseVsZg->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); fPhaseVsZg->GetYaxis()->SetRangeUser(-3e-4,0.); fPhaseVsZg->GetYaxis()->SetNdivisions(505); fPhaseVsZg->GetXaxis()->CenterTitle(); fPhaseVsZg->SetLineWidth(2); fPhaseVsZg->GetYaxis()->CenterTitle(); fPhaseVsZg->Draw("C"); fPhaseVsZg2->SetLineWidth(2); fPhaseVsZg2->SetLineStyle(2); fPhaseVsZg2->Draw("C same"); textZeta->Draw(); C->cd(3); gPhase->GetYaxis()->SetTitle("#Delta#zeta [c/#omega_{p}]"); if(opt.Contains("units")) { gPhase->GetXaxis()->SetTitle("z [m]"); gPhase->GetXaxis()->SetNdivisions(510); } else gPhase->GetXaxis()->SetTitle("z [c/#omega_{p}]"); // gPhase->GetXaxis()->SetNdivisions(510); gPhase->GetXaxis()->CenterTitle(); gPhase->GetYaxis()->CenterTitle(); gPhase->GetXaxis()->SetRangeUser(0.,z); gPhase->GetYaxis()->SetNdivisions(505); gPhase->SetLineWidth(2); gPhase->Draw("AC"); gPhase2->SetLineStyle(2); gPhase2->SetLineWidth(2); gPhase2->Draw("C"); textZetag->Draw(); C->cd(4); gPad->SetLeftMargin(0.18); if(opt.Contains("units")) { fPhaseVsZVsZg->GetYaxis()->SetTitle("#zeta [m]"); } else fPhaseVsZVsZg->GetYaxis()->SetTitle("#zeta [c/#omega_{p}]"); if(opt.Contains("units")) { fPhaseVsZVsZg->GetXaxis()->SetTitle("z [m]"); } else fPhaseVsZVsZg->GetXaxis()->SetTitle("z [c/#omega_{p}]"); fPhaseVsZVsZg->GetZaxis()->SetTitle("(v_{p} - c)/c"); fPhaseVsZVsZg->GetYaxis()->SetNdivisions(505); // fPhaseVsZVsZg->GetXaxis()->SetNdivisions(510); fPhaseVsZVsZg->GetXaxis()->CenterTitle(); fPhaseVsZVsZg->GetXaxis()->SetTitleOffset(1.6); fPhaseVsZVsZg->GetYaxis()->CenterTitle(); fPhaseVsZVsZg->GetYaxis()->SetTitleOffset(2.0); fPhaseVsZVsZg->GetZaxis()->CenterTitle(); fPhaseVsZVsZg->GetZaxis()->SetTitleOffset(1.4); fPhaseVsZVsZg->Draw("surf2"); C->cd(); // Print to a file PlasmaGlob::imgconv(C,"./WakePhaseVelocity",opt); // --------------------------------------------------------- }
void tempSumm() { const Int_t nx = 5; char *labels[nx] = {"9/30","10/15","10/31","11/19","12/19"}; TH1F *probe1summ = new TH1F("probe1summ","",nx,0,nx); TH1F *probe2summ = new TH1F("probe2summ","",nx,0,nx); TH1F *probe3summ = new TH1F("probe3summ","",nx,0,nx); TH1F *probe4summ = new TH1F("probe4summ","",nx,0,nx); probe1summ->Fill(labels[0],0.910);//keep track of these from SC elog:36 probe1summ->SetBinError(1,0.057); probe1summ->Fill(labels[1],1.088); probe1summ->SetBinError(2,0.018); probe1summ->Fill(labels[2],0.64); probe1summ->SetBinError(3,0.12); probe1summ->Fill(labels[3],0.72); probe1summ->SetBinError(4,0.057); probe1summ->Fill(labels[4],0.81); probe1summ->SetBinError(5,0.043); probe2summ->Fill(labels[0],1.280); probe2summ->SetBinError(1,0.026); probe2summ->Fill(labels[1],1.269); probe2summ->SetBinError(2,0.021); probe2summ->Fill(labels[2],1.05); probe2summ->SetBinError(3,0.08); probe2summ->Fill(labels[3],1.67); probe2summ->SetBinError(4,0.050); probe2summ->Fill(labels[4],1.42); probe2summ->SetBinError(5,0.028); probe3summ->Fill(labels[0],0.833); probe3summ->SetBinError(1,0.026); probe3summ->Fill(labels[1],1.423); probe3summ->SetBinError(2,0.035); probe3summ->Fill(labels[2],1.24); probe3summ->SetBinError(3,0.118); probe3summ->Fill(labels[3],1.60); probe3summ->SetBinError(4,0.055); probe3summ->Fill(labels[4],1.34); probe3summ->SetBinError(5,0.038); probe4summ->Fill(labels[0],-999); probe4summ->SetBinError(1,-999); probe4summ->Fill(labels[1],0.340); probe4summ->SetBinError(2,0.071); probe4summ->Fill(labels[2],0.38); probe4summ->SetBinError(3,0.082); probe4summ->Fill(labels[3],0.59); probe4summ->SetBinError(4,0.054); probe4summ->Fill(labels[4],0.48); probe4summ->SetBinError(5,0.119); probe1summ->GetXaxis()->SetTitle("run date"); probe1summ->GetXaxis()->CenterTitle(1); probe1summ->GetYaxis()->SetTitle("temp. (C)"); probe1summ->GetYaxis()->CenterTitle(1); probe1summ->SetMarkerColor(kBlue); probe1summ->SetLineColor(kBlue); probe2summ->SetMarkerColor(kRed); probe2summ->SetLineColor(kRed); probe3summ->SetMarkerColor(kGreen); probe3summ->SetLineColor(kGreen); probe4summ->SetMarkerColor(kCyan); probe4summ->SetLineColor(kCyan); probe1summ->SetMarkerStyle(20); probe2summ->SetMarkerStyle(20); probe3summ->SetMarkerStyle(20); probe4summ->SetMarkerStyle(20); probe1summ->SetMarkerSize(0.5); probe2summ->SetMarkerSize(0.5); probe3summ->SetMarkerSize(0.5); probe4summ->SetMarkerSize(0.5); probe1summ->SetMinimum(0); probe1summ->SetMaximum(2); probe1summ->GetXaxis()->SetLabelSize(0.05); TLegend *leg = new TLegend(0.155,0.691,0.344,0.860); leg->SetTextSize(0.035); leg->SetTextColor(1); leg->SetFillColor(0); leg->Clear(); leg->AddEntry(probe1summ, "probe 1", "pl"); leg->AddEntry(probe2summ, "probe 2", "pl"); leg->AddEntry(probe3summ, "probe 3", "pl"); leg->AddEntry(probe4summ, "probe 4", "pl"); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetTextFont(22); gStyle->SetOptStat(0000); TCanvas *tempSumm = new TCanvas(); probe1summ->Draw("e1p"); probe2summ->Draw("e1p same"); probe3summ->Draw("e1p same"); probe4summ->Draw("e1p same"); leg->Draw(); tempSumm->Print("tempSumm.eps"); }
void spike_summarize(TString dirOut="./HPU2012/Rebin/rebin3/", int factor=3, TString graph_style="A*") { loadPresentationStyle(); /* gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasColor(kWhite); gStyle->SetCanvasDefH(600); //Height of canvas gStyle->SetCanvasDefW(600); //Width of canvas gStyle->SetCanvasDefX(0); //POsition on screen gStyle->SetCanvasDefY(0); gStyle->SetTitleFont(42); gStyle->SetTitleColor(1); gStyle->SetTitleTextColor(1); */ //gStyle->SetTitleFillColor(10); /* gStyle->SetTitleFontSize(0.05); gStyle->SetTitleColor(1, "XYZ"); gStyle->SetTitleFont(42, "XYZ"); */ gStyle->SetTitleSize(0.05, "XYZ"); gStyle->SetTitleYOffset(1.2); /* gStyle->SetLabelColor(1, "XYZ"); gStyle->SetLabelFont(42, "XYZ"); gStyle->SetLabelOffset(0.007, "XYZ"); gStyle->SetLabelSize(0.05, "XYZ"); gStyle->SetAxisColor(1, "XYZ"); gStyle->SetStripDecimals(kTRUE); gStyle->SetTickLength(0.03, "XYZ"); gStyle->SetNdivisions(510, "XYZ"); gStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame gStyle->SetPadTickY(1); */ //const int nSrc = 3; // 2011A, 2011B, highPU const int nSrc=5; // data 2011B, newkill 2011B, data highPU, emul highPU, 2012 online HPU const int nStrict = 2; const int nEG = 8; const int nVtx = 40; const int nVTX[nSrc]={40,40,40,40,60}; const int nEG_g=4; // nEG for graph : EG12,15,20,30 //TString src_name[nSrc]={"2011A","2011B","highPU"}; TString src_name[nSrc]={"data_2011B","newsetting_2011B", "data_highPU", "d2012_HPU"}; TString strict_name[nStrict] = {"large","strict"}; TString trigname[nEG]={"2","5","8","10","12","15","20","30"}; int trigthresh[nEG]={2,5,8,10,12,15,20,30}; TH1F * h_evts_trigBy_any[nEG][nSrc]; TH1F * h_evts_trigBy_spikes[nEG][nStrict][nSrc]; cout << "objects declared and counters initialized" << endl; TString name_histo; for( int iSrc=0 ; iSrc<nSrc ; iSrc++ ) { for( int iEG=0 ; iEG<nEG ; iEG++ ) { name_histo = "h_evts_trigBy_any_EG"+trigname[iEG]+"_"+src_name[iSrc]; h_evts_trigBy_any[iEG][iSrc] = new TH1F(name_histo,name_histo,nVTX[iSrc],0,nVTX[iSrc]); for( int iStrict=0 ; iStrict<nStrict ; iStrict++ ) { name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_"+strict_name[iStrict]+"_"+src_name[iSrc]; h_evts_trigBy_spikes[iEG][iStrict][iSrc] = new TH1F(name_histo,name_histo,nVTX[iSrc],0,nVTX[iSrc]); } } } TString file[nSrc]; // FILES : HLTEG12 file[0]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/Commi_2011B_HLTEG12_fromfilter/spike_plots_half_0_1.root"; file[1]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/CommiEmulReco_Run2011B/GetContamNewkill/spike_plots_half_0_1.root"; file[2]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/Commi_2011B_highPU_HLTEG_repro/spike_plots_half_0_1.root" ; file[3]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/Spikes/HighPuContamination/try2/spike_plots.root" ; file[4]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/Spikes2012/HPU/spike_plots_half_0_1.root" ; TFile * f; cout << "going to open files" << endl; for(int iSrc=0 ; iSrc<nSrc ; iSrc++) { if(iSrc==3) continue; f = TFile::Open(file[iSrc]); cout << "file #" << iSrc << " opened" << endl; for( int iEG=0 ; iEG<nEG ; iEG++ ) { name_histo = "h_evts_trigBy_any_EG"+trigname[iEG]; h_evts_trigBy_any[iEG][iSrc] -> Add( (TH1F*)gDirectory->Get(name_histo) ); if(iSrc==4) h_evts_trigBy_any[iEG][iSrc] -> Rebin(2); cout << " got histogram " + name_histo << endl; for( int iStrict=0 ; iStrict<nStrict ; iStrict++ ) { name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_"+strict_name[iStrict]; h_evts_trigBy_spikes[iEG][iStrict][iSrc] -> Add( (TH1F*)gDirectory->Get(name_histo) ); if(iSrc==4) h_evts_trigBy_spikes[iEG][iStrict][iSrc] -> Rebin(2); cout << "got histogram "+ name_histo <<endl; } } f->Close(); } // highPU emul is special case f = TFile::Open(file[3]); cout << "file #" << 3 << " opened" << endl; for( int iEG=0 ; iEG<nEG ; iEG++ ) { name_histo = "h_evts_trigBy_any_EG"+trigname[iEG]+"_M"; h_evts_trigBy_any[iEG][3] -> Add( (TH1F*)gDirectory->Get(name_histo) ); // name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_M"; h_evts_trigBy_spikes[iEG][0][3] -> Add( (TH1F*)gDirectory->Get(name_histo) ); h_evts_trigBy_spikes[iEG][1][3] -> Add( (TH1F*)gDirectory->Get(name_histo) ); } const int nFr=2; // low/up frontier of iBin const int nBins_src[nSrc][nEG_g]={ {21,15,19,16} , {16,15,13,10} , {28,25,24,21} , {28,25,24,21} , {15,15,15,15}}; int idxBinsFr[nSrc][nEG_g][nFr]={ { {2,22},{1,15},{2,20},{3,18} }, { {3,18},{1,15},{4,16},{5,14} }, { {12,39},{14,38},{14,37},{14,34} }, { {12,39},{14,38},{14,37},{14,34} }, { {30,60},{30,60},{30,60},{30,60} } }; int fact[nSrc]={1,1,1,1,factor}; vector< float > n_evts_trigBy_any[nEG][nSrc]; // double tableau de vecteurs de floats vector< float > n_evts_trigBy_spikes[nEG][nStrict][nSrc]; // triple vector< float > n_contam[nEG][nStrict][nSrc]; vector< float > err_contam[nEG][nStrict][nSrc]; // --> chaque element du tableau est un vecteur contenant les valeurs des bins des histos for(int iEG=0 ; iEG<nEG_g ; iEG++) { for(int iSrc=0 ; iSrc<nSrc ; iSrc++) { const int nBins = nBins_src[iSrc][iEG] ; for(int iBin=0 ; iBin<nBins ; iBin++) { n_evts_trigBy_any[iEG][iSrc].push_back( (float)( h_evts_trigBy_any[iEG+4][iSrc] -> GetBinContent(idxBinsFr[iSrc][iEG][0]/fact[iSrc]+iBin+1) ) ); for(int iStrict=0 ; iStrict<nStrict ; iStrict++ ) { n_evts_trigBy_spikes[iEG][iStrict][iSrc].push_back( (float)( h_evts_trigBy_spikes[iEG+4][iStrict][iSrc] -> GetBinContent(idxBinsFr[iSrc][iEG][0]/fact[iSrc]+iBin+1) ) ); if( n_evts_trigBy_any[iEG][iSrc][iBin] !=0 ) { n_contam[iEG][iStrict][iSrc].push_back( n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin]/n_evts_trigBy_any[iEG][iSrc][iBin]); err_contam[iEG][iStrict][iSrc].push_back( errPoissCount( n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin], n_evts_trigBy_any[iEG][iSrc][iBin]) ); } else { n_contam[iEG][iStrict][iSrc].push_back(-0.01); err_contam[iEG][iStrict][iSrc].push_back(0); } } // loop over iStrict } // loop over iBin } // loop over iSrc } // loop over iEG for(int iEG=0 ; iEG<nEG_g ; iEG++) { for(int iSrc=0 ; iSrc<nSrc ; iSrc++) { int nBins = n_evts_trigBy_any[iEG][iSrc].size(); cout << "EG" << trigname[iEG+4] << " src=" << src_name[iSrc] << endl; for(int iBin=0 ; iBin<nBins ; iBin++) cout << n_evts_trigBy_any[iEG][iSrc][iBin] << " " ; cout << endl; for(int iStrict=0 ; iStrict<nStrict ; iStrict++ ) { cout << "strict="<< strict_name[iStrict]<< endl; int nBins_s = n_evts_trigBy_spikes[iEG][iStrict][iSrc].size(); for(int iBin=0 ; iBin<nBins_s ; iBin++) cout << n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin] << " "; cout << endl; nBins_s = n_contam[iEG][iStrict][iSrc].size(); for(int iBin=0 ; iBin<nBins_s ; iBin++) cout << n_contam[iEG][iStrict][iSrc][iBin] << " "; cout << endl; } cout << endl; } cout << endl; } //int mark_style[nSrc] = {22,20,21}; // kFullTriangleUp, kFullCircle, kFullSquare //int mark_col[nSrc] = {4,2,1}; // bleu, rouge, noir int mark_style[nSrc] = {22,22,21,21,20}; //int mark_col[nSrc] = {4,2,4,2}; int mark_col[nSrc] = {kRed,kGreen+2,kRed,kGreen+2,kBlue}; TGraph * g_evt_contam[nEG][nStrict][nSrc]; TGraphErrors * g_evt_contam_err[nEG][nStrict][nSrc]; for(int iSrc=0 ; iSrc<nSrc ; iSrc++) { for(int iStrict=0 ; iStrict<nStrict ; iStrict++) { for(int iEG=0 ; iEG<nEG_g ; iEG++) { const int nPts = nBins_src[iSrc][iEG]; float x_vtx[nPts]; float err_vtx[nPts]; for(int iVtx=0 ; iVtx<nPts ; iVtx++) { x_vtx[iVtx] = (float)( idxBinsFr[iSrc][iEG][0] + iVtx*fact[iSrc] ) ; cout << x_vtx[iVtx] << " | " ; err_vtx[iVtx] = 0.49*fact[iSrc]; } cout << endl; const int nDots = n_contam[iEG][iStrict][iSrc].size(); if( nDots != nPts ) { cout << "ERROR : nDots != nPts ! exit..." << endl; return; } float contam_vtx[nPts]; float err_contam_vtx[nPts]; for(int iVtx=0 ; iVtx<nPts ; iVtx++) { contam_vtx[iVtx] = n_contam[iEG][iStrict][iSrc][iVtx]; cout << n_contam[iEG][iStrict][iSrc][iVtx] << " |||" ; cout << contam_vtx[iVtx] << " || "; err_contam_vtx[iVtx] = err_contam[iEG][iStrict][iSrc][iVtx]; } cout << endl; g_evt_contam[iEG][iStrict][iSrc] = new TGraph( nPts, x_vtx, contam_vtx ); g_evt_contam_err[iEG][iStrict][iSrc] = new TGraphErrors( nPts, x_vtx, contam_vtx, err_vtx, err_contam_vtx ); g_evt_contam[iEG][iStrict][iSrc]->SetName( "Event_"+strict_name[iStrict]+"_contamination_EG"+trigname[iEG+4]+"_"+src_name[iSrc] ); g_evt_contam[iEG][iStrict][iSrc]->SetTitle( "Event "+strict_name[iStrict]+" contamination (EG"+trigname[iEG+4]+") "+src_name[iSrc] ); g_evt_contam[iEG][iStrict][iSrc]->SetMarkerStyle(mark_style[iSrc]); g_evt_contam[iEG][iStrict][iSrc]->SetMarkerColor(mark_col[iSrc]); g_evt_contam[iEG][iStrict][iSrc]->SetFillColor(kWhite); cout << "N POINTS = " << g_evt_contam[iEG][iStrict][iSrc]->GetN() << endl; g_evt_contam_err[iEG][iStrict][iSrc]->SetName( "Event_"+strict_name[iStrict]+"_contamination_error_EG"+trigname[iEG+4]+"_"+src_name[iSrc] ); g_evt_contam_err[iEG][iStrict][iSrc]->SetTitle( "Event "+strict_name[iStrict]+" contamination (EG"+trigname[iEG+4]+") "+src_name[iSrc] ); g_evt_contam_err[iEG][iStrict][iSrc]->SetMarkerStyle(mark_style[iSrc]); g_evt_contam_err[iEG][iStrict][iSrc]->SetMarkerColor(mark_col[iSrc]); g_evt_contam_err[iEG][iStrict][iSrc]->SetFillColor(kWhite); } } } cout << endl << endl; for(int iSrc=0 ; iSrc<nSrc ; iSrc++) for(int iStrict=0 ; iStrict<nStrict ; iStrict++) for(int iEG=0 ; iEG<nEG_g ; iEG++) cout << "N POINTS = " << g_evt_contam[iEG][iStrict][iSrc]->GetN() << endl; //for(int iVtx=0 ; iVtx<nPts ; iVtx++) //cout << n_contam[iEG][iStrict][iSrc][iVtx] << " || " << ////////////////////////////////////////////////////////// // PLOTTING ////////////////////////////////////////////// ////////////////////////////////////////////////////////// TCanvas * c_evt_contam[nEG_g][nStrict]; TCanvas * c_evt_contam_err[nEG_g][nStrict]; float g_max[nEG_g] = {0.3,0.4,0.6,0.35}; //for(int iEG=0 ; iEG<nEG_g ; iEG++) { /* for(int iEG=0 ; iEG<2 ; iEG++) { for(int iStrict=0 ; iStrict<nStrict ; iStrict++) { c_evt_contam[iEG][iStrict] = new TCanvas("c_evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict], "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")", 0,0,800,600); c_evt_contam[iEG][iStrict]->SetFillColor(kWhite); c_evt_contam[iEG][iStrict]->GetFrame()->SetFillColor(kWhite); g_evt_contam[iEG][iStrict][0]->SetMinimum(0); g_evt_contam[iEG][iStrict][0]->SetMaximum(g_max[iEG]); g_evt_contam[iEG][iStrict][0]->GetXaxis()->Set(40,0,40); g_evt_contam[iEG][iStrict][0]->GetXaxis()->SetTitle("Number of vertices"); g_evt_contam[iEG][iStrict][0]->GetYaxis()->SetTitle("Fraction of EG events trig. by spikes"); g_evt_contam[iEG][iStrict][0]->SetTitle( "Spike contamination (EG"+trigname[iEG+4]+")" ); g_evt_contam[iEG][iStrict][0]->Draw("AP"); g_evt_contam[iEG][iStrict][1]->Draw("P"); g_evt_contam[iEG][iStrict][2]->Draw("P"); g_evt_contam[iEG][iStrict][3]->Draw("P"); TLegend * leg = new TLegend(0.5,0.70,0.885,0.90,"CMS Preliminary 2011 pp #sqrt{s}=7 TeV","brNDC"); //(x1,y1),(x2,y2)->bottom left , top right leg->SetLineColor(1); leg->SetTextColor(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetMargin(0.2); leg->SetShadowColor(kWhite); leg->SetFillColor(kWhite); // leg->AddEntry(g_evt_contam[iEG][iStrict][0],"Run 2011B Data","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][1],"Run 2011B Emul new setting (data)","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][2],"High PU runs Data","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][3],"High PU runs Emul new setting (data)","P"); leg->Draw(); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".C"); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".gif"); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".png"); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".eps"); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".ps"); c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".pdf"); } } */ cout << "<--- FINE UNTIL HERE --->" << endl; //for(int iEG=0 ; iEG<nEG_g ; iEG++) { for(int iEG=1 ; iEG<3 ; iEG++) { for(int iStrict=0 ; iStrict<nStrict ; iStrict++) { c_evt_contam_err[iEG][iStrict] = new TCanvas("c_evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict], "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")", 0,0,800,600); c_evt_contam_err[iEG][iStrict]->SetFillColor(kWhite); c_evt_contam_err[iEG][iStrict]->GetFrame()->SetFillColor(kWhite); g_evt_contam_err[iEG][iStrict][0]->SetMinimum(0); g_evt_contam_err[iEG][iStrict][0]->SetMaximum(g_max[iEG]); g_evt_contam_err[iEG][iStrict][0]->GetXaxis()->Set(60,0,60); g_evt_contam_err[iEG][iStrict][0]->SetTitle( "Spike contamination (EG"+trigname[iEG+4]+")" ); g_evt_contam_err[iEG][iStrict][0]->GetXaxis()->SetTitle("Number of vertices"); g_evt_contam_err[iEG][iStrict][0]->GetYaxis()->SetTitle("Fraction of EG events trig. by spikes"); g_evt_contam_err[iEG][iStrict][0]->Draw("AP"); g_evt_contam_err[iEG][iStrict][1]->Draw("P"); g_evt_contam_err[iEG][iStrict][2]->Draw("P"); g_evt_contam_err[iEG][iStrict][3]->Draw("P"); g_evt_contam_err[iEG][iStrict][4]->Draw("P"); //TLegend * leg = new TLegend(0.17,0.695,0.58,0.90,"CMS Preliminary 2012 pp #sqrt{s}=7+8 TeV","brNDC"); TLegend * leg = new TLegend(0.17,0.675,0.58,0.88,"CMS Preliminary 2012 pp #sqrt{s}=7+8 TeV","brNDC"); //(x1,y1),(x2,y2)->bottom left , top right leg->SetMargin(0.15); leg->SetLineColor(1); leg->SetTextColor(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetShadowColor(kWhite); leg->SetFillColor(kWhite); // leg->AddEntry(g_evt_contam[iEG][iStrict][0],"Run 2011B Data","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][1],"Run 2011B Emul new setting (data)","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][2],"High PU runs Data","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][3],"High PU runs Emul new setting (data)","P"); leg->AddEntry(g_evt_contam[iEG][iStrict][4],"High PU runs 2012 (data)","P"); leg->Draw(); /* TLegend * leg2 = new TLegend(0.4,0.78,0.885,0.88,"","brNDC"); //(x1,y1),(x2,y2):bottom left,top right leg2->SetLineColor(1); leg2->SetTextColor(1); leg2->SetTextFont(42); leg2->SetTextSize(0.03); leg2->SetShadowColor(kWhite); leg2->SetFillColor(kWhite); leg2->AddEntry("NULL","Contamination = #frac{N(events triggered by a spike)}{N(events triggered by any object)}","h"); leg2->Draw(); */ c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".C"); c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".gif"); c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".png"); c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".eps"); c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".ps"); c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".pdf"); } } }
void Plotting() { TH1::AddDirectory(kFALSE); gStyle->SetCanvasDefH(600); gStyle->SetCanvasDefW(600); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetPadBorderSize(0); gStyle->SetCanvasBorderSize(0); gStyle->SetOptTitle(0); // at least most of the time gStyle->SetOptStat("nemr"); // most of the time, sometimes "nemriou" might be useful to display name, //number of entries, mean, rms, integral, overflow and underflow gStyle->SetOptFit(0); // set to 1 only if you want to display fit results //=================================== Histo for all cut variables ========================================== using namespace RooFit; using namespace RooStats; void setWSRange(RooWorkspace *ws); void defineMassBkg(RooWorkspace *ws); void defineMassSig(RooWorkspace *ws); double RError(double,double,double,double); double WeightRatioError(double,double,double,double); bool is3D =1; bool significance = 0; bool isHI=0; bool Prompt = 0; bool nonPrompt = 1; bool savePlot=0; bool Binning =0; bool ctauFit = 1; float ptmin=3.0; float ptmax=30.0; float ymin=1.6; float ymax=2.4; bool absRapidity=true; double threshold=0.8; double efficiency=0.9; int centmin=0; int centmax=200; ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=30.0; //ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=6.5; //ymin=1.6; ymax=2.4; ptmin=6.5; ptmax=12.0; //ymin=1.6; ymax=2.4; ptmin=12.0; ptmax=30.0; //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=30.0; //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=9.0; //ymin=0.0; ymax=1.6; ptmin=9.0; ptmax=12.0; //ymin=0.0; ymax=1.6; ptmin=12.0; ptmax=15.0; //ymin=0.0; ymax=1.6; ptmin=15.0; ptmax=20.0; //ymin=0.0; ymax=1.6; ptmin=20.0; ptmax=30.0; int range1 = 0; int fbin = 0; int range2 = 0; int lbin = 0; float xVal = 0.0; if(significance){ range1 = -10; range2 = 50; fbin = -10; lbin = 50; xVal = 11.0; }else{ range1 = -1; range2 = 3; fbin = -5; lbin = 10; xVal = 0.5; } float lCut=-10.0; TLegend *leg = new TLegend(0.38,0.5,0.87,0.75); if (isHI) leg->SetHeader("PYTHIA: PbPb #sqrt{s_{NN}} = 5.02 TeV"); else leg->SetHeader("PYTHIA: pp #sqrt{s} = 5.02 TeV"); leg->SetFillStyle(0); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetMargin(0.15); leg->SetTextSize(0.032); leg->SetTextColor(2); TCut defaultCut = NULL; // TCut defaultCut = "Reco_QQ_sign==0&&Gen_QQ_4mom.M()>3.09&&Gen_QQ_4mom.M()<3.10&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctauTrue>-10"; defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctau>-500&&Reco_QQ_ctauTrue>-10"; if(significance) defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau>-500&&Reco_QQ_ctauErr>-500&&Reco_QQ_ctauTrue>-10"; if(is3D){ defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauTrue3D>-10"; if(significance) defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauErr3D>-500&&Reco_QQ_ctauTrue3D>-10"; } TCut ptCut = Form("Reco_QQ_4mom.Pt()>%3.1f&&Reco_QQ_4mom.Pt()<%3.1f",ptmin,ptmax); TCut rapCut; if (absRapidity) rapCut = Form("abs(Reco_QQ_4mom.Rapidity())>%3.1f&&abs(Reco_QQ_4mom.Rapidity())<%3.1f",ymin,ymax); else rapCut = Form("Reco_QQ_4mom.Rapidity()>%3.1f&&Reco_QQ_4mom.Rapidity()<%3.1f",ymin,ymax); TCut centCut; if (isHI) centCut = Form("Centrality>=%d&&Centrality<%d",centmin,centmax); // new Acceptance TCut IsPlAccept = "(abs(Reco_QQ_mupl_4mom->Eta()) < 2.4 && ( (abs(Reco_QQ_mupl_4mom->Eta()) < 1.2 && Reco_QQ_mupl_4mom->Pt() >= 3.5 ) || (1.2 <= abs(Reco_QQ_mupl_4mom->Eta()) && abs(Reco_QQ_mupl_4mom->Eta()) < 2.1 && Reco_QQ_mupl_4mom->Pt() >= 5.77-1.89*abs(Reco_QQ_mupl_4mom->Eta() )) || (2.1 <= abs(Reco_QQ_mupl_4mom->Eta()) && Reco_QQ_mupl_4mom->Pt() >= 1.8 )))"; TCut IsMiAccept = "(abs(Reco_QQ_mumi_4mom->Eta()) < 2.4 && ( (abs(Reco_QQ_mumi_4mom->Eta()) < 1.2 && Reco_QQ_mumi_4mom->Pt() >= 3.5 ) || (1.2 <= abs(Reco_QQ_mumi_4mom->Eta()) && abs(Reco_QQ_mumi_4mom->Eta()) < 2.1 && Reco_QQ_mumi_4mom->Pt() >= 5.77-1.89*abs(Reco_QQ_mumi_4mom->Eta() )) || (2.1 <= abs(Reco_QQ_mumi_4mom->Eta()) && Reco_QQ_mumi_4mom->Pt() >= 1.8 )))"; TCut MuPlID = "((Reco_QQ_mupl_isGoodMuon==1) && Reco_QQ_mupl_nTrkWMea> 5 && Reco_QQ_mupl_nPixWMea > 0 && TMath::Abs(Reco_QQ_mupl_dxy) < 0.3 && TMath::Abs(Reco_QQ_mupl_dz) < 20 && Reco_QQ_VtxProb > 0.01 )"; TCut MuMiID = "((Reco_QQ_mumi_isGoodMuon==1) && Reco_QQ_mumi_nTrkWMea> 5 && Reco_QQ_mumi_nPixWMea > 0 && TMath::Abs(Reco_QQ_mumi_dxy) < 0.3 && TMath::Abs(Reco_QQ_mumi_dz) < 20 && Reco_QQ_VtxProb > 0.01 )"; unsigned int trigBit; if (isHI) trigBit=1; // DoubleMu0_HighQ else trigBit=1; // DoubleMu0_HighQ TCut trigCut = Form("(HLTriggers&%u)==%u&&(Reco_QQ_trig&%u)==%u",trigBit,trigBit,trigBit,trigBit); TString fname; TString fnamepng; TString outfname; TString plotDir; if(!is3D){plotDir = "Plots/2015";} if(!is3D && significance){plotDir = "Plots/2015/significance";} if(is3D){plotDir = "Plots/2015/3D";} if(is3D && Binning){plotDir = "Plots/2015/3D/Binning";} if(is3D && ctauFit){plotDir = "Plots/2015/3D/ctauFit";} if(is3D && significance){plotDir = "Plots/2015/3D/significance";} if (isHI) { if(Prompt){ fname = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.pdf",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); fnamepng = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.png",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); outfname = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.root",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); } if(nonPrompt){ fname = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.pdf",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); fnamepng = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.png",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); outfname = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.root",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0)); } } else { if(Prompt){ fname = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.pdf",efficiency,ymin,ymax,ptmin,ptmax); fnamepng = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.png",efficiency,ymin,ymax,ptmin,ptmax); outfname = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.root",efficiency,ymin,ymax,ptmin,ptmax); } if(nonPrompt){ fname = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.pdf",efficiency,ymin,ymax,ptmin,ptmax); fnamepng = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.png",efficiency,ymin,ymax,ptmin,ptmax); outfname = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.root",efficiency,ymin,ymax,ptmin,ptmax); } } std::cout << fname << std::endl; std::cout << "default: " << defaultCut.GetTitle() << std::endl; std::cout << "pt cut: " << ptCut.GetTitle() << std::endl; std::cout << "rapidity cut: " << rapCut.GetTitle() << std::endl; std::cout << "centrality cut: " << centCut.GetTitle() << std::endl; std::cout << "trigger bit: " << trigCut.GetTitle() << std::endl; TLatex *lpt; if (ptmin==0.0) lpt = new TLatex(0.38,0.845,Form("p_{T} < %3.1f GeV/c",ptmax)); else{ lpt = new TLatex(0.38,0.845,Form("%3.1f < p_{T} < %3.1f GeV/c",ptmin,ptmax)); lpt->SetTextSize(0.033); } TLatex *lrap; if (absRapidity){ if (ymin==0.0){ lrap = new TLatex(0.38,0.77,Form("|y| < %3.1f",ymax)); lrap->SetTextSize(0.033); } else{ lrap = new TLatex(0.38,0.77,Form("%3.1f < |y| < %3.1f",ymin,ymax)); lrap->SetTextSize(0.033); } } else { if (ymin==0.0) lrap = new TLatex(0.38,0.77,Form("y < %3.1f",ymax)); else lrap = new TLatex(0.38,0.77,Form("%3.1f < y < %3.1f",ymin,ymax)); } lpt->SetNDC(kTRUE); lrap->SetNDC(kTRUE); TLatex *lcent = NULL; if (isHI) { lcent = new TLatex(0.38,0.69,Form("Cent. %d-%d%%",int(centmin/2.0),int(centmax/2.0))); lcent->SetTextSize(0.033); lcent->SetNDC(kTRUE); } TChain *iTree = NULL; iTree = new TChain("hionia/myTree"); if (isHI) { if(Prompt) { iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_00_03_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_03_06_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_06_09_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_09_12_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_12_15_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_15_30_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_30_Inf_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); } if(nonPrompt) { iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_00_03_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_03_06_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_06_09_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_09_12_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_12_15_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_15_30_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); //iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_30_Inf_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root"); } } else{ if(Prompt) iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/pp/OniaTree_JpsiMM_5p02TeV_TuneCUETP8M1_HINppWinter16DR-75X_mcRun2_asymptotic_ppAt5TeV_v3-v1.root"); if(nonPrompt) iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/pp/OniaTree_BJpsiMM_5p02TeV_TuneCUETP8M1_HINppWinter16DR-75X_mcRun2_asymptotic_ppAt5TeV_v3-v1.root"); } Float_t muPlPt; Float_t muMiPt; Float_t muPlEta; Float_t muMiEta; Float_t QQctau3D; Float_t QQctau3DErr; double invariantMass; double JpsiPt; double JpsiRap; double vProb; float muPlDxy; float muPlDz; int muPlNhits; int muPlNPxlLayers; int muPlNTrkLayers; float muPlInnerChi; float muPlGlobalChi; int muPlNMuonhits; bool muPlGoodMu; bool muPlTrkArb; bool muPlTMOneStaTight; bool muPlHighPurity; float muMiDxy; float muMiDz; int muMiNhits; int muMiNPxlLayers; int muMiNTrkLayers; float muMiInnerChi; float muMiGlobalChi; int muMiNMuonhits; bool muMiGoodMu; bool muMiTrkArb; bool muMiTMOneStaTight; bool muMiHighPurity; int nx = 14, ny = 15000; //double xBins[22] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,30.0}; //19 double xBins[15] = {3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,15.0,18.0,22.0,30.0}; //19 //double xBins[4] = {3.0,6.5,12.0,30.0}; //19 //double xBins[6] = {6.5,9.0,12.0,15.0,20.0,30.0}; //19 //double xBins[13] = {6.5,7.0,8.0,9.0,10.0,11.0,12.0,13.0,15.0,18.0,21.0,24.0,30.0}; //13 //double xBins[8] = {6.0,9.0,12.0,15.0,18.0,21.0,24.0,30.0}; //19 //TH2D *hPR2D = new TH2D("hPR2D","hPR2D",nx,xBins,ny,-5.0,10.0); //TH1F *hPR = new TH1F("hPR","hPR;Inv_mass",100,-2.5,3.2); TH1F *hPR = new TH1F("hPR","hPR;p_{T}",nx,xBins); //TH1F *hPR = new TH1F("hPR","hPR;l_{J/#psi} (mm);counts",1500,-5,10); hPR->Sumw2(); hPR->SetLineColor(1); //TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;Inv_mass",100,-2.8,3.2); TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;p_{T}",nx,xBins); //TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;l_{J/#psi} (mm);counts",1500,-5,10); hPRfunc->Sumw2(); hPRfunc->SetLineColor(2); //TH1F* hPRCut = (TH1F*) hPR->Clone("hPRCut"); TFile *Fitfile = new TFile("Plots/2015/3D/ctauFit/Jpsi_pp_eff_0.9_Rap_1.6-2.4_Pt_3.0-30.0.root"); TGraph *FitGr = (TGraph*)Fitfile->Get("Graph"); TF1 *func1 = (TF1*)FitGr->GetFunction("FitFn"); new TCanvas; TAxis *XaxctauFW = FitGr->GetXaxis(); XaxctauFW->SetLimits(0.0,30.0); TAxis *YaxctauFW = FitGr->GetYaxis(); YaxctauFW->SetLimits(0.0,0.1); FitGr->GetXaxis()->SetRangeUser(0.0,30.0); FitGr->GetYaxis()->SetRangeUser(0.0,0.1); //FitGr->Draw("AP"); //FitGr->Draw(); func1->Draw(); initOniaTree(iTree); Long64_t nentries = iTree->GetEntries(); nentries = 500000; cout<<"Total Entries in data Tree "<<" "<<nentries<< "====="<<endl; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { nb = iTree->GetEntry(jentry); for (int iQQ=0; iQQ<Reco_QQ_size; iQQ++) { TLorentzVector *qq4mom = (TLorentzVector*) Reco_QQ_4mom->At(iQQ); TLorentzVector *qq4mupl = (TLorentzVector*) Reco_QQ_mupl_4mom->At(iQQ); TLorentzVector *qq4mumi = (TLorentzVector*) Reco_QQ_mumi_4mom->At(iQQ); invariantMass = qq4mom->M(); JpsiPt = qq4mom->Pt(); JpsiRap = qq4mom->Rapidity(); muPlPt = qq4mupl->Pt(); muMiPt = qq4mumi->Pt(); muPlEta = qq4mupl->Eta(); muMiEta = qq4mumi->Eta(); QQctau3D = Reco_QQ_ctau3D[iQQ]; //QQctauTrue3D = Reco_QQ_ctauTrue3D[iQQ]; vProb = Reco_QQ_VtxProb[iQQ]; muPlDxy=Reco_QQ_mupl_dxy[iQQ]; muPlDz=Reco_QQ_mupl_dz[iQQ]; muPlNPxlLayers=Reco_QQ_mupl_nPixWMea[iQQ]; muPlNTrkLayers=Reco_QQ_mupl_nTrkWMea[iQQ]; muPlTMOneStaTight=Reco_QQ_mupl_TMOneStaTight[iQQ]; muPlGoodMu = Reco_QQ_mupl_isGoodMuon[iQQ]; muPlHighPurity = Reco_QQ_mupl_highPurity[iQQ]; muMiDxy=Reco_QQ_mumi_dxy[iQQ]; muMiDz=Reco_QQ_mumi_dz[iQQ]; muMiNPxlLayers=Reco_QQ_mumi_nPixWMea[iQQ]; muMiNTrkLayers=Reco_QQ_mumi_nTrkWMea[iQQ]; muMiTMOneStaTight=Reco_QQ_mumi_TMOneStaTight[iQQ]; muMiGoodMu = Reco_QQ_mumi_isGoodMuon[iQQ]; muMiHighPurity = Reco_QQ_mumi_highPurity[iQQ]; bool defaultpass =0, ptpass =0, rappass =0, PosPass=0, NegPass=0, AllCut=0 ,PosIn=0, NegIn=0,TriggerPass=0; //if(Reco_QQ_sign[iQQ]==0 && invariantMass>2.85 && invariantMass<3.25 && Reco_QQ_ctau3D[iQQ]>-500 && Reco_QQ_ctauTrue3D[iQQ]>-10) {defaultpass =1;} if(Reco_QQ_sign[iQQ]==0 && invariantMass>2.85 && invariantMass<3.25 ) {defaultpass =1;} if(!defaultpass) continue; if(JpsiPt>ptmin && JpsiPt<ptmax) {ptpass =1;} if( fabs(JpsiRap)>ymin && fabs(JpsiRap) <ymax ) {rappass =1;} if(!ptpass) continue; if(!rappass) continue; //centCut = Form("Centrality>=%d&&Centrality<%d",centmin,centmax); if( (HLTriggers&(ULong64_t)pow(2,0))==pow(2,0) && (Reco_QQ_trig[iQQ]&(ULong64_t)pow(2,0))==pow(2,0) ) {TriggerPass =1;} if (fabs(muPlEta) < 2.4 && ( (fabs(muPlEta) < 1.2 && muPlPt >= 3.5 ) || (1.2 <= fabs(muPlEta) && fabs(muPlEta) < 2.1 && muPlPt >= 5.77-1.89*fabs(muPlEta )) || (2.1 <= fabs(muPlEta) && muPlPt >= 1.8 )) ) {PosIn =1;} if(fabs(muMiEta) < 2.4 && ( (fabs(muMiEta) < 1.2 && muMiPt >= 3.5 ) || (1.2 <= fabs(muMiEta) && fabs(muMiEta) < 2.1 && muMiPt >= 5.77-1.89*fabs(muMiEta )) || (2.1 <= fabs(muMiEta) && muMiPt >= 1.8 )) ) {NegIn =1;} if( (muPlGoodMu==1) && muPlNTrkLayers> 5 && muPlNPxlLayers > 0 && TMath::Abs(muPlDxy) < 0.3 && TMath::Abs(muPlDz) < 20 && vProb > 0.01){PosPass=1;} if( (muMiGoodMu==1) && muMiNTrkLayers> 5 && muMiNPxlLayers > 0 && TMath::Abs(muMiDxy) < 0.3 && TMath::Abs(muMiDz) < 20 ){NegPass=1;} //if((Reco_QQ_mupl_isGoodMuon==1) && Reco_QQ_mupl_nTrkWMea> 5 && Reco_QQ_mupl_nPixWMea > 0 && TMath::fabs(Reco_QQ_mupl_dxy) < 0.3 && TMath::fabs(Reco_QQ_mupl_dz) < 20 && Reco_QQ_VtxProb > 0.01 ) {PosPass =1;} //if((Reco_QQ_mumi_isGoodMuon==1) && Reco_QQ_mumi_nTrkWMea> 5 && Reco_QQ_mumi_nPixWMea > 0 && TMath::fabs(Reco_QQ_mumi_dxy) < 0.3 && TMath::fabs(Reco_QQ_mumi_dz) < 20 && Reco_QQ_VtxProb > 0.01 ) {NegPass =1;} if(TriggerPass &&PosIn && NegIn && PosPass && NegPass) {AllCut = 1;} if(!AllCut) continue; //hPR->Fill(QQctau3D); hPR->Fill(JpsiPt); //for pp fwdrap: cut.dMuon.ctauCut = "( ctau < (0.0128 + (0.288/pt)) )"; //for pbpb fwdrap: cut.dMuon.ctauCut = "( ctau < (0.0147 + (0.279/pt)) )"; //for pp midrap: cut.dMuon.ctauCut = "( ctau < (0.0097 + (0.249/pt)) )"; //for pbpb midrap: cut.dMuon.ctauCut = "( ctau < (0.0134 + (0.216/pt)) )"; if( QQctau3D < (0.0128 + (0.288/JpsiPt) ) ) {hPRfunc->Fill(JpsiPt);} } } //TH1F* ratio = (TH1F*)hPR->Clone(); //ratio->Divide(hPRfunc); TH1F* ratio = (TH1F*)hPRfunc->Clone(); ratio->Divide(hPR); ratio->SetStats(0); //gStyle->SetFitFormat("1.3f"); TCanvas *rt = new TCanvas(); gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridy(); ratio->SetMarkerColor(kGreen+3); ratio->SetLineColor(0); ratio->SetMarkerStyle(29); ratio->SetMarkerSize(1.3); XaxctauFW = ratio->GetXaxis(); XaxctauFW->SetLimits(0.0,30.0); YaxctauFW = ratio->GetYaxis(); YaxctauFW->SetLimits(0.5,1.5); ratio->GetXaxis()->SetRangeUser(0.0,30.0); ratio->GetYaxis()->SetRangeUser(0.5,1.5); ratio->Draw(); //*/ lpt->Draw(); lrap->Draw(); leg->Draw(); if (isHI) lcent->Draw(); if (savePlot) { rt->SaveAs(plotDir+fname); rt->SaveAs(plotDir+fnamepng); } return; /* //TH1D *ctauMid_pT = new TH1D("ctauMid_pT","ctauMid_pT",90,0,30); //TH1D *ctauFW_pT = new TH1D("ctauFW_pT","ctauFW_pT",90,0,30); //double ctauFrw[5] = {0.04,0.03,0.02,0.02,0.01}; double ctauFrw[4] = {0.07,0.04,0.03}; double ctauMd[6] = {0.04,0.03,0.02,0.02,0.01}; double Fbins[4] = {3,6.5,12.0,30.0}; double Mbins[6] = {6.5,9.0,12.0,15.0,20.0,30.0}; double x1bins[4] = {0.0}; double x2bins[6] = {0.0}; for(int i=0; i<3; i++){ x1bins[i] = (Fbins[i] + Fbins[i+1])/2.0; cout<<x1bins[i]<<endl; //ctauFW_pT->SetBinContent(x1bins[i], ctauFrw[i-1]); } for(int i=0; i<5; i++){ x2bins[i] = (Mbins[i] + Mbins[i+1])/2.0; //ctauMid_pT->SetBinContent(x2bins[i], ctauMd[i]); } new TCanvas; gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridy(); TGraph *ctauFW_pT = new TGraph(3,x1bins,ctauFrw); TF1 *FitFn = new TF1("FitFn",Pol2,0.0,30.0,3); FitFn->SetParNames("C","a","b"); FitFn->SetLineWidth(2.0); FitFn->SetLineColor(2); ctauFW_pT->Fit("FitFn","", "",3.0,30.0); ctauFW_pT->SetLineColor(2); ctauFW_pT->SetLineWidth(3); ctauFW_pT->SetMarkerSize(1.5); ctauFW_pT->GetYaxis()->SetTitle("c#tau"); ctauFW_pT->GetXaxis()->SetTitle("p_{T} bin"); TAxis *XaxctauFW = ctauFW_pT->GetXaxis(); XaxctauFW->SetLimits(0.0,30.0); TAxis *YaxctauFW = ctauFW_pT->GetYaxis(); YaxctauFW->SetLimits(0.0,0.1); ctauFW_pT->GetXaxis()->SetRangeUser(0.0,30.0); ctauFW_pT->GetYaxis()->SetRangeUser(0.0,0.1); ctauFW_pT->Draw("AP*"); new TCanvas; gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridy(); TF1 *FitFn2 = new TF1("FitFn2",Exp,0.0,30.0,2); TGraph *ctauMid_pT = new TGraph(5,x2bins,ctauMd); ctauMid_pT->SetLineColor(2); ctauMid_pT->SetLineWidth(3); ctauMid_pT->SetMarkerSize(1.5); ctauMid_pT->GetYaxis()->SetTitle("c#tau"); ctauMid_pT->GetXaxis()->SetTitle("p_{T} bin"); ctauMid_pT->Fit("FitFn2","", "",3.0,30.0); FitFn2->SetParNames("C1","n"); TAxis *XaxctauMid = ctauMid_pT->GetXaxis(); XaxctauMid->SetLimits(0.0,30.0); TAxis *YaxctauMid = ctauMid_pT->GetYaxis(); YaxctauMid->SetLimits(0.0,0.1); ctauMid_pT->GetXaxis()->SetRangeUser(0.0,30.0); ctauMid_pT->GetYaxis()->SetRangeUser(0.0,0.1); ctauMid_pT->Draw("AP*"); TLatex *t = new TLatex(); t->SetNDC(); t->SetTextAlign(12);t->SetTextColor(1); t->SetTextSize(0.03); //t->DrawLatex(0.135,0.21," 10 pp 6.5-30 0.0-1.6"); //lh->Draw("same"); TF1 *myfunc1=ctauFW_pT->GetFunction("FitFn"); TF1 *myfunc2=ctauMid_pT->GetFunction("FitFn2"); TH1F *funHist = new TH1F("funHist","funHist",30,0.0,30.0); TH1F *funHist2 = new TH1F("funHist2","funHist2",30,0.0,30.0); funHist->Eval(myfunc1); funHist2->Eval(myfunc2); //funHist = myfunc->GetHistogram(); //root > TH1F h("h","",100,0,10); //root > h.Eval(f1); cout<<"funHist:Entries "<<funHist->GetEntries()<<endl; for(int i=1;i<=funHist->GetNbinsX();++i) { cout<<"bin:pT "<<i<<"ctau: "<<funHist->GetBinContent(i)<<endl<<endl; } for(int i=1;i<=funHist2->GetNbinsX();++i) { cout<<"bin:pT "<<i<<"ctau: "<<funHist2->GetBinContent(i)<<endl<<endl; } new TCanvas; gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridy(); TAxis *XaxHistMid = funHist->GetXaxis(); XaxHistMid->SetLimits(0.0,30.0); TAxis *YaxHistMid = funHist->GetYaxis(); YaxHistMid->SetLimits(0.0,0.1); funHist->GetXaxis()->SetRangeUser(0.0,30.0); funHist->GetYaxis()->SetRangeUser(0.0,0.1); funHist->Draw(); funHist2->SetLineColor(2); funHist2->Draw("same"); //gPad->SaveAs("Plots/ctauMid.png"); //gPad->SaveAs("plots/ctauMid.pdf"); */ }
void draw_qa_sim(TString inFileName="sim.qa.root") { gStyle->SetPalette(1); TFile* inFile = new TFile(inFileName.Data()); TH1F* fhNofEvents = (TH1F*)inFile->Get("STSSimulationQA/hNofEvents"); TH1F* fhNofStsStations = (TH1F*)inFile->Get("STSSimulationQA/hNofStsStations"); Int_t nofStations = fhNofStsStations->GetBinContent(1); Int_t fShowStation = 4; Int_t fNEvents = fhNofEvents->GetBinContent(1); TH1F* fhMomAll = (TH1F*)inFile->Get("STSSimulationQA/hMomAll"); TH1F* fhMomRec = (TH1F*)inFile->Get("STSSimulationQA/hMomRec"); TH2F* fhYPtMapRec = (TH2F*)inFile->Get("STSSimulationQA/hYPtMapRec"); TH1F* fhStsPointsRec = (TH1F*)inFile->Get("STSSimulationQA/hStsPointsRec"); TH3F* fhStsPointsPosition = (TH3F*)inFile->Get("STSSimulationQA/hStsPointsPosition"); TH2F* fhStationPoints[10]; for ( Int_t ist = 0 ; ist < nofStations ; ist++ ) fhStationPoints[ist] = (TH2F*)inFile->Get(Form("STSSimulationQA/hStationPoints%i",ist+1)); Double_t tracksPerEvent = (Double_t)(fhMomAll->GetEntries())/((Double_t)fNEvents); Double_t pointsPerEvent = (Double_t)(fhStsPointsPosition->GetEntries())/((Double_t)fNEvents); TCanvas* simCanvas = new TCanvas("StsSim","Sts simulation",10,10,600,900); TPad* simPad[10]; simPad[0] = new TPad("titlePad", "Title pad" ,0.01,0.91,0.99,0.99); simPad[1] = new TPad("momentumPad","Momentum pad" ,0.01,0.46,0.49,0.89); simPad[2] = new TPad("yptPad", "y-pt pad" ,0.01,0.01,0.49,0.44); simPad[3] = new TPad("pointPad", "Points per track pad" ,0.51,0.61,0.99,0.89); simPad[4] = new TPad("stationPad", "Points on 1st station pad",0.51,0.31,0.99,0.59); simPad[5] = new TPad("printoutPad","Print information pad ",0.51,0.01,0.99,0.29); simPad[1]->SetLogy(); for ( Int_t ipad = 0 ; ipad < 6 ; ipad++ ) { simPad[ipad]->SetFillColor(0); simPad[ipad]->SetBorderMode(0); simPad[ipad]->Draw(); } simPad[0]->cd(); TLegend* brp = new TLegend(0.1,0.1,0.9,0.9,"STS simulation"); brp->SetTextAlign(22); brp->SetTextSize(0.6); brp->SetTextColor(1); brp->SetBorderSize(0); brp->SetFillColor(0); brp->Draw(); simPad[0]->Update(); simPad[1]->cd(); // fhMomAll->Draw(); fhMomRec->Draw(); simPad[1]->Update(); simPad[2]->cd(); fhYPtMapRec->Draw("colz"); simPad[2]->Update(); simPad[3]->cd(); fhStsPointsRec->Draw(); simPad[3]->Update(); simPad[4]->cd(); fhStationPoints[0]->Draw(); fhStationPoints[0]->Draw("colz"); simPad[4]->Update(); simPad[5]->cd(); TPaveText* printoutPave = new TPaveText(0.1,0.1,0.9,0.9); printoutPave->SetTextAlign(22); printoutPave->SetTextSize(0.1); printoutPave->SetTextColor(1); printoutPave->SetBorderSize(0); printoutPave->SetFillColor(0); printoutPave->AddText(Form("%i events",fNEvents)); printoutPave->AddText(Form("tracks/event = %3.2f",tracksPerEvent)); printoutPave->AddText(Form("points/event = %3.2f",pointsPerEvent)); simPad[5]->Clear(); printoutPave->Draw(); simPad[5]->Update(); }
void drawSignalBGData( const std::string& dirName, const std::string& channel, const std::string& var, const std::string& varName, const std::string& units, int nBins, float xMin, float xMax, TTree* tree_sig, TTree* tree_bg, TTree* tree_data, const std::string& fullSelection, const std::string& fullSelection_sidebands, const std::string& suffix ) { DrawBase* db = new DrawBase("sigbfdata" ); TH1D* h1_data = new TH1D("data", "", nBins, xMin, xMax ); TH1D* h1_sig = new TH1D("sig", "", nBins, xMin, xMax ); TH1D* h1_bg = new TH1D("bg", "", nBins, xMin, xMax ); h1_data->Sumw2(); h1_sig->Sumw2(); h1_bg->Sumw2(); h1_sig->SetFillColor(46); h1_bg->SetFillColor(38); h1_sig->SetLineColor(46); h1_bg->SetLineColor(38); h1_sig->SetFillStyle(3004); h1_bg->SetFillStyle(3005); if( BLINDED ) tree_data->Project( "data", var.c_str(), fullSelection_sidebands.c_str() ); else tree_data->Project( "data", var.c_str(), fullSelection.c_str() ); tree_sig->Project( "sig", var.c_str(), fullSelection.c_str() ); tree_bg ->Project( "bg", var.c_str(), fullSelection.c_str() ); float data_integral = h1_data->Integral(); if( data_integral < 2 ) data_integral=3.; h1_sig->Scale( data_integral/h1_sig->Integral() ); h1_bg->Scale( data_integral/h1_bg->Integral() ); TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false ); gr_data->SetMarkerStyle(20); gr_data->SetMarkerSize(1.3); TString category_tstr(channel); bool isLeptonic = category_tstr.Contains("leptonic"); std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel"; TLegend* legend = new TLegend( 0.55, 0.66, 0.9, 0.92, channelName_legend.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); if( useCS ) legend->AddEntry( gr_data, "Data Control Sample", "P" ); else { if( BLINDED ) { legend->AddEntry( gr_data, "Sidebands Data", "P" ); } else { legend->AddEntry( gr_data, "Sidebands Data", "P" ); } } legend->AddEntry( h1_sig, "tHq (125)", "F" ); legend->AddEntry( h1_bg, "ttH (125)", "F" ); float yMax = 0.; float yMax_data = h1_data->GetMaximum(); if( yMax_data>0. ) { if( yMax_data < 1.5 ) yMax=3.5; else if( yMax_data < 2.5 ) yMax=6.; else yMax=yMax_data*2.; } else { float yMax_mc = h1_sig->GetMaximum()*1.2; yMax = 1.8*yMax_mc; } TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax); std::string xTitle = varName; if( units!="" ) xTitle = xTitle + " [" + units + "]"; h2_axes->SetXTitle(xTitle.c_str()); h2_axes->SetYTitle( "Arbitrary Units" ); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); h1_bg->Draw("h same"); h1_sig->Draw("h same"); gr_data->Draw("p same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + channel + "/" + var + "_SignalBGData_" + channel; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete h1_data; delete h1_sig; delete h1_bg; delete h2_axes; delete legend; delete c1; }
void drawMassPlot( const std::string& dirName, const std::string& category, TH1D* h1_data, TH1D* h1_thq, TH1D* h1_ggh, TH1D* h1_vbf, TH1D* h1_wzh, TH1D* h1_tth, const std::string& suffix ) { DrawBase* db = new DrawBase("mgg"); db->set_lumi(19700.); TFile* dummyFile = TFile::Open("dummy.root", "recreate"); db->add_dataFile(dummyFile, "Data"); TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false ); gr_data->SetMarkerStyle(20); gr_data->SetMarkerSize(1.3); h1_thq->SetFillColor(kWhite); h1_tth->SetFillColor(kGray); h1_wzh->SetFillColor(28); h1_vbf->SetFillColor(90); h1_ggh->SetFillColor(46); h1_thq->SetLineColor(kBlack); h1_tth->SetLineColor(kBlack); h1_wzh->SetLineColor(kBlack); h1_vbf->SetLineColor(kBlack); h1_ggh->SetLineColor(kBlack); TString category_tstr(category); bool isLeptonic = category_tstr.Contains("leptonic"); THStack stack; if( !isLeptonic ) { stack.Add(h1_ggh); stack.Add(h1_vbf); } stack.Add(h1_wzh); stack.Add(h1_tth); stack.Add(h1_thq); std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel"; float yMin_leg = (isLeptonic) ? 0.9-4.*0.07 : 0.9-6.*0.07; TLegend* legend = new TLegend( 0.62, yMin_leg, 0.9, 0.92, channelName_legend.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); if( useCS ) legend->AddEntry( gr_data, "Data CS", "P" ); else legend->AddEntry( gr_data, "Data", "P" ); legend->AddEntry( h1_thq, "tHq (Ct = -1)", "F" ); legend->AddEntry( h1_tth, "ttH (125)", "F" ); legend->AddEntry( h1_wzh, "VH (125)", "F" ); if( !isLeptonic ) { legend->AddEntry( h1_vbf, "VBF H (125)", "F" ); legend->AddEntry( h1_ggh, "ggF H (125)", "F" ); } float yMax = 0.; float yMax_data = h1_data->GetMaximum(); if( yMax_data>0. ) { if( yMax_data < 1.5 ) yMax=3.5; else if( yMax_data < 2.5 ) yMax=6.; else yMax=yMax_data*2.; } else { float yMax_mc = h1_thq->GetMaximum()*1.2; yMax = 1.8*yMax_mc; } TH2D* h2_axes = new TH2D( "axes", "", 10, 100., 180., 10, 0., yMax); h2_axes->SetXTitle( "Diphoton Mass [GeV]"); h2_axes->SetYTitle( "Events / (1 GeV)"); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); stack.Draw("histo same"); if( BLINDED ) { TLine* lineBlind_low = new TLine( 115., 0., 115., yMax ); TLine* lineBlind_hi = new TLine( 135., 0., 135., yMax ); lineBlind_low->SetLineColor(46); lineBlind_hi ->SetLineColor(46); lineBlind_low->SetLineStyle(2); lineBlind_hi ->SetLineStyle(2); lineBlind_low->SetLineWidth(2); lineBlind_hi ->SetLineWidth(2); lineBlind_low->Draw("same"); lineBlind_hi ->Draw("same"); } gr_data->Draw("p same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + category + "/mggPlot_" + category; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete c1; delete h2_axes; delete legend; }
void compareSystVariable( const std::string& dirName, const std::string& channel, const std::string& dataset, TTree* tree_central, TFile* file_systUp, TFile* file_systDown, const std::string& fullSelection, const std::string& systName, const std::string& varName, const std::string& axisTitle, const std::string& units, int nBins, float xMin, float xMax, const std::string& suffix) { DrawBase* db = new DrawBase("syst" ); TTree* tree_systUp = (TTree*)file_systUp->Get(dataset.c_str()); TTree* tree_systDown = (file_systDown!=0) ? (TTree*)file_systDown->Get(dataset.c_str()) : 0; TH1D* h1_central = new TH1D("central", "", nBins, xMin, xMax); TH1D* h1_systUp = new TH1D("systUp", "", nBins, xMin, xMax); TH1D* h1_systDown = new TH1D("systDown", "", nBins, xMin, xMax); h1_central->Sumw2(); h1_systUp->Sumw2(); h1_systDown->Sumw2(); tree_central->Project( "central", varName.c_str(), fullSelection.c_str() ); tree_systUp->Project( "systUp", varName.c_str(), fullSelection.c_str() ); if( tree_systDown!=0 ) tree_systDown->Project( "systDown", varName.c_str(), fullSelection.c_str() ); h1_central ->SetLineColor(kBlack); h1_systUp ->SetLineColor(kGreen); h1_systDown->SetLineColor(kRed); h1_central ->SetLineWidth(2); h1_systUp ->SetLineWidth(2); h1_systDown->SetLineWidth(2); //h1_systUp ->SetLineStyle(2); //h1_systDown->SetLineStyle(2); TLegend* legend = new TLegend( 0.6, 0.66, 0.9, 0.92, dataset.c_str() ); legend->SetTextFont(42); legend->SetFillColor(kWhite); legend->SetTextSize(0.038); legend->SetTextColor(kBlack); legend->AddEntry( h1_central, "Central", "L" ); std::string systUp_text = systName + " +1#sigma"; std::string systDown_text = systName + " -1#sigma"; legend->AddEntry( h1_systUp, systUp_text.c_str(), "L" ); if( tree_systDown!=0 ) legend->AddEntry( h1_systDown, systDown_text.c_str(), "L" ); float yMax = 1.6*h1_central->GetMaximum(); TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax); std::string xTitle = axisTitle; if( units!="" ) xTitle = xTitle + " [" + units + "]"; h2_axes->SetXTitle(xTitle.c_str()); h2_axes->SetYTitle( "Events" ); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); TPaveText* labelTop = db->get_labelTop(); h2_axes->Draw(); legend->Draw("same"); labelTop->Draw("same"); h1_central->Draw("h same"); h1_systUp->Draw("h same"); if( tree_systDown!=0 ) h1_systDown->Draw("h same"); gPad->RedrawAxis(); std::string canvasName = dirName + "/" + channel + "/syst" + systName + "_" + varName + "_" + dataset + "_" + channel; if( suffix!="" ) canvasName = canvasName + "_" + suffix; std::string canvasName_eps = canvasName + ".eps"; std::string canvasName_png = canvasName + ".png"; c1->SaveAs(canvasName_eps.c_str()); c1->SaveAs(canvasName_png.c_str()); delete db; delete h1_central; delete h1_systUp; delete h1_systDown; delete h2_axes; delete legend; delete c1; }
// // Principal code segment // void pi0_HadCorrelations_Projections(const int iMultOption = 4, const bool peakRegionFile = true, const bool sideBandFile = false, const bool usePbPbData = false, const bool usepPbData = false, const bool useSimReco = false, const bool useGenEvts = true, const bool useV1V2Fit = true, const bool useV2FitOnly = false) { // // Control Parameter Instructions // iMultOption = 0, 1, 2, 3, 4 controls the track multiplicity selection [120-150, 150-195, 185-220, 220-260, 120-260] // peakRegionFile = true means that the input file inputTrue.root will be used // it is assumed that inputTrue.root is soft-linked to a peak-region output ROOT file from the EDM // this could be either a PbPb, or a pPb, or a pPb simulation ROOT file from the EDM // // sideBandFile = true is the same logic for a side-band output ROOT file from the EDM analyzer // the inputSide.root is to be soft-lined to a side-band output ROOT file from the EDM // // only one of peakRegionFile or sideBandFile can be true // // usePbPbData, usepPbData, useSimReco, or useGenEvts indicate which type of data or MC is being processed // // for the pPb data and the Sim data choices, there are 8 pT bins // for the PbPb data there are 6 pT bins // // // Output results // The macro produces two sets of plots: two-dimensional correlation and Fourier-fitted one-dimension // The macro produces an output text file, either PeakRegion_ijkMultlmn.txt or SideBand_ijkMultlmn.txt // the ijk and lmn are the track multiplicity limits determined by the iOption choice // if(sideBandFile && useGenEvts) { cerr << "\n\n Error in input parameters: cannot have a side-band file for generator events" << endl << endl; return; } int nPtBins = 8; const float _PbPb_ptMin[6] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0}; const float _PbPb_ptMax[6] = {1.0, 1.5, 2.0, 2.5, 3.0, 5.0}; const float _pPb_ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; const float _pPb_ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; float _ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; float _ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; bool goodDataSource = false; char *dataText = new char[200]; if(usePbPbData) { if(usepPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 6; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _PbPb_ptMin[kPt]; _ptMax[kPt] = _PbPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using PbPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS PbPb #sqrt{s_{NN}}=2.76 TeV"); } if(usepPbData) { if(usePbPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using pPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS pPb #sqrt{s_{NN}}=5.0 TeV"); } if(useSimReco) { if(usePbPbData || usepPbData || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using SimData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS RECO pPb #sqrt{s_{NN}}=5.01 TeV"); } if(useGenEvts) { if(usePbPbData || usepPbData || useSimReco) { cerr << "\n Cannot only specify one data source as true" << endl; return; } if(!peakRegionFile) { cerr << "\n The peakRegionFile must be set to true when useGenEvts is true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using GenEvts source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS GEN pPb #sqrt{s_{NN}}=5.01 TeV"); } if(!goodDataSource) { cerr << "\n The data source was not specified" << endl; return; } if(peakRegionFile && sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to true"<< endl; return; } if(!peakRegionFile && !sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to false"<< endl; return; } TCanvas *c1 = new TCanvas("c1","",900,900); Canvas(); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.1); c1->SetLeftMargin(0.1742581); c1->SetRightMargin(0.05); c1->SetTheta(50.61189); c1->SetPhi(40.90062); if(nPtBins == 8) c1->Divide(3,3); if(nPtBins == 6) c1->Divide(3,2); TCanvas *c2 = new TCanvas("c2", "c2",900,900); gStyle->SetOptFit(0); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c2->Range(0,0,1,1); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); //c1->SetLogy(); c2->SetTickx(1); c2->SetTicky(1); c2->SetLeftMargin(0.16); c2->SetRightMargin(0.16); c2->SetTopMargin(0.05); c2->SetBottomMargin(0.13); c2->SetFrameFillStyle(0); c2->SetFrameBorderMode(0); if(nPtBins == 8) c2->Divide(3,3); if(nPtBins == 6) c2->Divide(3,2); TH1::SetDefaultSumw2(); char *inputFileName = new char[200]; if(peakRegionFile) { sprintf(inputFileName, "inputTrue.root"); } if(sideBandFile) { sprintf(inputFileName, "inputSide.root"); } TFile *_fpPbData = new TFile(inputFileName, "r"); if(!_fpPbData) { cerr << "\n Cannot find input file " << inputFileName << endl; return; } else { cout << "\n Found input file " << inputFileName << endl; } TH1F * _hEvent_pPb; double _nEvents_pPb; TH2D *_hSignal_pPb[8]; TH2D *_hBackground_pPb[8]; char *multText = new char[10]; char *eventText = new char[100]; char *signalText = new char[100]; char *bkgText = new char[100]; int lowMultiplicity = 120; int highMultiplicity = 150; char *multiplicityText = new char[200]; bool goodMultOption = false; if(iMultOption == 0) { sprintf(multText, "EcalFlowNtpMult100"); goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 150"); } if(iMultOption == 1) { sprintf(multText, "EcalFlowNtpMult130"); lowMultiplicity = 150; highMultiplicity = 185; goodMultOption = true; sprintf(multiplicityText, "150 #leq N_{track}^{offline} < 185"); } if(iMultOption == 2) { sprintf(multText, "EcalFlowNtpMult160"); lowMultiplicity = 185; highMultiplicity = 220; goodMultOption = true; sprintf(multiplicityText, "185 #leq N_{track}^{offline} < 220"); } if(iMultOption == 3) { sprintf(multText, "EcalFlowNtpMult190"); lowMultiplicity = 220; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "220 #leq N_{track}^{offline} < 260"); } if(iMultOption == 4) { sprintf(multText, "EcalFlowNtp"); lowMultiplicity = 120; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 260"); } if(goodMultOption) { if(!useGenEvts) { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hBackgroundPtBin", multText); } else { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hGenSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hGenBackgroundPtBin", multText); } } else { cerr << "\n Multiplicity option " << iMultOption << " is not valid" << endl; return; } // safety check ofstream myfile; char *myFileName = new char[200]; if(peakRegionFile) { sprintf(myFileName, "PeakRegion_%dMult%d.txt", lowMultiplicity, highMultiplicity); } if(sideBandFile) { sprintf(myFileName, "SideBand_%dMult%d.txt", lowMultiplicity, highMultiplicity); } cout << "\n Opening output text file " << myFileName << endl; myfile.open (myFileName); cout << "\n eventText = " << eventText; cout << "\n signalText= " << signalText; cout << "\n signalText = " << bkgText; cout << endl; char *_SignalHistoName1 = new char[200]; char *_BkgHistoName1 = new char[200]; // // Why are these numbers hard=coded here? // float _SignalFraction[8] = {0.09, 0.23, 0.44, 0.59, 0.66, 0.71, 0.73, 0.74}; _hEvent_pPb = (TH1F*)_fpPbData->Get(eventText); if(!_hEvent_pPb) { cerr << "\n Unable to find hEvent_pPb with name " << eventText << endl; return; } _nEvents_pPb = _hEvent_pPb->Integral(); cout << "\n Number of events _nEvents_pPb = " << _nEvents_pPb << "; setting up 8 histogram names" << endl; for(int iCount=0; iCount<8; ++iCount) { sprintf(_SignalHistoName1, "%s%d", signalText, iCount); sprintf(_BkgHistoName1, "%s%d", bkgText, iCount); cout << " iCount = " << iCount << '\t' << "Signal name = " << _SignalHistoName1<<endl; cout << " iCount = " << iCount << '\t' << "Background name = " << _BkgHistoName1<<endl; _hSignal_pPb[iCount] = (TH2D*)_fpPbData->Get(_SignalHistoName1); if(!_hSignal_pPb[iCount]) { cerr << "\n Unable to find _hSignal_pPb[iCount]" << endl; return; } _hBackground_pPb[iCount] = (TH2D*)_fpPbData->Get(_BkgHistoName1); if(!_hBackground_pPb[iCount]) { cerr << "\n Unable to find _hBackground_pPb[iCount]" << endl; return; } } // loop over 8 histogram bins double _etabinwidth = _hSignal_pPb[0]->GetXaxis()->GetBinWidth(1); double _phibinwidth = _hSignal_pPb[0]->GetYaxis()->GetBinWidth(1); for(long iCount=0; iCount<nPtBins; ++iCount) { _hSignal_pPb[iCount]->Divide(_hBackground_pPb[iCount]); int _x0 = _hBackground_pPb[iCount]->GetXaxis()->FindBin(0.0); int _y0 = _hBackground_pPb[iCount]->GetYaxis()->FindBin(0.0); double _B0 = _hBackground_pPb[iCount]->GetBinContent(_x0,_y0); _hSignal_pPb[iCount]->Scale(_B0/(_nEvents_pPb)); _hSignal_pPb[iCount]->Scale(1.0/_etabinwidth/_phibinwidth); c1->cd(iCount+1); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->SetTitle("#Delta#eta"); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetXaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetXaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetXaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetXaxis()->SetTitleOffset(1.38); _hSignal_pPb[iCount]->GetXaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetTitle("#Delta#phi"); _hSignal_pPb[iCount]->GetYaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetYaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetYaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetYaxis()->SetTitleOffset(1.59); _hSignal_pPb[iCount]->GetYaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetTitle("#frac{1}{N_{trig}} #frac{d^{2}N^{pair}}{d#Delta#etad#Delta#phi}"); _hSignal_pPb[iCount]->GetZaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleOffset(2.33); _hSignal_pPb[iCount]->GetZaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetNdivisions(505); _hSignal_pPb[iCount]->Draw("SURF1"); TLatex * tex = new TLatex(-0.8847018,0.9364877,Form("%5.1f < p_{T} < %5.1f (GeV/c)",_ptMin[iCount],_ptMax[iCount])); tex->SetTextSize(0.06); tex->Draw(); } // loop over 8 histogram bins cout <<"\n Now drawing the projections..." << endl; float etaMin = 2.0; float etaMax = 3.6; TString _Name = "projClone"; TString _Name2 = "_pi0HadProj"; TString _Name4 = "FourierDecompose"; TString _Name1, _Name3, _Name5; TH2D *_projCorrFunc[9]; TH1D * _pi0HadCorrProj[9]; TF1 *_FourierDecompose[9]; const int n = 9; double _Parameter0[n]; double _Par0Error[n]; double _Parameter2[n]; double _Par2Error[n]; double _Ratio[n]; double _Error[n]; for(long iCount=0; iCount<nPtBins; ++iCount) { _Name1 = _Name + iCount; _Name3 = _Name2 + iCount; _Name5 = _Name4 + iCount; _projCorrFunc[iCount] = (TH2D*) _hSignal_pPb[iCount]->Clone(_Name1); Int_t etabin10m=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMin+0.01); Int_t etabin10p=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMax-0.01); _pi0HadCorrProj[iCount] = (TH1D *) _projCorrFunc[iCount]->ProjectionY(_Name3,etabin10m,etabin10p,"e"); _pi0HadCorrProj[iCount]->GetXaxis()->SetRange(8,24); c2->cd(iCount+1); _pi0HadCorrProj[iCount]->SetMarkerColor(4); _pi0HadCorrProj[iCount]->SetMarkerStyle(20); _pi0HadCorrProj[iCount]->SetMarkerSize(1.0); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitle("#Delta#phi"); _pi0HadCorrProj[iCount]->GetXaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleOffset(0.67); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitle("Associated yield"); _pi0HadCorrProj[iCount]->GetYaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleOffset(0.77); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleFont(42); float maximumHistogramValue = _pi0HadCorrProj[iCount]->GetMaximum(); float minimumHistogramValue = _pi0HadCorrProj[iCount]->GetMinimum(); _pi0HadCorrProj[iCount]->SetMaximum(maximumHistogramValue + 0.60*(maximumHistogramValue - minimumHistogramValue)); _pi0HadCorrProj[iCount]->Draw("E1"); (c2->cd(iCount+1))->SetGrid(); if(useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, v1v2Fit, -1.4, 4.88, 3); _FourierDecompose[iCount]->SetParNames("Norm","v1", "v2"); } if(useV2FitOnly) { _FourierDecompose[iCount] = new TF1(_Name5, v2Fit, -1.4, 4.88, 2); _FourierDecompose[iCount]->SetParNames("Norm","v2"); } if(!useV2FitOnly && !useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, Function, -1.4, 4.88, 4); _FourierDecompose[iCount]->SetParNames("Par0","Par1","Par2","Par3"); } _pi0HadCorrProj[iCount]->Fit(_Name5, "", "", -1.4, 4.84); double v1 = 0; double v1Error = 0; double v3 = 0; double v3Error = 0; if(useV1V2Fit) { v1 = ((_FourierDecompose[iCount]->GetParameter(1))/0.232); v1Error = ((_FourierDecompose[iCount]->GetParError(1))/0.232); _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(2))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(2))/0.232; } // using a v1 + v2 fit function if(useV2FitOnly) { _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(1))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(1))/0.232; } // using a pure v2 fit function if(!useV2FitOnly && !useV1V2Fit) { _Parameter0[iCount] = _FourierDecompose[iCount]->GetParameter(0); _Par0Error[iCount] = _FourierDecompose[iCount]->GetParError(0); _Parameter2[iCount] = _FourierDecompose[iCount]->GetParameter(2); _Par2Error[iCount] = _FourierDecompose[iCount]->GetParError(2); v3 = ((_FourierDecompose[iCount]->GetParameter(3))/0.232)/_Parameter0[iCount]; v3Error = ((_FourierDecompose[iCount]->GetParError(3))/0.232)/_Parameter0[iCount]; _Ratio[iCount] = _Parameter2[iCount]/_Parameter0[iCount]; _Ratio[iCount] /= 0.232; // v2 of the EPOS generator charged particles, 0.3 - 3.0 GeV/c, according to Z. Chen (May 4, 2014, K0-short analysis) _Error[iCount] = _Ratio[iCount]*(sqrt((_Par2Error[iCount]/_Parameter2[iCount])*(_Par2Error[iCount]/_Parameter2[iCount]) + (_Par0Error[iCount]/_Parameter0[iCount])*(_Par0Error[iCount]/_Parameter0[iCount]) + (0.0001364/0.08609)*(0.0001364/0.08609))); } // using Monika's fitting function TLegend *legend = new TLegend(0.15, 0.65, 0.88, 0.85); char *legendHeader = new char[200]; sprintf(legendHeader, "%s, %s", dataText, multiplicityText); legend->SetHeader(legendHeader); legend->SetTextSize(0.04); legend->SetTextColor(kBlue); char *ptRangeText = new char[200]; if(sideBandFile) { sprintf(ptRangeText, "Bkg: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } if(peakRegionFile) { sprintf(ptRangeText, "Peak for: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } char *fitResults = new char[200]; if(useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{1} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v1, v1Error); } if(useV2FitOnly) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f (pure v_{2} fit)",_Ratio[iCount], _Error[iCount]); } if(!useV2FitOnly && !useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{3} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v3, v3Error); } legend->AddEntry(_Name5, fitResults, "l"); legend->AddEntry((TObject*)0, ptRangeText, ""); legend->Draw(); } // loop over pT bins cout << "\n Now writing to the output text file " << myFileName << endl; cout << "------------------------****-------------------" << endl; for(long iCount=0; iCount<8; ++iCount) { cout << "Final v2(pi0) ["<< iCount << "] = " << _Ratio[iCount] << '\t' << _Error[iCount] << '\t' << _Error[iCount]/_SignalFraction[iCount] << endl; myfile << _Ratio[iCount] << '\t' << _Error[iCount] << endl; } cout <<"------------------------****-------------------" << endl; myfile.close(); }
void drawCMSresponse() { // New style settings // #include "tdrstyle_mod14.C" setTDRStyle(); // call cmsPrel(iPeriod, iPos); // int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot // iPos=11 : top-left, left-aligned // iPos=33 : top-right, right-aligned // iPos=22 : center, centered // mode generally : // iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right) if (!_jec) { const char *sd = "CondFormats/JetMETObjects/data"; //const char *st = "Winter14_V5_MC"; //const char *st = "Winter14_V8_MC"; // 2012 //const char *st = "Winter14_V8_DATA"; //const char *st = "Summer15_25nsV3_DATA"; //const char *st = "Summer15_25nsV6_DATA"; //const char *st = "Summer15_25nsV7_DATA"; //const char *st = "Fall15_25nsV1_DATA"; //const char *st = "Spring16_25nsV3_MC"; //const char *st = "Summer16_23Sep2016GV3_DATA"; // 2017 //const char *st = "Summer16_03Feb2017G_V3_DATA"; // 2017 03FebV3 const char *st = "Summer16_03Feb2017BCD_V7_DATA"; // 2017 03FebV7 const char *s; //s = Form("%s/%s_L1FastJet_AK5PFchs.txt",sd,st); cout << s << endl; //JetCorrectorParameters *l1 = new JetCorrectorParameters(s); s = Form("%s/%s_L1FastJet_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l1 = new JetCorrectorParameters(s); //s = Form("%s/%s_L2Relative_AK5PFchs.txt",sd,st); cout << s << endl; s = Form("%s/%s_L2Relative_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l2 = new JetCorrectorParameters(s); //s = Form("%s/%s_L3Absolute_AK5PFchs.txt",sd,st); cout << s << endl; s = Form("%s/%s_L3Absolute_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l3 = new JetCorrectorParameters(s); s = Form("%s/%s_L2L3Residual_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l2l3 = new JetCorrectorParameters(s); vector<JetCorrectorParameters> v; v.push_back(l1); v.push_back(*l2); v.push_back(*l3); v.push_back(*l2l3); _jec = new FactorizedJetCorrector(v); } if (!_jecpt) { _jecpt = new TF1("jecpt",fJECPt,0,6500,3); } //double ergs[] = {30, 60, 110, 400, 2000}; //const int ne = sizeof(ergs)/sizeof(ergs[0]); double pts[] = {10, 30, 100, 400, 2000}; const int npt = sizeof(pts)/sizeof(pts[0]); const int neta = 48;//52; const int jeta = TMath::Pi()*0.4*0.4; const int mu = 0; TGraph *gs[npt]; //for (int ie = 0; ie != ne; ++ie) { for (int ipt = 0; ipt != npt; ++ipt) { //double energy = ergs[ie]; double pt = pts[ipt]; TGraph *g = new TGraph(0); gs[ipt] = g; for (int ieta = 0; ieta != neta; ++ieta) { double eta = (ieta+0.5)*0.1; //double pt = energy / cosh(eta); double energy = pt * cosh(eta); if (pt >= 10. && energy < 6500.) { // 13 TeV double jes = getResp(pt, eta, jeta, mu); int n = g->GetN(); g->SetPoint(n, eta, jes); } } // for ie } // for ieta // Draw results //TH1D *h = new TH1D("h",";Jet |#eta|;Simulated jet response",40,0,4.8); //TH1D *h = new TH1D("h",";Jet |#eta|;Data jet response",40,0,4.8); TH1D *h = new TH1D("h",";Jet |#eta|;Data response+offset",40,0,4.8); h->SetMaximum(1.25); h->SetMinimum(0.5); extraText = "Simulation"; //extraText = "Simulation Preliminary"; //extraText = "Preliminary"; lumi_8TeV = ""; lumi_13TeV = ""; //lumi_13TeV = "2.1 fb^{-1}"; //TCanvas *c1 = tdrCanvas("c1",h,2,0,kSquare); TCanvas *c1 = tdrCanvas("c1",h,4,0,kSquare); TLegend *leg1 = tdrLeg(0.25,0.25,0.55,0.30); TLegend *leg2 = tdrLeg(0.25,0.20,0.55,0.25); TLegend *leg3 = tdrLeg(0.25,0.15,0.55,0.20); TLegend *leg4 = tdrLeg(0.55,0.25,0.85,0.30); TLegend *leg5 = tdrLeg(0.55,0.20,0.85,0.25); TLegend *legs[npt] = {leg1, leg2, leg3, leg4, leg5}; int colors[] = {kGreen+2, kBlack, kOrange+1, kBlue, kRed+1}; int markers[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare, kFullTriangleUp}; for (int ipt = 0; ipt != npt; ++ipt) { TGraph *g = gs[ipt]; g->SetMarkerColor(colors[ipt]); g->SetMarkerStyle(markers[ipt]); g->Draw("SAMEP"); //TLegend *leg = (ie<3 ? leg1 : leg2); TLegend *leg = legs[ipt]; leg->SetTextColor(colors[ipt]); //leg->AddEntry(g, Form("E = %1.0f GeV",ergs[ie]), "P"); leg->AddEntry(g, Form("p_{T} = %1.0f GeV",pts[ipt]), "P"); } TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); TLine *l = new TLine(); l->DrawLine(1.3,0.7,1.3,1.1); l->DrawLine(2.5,0.7,2.5,1.1); l->DrawLine(3.0,0.7,3.0,1.1); l->DrawLine(4.5,0.7,4.5,1.1); l->SetLineStyle(kDashed); l->DrawLine(3.2,0.7,3.2,1.1); //tex->DrawLatex(0.23,0.86,"2012 JES: Anti-k_{t} R = 0.5, PF+CHS"); //tex->DrawLatex(0.30,0.86,"53X JES: Anti-k_{t} R = 0.5, PF+CHS"); //tex->DrawLatex(0.30,0.86,"74X JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.30,0.86,"76X JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.23,0.86,"2016 JES: Anti-k_{T} R=0.4, PF+CHS"); tex->DrawLatex(0.23,0.86,"2017 JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.23,0.86,"2017 03FebV3: Anti-k_{t} R = 0.4, PF+CHS"); tex->DrawLatex(0.19,0.78,"Barrel"); tex->DrawLatex(0.47,0.78,"Endcap"); //0.42 tex->DrawLatex(0.73,0.78,"Forward"); tex->DrawLatex(0.21,0.73,"BB"); tex->DrawLatex(0.43,0.73,"EC1"); tex->DrawLatex(0.57,0.73,"EC2"); tex->DrawLatex(0.77,0.73,"HF"); c1->SaveAs("pdf/drawCMSresponse.pdf"); } // drawCMSresponse
void V2_gap0_gap1() { const int NCentBin=15; const int NCentBin24=24; double pt[NCentBin]; double pta[NCentBin]; double pta2[NCentBin]; double pta3[NCentBin]; double v2a[NCentBin]; double v2ae[NCentBin]; double v21[NCentBin]; double v21e[NCentBin]; double v22[NCentBin24]; double v22e[NCentBin24]; double v23[NCentBin]; double v23e[NCentBin]; double temp; ofstream sysbn; ifstream inv2a; ifstream inv21; ifstream inv22; ifstream inv23; inv2a.open("v2.txt"); if(!inv2a.good()) cout<<" input fail"<<endl; else cout<<" have put in"<<endl; for(int i=0;i<NCentBin;i++){ inv2a>>pt[i]; inv2a>>v2a[i]; inv2a>>v2ae[i]; } for(int i=0;i<NCentBin;i++){ inv2a>>pta[i]; //inv21>>temp; inv2a>>v21[i]; inv2a>>v21e[i]; } for(int i=0;i<NCentBin;i++){ inv2a>>pta2[i]; //inv21>>temp; inv2a>>v22[i]; inv2a>>v22e[i]; } for(int i=0;i<NCentBin;i++){ inv2a>>pta3[i]; //inv21>>temp; inv2a>>v23[i]; inv2a>>v23e[i]; } //////////////// //////// TCanvas *c1 = new TCanvas("c1","c1",1,1,650,550); c1->SetFillColor(10); c1->SetFrameFillColor(0); c1->SetFrameBorderSize(0); c1->SetFrameBorderMode(0); c1->SetLeftMargin(0.15); c1->SetBottomMargin(0.15); c1->SetTopMargin(0.02); c1->SetRightMargin(0.02); //c1->Divide(2,1,0,0); gStyle->SetOptStat(0); c1->SetTicks(-1); TH1D* hist = new TH1D("hist","",100,0.,8.9); hist->SetXTitle("p_{T} (GeV/c)"); hist->SetYTitle("v_{2}{EP}"); hist->SetMinimum(0.001); hist->SetMaximum(0.349); hist->GetXaxis()->CenterTitle(1); hist->GetYaxis()->CenterTitle(1); hist->GetYaxis()->SetTitleOffset(1.1); hist->GetXaxis()->SetTitleOffset(0.95); hist->GetXaxis()->SetTitleSize(0.066); hist->GetYaxis()->SetTitleSize(0.066); hist->GetXaxis()->SetLabelSize(0.05); hist->GetYaxis()->SetLabelSize(0.05); hist->Draw(); TF1 *V2vsPt = new TF1("V2vsPt","((x/3.4)^1.8/(1+(x/3)^1.8))*(.00005+(1/x)^0.8)",0.2,10); //TF1 *V2vsPt = new TF1("V2vsPt","0.000000001*x+0.04",0.2,10); V2vsPt->SetLineColor(1); V2vsPt->SetLineWidth(2); V2vsPt->SetLineStyle(2); V2vsPt->Draw("same"); TGraphErrors *gr2 = new TGraphErrors(NCentBin,pt,v2a,0,v2ae); gr2->SetTitle(""); gr2->SetMarkerStyle(20); gr2->SetMarkerSize(1.0); gr2->SetMarkerColor(1); gr2->SetLineWidth(2); gr2->SetLineColor(1); gr2->Draw("psameez"); TGraphErrors *gr3 = new TGraphErrors(NCentBin,pta,v21,0,v21e); gr3->SetMarkerStyle(24); gr3->SetMarkerSize(1.); gr3->SetMarkerColor(2); gr3->SetLineWidth(2); gr3->SetLineColor(1); gr3->Draw("psameez"); TGraphErrors *gr4 = new TGraphErrors(NCentBin,pta2,v22,0,v22e); gr4->SetMarkerStyle(25); gr4->SetMarkerSize(1.); gr4->SetMarkerColor(4); gr4->SetLineWidth(2); gr4->SetLineColor(1); gr4->Draw("psameez"); TGraphErrors *gr5 = new TGraphErrors(NCentBin,pta3,v23,0,v23e); gr5->SetMarkerStyle(28); gr5->SetMarkerSize(1); gr5->SetMarkerColor(3); gr5->SetLineWidth(2); gr5->SetLineColor(1); gr5->Draw("psameez"); TLegend *leg = new TLegend(0.19,0.65,0.38,0.93); leg->SetFillColor(10); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextColor(1); leg->SetTextSize(0.04); //leg->SetLineStyle(0.06); leg->AddEntry(gr2,"|#Delta#eta|>0.0","p"); leg->AddEntry(gr3,"|#Delta#eta|>1.0","p"); leg->AddEntry(gr4,"|#Delta#eta|>1.5","p"); leg->AddEntry(gr5,"|#Delta#eta|>2.0","p"); leg->AddEntry(V2vsPt,"Input v_{2}","l"); leg->Draw(); TLatex *tex1= new TLatex(5,0.305,"STEG, 5k events"); tex1->SetTextColor(1); tex1->SetTextSize(0.05); tex1->SetTextFont(42); tex1->Draw(); TLatex *tex2= new TLatex(3,0.265,"90>N>=35, |#eta| < 2.4"); tex2->SetTextColor(1); tex2->SetTextSize(0.05); tex2->SetTextFont(42); //tex2->Draw(); c1->Print("eventplanev2.png"); }
void PlotRakeBunch( const TString &sim, Int_t time, Int_t index = 0, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetLabelFont(42,"xyz"); gStyle->SetTextFont(62); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; opt += "comovcenter"; // Centering time and z position: Double_t shiftz = pData->Shift(opt); TString sshiftz = Form("(x1-%f)",shiftz); if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Spatial coordinates intervals: Float_t x1Min = -4.3; Float_t x1Max = -3.9; Float_t x2Min = -0.5; Float_t x2Max = 0.5; Float_t x3Min = -0.5; Float_t x3Max = 0.5; // Momentum coordinates intervals: Float_t p1Min = 6500.01; Float_t p1Max = 10099.99; Float_t p2Min = -20.0; Float_t p2Max = 20.0; Float_t p3Min = -20.0; Float_t p3Max = 20.0; // Bining, intervals, labels, etc. Int_t xNbin = 200; Int_t yNbin = 200; if(sim.Contains("DR")) { xNbin = 200; yNbin = 200; // p1Min = 2200.01; // p1Max = 3399.99; // p1Min = 3500.01; // p1Max = 4999.99; p1Min = 1800.01; p1Max = 3999.99; // x1Min = -4.0; // x1Max = -3.2; x1Min = 8637.0; x1Max = 8639.0; x2Min = -0.5; x2Max = 0.5; x3Min = -0.5; x3Max = 0.5; } else if(sim.Contains("flash") && sim.Contains(".G.") ) { x1Min = -6.3; x1Max = -5.0; //p1Min = 0.001; p1Min = 650.001; p1Max = 1499.99; } else if(sim.Contains("facet_v23kA.G.A")) { x1Min = -7.8; x1Max = -7.1; x2Min = -1.0; x2Max = 1.0; x3Min = -1.0; x3Max = 1.0; // t=150 p1Min = 1100.001; p1Max = 1999.99; } else if(sim.Contains("facet_v23kA.G")) { x1Min = -7.8; x1Max = -7.0; x2Min = -1.0; x2Max = 1.0; x3Min = -1.0; x3Max = 1.0; // t=60 p1Min = 350.01; p1Max = 799.99; // t = 100 // p1Min = 700.01; // p1Max = 1399.99; // t=105 //p1Min = 800.001; //p1Max = 1399.99; // t=183 // p1Min = 1500.001; // p1Max = 2499.99; // t=235 // p1Min = 2000.01; // p1Max = 3499.99; // t=310 // p1Min = 2800.01; // p1Max = 4799.99; } // Get phasespace histos Int_t Nspecies = pData->NSpecies(); if(index>Nspecies-1) { return; } if(!pData->GetRawFileName(index)) { return; } TH1F *hX1 = NULL; TH1F *hP1 = NULL; TH2F *hP1X1 = NULL; TH2F *hP2X2 = NULL; cout << Form("\n1. Getting data... ") << endl; char cutString[512]; sprintf(cutString,"TMath::Abs(q)*(%s > %.1f && %s < %.1f && x2 > %.1f && x2 < %.1f && x3 > %.1f && x3 < %.1f)",sshiftz.Data(),x1Min,sshiftz.Data(),x1Max,x2Min,x2Max,x3Min,x3Max); TCut Cut = cutString; cout << Form(" (applied cut: \n %s)",cutString) << endl; TTree *tree = pData->GetTreeRaw(pData->GetRawFileName(index)->c_str(),opt); char hName[24]; char dCommand[128]; cout << Form("\n2. Dumping 1D histograms.. ") << endl; sprintf(hName,"hX1"); hX1 = (TH1F*) gROOT->FindObject(hName); if(hX1) delete hX1; hX1 = new TH1F(hName,"",xNbin,x1Min,x1Max); sprintf(dCommand,"%s>>%s",sshiftz.Data(),hName); cout << Form(" - x1. ") << endl; tree->Draw(dCommand,Cut,"goff"); sprintf(hName,"hP1"); hP1 = (TH1F*) gROOT->FindObject(hName); if(hP1) delete hP1; hP1 = new TH1F(hName,"",yNbin,p1Min,p1Max); sprintf(dCommand,"p1>>%s",hName); cout << Form(" - p1. ") << endl; tree->Draw(dCommand,Cut,"goff"); cout << Form("\n3. Dumping 2D histograms.. ") << endl; sprintf(hName,"hP1X1"); hP1X1 = (TH2F*) gROOT->FindObject(hName); if(hP1X1) delete hP1X1; hP1X1 = new TH2F(hName,"",xNbin,x1Min,x1Max,yNbin,p1Min,p1Max); sprintf(dCommand,"p1:%s>>%s",sshiftz.Data(),hName); cout << Form(" - p1 vs. x1 ") << endl; tree->Draw(dCommand,Cut,"goff"); sprintf(hName,"hP2X2"); hP2X2 = (TH2F*) gROOT->FindObject(hName); if(hP2X2) delete hP2X2; hP2X2 = new TH2F(hName,"",xNbin,x2Min,x2Max,yNbin,p2Min,p2Max); sprintf(dCommand,"p2:x2>>%s",hName); cout << Form(" - p2 vs. x2 ") << endl; tree->Draw(dCommand,Cut,"goff"); hX1->GetXaxis()->CenterTitle(); hX1->GetYaxis()->CenterTitle(); hX1->GetZaxis()->CenterTitle(); hP1X1->GetXaxis()->CenterTitle(); hP1X1->GetYaxis()->CenterTitle(); hP1X1->GetZaxis()->CenterTitle(); hP2X2->GetXaxis()->CenterTitle(); hP2X2->GetYaxis()->CenterTitle(); hP2X2->GetZaxis()->CenterTitle(); // Integrated long. emittance: cout << Form("\n4. Calculating integrated quantities.. ") << endl; Double_t xmean = 0.0; Double_t ymean = 0.0; Double_t x2mean = 0.0; Double_t y2mean = 0.0; Double_t xymean = 0.0; Double_t Ntotal = 0.0; for(Int_t i=1;i<=xNbin;i++) { Double_t x = hP1X1->GetXaxis()->GetBinCenter(i); // if(x<xmin || x>xmax) continue; for(Int_t j=1;j<=yNbin;j++) { Double_t y = hP1X1->GetYaxis()->GetBinCenter(j); // if(y<ymin || y>ymax) continue; Double_t value = TMath::Abs(hP1X1->GetBinContent(i,j)); xmean += x*value; ymean += y*value; x2mean += x*x*value; y2mean += y*y*value; xymean += x*y*value; Ntotal += value; } } xmean /= Ntotal; ymean /= Ntotal; x2mean /= Ntotal; y2mean /= Ntotal; xymean /= Ntotal; Double_t xrms2 = x2mean - xmean*xmean; Double_t yrms2 = y2mean - ymean*ymean; Double_t xrms = TMath::Sqrt(xrms2); Double_t yrms = TMath::Sqrt(yrms2); Double_t xyrms2 = xymean - xmean*ymean; Double_t emittance = TMath::Sqrt(xrms2*yrms2 - xyrms2*xyrms2); // cout << " xrms = " << xrms << endl; // Sliced emittance: // -------------------------------------------------------------------------- cout << Form("\n5. Slicing ") << endl; // Bining for sliced quantities: // const Int_t SNbin = 7; // Float_t sBinLim[SNbin+1] = {-4.16,-4.14,-4.12,-4.10,-4.08,-4.06,-4.04,-4.02}; // const Int_t SNbin = 7; // Float_t sBinLim[SNbin+1] = {-4.20,-4.17,-4.14,-4.12,-4.10,-4.08,-4.06,-4.00}; // const Int_t SNbin = 8; // Float_t sBinLim[SNbin+1] = {-3.93,-3.87,-3.81,-3.75,-3.69,-3.63,-3.57,-3.51,-3.45}; Int_t SNbin = 7; Float_t nsigma = 2; Float_t x1BinMin = -4.16; Float_t x1BinMax = -4.02; if(sim.Contains("DR")) { SNbin = 150; nsigma = 1.4; } else if(sim.Contains("facet_v23kA.G.A")) { SNbin = 46; nsigma = 1; x1BinMin = -7.55; x1BinMax = -7.25; } else if(sim.Contains("facet_v23kA.G")) { SNbin = 10; nsigma = 1; x1BinMin = -7.55; x1BinMax = -7.15; } Float_t *sBinLim = new Float_t[SNbin+1]; if(opt.Contains("rms")) { sBinLim[0] = xmean - nsigma*xrms; sBinLim[SNbin] = xmean + nsigma*xrms; } else { sBinLim[0] = x1BinMin; sBinLim[SNbin] = x1BinMax; } Float_t slbinSize = (sBinLim[SNbin] - sBinLim[0])/SNbin; for(Int_t i=1;i<SNbin;i++) { sBinLim[i] = sBinLim[i-1] + slbinSize; } TH1F **hP1sl = new TH1F*[SNbin]; TH2F **hP2X2sl = new TH2F*[SNbin]; cout << Form("\n - Dumping in %i bins ",SNbin) << endl; for(Int_t k=0;k<SNbin;k++) { cout<< Form("k = %i : (x1 > %f && x1 < %f)",k,sBinLim[k],sBinLim[k+1]) << endl; sprintf(hName,"hP2X2sl_%2i",k); hP2X2sl[k] = (TH2F*) gROOT->FindObject(hName); if(hP2X2sl[k]) delete hP2X2sl[k]; hP2X2sl[k] = new TH2F(hName,"",xNbin,x2Min,x2Max,yNbin,p2Min,p2Max); char zCutString[128]; sprintf(zCutString,"(%s > %f && %s < %f)",sshiftz.Data(),sBinLim[k],sshiftz.Data(),sBinLim[k+1]); TCut zCut = zCutString; tree->Project(hName,"p2:x2",Cut + zCut); sprintf(hName,"hP1sl_%2i",k); hP1sl[k] = (TH1F*) gROOT->FindObject(hName); if(hP1sl[k]) delete hP1sl[k]; hP1sl[k] = new TH1F(hName,"",yNbin,p1Min,p1Max); tree->Project(hName,"p1",Cut + zCut); } cout << Form("\n6. Calculating sliced quantities.. ") << endl; TGraph *gemit = NULL; TGraph *gYrms = NULL; TGraph *gErms = NULL; TGraph *gErmsB = NULL; Double_t * sxmean = new Double_t[SNbin]; Double_t * symean = new Double_t[SNbin]; Double_t * sx2mean = new Double_t[SNbin]; Double_t * sy2mean = new Double_t[SNbin]; Double_t * sxymean = new Double_t[SNbin]; Double_t * sNtotal = new Double_t[SNbin]; Double_t * sxrms2 = new Double_t[SNbin]; Double_t * syrms2 = new Double_t[SNbin]; Double_t * sxrms = new Double_t[SNbin]; Double_t * syrms = new Double_t[SNbin]; Double_t * sxyrms2 = new Double_t[SNbin]; Double_t * xbin = new Double_t[SNbin]; Double_t * semittance = new Double_t[SNbin]; Double_t * sNEtotal = new Double_t[SNbin]; Double_t * sEmean = new Double_t[SNbin]; Double_t * sE2mean = new Double_t[SNbin]; Double_t * sErms = new Double_t[SNbin]; for(Int_t k=0;k<SNbin;k++) { sxmean[k] = symean[k] = sx2mean[k] = sy2mean[k] = sxymean[k] = sNtotal[k] = sxrms2[k] = syrms2[k] = sxrms[k] = syrms[k] = sxyrms2[k] = xbin[k] = semittance[k] = 0.0; sNEtotal[k] = sEmean[k] = sE2mean[k] = sErms[k] = 0.0; xbin[k] = (sBinLim[k] + sBinLim[k+1])/2.; for(Int_t i=1;i<=xNbin;i++) { Double_t x = hP2X2sl[k]->GetXaxis()->GetBinCenter(i); // if(x<xmin || x>xmax) continue; for(Int_t j=1;j<=yNbin;j++) { Double_t y = hP2X2sl[k]->GetYaxis()->GetBinCenter(j); // if(y<ymin || y>ymax) continue; Double_t value = TMath::Abs(hP2X2sl[k]->GetBinContent(i,j)); sxmean[k] += x*value; symean[k] += y*value; sx2mean[k] += x*x*value; sy2mean[k] += y*y*value; sxymean[k] += x*y*value; sNtotal[k] += value; } } for(Int_t i=1;i<=yNbin;i++) { Double_t y = hP1sl[k]->GetXaxis()->GetBinCenter(i); Double_t value = TMath::Abs(hP1sl[k]->GetBinContent(i)); sEmean[k] += y*value; sE2mean[k] += y*y*value; sNEtotal[k] += value; } sxmean[k] /= sNtotal[k]; symean[k] /= sNtotal[k]; sx2mean[k] /= sNtotal[k]; sy2mean[k] /= sNtotal[k]; sxymean[k] /= sNtotal[k]; sxrms2[k] = sx2mean[k] - sxmean[k]*sxmean[k]; syrms2[k] = sy2mean[k] - symean[k]*symean[k]; sxrms[k] = TMath::Sqrt(sxrms2[k]); syrms[k] = TMath::Sqrt(syrms2[k]); sxyrms2[k] = sxymean[k] - sxmean[k]*symean[k]; semittance[k] = TMath::Sqrt(sxrms2[k]*syrms2[k] - sxyrms2[k]*sxyrms2[k]); sEmean[k] /= sNEtotal[k]; sE2mean[k] /= sNEtotal[k]; sErms[k] = TMath::Sqrt(sE2mean[k] - sEmean[k]*sEmean[k]); cout << " Bunch properties: " << endl; cout << Form(" xMean = %7.3f yMean = %7.3f",sxmean[k],symean[k]) << endl; cout << Form(" xRms = %7.3f yRms = %7.3f",sxrms[k],syrms[k]) << endl; cout << Form(" Emittance = %7.3f",semittance[k]) << endl; cout << Form(" Emean = %7.3f Erms = %7.3f",sEmean[k],sErms[k]) << endl; } // Charge Double_t dx1 = pData->GetDX(0); Double_t dx2 = pData->GetDX(1); Double_t dx3 = pData->GetDX(2); hX1->Scale(dx1*dx2*dx3); Double_t Charge = hX1->Integral(); // Charge *= dx1*dx2*dx3; if(opt.Contains("units")) { Double_t dV = skindepth * skindepth * skindepth; Charge *= n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb); cout << Form(" Integrated charge (RAW) of specie %3i = %8f pC",index,Charge) << endl; } else { cout << Form(" Integrated charge (RAW) of specie %3i = %8.4f n0 * kp^-3",index,Charge) << endl; } // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { Int_t NbinsX = hP1X1->GetNbinsX(); Double_t xMin = skindepth * hP1X1->GetXaxis()->GetXmin() / PUnits::um; Double_t xMax = skindepth * hP1X1->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hP1X1->GetNbinsY(); Double_t yMin = hP1X1->GetYaxis()->GetXmin() * pData->GetBeamMass() / PUnits::GeV; Double_t yMax = hP1X1->GetYaxis()->GetXmax() * pData->GetBeamMass() / PUnits::GeV; hP1X1->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); // Converting electron density Double_t dVb = skindepth * skindepth * skindepth; Double_t dX = (xMax-xMin)/NbinsX; Double_t dE = (yMax-yMin)/NbinsY; for(Int_t j=0;j<hP1X1->GetNbinsX();j++) { for(Int_t k=0;k<hP1X1->GetNbinsY();k++) { Double_t binValue = fabs(hP1X1->GetBinContent(j,k) * dx1 * dx2 * dx3 * dVb * n0 * (PConst::ElectronCharge/PUnits::picocoulomb)); //cout << Form(" value = %f",binValue) << endl; hP1X1->SetBinContent(j,k,binValue); } } if(opt.Contains("comov")) hP1X1->GetXaxis()->SetTitle("#zeta [#mum]"); else hP1X1->GetXaxis()->SetTitle("z [#mum]"); hP1X1->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hP1X1->GetZaxis()->SetTitle("dQ/d#zetadp_{z} [pC]"); hP1->SetBins(NbinsY,yMin,yMax); hP1->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hX1->SetBins(NbinsX,xMin,xMax); Double_t binSize = (xMax - xMin)/NbinsX; Double_t dV = skindepth * skindepth * skindepth; Double_t lightspeed = PConst::c_light / (PUnits::um/PUnits::femtosecond); cout << Form("Speed of light = %f",lightspeed) << endl; hX1->Scale(TMath::Abs(n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb) * (lightspeed/binSize))); // hX1->Scale(TMath::Abs((PUnits::um/skindepth)*(PConst::ElectronCharge/PUnits::picocoulomb)*PConst::c_light)); // hX1->GetYaxis()->SetTitle("I[kA]"); hX1->GetYaxis()->SetTitle(""); if(opt.Contains("comov")) hX1->GetXaxis()->SetTitle("#zeta [#mum]"); else hX1->GetXaxis()->SetTitle("z [#mum]"); xmean *= skindepth / PUnits::um; xrms *= skindepth / PUnits::um; ymean *= pData->GetBeamMass() / PUnits::GeV; yrms *= pData->GetBeamMass() / PUnits::GeV; emittance *= (skindepth / PUnits::um); for(Int_t k=0;k<SNbin;k++) { xbin[k] *= skindepth / PUnits::um; sxmean[k] *= skindepth / PUnits::um; sxrms[k] *= skindepth / PUnits::um; symean[k] *= pData->GetBeamMass() / PUnits::MeV; syrms[k] *= pData->GetBeamMass() / PUnits::MeV; semittance[k] *= (skindepth / PUnits::um); sEmean[k] *= pData->GetBeamMass() / PUnits::GeV; sErms[k] *= 100 * pData->GetBeamMass() / PUnits::GeV / ymean; //sEmean[k]; // sErms[k] *= pData->GetBeamMass() / PUnits::GeV; } } // Create the graph with the emittances: gemit = new TGraph(SNbin,xbin,semittance); gYrms = new TGraph(SNbin,xbin,sxrms); gErms = new TGraph(SNbin,xbin,sErms); // Profile energy for p1 vs x1: TString pname = hP1X1->GetName(); pname += "_pfx"; TProfile *hP1X1prof = (TProfile*) gROOT->FindObject(pname.Data()); if(hP1X1prof) { delete hP1X1prof; hP1X1prof = NULL; } hP1X1prof = hP1X1->ProfileX("_pfx",1,-1,"s"); // get the errors from the profile: Int_t NP1X1Bins = hP1X1prof->GetNbinsX(); Double_t *x1bins = new Double_t[NP1X1Bins]; Double_t *eRms = new Double_t[NP1X1Bins]; for(Int_t i=1;i<=hP1X1prof->GetNbinsX();i++) { x1bins[i] = hP1X1prof->GetBinCenter(i); eRms[i] = 100 * hP1X1prof->GetBinError(i) / hP1X1prof->GetBinContent(i); } gErmsB = new TGraph(NP1X1Bins,x1bins,eRms); // Vertical Energy histogram: // -------------------------------------------------------------------------------- TGraph *gP1left = NULL; if(hP1) { Double_t *yarray = new Double_t[yNbin]; Double_t *xarray = new Double_t[yNbin]; // This is for the right side: // Double_t xMax = x1Min + (x1Max-x1Min) * 0.9; // Double_t xMin = x1Max; // And this for left: Double_t xMin = hX1->GetXaxis()->GetXmin(); Double_t xMax = hX1->GetXaxis()->GetXmin() + (hX1->GetXaxis()->GetXmax() -hX1->GetXaxis()->GetXmin()) * 0.2; Double_t EneMax = hP1->GetMaximum(); // cout << Form(" EneMax = %f ", EneMax) << endl; for(Int_t j=0; j<yNbin; j++) { yarray[j] = hP1->GetBinCenter(j+1); xarray[j] = ((xMax-xMin)/EneMax)*hP1->GetBinContent(j+1) + xMin; // cout << Form(" x = %f y = %f ", xarray[j],yarray[j]) << endl; } gP1left = new TGraph(yNbin,xarray,yarray); gP1left->SetLineColor(PlasmaGlob::elecLine); gP1left->SetLineWidth(2); gP1left->SetFillStyle(1001); gP1left->SetFillColor(PlasmaGlob::elecFill); } // Plotting // ----------------------------------------------- // Canvas setup // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 800; Int_t sizey = 600; if(opt.Contains("hres")) { Int_t sizex = 1600; Int_t sizey = 1200; } TCanvas *C = new TCanvas("C1","Evolution of Injection",sizex,sizey); C->cd(); // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron"); pPalette->cd(); // Float_t Max = hP1X1->GetMaximum(); // Float_t Min = hP1X1->GetMinimum(); // hP1X1->GetZaxis()->SetRangeUser(Min,Max); // Text objects TPaveText *textTime = new TPaveText(0.55,0.8,0.82,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); textTime->SetTextColor(kGray+2); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"z = %5.1f mm", Time * skindepth / PUnits::mm); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cc", n0 / (1e17/PUnits::cm3)); else if(pData->GetBeamDensity() && pData->GetPlasmaDensity()) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/n0); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.15,0.2,0.48,0.25,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.2f #mum", pData->GetPlasmaWaveLength() / PUnits::um); textWav->AddText(ctext); TPaveText *textCharge = new TPaveText(0.15,0.25,0.48,0.3,"NDC"); PlasmaGlob::SetPaveTextStyle(textCharge,12); textCharge->SetTextColor(kGray+2); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Charge = %5.2f pC", Charge); else sprintf(ctext,"Charge = %5.2f n0#timeskp^{-3}", Charge); textCharge->AddText(ctext); TPaveText *textMom = new TPaveText(0.55,0.03,0.82,0.13,"NDC"); PlasmaGlob::SetPaveTextStyle(textMom,32); textMom->SetTextColor(kGray+3); textMom->SetTextFont(62); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"#LTp_{z}#GT = %5.2f GeV/c", ymean); else sprintf(ctext,"Mom = %5.2f mc", ymean); textMom->AddText(ctext); TPaveText *textInfo = new TPaveText(0.55,0.52,0.82,0.75,"NDC"); PlasmaGlob::SetPaveTextStyle(textInfo,32); textInfo->SetTextColor(kGray+2); textInfo->SetTextFont(42); sprintf(ctext,"Charge = %5.2f pC",Charge); textInfo->AddText(ctext); sprintf(ctext,"#LT#zeta#GT_{rms} = %5.2f #mum",xrms); textInfo->AddText(ctext); sprintf(ctext,"#LTp_{z}#GT_{rms} = %5.2f GeV/c",yrms); textInfo->AddText(ctext); // sprintf(ctext,"#epsilon_{N} = %5.2f #mum",emittance); // textInfo->AddText(ctext); // Setup Pad layout: const Int_t NFrames = 2; TPad **pad = new TPad*[NFrames]; TH1F *hFrame[NFrames]; Double_t lMargin = 0.15; Double_t rMargin = 0.18; Double_t bMargin = 0.15; Double_t tMargin = 0.04; Double_t vSpacing = 0.00; Double_t hStep = (1.-lMargin-rMargin); Double_t vStep = (1.- bMargin - tMargin - (NFrames-1) * vSpacing) / NFrames; Float_t vposd = 0.0; Float_t vposu = 0.0; Float_t vmard = 0.0; Float_t vmaru = 0.0; Float_t vfactor = 0.0; Float_t hposl = 0.0; Float_t hposr = 1.0; Float_t hmarl = lMargin; Float_t hmarr = rMargin; Float_t hfactor = 1.0; // Actual Plotting! // ------------------------------------------------------------ for(Int_t k=0;k<NFrames;k++) { // PLOTTING! if(k==0) { vposd = 0.0; vposu = bMargin + vStep; vfactor = vposu-vposd; vmard = bMargin / vfactor; vmaru = 0.0; } else if(k == NFrames-1) { vposd = vposu + vSpacing; vposu = vposd + vStep + tMargin; vfactor = vposu-vposd; vmard = 0.0; vmaru = tMargin / (vposu-vposd); } else { vposd = vposu + vSpacing; vposu = vposd + vStep; vfactor = vposu-vposd; vmard = 0.0; vmaru = 0.0; } hfactor = hposl-hposr; char name[16]; sprintf(name,"pad_%i",k); pad[k] = new TPad(name,"",hposl,vposd,hposr,vposu); // // cout << Form("%f %f %f %f",hposl,vposd,hposr,vposu) << endl; // // cout << Form("%f %f %f %f",hmarl,vmard,hmarr,vmaru) << endl; pad[k]->SetLeftMargin(hmarl); pad[k]->SetRightMargin(hmarr); pad[k]->SetBottomMargin(vmard); pad[k]->SetTopMargin(vmaru); pad[k]->SetFrameLineWidth(3); sprintf(name,"hFrame_%i",k); hFrame[k] = (TH1F*) gROOT->FindObject(name); if(hFrame[k]) delete hFrame[k]; hFrame[k] = (TH1F*) hX1->Clone(name); hFrame[k]->Reset(); hFrame[k]->GetXaxis()->CenterTitle(); hFrame[k]->GetYaxis()->CenterTitle(); hFrame[k]->GetZaxis()->CenterTitle(); hFrame[k]->SetLabelFont(42,"xyz"); hFrame[k]->SetTitleFont(42,"xyz"); hFrame[k]->SetNdivisions(505,"xyz"); hFrame[k]->SetTickLength(0.04,"xyz"); hFrame[k]->SetTickLength(0.04*vfactor,"y"); hFrame[k]->GetYaxis()->SetLabelSize(0.04/vfactor); hFrame[k]->GetYaxis()->SetLabelOffset(0.02); hFrame[k]->GetYaxis()->SetTitleSize(0.05/vfactor); hFrame[k]->GetYaxis()->SetTitleOffset(1.2*vfactor); if(k==0) { hFrame[k]->GetXaxis()->SetLabelSize(0.08); hFrame[k]->GetXaxis()->SetLabelOffset(0.02); hFrame[k]->GetXaxis()->SetTitleSize(0.12); hFrame[k]->GetXaxis()->SetTitleOffset(1.0); } else { hFrame[k]->GetXaxis()->SetLabelSize(0.0); hFrame[k]->GetXaxis()->SetTitleSize(0.0); } } // Ranges!! Double_t yMin = 999.9; Double_t yMax = -999.9; for(Int_t k=0;k<SNbin;k++) { if(semittance[k]<yMin) yMin = semittance[k]; if(semittance[k]>yMax) yMax = semittance[k]; if(sErms[k]<yMin) yMin = sErms[k]; if(sErms[k]>yMax) yMax = sErms[k]; } for(Int_t k=1;k<=xNbin;k++) { Double_t value = hX1->GetBinContent(k); if(value<yMin) yMin = value; if(value>yMax) yMax = value; } C->cd(); pad[1]->Draw(); pad[1]->cd(); if(opt.Contains("logz")) { gPad->SetLogz(1); } else { gPad->SetLogz(0); } hFrame[1]->GetYaxis()->SetRangeUser(hP1X1->GetYaxis()->GetXmin(),hP1X1->GetYaxis()->GetXmax()); if(opt.Contains("units")) hFrame[1]->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hFrame[1]->Draw(); gP1left->SetLineWidth(2); gP1left->Draw("F"); gP1left->Draw("L"); TLine lZmean(xmean,hP1X1->GetYaxis()->GetXmin(),xmean,hP1X1->GetYaxis()->GetXmax()); lZmean.SetLineColor(kGray+2); lZmean.SetLineStyle(2); lZmean.Draw(); TLine lPmean(hP1X1->GetXaxis()->GetXmin(),ymean,hP1X1->GetXaxis()->GetXmax(),ymean); lPmean.SetLineColor(kGray+2); lPmean.SetLineStyle(2); lPmean.Draw(); hP1X1->GetYaxis()->SetNdivisions(503); hP1X1->GetZaxis()->SetNdivisions(503); hP1X1->GetZaxis()->SetRangeUser(0.001*hP1X1->GetMaximum(),hP1X1->GetMaximum()); hP1X1->GetZaxis()->SetLabelSize(0.05); hP1X1->GetZaxis()->SetTitleSize(0.04); hP1X1->GetZaxis()->SetTitleFont(42); hP1X1->Draw("colzsame"); // hP1X1->SetContour(20); // hP1X1->Draw("contzsame"); // hP1X1prof->SetMarkerStyle(1); // hP1X1prof->SetLineWidth(2); // hP1X1prof->Draw("zsame"); //hP1->Draw("C"); gPad->Update(); TPaletteAxis *palette = (TPaletteAxis*)hP1X1->GetListOfFunctions()->FindObject("palette"); if(palette) { Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = 1 - gPad->GetRightMargin(); palette->SetY2NDC(y2 - 0.04); palette->SetY1NDC(y1 + 0.04); palette->SetX1NDC(x1 + 0.01); palette->SetX2NDC(x1 + 0.04); palette->SetLabelFont(42); palette->SetLabelSize(0.08); //palette->SetLabelOffset(0.005/vfactor); palette->SetTitleSize(0.10); // palette->SetTitleOffset(9999.0*vfactor); palette->SetTitleOffset(0.6); palette->SetBorderSize(2); palette->SetLineColor(1); } textTime->Draw(); textInfo->Draw(); // textCharge->Draw(); textMom->Draw(); gPad->RedrawAxis(); // Bottom plot ----------------------------------------- C->cd(); pad[0]->Draw(); pad[0]->cd(); hFrame[0]->GetYaxis()->SetRangeUser(0.0,1.1*yMax); hFrame[0]->Draw(); hX1->SetLineWidth(2); hX1->SetFillStyle(1001); hX1->SetFillColor(PlasmaGlob::elecFill); // hX1->SetLineColor(kBlue); hX1->Draw("FL same"); //hX1->Draw("C"); TLine lZmean2(xmean,0.0,xmean,1.1*yMax); lZmean2.SetLineColor(kGray+2); lZmean2.SetLineStyle(2); lZmean2.Draw(); Int_t markerSize = 1.2; Int_t lineWidth = 2.0; gYrms->SetMarkerStyle(20); gYrms->SetLineStyle(1); gYrms->SetMarkerColor(kGray+1); gYrms->SetMarkerSize(markerSize); gYrms->SetLineColor(kGray+1); gYrms->SetLineWidth(lineWidth); gYrms->Draw("PL"); // hP2X2sl[0]->Draw("colz"); gemit->SetMarkerStyle(20); // gemit->SetMarkerColor(kMagenta-2); gemit->SetMarkerColor(kGray+2); gemit->SetMarkerSize(markerSize); gemit->SetLineWidth(lineWidth); gemit->SetLineColor(kGray+2); gemit->Draw("PL"); gErms->SetMarkerStyle(20); gErms->SetMarkerSize(markerSize); gErms->SetMarkerColor(kOrange+10); gErms->SetLineColor(kOrange+10); gErms->SetLineWidth(lineWidth); gErms->Draw("PL"); TLegend *Leg; if(!sim.Contains("DR")) Leg=new TLegend(0.55,0.60,1 - gPad->GetRightMargin() - 0.02,0.95); else Leg=new TLegend(gPad->GetLeftMargin() + 0.02, 1.0-gPad->GetTopMargin()-0.20, gPad->GetLeftMargin() + 0.30, 1.0-gPad->GetTopMargin()-0.02); PlasmaGlob::SetPaveStyle(Leg); Leg->SetTextAlign(12); Leg->SetTextColor(kGray+3); Leg->SetTextFont(42); Leg->SetLineColor(1); Leg->SetBorderSize(0); Leg->SetFillColor(0); Leg->SetFillStyle(1001); Leg->SetFillStyle(0); // Hollow Leg->AddEntry(hX1 ,"Current [kA]","L"); // Leg->AddEntry(gErms,"Energy spread (GeV)","PL"); Leg->AddEntry(gErms,"Energy spread [%]","PL"); Leg->AddEntry(gemit,"Emittance [#mum]","PL"); Leg->AddEntry(gYrms,"Bunch width [#mum]","PL"); Leg->Draw(); gPad->RedrawAxis(); gPad->Update(); // Print to file -------------------------------------- C->cd(); // Print to a file // Output file TString fOutName = Form("./%s/Plots/RakeBunch/RakeBunch",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void fitEfficiency(float thres, float mLow=45, float mHigh=70, TString cutdef="pt_HLT>=20", TString cut_choice="HLT", TString dirIn="/data_CMS/cms/ndaci/ndaci_2012/HTauTau/TriggerStudy/SingleMu/MuMu/Run2012A_PRV1/Pairs/", TString dirResults="/home//llr/cms/ndaci/SKWork/macro/HTauTau/results/TriggerStudies/MuMu/Run2012A_PRV1/", TString lumi="200 pb", int nCPU=4, int color1=kBlack, int style1=kFullCircle, int color2=kRed, int style2=kOpenSquare, TString fileIn="*.root", TString image="eff_HLT_MuTau") { // STYLE // gROOT->Reset(); loadPresentationStyle(); gROOT->ForceStyle(); // OUTPUT // TString name_image = dirResults+"/"+image; ofstream fichier(name_image+".txt", ios::out); // BINNING // const int nbinsEB = 14; Double_t binsEB[nbinsEB] = {10., 14., 18., 20., 22., 26., 30., 40., 50., 60., 70., 80, 90, 100}; RooBinning binningEB = RooBinning(nbinsEB-1, binsEB, "binningEB"); const int nbinsEE = 14; Double_t binsEE[nbinsEE] = {10., 14., 18., 20., 22., 26., 30., 40., 50., 60., 70., 80, 90, 100}; RooBinning binningEE = RooBinning(nbinsEE-1, binsEE, "binningEE"); // EB/EE eta cuts // TString etacutEB="eta>-1.479 && eta<1.479", etacutEE="eta<=-1.479 || eta>=1.479"; TString cutdefEB, cutdefEE; if(cutdef=="") { cutdefEB=etacutEB; cutdefEE=etacutEE; } else { cutdefEB=cutdef+" && "+etacutEB ; cutdefEB=cutdef+" && "+etacutEE ; } // INPUT DATA // TChain* treeTnP = new TChain("treeTnP"); treeTnP->Add(dirIn+"/"+fileIn); RooRealVar xaxis("pt","P_{T} [GeV]",0,150) ; RooRealVar mass("mass","mass",mLow,mHigh) ;// consider only this mass range when importing data RooRealVar eta("eta","eta",-3., 3) ; RooRealVar weight("weight","weight",-1,1000) ; RooRealVar pt_HLT_tag("pt_HLT_tag","P_{T} [GeV]",0,150) ; RooRealVar pt_HLT_tag_sanity("pt_HLT_tag_sanity","P_{T} [GeV]",0,150) ; RooRealVar pt_L3("pt_L3","P_{T} [GeV]",0,150) ; RooRealVar pt_L25("pt_L25","P_{T} [GeV]",0,150) ; RooRealVar pt_L2("pt_L2","P_{T} [GeV]",0,150) ; RooRealVar et_L1jet("et_L1_jet","P_{T} [GeV]",0,150) ; RooRealVar et_L1tau("et_L1_tau","P_{T} [GeV]",0,150) ; // DEFINE EFFICIENCY CUT // RooCategory cutHLT("match","") ; cutHLT.defineType("accept",1) ; cutHLT.defineType("reject",0) ; RooCategory cutL1("L1match","") ; cutL1.defineType("accept",1) ; cutL1.defineType("reject",0) ; RooCategory cutL1L2("L1L2match","") ; cutL1L2.defineType("accept",1) ; cutL1L2.defineType("reject",0) ; RooCategory cutL1L2L25("L1L2L25match","") ; cutL1L2L25.defineType("accept",1) ; cutL1L2L25.defineType("reject",0) ; RooCategory cutL1L2L25L3("L1L2L25L3match","") ; cutL1L2L25L3.defineType("accept",1) ; cutL1L2L25L3.defineType("reject",0) ; RooCategory *cut; if(cut_choice=="HLT") cut = &cutHLT; if(cut_choice=="L1") cut = &cutL1; if(cut_choice=="L1L2") cut = &cutL1L2; if(cut_choice=="L1L2L25") cut = &cutL1L2L25; if(cut_choice=="L1L2L25L3") cut = &cutL1L2L25L3; RooDataSet dataSetEB("data","data from tree", RooArgSet(xaxis, *cut, pt_HLT_tag, pt_L3, pt_L25, pt_L2, mass, weight, eta), WeightVar(weight), Import(*treeTnP), Cut(cutdefEB) ); RooDataSet dataSetEE("data","data from tree", RooArgSet(xaxis, *cut, pt_HLT_tag, pt_L3, pt_L25, pt_L2, mass, weight, eta), WeightVar(weight), Import(*treeTnP), Cut(cutdefEE) ); dataSetEB.Print(); dataSetEE.Print(); // PLOT // RooPlot* frame = xaxis.frame(Bins(18000),Title("Fitted efficiency")) ; dataSetEB.plotOn(frame, Binning(binningEB), Efficiency(*cut), MarkerColor(color1), LineColor(color1), MarkerStyle(style1) ); dataSetEE.plotOn(frame, Binning(binningEE), Efficiency(*cut), MarkerColor(color2), LineColor(color2), MarkerStyle(style2) ); // PARAMETRES ROOFIT CRYSTAL BALL // RooRealVar norm("norm","N",0.95,0.6,1); RooRealVar alpha("alpha","#alpha",0.2,0.01,8); RooRealVar n("n","n",2,1.1,35); RooRealVar mean("mean","mean",10,5,30); mean.setVal(thres); RooRealVar sigma("sigma","#sigma",0.23,0.01,5); RooRealVar pedestal("pedestal","pedestal",0.01,0,0.4); FuncCB cb_EB("cb_EB","Fit function EB (cb)",xaxis,mean,sigma,alpha,n,norm) ; FuncCB cb_EE("cb_EE","Fit function EE (cb)",xaxis,mean,sigma,alpha,n,norm) ; RooEfficiency eff_EB("eff_EB","efficiency EB", cb_EB, *cut, "accept"); RooEfficiency eff_EE("eff_EE","efficiency EE", cb_EE, *cut, "accept"); // FIT // double fit_cuts_min = thres-1.5 ; double fit_cuts_max = 150; xaxis.setRange("interesting",fit_cuts_min,fit_cuts_max); fichier << "Fit characteristics :" << endl << "Threshold : " << thres << endl << "Fit Range : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl << endl << endl; RooFitResult* roofitres_EB = new RooFitResult("roofitres_EB","roofitres_EB"); RooFitResult* roofitres_EE = new RooFitResult("roofitres_EE","roofitres_EE"); // Fit #1 // roofitres_EB = eff_EB.fitTo(dataSetEB,ConditionalObservables(xaxis),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE),SumW2Error(kTRUE)); cb_EB.plotOn(frame,LineColor(color1),LineWidth(2)); fichier << "<----------------- EB ----------------->" << endl << "double res_mean=" << mean.getVal() << "; " << "double res_sigma=" << sigma.getVal() << "; " << "double res_alpha=" << alpha.getVal() << "; " << "double res_n=" << n.getVal() << "; " << "double res_norm=" << norm.getVal() << "; " << endl << "double err_mean=" << mean.getError() << "; " << "double err_sigma=" << sigma.getError() << "; " << "double err_alpha=" << alpha.getError() << "; " << "double err_n=" << n.getError() << "; " << "double err_norm=" << norm.getErrorLo()<< "; " << endl; // Fit #2 // roofitres_EE = eff_EE.fitTo(dataSetEE,ConditionalObservables(xaxis),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE),SumW2Error(kTRUE)); cb_EE.plotOn(frame,LineColor(color2),LineWidth(2)); fichier << "<----------------- EE ----------------->" << endl << "double res_mean=" << mean.getVal() << "; " << "double res_sigma=" << sigma.getVal() << "; " << "double res_alpha=" << alpha.getVal() << "; " << "double res_n=" << n.getVal() << "; " << "double res_norm=" << norm.getVal() << "; " << endl << "double err_mean=" << mean.getError() << "; " << "double err_sigma=" << sigma.getError() << "; " << "double err_alpha=" << alpha.getError() << "; " << "double err_n=" << n.getError() << "; " << "double err_norm=" << norm.getErrorLo()<< "; " << endl; //////////////////////////// DRAWING PLOTS AND LEGENDS ///////////////////////////////// TCanvas* ca = new TCanvas("ca","Trigger Efficiency") ; ca->SetGridx(); ca->SetGridy(); ca->cd(); //gPad->SetLogx(); gPad->SetObjectStat(1); frame->GetYaxis()->SetRangeUser(0,1.05); frame->GetXaxis()->SetRangeUser(1,150.); frame->GetYaxis()->SetTitle("Efficiency"); frame->GetXaxis()->SetTitle("E_{T} [GeV]"); frame->Draw() ; TH1F *SCeta_EB = new TH1F("SCeta_EB","SCeta_EB",50,-2.5,2.5); TH1F *SCeta_EE = new TH1F("SCeta_EE","SCeta_EE",50,-2.5,2.5); SCeta_EB->SetLineColor(color1) ; SCeta_EB->SetMarkerColor(color1); SCeta_EB->SetMarkerStyle(style1); SCeta_EE->SetLineColor(color2) ; SCeta_EE->SetMarkerColor(color2); SCeta_EE->SetMarkerStyle(style2); TLegend *leg = new TLegend(0.40, 0.14, 0.63, 0.34, NULL, "brNDC"); leg->SetLineColor(1); leg->SetTextColor(1); leg->SetTextFont(42); leg->SetTextSize(0.0244755); leg->SetShadowColor(kWhite); leg->SetFillColor(kWhite); leg->AddEntry("NULL","e #tau electrons efficiency","h"); // entry->SetLineColor(1); // entry->SetLineStyle(1); // entry->SetLineWidth(1); // entry->SetMarkerColor(1); // entry->SetMarkerStyle(21); // entry->SetMarkerSize(1); // entry->SetTextFont(62); leg->AddEntry(SCeta_EB,"Barrel","p"); leg->AddEntry(SCeta_EE,"Endcaps","p"); leg->Draw(); ostringstream ossi(""); ossi << thres; TString tossi = ossi.str(); leg = new TLegend(0.40, 0.30, 0.50, 0.50, NULL, "brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.0297203); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry("NULL","CMS Preliminary 2012 pp #sqrt{s}=8 TeV","h"); leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h"); leg->AddEntry("NULL","Threshold : "+tossi+" GeV","h"); leg->Draw(); ca->Print(name_image+".C","C"); ca->Print(name_image+".cxx","cxx"); ca->Print(name_image+".png","png"); ca->Print(name_image+".gif","gif"); ca->Print(name_image+".pdf","pdf"); ca->Print(name_image+".ps","ps"); ///////////////////////////// // SAVE THE ROO FIT RESULT // ///////////////////////////// RooWorkspace *w = new RooWorkspace("workspace","workspace") ; w->import(dataSetEB); w->import(dataSetEE); w->import(*roofitres_EB,"roofitres_EB"); w->import(*roofitres_EE,"roofitres_EE"); cout << "CREATES WORKSPACE : " << endl; w->Print(); w->writeToFile(name_image+"_fitres.root") ; //gDirectory->Add(w) ; // DELETE POINTERS // int a=0; // cin >> a; // delete treeTnP; delete cut; delete frame; delete roofitres_EB; delete roofitres_EE; delete ca; delete SCeta_EB; delete SCeta_EE; delete leg; delete w; }