コード例 #1
0
ファイル: AnaCombineEvH.C プロジェクト: xcheung/AliGenFME
void AnaCombineEvH()
{
  TFile *file = TFile::Open("AnalysisResults_EmcalEvH.root", "READ");
  TList *list = (TList*)file->Get("listEmcalEvH");
  file->Close();
//=============================================================================

  TH2D *hist2 = 0;
  TH2D *hCentMtCh = 0;
  TH2D *hMtChMtEm = 0;
  for (Int_t i=0; i<4; i++) {
    hist2 = (TH2D*)list->FindObject(Form("hCentMtCh_%d",i));
    if (i==0) { hCentMtCh = (TH2D*)hist2->Clone("hCentMtCh"); hCentMtCh->Reset(); } hCentMtCh->Add(hist2); hist2 = 0;

    hist2 = (TH2D*)list->FindObject(Form("hMtChMtEm_%d",i));
    if (i==0) { hMtChMtEm = (TH2D*)hist2->Clone("hMtChMtEm"); hMtChMtEm->Reset(); } hMtChMtEm->Add(hist2); hist2 = 0;
  }
//=============================================================================

/*file = TFile::Open("AnalysisResults_EmcalEvH.root", "UPDATE");
  hCentMtCh->Write();
  hMtChMtEm->Write();
  file->Close();*/
//=============================================================================

  return;
}
コード例 #2
0
ファイル: drawDist.C プロジェクト: maszyman/PlotMacros
void drawDist(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) {

        myOptions(0);

        gROOT->ForceStyle();
        gStyle->SetPalette(1.0);

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

        TFile *f = new TFile(infilename, "read");
        // TList *list = (TList*)f->Get("femtolist");

        // pseudorapidity vs pt
        TH2D* ypt =(TH2D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,0));

        int minMultBin = 0;
        int maxMultBin = 6;
        double EvMultall = 0;

        for(int i = minMultBin; i < maxMultBin; i++) {
                TH1D* yptN =(TH1D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,i));
                ypt->Add(yptN);
                //delete hEvMult;
        }

        TCanvas *c2 = new TCanvas("pseudorapidity vs pt", "pseudorapidity vs pt");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        ypt->GetXaxis()->SetTitle("#eta");
        ypt->GetYaxis()->SetTitle("p_{T}");
        ypt->GetXaxis()->SetTitleOffset(1.3);
        ypt->GetYaxis()->SetTitleOffset(1.3);
        ypt->GetXaxis()->SetRangeUser(-0.8,0.8);
        ypt->GetYaxis()->SetRangeUser(0.1,8.);
        ypt->Draw("colz");

        // https://wiki.bnl.gov/eic/index.php/ROOT#Moving_and_resizing_the_palette_axis_of_a_2D_histogram
        gPad->SetRightMargin( 0.12 ); // The default right margin is 0.1 i.e. 10% of the image width
//   TPaletteAxis* palette
//       = dynamic_cast<TPaletteAxis*>( myHistogram.GetListOfFunctions()->FindObject( "palette" ) );
//   if( palette ) {
//     palette->SetX1NDC( 0.86 ); // Start the palette 86 % of the way across the image
//     palette->SetX1NDC( 0.91 ); // End the palette 91% of the way across the image
//     gPad->Modified(); // Update with the new position
//   } // if

        postprocess(c2,Form("ypt%s",system),rWrite,rPerformance);

}
コード例 #3
0
ファイル: massPlotPost.C プロジェクト: raggleton/4tau_work
TH2D* combinePlots(std::vector<TH2D*> plots, std::vector<double> scalingFactors) {
	TH1::SetDefaultSumw2();

	TH2D* h = (TH2D*)plots[0]->Clone(plots[0]->GetName());
	h->Scale(scalingFactors[0]);
	for (unsigned i = 1; i < plots.size(); i++) {
		h->Add(plots[i], scalingFactors[i]);
	}
	return h;
}
コード例 #4
0
ファイル: fakerate.C プロジェクト: radziej/findsusyb3
/* Get a fake estimate from the given histogram, i.e. return Data - MC.
 *
 * Subtract all background MCs from data but the one specified with
 * "notremove". Under- and overflows are ignored in computation.
 *
 * @param hname     Histogram name from which to compute estimate
 * @return          Histogram of fakes
 */
