void plot_diff_xsec() { TF1* fXsec = new TF1("fXsec", "diff_xsec(x)", 1, 0); fXsec->SetLineWidth(3); fXsec->SetTitle("#nu_{#mu}-e differential cross section (E_{#nu} = 2 GeV)"); fXsec->Draw(); fXsec->GetXaxis()->SetTitle("cos#theta"); fXsec->GetXaxis()->CenterTitle(); fXsec->GetYaxis()->SetTitle("d#sigma/dcos#theta (cm^{-2})"); fXsec->GetYaxis()->CenterTitle(); fXsec->GetYaxis()->SetTitleOffset(1.4); gPad->SetLogy(1); double totXsec = fXsec->Integral(0,1); for(int i = 0; i < 100; i++) { cout << fXsec->Integral(0.01*i,1)/totXsec << endl; } cout << totXsec << " " << fXsec->Integral(.99,1) << endl; ROOT::Math::GSLIntegrator ig(1.E-6,1.E-6,1000); ROOT::Math::WrappedTF1 wf(*fXsec); ig.SetFunction(wf); cout << ig.Integral(.9,1) << endl; //~ TCanvas* c2 = new TCanvas("c2"); //~ TF1* fCXsec = new TF1("fCXsec", "cumul_xsec(x)", 0, 90); //~ fCXsec->Draw(); //~ cout << cumul_xsec(45) << endl; }
void setGraphOptions(TF1 &f, const char *xname, const char *yname) { TAxis::TAxis *axis1; TAxis::TAxis *axis2; axis1 = f.GetXaxis(); axis2 = f.GetYaxis(); axis1->SetTitle(xname); axis2->SetTitle(yname); setAxisOptions(axis1); setAxisOptions(axis2); }
void wilenbrock_pseudoscalar() { setTDRStyle(); TCanvas* c = new TCanvas(); TF1* func = new TF1("Signal + Interferences",Somme,350,900,1); func->SetTitle("Scalar : Signal + interferences"); func->SetMinimum(-9e-9); //func->GetXaxis()->SetTitle("m_{t#bar{t}}"); double m=400; func->SetParameter(0,m); func->SetLineColor(TColor::GetColor("#542437")); func->SetLineWidth(2); func->SetNpx(500); func->Draw(); func->GetXaxis()->SetTitle("m_{t#bar{t}}"); func->GetYaxis()->SetTitle("#sigma(#hat{s}) - #sigma_{QCD}(#hat{s})"); TF1* func2 = new TF1("Signal + Interferences",Somme,350,900,1); m=500; func2->SetParameter(0,m); func2->SetLineColor(TColor::GetColor("#C02942")); func2->SetLineWidth(2); func2->SetNpx(500); func2->Draw("SAME"); TF1* func3 = new TF1("Signal + Interferences",Somme,350,900,1); m=600; func3->SetParameter(0,m); func3->SetLineColor(TColor::GetColor("#53777A")); func3->SetLineWidth(2); func3->SetNpx(500); func3->Draw("SAME"); TF1* func4 = new TF1("Signal + Interferences",Somme,350,900,1); m=700; func4->SetParameter(0,m); func4->SetLineColor(TColor::GetColor("#D95B43")); func4->SetLineWidth(2); func4->SetNpx(500); func4->Draw("SAME"); TF1* func5 = new TF1("Signal + Interferences",Somme,350,900,1); m=800; func5->SetParameter(0,m); func5->SetLineColor(TColor::GetColor("#ECD078")); func5->SetLineWidth(2); func5->SetNpx(500); func5->Draw("SAME"); c->SaveAs("pseudoscalar.pdf"); }
void FFT() { //This tutorial illustrates the Fast Fourier Transforms interface in ROOT. //FFT transform types provided in ROOT: // - "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT) // in one or more dimensions, -1 in the exponent // - "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT) // in one or more dimensions, +1 in the exponent // - "R2C" - a real-input/complex-output discrete Fourier transform (DFT) // in one or more dimensions, // - "C2R" - inverse transforms to "R2C", taking complex input // (storing the non-redundant half of a logically Hermitian array) // to real output // - "R2HC" - a real-input DFT with output in ¡Èhalfcomplex¡É format, // i.e. real and imaginary parts for a transform of size n stored as // r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1 // - "HC2R" - computes the reverse of FFTW_R2HC, above // - "DHT" - computes a discrete Hartley transform // Sine/cosine transforms: // DCT-I (REDFT00 in FFTW3 notation) // DCT-II (REDFT10 in FFTW3 notation) // DCT-III(REDFT01 in FFTW3 notation) // DCT-IV (REDFT11 in FFTW3 notation) // DST-I (RODFT00 in FFTW3 notation) // DST-II (RODFT10 in FFTW3 notation) // DST-III(RODFT01 in FFTW3 notation) // DST-IV (RODFT11 in FFTW3 notation) //First part of the tutorial shows how to transform the histograms //Second part shows how to transform the data arrays directly //Authors: Anna Kreshuk and Jens Hoffmann //********* Histograms ********// //prepare the canvas for drawing TCanvas *myc = new TCanvas("myc", "Fast Fourier Transform", 800, 600); myc->SetFillColor(45); TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.67,0.49,0.99); TPad *c1_2 = new TPad("c1_2", "c1_2",0.51,0.67,0.99,0.99); TPad *c1_3 = new TPad("c1_3", "c1_3",0.01,0.34,0.49,0.65); TPad *c1_4 = new TPad("c1_4", "c1_4",0.51,0.34,0.99,0.65); TPad *c1_5 = new TPad("c1_5", "c1_5",0.01,0.01,0.49,0.32); TPad *c1_6 = new TPad("c1_6", "c1_6",0.51,0.01,0.99,0.32); c1_1->Draw(); c1_2->Draw(); c1_3->Draw(); c1_4->Draw(); c1_5->Draw(); c1_6->Draw(); c1_1->SetFillColor(30); c1_1->SetFrameFillColor(42); c1_2->SetFillColor(30); c1_2->SetFrameFillColor(42); c1_3->SetFillColor(30); c1_3->SetFrameFillColor(42); c1_4->SetFillColor(30); c1_4->SetFrameFillColor(42); c1_5->SetFillColor(30); c1_5->SetFrameFillColor(42); c1_6->SetFillColor(30); c1_6->SetFrameFillColor(42); c1_1->cd(); TH1::AddDirectory(kFALSE); //A function to sample TF1 *fsin = new TF1("fsin", "sin(x)*sin(x)/(x*x)", 0, 4*TMath::Pi()); fsin->Draw(); Int_t n=25; TH1D *hsin = new TH1D("hsin", "hsin", n+1, 0, 4*TMath::Pi()); Double_t x; //Fill the histogram with function values for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); hsin->SetBinContent(i+1, fsin->Eval(x)); } hsin->Draw("same"); fsin->GetXaxis()->SetLabelSize(0.05); fsin->GetYaxis()->SetLabelSize(0.05); c1_2->cd(); //Compute the transform and look at the magnitude of the output TH1 *hm =0; TVirtualFFT::SetTransform(0); hm = hsin->FFT(hm, "MAG"); hm->SetTitle("Magnitude of the 1st transform"); hm->Draw(); //NOTE: for "real" frequencies you have to divide the x-axes range with the range of your function //(in this case 4*Pi); y-axes has to be rescaled by a factor of 1/SQRT(n) to be right: this is not done automatically! hm->SetStats(kFALSE); hm->GetXaxis()->SetLabelSize(0.05); hm->GetYaxis()->SetLabelSize(0.05); c1_3->cd(); //Look at the phase of the output TH1 *hp = 0; hp = hsin->FFT(hp, "PH"); hp->SetTitle("Phase of the 1st transform"); hp->Draw(); hp->SetStats(kFALSE); hp->GetXaxis()->SetLabelSize(0.05); hp->GetYaxis()->SetLabelSize(0.05); //Look at the DC component and the Nyquist harmonic: Double_t re, im; //That's the way to get the current transform object: TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform(); c1_4->cd(); //Use the following method to get just one point of the output fft->GetPointComplex(0, re, im); printf("1st transform: DC component: %f\n", re); fft->GetPointComplex(n/2+1, re, im); printf("1st transform: Nyquist harmonic: %f\n", re); //Use the following method to get the full output: Double_t *re_full = new Double_t[n]; Double_t *im_full = new Double_t[n]; fft->GetPointsComplex(re_full,im_full); //Now let's make a backward transform: TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &n, "C2R M K"); fft_back->SetPointsComplex(re_full,im_full); fft_back->Transform(); TH1 *hb = 0; //Let's look at the output hb = TH1::TransformHisto(fft_back,hb,"Re"); hb->SetTitle("The backward transform result"); hb->Draw(); //NOTE: here you get at the x-axes number of bins and not real values //(in this case 25 bins has to be rescaled to a range between 0 and 4*Pi; //also here the y-axes has to be rescaled (factor 1/bins) hb->SetStats(kFALSE); hb->GetXaxis()->SetLabelSize(0.05); hb->GetYaxis()->SetLabelSize(0.05); delete fft_back; fft_back=0; //********* Data array - same transform ********// //Allocate an array big enough to hold the transform output //Transform output in 1d contains, for a transform of size N, //N/2+1 complex numbers, i.e. 2*(N/2+1) real numbers //our transform is of size n+1, because the histogram has n+1 bins Double_t *in = new Double_t[2*((n+1)/2+1)]; Double_t re_2,im_2; for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fsin->Eval(x); } //Make our own TVirtualFFT object (using option "K") //Third parameter (option) consists of 3 parts: //-transform type: // real input/complex output in our case //-transform flag: // the amount of time spent in planning // the transform (see TVirtualFFT class description) //-to create a new TVirtualFFT object (option "K") or use the global (default) Int_t n_size = n+1; TVirtualFFT *fft_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K"); if (!fft_own) return; fft_own->SetPoints(in); fft_own->Transform(); //Copy all the output points: fft_own->GetPoints(in); //Draw the real part of the output c1_5->cd(); TH1 *hr = 0; hr = TH1::TransformHisto(fft_own, hr, "RE"); hr->SetTitle("Real part of the 3rd (array) tranfsorm"); hr->Draw(); hr->SetStats(kFALSE); hr->GetXaxis()->SetLabelSize(0.05); hr->GetYaxis()->SetLabelSize(0.05); c1_6->cd(); TH1 *him = 0; him = TH1::TransformHisto(fft_own, him, "IM"); him->SetTitle("Im. part of the 3rd (array) transform"); him->Draw(); him->SetStats(kFALSE); him->GetXaxis()->SetLabelSize(0.05); him->GetYaxis()->SetLabelSize(0.05); myc->cd(); //Now let's make another transform of the same size //The same transform object can be used, as the size and the type of the transform //haven't changed TF1 *fcos = new TF1("fcos", "cos(x)+cos(0.5*x)+cos(2*x)+1", 0, 4*TMath::Pi()); for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fcos->Eval(x); } fft_own->SetPoints(in); fft_own->Transform(); fft_own->GetPointComplex(0, re_2, im_2); printf("2nd transform: DC component: %f\n", re_2); fft_own->GetPointComplex(n/2+1, re_2, im_2); printf("2nd transform: Nyquist harmonic: %f\n", re_2); delete fft_own; delete [] in; delete [] re_full; delete [] im_full; }
void betaMS(Double_t z = 1000, const TString &opt="pdf") { gROOT->Reset(); PGlobals::Initialize(); // gStyle->SetPadTopMargin(0.10); // gStyle->SetPadRightMargin(0.05); // gStyle->SetPadBottomMargin(0.15); // gStyle->SetPadLeftMargin(0.15); Double_t E0 = 1000; // MeV Double_t gamma = E0/0.511; Double_t X0 = 35.0E4; // um (Berylium) Double_t sx0 = 10.0; // um Double_t emitxn = 1.00; // um Double_t emitx = emitxn/gamma; // um Double_t sd0 = 1000. * (emitx/sx0); // mrad Double_t kp = 0.0595; // um^-1 for n0 = 10^17 cm^-3 Double_t kbeta = kp/TMath::Sqrt(2 * gamma); Double_t betamatch = (1/kbeta) / 1000.; // mm TF1 *ftheta = new TF1("ftheta",theta,-0.01*z,z,4); ftheta->SetParameters(E0,X0,sx0,sd0); ftheta->SetParNames("Energy","X0","sx0","sd0"); ftheta->SetTitle(""); ftheta->GetXaxis()->SetTitle("#Deltaz [#mum]"); ftheta->GetYaxis()->SetTitle("#Theta_{0} [mrad]"); TF1 *fsigmax = new TF1("fsigmax",Sigmax,-0.01*z,z,4); fsigmax->SetParameters(E0,X0,sx0,sd0); fsigmax->SetParNames("Energy","X0","sx0","sd0"); fsigmax->SetTitle(""); fsigmax->GetXaxis()->SetTitle("#Deltaz [#mum]"); fsigmax->GetYaxis()->SetTitle("#sigma_{x} [#mum]"); TF1 *fsigmaxp = new TF1("fsigmaxp",Sigmaxp,-0.01*z,z,4); fsigmaxp->SetParameters(E0,X0,sx0,sd0); fsigmaxp->SetParNames("Energy","X0","sx0","sd0"); fsigmaxp->SetTitle(""); fsigmaxp->GetXaxis()->SetTitle("#Deltaz [#mum]"); fsigmaxp->GetYaxis()->SetTitle("#sigma_{x'} [mrad]"); TF1 *femit = new TF1("femit",emittance,-0.01*z,z,4); femit->SetParameters(E0,X0,sx0,sd0); femit->SetParNames("Energy","X0","sx0","sd0"); femit->SetTitle(""); femit->GetXaxis()->SetTitle("#Deltaz [#mum]"); femit->GetYaxis()->SetTitle("#epsilon_{x,n} [#mum]"); TF1 *fbeta = new TF1("fbeta",beta,-0.01*z,z,4); fbeta->SetParameters(E0,X0,sx0,sd0); fbeta->SetParNames("Energy","X0","sx0","sd0"); fbeta->SetTitle(""); fbeta->GetXaxis()->SetTitle("#Deltaz [#mum]"); fbeta->GetYaxis()->SetTitle("#beta [mm]"); TF1 *femitfin = new TF1("femitfin",finalemittance,-0.01*z,z,5); femitfin->SetParameters(E0,X0,sx0,sd0,betamatch); femitfin->SetParNames("Energy","X0","sx0","sd0","betam"); femitfin->SetTitle(""); femitfin->GetXaxis()->SetTitle("#Deltaz [#mum]"); femitfin->GetYaxis()->SetTitle("#epsilon_{x,n,F} [#mum]"); const UInt_t NPad = 6; TCanvas *C = new TCanvas("C","",640,1024); // Setup Pad layout: TPad **pad = new TPad*[NPad]; Float_t bMargin = 0.10; Float_t tMargin = 0.04; Float_t lMargin = 0.20; Float_t rMargin = 0.08; Float_t vSpacing = 0.017; PGlobals::CanvasPartition(C,NPad,lMargin,rMargin,bMargin,tMargin,vSpacing); // Define the frames for plotting Int_t fonttype = 43; Int_t fontsize = 22; Int_t tfontsize = 26; Float_t txoffset = 5.0; Float_t lxoffset = 0.02; Float_t tyoffset = 3.0; Float_t lyoffset = 0.01; Float_t tylength = 0.02; Float_t txlength = 0.04; TF1 *func[NPad]; func[5] = ftheta; func[4] = fsigmax; func[3] = fsigmaxp; func[2] = femit; func[1] = fbeta; func[0] = femitfin; for(Int_t i=0;i<NPad;i++) { char name[16]; sprintf(name,"pad_%i",i); pad[i] = (TPad*) gROOT->FindObject(name); pad[i]->SetFrameLineWidth(2); pad[i]->SetTickx(1); pad[i]->SetTicky(1); pad[i]->SetFillStyle(4000); pad[i]->SetFrameFillStyle(4000); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[i]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[i]->GetAbsHNDC(); // Format for y axis func[i]->GetYaxis()->SetTitleFont(fonttype); func[i]->GetYaxis()->SetTitleSize(tfontsize); func[i]->GetYaxis()->SetTitleOffset(tyoffset); func[i]->GetYaxis()->SetLabelFont(fonttype); func[i]->GetYaxis()->SetLabelSize(fontsize); func[i]->GetYaxis()->SetLabelOffset(lyoffset); func[i]->GetYaxis()->SetTickLength(xFactor*tylength/yFactor); func[i]->GetYaxis()->CenterTitle(); // Format for x axis func[i]->GetXaxis()->SetTitleFont(fonttype); func[i]->GetXaxis()->SetTitleSize(tfontsize+2); func[i]->GetXaxis()->SetTitleOffset(txoffset); func[i]->GetXaxis()->SetLabelFont(fonttype); func[i]->GetXaxis()->SetLabelSize(fontsize); func[i]->GetXaxis()->SetLabelOffset(lxoffset); func[i]->GetXaxis()->SetTickLength(yFactor*txlength/xFactor); func[i]->GetXaxis()->CenterTitle(); if(i>0) { func[i]->GetXaxis()->SetTitleSize(0.0); func[i]->GetXaxis()->SetLabelSize(0.0); } pad[i]->cd(); // pad[i]->SetLogy(1); func[i]->Draw("L"); } // Calculations: cout << Form(" Matched beta = %.4f mm", betamatch) << endl; Double_t iniemit0 = femit->Eval(0.0); Double_t inibeta0 = fbeta->Eval(0.0); Double_t inibetap0 = inibeta0/betamatch; Double_t finemit0 = iniemit0 * 0.5 * ( 1.0/inibetap0 + inibetap0); cout << Form(" Initial beta = %6.2f mm, emit = %6.2f um --> final emittance = %6.3f um %6.3f um ", inibeta0,iniemit0,finemit0,femitfin->Eval(0)) << endl; Double_t iniemitZ = femit->Eval(z); Double_t inibetaZ = fbeta->Eval(z); Double_t inibetapZ = inibetaZ/betamatch; Double_t finemitZ = iniemitZ * 0.5 * ( 1.0/inibetapZ + inibetapZ); cout << Form(" Initial beta = %6.2f mm, emit = %6.2f um --> final emittance = %6.3f um %6.3f um", inibetaZ,iniemitZ,finemitZ,femitfin->Eval(z) ) << endl; // Writing the figure TString fOutName = Form("./betaMS"); PGlobals::imgconv(C,fOutName,opt); // --------------------------------------------------------- PGlobals::DestroyCanvases(); }
void FFT() { // Histograms // ========= //prepare the canvas for drawing TCanvas *myc = new TCanvas("myc", "Fast Fourier Transform", 800, 600); myc->SetFillColor(45); TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.67,0.49,0.99); TPad *c1_2 = new TPad("c1_2", "c1_2",0.51,0.67,0.99,0.99); TPad *c1_3 = new TPad("c1_3", "c1_3",0.01,0.34,0.49,0.65); TPad *c1_4 = new TPad("c1_4", "c1_4",0.51,0.34,0.99,0.65); TPad *c1_5 = new TPad("c1_5", "c1_5",0.01,0.01,0.49,0.32); TPad *c1_6 = new TPad("c1_6", "c1_6",0.51,0.01,0.99,0.32); c1_1->Draw(); c1_2->Draw(); c1_3->Draw(); c1_4->Draw(); c1_5->Draw(); c1_6->Draw(); c1_1->SetFillColor(30); c1_1->SetFrameFillColor(42); c1_2->SetFillColor(30); c1_2->SetFrameFillColor(42); c1_3->SetFillColor(30); c1_3->SetFrameFillColor(42); c1_4->SetFillColor(30); c1_4->SetFrameFillColor(42); c1_5->SetFillColor(30); c1_5->SetFrameFillColor(42); c1_6->SetFillColor(30); c1_6->SetFrameFillColor(42); c1_1->cd(); TH1::AddDirectory(kFALSE); //A function to sample TF1 *fsin = new TF1("fsin", "sin(x)+sin(2*x)+sin(0.5*x)+1", 0, 4*TMath::Pi()); fsin->Draw(); Int_t n=25; TH1D *hsin = new TH1D("hsin", "hsin", n+1, 0, 4*TMath::Pi()); Double_t x; //Fill the histogram with function values for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); hsin->SetBinContent(i+1, fsin->Eval(x)); } hsin->Draw("same"); fsin->GetXaxis()->SetLabelSize(0.05); fsin->GetYaxis()->SetLabelSize(0.05); c1_2->cd(); //Compute the transform and look at the magnitude of the output TH1 *hm =0; TVirtualFFT::SetTransform(0); hm = hsin->FFT(hm, "MAG"); hm->SetTitle("Magnitude of the 1st transform"); hm->Draw(); //NOTE: for "real" frequencies you have to divide the x-axes range with the range of your function //(in this case 4*Pi); y-axes has to be rescaled by a factor of 1/SQRT(n) to be right: this is not done automatically! hm->SetStats(kFALSE); hm->GetXaxis()->SetLabelSize(0.05); hm->GetYaxis()->SetLabelSize(0.05); c1_3->cd(); //Look at the phase of the output TH1 *hp = 0; hp = hsin->FFT(hp, "PH"); hp->SetTitle("Phase of the 1st transform"); hp->Draw(); hp->SetStats(kFALSE); hp->GetXaxis()->SetLabelSize(0.05); hp->GetYaxis()->SetLabelSize(0.05); //Look at the DC component and the Nyquist harmonic: Double_t re, im; //That's the way to get the current transform object: TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform(); c1_4->cd(); //Use the following method to get just one point of the output fft->GetPointComplex(0, re, im); printf("1st transform: DC component: %f\n", re); fft->GetPointComplex(n/2+1, re, im); printf("1st transform: Nyquist harmonic: %f\n", re); //Use the following method to get the full output: Double_t *re_full = new Double_t[n]; Double_t *im_full = new Double_t[n]; fft->GetPointsComplex(re_full,im_full); //Now let's make a backward transform: TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &n, "C2R M K"); fft_back->SetPointsComplex(re_full,im_full); fft_back->Transform(); TH1 *hb = 0; //Let's look at the output hb = TH1::TransformHisto(fft_back,hb,"Re"); hb->SetTitle("The backward transform result"); hb->Draw(); //NOTE: here you get at the x-axes number of bins and not real values //(in this case 25 bins has to be rescaled to a range between 0 and 4*Pi; //also here the y-axes has to be rescaled (factor 1/bins) hb->SetStats(kFALSE); hb->GetXaxis()->SetLabelSize(0.05); hb->GetYaxis()->SetLabelSize(0.05); delete fft_back; fft_back=0; // Data array - same transform // =========================== //Allocate an array big enough to hold the transform output //Transform output in 1d contains, for a transform of size N, //N/2+1 complex numbers, i.e. 2*(N/2+1) real numbers //our transform is of size n+1, because the histogram has n+1 bins Double_t *in = new Double_t[2*((n+1)/2+1)]; Double_t re_2,im_2; for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fsin->Eval(x); } //Make our own TVirtualFFT object (using option "K") //Third parameter (option) consists of 3 parts: //- transform type: // real input/complex output in our case //- transform flag: // the amount of time spent in planning // the transform (see TVirtualFFT class description) //- to create a new TVirtualFFT object (option "K") or use the global (default) Int_t n_size = n+1; TVirtualFFT *fft_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K"); if (!fft_own) return; fft_own->SetPoints(in); fft_own->Transform(); //Copy all the output points: fft_own->GetPoints(in); //Draw the real part of the output c1_5->cd(); TH1 *hr = 0; hr = TH1::TransformHisto(fft_own, hr, "RE"); hr->SetTitle("Real part of the 3rd (array) tranfsorm"); hr->Draw(); hr->SetStats(kFALSE); hr->GetXaxis()->SetLabelSize(0.05); hr->GetYaxis()->SetLabelSize(0.05); c1_6->cd(); TH1 *him = 0; him = TH1::TransformHisto(fft_own, him, "IM"); him->SetTitle("Im. part of the 3rd (array) transform"); him->Draw(); him->SetStats(kFALSE); him->GetXaxis()->SetLabelSize(0.05); him->GetYaxis()->SetLabelSize(0.05); myc->cd(); //Now let's make another transform of the same size //The same transform object can be used, as the size and the type of the transform //haven't changed TF1 *fcos = new TF1("fcos", "cos(x)+cos(0.5*x)+cos(2*x)+1", 0, 4*TMath::Pi()); for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fcos->Eval(x); } fft_own->SetPoints(in); fft_own->Transform(); fft_own->GetPointComplex(0, re_2, im_2); printf("2nd transform: DC component: %f\n", re_2); fft_own->GetPointComplex(n/2+1, re_2, im_2); printf("2nd transform: Nyquist harmonic: %f\n", re_2); delete fft_own; delete [] in; delete [] re_full; delete [] im_full; }
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 fitBvar(TString collsyst="PbPb", TString inputfile ="", TString npfile="ROOTfiles/NPFitPbPb.root", float centMin=0, float centMax=100, TString outputfile="outHisto") { collisionsystem = collsyst; infname = outputfile; centmin = centMin; centmax = centMax; if(collsyst != "PbPb") isPbPb = false; gStyle->SetTextSize(0.05); gStyle->SetTextFont(42); gStyle->SetPadRightMargin(0.02); gStyle->SetPadLeftMargin(0.18); gStyle->SetPadTopMargin(0.09); gStyle->SetPadBottomMargin(0.145); gStyle->SetTitleX(.0f); TF1* fit (float ptmin, float ptmax, int s, int b, int widVar); // widVar=0,1 TCanvas* c = new TCanvas("c","",600,600); TF1* bmass = new TF1("bmass","[0]",7,50); bmass->SetTitle(";B^{+} p_{T} (GeV/c);fraction of default yield"); bmass->SetMinimum(0.9); bmass->SetMaximum(1.1); if(isPbPb) { bmass->SetMinimum(0.9); bmass->SetMaximum(1.1); } bmass->SetParameter(0,1); bmass->SetLineWidth(1); bmass->SetLineColor(kRed); bmass->SetLineStyle(2); bmass->GetXaxis()->SetTitleOffset(1.3); bmass->GetYaxis()->SetTitleOffset(1.8); bmass->GetXaxis()->SetLabelOffset(0.007); bmass->GetYaxis()->SetLabelOffset(0.007); bmass->GetXaxis()->SetTitleSize(0.045); bmass->GetYaxis()->SetTitleSize(0.045); bmass->GetXaxis()->SetTitleFont(42); bmass->GetYaxis()->SetTitleFont(42); bmass->GetXaxis()->SetLabelFont(42); bmass->GetYaxis()->SetLabelFont(42); bmass->GetXaxis()->SetLabelSize(0.04); bmass->GetYaxis()->SetLabelSize(0.04); bmass->Draw(); TLatex* Title = new TLatex(0.1,0.94, Form("Fit Variation for %s",collisionsystem.Data())); Title->SetNDC(); Title->SetTextAlign(12); Title->SetTextSize(0.04); Title->SetTextFont(42); Title->Draw("Same"); TLegend* leg = new TLegend(0.2,0.67,0.4,0.87,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); getNPFnPar(npfile, NPpar); std::cout<<"NP parameter 0: "<<NPpar[0]<<std::endl; std::cout<<"NP parameter 1: "<<NPpar[1]<<std::endl; TString inputf; if(nBins == 1) inputf = Form("%s_integrated.root",inputfile.Data()); else inputf = Form("%s.root",inputfile.Data()); TFile* data = new TFile(inputf.Data()); TH1D* h_def = (TH1D*)data->Get("hPt"); TH1D* hwidvar; int cnt =0; for(int s=0;s<nsig;s++) { bkgmax[0]=sigmax[s]+2; for(int b=0;b<nbkg;b++) { if(s==0 || b==0) { TH1D* hvar = new TH1D(Form("h_%s",bkgname[b].Data()),"",nBins,ptBins); if(s==0 && b==0) hwidvar = new TH1D("h_widvar","",nBins,ptBins); for(int i=0;i<nBins;i++) { double def_y = h_def->GetBinContent(i+1); double def_err = h_def->GetBinError(i+1); TF1* f = fit(ptBins[i],ptBins[i+1],s,b,0); cout<<"YIELD / YIELDERR: "<< yield <<" "<< yieldErr << endl; cout << "DEF YIELD: "<< def_y*(ptBins[i+1]-ptBins[i]) <<endl; double y = yield/(ptBins[i+1]-ptBins[i]); double err = yieldErr/(ptBins[i+1]-ptBins[i]); double y_fr = y/def_y; cout << "YIELD FRACTION: " << y_fr << endl; double err_fr = sqrt(pow(err/def_y,2)+pow(def_err*y/(def_y*def_y),2)); hvar->SetBinContent(i+1,y_fr); hvar->SetBinError(i+1,err_fr); hvar->SetMarkerStyle(8); hvar->SetMarkerColor(4+cnt); cnt++; if(s==0 && b==0) { f = fit(ptBins[i],ptBins[i+1],0,0,1); cout<<"YIELD / YIELDERR: "<< yield <<" "<< yieldErr << endl; cout << "DEF YIELD: "<< def_y*(ptBins[i+1]-ptBins[i]) <<endl; y = yield/(ptBins[i+1]-ptBins[i]); err = yieldErr/(ptBins[i+1]-ptBins[i]); y_fr = y/def_y; cout << "YIELD FRACTION: " << y_fr << endl; err_fr = sqrt(pow(err/def_y,2)+pow(def_err*y/(def_y*def_y),2)); hwidvar->SetBinContent(i+1,y_fr); hwidvar->SetBinError(i+1,err_fr); hwidvar->SetMarkerStyle(8); hwidvar->SetMarkerColor(3); } } c->cd(); hvar->Draw("Same"); if(s==0 && b==0) hwidvar->Draw("Same"); leg->AddEntry(hvar,Form("%s and %s",signame[s].Data(),bkgname[b].Data()),"pl"); if(s==0 && b==0) leg->AddEntry(hwidvar, "Width Variation", "pl"); } } } c->cd(); leg->Draw("Same"); if(nBins == 1) c->SaveAs(Form("SystPDF/total_var_%s.pdf",collisionsystem.Data())); else c->SaveAs(Form("SystPDF/var_%s.pdf",collisionsystem.Data())); }
void rsLimit7TeV(){ setTDRStyle(); //=========Macro generated from canvas: cLimit/Limit //========= (Mon Feb 22 22:44:48 2010) by ROOT version5.18/00a // TCanvas *cLimit = new TCanvas("cLimit", "Limit",450,40,800,550); // TCanvas *cLimit = new TCanvas("cLimit", "Limit",100,122,600,600); cLimit = new TCanvas("cLimit","cLimit",800,600); gStyle->SetOptStat(0); // cLimit->Range(595.5973,-0.03483694,1345.283,0.2539571); cLimit->SetFillColor(0); cLimit->SetBorderMode(0); cLimit->SetBorderSize(2); cLimit->SetLeftMargin(0.139262); cLimit->SetRightMargin(0.0604027); cLimit->SetTopMargin(0.0804196); cLimit->SetBottomMargin(0.120629); cLimit->SetFrameBorderMode(0); cLimit->SetFrameBorderMode(0); TGraph *graph = new TGraph(11); graph->SetName("Graph"); graph->SetTitle(""); graph->SetFillColor(1); Int_t ci; // for color index setting ci = TColor::GetColor("#ff0000"); graph->SetLineColor(ci); graph->SetLineWidth(3); ci = TColor::GetColor("#ff0000"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); graph->SetMarkerSize(1.0); graph->SetPoint(0, 863,0.01); graph->SetPoint(1, 1132,0.02); graph->SetPoint(2, 1274,0.03); graph->SetPoint(3, 1395,0.04); graph->SetPoint(4, 1503,0.05); graph->SetPoint(5, 1597,0.06); graph->SetPoint(6, 1676,0.07); graph->SetPoint(7, 1742,0.08); graph->SetPoint(8, 1801,0.09); graph->SetPoint(9, 1844,0.1); graph->SetPoint(10,1881,0.11); cout << " Don't forget to change this..." << endl; TH1 *Graph6 = new TH1F("Graph6","",100,863,1881); Graph6->SetMinimum(0); Graph6->SetMaximum(0.12); Graph6->SetDirectory(0); Graph6->SetStats(0); Graph6->GetXaxis()->SetTitle("M_{1} [GeV]"); Graph6->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); Graph6->GetXaxis()->SetLabelFont(42); Graph6->GetYaxis()->SetLabelFont(42); Graph6->GetYaxis()->SetTitleOffset(1.8); graph->SetHistogram(Graph6); graph->GetYaxis()->SetTitleOffset(1.19); graph->Draw("al"); TGraph* graph2 = new TGraph(11); graph2->SetMarkerColor(ci); graph2->SetMarkerStyle(20); graph2->SetMarkerSize(0.0); graph2->SetPoint(0, 845,0.01); graph2->SetPoint(1, 1133,0.02); graph2->SetPoint(2, 1275,0.03); graph2->SetPoint(3, 1396,0.04); graph2->SetPoint(4, 1504,0.05); graph2->SetPoint(5, 1598,0.06); graph2->SetPoint(6, 1677,0.07); graph2->SetPoint(7, 1743,0.08); graph2->SetPoint(8, 1801,0.09); graph2->SetPoint(9, 1844,0.1); graph2->SetPoint(10,1881,0.11); graph2->SetLineStyle(kDashed); graph2->SetLineColor(ci); graph2->SetLineWidth(3); graph2->GetXaxis()->SetLabelFont(42); graph2->GetYaxis()->SetLabelFont(42); graph2->Draw("plsame"); // graph = new TGraph(3); // graph->SetName("Graph"); // graph->SetTitle(""); // graph->SetFillColor(1); // ci = TColor::GetColor("#0000ff"); // graph->SetLineColor(ci); // graph->SetLineWidth(3); // ci = TColor::GetColor("#0000ff"); // graph->SetMarkerColor(ci); // graph->SetMarkerStyle(22); // graph->SetMarkerSize(1.4); // graph->SetPoint(0,750,0.03355478); // graph->SetPoint(1,1000,0.07617687); // graph->SetPoint(2,1250,0.1542326); // TH1 *Graph7 = new TH1F("Graph7","",100,700,1300); // Graph7->SetMinimum(0.021487); // Graph7->SetMaximum(0.1663004); // Graph7->SetDirectory(0); // Graph7->SetStats(0); // Graph7->GetXaxis()->SetTitle("Graviton Mass (GeV)"); // Graph7->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); // graph->SetHistogram(Graph7); // graph->Draw("pc"); // graph = new TGraph(3); // graph->SetName("Graph"); // graph->SetTitle(""); // graph->SetFillColor(1); // ci = TColor::GetColor("#00ff00"); // graph->SetLineColor(ci); // graph->SetLineWidth(3); // ci = TColor::GetColor("#00ff00"); // graph->SetMarkerColor(ci); // graph->SetMarkerStyle(21); // graph->SetMarkerSize(1.3); // graph->SetPoint(0,750,0.02431275); // graph->SetPoint(1,1000,0.05519538); // graph->SetPoint(2,1250,0.1117521); // TH1 *Graph8 = new TH1F("Graph8","",100,700,1300); // Graph8->SetMinimum(0.01556881); // Graph8->SetMaximum(0.1204961); // Graph8->SetDirectory(0); // Graph8->SetStats(0); // Graph8->GetXaxis()->SetTitle("Graviton Mass (GeV/c^{2})"); // Graph8->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); // graph->SetHistogram(Graph8); // graph->Draw("pc"); // TF1 *LambdaPi = new TF1("LambdaPi","pol1",500,2500); // LambdaPi->SetFillColor(15); // LambdaPi->SetFillStyle(3004); // LambdaPi->SetLineColor(15); // LambdaPi->SetLineWidth(1); // LambdaPi->SetParameter(0,0); // LambdaPi->SetParError(0,0); // LambdaPi->SetParLimits(0,0,0); // LambdaPi->SetParameter(1,2.61097e-05); // LambdaPi->SetParError(1,0); // LambdaPi->SetParLimits(1,0,0); // LambdaPi->Draw("same"); // TF1 *LambdaPi = new TF1("LambdaPi","pol1",250,2500); LambdaPi->SetFillColor(15); LambdaPi->SetFillStyle(3004); LambdaPi->SetLineColor(15); LambdaPi->SetLineWidth(1); LambdaPi->SetParameter(0,0); LambdaPi->SetParError(0,0); LambdaPi->SetParLimits(0,0,0); LambdaPi->SetParameter(1,2.61097e-05); LambdaPi->SetParError(1,0); LambdaPi->SetParLimits(1,0,0); LambdaPi->GetXaxis()->SetLabelFont(42); LambdaPi->GetYaxis()->SetLabelFont(42); LambdaPi->Draw("same"); graph = new TGraph(27); graph->SetName("Graph"); graph->SetTitle("Graph"); graph->SetFillColor(1); graph->SetFillStyle(3004); graph->SetLineStyle(5); graph->SetLineWidth(3); graph->SetPoint(0,180,0.1071); graph->SetPoint(1,183,0.1062); graph->SetPoint(2,190,0.1043); graph->SetPoint(3,200,0.1016); graph->SetPoint(4,210,0.0989); graph->SetPoint(5,220,0.0963); graph->SetPoint(6,230,0.0938); graph->SetPoint(7,240,0.0913); graph->SetPoint(8,250,0.0889); graph->SetPoint(9,260,0.0866); graph->SetPoint(10,270,0.0843); graph->SetPoint(11,280,0.0821); graph->SetPoint(12,290,0.0799); graph->SetPoint(13,300,0.0778); graph->SetPoint(14,400,0.0603); graph->SetPoint(15,500,0.0481); graph->SetPoint(16,600,0.0397); graph->SetPoint(17,700,0.0337); graph->SetPoint(18,800,0.0292); graph->SetPoint(19,900,0.0258); graph->SetPoint(20,1000,0.0231); graph->SetPoint(21,1100,0.0209); graph->SetPoint(22,1200,0.0191); graph->SetPoint(23,1300,0.0176); graph->SetPoint(24,1400,0.0163); graph->SetPoint(25,1500,0.0152); graph->SetPoint(26,2200,0.01); graph->GetXaxis()->SetLabelFont(42); graph->GetYaxis()->SetLabelFont(42); graph->SetFillColor(kBlack); graph->SetFillStyle(3004); graph->SetLineWidth(1); graph->SetFillStyle(3002); graph->SetFillColor(kBlack); graph->SetLineWidth(-10000); graph->Draw("c"); // graph->Draw("same"); // TPaveText *pt = new TPaveText(0.194631,0.748252,0.436242,0.816434,"blNDC"); // pt->SetName("95% CL Limit"); // pt->SetFillColor(0); // pt->SetBorderSize(1); // pt->SetLineColor(0); // pt->SetTextSize(0.04); // TText *text = pt->AddText("95% CL Limit"); // pt->Draw(); TLegend *leg = new TLegend(0.2072864,0.4667832,0.4007538,0.7517483,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2072864,0.5332168,0.4007538,0.7517483,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2110553,0.4248252,0.4120603,0.6433566,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2181208,0.5297203,0.4194631,0.7482517,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetTextFont(62); leg->SetTextSize(0.05); leg->SetLineColor(0); leg->SetLineStyle(0); leg->SetLineWidth(0); leg->SetFillColor(0); leg->SetFillStyle(0); // TLegendEntry *entry=leg->AddEntry("graph","50/pb","pl"); // ci = TColor::GetColor("#ff0000"); // entry->SetLineColor(ci); // entry->SetLineStyle(1); // entry->SetLineWidth(3); entry=leg->AddEntry("graph","Electroweak Limits","lf"); entry->SetLineColor(1); entry->SetLineStyle(5); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); ci = TColor::GetColor("#ff0000"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1.3); entry=leg->AddEntry("Graph","95% CL Limit","l"); leg->AddEntry(graph2,"Expected Limit","l"); ci = TColor::GetColor("#00ff00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1.3); // entry=leg->AddEntry("LambdaPi","#Lambda_{#pi}> 10TeV","lf"); entry=leg->AddEntry("LambdaPi","M_{D} > 10TeV","lf"); // entry->SetFillColor(15); // entry->SetFillStyle(3004); // entry->SetLineColor(15); // entry->SetLineStyle(1); // entry->SetLineWidth(1); // entry->SetMarkerColor(1); // entry->SetMarkerStyle(1); // entry->SetMarkerSize(1); leg->Draw(); TPaveText *pt = new TPaveText(0.2236181,0.7884615,0.4736181,0.8583916,"blNDC"); // TPaveText *pt = new TPaveText(0.1959799,0.7954545,0.4459799,0.8653846,"blNDC"); // TPaveText *pt = new TPaveText(0.2130872,0.8339161,0.4630872,0.9038462,"blNDC"); pt->SetName("CMS Preliminary"); pt->SetBorderSize(1); pt->SetLineColor(0); pt->SetFillColor(0); // pt->SetTextFont(72); pt->SetTextSize(0.06); text = pt->AddText("CMS Preliminary"); pt->Draw(); pt = new TPaveText(0.629397,0.798951,0.8002513,0.8653846,"blNDC"); // pt = new TPaveText(0.6005025,0.8059441,0.7713568,0.8723776,"blNDC"); // pt = new TPaveText(0.2738693,0.7027972,0.4447236,0.7692308,"blNDC"); // pt = new TPaveText(0.2416107,0.7727273,0.4127517,0.8391608,"blNDC"); pt->SetFillColor(0); pt->SetBorderSize(1); pt->SetLineColor(0); pt->SetTextSize(0.06); text = pt->AddText("2.2 fb^{-1} at 7 TeV"); pt->Draw(); // pt = new TPaveText(0.6879195,0.8129371,0.7885906,0.9108392,"blNDC"); // pt->SetFillColor(0); // pt->SetBorderSize(1); // pt->SetLineColor(0); // pt->SetTextSize(0.0454545); // text = pt->AddText("L = 1091 pb^{-1}"); // pt->Draw(); cLimit->Modified(); cLimit->cd(); cLimit->SetSelected(cLimit); }
Float_t FitOmega(TH1D *hist, char *plotFilePrefix) { Float_t fPeak, fWidth, SumLo, SumHi; Float_t xLo = 0.5; // lower value of x-axis for drawing histogram Float_t xHi = 1.0; // upper value of x-axis for drawing histogram Float_t PeakLo = 0.7; // lower limit on the peak range Float_t PeakHi = 0.9; // upper limit on the peak range Float_t Nsigma = 3.0; // number of sigma of the peak Int_t ibg = 3; // parameter index in the par[] array where the background parameters start Int_t i, j, k; Float_t x, pval; Float_t yield; cout << "Fitting histogram " << hist->GetName() << endl; TH1D *hBgFit; // histogram of background // create canvas char title[100]; char xtitle[100]; char ytitle[100]; sprintf(title,"Fitting Analysis"); // canvas title TCanvas *can1 = new TCanvas("can1",title,0,0,600,600); // create the canvas // gStyle->SetOptStat(1111); gStyle->SetOptFit(1111); can1->SetBorderMode(0); //Bordermode (-1=down, 0 = no border, 1=up) can1->SetBorderSize(5); can1->SetFillStyle(4000); can1->Divide(2,2); sprintf(xtitle,"Invariant Mass (GeV)"); // set the x-axis title sprintf(ytitle,"Counts"); // set the y-axis title // histogram of background hBgFit = (TH1D*)hist->Clone("hBgFit"); // clone original hist. into background temp. hist. hBgFit->SetName("hBgFit"); hBgFit->SetTitle("Background"); // fit the histogram Double_t par[7]={1.0,0.782,1.0,1.0,1.0,1.0,1.0}; TF1 *g1 = new TF1("g1",gaussFit,PeakLo,PeakHi,3); // declare fit fcn TF1 *pol = new TF1("pol",polFit,xLo,xHi,4); TF1 *t1 = new TF1("t1",totFit,xLo,xHi,7); can1->cd(1); g1->SetParameters(&par[0]); // set parameters for initial peak fit hist->Fit("g1","WR"); // fit the peak g1->GetParameters(&par[0]); // get parameters from initial peak fit g1->Draw("same"); can1->cd(2); hist->Fit("pol","WR+"); // fit the background pol->GetParameters(&par[ibg]); // get parameters fromt background fit pol->Draw("same"); t1->SetParameters(par); // set the parameters from initial fits for total fit t1->SetLineWidth(5); // make fit line thicker t1->SetLineColor(1); // set the fit line color can1->cd(3); hist->Fit("t1","R"); // fit spectrum with total fit function t1->GetParameters(&par[0]); //get final parameters can1->cd(); fPeak = t1->GetParameter(1); // get peak centroid fWidth = t1->GetParameter(2); // get peak width SumLo = fPeak - Nsigma*fWidth; // calc lower edge at Nsigma away from centroid SumHi = fPeak + Nsigma*fWidth; // calc upper edge at Nsigma away from centroid cout << "fPeak: " << fPeak << endl; pol->SetParameters(&par[ibg]); // set the pfinal parameters for the background function hBgFit->Add(pol,-1.0); // subtract background function for(k=1; k<hBgFit->GetNbinsX(); k++){ x = hBgFit->GetBinCenter(k); // read bin center value on the x-axis if(x>=SumLo && x<=SumHi){ // check that x is in the peak summation region pval = hBgFit->GetBinContent(k); // get the number of counts in the bin if(pval<0.0) pval = 0.0; // if neg. counts, set to zero }else{ pval =0.0; } hBgFit->SetBinContent(k,pval); // refill the histogram } yield = hBgFit->Integral(hBgFit->FindBin(SumLo),hBgFit->FindBin(SumHi)); // sum total counts in peak //g1, pol, t1 TODO Double_t binWidth = hist->GetXaxis()->GetBinWidth(0); cout << "Bin width: " << binWidth << endl; cout << "SumLo: " << SumLo << "\nSumHi: " << SumHi << endl; TCanvas *can2 = new TCanvas("can2","Fit Functions",0,0,600,600); // create the canvas can2->Divide(2); can2->cd(1); g1->GetXaxis()->SetRangeUser(SumLo,SumHi); g1->Draw(); can2->cd(2); pol->GetXaxis()->SetRangeUser(SumLo,SumHi); pol->Draw(); Double_t peakSum = g1->Integral(SumLo,SumHi); Double_t bgSum = pol->Integral(SumLo,SumHi); cout << "Counts above peak: " << (peakSum-bgSum)/binWidth << endl; cout << "Counts below peak: " << bgSum/binWidth << endl; // set up the Pad parameters gPad->SetLeftMargin(Lmar); gPad->SetRightMargin(Rmar); gPad->SetFillColor(0); // draw the original histogram hist->SetTitle(0); hist->GetXaxis()->SetTitle(xtitle); hist->GetXaxis()->CenterTitle(); hist->GetYaxis()->SetTitle(ytitle); hist->GetYaxis()->CenterTitle(); hist->GetYaxis()->SetTitleOffset(yoff); // hist->GetXaxis()->SetRangeUser(xLo,xHi); // set the x-axis range for the plot hist->SetLineWidth(2); hist->SetMinimum(0); // start the y-axis at zero. // hist->Draw(); // draw the background-subtracted histogram hBgFit->SetLineWidth(2); hBgFit->SetFillColor(4); // hBgFit->Draw("same"); // create the image files char OutCan[100]; sprintf(OutCan,"%s.gif",plotFilePrefix); can1->Print(OutCan); sprintf(OutCan,"%s.eps",plotFilePrefix); can1->Print(OutCan); // can1->Close(); return yield; }
void compare_cent(bool bSavePlots = true, bool bDoDebug = 1, // adds some numbers, numerator, denominator, to help figure out if things are read properly int whichCompare = 1,//0: no TnP corrections; 1: w/ TnP corr on Data; 2: w/ TnP corr on MC; 3: lxy w/ TnP on MC const char* inputDir = "../readFitTable", // the place where the input root files, with the histograms are const char* outputDir = "figs/compare")// where the output figures will be { gSystem->mkdir(Form("./%s/png",outputDir), kTRUE); gSystem->mkdir(Form("./%s/pdf",outputDir), kTRUE); // set the style setTDRStyle(); // type of available comparisons: const char* compWhat[4] = {"noTnP","dataTnP","mcTnP","lxyTnP"}; const int nInHist = 5; const char* yieldHistNames[nInHist] = {"cent","y012Cent", "y1216Cent", "y1624Cent", "y1624LowPtCent"}; //----------------------------------------- // input files: are in the filesRaa_2015.h // open the files with yields and do the math // default is TnP on data with Lxyz TFile *fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[0])); TFile *fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[1])); TFile *fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[0])); TFile *fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[1])); TFile *fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile[0])); TFile *fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile[1])); switch(whichCompare) { case 0: cout << "You are making Raa, with NOT TnP corrections whatsoever!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[1])); fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[0])); fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[1])); break; case 2: cout << "You are making Raa, with TnP corrections applied on MC!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[1])); break; case 3: cout << "You are making Raa, with Lxy and TnP corrections applie on MC!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[1])); break; case 1: default: cout<<" You are doing Raa Nominal: TnP on data!"<<endl; break; } if (!fYesWeighFile_aa->IsOpen() || !fYesWeighFile_pp->IsOpen()|| !fNoWeighFile_aa->IsOpen() || !fNoWeighFile_pp->IsOpen() || !fEffFile_aa->IsOpen() || !fEffFile_pp->IsOpen()) { cout << "One or more input files are missing" << endl; return ; } //------------------------------------------------------------------------------------ TH1F *phRaw_pr_pp; TH1F *phCorr_pr_pp; TH1F *phEff_pr_pp; TH1F *phRaw_pr_aa; TH1F *phCorr_pr_aa; TH1F *phEff_pr_aa; TH1F *phRaw_npr_pp; TH1F *phCorr_npr_pp; TH1F *phEff_npr_pp; TH1F *phRaw_npr_aa; TH1F *phCorr_npr_aa; TH1F *phEff_npr_aa; // to store the ratio of ev-by-ev and traditionally corrected yields in each case TH1F *ahRatio_pr_pp[nInHist]; TH1F *ahRatio_npr_pp[nInHist]; TH1F *ahRatio_pr_aa[nInHist]; TH1F *ahRatio_npr_aa[nInHist]; for(int ih=0; ih<nInHist; ih++) // for each kinematic range { TString hist_pr(Form("phPrp_%s",yieldHistNames[ih])); TString hist_npr(Form("phNPrp_%s",yieldHistNames[ih])); cout<<"histogram input name: "<< hist_pr<<"\t"<<hist_npr<<endl; // prompt histos phRaw_pr_pp = (TH1F*)fNoWeighFile_pp->Get(hist_pr); phCorr_pr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_pr); phRaw_pr_aa = (TH1F*)fNoWeighFile_aa->Get(hist_pr); phCorr_pr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_pr); // non-prompt histos phRaw_npr_pp = (TH1F*)fNoWeighFile_pp->Get(hist_npr); phCorr_npr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_npr); phRaw_npr_aa = (TH1F*)fNoWeighFile_aa->Get(hist_npr); phCorr_npr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_npr); // efficiency histos phEff_pr_pp = (TH1F*)fEffFile_pp->Get(hist_pr); phEff_npr_pp = (TH1F*)fEffFile_pp->Get(hist_npr); phEff_pr_aa = (TH1F*)fEffFile_aa->Get(hist_pr); phEff_npr_aa = (TH1F*)fEffFile_aa->Get(hist_npr); //--------------- corrected yields in the traditional way (simple division for the moment) // store the yield_Ratio histos: ev_by_ev/(raw*eff), ahRatio_pr_pp[ih] = (TH1F *)phCorr_pr_pp->Clone(); ahRatio_pr_pp[ih]->SetDirectory(0); ahRatio_pr_pp[ih]->Divide(phRaw_pr_pp); if (whichCompare != 0) // tnp comp shouldn't have eff correction ahRatio_pr_pp[ih]->Multiply(phEff_pr_pp);// correct the raw with it's efficiency ahRatio_npr_pp[ih] = (TH1F *)phCorr_npr_pp->Clone(); ahRatio_npr_pp[ih]->SetDirectory(0); ahRatio_npr_pp[ih]->Divide(phRaw_npr_pp); if (whichCompare != 0) // tnp comp shouldn't have eff correction ahRatio_npr_pp[ih]->Multiply(phEff_npr_pp); ahRatio_pr_aa[ih] = (TH1F *)phCorr_pr_aa->Clone(); ahRatio_pr_aa[ih]->SetDirectory(0); ahRatio_pr_aa[ih]->Divide(phRaw_pr_aa); if (whichCompare != 0) // tnp comp shouldn't have eff correction ahRatio_pr_aa[ih]->Multiply(phEff_pr_aa); ahRatio_npr_aa[ih] = (TH1F *)phCorr_npr_aa->Clone(); ahRatio_npr_aa[ih]->SetDirectory(0); ahRatio_npr_aa[ih]->Divide(phRaw_npr_aa); if (whichCompare != 0) // tnp comp shouldn't have eff correction ahRatio_npr_aa[ih]->Multiply(phEff_npr_aa); double scaleFactor = ppLumi/nMbEvents; int numBins = 0; if(ih==0) numBins = nBinsNpart12; if(ih==4) numBins = nBinsNpart6; if(ih==1 || ih==2 || ih==3) numBins = nBinsNpart6; for(int ibin=1; ibin<=numBins; ibin++) { double raa_pr=0, raaErr_pr=0, raa_npr=0, raaErr_npr=0; double raaTrad_pr=0, raaTradErr_pr=0, raaTrad_npr=0, raaTradErr_npr=0; double scale_cent = 1; double scale_cent_np = 1; if(ih==0) { scale_cent = 1/(adTaa12[ibin-1]*adDeltaCent12[ibin-1]); scale_cent_np = 1/(adTaa6[ibin-1]*adDeltaCent6[ibin-1]); } if(ih==4) scale_cent = 1/(adTaa6[ibin-1]*adDeltaCent6[ibin-1]); if(ih!=0 && ih!=4) scale_cent = 1/(adTaa6[ibin-1]*adDeltaCent6[ibin-1]); //prompt double dRelErrRaw_pr_pp = phRaw_pr_pp->GetBinError(ibin)/phRaw_pr_pp->GetBinContent(ibin); double dRelErrRaw_pr_aa = phRaw_pr_aa->GetBinError(ibin)/phRaw_pr_aa->GetBinContent(ibin); double yieldRatio_pr = phCorr_pr_aa->GetBinContent(ibin)/phCorr_pr_pp->GetBinContent(ibin); double yieldRatioTrad_pr = (phRaw_pr_aa->GetBinContent(ibin)/phRaw_pr_pp->GetBinContent(ibin)); if (whichCompare != 0) // tnp comp shouldn't have eff correction yieldRatioTrad_pr *= (phEff_pr_pp->GetBinContent(ibin)/phEff_pr_aa->GetBinContent(ibin)); raa_pr = yieldRatio_pr * scaleFactor * scale_cent; raaErr_pr = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raa_pr; raaTrad_pr = yieldRatioTrad_pr * scaleFactor * scale_cent; raaTradErr_pr = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raaTrad_pr; //non-prompt // get the rel uncert from the raw sample double dRelErrRaw_npr_pp = phRaw_npr_pp->GetBinError(ibin)/phRaw_npr_pp->GetBinContent(ibin); double dRelErrRaw_npr_aa = phRaw_npr_aa->GetBinError(ibin)/phRaw_npr_aa->GetBinContent(ibin); double yieldRatio_npr = phCorr_npr_aa->GetBinContent(ibin)/phCorr_npr_pp->GetBinContent(ibin); double yieldRatioTrad_npr = (phRaw_npr_aa->GetBinContent(ibin)/phRaw_npr_pp->GetBinContent(ibin)); if (whichCompare != 0) // tnp comp shouldn't have eff correction yieldRatioTrad_npr *= (phEff_npr_pp->GetBinContent(ibin)/phEff_npr_aa->GetBinContent(ibin)); if(ih==0) { raa_npr = yieldRatio_npr * scaleFactor * scale_cent_np;// the 1D nonPr has 6 bins only raaTrad_npr = yieldRatioTrad_npr * scaleFactor * scale_cent_np; } else { raa_npr = yieldRatio_npr * scaleFactor * scale_cent; raaTrad_npr = yieldRatioTrad_npr * scaleFactor * scale_cent; } raaErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raa_npr; raaTradErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raaTrad_npr; // fill the corresponding array switch(ih) { case 0: prJpsi_cent[ibin-1] = raa_pr; prJpsiErr_cent[ibin-1] = raaErr_pr; nonPrJpsi_cent[ibin-1] = raa_npr; nonPrJpsiErr_cent[ibin-1] = raaErr_npr; prJpsiTrad_cent[ibin-1] = raaTrad_pr; prJpsiTradErr_cent[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_cent[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_cent[ibin-1] = raaTradErr_npr; if(bDoDebug) { if (whichCompare != 0) // tnp comp shouldn't have eff correction cout<<"weight_pr_aa = "<<phEff_pr_aa->GetBinContent(ibin)<<"\t weight_pr_pp = "<<phEff_pr_pp->GetBinContent(ibin)<<endl; cout<<"yield_pr_aa "<<phCorr_pr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_pr_pp->GetBinContent(ibin)<<endl; cout<<"pr_aa= "<<phRaw_pr_aa->GetBinContent(ibin)/phEff_pr_aa->GetBinContent(ibin)<<"\t pr_pp= "<<phRaw_pr_pp->GetBinContent(ibin)/phEff_pr_pp->GetBinContent(ibin)<<endl; // cout<<setprecision(2); cout<<"!!!!! raa = "<<prJpsi_cent[ibin-1]<<endl; // cout<<"Scale_Cent= "<<scale_cent<<endl; } break; case 1: prJpsi_pt6530y012_cent[ibin-1] = raa_pr; prJpsiErr_pt6530y012_cent[ibin-1] = raaErr_pr; nonPrJpsi_pt6530y012_cent[ibin-1] = raa_npr; nonPrJpsiErr_pt6530y012_cent[ibin-1] = raaErr_npr; prJpsiTrad_pt6530y012_cent[ibin-1] = raaTrad_pr; prJpsiTradErr_pt6530y012_cent[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_pt6530y012_cent[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_pt6530y012_cent[ibin-1] = raaTradErr_npr; break; case 2: prJpsi_pt6530y1216_cent[ibin-1] = raa_pr; prJpsiErr_pt6530y1216_cent[ibin-1] = raaErr_pr; nonPrJpsi_pt6530y1216_cent[ibin-1] = raa_npr; nonPrJpsiErr_pt6530y1216_cent[ibin-1] = raaErr_npr; prJpsiTrad_pt6530y1216_cent[ibin-1] = raaTrad_pr; prJpsiTradErr_pt6530y1216_cent[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_pt6530y1216_cent[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_pt6530y1216_cent[ibin-1] = raaTradErr_npr; break; case 3: prJpsi_pt6530y1624_cent[ibin-1] = raa_pr; prJpsiErr_cent[ibin-1] = raaErr_pr; nonPrJpsi_pt6530y1624_cent[ibin-1] = raa_npr; nonPrJpsiErr_pt6530y1624_cent[ibin-1] = raaErr_npr; prJpsiTrad_pt6530y1624_cent[ibin-1] = raaTrad_pr; prJpsiTradErr_pt6530y1624_cent[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_pt6530y1624_cent[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_pt6530y1624_cent[ibin-1] = raaTradErr_npr; if(bDoDebug) { cout<<"yield_npr_aa: raw "<<phRaw_npr_aa->GetBinContent(ibin)<<"\t eff: "<<phEff_npr_aa->GetBinContent(ibin)<<endl; cout<<"yield_npr_aa: corr "<<phCorr_npr_aa->GetBinContent(ibin)<<endl; cout<<"yield_npr_pp: raw "<<phRaw_npr_pp->GetBinContent(ibin)<<"\t eff: "<<phEff_npr_pp->GetBinContent(ibin)<<endl; cout<<"yield_npr_pp: corr "<<phCorr_npr_pp->GetBinContent(ibin)<<endl; // cout<<setprecision(2); cout<<"!!!!! raa = "<<prJpsi_cent[ibin-1]<<endl; // cout<<"Scale_Cent= "<<scale_cent<<endl; } break; case 4: prJpsi_pt365y1624_cent[ibin-1] = raa_pr; prJpsiErr_pt365y1624_cent[ibin-1] = raaErr_pr; nonPrJpsi_pt365y1624_cent[ibin-1] = raa_npr; nonPrJpsiErr_pt365y1624_cent[ibin-1] = raaErr_npr; prJpsiTrad_pt365y1624_cent[ibin-1] = raaTrad_pr; prJpsiTradErr_pt365y1624_cent[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_pt365y1624_cent[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_pt365y1624_cent[ibin-1] = raaTradErr_npr; if(bDoDebug) { cout<<"yield_npr_aa: raw "<<phRaw_npr_aa->GetBinContent(ibin)<<"\t eff: "<<phEff_npr_aa->GetBinContent(ibin)<<endl; cout<<"yield_npr_aa: corr "<<phCorr_npr_aa->GetBinContent(ibin)<<endl; cout<<"yield_npr_pp: raw "<<phRaw_npr_pp->GetBinContent(ibin)<<"\t eff: "<<phEff_npr_pp->GetBinContent(ibin)<<endl; cout<<"yield_npr_pp: corr "<<phCorr_npr_pp->GetBinContent(ibin)<<endl; // cout<<setprecision(2); cout<<"!!!!! raa = "<<prJpsi_cent[ibin-1]<<endl; // cout<<"Scale_Cent= "<<scale_cent<<endl; } break; } }//loop end: for(int ibin=1; ibin<=numBins; ibin++) }//loop end: for(int ih=0; ih<nInHist;ih++) // ***** //Drawing // pr TGraphErrors *gPrJpsi = new TGraphErrors(nBinsNpart12, binsNpart12, prJpsi_cent, binsNpart12Err, prJpsiErr_cent); TGraphErrors *gPrJpsi_pt6530y012 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftMinus, prJpsi_pt6530y012_cent, binsNpart6Err, prJpsiErr_pt6530y012_cent); TGraphErrors *gPrJpsi_pt6530y1216 = new TGraphErrors(nBinsNpart6, binsNpart6, prJpsi_pt6530y1216_cent, binsNpart6Err, prJpsiErr_pt6530y1216_cent); TGraphErrors *gPrJpsi_pt6530y1624 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftPlus, prJpsi_pt6530y1624_cent, binsNpart6Err, prJpsiErr_pt6530y1624_cent); TGraphErrors *gPrJpsi_pt365y1624 = new TGraphErrors(nBinsNpart6, binsNpart6, prJpsi_pt365y1624_cent, binsNpart6Err, prJpsiErr_pt365y1624_cent); // nonPr TGraphErrors *gNonPrJpsi = new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsi_cent, binsNpart6Err, nonPrJpsiErr_cent); TGraphErrors *gNonPrJpsi_pt6530y012 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftMinus,nonPrJpsi_pt6530y012_cent, binsNpart6Err, nonPrJpsiErr_pt6530y012_cent); TGraphErrors *gNonPrJpsi_pt6530y1216 = new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsi_pt6530y1216_cent, binsNpart6Err, nonPrJpsiErr_pt6530y1216_cent); TGraphErrors *gNonPrJpsi_pt6530y1624 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftPlus, nonPrJpsi_pt6530y1624_cent, binsNpart6Err, nonPrJpsiErr_pt6530y1624_cent); TGraphErrors *gNonPrJpsi_pt365y1624 = new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsi_pt365y1624_cent, binsNpart6Err, nonPrJpsiErr_pt365y1624_cent); //-------------------------- traditional stuff // pr TGraphErrors *gPrJpsiTrad = new TGraphErrors(nBinsNpart12, binsNpart12, prJpsiTrad_cent, binsNpart12Err, prJpsiTradErr_cent); TGraphErrors *gPrJpsiTrad_pt6530y012 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftMinus, prJpsiTrad_pt6530y012_cent, binsNpart6Err, prJpsiTradErr_pt6530y012_cent); TGraphErrors *gPrJpsiTrad_pt6530y1216 = new TGraphErrors(nBinsNpart6, binsNpart6, prJpsiTrad_pt6530y1216_cent, binsNpart6Err, prJpsiTradErr_pt6530y1216_cent); TGraphErrors *gPrJpsiTrad_pt6530y1624 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftPlus, prJpsiTrad_pt6530y1624_cent, binsNpart6Err, prJpsiTradErr_pt6530y1624_cent); TGraphErrors *gPrJpsiTrad_pt365y1624 = new TGraphErrors(nBinsNpart6, binsNpart6, prJpsiTrad_pt365y1624_cent, binsNpart6Err, prJpsiTradErr_pt365y1624_cent); // nonPr TGraphErrors *gNonPrJpsiTrad = new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsiTrad_cent, binsNpart6Err, nonPrJpsiErr_cent); TGraphErrors *gNonPrJpsiTrad_pt6530y012 = new TGraphErrors(nBinsNpart6, binsNpart6_shiftMinus,nonPrJpsiTrad_pt6530y012_cent, binsNpart6Err, nonPrJpsiTradErr_pt6530y012_cent); TGraphErrors *gNonPrJpsiTrad_pt6530y1216= new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsiTrad_pt6530y1216_cent, binsNpart6Err, nonPrJpsiTradErr_pt6530y1216_cent); TGraphErrors *gNonPrJpsiTrad_pt6530y1624= new TGraphErrors(nBinsNpart6, binsNpart6_shiftPlus, nonPrJpsiTrad_pt6530y1624_cent, binsNpart6Err, nonPrJpsiTradErr_pt6530y1624_cent); TGraphErrors *gNonPrJpsiTrad_pt365y1624 = new TGraphErrors(nBinsNpart6, binsNpart6, nonPrJpsiTrad_pt365y1624_cent, binsNpart6Err, nonPrJpsiTradErr_pt365y1624_cent); //------------------------------------------------------------------- // **************** marker colors gPrJpsi->SetMarkerColor(kRed); gPrJpsi_pt6530y012->SetMarkerColor(kAzure+7); gPrJpsi_pt6530y1216->SetMarkerColor(kRed); gPrJpsi_pt6530y1624->SetMarkerColor(kGreen+2); gPrJpsi_pt365y1624->SetMarkerColor(kViolet+2); // non-prompt gNonPrJpsi->SetMarkerColor(kOrange+2); gNonPrJpsi_pt6530y012->SetMarkerColor(kAzure+7); gNonPrJpsi_pt6530y1216->SetMarkerColor(kRed); gNonPrJpsi_pt6530y1624->SetMarkerColor(kGreen+2); gNonPrJpsi_pt365y1624->SetMarkerColor(kViolet+2); //--------- marker style // pr gPrJpsi->SetMarkerStyle(21); gPrJpsi_pt6530y012->SetMarkerStyle(20); gPrJpsi_pt6530y1216->SetMarkerStyle(21); gPrJpsi_pt6530y1624->SetMarkerStyle(33); gPrJpsi_pt365y1624->SetMarkerStyle(34); // non-pr gNonPrJpsi->SetMarkerStyle(29); gNonPrJpsi_pt6530y012->SetMarkerStyle(20); gNonPrJpsi_pt6530y1216->SetMarkerStyle(21); gNonPrJpsi_pt6530y1624->SetMarkerStyle(33); gNonPrJpsi_pt365y1624->SetMarkerStyle(34); // marker size // pr gPrJpsi->SetMarkerSize(1.2); gPrJpsi_pt6530y012->SetMarkerSize(1.2); gPrJpsi_pt6530y1216->SetMarkerSize(1.2); gPrJpsi_pt6530y1624->SetMarkerSize(2.0); gPrJpsi_pt365y1624->SetMarkerSize(1.7); // nonPr gNonPrJpsi->SetMarkerSize(2.0); gNonPrJpsi_pt6530y012->SetMarkerSize(1.2); gNonPrJpsi_pt6530y1216->SetMarkerSize(1.2); gNonPrJpsi_pt6530y1624->SetMarkerSize(2.0); gNonPrJpsi_pt365y1624->SetMarkerSize(1.7); //-------------- traditional stuff // pr gPrJpsiTrad->SetMarkerStyle(25); gPrJpsiTrad_pt6530y012->SetMarkerStyle(24); gPrJpsiTrad_pt6530y1216->SetMarkerStyle(25); gPrJpsiTrad_pt6530y1624->SetMarkerStyle(27); gPrJpsiTrad_pt365y1624->SetMarkerStyle(28); // non-pr gNonPrJpsiTrad->SetMarkerStyle(30); gNonPrJpsiTrad_pt6530y012->SetMarkerStyle(24); gNonPrJpsiTrad_pt6530y1216->SetMarkerStyle(25); gNonPrJpsiTrad_pt6530y1624->SetMarkerStyle(27); gNonPrJpsiTrad_pt365y1624->SetMarkerStyle(28); // pr gPrJpsiTrad->SetMarkerSize(1.2); gPrJpsiTrad_pt6530y012->SetMarkerSize(1.2); gPrJpsiTrad_pt6530y1216->SetMarkerSize(1.2); gPrJpsiTrad_pt6530y1624->SetMarkerSize(2.0); gPrJpsiTrad_pt365y1624->SetMarkerSize(1.7); // nonPr gNonPrJpsiTrad->SetMarkerSize(2.0); gNonPrJpsiTrad_pt6530y012->SetMarkerSize(1.2); gNonPrJpsiTrad_pt6530y1216->SetMarkerSize(1.2); gNonPrJpsiTrad_pt6530y1624->SetMarkerSize(2.0); gNonPrJpsiTrad_pt365y1624->SetMarkerSize(1.7); // same for the raa denominator and nominator yields histograms for(int ih=0; ih<nInHist; ih++) // for each kinematic range { ahRatio_pr_pp[ih]->SetMarkerStyle(20); ahRatio_npr_pp[ih]->SetMarkerStyle(20); ahRatio_pr_aa[ih]->SetMarkerStyle(20); ahRatio_npr_aa[ih]->SetMarkerStyle(20); } //------------------------------------------- TF1 *f4 = new TF1("f4","1",0,400); f4->SetLineWidth(1); f4->GetXaxis()->SetTitle("N_{part}"); f4->GetYaxis()->SetTitle("R_{AA}"); f4->GetYaxis()->SetRangeUser(0.0,1.5); f4->GetXaxis()->CenterTitle(kTRUE); TLegend *leg11a = new TLegend(0.6,0.5,0.85,0.65); leg11a->SetFillStyle(0); leg11a->SetFillColor(0); leg11a->SetBorderSize(0); leg11a->SetMargin(0.2); leg11a->SetTextSize(0.04); leg11a->AddEntry(gPrJpsi_pt6530y012,"|y|<1.2","P"); leg11a->AddEntry(gPrJpsi_pt6530y1216,"1.2<|y|<1.6","P"); TLegend *leg11b = new TLegend(0.5,0.52,0.8,0.65); leg11b->SetFillStyle(0); leg11b->SetFillColor(0); leg11b->SetBorderSize(0); leg11b->SetMargin(0.2); leg11b->SetTextSize(0.04); leg11b->AddEntry(gPrJpsi_pt6530y1624,"6.5<p_{T}<30 GeV/c","P"); leg11b->AddEntry(gPrJpsi_pt365y1624,"3<p_{T}<6.5 GeV/c","P"); TLegend *leg21a = new TLegend(0.6,0.5,0.85,0.65); leg21a->SetFillStyle(0); leg21a->SetFillColor(0); leg21a->SetBorderSize(0); leg21a->SetMargin(0.2); leg21a->SetTextSize(0.04); leg21a->AddEntry(gNonPrJpsi_pt6530y012,"|y|<1.2","P"); leg21a->AddEntry(gNonPrJpsi_pt6530y1216,"1.2<|y|<1.6","P"); TLegend *leg21b = new TLegend(0.55,0.5,0.8,0.65); leg21b->SetFillStyle(0); leg21b->SetFillColor(0); leg21b->SetBorderSize(0); leg21b->SetMargin(0.2); leg21b->SetTextSize(0.04); leg21b->AddEntry(gNonPrJpsi_pt6530y1624,"6.5<p_{T}<30 GeV/c","P"); leg21b->AddEntry(gNonPrJpsi_pt365y1624, "3<p_{T}<6.5 GeV/c","P"); //---------------- general stuff TLatex *pre_pr = new TLatex(20,1.35,"Prompt J/#psi"); pre_pr->SetTextFont(42); pre_pr->SetTextSize(0.05); TLatex *lPr = new TLatex(20,1.35,"Prompt J/#psi"); lPr->SetTextFont(42); lPr->SetTextSize(0.05); TLatex *lNpr = new TLatex(20,1.35,"Non-prompt J/#psi"); lNpr->SetTextFont(42); lNpr->SetTextSize(0.05); TLatex *ly = new TLatex(190.0,1.05,"|y| < 2.4"); ly->SetTextFont(42); ly->SetTextSize(0.05); TLatex *lpt = new TLatex(190.0,1.05,"6.5 < p_{T} < 30 GeV/c"); lpt->SetTextFont(42); lpt->SetTextSize(0.05); TLatex *lpt2 = new TLatex(190.0,0.90,"6.5 < p_{T} < 30 GeV/c"); lpt2->SetTextFont(42); lpt2->SetTextSize(0.05); // -----------------------for comparison purposes // axis for the yields TF1 *fBin = new TF1("fBin","1",0,10); fBin->SetLineWidth(1); fBin->GetXaxis()->SetTitle("Bin number"); fBin->GetYaxis()->SetTitle("Yield ratio"); fBin->GetYaxis()->SetRangeUser(0.5,2); fBin->GetXaxis()->CenterTitle(kTRUE); TLatex *lRatio; if (whichCompare == 0) lRatio = new TLatex(0.5,1.7,"Yield: withTnP/noTnP correction"); else if (whichCompare == 1) lRatio = new TLatex(0.5,1.7,"Yield: Ev-by-Ev/Trad. correction"); lRatio->SetTextFont(42); lRatio->SetTextSize(0.05); TLatex *lPP = new TLatex(0.5,1.8,"[email protected]"); lPP->SetTextFont(42); lPP->SetTextSize(0.05); TLatex *lAA = new TLatex(0.5,1.8,"[email protected]"); lAA->SetTextFont(42); lAA->SetTextSize(0.05); // ##################################################### pr plots TCanvas *c1 = new TCanvas("c1","c1",1200,400); c1->Divide(3,1); // general stuff c1->cd(1); f4->Draw();// axis lPr->Draw(); ly->Draw(); lpt2->Draw(); gPrJpsi->Draw("P"); gPrJpsiTrad->Draw("P"); // yields c1->cd(2); fBin->Draw();// axis gPad->SetGridy(); ahRatio_pr_pp[0]->Draw("sames"); lPP->Draw(); lRatio->Draw(); c1->cd(3); fBin->Draw();// axis gPad->SetGridy(); ahRatio_pr_aa[0]->Draw("sames"); lAA->Draw(); lRatio->Draw(); if(bSavePlots) { c1->SaveAs(Form("%s/pdf/PrJpsi_vsCent_%s.pdf",outputDir,compWhat[whichCompare])); c1->SaveAs(Form("%s/png/PrJpsi_vsCent_%s.png",outputDir,compWhat[whichCompare])); } //------------------- (pt, y) dependence TCanvas *c11a = new TCanvas("c11a","c11a",1200,800); c11a->Divide(3,2); c11a->cd(1); f4->Draw(); gPrJpsi_pt6530y012->Draw("P"); gPrJpsiTrad_pt6530y012->Draw("P"); lPr->Draw(); leg11a->Draw(); lpt->Draw(); gPad->RedrawAxis(); c11a->cd(2); fBin->Draw(); gPad->SetGridy(); lRatio->Draw(); ahRatio_pr_pp[1]->Draw("sames"); c11a->cd(3); fBin->Draw(); gPad->SetGridy(); lRatio->Draw(); ahRatio_pr_aa[1]->Draw("sames"); c11a->cd(4); f4->Draw(); gPrJpsi_pt6530y1216->Draw("P"); gPrJpsiTrad_pt6530y1216->Draw("P"); c11a->cd(5); fBin->Draw(); gPad->SetGridy(); lPP->Draw(); ahRatio_pr_pp[2]->Draw("sames"); c11a->cd(6); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); ahRatio_pr_aa[2]->Draw("sames"); //------------------- fwd region TCanvas *c11b = new TCanvas("c11b","c11b",1200,800); c11b->Divide(3,2); c11b->cd(1); f4->Draw(); gPrJpsi_pt6530y1624->Draw("P"); gPrJpsiTrad_pt6530y1624->Draw("P"); lPr->Draw(); leg11b->Draw(); gPad->RedrawAxis(); c11b->cd(2); fBin->Draw(); gPad->SetGridy(); ahRatio_pr_pp[3]->Draw("sames"); lPP->Draw(); lRatio->Draw(); c11b->cd(3); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_pr_aa[3]->Draw("sames"); c11b->cd(4); f4->Draw(); gPrJpsi_pt365y1624->Draw("P"); gPrJpsiTrad_pt365y1624->Draw("P"); c11b->cd(5); fBin->Draw(); gPad->SetGridy(); ahRatio_pr_pp[4]->Draw("sames"); c11b->cd(6); fBin->Draw(); gPad->SetGridy(); ahRatio_pr_aa[4]->Draw("sames"); if(bSavePlots) { c11a->SaveAs(Form("%s/pdf/PrJpsi_vsCent_yMid_%s.pdf",outputDir,compWhat[whichCompare])); c11a->SaveAs(Form("%s/png/PrJpsi_vsCent_yMid_%s.png",outputDir,compWhat[whichCompare])); c11b->SaveAs(Form("%s/pdf/PrJpsi_vsCent_yFwd_%s.pdf",outputDir,compWhat[whichCompare])); c11b->SaveAs(Form("%s/png/PrJpsi_vsCent_yFwd_%s.png",outputDir,compWhat[whichCompare])); } // // // ############################################## non-pr // // // ############################################## non-pr // // // ############################################## non-pr TCanvas *c2 = new TCanvas("c2","c2",1200,400); c2->Divide(3,1); // general stuff c2->cd(1); f4->Draw();// axis lNpr->Draw(); ly->Draw(); lpt2->Draw(); gNonPrJpsi->Draw("P"); gNonPrJpsiTrad->Draw("P"); // yields c2->cd(2); fBin->Draw();// axis gPad->SetGridy(); ahRatio_npr_pp[0]->Draw("sames"); lPP->Draw(); lRatio->Draw(); c2->cd(3); fBin->Draw();// axis gPad->SetGridy(); ahRatio_npr_aa[0]->Draw("sames"); lAA->Draw(); lRatio->Draw(); if(bSavePlots) { c2->SaveAs(Form("%s/pdf/NonPrJpsi_vsCent_%s.pdf",outputDir,compWhat[whichCompare])); c2->SaveAs(Form("%s/png/NonPrJpsi_vsCent_%s.png",outputDir,compWhat[whichCompare])); } //------------------- (pt, y) dependence TCanvas *c22a = new TCanvas("c22a","c22a",1200,800); c22a->Divide(3,2); c22a->cd(1); f4->Draw(); gNonPrJpsi_pt6530y012->Draw("P"); gNonPrJpsiTrad_pt6530y012->Draw("P"); lNpr->Draw(); leg21a->Draw(); lpt->Draw(); gPad->RedrawAxis(); c22a->cd(2); fBin->Draw(); gPad->SetGridy(); lPP->Draw(); lRatio->Draw(); ahRatio_npr_pp[1]->Draw("sames"); c22a->cd(3); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_npr_aa[1]->Draw("sames"); c22a->cd(4); f4->Draw(); gNonPrJpsi_pt6530y1216->Draw("P"); gNonPrJpsiTrad_pt6530y1216->Draw("P"); c22a->cd(5); fBin->Draw(); gPad->SetGridy(); ahRatio_npr_pp[2]->Draw("sames"); c22a->cd(6); fBin->Draw(); gPad->SetGridy(); ahRatio_npr_aa[2]->Draw("sames"); //------------------- fwd region TCanvas *c22b = new TCanvas("c22b","c22b",1200,800); c22b->Divide(3,2); c22b->cd(1); f4->Draw(); gNonPrJpsi_pt6530y1624->Draw("P"); gNonPrJpsiTrad_pt6530y1624->Draw("P"); lNpr->Draw(); leg21b->Draw(); gPad->RedrawAxis(); c22b->cd(2); fBin->Draw(); gPad->SetGridy(); for (int jj=1; jj<ahRatio_npr_pp[3]->GetNbinsX(); jj++) cout << jj << " " << ahRatio_npr_pp[3]->GetBinContent(jj) << endl; ahRatio_npr_pp[3]->Draw("sames"); lPP->Draw(); lRatio->Draw(); c22b->cd(3); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_npr_aa[3]->Draw("sames"); c22b->cd(4); f4->Draw(); gNonPrJpsi_pt365y1624->Draw("P"); gNonPrJpsiTrad_pt365y1624->Draw("P"); c22b->cd(5); fBin->Draw(); gPad->SetGridy(); ahRatio_npr_pp[4]->Draw("sames"); c22b->cd(6); fBin->Draw(); gPad->SetGridy(); ahRatio_npr_aa[4]->Draw("sames"); if(bSavePlots) { c22a->SaveAs(Form("%s/pdf/NonPrJpsi_vsCent_yMid_%s.pdf",outputDir,compWhat[whichCompare])); c22a->SaveAs(Form("%s/png/NonPrJpsi_vsCent_yMid_%s.png",outputDir,compWhat[whichCompare])); c22b->SaveAs(Form("%s/pdf/NonPrJpsi_vsCent_yFwd_%s.pdf",outputDir,compWhat[whichCompare])); c22b->SaveAs(Form("%s/png/NonPrJpsi_vsCent_yFwd_%s.png",outputDir,compWhat[whichCompare])); } }
void FFT() { //This tutorial illustrates the Fast Fourier Transforms interface in ROOT. //FFT transform types provided in ROOT: // - "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT) // in one or more dimensions, -1 in the exponent // - "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT) // in one or more dimensions, +1 in the exponent // - "R2C" - a real-input/complex-output discrete Fourier transform (DFT) // in one or more dimensions, // - "C2R" - inverse transforms to "R2C", taking complex input // (storing the non-redundant half of a logically Hermitian array) // to real output // - "R2HC" - a real-input DFT with output in ¡Èhalfcomplex¡É format, // i.e. real and imaginary parts for a transform of size n stored as // r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1 // - "HC2R" - computes the reverse of FFTW_R2HC, above // - "DHT" - computes a discrete Hartley transform // Sine/cosine transforms: // DCT-I (REDFT00 in FFTW3 notation) // DCT-II (REDFT10 in FFTW3 notation) // DCT-III(REDFT01 in FFTW3 notation) // DCT-IV (REDFT11 in FFTW3 notation) // DST-I (RODFT00 in FFTW3 notation) // DST-II (RODFT10 in FFTW3 notation) // DST-III(RODFT01 in FFTW3 notation) // DST-IV (RODFT11 in FFTW3 notation) //First part of the tutorial shows how to transform the histograms //Second part shows how to transform the data arrays directly //Authors: Anna Kreshuk and Jens Hoffmann //********* Histograms ********// //prepare the canvas for drawing TCanvas *myc = new TCanvas("myc", "Fast Fourier Transform", 800, 600); myc->SetFillColor(45); TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.67,0.49,0.99); TPad *c1_2 = new TPad("c1_2", "c1_2",0.51,0.67,0.99,0.99); TPad *c1_3 = new TPad("c1_3", "c1_3",0.01,0.34,0.49,0.65); TPad *c1_4 = new TPad("c1_4", "c1_4",0.51,0.34,0.99,0.65); TPad *c1_5 = new TPad("c1_5", "c1_5",0.01,0.01,0.49,0.32); TPad *c1_6 = new TPad("c1_6", "c1_6",0.51,0.01,0.99,0.32); c1_1->Draw(); c1_2->Draw(); c1_3->Draw(); c1_4->Draw(); c1_5->Draw(); c1_6->Draw(); c1_1->SetFillColor(30); c1_1->SetFrameFillColor(42); c1_2->SetFillColor(30); c1_2->SetFrameFillColor(42); c1_3->SetFillColor(30); c1_3->SetFrameFillColor(42); c1_4->SetFillColor(30); c1_4->SetFrameFillColor(42); c1_5->SetFillColor(30); c1_5->SetFrameFillColor(42); c1_6->SetFillColor(30); c1_6->SetFrameFillColor(42); c1_1->cd(); TH1::AddDirectory(kFALSE); //A function to sample TF1 *fsin = new TF1("fsin", "exp(-(x-679.)/40.0)*TMath::Erfc(-(1/sqrt(2))*((x-679.)/2.0 + 0.05))", 0, 1023); TF1 *model = new TF1("model", "[0]*exp(-(x-[1])/[2])*TMath::Erfc(-(1/sqrt(2))*((x-[1])/[3] + [3]/[2]))", 0, 1023); model->SetParameter( 0, 1. ); model->SetParameter( 1, 679. ); model->SetParameter( 2, 40. ); model->SetParameter( 3, 2. ); model->SetLineColor( kViolet ); TF1 *model2 = new TF1("model2", "[0]*exp(-(x-[1])/[2])*TMath::Erfc(-(1/sqrt(2))*((x-[1])/[3] + [3]/[2])) + [4]*sin(2*TMath::Pi()*[5]*x)", 0, 1023); model2->SetParameter( 0, 1. ); model2->SetParameter( 1, 679. ); model2->SetParameter( 2, 40. ); model2->SetParameter( 3, 2. ); model2->SetParameter( 4, 0.05 ); model2->SetParameter( 5, 2. ); model2->SetLineColor( kViolet ); //fsin->Draw(); Int_t n=1024; TH1D *hsin = new TH1D("hsin", "hsin", n+1, 0, 1023); Double_t x; //hsin->Fit( model,"MLR" ); //Fill the histogram with function values for (Int_t i=0; i<=n; i++){ /* if( i >= n/2 ) { x = (Double_t(i-(n/2+1))/n)*(160*TMath::Pi()); } else { x = -80*TMath::Pi()+(Double_t(i)/n)*(160*TMath::Pi()); } */ x = (Double_t(i)/n)*(1024); //std::cout << "n: " << i << " x: " << x << std::endl; hsin->SetBinContent(i+1, fsin->Eval(x)); } hsin->Fit( model2,"MLR" ); //TFile* fn = new TFile("/Users/cmorgoth/Software/git/TimingAna_New/CIT_Laser_022015_69_ana.root", "READ"); TFile* fn = new TFile("/Users/cmorgoth/Work/data/LaserDataAtCaltech/02282015/CIT_Laser_022015_69_ana.root", "READ"); TH1F* pulse = (TH1F*)fn->Get("CH2pulse"); //hsin->Draw("same"); hsin->SetLineColor(kGreen-4); hsin->Draw(); model->Draw("same"); //pulse->SetAxisRange(650, 780, "X"); pulse->Scale(22.0); pulse->Draw("same"); fsin->GetXaxis()->SetLabelSize(0.05); fsin->GetYaxis()->SetLabelSize(0.05); c1_2->cd(); //Compute the transform and look at the magnitude of the output TH1 *hm =0; TVirtualFFT::SetTransform(0); //hm = hsin->FFT(hm, "MAG"); hm = pulse->FFT(hm, "MAG"); hm->SetTitle("Magnitude of the 1st transform"); //hm->Draw(); double sf = 5e3;//to go from sample to picosecons and also from Hz to MHz double range = sf*(double)n/(1023.); int n_bin_fft = hm->GetNbinsX(); TH1F* hmr = new TH1F( "hmr" ,"Magnitude of the 1st transform Rescaled", n_bin_fft, 0, range); for( int i = 1; i <= n_bin_fft; i++) { double bc = hm->GetBinContent( i )/sqrt( n ); hmr->SetBinContent( i, bc ); } hmr->SetXTitle("f (MHz)"); hmr->Draw(); //Transfor to the theoretical function TH1 *hm2 =0; TVirtualFFT::SetTransform(0); hm2 = hsin->FFT(hm2, "MAG"); hm2->SetLineColor(2); //hm2->Draw("same"); TH1F* hmr2 = new TH1F( "hmr2" ,"Magnitude of the 1st transform Rescaled", n_bin_fft, 0, range); for( int i = 1; i <= n_bin_fft; i++) { double bc = hm2->GetBinContent( i )/sqrt( n ); hmr2->SetBinContent( i, bc ); } hmr2->SetLineColor( kRed ); hmr2->Draw("same"); //NOTE: for "real" frequencies you have to divide the x-axes range with the range of your function //(in this case 4*Pi); y-axes has to be rescaled by a factor of 1/SQRT(n) to be right: this is not done automatically! hm->SetStats(kFALSE); hm->GetXaxis()->SetLabelSize(0.05); hm->GetYaxis()->SetLabelSize(0.05); c1_3->cd(); //Look at the phase of the output TH1 *hp = 0; hp = hsin->FFT(hp, "PH"); hp->SetTitle("Phase of the 1st transform"); hp->Draw(); hp->SetStats(kFALSE); hp->GetXaxis()->SetLabelSize(0.05); hp->GetYaxis()->SetLabelSize(0.05); //Look at the DC component and the Nyquist harmonic: Double_t re, im; //That's the way to get the current transform object: TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform(); c1_4->cd(); //Use the following method to get just one point of the output fft->GetPointComplex(0, re, im); printf("1st transform: DC component: %f\n", re); fft->GetPointComplex(n/2+1, re, im); printf("1st transform: Nyquist harmonic: %f\n", re); //Use the following method to get the full output: Double_t *re_full = new Double_t[n]; Double_t *im_full = new Double_t[n]; fft->GetPointsComplex(re_full,im_full); //Now let's make a backward transform: TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &n, "C2R M K"); fft_back->SetPointsComplex(re_full,im_full); fft_back->Transform(); TH1 *hb = 0; //Let's look at the output hb = TH1::TransformHisto(fft_back,hb,"Re"); hb->SetTitle("The backward transform result"); hb->Draw(); //NOTE: here you get at the x-axes number of bins and not real values //(in this case 25 bins has to be rescaled to a range between 0 and 4*Pi; //also here the y-axes has to be rescaled (factor 1/bins) hb->SetStats(kFALSE); hb->GetXaxis()->SetLabelSize(0.05); hb->GetYaxis()->SetLabelSize(0.05); delete fft_back; fft_back=0; //********* Data array - same transform ********// //Allocate an array big enough to hold the transform output //Transform output in 1d contains, for a transform of size N, //N/2+1 complex numbers, i.e. 2*(N/2+1) real numbers //our transform is of size n+1, because the histogram has n+1 bins Double_t *in = new Double_t[2*((n+1)/2+1)]; Double_t re_2,im_2; for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fsin->Eval(x); } //Make our own TVirtualFFT object (using option "K") //Third parameter (option) consists of 3 parts: //-transform type: // real input/complex output in our case //-transform flag: // the amount of time spent in planning // the transform (see TVirtualFFT class description) //-to create a new TVirtualFFT object (option "K") or use the global (default) Int_t n_size = n+1; TVirtualFFT *fft_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K"); if (!fft_own) return; fft_own->SetPoints(in); fft_own->Transform(); //Copy all the output points: fft_own->GetPoints(in); //Draw the real part of the output c1_5->cd(); TH1 *hr = 0; hr = TH1::TransformHisto(fft_own, hr, "RE"); hr->SetTitle("Real part of the 3rd (array) tranfsorm"); hr->Draw(); hr->SetStats(kFALSE); hr->GetXaxis()->SetLabelSize(0.05); hr->GetYaxis()->SetLabelSize(0.05); c1_6->cd(); TH1 *him = 0; him = TH1::TransformHisto(fft_own, him, "IM"); him->SetTitle("Im. part of the 3rd (array) transform"); him->Draw(); him->SetStats(kFALSE); him->GetXaxis()->SetLabelSize(0.05); him->GetYaxis()->SetLabelSize(0.05); myc->cd(); //Now let's make another transform of the same size //The same transform object can be used, as the size and the type of the transform //haven't changed TF1 *fcos = new TF1("fcos", "cos(x)+cos(0.5*x)+cos(2*x)+1", 0, 4*TMath::Pi()); for (Int_t i=0; i<=n; i++){ x = (Double_t(i)/n)*(4*TMath::Pi()); in[i] = fcos->Eval(x); } fft_own->SetPoints(in); fft_own->Transform(); fft_own->GetPointComplex(0, re_2, im_2); printf("2nd transform: DC component: %f\n", re_2); fft_own->GetPointComplex(n/2+1, re_2, im_2); printf("2nd transform: Nyquist harmonic: %f\n", re_2); delete fft_own; delete [] in; delete [] re_full; delete [] im_full; }
void normalDist() { TF1 *pdfunc = new TF1("pdf","ROOT::Math::normal_pdf(x, [0],[1])",-5,5); TF1 *cdfunc = new TF1("cdf","ROOT::Math::normal_cdf(x, [0],[1])",-5,5); TF1 *ccdfunc = new TF1("cdf_c","ROOT::Math::normal_cdf_c(x, [0])",-5,5); TF1 *qfunc = new TF1("quantile","ROOT::Math::normal_quantile(x, [0])",0,1); TF1 *cqfunc = new TF1("quantile_c","ROOT::Math::normal_quantile_c(x, [0])",0,1); pdfunc->SetParameters(1.0,0.0); // set sigma to 1 and mean to zero pdfunc->SetTitle(""); pdfunc->SetLineColor(kBlue); pdfunc->GetXaxis()->SetLabelSize(0.06); pdfunc->GetXaxis()->SetTitle("x"); pdfunc->GetXaxis()->SetTitleSize(0.07); pdfunc->GetXaxis()->SetTitleOffset(0.55); pdfunc->GetYaxis()->SetLabelSize(0.06); cdfunc->SetParameters(1.0,0.0); // set sigma to 1 and mean to zero cdfunc->SetTitle(""); cdfunc->SetLineColor(kRed); cdfunc->GetXaxis()->SetLabelSize(0.06); cdfunc->GetXaxis()->SetTitle("x"); cdfunc->GetXaxis()->SetTitleSize(0.07); cdfunc->GetXaxis()->SetTitleOffset(0.55); cdfunc->GetYaxis()->SetLabelSize(0.06); cdfunc->GetYaxis()->SetTitle("p"); cdfunc->GetYaxis()->SetTitleSize(0.07); cdfunc->GetYaxis()->SetTitleOffset(0.55); ccdfunc->SetParameters(1.0,0.0); // set sigma to 1 and mean to zero ccdfunc->SetTitle(""); ccdfunc->SetLineColor(kGreen); qfunc->SetParameter(0, 1.0); // set sigma to 1 qfunc->SetTitle(""); qfunc->SetLineColor(kRed); qfunc->SetNpx(1000); // to get more precision for p close to 0 or 1 qfunc->GetXaxis()->SetLabelSize(0.06); qfunc->GetXaxis()->SetTitle("p"); qfunc->GetYaxis()->SetLabelSize(0.06); qfunc->GetXaxis()->SetTitleSize(0.07); qfunc->GetXaxis()->SetTitleOffset(0.55); qfunc->GetYaxis()->SetTitle("x"); qfunc->GetYaxis()->SetTitleSize(0.07); qfunc->GetYaxis()->SetTitleOffset(0.55); cqfunc->SetParameter(0, 1.0); // set sigma to 1 cqfunc->SetTitle(""); cqfunc->SetLineColor(kGreen); cqfunc->SetNpx(1000); TCanvas * c1 = new TCanvas("c1","Normal Distributions",100,10,600,800); c1->Divide(1,3); c1->cd(1); pdfunc->Draw(); TLegend *legend1 = new TLegend(0.583893,0.601973,0.885221,0.854151); legend1->AddEntry(pdfunc,"normal_pdf","l"); legend1->Draw(); c1->cd(2); cdfunc->Draw(); ccdfunc->Draw("same"); TLegend *legend2 = new TLegend(0.585605,0.462794,0.886933,0.710837); legend2->AddEntry(cdfunc,"normal_cdf","l"); legend2->AddEntry(ccdfunc,"normal_cdf_c","l"); legend2->Draw(); c1->cd(3); qfunc->Draw(); cqfunc->Draw("same"); TLegend *legend3 = new TLegend(0.315094,0.633668,0.695179,0.881711); legend3->AddEntry(qfunc,"normal_quantile","l"); legend3->AddEntry(cqfunc,"normal_quantile_c","l"); legend3->Draw(); }
void compare_y(bool bSavePlots = true, bool bDoDebug = 1, // adds some numbers, numerator, denominator, to help figure out if things are read properly int whichCompare = 1,//0: no TnP corrections; 1: w/ TnP corr on Data; 2: w/ TnP corr on MC; 3: lxy w/ TnP on MC const char* inputDir = "../readFitTable", // the place where the input root files, with the histograms are const char* outputDir = "figs/compare")// where the output figures will be { gSystem->mkdir(Form("./%s/png",outputDir), kTRUE); gSystem->mkdir(Form("./%s/pdf",outputDir), kTRUE); // set the style setTDRStyle(); // type of available comparisons: const char* compWhat[4] = {"noTnP","dataTnP","mcTnP","lxyTnP"}; const int nInHist = 3; const char* yieldHistNames[nInHist] = {"y", "y_mb", "mb"}; //----------------------------------------- // input files: are in the filesRaa_2015.h // open the files with yields and do the math TFile *fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[0])); TFile *fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[1])); TFile *fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[0])); TFile *fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[1])); TFile *fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile[0])); TFile *fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile[1])); switch(whichCompare){ case 0: cout << "You are making Raa, with NOT TnP corrections whatsoever!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[1])); fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[0])); fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[1])); break; case 2: cout << "You are making Raa, with TnP corrections applied on MC!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[1])); break; case 3: cout << "You are making Raa, with Lxy and TnP corrections applie on MC!"<<endl; fYesWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[0])); fYesWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[1])); fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[0])); fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[1])); break; case 1: default: cout<<" You are doing Raa Nominal: TnP on data!"<<endl; break; } if (!fYesWeighFile_aa->IsOpen() || !fYesWeighFile_pp->IsOpen()|| !fNoWeighFile_aa->IsOpen() || !fNoWeighFile_pp->IsOpen() || !fEffFile_aa->IsOpen() || !fEffFile_pp->IsOpen()) { cout << "One or more input files are missing" << endl; return ; } TH1F *phRaw_pr_pp; TH1F *phCorr_pr_pp; TH1F *phEff_pr_pp; TH1F *phRaw_pr_aa; TH1F *phCorr_pr_aa; TH1F *phEff_pr_aa; TH1F *phRaw_npr_pp; TH1F *phCorr_npr_pp; TH1F *phEff_npr_pp; TH1F *phRaw_npr_aa; TH1F *phCorr_npr_aa; TH1F *phEff_npr_aa; // to store the ratio of ev-by-ev and traditionally corrected yields in each case TH1F *ahRatio_pr_pp[nInHist]; TH1F *ahRatio_npr_pp[nInHist]; TH1F *ahRatio_pr_aa[nInHist]; TH1F *ahRatio_npr_aa[nInHist]; for(int ih=0; ih<nInHist;ih++) // for each kinematic range { TString hist_pr(Form("phPrp_%s",yieldHistNames[ih])); TString hist_npr(Form("phNPrp_%s",yieldHistNames[ih])); cout<<"histogram input name: "<< hist_pr<<"\t"<<hist_npr<<endl; // prompt histos phRaw_pr_pp = (TH1F*)fNoWeighFile_pp->Get(hist_pr); phCorr_pr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_pr); phRaw_pr_aa = (TH1F*)fNoWeighFile_aa->Get(hist_pr); phCorr_pr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_pr); // non-prompt histos phRaw_npr_pp = (TH1F*)fNoWeighFile_pp->Get(hist_npr); phCorr_npr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_npr); phRaw_npr_aa = (TH1F*)fNoWeighFile_aa->Get(hist_npr); phCorr_npr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_npr); // efficiency histos phEff_pr_pp = (TH1F*)fEffFile_pp->Get(hist_pr); phEff_npr_pp = (TH1F*)fEffFile_pp->Get(hist_npr); phEff_pr_aa = (TH1F*)fEffFile_aa->Get(hist_pr); phEff_npr_aa = (TH1F*)fEffFile_aa->Get(hist_npr); //--------------- corrected yields in the traditional way (simple division for the moment) // store the yield_Ratio histos: ev_by_ev/(raw*eff), ahRatio_pr_pp[ih] = (TH1F *)phCorr_pr_pp->Clone(); ahRatio_pr_pp[ih]->SetDirectory(0); ahRatio_pr_pp[ih]->Divide(phRaw_pr_pp); ahRatio_pr_pp[ih]->Multiply(phEff_pr_pp);// correct the raw with it's efficiency ahRatio_npr_pp[ih] = (TH1F *)phCorr_npr_pp->Clone(); ahRatio_npr_pp[ih]->SetDirectory(0); ahRatio_npr_pp[ih]->Divide(phRaw_npr_pp); ahRatio_npr_pp[ih]->Multiply(phEff_npr_pp); ahRatio_pr_aa[ih] = (TH1F *)phCorr_pr_aa->Clone(); ahRatio_pr_aa[ih]->SetDirectory(0); ahRatio_pr_aa[ih]->Divide(phRaw_pr_aa); ahRatio_pr_aa[ih]->Multiply(phEff_pr_aa); ahRatio_npr_aa[ih] = (TH1F *)phCorr_npr_aa->Clone(); ahRatio_npr_aa[ih]->SetDirectory(0); ahRatio_npr_aa[ih]->Divide(phRaw_npr_aa); ahRatio_npr_aa[ih]->Multiply(phEff_npr_aa); double scaleFactor = ppLumi/nMbEvents; double scale_cent = 1/(adTaaMB[0]*adDeltaCentMB[0]); int numBins = 0; if(ih==0) numBins = nBinsY; if(ih==1) numBins = nBinsY3; if(ih==2) numBins = nBinsMB; cout << "Number of bins: " << numBins<<endl; for(int ibin=1; ibin<=numBins; ibin++) { double raa_pr=0, raaErr_pr=0, raa_npr=0, raaErr_npr=0; double raaTrad_pr=0, raaTradErr_pr=0, raaTrad_npr=0, raaTradErr_npr=0; //prompt double dRelErrRaw_pr_pp = phRaw_pr_pp->GetBinError(ibin)/phRaw_pr_pp->GetBinContent(ibin); double dRelErrRaw_pr_aa = phRaw_pr_aa->GetBinError(ibin)/phRaw_pr_aa->GetBinContent(ibin); double yieldRatio_pr = phCorr_pr_aa->GetBinContent(ibin)/phCorr_pr_pp->GetBinContent(ibin); double yieldRatioTrad_pr = (phRaw_pr_aa->GetBinContent(ibin)/phRaw_pr_pp->GetBinContent(ibin)) * (phEff_pr_pp->GetBinContent(ibin)/phEff_pr_aa->GetBinContent(ibin)); raa_pr = yieldRatio_pr * scaleFactor * scale_cent; raaErr_pr = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raa_pr; raaTrad_pr = yieldRatioTrad_pr * scaleFactor * scale_cent; raaTradErr_pr = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raaTrad_pr; //non-prompt // get the rel uncert from the raw sample double dRelErrRaw_npr_pp = phRaw_npr_pp->GetBinError(ibin)/phRaw_npr_pp->GetBinContent(ibin); double dRelErrRaw_npr_aa = phRaw_npr_aa->GetBinError(ibin)/phRaw_npr_aa->GetBinContent(ibin); double yieldRatio_npr = phCorr_npr_aa->GetBinContent(ibin)/phCorr_npr_pp->GetBinContent(ibin); double yieldRatioTrad_npr = phRaw_npr_aa->GetBinContent(ibin)/phRaw_npr_pp->GetBinContent(ibin) * (phEff_npr_pp->GetBinContent(ibin)/phEff_npr_aa->GetBinContent(ibin)); raa_npr = yieldRatio_npr * scaleFactor * scale_cent; raaErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raa_npr; raaTrad_npr= yieldRatioTrad_npr * scaleFactor * scale_cent; raaTradErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raaTrad_npr; // fill the corresponding array switch(ih){ case 0: prJpsi_y[ibin-1] = raa_pr; prJpsiErr_y[ibin-1] = raaErr_pr; nonPrJpsi_y[ibin-1] = raa_npr; nonPrJpsiErr_y[ibin-1] = raaErr_npr; prJpsiTrad_y[ibin-1] = raaTrad_pr; prJpsiTradErr_y[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_y[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_y[ibin-1] = raaTradErr_npr; if(bDoDebug) { cout<<"yield_pr_aa "<<phCorr_pr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_pr_pp->GetBinContent(ibin)<<endl; cout<<"yield_npr_aa "<<phCorr_npr_aa->GetBinContent(ibin)<<"\t yield_npr_pp "<<phCorr_npr_pp->GetBinContent(ibin)<<endl; cout<<"!!!!! raa_pr = "<<raa_pr<<"\t raa_npr= "<<raa_npr<<endl; } break; case 1: prJpsi_y_y[ibin-1] = raa_pr; prJpsiErr_y_y[ibin-1] = raaErr_pr; nonPrJpsi_y_y[ibin-1] = raa_npr; nonPrJpsiErr_y_y[ibin-1] = raaErr_npr; prJpsiTrad_y_y[ibin-1] = raaTrad_pr; prJpsiTradErr_y_y[ibin-1] = raaTradErr_pr; nonPrJpsiTrad_y_y[ibin-1] = raaTrad_npr; nonPrJpsiTradErr_y_y[ibin-1] = raaTradErr_npr; if(bDoDebug) { cout<<"yield_npr_aa "<<phCorr_npr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_npr_pp->GetBinContent(ibin)<<endl; cout<<setprecision(2); cout<<"!!!!! raa_pr = "<<raa_pr<<"\t raa_npr= "<<raa_npr<<endl; } break; case 2: // mb prJpsi_mb[0] = raa_pr; prJpsiErr_mb[0] = raaErr_pr; nonPrJpsi_mb[0] = raa_npr; nonPrJpsiErr_mb[0] = raaErr_npr; prJpsiTrad_mb[0] = raaTrad_pr; prJpsiTradErr_mb[0] = raaTradErr_pr; nonPrJpsiTrad_mb[0] = raaTrad_npr; nonPrJpsiTradErr_mb[0] = raaTradErr_npr; break; } }//loop end: for(int ibin=1; ibin<=numBins; ibin++) }//loop end: for(int ih=0; ih<nInHist;ih++) // ***** //Drawing // pr TGraphErrors *gPrJpsi = new TGraphErrors(nBinsY, binsY, prJpsi_y, binsYErr, prJpsiErr_y); TGraphErrors *gPrJpsi_mb = new TGraphErrors(nBinsMB, binsYMB, prJpsi_mb, binsYMBErr, prJpsiErr_mb); TGraphErrors *gPrJpsi_y_y = new TGraphErrors(nBinsY3, binsY3, prJpsi_y_y, binsY3Err, prJpsiErr_y_y); // nonPr TGraphErrors *gNonPrJpsi = new TGraphErrors(nBinsY, binsY, nonPrJpsi_y, binsYErr, nonPrJpsiErr_y); TGraphErrors *gNonPrJpsi_mb = new TGraphErrors(nBinsMB, binsYMB, nonPrJpsi_mb, binsYMBErr, nonPrJpsiErr_mb); TGraphErrors *gNonPrJpsi_y_y= new TGraphErrors(nBinsY3, binsY3, nonPrJpsi_y_y, binsY3Err, nonPrJpsiErr_y_y); //------------ trad // pr TGraphErrors *gPrJpsiTrad = new TGraphErrors(nBinsY, binsY, prJpsiTrad_y, binsYErr, prJpsiTradErr_y); TGraphErrors *gPrJpsiTrad_mb = new TGraphErrors(nBinsMB, binsYMB, prJpsiTrad_mb, binsYMBErr, prJpsiTradErr_mb); TGraphErrors *gPrJpsiTrad_y_y= new TGraphErrors(nBinsY3, binsY3, prJpsiTrad_y_y, binsY3Err, prJpsiTradErr_y_y); // nonPr TGraphErrors *gNonPrJpsiTrad = new TGraphErrors(nBinsY, binsY, nonPrJpsiTrad_y, binsYErr, nonPrJpsiTradErr_y); TGraphErrors *gNonPrJpsiTrad_mb = new TGraphErrors(nBinsMB, binsYMB, nonPrJpsiTrad_mb, binsYMBErr, nonPrJpsiTradErr_mb); TGraphErrors *gNonPrJpsiTrad_y_y= new TGraphErrors(nBinsY3, binsY3, nonPrJpsiTrad_y_y, binsY3Err, nonPrJpsiTradErr_y_y); //------------------------------------------------------------------- // **************** marker colors gPrJpsi->SetMarkerColor(kRed); gNonPrJpsi->SetMarkerColor(kOrange+2); //mnbias colors gPrJpsi_mb->SetMarkerColor(kCyan+2); gNonPrJpsi_mb->SetMarkerColor(kCyan+2); gPrJpsi_y_y->SetMarkerColor(kBlue-4); gNonPrJpsi_y_y->SetMarkerColor(kBlue-4); //--------- marker style gPrJpsi->SetMarkerStyle(21); gPrJpsi_y_y->SetMarkerStyle(34); gNonPrJpsi->SetMarkerStyle(29); gNonPrJpsi_y_y->SetMarkerStyle(34); //mb gPrJpsi_mb->SetMarkerStyle(33); gNonPrJpsi_mb->SetMarkerStyle(33); // marker size gPrJpsi->SetMarkerSize(1.2); gPrJpsi_y_y->SetMarkerSize(1.7); gNonPrJpsi->SetMarkerSize(1.7); gNonPrJpsi_y_y->SetMarkerSize(1.7); //mb gPrJpsi_mb->SetMarkerSize(1.5); gNonPrJpsi_mb->SetMarkerSize(1.5); //--------------- traditional stuff gPrJpsiTrad->SetMarkerStyle(25); gPrJpsiTrad_y_y->SetMarkerStyle(28); gNonPrJpsiTrad->SetMarkerStyle(30); gNonPrJpsiTrad_y_y->SetMarkerStyle(28); //mb gPrJpsiTrad_mb->SetMarkerStyle(27); gNonPrJpsiTrad_mb->SetMarkerStyle(27); // marker size gPrJpsiTrad->SetMarkerSize(1.2); gPrJpsiTrad_y_y->SetMarkerSize(1.7); gNonPrJpsiTrad->SetMarkerSize(1.7); gNonPrJpsiTrad_y_y->SetMarkerSize(1.7); //mb gPrJpsiTrad_mb->SetMarkerSize(1.5); gNonPrJpsiTrad_mb->SetMarkerSize(1.5); // same for the raa denominator and nominator yields histograms for(int ih=0; ih<nInHist;ih++) // for each kinematic range { ahRatio_pr_pp[ih]->SetMarkerStyle(20); ahRatio_npr_pp[ih]->SetMarkerStyle(20); ahRatio_pr_aa[ih]->SetMarkerStyle(20); ahRatio_npr_aa[ih]->SetMarkerStyle(20); if(ih==2) { ahRatio_pr_pp[ih]->SetMarkerColor(kCyan+2); ahRatio_npr_pp[ih]->SetMarkerColor(kCyan+2); ahRatio_pr_aa[ih]->SetMarkerColor(kCyan+2); ahRatio_npr_aa[ih]->SetMarkerColor(kCyan+2); } } //------------------------------------------- TF1 *f4 = new TF1("f4","1",0,2.4); f4->SetLineWidth(1); f4->GetXaxis()->SetTitle("|y|"); f4->GetXaxis()->SetNdivisions(-6); f4->GetYaxis()->SetTitle("R_{AA}"); f4->GetYaxis()->SetRangeUser(0.0,1.5); f4->GetXaxis()->CenterTitle(kTRUE); //---------------- general stuff TLatex *lcent = new TLatex(1.1,1.03,"Cent. 0-100%"); lcent->SetTextFont(42); lcent->SetTextSize(0.05); TLatex *lpt = new TLatex(1.1,0.9,"6.5 < p_{T} < 30 GeV/c"); lpt->SetTextFont(42); lpt->SetTextSize(0.05); TLatex *lPr = new TLatex(0.2,1.35,"Prompt J/#psi"); lPr->SetTextFont(42); lPr->SetTextSize(0.05); TLatex *lNpr = new TLatex(0.2,1.35,"Non-prompt J/#psi"); lNpr->SetTextFont(42); lNpr->SetTextSize(0.05); // -----------------------for comparison purposes // axis for the yields TF1 *fBin = new TF1("fBin","1",0,8); fBin->SetLineWidth(1); fBin->GetXaxis()->SetTitle("Bin number"); fBin->GetYaxis()->SetTitle("Yield ratio"); fBin->GetYaxis()->SetRangeUser(0.5,2); fBin->GetXaxis()->CenterTitle(kTRUE); TLatex *lRatio = new TLatex(0.5,1.7,"Yield: Ev-by-Ev/Trad. correction"); lRatio->SetTextFont(42); lRatio->SetTextSize(0.05); TLatex *lPP = new TLatex(0.5,1.8,"[email protected]"); lPP->SetTextFont(42); lPP->SetTextSize(0.05); TLatex *lAA = new TLatex(0.5,1.8,"[email protected]"); lAA->SetTextFont(42); lAA->SetTextSize(0.05); // ##################################################### pr plots TCanvas *c1 = new TCanvas("c1","c1",1200,400); c1->Divide(3,1); c1->cd(1); f4->Draw();// axis lPr->Draw(); lcent->Draw(); lpt->Draw(); gPrJpsi->Draw("P"); gPrJpsiTrad->Draw("P"); c1->cd(2); fBin->Draw();// axis gPad->SetGridy(); lPP->Draw(); lRatio->Draw(); ahRatio_pr_pp[0]->Draw("sames"); c1->cd(3); fBin->Draw();// axis gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_pr_aa[0]->Draw("sames"); if(bSavePlots) { c1->SaveAs(Form("%s/pdf/PrJpsi_vsY_%s.pdf",outputDir,compWhat[whichCompare])); c1->SaveAs(Form("%s/png/PrJpsi_vsY_%s.png",outputDir,compWhat[whichCompare])); } //-------------------minbias dependence TCanvas *c11b = new TCanvas("c11b","c11b",1200,400); c11b->Divide(3,1); c11b->cd(1); f4->Draw(); lPr->Draw(); lcent->Draw(); lpt->Draw(); gPrJpsi_mb->Draw("P"); gPrJpsi_y_y->Draw("P"); gPrJpsiTrad_mb->Draw("P"); gPrJpsiTrad_y_y->Draw("P"); c11b->cd(2); fBin->Draw(); gPad->SetGridy(); lPP->Draw(); lRatio->Draw(); ahRatio_pr_pp[1]->Draw("sames"); ahRatio_pr_pp[2]->Draw("sames"); c11b->cd(3); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_pr_aa[1]->Draw("sames"); ahRatio_pr_aa[2]->Draw("sames"); gPad->RedrawAxis(); if(bSavePlots) { c11b->SaveAs(Form("%s/pdf/PrJpsi_vsY_mb_%s.pdf",outputDir,compWhat[whichCompare])); c11b->SaveAs(Form("%s/png/PrJpsi_vsY_mb_%s.png",outputDir,compWhat[whichCompare])); } // // ############################################## non-pr // // ############################################## non-pr // // ############################################## non-pr TCanvas *c2 = new TCanvas("c2","c2",1200,400); c2->Divide(3,1); c2->cd(1); f4->Draw();// axis lNpr->Draw(); lcent->Draw(); lpt->Draw(); gNonPrJpsi->Draw("P"); gNonPrJpsiTrad->Draw("P"); c2->cd(2); fBin->Draw();// axis gPad->SetGridy(); lPP->Draw(); lRatio->Draw(); ahRatio_npr_pp[0]->Draw("sames"); c2->cd(3); fBin->Draw();// axis gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_npr_aa[0]->Draw("sames"); if(bSavePlots) { c2->SaveAs(Form("%s/pdf/NonPrJpsi_vsY_%s.pdf",outputDir,compWhat[whichCompare])); c2->SaveAs(Form("%s/png/NonPrJpsi_vsY_%s.png",outputDir,compWhat[whichCompare])); } //-------------------minbias dependence TCanvas *c22b = new TCanvas("c22b","c22b",1200,400); c22b->Divide(3,1); c22b->cd(1); f4->Draw(); lNpr->Draw(); lcent->Draw(); lpt->Draw(); gNonPrJpsi_mb->Draw("P"); gNonPrJpsi_y_y->Draw("P"); gNonPrJpsiTrad_mb->Draw("P"); gNonPrJpsiTrad_y_y->Draw("P"); c22b->cd(2); fBin->Draw(); gPad->SetGridy(); lPP->Draw(); lRatio->Draw(); ahRatio_npr_pp[1]->Draw("sames"); ahRatio_npr_pp[2]->Draw("sames"); c22b->cd(3); fBin->Draw(); gPad->SetGridy(); lAA->Draw(); lRatio->Draw(); ahRatio_npr_aa[1]->Draw("sames"); ahRatio_npr_aa[2]->Draw("sames"); gPad->RedrawAxis(); if(bSavePlots) { c11b->SaveAs(Form("%s/pdf/NonPrJpsi_vsY_mb_%s.pdf",outputDir,compWhat[whichCompare])); c11b->SaveAs(Form("%s/png/NonPrJpsi_vsY_mb_%s.png",outputDir,compWhat[whichCompare])); } }