TH2D * get_fakes_2d(const char * hname)
{
  // get number of single fakes from data histogram
  plot2(hname);
  TH2D * hData = dataHisto2();
  if (hData == 0) {
    THROW("get_fakes() needs a data histogram");
  }
  // data
  double N = hData->Integral();
  INFO("Data events: " << N);

  TH2D * hBack = 0;
  for (unsigned int i = 0; i < sizeof(removeNames)/sizeof(void *); i++) {
    TH2D * hSub = backgroundHisto2(removeNames[i]);
    if (hSub == 0) {
      THROW(string("get_fakes() problem getting background ")+removeNames[i]);
    }
    // add backgrounds together
    if (hBack == 0) {
      hBack = hSub;
    }
    else {
      hBack->Add(hSub);
      delete hSub;
    }
  }
  N = hBack->Integral();
  INFO("Background events : " << N);

  // subtract
  hData->Add(hBack, -1.);
  // temporarily needed for function call
  delete hBack;
  return hData;
}
コード例 #5
0
ファイル: paperConvert.C プロジェクト: raggleton/4tau_work
TH2D* combineScale(std::vector<TH2D*> hists, std::vector<double> scalingFactors) {
    TH1::SetDefaultSumw2();

    // get total
    double total = 0;
    for (int i = 0; i < scalingFactors.size(); i++) {
        total += scalingFactors[i];
    }
    TH2D* h = (TH2D*) hists[0]->Clone(hists[0]->GetName());
    h->Scale(scalingFactors[0]/total);

    for (i = 1; i < scalingFactors.size(); i++) {
        h->Add(hists[i], scalingFactors[i]/total);
    }

    return h;
}
コード例 #6
0
TH2D* Plot2D (std::string var,std::vector<TFile*>& tfiles,std::vector<double>& weights) {

    double weightTot = 0.0;
    for ( int i = 0; i<weights.size(); i++) {
        weightTot+=weights[i];
    }

    std::string name = var;
    name+="NEW";
    TH2D* hVar = (TH2D*)tfiles[0]->Get(var.c_str());
    TH2D* HVar = (TH2D*)hVar->Clone(name.c_str());
    //HVar->Sumw2();

    for (int i=1; i<tfiles.size(); i++) {
        TH2D* htempVar = (TH2D*)tfiles[i]->Get(var.c_str());
        HVar->Add(htempVar,weights[i]/weightTot);
    }

    return HVar;

}
コード例 #7
0
ファイル: Plots2D.cpp プロジェクト: phy6phs/PlottingTools
TH2D* Plots2D::readHistogram(Sample sample, Variable variable) {

	cout << "plot: " << "Binning/"+folder+variable.name << endl;
	TH2D* plot = (TH2D*) sample.file->Get("Binning/"+folder+variable.name+"_2btags");
	TH2D* plot2 = (TH2D*) sample.file->Get("Binning/"+folder+variable.name+"_3btags");
	TH2D* plot3 = (TH2D*) sample.file->Get("Binning/"+folder+variable.name+"_4orMoreBtags");

//	TH1D* plot = (TH1D*) sample.file->Get(selection+objName+"/"+variable.name+"_2btags");
//	TH1D* plot2 = (TH1D*) sample.file->Get(selection+objName+"/"+variable.name+"_3btags");
//	TH1D* plot3 = (TH1D*) sample.file->Get(selection+objName+"/"+variable.name+"_4orMoreBtags");

	plot->Add(plot2);
	plot->Add(plot3);

	plot->SetFillColor(sample.fillColor);
	plot->SetLineColor(sample.lineColor);

	plot->Rebin2D(variable.rebinFact, variable.rebinFact);

	return plot;
}
コード例 #8
0
ファイル: TSVDUnfoldExample.C プロジェクト: digideskio/root
void TSVDUnfoldExample()
{
   gROOT->Reset();
   gROOT->SetStyle("Plain");
   gStyle->SetOptStat(0);

   TRandom3 R;

   const Double_t cutdummy= -99999.0;

   // --- Data/MC toy generation -----------------------------------

   // The MC input
   Int_t nbins = 40;
   TH1D *xini = new TH1D("xini", "MC truth", nbins, -10.0, 10.0);
   TH1D *bini = new TH1D("bini", "MC reco", nbins, -10.0, 10.0);
   TH2D *Adet = new TH2D("Adet", "detector response", nbins, -10.0, 10.0, nbins, -10.0, 10.0);

   // Data
   TH1D *data = new TH1D("data", "data", nbins, -10.0, 10.0);
   // Data "truth" distribution to test the unfolding
   TH1D *datatrue = new TH1D("datatrue", "data truth", nbins, -10.0, 10.0);
   // Statistical covariance matrix
   TH2D *statcov = new TH2D("statcov", "covariance matrix", nbins, -10.0, 10.0, nbins, -10.0, 10.0);

   // Fill the MC using a Breit-Wigner, mean 0.3 and width 2.5.
   for (Int_t i= 0; i<100000; i++) {
      Double_t xt = R.BreitWigner(0.3, 2.5);
      xini->Fill(xt);
      Double_t x = Reconstruct( xt, R );
      if (x != cutdummy) {
         Adet->Fill(x, xt);
         bini->Fill(x);
      }
   }

   // Fill the "data" with a Gaussian, mean 0 and width 2.
   for (Int_t i=0; i<10000; i++) {
      Double_t xt = R.Gaus(0.0, 2.0);
      datatrue->Fill(xt);
      Double_t x = Reconstruct( xt, R );
      if (x != cutdummy)
      data->Fill(x);
   }

   cout << "Created toy distributions and errors for: " << endl;
   cout << "... \"true MC\"   and \"reconstructed (smeared) MC\"" << endl;
   cout << "... \"true data\" and \"reconstructed (smeared) data\"" << endl;
   cout << "... the \"detector response matrix\"" << endl;

   // Fill the data covariance matrix
   for (int i=1; i<=data->GetNbinsX(); i++) {
       statcov->SetBinContent(i,i,data->GetBinError(i)*data->GetBinError(i));
   }

   // --- Here starts the actual unfolding -------------------------

   // Create TSVDUnfold object and initialise
   TSVDUnfold *tsvdunf = new TSVDUnfold( data, statcov, bini, xini, Adet );

   // It is possible to normalise unfolded spectrum to unit area
   tsvdunf->SetNormalize( kFALSE ); // no normalisation here

   // Perform the unfolding with regularisation parameter kreg = 13
   // - the larger kreg, the finer grained the unfolding, but the more fluctuations occur
   // - the smaller kreg, the stronger is the regularisation and the bias
   TH1D* unfres = tsvdunf->Unfold( 13 );

   // Get the distribution of the d to cross check the regularization
   // - choose kreg to be the point where |d_i| stop being statistically significantly >>1
   TH1D* ddist = tsvdunf->GetD();

   // Get the distribution of the singular values
   TH1D* svdist = tsvdunf->GetSV();

   // Compute the error matrix for the unfolded spectrum using toy MC
   // using the measured covariance matrix as input to generate the toys
   // 100 toys should usually be enough
   // The same method can be used for different covariance matrices separately.
   TH2D* ustatcov = tsvdunf->GetUnfoldCovMatrix( statcov, 100 );

   // Now compute the error matrix on the unfolded distribution originating
   // from the finite detector matrix statistics
   TH2D* uadetcov = tsvdunf->GetAdetCovMatrix( 100 );

   // Sum up the two (they are uncorrelated)
   ustatcov->Add( uadetcov );

   //Get the computed regularized covariance matrix (always corresponding to total uncertainty passed in constructor) and add uncertainties from finite MC statistics.
   TH2D* utaucov = tsvdunf->GetXtau();
   utaucov->Add( uadetcov );

   //Get the computed inverse of the covariance matrix
   TH2D* uinvcov = tsvdunf->GetXinv();


   // --- Only plotting stuff below ------------------------------

   for (int i=1; i<=unfres->GetNbinsX(); i++) {
      unfres->SetBinError(i, TMath::Sqrt(utaucov->GetBinContent(i,i)));
   }

   // Renormalize just to be able to plot on the same scale
   xini->Scale(0.7*datatrue->Integral()/xini->Integral());

   TLegend *leg = new TLegend(0.58,0.68,0.99,0.88);
   leg->SetBorderSize(0);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->AddEntry(unfres,"Unfolded Data","p");
   leg->AddEntry(datatrue,"True Data","l");
   leg->AddEntry(data,"Reconstructed Data","l");
   leg->AddEntry(xini,"True MC","l");

   TCanvas *c1 = new TCanvas( "c1", "Unfolding toy example with TSVDUnfold", 900, 800 );

   // --- Style settings -----------------------------------------
   Int_t c_Canvas    = TColor::GetColor( "#f0f0f0" );
   Int_t c_FrameFill = TColor::GetColor( "#fffffd" );
   Int_t c_TitleBox  = TColor::GetColor( "#6D7B8D" );
   Int_t c_TitleText = TColor::GetColor( "#FFFFFF" );

   c1->SetFrameFillColor( c_FrameFill );
   c1->SetFillColor     ( c_Canvas    );
   c1->Divide(1,2);
   TVirtualPad * c11 = c1->cd(1);
   c11->SetFrameFillColor( c_FrameFill );
   c11->SetFillColor     ( c_Canvas    );

   gStyle->SetTitleFillColor( c_TitleBox  );
   gStyle->SetTitleTextColor( c_TitleText );
   gStyle->SetTitleBorderSize( 1 );
   gStyle->SetTitleH( 0.052 );
   gStyle->SetTitleX( c1->GetLeftMargin() );
   gStyle->SetTitleY( 1 - c1->GetTopMargin() + gStyle->GetTitleH() );
   gStyle->SetTitleW( 1 - c1->GetLeftMargin() - c1->GetRightMargin() );

   TH1D* frame = new TH1D( *unfres );
   frame->SetTitle( "Unfolding toy example with TSVDUnfold" );
   frame->GetXaxis()->SetTitle( "x variable" );
   frame->GetYaxis()->SetTitle( "Events" );
   frame->GetXaxis()->SetTitleOffset( 1.25 );
   frame->GetYaxis()->SetTitleOffset( 1.29 );
   frame->Draw();

   data->SetLineStyle(2);
   data->SetLineColor(4);
   data->SetLineWidth(2);
   unfres->SetMarkerStyle(20);
   datatrue->SetLineColor(2);
   datatrue->SetLineWidth(2);
   xini->SetLineStyle(2);
   xini->SetLineColor(8);
   xini->SetLineWidth(2);
   // ------------------------------------------------------------

   // add histograms
   unfres->Draw("same");
   datatrue->Draw("same");
   data->Draw("same");
   xini->Draw("same");

   leg->Draw();

   // covariance matrix
   gStyle->SetPalette(1,0);
   TVirtualPad * c12 = c1->cd(2);
   c12->Divide(2,1);
   TVirtualPad * c2 = c12->cd(1);
   c2->SetFrameFillColor( c_FrameFill );
   c2->SetFillColor     ( c_Canvas    );
   c2->SetRightMargin   ( 0.15         );

   TH2D* covframe = new TH2D( *ustatcov );
   covframe->SetTitle( "TSVDUnfold covariance matrix" );
   covframe->GetXaxis()->SetTitle( "x variable" );
   covframe->GetYaxis()->SetTitle( "x variable" );
   covframe->GetXaxis()->SetTitleOffset( 1.25 );
   covframe->GetYaxis()->SetTitleOffset( 1.29 );
   covframe->Draw();

   ustatcov->SetLineWidth( 2 );
   ustatcov->Draw( "colzsame" );

   // distribution of the d quantity
   TVirtualPad * c3 = c12->cd(2);
   c3->SetFrameFillColor( c_FrameFill );
   c3->SetFillColor     ( c_Canvas    );
   c3->SetLogy();

   TLine *line = new TLine( 0.,1.,40.,1. );
   line->SetLineStyle(2);

   TH1D* dframe = new TH1D( *ddist );
   dframe->SetTitle( "TSVDUnfold |d_{i}|" );
   dframe->GetXaxis()->SetTitle( "i" );
   dframe->GetYaxis()->SetTitle( "|d_{i}|" );
   dframe->GetXaxis()->SetTitleOffset( 1.25 );
   dframe->GetYaxis()->SetTitleOffset( 1.29 );
   dframe->SetMinimum( 0.001 );
   dframe->Draw();

   ddist->SetLineWidth( 2 );
   ddist->Draw( "same" );
   line->Draw();
}
コード例 #9
0
ファイル: pc3matching.C プロジェクト: XuQiao/HI
void pc3matching() {

  TFile *f = TFile::Open("output_perform.root");

  ofstream fout("run16dAupc3matching.h");
  ofstream fout2("run16dAupc3matchingfirst.h");
  fout << "float pc3dphimean[2][2][5][50];" << endl;
  fout << "float pc3dphisigma[2][2][5][50];" << endl;
  fout << "float pc3dzmean[2][2][5][50];" << endl;
  fout << "float pc3dzsigma[2][2][5][50];" << endl;
  fout << "float pc3dphimeanerr[2][2][5][50];" << endl;
  fout << "float pc3dphisigmaerr[2][2][5][50];" << endl;
  fout << "float pc3dzmeanerr[2][2][5][50];" << endl;
  fout << "float pc3dzsigmaerr[2][2][5][50];" << endl;
  fout << " " << endl;
  fout << "void fetchpc3dphidz();" << endl;
  fout << " " << endl;
  fout << "void fetchpc3dphidz() {" << endl;


  float max = 0.0;
  float sigma = 0.0;
  float mean = 0.0;

  for (Int_t iarm = 0; iarm < 2; iarm++) {
    for (Int_t ich = 0; ich < 2; ich++) {
      for (Int_t ipt = 0; ipt < 50; ipt++) {
        for(Int_t ivz = 0; ivz < 5; ivz++) {
           // if(ipt!=3 || iarm!=0 || ich!=0 || ivz!=0)continue;
            cout<<iarm<<" "<<ich<<" "<<ipt<<" "<<ivz<<endl;
          double sigmaerr=0.0;
	  double meanerr=0.0;
          TString ch = "";
            if(ich == 0) ch = "pos";
            if(ich == 1) ch = "neg";
	  TString histname = Form("pc3dphidz_arm%d_%s_z%d_%d",iarm,ch.Data(),ivz*2,ipt);
	  TString histname1 = Form("pc3dphidz_arm%d_%s_z%d_%d",iarm,ch.Data(),ivz*2+1,ipt);
          TH2D *hist = (TH2D*) f->Get(histname);
          TH2D *hist1 = (TH2D*) f->Get(histname1);
          hist->Add(hist1);

          TH1D *dphi = (TH1D*) hist->ProjectionX(Form("pc3dphi_%d_%d_%d_%d",iarm,ich,ipt,ivz));
          TH1D *dz = (TH1D*) hist->ProjectionY(Form("pc3dz_%d_%d_%d_%d",iarm,ich,ipt,ivz));

	  dphi->GetXaxis()->SetRangeUser(-0.1,0.1);

          gStyle->SetOptFit(1101);

          TF1 *fphi1 = new TF1("fphi1","gaus",-0.1,0.1);
          TF1 *fz1 = new TF1("fz1","gaus",-10,10);
          TF1 *fphi2 = new TF1("fphi2","gaus(0)+gaus(3)",-0.1,0.1);
          TF1 *fz2 = new TF1("fz2","gaus(0)+gaus(3)",-10,10);
          TF1 *phi_gaus1 = new TF1("phi_gaus1","gaus",-0.1,0.1);
          TF1 *phi_gaus2 = new TF1("phi_gaus2","gaus",-0.1,0.1);
          TF1 *z_gaus1 = new TF1("z_gaus1","gaus",-10,10);
          TF1 *z_gaus2 = new TF1("z_gaus2","gaus",-10,10);


          Float_t Xbins = dphi->GetNbinsX();
          Float_t Xmin = dphi->GetXaxis()->GetXmin();
          Float_t Xmax = dphi->GetXaxis()->GetXmax();
          mean = (dphi->GetMaximumBin() * (Xmax-Xmin))/Xbins + Xmin;
          max = dphi->GetMaximum();
          fphi1->SetRange(mean-0.01,mean+0.01);
	  fphi1->SetParameters(max,mean);

          TCanvas *c = new TCanvas("c","c",500,500);
	  //dphi->Scale(1./dphi->Integral());
	  dphi->SetTitle("dphi matching");
	  dphi->GetXaxis()->SetTitle("dphi");
	  dphi->GetYaxis()->SetTitle("# tracks");
	  if (iarm == 1 && ich ==0) dphi->Rebin(2);
	//  dphi->Rebin(2);
	  dphi->SetMarkerSize(1);
	  dphi->SetMarkerStyle(kFullCircle);
          dphi->Draw("P");
          dphi->Fit("fphi1","RQ0");
          double dphi_par[6];
          fphi1->GetParameters(dphi_par);
          dphi_par[3] = 0.1*dphi_par[0];
          dphi_par[4] = dphi_par[1];
          dphi_par[5] = 8*dphi_par[2];
          fphi2->SetParameters(dphi_par);
	  fphi2->SetParLimits(3,0,5*dphi_par[3]);
	  fphi2->SetParLimits(4,-1,1);
	  fphi2->SetParLimits(5,0,100*dphi_par[2]);
          dphi->Fit("fphi2","RQ0");
	  fphi2->Draw("same");
          fphi2->GetParameters(dphi_par);
	  meanerr = fphi2->GetParError(1);
	  sigmaerr = fphi2->GetParError(2);

          fout << "pc3dphimean[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" << dphi_par[1] << ";" << endl;
          fout << "pc3dphisigma[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" <<  dphi_par[2] << ";" << endl;
          fout << "pc3dphimeanerr[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" << meanerr << ";" << endl;
          fout << "pc3dphisigmaerr[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" <<  sigmaerr << ";" << endl;
          if(ipt == 2){
            fout2 << "PC3_dphifirst_mean[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "] = " << dphi_par[1] << ";" << endl;
            fout2 << "PC3_dphifirst_sigma[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "] = " <<  dphi_par[2] << ";" << endl;
          }

          phi_gaus1->SetParameters(dphi_par[0],dphi_par[1],dphi_par[2]);
          phi_gaus1->SetLineColor(1);
          phi_gaus1->Draw("SAME");
          phi_gaus2->SetParameters(dphi_par[3],dphi_par[4],dphi_par[5]);
          phi_gaus2->SetLineColor(6);
          phi_gaus2->Draw("SAME");

          //c->Print(Form("matching/pc3dphi_%d_%d_%d_%d.png",iarm,ich,ipt,ivz));
          delete c;



          Float_t Xbins = dz->GetNbinsX();
          Float_t Xmin = dz->GetXaxis()->GetXmin();
          Float_t Xmax = dz->GetXaxis()->GetXmax();
          mean = (dz->GetMaximumBin() * (Xmax-Xmin))/Xbins + Xmin;
          max = dz->GetMaximum();
          fz1->SetRange(mean-4,mean+4);
	  fz1->SetParameters(max,mean);

          TCanvas *c = new TCanvas("c","c",500,500);
	  //dz->Scale(1./dz->Integral());
	  dz->SetTitle("dz matching");
	  dz->GetXaxis()->SetTitle("dz");
	  dz->GetYaxis()->SetTitle("# tracks");
	  dz->Rebin(5);
          dz->SetMarkerSize(1);
	  dz->SetMarkerStyle(kFullCircle);
	  dz->Draw("P");
          dz->Fit("fz1","RQ0");
          double dz_par[6];
          fz1->GetParameters(dz_par);
          dz_par[3] = 0.1*dz_par[0];
          dz_par[4] = dz_par[1];
          dz_par[5] = 7*dz_par[2];
          fz2->SetParameters(dz_par);
	  fz2->SetParLimits(3,0,5*dz_par[3]);
	  fz2->SetParLimits(4,-1,1);
	  fz2->SetParLimits(5,2*dz_par[2],8*dz_par[2]);
          dz->Fit("fz2","RQ0");
	  fz2->Draw("same");
          fz2->GetParameters(dz_par);
	  meanerr = fz2->GetParError(1);
	  sigmaerr = fz2->GetParError(2);


          fout << "pc3dzmean[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" << dz_par[1] << ";" << endl;
          fout << "pc3dzsigma[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" <<  dz_par[2] << ";" << endl;
          fout << "pc3dzmeanerr[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" << meanerr << ";" << endl;
          fout << "pc3dzsigmaerr[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "]=" <<  sigmaerr << ";" << endl;
          if(ipt == 2){
            fout2 << "PC3_dzfirst_mean[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "] = " << dz_par[1] << ";" << endl;
            fout2 << "PC3_dzfirst_sigma[" << iarm << "][" << ich << "][" << ivz << "][" << ipt << "] = " <<  dz_par[2] << ";" << endl;
          }

          z_gaus1->SetParameters(dz_par[0],dz_par[1],dz_par[2]);
          z_gaus1->SetLineColor(1);
          z_gaus1->Draw("SAME");
          z_gaus2->SetParameters(dz_par[3],dz_par[4],dz_par[5]);
          z_gaus2->SetLineColor(6);
          z_gaus2->Draw("SAME");

          //c->Print(Form("matching/pc3dz_%d_%d_%d_%d.png",iarm,ich,ipt,ivz));
          delete c;
	}
      }
    }
  }
  fout << "}" << endl;

}
コード例 #10
0
ファイル: drawPID.C プロジェクト: maszyman/PlotMacros
// infilename - root file with relevant histograms
// system - PP,APAP,PP
// status - Pass,Fail
// rWrite - 0-no,1-png,2-eps
// rPerformance - 0-no,1-yes (ALICE logo etc.)
// bin: 0 - all, 1- 0:5, 2- 5:10, etc
void drawPID(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, Int_t bin)
{


    TFile *f = new TFile(infilename, "read");

    // TPC dEdx
    TH2D* TPCdEdx =(TH2D*)f->Get(Form("TPCdEdxcut%s1%stpcM%i",status, system,0));

    if (!bin) {
        int minMultBin = 0;
        int maxMultBin = 6; // 8
    }
    else {
        int minMultBin = bin-1;
        int maxMultBin = bin; // 8
    }

    double EvMultall = 0;

    for (int i = minMultBin; i < maxMultBin; i++) {

        TH2D* TPCdEdxN =(TH2D*)f->Get(Form("TPCdEdxcut%s1%stpcM%i",status,system,i));
        TPCdEdx->Add(TPCdEdxN);

        cout << i << " " << TPCdEdxN->GetEntries() << endl;

        //delete hEvMult;
    }

    TCanvas *c2 = new TCanvas("TPC dEdx", "TPC dEdx");
    c2->SetGridx();
    c2->SetGridy();
    c2->SetFillColor(10);
    c2->SetRightMargin(1.9);
    c2->SetLogz();

    TPCdEdx->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
    TPCdEdx->GetXaxis()->SetRangeUser(0.0,6.0);
    TPCdEdx->GetYaxis()->SetTitle("dE/dx");
    TPCdEdx->GetZaxis()->SetLabelSize(0.03);
    TPCdEdx->Draw("colz");

// 	double a1 = -3000.0; double b1 =  1280.0;
// 	double a2 = -312.5;  double b2 =  312.5;
// 	double a3 = -200.0;  double b3 =  240.0;

//    TF1 *fa1 = new TF1("fa1","-1800*x+940",0.3,0.4);
//   fa1->Draw("same");
//   TF1 *fa2 = new TF1("fa2","-500.0*x+420.0",0.4,0.6);
//   fa2->Draw("same");
// TF1 *fa3 = new TF1("fa3","-216.7*x+250.0",0.6,0.9);
//    fa3->Draw("same");
// TF1 *fa4 = new TF1("fa4","-566.7*x+570.0",0.6,0.75);
//    fa4->Draw("same");
// TF1 *fa5 = new TF1("fa5","-2076.92*x+1476.15",0.47,0.6);
//    fa5->Draw("same");
//   cout<<TPCdEdx->GetNbinsX()<<endl;
//   cout<<TPCdEdx->GetNbinsY()<<endl;
//   for (int ii=0;ii<TPCdEdx->GetNbinsX();ii++){

//     for (int jj=0;jj<TPCdEdx->GetNbinsY();jj++){

//       cout<<"binX: "<<ii<<endl;
//       cout<<"binY: "<<jj<<endl;
//       cout<<"val: "<<TPCdEdx->GetBinContent(ii,jj)<<endl;
//     }
//   }

// 	TH1D *py = TPCdEdx->ProjectionY("py", 230, 232); // where firstYbin = 0 and lastYbin = 9
// 	TCanvas *c22 = new TCanvas("TPC2", "TPC2");
// 	py->Draw();

    postprocess(c2,Form("TPCdEdx%s",status),rWrite,rPerformance,system);

    // TPC Nsigma
    TH2D* TPCNsigma =(TH2D*)f->Get(Form("TPCNSigmacut%s1%stpcM%i",status,system,0));

    // int minMultBin = 0;
    // int maxMultBin = 2;
    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {
        //all
        TH2D* TPCNsigmaN =(TH2D*)f->Get(Form("TPCNSigmacut%s1%stpcM%i",status,system,i));
        TPCNsigma->Add(TPCNsigmaN);
        //delete hEvMult;
    }

    TCanvas *c3 = new TCanvas("TPC Nsigma", "TPC Nsigma");
    c3->SetGridx();
    c3->SetGridy();
    c3->SetFillColor(10);
    c3->SetRightMargin(1.7);
    c3->SetLogz();

    TPCNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
    TPCNsigma->GetXaxis()->SetRangeUser(0.0,5.0);
    TPCNsigma->GetYaxis()->SetTitle("number of sigmas");
    TPCNsigma->GetZaxis()->SetLabelSize(0.03);

    TPCNsigma->Draw("colz");

    postprocess(c3,Form("TPCNsigma%s",status),rWrite,rPerformance,system);

    // TOF Nsigma
    TH2D* TOFNsigma =(TH2D*)f->Get(Form("TOFNSigmacut%s1%stpcM%i",status,system,0));

    // int minMultBin = 1;
    // int maxMultBin = 1;
    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {
        //all
        TH2D* TOFNsigmaN =(TH2D*)f->Get(Form("TOFNSigmacut%s1%stpcM%i",status,system,i));
        TOFNsigma->Add(TOFNsigmaN);
        //delete hEvMult;
    }

    TCanvas *c4 = new TCanvas("TOF Nsigma", "TOF Nsigma");
    c4->SetGridx();
    c4->SetGridy();
    c4->SetFillColor(10);
    c4->SetRightMargin(1.7);
    c4->SetLogz();

    TOFNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
    TOFNsigma->GetXaxis()->SetRangeUser(0.0,5.0);
    TOFNsigma->GetYaxis()->SetTitle("number of sigmas from TOF");
    TOFNsigma->GetZaxis()->SetLabelSize(0.03);
    TOFNsigma->Draw("colz");

    postprocess(c4,Form("TOFNsigma%s",status),rWrite,rPerformance,system);

    // TOF time
    TH2D* TOFTime =(TH2D*)f->Get(Form("TOFTimecut%s1%stpcM%i",status,system,0));

    // int minMultBin = 1;
    // int maxMultBin = 1;
    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {
        //all
        TH2D* TOFTimeN =(TH2D*)f->Get(Form("TOFTimecut%s1%stpcM%i",status,system,i));
        TOFTime->Add(TOFTimeN);
        //delete hEvMult;
    }

    TCanvas *c5 = new TCanvas("TOF Time", "TOF Time");
    c5->SetGridx();
    c5->SetGridy();
    c5->SetFillColor(10);
    c5->SetRightMargin(1.7);
    c5->SetLogz();

    TOFTime->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
    TOFTime->GetYaxis()->SetTitle("GetTOFsignal - GetIntegratedTimes");
    TOFTime->GetYaxis()->SetTitleOffset(1.3);
    TOFTime->GetXaxis()->SetRangeUser(0,5);
    TOFTime->GetYaxis()->SetRangeUser(-7000,7000);
    //  TOFTime->GetZaxis()->SetLabelSize(0.03);
    TOFTime->Draw("colz");

    postprocess(c5,Form("TOFTime%s",status),rWrite,rPerformance,system);


    // TPC & TOF Nsigma
    TH2D* TPCTOFNsigma =(TH2D*)f->Get(Form("TPCTOFNSigmacut%s1%stpcM%i",status,system,0));

    int minMultBin = 1;
    int maxMultBin = 1;
    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {
        //all
        TH2D* TPCTOFNsigmaN =(TH2D*)f->Get(Form("TPCTOFNSigmacut%s1%stpcM%i",status,system,i));
        TOFNsigma->Add(TOFNsigmaN);
        //delete hEvMult;
    }

    TCanvas *c6 = new TCanvas("TOF Nsigma", "TOF Nsigma");
    c6->SetGridx();
    c6->SetGridy();
    c6->SetFillColor(10);
    c6->SetRightMargin(1.7);
    c6->SetLogz();

    TPCTOFNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
    TPCTOFNsigma->GetXaxis()->SetRangeUser(0.0,5.0);
    TPCTOFNsigma->GetYaxis()->SetTitle("#sqrt{#frac{n#sigma_{TPC} + n#sigma_{TOF}}{2}}");
    TPCTOFNsigma->GetZaxis()->SetLabelSize(0.03);
    TPCTOFNsigma->Draw("colz");

    postprocess(c6,Form("TPCTOFNsigma%s",status),rWrite,rPerformance,system);

}
コード例 #11
0
/*
 * this script takes 2 TStrings as root filenames as a parameters
 * basic functionality:
 * loop through all directories (the mass bins) in the root file
 * -> create difference plots
 * -> create global plots
 * -> create 2D diff vs mass plots
 * -> etc...
 */
void plotGlobalWeightedEvts_Kpipi(TString input_filename, TString output_filename) {
  setupBookies();

  gROOT->SetStyle("Plain");
  gStyle->SetTitleFont(10*13+2,"xyz");
  gStyle->SetTitleSize(0.06, "xyz");
  gStyle->SetTitleOffset(1.3,"y");
  gStyle->SetTitleOffset(1.3,"z");
  gStyle->SetLabelFont(10*13+2,"xyz");
  gStyle->SetLabelSize(0.06,"xyz");
  gStyle->SetLabelOffset(0.009,"xyz");
  gStyle->SetPadBottomMargin(0.16);
  gStyle->SetPadTopMargin(0.16);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadRightMargin(0.16);
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gROOT->ForceStyle();
  gStyle->SetFrameFillColor(0);
  gStyle->SetFrameFillStyle(0);
  TGaxis::SetMaxDigits(3);
  //IsPhDStyle = true;

  int massbins =0;
  double mass= 0.0, massstart =1000.0, massend=0.0;
  std::map<std::string, std::pair<double, std::pair<double, double> > > diffbounds;

  TFile* infile = TFile::Open(input_filename, "READ");
  TFile* outfile = new TFile(output_filename, "RECREATE");
  outfile->mkdir("global");

  TList *dirlist = infile->GetListOfKeys();
  massbins = dirlist->GetSize();
  infile->cd();
  TIter diriter(dirlist);
  TDirectory *dir;

  std::cout<< "scanning directories and creating overview canvases..." <<std::endl;
  while ((dir = (TDirectory *)diriter())) {
    std::string dirname = dir->GetName();
    // check if directory is mass bin dir
    unsigned int pointpos = dirname.find(".");
    if(pointpos == 0 || pointpos == dirname.size()) continue;
    std::string masslow = dirname.substr(0, pointpos+1);
    std::string masshigh = dirname.substr(pointpos+1);
    double massstarttemp = atof(masslow.c_str())/1000;
    double massendtemp = atof(masshigh.c_str())/1000;
    if((int)(massendtemp - massstarttemp) != massbinwidth)
      massbinwidth = (int)(massendtemp - massstarttemp);
    mass = (massstarttemp + massendtemp)/2;
    if(massstart > massstarttemp) massstart = massstarttemp;
    if(massend < massendtemp) massend = massendtemp;

    outfile->cd();
    outfile->mkdir(dir->GetName());
    infile->cd(dir->GetName());

    // make list of MC Histograms
    TList mclist;
    TList *histlist = gDirectory->GetListOfKeys();
    TIter histiter(histlist);
    TObject *obj;
    while ((obj = histiter())) {
      TString s(obj->GetName());
      if(s.EndsWith("MC"))
        mclist.Add(obj);
      else if(s.Contains("MC_"))
        mclist.Add(obj);
    }
    make1DOverviewCanvas(infile, outfile, &mclist, dirname);
    histiter = TIter(&mclist);
    TH1D *diffhist, *mchist;
    while ((mchist = (TH1D*)histiter())) {
      // generate difference histograms
      std::string hnamemc(mchist->GetName());
      // create new string with MC exchanged for Diff
      std::string hnamediff(hnamemc);
      int pos = hnamemc.find("MC");
      hnamediff.erase(pos, 2);
      hnamediff.insert(pos, "Diff");

      infile->GetObject((std::string(dir->GetName())+"/"+hnamediff).c_str(), diffhist);

      if (diffhist) {
        // get diff min max values
        std::pair<double, std::pair<double, double> > p;

        bool change =false;
        double maxdiff = diffhist->GetMaximum();
        double maxdifftemp = diffhist->GetMinimum();
        if(abs(maxdifftemp) > maxdiff) maxdiff = maxdifftemp;

        double diffmintemp = diffhist->GetXaxis()->GetXmin();
        double diffmaxtemp = diffhist->GetXaxis()->GetXmax();
        std::map<std::string, std::pair<double, std::pair<double, double> > >::iterator iter = diffbounds.find(
            diffhist->GetName());
        if (iter != diffbounds.end()) {
          p.first = iter->second.first;
          p.second.first = iter->second.second.first;
          p.second.second = iter->second.second.second;

          if (iter->second.first < maxdiff) {
            change = true;
            p.first = maxdiff;
          }
          if (iter->second.second.first > diffmintemp) {
            change = true;
            p.second.first = diffmintemp;
          }
          if (iter->second.second.second < diffmaxtemp) {
            change = true;
            p.second.second = diffmaxtemp;
          }

          if (change) {
            diffbounds[diffhist->GetName()] = p;
          }
        }
        else {
          p.first = maxdiff;
          p.second.first = diffmintemp;
          p.second.second = diffmaxtemp;
          diffbounds.insert(std::pair<std::string, std::pair<double, std::pair<double, double> > >(diffhist->GetName(),
              p));
        }
      }
    }
    histiter = TIter(&mclist);
    TH2D *reldiffhist2d, *diffhist2d, *mchist2d, *datahist2d;
    while ((mchist2d = (TH2D*) histiter())) {
      // generate difference histograms
      std::string hnamemc(mchist2d->GetName());
      // create new string with MC exchanged for Diff
      std::string hnamediff(hnamemc);
      int pos = hnamemc.find("MC");
      hnamediff.erase(pos, 2);
      hnamediff.insert(pos, "Diff");
      // create new string with MC exchanged for RelDiff
      std::string hnamereldiff(hnamemc);
      hnamereldiff.erase(pos, 2);
      hnamereldiff.insert(pos, "RelDiff");
      // create new string with MC exchanged for Data
      std::string hnamedata(hnamemc);
      hnamedata.erase(pos, 2);
      hnamedata.insert(pos, "Data");

      infile->GetObject((std::string(dir->GetName()) + "/" + hnamereldiff).c_str(), reldiffhist2d);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamediff).c_str(), diffhist2d);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamedata).c_str(), datahist2d);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamemc).c_str(), mchist2d);

      outfile->cd(dir->GetName());
      make2DOverviewCanvas(mchist2d, datahist2d, diffhist2d, reldiffhist2d, mass);
    }
  }

  dirlist = infile->GetListOfKeys();
  infile->cd();
  diriter = TIter(dirlist);

  std::cout << "creating global histograms and 2D diff vs mass plots..." << std::endl;
  while ((dir = (TDirectory *) diriter())) {
    std::string dirname = dir->GetName();
    // check if directory is mass bin dir
    unsigned int pointpos = dirname.find(".");
    if (pointpos == 0 || pointpos == dirname.size())
      continue;

    infile->cd(dir->GetName());

    // make list of MC Histograms
    TList mclist;
    TList *histlist = gDirectory->GetListOfKeys();
    TIter histiter(histlist);
    TObject *obj;
    while ((obj = histiter())) {
      TString s(obj->GetName());
      if (s.EndsWith("MC"))
        mclist.Add(obj);
      else if (s.Contains("MC_"))
        mclist.Add(obj);
    }
    histiter = TIter(&mclist);
    TH1D *hist;
    TH1D *diffhist, *mchist, *datahist;
    while ((hist = (TH1D*) histiter())) {
      // generate difference histograms
      std::string hnamemc(hist->GetName());
      // create new string with MC exchanged for Diff
      std::string hname(hnamemc);
      int pos = hnamemc.find("MC");
      hname.erase(pos, 2);
      hname.insert(pos, "Diff");
      // create new string with MC exchanged for Data
      std::string hnamedata(hnamemc);
      hnamedata.erase(pos, 2);
      hnamedata.insert(pos, "Data");
      // create new string for MC Global Histogram
      std::string hnamemcglob(hnamemc);
      hnamemcglob.insert(pos + 2, "Global");
      // create new string for MC Global Histogram
      std::string hnamedataglob(hnamemc);
      hnamedataglob.erase(pos, 2);
      hnamedataglob.insert(pos, "DataGlobal");

      infile->GetObject((std::string(dir->GetName()) + "/" + hname + ";1").c_str(), diffhist);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamedata + ";1").c_str(), datahist);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamemc + ";1").c_str(), mchist);
      if (datahist) {
        // make global histograms in global folder
        outfile->cd("global");
        TH1D* hmcglob = (TH1D*) outfile->Get(std::string("global/"+hnamemcglob).c_str());
        if (hmcglob == NULL)
          hmcglob = new TH1D(hnamemcglob.c_str(), mchist->GetTitle(), mchist->GetNbinsX(),
              mchist->GetXaxis()->GetXmin(), mchist->GetXaxis()->GetXmax());
        hmcglob->Add(mchist);
        TH1D* hdataglob = (TH1D*) outfile->Get(std::string("global/"+hnamedataglob).c_str());
        if (hdataglob == NULL)
          hdataglob = new TH1D(hnamedataglob.c_str(), datahist->GetTitle(), datahist->GetNbinsX(),
              datahist->GetXaxis()->GetXmin(), datahist->GetXaxis()->GetXmax());
        hdataglob->Add(datahist);

        // make diff vs. mass plots
        fillDiffvsMassPlot(diffhist, dir->GetName(), massbins, massstart, massend, diffbounds, outfile);
      }
    }
    histiter = TIter(&mclist);
    TH2D *mchist2d, *datahist2d;
    while ((mchist2d = (TH2D*) histiter())) {
      // generate difference histograms
      std::string hnamemc(mchist2d->GetName());
      // create new string with MC exchanged for Diff
      std::string hnamediff(hnamemc);
      int pos = hnamemc.find("MC");
      hnamediff.erase(pos, 2);
      hnamediff.insert(pos, "Diff");
      // create new string with MC exchanged for Data
      std::string hnamedata(hnamemc);
      hnamedata.erase(pos, 2);
      hnamedata.insert(pos, "Data");
      // create new string for MC Global Histogram
      std::string hnamemcglob(hnamemc);
      hnamemcglob.insert(pos + 2, "Global");
      // create new string for MC Global Histogram
      std::string hnamedataglob(hnamemc);
      hnamedataglob.erase(pos, 2);
      hnamedataglob.insert(pos, "DataGlobal");

      infile->GetObject((std::string(dir->GetName()) + "/" + hnamedata + ";1").c_str(), datahist2d);
      infile->GetObject((std::string(dir->GetName()) + "/" + hnamemc + ";1").c_str(), mchist2d);
      if (datahist2d) {
        // make global histograms in global folder
        outfile->cd("global");
        TH2D* hmcglob = (TH2D*) outfile->Get(std::string("global/" + hnamemcglob).c_str());
        if (hmcglob == NULL) {
          hmcglob = new TH2D(hnamemcglob.c_str(), mchist2d->GetTitle(), mchist->GetNbinsX(),
              mchist2d->GetXaxis()->GetXmin(), mchist2d->GetXaxis()->GetXmax(), mchist2d->GetNbinsY(),
              mchist2d->GetYaxis()->GetXmin(), mchist2d->GetYaxis()->GetXmax());
          hmcglob->SetXTitle(mchist2d->GetXaxis()->GetTitle());
          hmcglob->SetYTitle(mchist2d->GetYaxis()->GetTitle());
        }
        hmcglob->Add(mchist2d);
        TH2D* hdataglob = (TH2D*) outfile->Get(std::string("global/" + hnamedataglob).c_str());
        if (hdataglob == NULL) {
          hdataglob = new TH2D(hnamedataglob.c_str(), datahist2d->GetTitle(), datahist2d->GetNbinsX(),
              datahist2d->GetXaxis()->GetXmin(), datahist2d->GetXaxis()->GetXmax(), datahist2d->GetNbinsY(),
              datahist2d->GetYaxis()->GetXmin(), datahist2d->GetYaxis()->GetXmax());
          hdataglob->SetXTitle(datahist2d->GetXaxis()->GetTitle());
          hdataglob->SetYTitle(datahist2d->GetYaxis()->GetTitle());
        }
        hdataglob->Add(datahist2d);
      }
    }
  }

  makeBookies();

  std::cout<< "saving to disk..." <<std::endl;
  outfile->Write();
  std::cout<< "done!" <<std::endl;

  /*// ok lets make a canvas and plug some plots into it -> add to booky
  TCanvas* c = new TCanvas("KineValidate" + massbin, "Weighted Events", 10, 10, 600, 800);
  c->Divide(4, 4);

  // first column contains neutral isobar histograms
  c->cd(1);

  double totMC = GJHB_neutral_isobar.isobar_mass[0]->Integral();
  double totDATA = GJHB_neutral_isobar.isobar_mass[1]->Integral();

  if (totMC != 0)
    GJHB_neutral_isobar.isobar_mass[0]->Scale(totDATA / totMC);
  GJHB_neutral_isobar.isobar_mass[0]->SetLineColor(kRed);
  GJHB_neutral_isobar.isobar_mass[0]->SetFillColor(kRed);
  GJHB_neutral_isobar.isobar_mass[0]->Draw("E4");

  TH1D* hDiffMIsobar = new TH1D(*GJHB_neutral_isobar.isobar_mass[0]);
  hDiffMIsobar->Add(GJHB_neutral_isobar.isobar_mass[1], -1.);
  GJHB_neutral_isobar.isobar_mass[1]->Draw("same");
  hDiffMIsobar->SetLineColor(kOrange - 3);
  hDiffMIsobar->Draw("same");

  GJHB_neutral_isobar.isobar_mass[0]->GetYaxis()->SetRangeUser(hDiffMIsobar->GetMinimum() * 1.5,
      GJHB_neutral_isobar.isobar_mass[0]->GetMaximum() * 1.2);
  gPad->Update();

  c->cd(5);
  totMC = GJHB_neutral_isobar.costheta_GJF[0]->Integral();
  totDATA = GJHB_neutral_isobar.costheta_GJF[1]->Integral();
  if (totMC != 0)
    GJHB_neutral_isobar.costheta_GJF[0]->Scale(totDATA / totMC);
  GJHB_neutral_isobar.costheta_GJF[0]->SetLineColor(kRed);
  GJHB_neutral_isobar.costheta_GJF[0]->SetFillColor(kRed);
  GJHB_neutral_isobar.costheta_GJF[0]->Draw("E4");

  GJHB_neutral_isobar.costheta_GJF[1]->Draw("same E");

  totMC = GJHB_neutral_isobar.costheta_GJF_MC_raw->Integral();
  GJHB_neutral_isobar.costheta_GJF_MC_raw->Scale(totDATA / totMC);
  GJHB_neutral_isobar.costheta_GJF_MC_raw->Draw("same");

  GJHB_neutral_isobar.costheta_GJF[0]->GetYaxis()->SetRangeUser(0, GJHB_neutral_isobar.costheta_GJF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(9);
  totMC = GJHB_neutral_isobar.phi_GJF[0]->Integral();
  totDATA = GJHB_neutral_isobar.phi_GJF[1]->Integral();
  GJHB_neutral_isobar.phi_GJF[0]->Sumw2();
  if (totMC != 0)
    GJHB_neutral_isobar.phi_GJF[0]->Scale(totDATA / totMC);
  GJHB_neutral_isobar.phi_GJF[0]->SetLineColor(kRed);
  GJHB_neutral_isobar.phi_GJF[0]->SetFillColor(kRed);
  GJHB_neutral_isobar.phi_GJF[0]->Draw("E4");

  GJHB_neutral_isobar.phi_GJF[1]->Draw("same E");
  GJHB_neutral_isobar.phi_GJF[0]->GetYaxis()->SetRangeUser(0, GJHB_neutral_isobar.phi_GJF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(13);
  totMC = HHB_neutral_isobar.costheta_HF[0]->Integral();
  totDATA = HHB_neutral_isobar.costheta_HF[1]->Integral();
  HHB_neutral_isobar.costheta_HF[0]->Sumw2();
  if (totMC != 0)
    HHB_neutral_isobar.costheta_HF[0]->Scale(totDATA / totMC);
  HHB_neutral_isobar.costheta_HF[0]->SetLineColor(kRed);
  HHB_neutral_isobar.costheta_HF[0]->SetFillColor(kRed);
  HHB_neutral_isobar.costheta_HF[0]->Draw("E4");

  HHB_neutral_isobar.costheta_HF[1]->Draw("same E");
  HHB_neutral_isobar.costheta_HF[0]->GetYaxis()->SetRangeUser(0,
      HHB_neutral_isobar.costheta_HF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(15);
  totMC = HHB_neutral_isobar.phi_HF[0]->Integral();
  totDATA = HHB_neutral_isobar.phi_HF[1]->Integral();
  HHB_neutral_isobar.phi_HF[0]->Sumw2();
  if (totMC != 0)
    HHB_neutral_isobar.phi_HF[0]->Scale(totDATA / totMC);
  HHB_neutral_isobar.phi_HF[0]->SetLineColor(kRed);
  HHB_neutral_isobar.phi_HF[0]->SetFillColor(kRed);
  HHB_neutral_isobar.phi_HF[0]->Draw("E4");

  HHB_neutral_isobar.phi_HF[1]->Draw("same E");
  HHB_neutral_isobar.phi_HF[0]->GetYaxis()->SetRangeUser(0,
      HHB_neutral_isobar.phi_HF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(2);

  totMC = GJHB_charged_isobar.isobar_mass[0]->Integral();
  totDATA = GJHB_charged_isobar.isobar_mass[1]->Integral();

  if (totMC != 0)
    GJHB_charged_isobar.isobar_mass[0]->Scale(totDATA / totMC);
  GJHB_charged_isobar.isobar_mass[0]->SetLineColor(kRed);
  GJHB_charged_isobar.isobar_mass[0]->SetFillColor(kRed);
  GJHB_charged_isobar.isobar_mass[0]->Draw("E4");

  TH1D* hDiffMIsobar2 = new TH1D(*GJHB_charged_isobar.isobar_mass[0]);
  hDiffMIsobar2->Add(GJHB_charged_isobar.isobar_mass[1], -1.);
  GJHB_charged_isobar.isobar_mass[1]->Draw("same");
  hDiffMIsobar2->SetLineColor(kOrange - 3);
  hDiffMIsobar2->Draw("same");

  GJHB_charged_isobar.isobar_mass[0]->GetYaxis()->SetRangeUser(hDiffMIsobar->GetMinimum() * 1.5,
      GJHB_charged_isobar.isobar_mass[0]->GetMaximum() * 1.2);
  gPad->Update();

  c->cd(6);
  totMC = GJHB_charged_isobar.costheta_GJF[0]->Integral();
  totDATA = GJHB_charged_isobar.costheta_GJF[1]->Integral();
  //hGJ[0]->Sumw2();
  if (totMC != 0)
    GJHB_charged_isobar.costheta_GJF[0]->Scale(totDATA / totMC);
  GJHB_charged_isobar.costheta_GJF[0]->SetLineColor(kRed);
  GJHB_charged_isobar.costheta_GJF[0]->SetFillColor(kRed);
  GJHB_charged_isobar.costheta_GJF[0]->Draw("E4");

  GJHB_charged_isobar.costheta_GJF[1]->Draw("same E");

  totMC = GJHB_charged_isobar.costheta_GJF_MC_raw->Integral();
  GJHB_charged_isobar.costheta_GJF_MC_raw->Scale(totDATA / totMC);
  GJHB_charged_isobar.costheta_GJF_MC_raw->Draw("same");

  GJHB_charged_isobar.costheta_GJF[0]->GetYaxis()->SetRangeUser(0, GJHB_charged_isobar.costheta_GJF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(10);
  totMC = GJHB_charged_isobar.phi_GJF[0]->Integral();
  totDATA = GJHB_charged_isobar.phi_GJF[1]->Integral();
  GJHB_charged_isobar.phi_GJF[0]->Sumw2();
  if (totMC != 0)
    GJHB_charged_isobar.phi_GJF[0]->Scale(totDATA / totMC);
  GJHB_charged_isobar.phi_GJF[0]->SetLineColor(kRed);
  GJHB_charged_isobar.phi_GJF[0]->SetFillColor(kRed);
  GJHB_charged_isobar.phi_GJF[0]->Draw("E4");

  GJHB_charged_isobar.phi_GJF[1]->Draw("same E");
  GJHB_charged_isobar.phi_GJF[0]->GetYaxis()->SetRangeUser(0, GJHB_charged_isobar.phi_GJF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(14);
  totMC = HHB_charged_isobar.costheta_HF[0]->Integral();
  totDATA = HHB_charged_isobar.costheta_HF[1]->Integral();
  HHB_charged_isobar.costheta_HF[0]->Sumw2();
  if (totMC != 0)
    HHB_charged_isobar.costheta_HF[0]->Scale(totDATA / totMC);
  HHB_charged_isobar.costheta_HF[0]->SetLineColor(kRed);
  HHB_charged_isobar.costheta_HF[0]->SetFillColor(kRed);
  HHB_charged_isobar.costheta_HF[0]->Draw("E4");

  HHB_charged_isobar.costheta_HF[1]->Draw("same E");
  HHB_charged_isobar.costheta_HF[0]->GetYaxis()->SetRangeUser(0,
      HHB_charged_isobar.costheta_HF[0]->GetMaximum() * 1.5);
  gPad->Update();

  c->cd(16);
  totMC = HHB_charged_isobar.phi_HF[0]->Integral();
  totDATA = HHB_charged_isobar.phi_HF[1]->Integral();
  HHB_charged_isobar.phi_HF[0]->Sumw2();
  if (totMC != 0)
    HHB_charged_isobar.phi_HF[0]->Scale(totDATA / totMC);
  HHB_charged_isobar.phi_HF[0]->SetLineColor(kRed);
  HHB_charged_isobar.phi_HF[0]->SetFillColor(kRed);
  HHB_charged_isobar.phi_HF[0]->Draw("E4");

  HHB_charged_isobar.phi_HF[1]->Draw("same E");
  HHB_charged_isobar.phi_HF[0]->GetYaxis()->SetRangeUser(0,
      HHB_charged_isobar.phi_HF[0]->GetMaximum() * 1.5);
  gPad->Update();

  // add global diagrams

  c->cd(1);
  TLatex* Label = new TLatex();
  Label->PaintLatex(2, GJHB_neutral_isobar.isobar_mass[0]->GetMaximum() * 0.8, 0, 0.1, massbin.Data());

  c->Update();

  TList* Hlist = gDirectory->GetList();
  Hlist->Remove(mctr);
  Hlist->Remove(datatr);
  //Hlist->Remove("hWeights");

  TFile* outfile = TFile::Open(outfilename, "UPDATE");
  TString psFileName = outfilename;
  psFileName.ReplaceAll(".root", massbin);
  psFileName.Append(".ps");

  if (totMC != 0) {
    // get mass-integrated plots (or create them if not there)

    // neutral isobar
    TH1D* hMIsobarMCGlob = (TH1D*) outfile->Get("hMIsobarMCGlob");
    if (hMIsobarMCGlob == NULL)
      hMIsobarMCGlob = new TH1D("hMIsobarMCGlob", "2#pi neutral Isobar Mass (MC)", nbninsm, 0.2, 2.5);
    hMIsobarMCGlob->Add(GJHB_neutral_isobar.isobar_mass[0]);
    hMIsobarMCGlob->Write();
    TH1D* hMIsobarDataGlob = (TH1D*) outfile->Get("hMIsobarDataGlob");
    if (hMIsobarDataGlob == NULL)
      hMIsobarDataGlob = new TH1D("hMIsobarDataGlob", "2#pi neutral Isobar Mass (DATA)", nbninsm, 0.2, 2.5);
    hMIsobarDataGlob->Add(GJHB_neutral_isobar.isobar_mass[1]);
    hMIsobarDataGlob->Write();

    TH1D* hGJMCGlob = (TH1D*) outfile->Get("hGJMCGlob");
    if (hGJMCGlob == NULL)
      hGJMCGlob = new TH1D("hGJMCGlob", "Gottfried-Jackson Theta (MC)", nbinsang, -1, 1);
    hGJMCGlob->Add(GJHB_neutral_isobar.costheta_GJF[0]);
    hGJMCGlob->Write();
    TH1D* hGJDataGlob = (TH1D*) outfile->Get("hGJDataGlob");
    if (hGJDataGlob == NULL)
      hGJDataGlob = new TH1D("hGJDataGlob", "Gottfried-Jackson Theta (Data)", nbinsang, -1, 1);
    hGJDataGlob->Add(GJHB_neutral_isobar.costheta_GJF[1]);
    hGJDataGlob->Write();

    TH1D* hTYMCGlob = (TH1D*) outfile->Get("hTYMCGlob");
    if (hTYMCGlob == NULL)
      hTYMCGlob = new TH1D("hTYMCGlob", "Treiman-Yang Phi (MC)", nbinsang, -TMath::Pi(),TMath::Pi());
    hTYMCGlob->Add(GJHB_neutral_isobar.phi_GJF[0]);
    hTYMCGlob->Write();
    TH1D* hTYDataGlob = (TH1D*) outfile->Get("hTYDataGlob");
    if (hTYDataGlob == NULL)
      hTYDataGlob = new TH1D("hTYDataGlob", "Treiman-Yang Phi (Data)", nbinsang, -TMath::Pi(),TMath::Pi());
    hTYDataGlob->Add(GJHB_neutral_isobar.phi_GJF[1]);
    hTYDataGlob->Write();

    c->cd(3);
    hMIsobarMCGlob->SetLineColor(kRed);
    hMIsobarMCGlob->SetFillColor(kRed);
    hMIsobarMCGlob->Draw("E4");
    hMIsobarDataGlob->Draw("E SAME");

    c->cd(7);
    hGJMCGlob->SetLineColor(kRed);
    hGJMCGlob->SetFillColor(kRed);
    hGJMCGlob->Draw("E4");
    hGJDataGlob->Draw("E SAME");

    c->cd(11);
    hTYMCGlob->SetLineColor(kRed);
    hTYMCGlob->SetFillColor(kRed);
    hTYMCGlob->Draw("E4");
    hTYDataGlob->Draw("E SAME");


    // charged isobar
    TH1D* hMIsobarMCGlob2 = (TH1D*) outfile->Get("hMIsobarMCGlob2");
    if (hMIsobarMCGlob2 == NULL)
      hMIsobarMCGlob2 = new TH1D("hMIsobarMCGlob2", "2#pi charged Isobar Mass (MC)", nbninsm, 0.2,
          2.5);
    hMIsobarMCGlob2->Add(GJHB_charged_isobar.isobar_mass[0]);
    hMIsobarMCGlob2->Write();
    TH1D* hMIsobarDataGlob2 = (TH1D*) outfile->Get("hMIsobarDataGlob2");
    if (hMIsobarDataGlob2 == NULL)
      hMIsobarDataGlob2 = new TH1D("hMIsobarDataGlob2", "2#pi charged Isobar mass (DATA)", nbninsm,
          0.2, 2.5);
    hMIsobarDataGlob2->Add(GJHB_charged_isobar.isobar_mass[1]);
    hMIsobarDataGlob2->Write();

    TH1D* hGJMCGlob2 = (TH1D*) outfile->Get("hGJMCGlob2");
    if (hGJMCGlob2 == NULL)
      hGJMCGlob2 = new TH1D("hGJMCGlob2", "Gottfried-Jackson Theta (MC)", nbinsang, -1, 1);
    hGJMCGlob2->Add(GJHB_charged_isobar.costheta_GJF[0]);
    hGJMCGlob2->Write();
    TH1D* hGJDataGlob2 = (TH1D*) outfile->Get("hGJDataGlob2");
    if (hGJDataGlob2 == NULL)
      hGJDataGlob2 = new TH1D("hGJDataGlob2", "Gottfried-Jackson Theta (Data)", nbinsang, -1, 1);
    hGJDataGlob2->Add(GJHB_charged_isobar.costheta_GJF[1]);
    hGJDataGlob2->Write();

    TH1D* hTYMCGlob2 = (TH1D*) outfile->Get("hTYMCGlob2");
    if (hTYMCGlob2 == NULL)
      hTYMCGlob2 = new TH1D("hTYMCGlob2", "Treiman-Yang Phi (MC)", nbinsang, -TMath::Pi(),TMath::Pi());
    hTYMCGlob2->Add(GJHB_charged_isobar.phi_GJF[0]);
    hTYMCGlob2->Write();
    TH1D* hTYDataGlob2 = (TH1D*) outfile->Get("hTYDataGlob2");
    if (hTYDataGlob2 == NULL)
      hTYDataGlob2 = new TH1D("hTYDataGlob2", "Treiman-Yang Phi (Data)", nbinsang, -TMath::Pi(),TMath::Pi());
    hTYDataGlob2->Add(GJHB_charged_isobar.phi_GJF[1]);
    hTYDataGlob2->Write();

    c->cd(4);
    hMIsobarMCGlob2->SetLineColor(kRed);
    hMIsobarMCGlob2->SetFillColor(kRed);
    hMIsobarMCGlob2->Draw("E4");
    hMIsobarDataGlob2->Draw("E SAME");

    c->cd(8);
    hGJMCGlob2->SetLineColor(kRed);
    hGJMCGlob2->SetFillColor(kRed);
    hGJMCGlob2->Draw("E4");
    hGJDataGlob2->Draw("E SAME");

    c->cd(12);
    hTYMCGlob2->SetLineColor(kRed);
    hTYMCGlob2->SetFillColor(kRed);
    hTYMCGlob2->Draw("E4");
    hTYDataGlob2->Draw("E SAME");
  }

  c->Write();
  TCanvas dummyCanv("dummy", "dummy");
  c->Print((psFileName));*/
}
コード例 #12
0
ファイル: sysError.C プロジェクト: CmsHI/CVS_SavedFMa
void sysError(
    TString inFileName="jfh_HCPR_J50U_Cent30to100_Aj0to100_SubEtaRefl.root",
    Int_t compMode = 0, // Compare mode: 0 reco-genSig, 1 reco-genAll, 3 genAll-genSig, 4 calo_genp-allGen
    Int_t sysMode = 0, // Plot mode: 0 for simple plot, 1 for difference
    TString outdir = ".",
    TString title = "test"
    ) {
  // ===============================================
  // Inputs
  // ===============================================
  TFile *f = new TFile(inFileName);
  TString inFileNameStrip(inFileName); inFileNameStrip.ReplaceAll(".root","");
  TString inFileNameGen(inFileName);
  if (compMode==0) { 
    inFileNameGen.ReplaceAll("djcalo","djcalo_genp");
    inFileNameGen.ReplaceAll("HydjetAll","HydjetSig");
  }
  if (compMode==1) inFileNameGen.ReplaceAll("djcalo","djcalo_genp");
  else if (compMode==3) inFileNameGen.ReplaceAll("HydjetAll","HydjetSig");
  else if (compMode==5) inFileNameGen.ReplaceAll("djcalo_genp","djgen");
  TFile *fgen = new TFile(inFileNameGen);
  TString inFileNameStripGen(inFileNameGen); inFileNameStripGen.ReplaceAll(".root","");
  cout << "==========================================================" << endl;
  cout << "Compare: " << inFileName << endl
       << "         vs " << endl
       << "         " << inFileNameGen << endl;
  cout << "==========================================================" << endl;

  // ===============================================
  // Setup
  // ===============================================
  TString tag=Form("sysError_%s_%s_%d_%d",inFileNameStrip.Data(),title.Data(),compMode,sysMode);

  // ===============================================
  // Analyze
  // ===============================================
  TH2D * hPtPNDR = (TH2D*) f->Get("hPtPNDR");
  TH2D * hPtPADR = (TH2D*) f->Get("hPtPADR");
  TH2D * hPtPNDRBg = (TH2D*) f->Get("hPtPNDRBg");
  TH2D * hPtPADRBg = (TH2D*) f->Get("hPtPADRBg");
  TH2D * hPtPNDRSub = (TH2D*)hPtPNDR->Clone(tag+"hPtPNDRSub");
  TH2D * hPtPADRSub = (TH2D*)hPtPADR->Clone(tag+"hPtPADRSub");
  hPtPNDRSub->Add(hPtPNDR,hPtPNDRBg,1,-1);
  hPtPADRSub->Add(hPtPADR,hPtPADRBg,1,-1);

  TH2D * hPtPNDRGen = (TH2D*) fgen->Get("hPtPNDR");
  TH2D * hPtPADRGen = (TH2D*) fgen->Get("hPtPADR");
  TH2D * hPtPNDRBgGen = (TH2D*) fgen->Get("hPtPNDRBg");
  TH2D * hPtPADRBgGen = (TH2D*) fgen->Get("hPtPADRBg");
  TH2D * hPtPNDRSubGen = (TH2D*)hPtPNDRGen->Clone(tag+"hPtPNDRSub");
  TH2D * hPtPADRSubGen = (TH2D*)hPtPADRGen->Clone(tag+"hPtPADRSub");
  hPtPNDRSubGen->Add(hPtPNDRGen,hPtPNDRBgGen,1,-1);
  hPtPADRSubGen->Add(hPtPADRGen,hPtPADRBgGen,1,-1);

  // ===============================================
  // Draw
  // ===============================================
  // Get Pt info
  Int_t numPtBins=hPtPNDR->GetNbinsX();
  TH1D * hPt = (TH1D*)hPtPNDR->ProjectionX("hPt");
  /*
  cout << "Pt bins: " << numPtBins << endl;
  for (Int_t i=0; i<numPtBins+2; ++i) {
    cout << "Pt Bin " << i << " Low Edge: " << hPt->GetBinLowEdge(i) << endl;
  }
  */

  // What pt bins to draw
  const Int_t numPtBinsDraw=3;

  TCanvas * c6 = new TCanvas("c"+tag,"c"+tag,1400,500);
  c6->Divide(3,1);
  for (Int_t i=0; i<numPtBinsDraw; ++i) {
    Int_t iBeg,iEnd;
    if (i==0) { iBeg=2; iEnd=3;}
    if (i==1) { iBeg=4; iEnd=4;}
    if (i==2) { iBeg=5; iEnd=numPtBins;}
    cout << "Bin: " << iBeg <<  " to " << iEnd << endl;
    TH1D * hNr = (TH1D*)hPtPNDRSub->ProjectionY(tag+Form("hPNDRSub_%d_%d",iBeg,iEnd),iBeg,iEnd);
    TH1D * hAw = (TH1D*)hPtPADRSub->ProjectionY(tag+Form("hPADRSub_%d_%d",iBeg,iEnd),iBeg,iEnd);
    TH1D * hNrGen = (TH1D*)hPtPNDRSubGen->ProjectionY(tag+Form("hPNDRSubGen_%d_%d",iBeg,iEnd),iBeg,iEnd);
    TH1D * hAwGen = (TH1D*)hPtPADRSubGen->ProjectionY(tag+Form("hPADRSubGen_%d_%d",iBeg,iEnd),iBeg,iEnd);
    if (sysMode==1) {
      hNr->Add(hNrGen,-1);
      hAw->Add(hAwGen,-1);
    }
    if (sysMode==2) {
      hNr->Divide(hNrGen);
      hAw->Divide(hAwGen);
    }
    // Print
    cout << Form("%.1f < P_{T} < %.1f GeV: ",hPt->GetBinLowEdge(iBeg),hPt->GetBinLowEdge(iEnd+1))
      << " SigSubBkg Integral - Nr: " << hNr->Integral() << " Aw: " << hAw->Integral() << endl
      << " Gen - Nr: " << hNrGen->Integral() << " Aw: " << hAwGen->Integral() << endl;
    // Styles
    hNr->SetMarkerColor(kRed);
    hNr->SetLineColor(kRed);
    hAw->SetMarkerColor(kBlue);
    hAw->SetLineColor(kBlue);
    hAwGen->SetLineStyle(2);
    // Axis Range
    if (sysMode==0) {
      hNr->SetYTitle("Background Subtracted Signal (GeV/c)");
      hNr->SetAxisRange(-5,60,"Y");
    }
    if (sysMode==2) {
      hNr->SetAxisRange(-2,6,"Y");
    }
    // Axis Label
    if (compMode==0) {
      if (sysMode==1) {
	hNr->SetYTitle("(Reco Trk)-(Sig GenP) (GeV/c)");
	//hNr->SetAxisRange(-20,20,"Y");
      }
      if (sysMode==2) {
	hNr->SetYTitle("(Reco Trk)/(Sig GenP) (GeV/c)");
      }
    }
    if (compMode==3) {
      if (sysMode==1) {
	hNr->SetYTitle("All GenP - Sig GenP (GeV/c)");
	//hNr->SetAxisRange(-3,3,"Y");
      }
      if (sysMode==2) {
	hNr->SetYTitle("(All GenP)/(Sig GenP) (GeV/c)");
      }
    }
    hNr->SetXTitle("#Delta R");
    hNr->SetAxisRange(0,0.79999,"X");
    hNr->SetTitleOffset(1.5,"X");
    hNr->GetXaxis()->CenterTitle();
    hNr->GetYaxis()->CenterTitle();
    c6->cd(i+1);
    // Fit
    if (sysMode>0) {
      TF1 * f0 = new TF1("f0","pol0");
      f0->SetLineStyle(2);
      f0->SetLineWidth(1);
      hNr->Fit("f0");
      hAw->Fit("f0");
    }
    // Draw to Inspect
    hNr->Draw();
    hAw->Draw("same");
    if (sysMode==0) {
      hNrGen->Draw("hist same");
      hAwGen->Draw("hist same");
    }
    if (sysMode==0||sysMode==1) {
      TLine *l = new TLine(0,0,0.8,0);
      l->Draw();
    }
    if (sysMode==2) {
      TLine *l = new TLine(0,1,0.8,1);
      l->Draw();
    }
    
    TLegend *leg = new TLegend(0.35,0.7,0.85,0.94);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->AddEntry(hNr,Form("%.1f < P_{T} < %.1f GeV",hPt->GetBinLowEdge(iBeg),hPt->GetBinLowEdge(iEnd+1)),"");
    if (sysMode==0) {
      if (compMode==0) {
	leg->AddEntry(hNr,"Leading (RecoTrk)","pl");
	leg->AddEntry(hNrGen,"Leading (Sig. GenP)","l");
	leg->AddEntry(hAw,"SubLeading (RecoTrk)","pl");
	leg->AddEntry(hAwGen,"SubLeading (Sig. GenP)","l");
      }
      if (compMode==1) {
	leg->AddEntry(hNr,"Leading (RecoTrk)","pl");
	leg->AddEntry(hNrGen,"Leading (All GenP)","l");
	leg->AddEntry(hAw,"SubLeading (RecoTrk)","pl");
	leg->AddEntry(hAwGen,"SubLeading (All GenP)","l");
      }
    }
    if (sysMode>0) {
      leg->AddEntry(hNr,"Leading","pl");
      leg->AddEntry(hAw,"SubLeading","pl");
    }
    leg->SetTextSize(0.05);
    leg->Draw();
  }

  // ===============================================
  // Save
  // ===============================================
  c6->Print(Form("%s/%s.gif",outdir.Data(),tag.Data()));
  c6->Print(Form("%s/%s.eps",outdir.Data(),tag.Data()));
  c6->Print(Form("%s/%s.C",outdir.Data(),tag.Data()));
}
コード例 #13
0
ファイル: drawDCA.C プロジェクト: maszyman/PlotMacros
// infilename - root file with relevant histograms
// system - PP,APAP,PP
// status - Pass,Fail
// rWrite - 0-no,1-png,2-eps
// rPerformance - 0-no,1-yes (ALICE logo etc.)
// bin: 0 - all, 1- 0:5, 2- 5:10, etc
void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange)
{

    myOptions(0);

    gROOT->ForceStyle();
    gStyle->SetPalette(1.0);

    TDatime now;
    int iDate = now.GetDate();
    int iYear=iDate/10000;
    int iMonth=(iDate%10000)/100;
    int iDay=iDate%100;
    char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                      "Jul","Aug","Sep","Oct","Nov","Dec"};
    char cStamp1[25],cStamp2[25];
    sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
    sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

    TFile *f = new TFile(infilename, "read");

    // DCA xy
    TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0));


    if (!bin) {
        int minMultBin = 0;
        int maxMultBin = 6; // 8
    }
    else {
        int minMultBin = bin-1;
        int maxMultBin = bin; // 8
    }

    // int minMultBin = 0;
    // int maxMultBin = 0; // 8

    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {

        TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i));
        DCAxy->Add(DCAxyN);

        cout<<i<<" "<<DCAxyN->GetEntries()<<endl;

        //delete hEvMult;
    }


    if (!isMC) {
        TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetRightMargin(1.9);
        c2->SetLogz();

        DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0);
        DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        // DCAxy->GetZaxis()->SetLabelSize(0.05);
        DCAxy->Draw("colz");
        postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X");
        // c4->SetGridx();
        // c4->SetGridy();
        // c4->SetFillColor(10);
        // c4->SetRightMargin(1.9);
        // c4->SetLogy();

        gStyle->SetOptTitle(1);
        TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400);
        myCan->Draw();
        myCan->cd();

        TPad *myPad = new TPad("myPad", "The pad",0,0,1,1);
        myPadSetUp(myPad,0.15,0.04,0.04,0.15);
        myPad->Draw();
        myPad->SetLogy();

        myPad->cd();

        if (ptrange == 0) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100);
            pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}");
        }
        else if (ptrange == 1) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33);
            pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}");
        }
        else if (ptrange == 2) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100);
            pripp->SetTitle("1 < #it{p}_{T} < 3 GeV/#it{c}");
        }

        pripp->SetYTitle("Number of Entries (normalized)");
        pripp->GetXaxis()->SetTitleSize(0.068);
        pripp->GetYaxis()->SetTitleSize(0.068);
        pripp->GetXaxis()->SetLabelSize(0.058);
        pripp->GetYaxis()->SetLabelSize(0.058);

        // pripp->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->SetYTitle("Number of Entries");
        // DCAxy->ProjectionX("asd",50,100)->SetTitle("1.0 < p_{T} < 2.0 GeV");
        // DCAxy->ProjectionX("asd",0,200)->SetTitle("");
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetLabelSize(0.05);

        pripp->Draw("");

        //if (!isMC) {
        pripp->Scale(1./pripp->Integral());
        TFile* fout = new TFile("dca.root","update");
        pripp->SetName(Form("dcaxyMC%d",isMC));
        pripp->Write();
        //}

        postprocess(myCan,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

    }
    else if (isMC) {

        TH2D* primp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dprim","Pass", system,0));
        TH2D* weakp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dweak","Pass", system,0));
        TH2D* matp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dmat","Pass", system,0));

        // prim 2D
        TCanvas *c3prim = new TCanvas("DCA xy primary", "DCA xy primary");
        c3prim->SetGridx();
        c3prim->SetGridy();
        c3prim->SetFillColor(10);
        c3prim->SetRightMargin(1.9);
        c3prim->SetLogz();

        primp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        primp->GetXaxis()->SetRangeUser(-5.0,5.0);
        primp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        primp->GetZaxis()->SetLabelSize(0.03);
        primp->Draw("colz");
        postprocess(c3prim,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // weak 2D
        TCanvas *c3 = new TCanvas("DCA xy weak", "DCA xy weak");
        c3->SetGridx();
        c3->SetGridy();
        c3->SetFillColor(10);
        c3->SetRightMargin(1.9);
        c3->SetLogz();

        weakp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        weakp->GetXaxis()->SetRangeUser(-5.0,5.0);
        weakp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        weakp->GetZaxis()->SetLabelSize(0.03);
        weakp->Draw("colz");
        postprocess(c3,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // mat 2D
        TCanvas *c4 = new TCanvas("DCA xy mat", "DCA xy mat");
        c4->SetGridx();
        c4->SetGridy();
        c4->SetFillColor(10);
        c4->SetRightMargin(1.9);
        c4->SetLogz();

        matp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        matp->GetXaxis()->SetRangeUser(-5.0,5.0);
        matp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        matp->GetZaxis()->SetLabelSize(0.03);
        matp->Draw("colz");
        postprocess(c4,Form("DCAxy%s",status),rWrite,rPerformance,system);


        // prim proj
        gStyle->SetOptTitle(1);

        TCanvas *myCan3prim = new TCanvas("myCan3prim",cStamp1);
        myCan3prim->Draw();
        myCan3prim->cd();

        TPad *myPad3prim = new TPad("myPad3prim", "The pad3prim",0,0,1,1);
        myPadSetUp(myPad3prim,0.15,0.04,0.04,0.15);
        myPad3prim->Draw();
        myPad3prim->SetLogy();

        myPad3prim->cd();

        TH1D* primpp = (TH1D*)primp->ProjectionX("zxc22",0,100);
        primpp->Draw("");

        cout << primpp->FindBin(-0.1) << endl;
        cout << primpp->FindBin(0.1) << endl;

        cout << "primary in cut- " << primpp->Integral(191,211) << endl;
        cout << "primary all- " << primpp->Integral(1,400) << endl;

        postprocess(myCan3prim,Form("DCAxy%sProX",status),rWrite,rPerformance,system);


        // weak proj
        TCanvas *myCan3 = new TCanvas("myCan3",cStamp1);
        myCan3->Draw();
        myCan3->cd();

        TPad *myPad3 = new TPad("myPad3", "The pad3",0,0,1,1);
        myPadSetUp(myPad3,0.15,0.04,0.04,0.15);
        myPad3->Draw();
        myPad3->SetLogy();

        myPad3->cd();

        TH1D* weakpp = (TH1D*)weakp->ProjectionX("zxc2",0,100);
        weakpp->Draw("");

        cout << "weak in cut- " << weakpp->Integral(191,211) << endl;
        cout << "weak all- " << weakpp->Integral(1,400) << endl;

        postprocess(myCan3,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        // mat proj
        gStyle->SetOptTitle(1);
        TCanvas *myCan4 = new TCanvas("myCan4",cStamp1);
        myCan4->Draw();
        myCan4->cd();

        TPad *myPad4 = new TPad("myPad4", "The pad4",0,0,1,1);
        myPadSetUp(myPad4,0.15,0.04,0.04,0.15);
        myPad4->Draw();
        myPad4->SetLogy();

        myPad4->cd();

        TH1D* matpp = (TH1D*)matp->ProjectionX("zxc3",0,100);
        matpp->Draw("");

        cout << "material in cut- " << matpp->Integral(191,211) << endl;
        cout << "material all- " << matpp->Integral(1,400) << endl;

        postprocess(myCan4,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        cout  << "in cut: " << endl;
        cout << "prim - " << primpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "mat - " << matpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;

        cout << endl << "in cut / all " << endl;
        cout << "prim - " << primpp->Integral(191,211) / primpp->Integral(1,400) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / weakpp->Integral(1,400) << endl;
        cout << "mat - " << matpp->Integral(191,211) / matpp->Integral(1,400) << endl;


        // _____sum____

        TH2D* psum = new TH2D("psum","",400, -2.0, 2.0, 100,0.0,2.0);
        psum->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        psum->GetYaxis()->SetTitle("Number of Entries (normalized)");
        psum->GetXaxis()->SetLimits(-2,2);


        for (int i = 0; i < primp->GetNbinsX(); i++) {
            for (int j = 0; j < primp->GetNbinsY(); j++) {
                psum->SetBinContent(i,j,primp->GetBinContent(i,j)+weakp->GetBinContent(i,j)+matp->GetBinContent(i,j));
            }
        }

        gStyle->SetOptStat(0);

        TCanvas *cansum = new TCanvas("cansum",cStamp1,600,400);
        cansum->Draw();
        cansum->cd();

        TPad *padsum = new TPad("padsum", "The pad4",0,0,1,1);
        myPadSetUp(padsum,0.15,0.04,0.04,0.15);
        padsum->Draw();
        padsum->SetLogy();

        padsum->cd();

        // TCanvas* cansum = new TCanvas("cansum","cansum");
        // cansum->SetLogy();
        //psum->Draw("colz");
        TH1D* asd0 = (TH1D*)psum->ProjectionX("zxc",0,100);

        // asd0->Scale(1./asd0->Integral());
        // TFile* fout = new TFile("dca.root","update");
        // asd0->SetName(Form("dcaxyMC%d",isMC));
        // asd0->Write();

        asd0->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        asd0->GetYaxis()->SetTitle("Number of Entries (normalized)");
        //asd0->SetMaximum(5000);
        //asd0->SetMinimum(0.00008);
        asd0->GetXaxis()->SetNdivisions(8);
        asd0->GetYaxis()->SetNdivisions(8);
        //asd0->GetYaxis()->SetTitleOffset(1.4);
        asd0->GetXaxis()->SetTitleSize(0.068);
        asd0->GetYaxis()->SetTitleSize(0.068);
        asd0->GetXaxis()->SetLabelSize(0.058);
        asd0->GetYaxis()->SetLabelSize(0.058);
        asd0->SetFillColor(kBlack);

        Double_t norm = asd0->Integral();
        //asd0->Scale(1./norm);
        //asd0->SetMinimum(0.00007);

        asd0->SetMarkerSize(1.3);
        asd0->SetMarkerColor(kBlack);
        asd0->SetMarkerStyle(20);
        asd0->Draw("pc");

        primpp->SetFillColor(kGreen+2);
        //primpp->Scale(1./norm);
        primpp->SetMarkerSize(1.3);
        primpp->SetMarkerColor(kGreen+2);
        primpp->SetMarkerStyle(20);
        primpp->Draw("psame");

        matpp->SetFillColor(kRed);
        //matpp->Scale(1./norm);
        matpp->SetMarkerSize(1.3);
        matpp->SetMarkerColor(kRed);
        matpp->SetMarkerStyle(20);
        matpp->Draw("psame");

        weakpp->SetFillColor(kBlue);
        //weakpp->Scale(1./norm);
        weakpp->SetMarkerSize(1.3);
        weakpp->SetMarkerColor(kBlue);
        weakpp->SetMarkerStyle(20);
        weakpp->Draw("psame");



        // _____endofsum____


        TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89);
        myLegend->SetFillColor(10);
        myLegend->SetBorderSize(0);

        myLegend->AddEntry(asd0,"all","f");
        myLegend->AddEntry(primpp,"primary","f");
        myLegend->AddEntry(weakpp,"weak decay","f");
        myLegend->AddEntry(matpp,"material","f");
        //myLegend->Draw("same");


        // logo

        TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
        sys->SetNDC();
        sys->SetTextFont(42);
        sys->SetTextSize(0.05);
        sys->SetTextColor(kRed+2);
        sys->Draw();

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);


        TText *date = new TText(0.27,0.5,cStamp2);
        date->SetNDC();
        date->SetTextFont(42);
        date->SetTextSize(0.04);
        date->Draw();

        //           //Acquire canvas proportions
//                 Double_t AliLogo_LowX = 0.27;
//                 Double_t AliLogo_LowY = 0.6;
//                 Double_t AliLogo_Height = 0.22;
//                 //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
//                 Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

//                 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
//                 //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
//                 myPadSetUp(myPadLogo,0,0,0,0);
//                 myPadLogo->SetFixedAspectRatio(1);
//                 myPadLogo->Draw();
//                 myPadLogo->cd();

// //                TASImage *myAliceLogo = new TASImage("alice_preliminary.eps");
//                 TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// //		TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
//                 myAliceLogo->Draw();

        DrawALICELogo(0,0.27,0.55,0.7,0.8);

//logo

        // postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system);
        cansum->SaveAs("DCAxyMC.png");
        cansum->SaveAs("DCAxyMC.eps");
    }

//__________________________________________________


}
コード例 #14
0
void drawJetFragBalance_DRDiff(
			       TString inFileName=    "plot/jfhCorrEtaPtBin4RBin20v2_HCPR_J50U_djcalo_Cent0to30_Aj0to100_SubEtaRefl.root",
			       TString inFileNameHyPy="plot/jfhCorrEtaPtBin4RBin20v2_Hydjet_djcalo_Cent0to30_Aj0to100_SubEtaRefl.root",
    TString title = "test",
    Int_t drawMode=1,
			       Int_t doLeg=1,
bool cumulative = 1
    ) {
  TFile *f = new TFile(inFileName);
  TString inFileNameStrip(inFileName); inFileNameStrip.ReplaceAll(".root","");

  TH2D * hPtPNDR = (TH2D*) f->Get("hPtPNDR");
  TH2D * hPtPADR = (TH2D*) f->Get("hPtPADR");
  TH2D * hPtPNDRBg = (TH2D*) f->Get("hPtPNDRBg");
  TH2D * hPtPADRBg = (TH2D*) f->Get("hPtPADRBg");
  TH2D * hPtPNDRBgSub = (TH2D*)hPtPNDR->Clone(inFileNameStrip+"hPtPNDRBgSub");
  TH2D * hPtPADRBgSub = (TH2D*)hPtPADR->Clone(inFileNameStrip+"hPtPADRBgSub");
  hPtPNDRBgSub->Add(hPtPNDR,hPtPNDRBg,1,-1);
  hPtPADRBgSub->Add(hPtPADR,hPtPADRBg,1,-1);

  TFile *fhypy = new TFile(inFileNameHyPy);
  TH2D * hPtPNDRHyPy = (TH2D*) fhypy->Get("hPtPNDR");
  TH2D * hPtPADRHyPy = (TH2D*) fhypy->Get("hPtPADR");
  TH2D * hPtPNDRBgHyPy = (TH2D*) fhypy->Get("hPtPNDRBg");
  TH2D * hPtPADRBgHyPy = (TH2D*) fhypy->Get("hPtPADRBg");
  TH2D * hPtPNDRBgSubHyPy = (TH2D*)hPtPNDR->Clone(inFileNameStrip+"hPtPNDRBgSubHyPy");
  TH2D * hPtPADRBgSubHyPy = (TH2D*)hPtPADR->Clone(inFileNameStrip+"hPtPADRBgSubHyPy");
  hPtPNDRBgSubHyPy->Add(hPtPNDRHyPy,hPtPNDRBgHyPy,1,-1);
  hPtPADRBgSubHyPy->Add(hPtPADRHyPy,hPtPADRBgHyPy,1,-1);

  // Get Pt info
  Int_t numBinsPt=hPtPNDR->GetNbinsX();
  Int_t numBinsDR=hPtPNDR->GetNbinsY();
  TH1D * hPt = (TH1D*)hPtPNDR->ProjectionX("hPt");
  cout << "Pt bins: " << numBinsPt << endl;

  Double_t totPtBgSubNr=hPtPNDRBgSub->Integral();
  Double_t totPtBgSubAw=hPtPADRBgSub->Integral();

  Double_t totPtBgSubNrHyPy=hPtPNDRBgSubHyPy->Integral();
  Double_t totPtBgSubAwHyPy=hPtPADRBgSubHyPy->Integral();

  int ptUp = 2;
  TH1D * hDRBgSubNr = (TH1D*)hPtPNDRBgSub->ProjectionY(inFileNameStrip+"hDRBgSubNr",1,ptUp);
  TH1D * hDRBgSubAw = (TH1D*)hPtPADRBgSub->ProjectionY(inFileNameStrip+"hDRBgSubAw",1,ptUp);
  TH1D * hDRBgSubNrHyPy = (TH1D*)hPtPNDRBgSubHyPy->ProjectionY(inFileNameStrip+"hDRBgSubNrHyPy",1,ptUp);
  TH1D * hDRBgSubAwHyPy = (TH1D*)hPtPADRBgSubHyPy->ProjectionY(inFileNameStrip+"hDRBgSubAwHyPy",1,ptUp);
  // Print
  cout << Form("%.1f < p_{T} < %.1f GeV/c: ",hPt->GetBinLowEdge(1),hPt->GetBinLowEdge(ptUp+1)) << " SigSubBkg Integral - Nr: " << endl;
  cout << " Data - Nr: " << hDRBgSubNr->Integral() << " Aw: " << hDRBgSubAw->Integral() << endl;
  cout << " Pythia+Hydjet - Nr: " << hDRBgSubNrHyPy->Integral() << " Aw: " << hDRBgSubAwHyPy->Integral() << endl;

  if (drawMode==1) TCanvas * c6 = new TCanvas("c6","c6",500,500);
  hDRBgSubNr->Scale(1./totPtBgSubNr);
  hDRBgSubAw->Scale(1./totPtBgSubAw);
  hDRBgSubNrHyPy->Scale(1./totPtBgSubNrHyPy);
  hDRBgSubAwHyPy->Scale(1./totPtBgSubAwHyPy);

  if(cumulative){
     hDRBgSubNr = IntegrateFromLeft(hDRBgSubNr);
     hDRBgSubAw = IntegrateFromLeft(hDRBgSubAw);
     hDRBgSubNrHyPy = IntegrateFromLeft(hDRBgSubNrHyPy);
     hDRBgSubAwHyPy = IntegrateFromLeft(hDRBgSubAwHyPy);
  }

  // Set Styles
  hDRBgSubNr->SetMarkerStyle(kOpenSquare);
  mcStyle1(hDRBgSubNrHyPy);
  mcStyle2(hDRBgSubAwHyPy);
  hDRBgSubNrHyPy->SetMarkerStyle(0);
  hDRBgSubAwHyPy->SetMarkerStyle(0);
  // Draw
  hDRBgSubNrHyPy->SetTitle(";#DeltaR_{max};F(#DeltaR<#DeltaR_{max})");
  hDRBgSubNrHyPy->SetAxisRange(0,0.784,"X");
  hDRBgSubNrHyPy->SetAxisRange(0,0.7,"Y");
  if(!cumulative){
     hDRBgSubNrHyPy->SetAxisRange(0,0.1,"Y");
  }
  fixedFontHist(hDRBgSubNrHyPy);
  hDRBgSubNrHyPy->DrawCopy("Ehist");
  hDRBgSubAwHyPy->DrawCopy("Ehistsame");
  hDRBgSubNr->DrawCopy("Esame");
  hDRBgSubAw->DrawCopy("Esame");

  if (doLeg==1) {
     TLegend *leg = new TLegend(0.302407,0.67,0.7536548,0.9324599);
    leg->SetFillStyle(0);
    leg->SetBorderSize(0);
    leg->SetTextFont(63);
    leg->SetTextSize(16);
    leg->AddEntry(hDRBgSubNr,Form("%.1f < p_{T} < %.1f GeV/c",hPt->GetBinLowEdge(1),hPt->GetBinLowEdge(ptUp+1)),"");
    leg->AddEntry(hDRBgSubNr,"Data Leading Jet","pl");
    leg->AddEntry(hDRBgSubAw,"Data SubLeading Jet","pl");
    leg->AddEntry(hDRBgSubNrHyPy,"MC Leading Jet","l");
    leg->AddEntry(hDRBgSubAwHyPy,"MC SubLeading Jet","l");
    leg->Draw();
  }
}