Пример #1
0
void flavor_ana(int doMC=1,
                const char * JecType = "abs",
                const char * inFile0Name="../outputs/jetSkimRelValQCD_Pt_80_120_sw354-JEC_Summer09_7TeV_ReReco332.root",
                const char * inFile1Name="djtree_JEC_Summer09_7TeV_ReReco332.root")
{
    // Define Inputs
    cout << "======= Inputs: ========" << endl;
    //cout << "Inclusive jets: " << inFile0Name << endl;
    //cout << "Dijets:         " << inFile1Name << endl;
    //TFile * inFile0 = new TFile(inFile0Name);
    //TFile * inFile1 = new TFile(inFile1Name);
    TFile * inFile0 = new TFile("../outputs/jetSkimRelValQCD_Pt_80_120_sw354-JEC_Summer09_7TeV_ReReco332.root");
    TFile * inFile1 = new TFile(Form("djtree_JEC_Summer09_7TeV_ReReco332_%s.root",JecType));
    TTree * Events;
    inFile0->GetObject("Events",Events);
    TTree * djtree;
    inFile1->GetObject("djtree",djtree);
    aliases(Events);

    // === Dijets ===
    cout << endl << "================ dijets ==============" << endl;
    Int_t numPreSelEvtl = djtree->GetEntries("vz>-99");
    cout << "Events:" << endl;
    cout << "- with none-fake vtx: " << numPreSelEvtl << endl;
    //  - selection -
    TCut evtSelDj("nlpet>80 && nlpet<120 && alpet>80 && jdphi>2.8");
    TCut evtSelDj2("nlpet>80 && nlpet<120 && alpet>80 && jdphi>3.0");
    Int_t numSelEvt1 = djtree->GetEntries(evtSelDj);
    cout << "- Passing sel: " << numSelEvt1 << endl;
    Int_t numSelEvt2 = djtree->GetEntries(evtSelDj2);
    cout << "- Passing diphi sel: " << numSelEvt2 << endl;

    // === flavor studies ===
    TProfile * hNrJFlav = new TProfile("hNrJFlav","flavor",10,85,110);
    hNrJFlav->SetMarkerColor(kRed);
    hNrJFlav->SetLineColor(kRed);
    hNrJFlav->SetMarkerStyle(kOpenCircle);
    hNrJFlav->SetMinimum(0.);
    hNrJFlav->SetMaximum(0.7);
    hNrJFlav->SetTitle(";p_{T}^{gen jet};q jet fraction");
    TProfile * hAwJFlav = (TProfile*)hNrJFlav->Clone("hAwJFlav");
    hAwJFlav->SetMarkerColor(kBlue);
    hAwJFlav->SetLineColor(kBlue);

    TCanvas * cJFlav = new TCanvas("cJFlav","cJFlav",500,500);
    TCut matParton("nlpstat>-99&&alpstat>-99");
    djtree->Draw("(abs(nlpid)<6):nlpet>>hNrJFlav",evtSelDj&&matParton,"prof");
    djtree->Draw("(abs(alpid)<6):alpet>>hAwJFlav",evtSelDj&&matParton,"prof same");

    TLegend *leg2 = new TLegend(0.605,0.216,0.905,0.369,NULL,"brNDC");
    leg2->SetFillColor(0);
    leg2->SetBorderSize(0);
    leg2->SetTextSize(0.03);
    leg2->AddEntry(hNrJFlav,"Di-Jets, Near Jet","p");
    leg2->AddEntry(hAwJFlav,"Di-Jets, Away Jet","p");
    leg2->Draw();
    cJFlav->Print("plots/cDJFlavor.gif");
}
Пример #2
0
TProfile* overlayTProfiles(TH2F* hdata, TH2F* hdy, float ymin, float ymax, TString savename)
{
  // See how the mean of the dimumass changes vs some variable by making TProfiles of a 2D histogram with the Dimu mass as the y axis.
  // Compare data to MC and save the results as png files.

  TString dataname  = TString("Golden_JSON_DoubleMuon_Data");
  TString dyname    = TString("Drell_Yan_Monte_Carlo_2015");

  // Make TProfiles from them to see how the mean changes vs the x variable.
  TProfile* pdata = hdata->ProfileX();
  pdata->SetLineColor(1);
  pdata->SetLineWidth(3);
  pdata->SetTitle(hdata->GetTitle());
  pdata->GetYaxis()->SetTitle(hdata->GetYaxis()->GetTitle());

  TProfile* pdy = hdy->ProfileX();
  pdy->SetLineColor(2);
  pdy->SetLineWidth(3);
  pdy->SetTitle(hdy->GetTitle());
  pdy->GetYaxis()->SetTitle(hdy->GetYaxis()->GetTitle());

  std::cout<< "hdata: " << hdata << std::endl;
  std::cout<< "hdy: " << hdy << std::endl;
  std::cout<< "pdata: " << pdata << std::endl;
  std::cout<< "pdy: " << pdy << std::endl;

  TCanvas* c = new TCanvas();
  c->SetGridx(kTRUE);
  c->SetGridy(kTRUE);

  // Draw data and MC on the same plot
  // Have to draw the same plots twice to get error bars and a curve through the error bars.
  c->cd();
  //    hdata->Draw("colz");
  pdata->SetAxisRange(ymin,ymax,"Y");
  pdata->Draw("hist c");
  pdata->Draw("E X0 same");
  pdy->Draw("hist c same");
  pdy->Draw("E X0 same");

  // Stat box alignment
  DiMuPlottingSystem* dps = new DiMuPlottingSystem();
  dps->arrangeStatBox(c);

  // Legend
  TLegend* l = new TLegend(0.15, 0.15, 0.7, 0.25, "", "brNDC");
  l->AddEntry(pdata, dataname, "l");
  l->AddEntry(pdy, dyname, "l");
  l->Draw("same");
  c->Print(savename);

  return pdata;
}
Пример #3
0
// Draw a 2-D plot within the specified Y range and superimpose its X profile,
// setting as sigmas that of the fit (and not the error of the mean)
void plotAndProfileXSpread (TH2* h2, float min, float max, bool profile=false, float ymin=-5., float ymax=5.) {
  setStyle(h2);
  gPad->SetGrid(1,1);
  gStyle->SetGridColor(15);
  gStyle->SetOptStat(0);
  // h2->RebinX(3);
  // h2->RebinY(2);
  // h2->SetXTitle("distance from anode (cm)");
  // h2->SetYTitle("(d_{reco}-d_{sim})/#sigma_{reco}");
  h2->SetMarkerColor(2);
  h2->SetLineColor(2);
  h2->GetYaxis()->SetTitleOffset(1.4);
  h2->GetXaxis()->SetRangeUser(min,max);
  h2->GetYaxis()->SetRangeUser(ymin,ymax);
  h2->DrawCopy("box");
  if (profile) {
    TProfile* prof = h2->ProfileX("profile",-1,-1,"s");
    prof->SetMarkerStyle(20);
    prof->SetMarkerSize(1.2);
    prof->SetMarkerColor(1);
    prof->SetLineColor(1);
    prof->SetLineWidth(2);
    prof->DrawCopy("same e1");
    delete prof;
  }
  TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
  l->SetLineColor(3);
  l->Draw();
}
Пример #4
0
void rotate2DN(const char* filename,int detNum){


  TFile *f = new TFile(filename);

  TCanvas* cnew= new TCanvas("cnew","",800.,500.);
  cnew->cd();
   

  stringstream sss;
  sss<<"Transposed-"<<filename;
  TFile f1(sss.str().c_str(),"RECREATE");

  for (int i=0;i<detNum;i++){
    stringstream orig ;
    orig<<"hNc"<<i ;
    TH2D* h1=(TH2D*)f->Get(orig.str().c_str());
    
    string gname = h1->GetTitle();
    stringstream hname ;
    hname<<"hN"<<i;
    TH2D* Hnew = new TH2D(hname.str().c_str(),gname.c_str(),1700.,0.,1700.,8000.,0.,8000.);
    for (int x=0;x<8000;x++){
      for (int y=0;y<1600;y++){
 	int bin = h1->GetBinContent(x,y);
	Hnew->Fill(y,x,bin);
      }
    }
    cout<<"Histogram Number "<<i<<" transpose completed"<<endl; 
    cnew->cd();
    
    Hnew->SetMinimum(7);
    Hnew->GetYaxis()->SetRangeUser(1300,1600);
    Hnew->GetYaxis()->SetTitle("Energy (keV)");
    Hnew->GetXaxis()->SetTitle("Cycle Number");
    Hnew->Draw("COLZ");

    TCutG *cutg = new TCutG("NaIcut1",5);
    cutg->SetVarX("y");
    cutg->SetVarY("x");
    cutg->SetPoint(0,0,1350);
    cutg->SetPoint(1,1500,1350);
    cutg->SetPoint(2,1500,1500);
    cutg->SetPoint(3,0,1500);
    cutg->SetPoint(4,0,1350);
     
    TProfile *profx = Hnew->ProfileX(Form("profx_%d",i),1,-1,"[NaIcut1]");

    profx->SetLineColor(kRed);   
    profx->Draw("same");
    cnew->Update();

    gname = gname + ".pdf";
    cnew->SaveAs(gname.c_str());

  }
    f1.Write();
 
}
Пример #5
0
void QAoccupancy(const Char_t *fdata, const Char_t *fmc)
{
  style();

  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("NClustersSPD2");
  TProfile *pdtin = hdtin->ProfileY("pdtin_clusters");
  pdtin->SetMarkerStyle(20);
  pdtin->SetMarkerSize(2);
  pdtin->SetMarkerColor(kAzure-3);
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");
  TH2 *hmcin = (TH2 *)lmcin->FindObject("NClustersSPD2");
  TProfile *pmcin = hmcin->ProfileY("pmcin_clusters");
  pmcin->SetMarkerStyle(25);
  pmcin->SetMarkerSize(2);
  pmcin->SetMarkerColor(kRed+1);

  TCanvas *c = new TCanvas("cOccupancy", "cOccupancy", 800, 800);
  c->SetLogy();
  TH1 * hfr = c->DrawFrame(-0.5, 2., 10.5, 500.);
  DrawBinLabelsX(hfr, kTRUE);
  hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT");
  pdtin->DrawCopy("same");
  pmcin->DrawCopy("same");
  TLegend *legend = new TLegend(0.20, 0.18, 0.50, 0.30);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data", "pl");
  legend->AddEntry(pmcin, "Monte Carlo", "pl");
  legend->Draw("same");
  c->SaveAs(canvasPrefix+"occupancy.pdf");
  return;
  TCanvas *cr = new TCanvas("cOccupancyr", "cOccupancyr", 800, 800);
  // hfr = cr->DrawFrame(-0.5, 0.75, 10.5, 1.25);
  // DrawBinLabelsX(hfr, kTRUE);
  // hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT ratio");
  pdtin->SetLineColor(kAzure-3);
  pdtin->SetLineWidth(3);
  pdtin->Divide(pmcin);
  pdtin->Draw("same,histo"); 
  legend = new TLegend(0.505025, 0.760673, 0.805276, 0.930142);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data / Monte Carlo", "l");
  legend->Draw("same");
  cr->SaveAs(canvasPrefix+"occupancyr.pdf");
  
}
Пример #6
0
void compareTPCTOF(Int_t icentr,Int_t spec,Int_t arm,Float_t pTh,Int_t addbin){
  LoadLib();
  Float_t ptMaxFit[8] = {20,0.7,0.55,1.2,2,2,2,2};

  TProfile *pTPC = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TPC",0,0,-1,-1+2*(spec!=3)); // TPC && !TOF (TPC PID)
  TProfile *pTPC2 = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TPCextra",2,2,-1,-1+2*(spec!=3)); //TPC && TOF (TPC PID)

  TProfile *pTOF = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TOF",1,1,-1,-1+2*(spec!=3)); //TPC && TOF (TPC&TOF PID)

  if(spec > 0) pTPC->Add(pTPC2);
  else pTPC->Add(pTOF);

  char name[100];
  snprintf(name,100,"NUO_%i",spec);

  hNUO[spec] = pTPC->ProjectionX(name);
  hNUO[spec]->Add(pTOF,-1);

  if(spec && hNUO[0]) hNUO[spec]->Add(hNUO[0],-1);

  if(! kCleanMemory){
    new TCanvas();
    pTPC->Draw();
    pTOF->Draw("SAME");

    new TCanvas();  
    pTPC->SetLineColor(1);
    pTOF->SetLineColor(2);
  }

  hNUO[spec]->Draw();

  if(kCleanMemory){
    if(pTPC) delete pTPC;
    if(pTPC2) delete pTPC2;
    if(pTOF) delete pTOF;
  }
}
Пример #7
0
void plotAndProfileX (TH2* h2, float min, float max, bool profile) {
  setStyle(h2);
  gPad->SetGrid(1,1);
  gStyle->SetGridColor(15);
  h2->GetYaxis()->SetRangeUser(min,max);
  h2->Draw();
  if (profile) {
    TProfile* prof = h2->ProfileX();
    prof->SetMarkerColor(2);
    prof->SetLineColor(2);
    prof->Draw("same");
  }
  TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
  l->SetLineColor(3);
  l->Draw();
}
Пример #8
0
void show_mass_dist()
{
    TFile *file_f = new TFile("particle_mass_dist.root");

    TH2F *hm = (TH2F *) file_f->Get("mass_dist");
    TProfile *pm = (TProfile *) file_f->Get("mass_dist_p");

    TCanvas *cm = new TCanvas("cm", "Mass", 1000, 500);
    cm->Divide(2, 1);

    pm->SetLineColor(4);

    cm->cd(1);
    hm->Draw();
    cm->cd(2)->SetBorderMode(0);
    pm->Draw();
}
Пример #9
0
//------------------------------------------------------------//
// Get TProfile
//------------------------------------------------------------//
TProfile* getProfile(TFile* file, TString pname, TString xtitle,
		     TString ytitle, int color, int marker)
{
  
  TProfile* prof = (TProfile*) (file->Get(pname.Data())->Clone(Form("%s_%i",pname.Data(),color)));
  prof->GetXaxis()->SetTitle(xtitle.Data());
  prof->GetYaxis()->SetTitle(ytitle.Data());
  prof->SetMarkerStyle(marker);
  prof->SetMarkerColor(color);
  //prof->SetMarkerSize(0.5);
  prof->SetLineColor(color);
  prof->SetTitle("");
  prof->SetStats(0);
  prof->GetYaxis()->SetTitleOffset(1.5);
  
  return prof;

}
Пример #10
0
TProfile* plotIsoPerformance( TFile* ftt, 
			      const char* signal,     // histogram name
			      const char* background, // histogram name
			      const char* name,       // unique name
			      bool reverse = false,   // normally signal near zero bin, reverse means signal is around max bin
			      double bkg_eff_min = 0,
			      double bkg_eff_max = 1,
			      double sig_eff_min = 0,
			      double sig_eff_max = 0
			      )
{ 
  TH1F* S = dynamic_cast<TH1F*>(ftt->Get(signal));
  if ( ! S ) {
    std::cout << "Error: histogram not found " << signal << std::endl;
    return 0;
  }
  TH1F* B = dynamic_cast<TH1F*>(ftt->Get(background));
  if ( ! B ) {
    std::cout << "Error: histogram not found " << background << std::endl;
    return 0;
  }
  char buf[1024];
  sprintf(buf,"c_%s",name);
  // TCanvas* c = new TCanvas(buf,buf,500,500);
  sprintf(buf,"p_%s",name);
  TProfile* p = new TProfile(buf,buf,50,bkg_eff_min,bkg_eff_max,sig_eff_min,sig_eff_max);
  p->SetLineColor(kBlue);
  p->SetLineWidth(2);
  p->SetMarkerStyle(20);
  p->SetMarkerSize(1);
  p->GetXaxis()->SetTitle("Background Efficiency");
  p->GetYaxis()->SetTitle("Signal Efficiency");
  p->SetStats(kFALSE);
  for( int i=0;i<=S->GetNbinsX()+1; ++i )
    if ( reverse ) 
      p->Fill(B->Integral(i,B->GetNbinsX()+1)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(i,S->GetNbinsX()+1)/S->Integral(0,S->GetNbinsX()+1));
    else
      p->Fill(B->Integral(0,i)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(0,i)/S->Integral(0,S->GetNbinsX()+1));
  // p->Draw();
  return p;
}
Пример #11
0
//----------------------------------------//
// Get profile from all events mixed
//----------------------------------------//
TProfile* getMixProfile(TFile* file, int nbins,
			float xmin, float xmax,
			int color, int marker)
{

  // Histograms all have same base name
  string base = "h_evt";
  
  // String stream easy for manipulation
  stringstream ss;
  
  // Create Profile
  TProfile* p = new TProfile("mixed","",nbins,xmin,xmax);
  p->SetMarkerSize(0.75);
  p->SetMarkerStyle(marker);
  p->SetMarkerColor(color);
  p->SetLineColor(color);

  // Now loop over events and get result
  TH1F* h = NULL;
  for(int i=0; i<m_nEvent; ++i){
    ss.str("");
    ss << base << i;
    h = (TH1F*) file->Get(ss.str().c_str());

    // Loop over bin content
    for(int bin=1; bin<=h->GetNbinsX(); ++bin){
      float content = h->GetBinContent(bin);
      float center  = h->GetBinCenter(bin);
      p->Fill(center, content);
    }
    
    h = NULL;

  }// end loop events

  return p;

}
Пример #12
0
void plotAnaMult4(char *infname="ana.root")
{    
   TFile *inf = new TFile(infname);
   
   TTree *tData = (TTree*) inf->Get("Data_tree");
   TTree *tMC   = (TTree*) inf->Get("MC_tree");
   TTree *tPP   = (TTree*) inf->Get("PP_tree");

   TCanvas *c1 = new TCanvas("c","",1200,700);
//   c->Divide(4,1);
   TCut recoCut = "leadingJetPt>120&&subleadingJetPt>50&&dphi>5*3.14159265358979/6.&&abs(leadingJetEta)<1.6&&abs(subleadingJetEta)<1.6";
   TCut genCut = "genleadingJetPt>120&&gensubleadingJetPt>50&&genDphi>5*3.14159265358979/6.&&abs(genleadingJetEta)<1.6&&abs(gensubleadingJetEta)<1.6";

   
   const int nPtBin=5;
   Float_t PtBins[nPtBin+1] = {0.001,0.5,1,1.5,2,3.2};
   
   Int_t centBin[5] = {200,100,60,20,0};
   makeMultiPanelCanvas(c1,4,2,0.0,0.0,0.2,0.2,0.02);
   
   for (int i=0;i<4;i++) {
      c1->cd(i+1);
      TH1D * empty=new TH1D("empty","",100,0,3.19);
//      empty->Fill(0.5,1000); 
      empty->SetMaximum(39.99); 
      empty->SetMinimum(0.001); 
      empty->SetNdivisions(105,"X");
      empty->GetXaxis()->SetTitleSize(28);
      empty->GetXaxis()->SetTitleFont(43); 
      empty->GetXaxis()->SetTitleOffset(1.8);
      empty->GetXaxis()->SetLabelSize(22);
      empty->GetXaxis()->SetLabelFont(43);
      empty->GetYaxis()->SetTitleSize(28);
      empty->GetYaxis()->SetTitleFont(43); 
      empty->GetYaxis()->SetTitleOffset(1.8);
      empty->GetYaxis()->SetLabelSize(22);
      empty->GetYaxis()->SetLabelFont(43);
      empty->GetXaxis()->CenterTitle();
      empty->GetYaxis()->CenterTitle();

      empty->SetXTitle("#Delta#eta_{1,2}");
      empty->SetYTitle("Multiplicity Difference");
   
      TProfile *pData = new TProfile(Form("pData%d",i),"",nPtBin,PtBins);
      TProfile *pMC = new TProfile(Form("pMC%d",i),"",nPtBin,PtBins);
      TProfile *pPP = new TProfile(Form("pPP%d",i),"",nPtBin,PtBins);
      TProfile *pGen = new TProfile(Form("pGen%d",i),"",nPtBin,PtBins);
      TCut centCut = Form("hiBin>=%d&&hiBin<%d",centBin[i+1],centBin[i]);
      tData->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pData%d",i),recoCut&&centCut);
      tPP->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pPP%d",i),recoCut);
      tMC->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pMC%d",i),recoCut&&centCut);  
      tMC->Draw(Form("-genMultDiff:abs(genleadingJetEta-gensubleadingJetEta)>>pGen%d",i),genCut&&centCut);  

      pMC->SetLineColor(2);
      pMC->SetMarkerColor(2);
      pPP->SetLineColor(4);
      pPP->SetMarkerColor(4);
      
//      pData->SetAxisRange(0,50,"Y");
//      pData->SetAxisRange(0,0.49,"X");
      empty->Draw();

      double diff=0;
      if (i==0) diff=0.1;
      drawText(Form("%d-%d %%",(int)(0.5*centBin[i+1]),(int)(0.5*centBin[i])),0.22+diff,0.65);
      if (i==0) drawText("PbPb #sqrt{s_{NN}}=2.76 TeV 150/#mub",0.22+diff,0.85);
      if (i==0) drawText("pp      #sqrt{s_{NN}}=2.76 TeV 5.3/pb",0.22+diff,0.75);
      if (i==3) drawText("CMS Preliminary",0.3+diff,0.85);
            
      Float_t sys[4]={1,1,2.5,3};
      

      for (int j=1;j<=pData->GetNbinsX();j++)
      {
         TBox *b = new TBox(pData->GetBinLowEdge(j),pData->GetBinContent(j)-sys[i],pData->GetBinLowEdge(j+1),pData->GetBinContent(j)+sys[i]);
	 //b->SetFillColor(kGray);
	 b->SetFillStyle(0);
	 b->SetLineColor(1);
	 b->Draw();
         TBox *b2 = new TBox(pPP->GetBinLowEdge(j),pPP->GetBinContent(j)-1,pPP->GetBinLowEdge(j+1),pPP->GetBinContent(j)+1);
	 //b2->SetFillColor(65);
	 b2->SetFillStyle(0);
	 b2->SetLineColor(4);
	 b2->Draw();
      }
      pData->Draw("same");
      pMC->Draw("same");
      pPP->Draw("same");
      pGen->SetMarkerColor(4);
      pGen->SetMarkerStyle(24);
      pData->Draw("same");
      
//      pGen->Draw(" same");

      c1->cd(5+i);
      TH1D *empty2 = (TH1D*)empty->Clone("empty2");
      empty2->SetYTitle("PbPb - pp");
      empty2->SetMinimum(-5);
      empty2->SetMaximum(+29.99);
      empty2->Draw();
//      TProfile *pDiff = (TProfile*)pData->Clone("pDiff");
      TH1D *pDiff = new TH1D("pDiff","",nPtBin,PtBins);
      
      for (int j=1;j<=pData->GetNbinsX();j++)
      {
	 pDiff->SetBinContent(j,pData->GetBinContent(j)-pPP->GetBinContent(j));
  	 pDiff->SetBinError(j,sqrt(pData->GetBinError(j)*pData->GetBinError(j)+pPP->GetBinError(j)*pPP->GetBinError(j)));
         TBox *b = new TBox(pDiff->GetBinLowEdge(j),pDiff->GetBinContent(j)-sys[i],pDiff->GetBinLowEdge(j+1),pDiff->GetBinContent(j)+sys[i]);
         TBox *b2 = new TBox(pDiff->GetBinLowEdge(j),pDiff->GetBinContent(j)-sys[i],pDiff->GetBinLowEdge(j+1),pDiff->GetBinContent(j)+sys[i]);
         b->SetFillColor(TColor::GetColor("#FFEE00"));
	 b2->SetLineColor(1);
	 b2->SetFillStyle(0);
	 b->Draw();
	 b2->Draw();
      }
      
      pDiff->Draw("p same");


      TLegend *leg = new TLegend(0.3,0.6,0.9,0.9);
      leg->SetFillStyle(0);
      leg->SetBorderSize(0);
      leg->AddEntry(pData,"PbPb","pl");
      leg->AddEntry(pPP,"pp","pl");
      leg->AddEntry(pMC,"PYTHIA+HYDJET","pl");
      if (i==0) leg->Draw();

      if (i==1) drawText("p_{T,1} > 120 GeV/c",0.22+diff,0.85);
      if (i==1) drawText("p_{T,2} >  50 GeV/c",0.22+diff,0.75);
      if (i==1) drawText("#Delta#phi_{1,2} > 5#pi/6",0.22+diff,0.65);

   }
/*
   TCanvas *c1 = new TCanvas("c1","",(ncent+1)*300,700);
   makeMultiPanelCanvas(c1,ncent+1,2,0.0,0.0,0.2,0.2,0.02);
   TH1D * empty=new TH1D("empty",Form(";%s;<#slash{p}_{T}^{#parallel}> (GeV)",axistitle[index_var].Data()),nalpha/2+1,frac);
   TH1D * empty2=new TH1D("empty2",Form(";%s;<#slash{p}_{T}^{#parallel}> (GeV)",axistitle[index_var].Data()),nalpha/2+1,frac);
   empty->Fill(0.5,1000); 
   empty2->Fill(0.5,1000);   
   if(doIntegrate){
      if(index_var==0){
         empty->SetMaximum(30); 
         empty->SetMinimum(-70); 
      }else{
         empty->SetMaximum(35); 
         empty->SetMinimum(-45); 
      }
   }else{
      empty->SetMaximum(15); 
      empty->SetMinimum(-10); 
      empty2->SetMaximum(15); 
      empty2->SetMinimum(-10); 
   }
   empty->GetXaxis()->SetTitleSize(28);
   empty->GetXaxis()->SetTitleFont(43); 
   empty->GetXaxis()->SetTitleOffset(2.2);
   empty->GetXaxis()->SetLabelSize(22);
   empty->GetXaxis()->SetLabelFont(43);
   empty->GetYaxis()->SetTitleSize(28);
   empty->GetYaxis()->SetTitleFont(43); 
   empty->GetYaxis()->SetTitleOffset(2.2);
   empty->GetYaxis()->SetLabelSize(22);
   empty->GetYaxis()->SetLabelFont(43);
   empty2->GetXaxis()->SetTitleSize(28);
   empty2->GetXaxis()->SetTitleFont(43); 
   empty2->GetXaxis()->SetTitleOffset(2.2);
   empty2->GetXaxis()->SetLabelSize(22);
   empty2->GetXaxis()->SetLabelFont(43);
   empty2->GetYaxis()->SetTitleSize(28);
   empty2->GetYaxis()->SetTitleFont(43); 
   empty2->GetYaxis()->SetTitleOffset(2.2);
   empty2->GetYaxis()->SetLabelSize(22);
   empty2->GetYaxis()->SetLabelFont(43);
   
   
   c1->cd(ncent+2); 
*/

   c1->SaveAs("results/MultiplicityDifference-DeltaEta.C");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.gif");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.eps");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.pdf");


}
void draw_clouds_profiles()
{
    //        gROOT->ProcessLine(".L ../utils.C");
    //        gROOT->ProcessLine(".L AliLRCFit.cxx");
    TFile *f[8];

    //    f[0] = new TFile( "output_classesByV0M_LHC10h.root" );
    //    f[0] = new TFile( "output_classesByV0M_LHC10h_c10_5_1.root" );
        f[0] = new TFile( "output_classesByV0M_LHC10h_c10_5_25_1_05.root" );
//    f[0] = new TFile( "output_classesByV0M_LHC11h_FemtoPlus_c10_5_CUT_OUTLIERS.root" );

//    f[0] = new TFile( "output_classesByV0M_LHC15o_fieldMM_c10_5_CUT_OUTLIERS.root" );
//    f[0] = new TFile( "output_classesByV0M_LHC15o_fieldPP_c10_5_CUT_OUTLIERS.root" );

//    const int nCW = 2; //nCentrWidths
//    const double cWidths[nCW] = { 10, 5 }; //width of the centrality bins
//    const double cStep[nCW] = { 5, 2.5 }; //centrality bins step
//    const int nCentrBins[nCW] = { 17, 35 }; //n centrality bins

    //    const int nCW = 3; //nCentrWidths
    //    const double cWidths[nCW] = { 10, 5, 1.0 }; //width of the centrality bins
    //    const double cStep[nCW] = { 5, 2.5, 1.0 }; //centrality bins step
    //    const int nCentrBins[nCW] = { 17, 35, 90 }; //n centrality bins

    //    const int nCW = 4; //nCentrWidths
    //    const double cWidths[nCW] = { 10, 5, 1.0, 0.5 }; //width of the centrality bins
    //    const double cStep[nCW] = { 5, 2.5, 1.0, 1.0 }; //centrality bins step
    //    const int nCentrBins[nCW] = { 17, 35, 90, 90 }; //n centrality bins

        const int nCW = 5; //nCentrWidths
        const double cWidths[nCW] = { 10, 5, 2.5, 1.0, 0.5 }; //width of the centrality bins
        const double cStep[nCW] = { 5, 2.5,  2.5, 1.0, 1.0 }; //centrality bins step
        const int nCentrBins[nCW] = { 17, 35, 36,  90, 90 }; //n centrality bins


    TH2D *hist2D;//[200][3];
    TProfile *profile;//[200][3];
    int cW = 2;
    int etaW = 1;
    int phiW = 0;

    const int kCorrType = 1; //0-NN, 1-PtPt, 2-PtN

    TCanvas *canv_tmp_for_fit = new TCanvas("canv_tmp_for_fit","canv_tmp_for_fit",50,50,300,300 );
    TCanvas *canv_2D_clouds = new TCanvas("canv_2D_clouds","canv_2D_clouds",150,250,1400,600 );
    tuneCanvas(canv_2D_clouds);
    canv_2D_clouds->Divide(2,1);

    gStyle->SetOptStat( kFALSE );

    TGraph *grFromFit2D = new TGraph;

    bool firstDraw = true;
    //    for ( int cBin = 0; cBin < nCentrBins[cW]; cBin++ )
    for ( int cBin = nCentrBins[cW]-1; cBin >= 0; cBin-- )
    {
                if (cBin%2!=0)
                    continue;

        //        cout << "cBin=" << cBin << endl;

        float cBinMin = cStep[cW] * cBin;
        float cBinMax = cWidths[cW] + cStep[cW] * cBin;

        // ##### pad 1 - clouds
        tunePad( canv_2D_clouds->cd(1) );
        if ( kCorrType == 0 )
        {
            hist2D = (TH2D*)f[0]->Get( Form("hist2D_NN_c%.1f-%.1f_etaW_%d_phiW_%d", cBinMin, cBinMax, etaW, phiW) );
            hist2D->SetTitle( "");
            hist2D->GetXaxis()->SetTitle( "N_{ch} Forward");
            hist2D->GetYaxis()->SetTitle( "N_{ch} Backward");
            hist2D->GetXaxis()->SetRangeUser(0,650);
            hist2D->GetYaxis()->SetRangeUser(0,650);
        }
        else if ( kCorrType == 1 )
        {
            hist2D = (TH2D*)f[0]->Get( Form("hist2D_PtPt_c%.1f-%.1f_etaW_%d_phiW_%d", cBinMin, cBinMax, etaW, phiW) );
            hist2D->SetTitle( "");
            hist2D->GetXaxis()->SetTitle( "#LTp_{T}#GT Forward");
            hist2D->GetYaxis()->SetTitle( "#LTp_{T}#GT Backward");
        }     hist2D->SetMarkerColor(kOrange-9+cBin);
        tuneHist2D_onPad(hist2D);
        hist2D->GetXaxis()->CenterTitle();
        hist2D->GetYaxis()->CenterTitle();

        //        removeBinsWithFewEntries(hist2D);

        hist2D->DrawCopy( firstDraw ? "" : "same" );

        // ##### pad 2 - profiles
        tunePad( canv_2D_clouds->cd(2) );
        profile = hist2D->ProfileX();    //(TProfile*)f[0]->Get( Form("hist2D_c%.1f-%.1f_etaW_%d_phiW_%d_pfx", cBinMin, cBinMax, etaW, phiW) );
        if ( kCorrType == 0 )
        {
            profile->SetTitle( "");
            profile->GetYaxis()->SetTitle( "#LTN_{ch}#GT Backward");
            profile->GetXaxis()->SetRangeUser(0,650);
            profile->GetYaxis()->SetRangeUser(0,650);
        }
        else if ( kCorrType == 1 )
        {
            profile->SetTitle( "");
            profile->GetYaxis()->SetTitle( "#LT#LTp_{T}#GT#GT Backward");
        }
        profile->SetLineColor(kOrange-9+cBin);
        profile->SetMarkerStyle(7);
        tuneProfile_onPad( profile );
        profile->GetYaxis()->CenterTitle();

        deleteProfileEmptyBinErrors(profile);


        canv_tmp_for_fit->cd();
        profile->Fit("pol1","Q");//,"",0.25,1.2);//,"N");
        canv_2D_clouds->cd(2);

        TF1 *fit = profile->GetFunction("pol1");
        Double_t p0 = fit->GetParameter(0);
        Double_t p1 = fit->GetParameter(1);
        grFromFit2D->SetPoint(grFromFit2D->GetN(), (cBinMax+cBinMin)/2, p1);

        double meanX = hist2D->ProjectionX()->GetMean();
        double rmsX = hist2D->ProjectionX()->GetRMS();
        fit->SetRange( meanX-3*rmsX, meanX+3*rmsX );
        fit->SetLineColorAlpha( kRed, 0.6 );

        fit->Draw("same");

        profile->DrawCopy( firstDraw ? "" : "same" );



        firstDraw = false;
    }

    TGraphErrors *grByFormula; /*[cW][etaW]*/
    if ( kCorrType == 0 )
    {
        grByFormula = (TGraphErrors*)f[0]->Get( Form( "grNN_c%d_eta%d", cW, etaW ) );
    }
    else if ( kCorrType == 1 )
    {
        grByFormula = (TGraphErrors*)f[0]->Get( Form( "grPtPt_c%d_eta%d", cW, etaW ) );
    }



    TCanvas *canv_GrCoeff = new TCanvas("canv_GrCoeff","canv_GrCoeff",20,150,900,700 );
    grByFormula->Draw("APL");

    grFromFit2D->SetLineColor(kRed);
    grFromFit2D->DrawClone("PL");



    return;

    TGraphErrors *gr[10][10];
    for ( int cW = 0; cW < 2; cW++ )
        for ( int etaW = 0; etaW < 3; etaW++ )
            gr[cW][etaW] = (TGraphErrors*)f[0]->Get( Form( "grPtPt_c%d_eta%d", cW, etaW ) );



    drawGraph( gr[1][0], 24, kBlack, "APL" );
    drawGraph( gr[0][0], 20, kBlack, "PL" );

    //    drawGraph( gr[1][1], 24, kBlue, "PL" );
    //    drawGraph( gr[0][1], 20, kBlue, "PL" );

    //    drawGraph( gr[1][2], 24, kGreen, "PL" );
    //    drawGraph( gr[0][2], 20, kGreen, "PL" );

    ////    drawGraph( gr[6], 24, kRed, "PL" );
    //    drawGraph( gr[7], 20, kRed, "PL" );



    f[1] = new TFile( "output_histos_graphs_LHC15o_fieldMM.root" );
    TGraphErrors *grMM[10][10];
    for ( int cW = 0; cW < 2; cW++ )
        for ( int etaW = 0; etaW < 3; etaW++ )
            grMM[cW][etaW] = (TGraphErrors*)f[1]->Get( Form( "grPtPt_c%d_eta%d", cW, etaW ) );

    drawGraph( grMM[1][0], 24, kGreen, "PL" );
    drawGraph( grMM[0][0], 20, kGreen, "PL" );

    //    drawGraph( grMM[1][1], 24, kRed, "PL" );
    //    drawGraph( grMM[0][1], 20, kRed, "PL" );

    //    drawGraph( grMM[1][2], 24, kGreen, "PL" );
    //    drawGraph( grMM[0][2], 20, kGreen, "PL" );




    //    gROOT->ProcessLine( ".q");
}
Пример #14
0
TProfile *extractFlowVZEROsingle(Int_t icentr,Int_t spec,Int_t arm,Bool_t isMC,Float_t pTh,Int_t addbin,const char *nameSp,Float_t detMin,Float_t detMax,Int_t chMin,Int_t chMax){
  LoadLib();

  pTh += 0.00001;

  // NUA correction currently are missing
  char name[100];
  char stringa[200];

  snprintf(name,100,"AnalysisResults.root");
  if(!fo) fo = new TFile(name);
  snprintf(name,100,"contVZEROv%i",arm);
  TList *cont = (TList *) fo->Get(name);

  cont->ls();

  Float_t xMin[5] = {icentr/*centrality bin*/,chMin/*charge*/,pTh/*prob*/,-TMath::Pi()/arm/*Psi*/,detMin/*PID mask*/};
  Float_t xMax[5] = {icentr+addbin,chMax,1.0,TMath::Pi()/arm,detMax};

  cont->ls();

  TProfile *p1 = cont->At(2);
  TProfile *p2 = cont->At(3);
  TProfile *p3 = cont->At(4);

  TH2F *hPsi2DA = cont->At(5);
  TH2F *hPsi2DC = cont->At(6);

  TH1D *hPsiA = hPsi2DA->ProjectionY("PsiA",icentr+1,icentr+addbin+1);
  TH1D *hPsiC = hPsi2DC->ProjectionY("PsiC",icentr+1,icentr+addbin+1);

  if(!fPsi) fPsi = new TF1("fPsi","pol0",-TMath::Pi()/arm,TMath::Pi()/arm);
  hPsiA->Fit(fPsi,"0");
  Float_t offsetA = fPsi->GetParameter(0);
  hPsiC->Fit(fPsi,"0");
  Float_t offsetC = fPsi->GetParameter(0);

  Int_t nbinPsi = hPsiA->GetNbinsX();

  Float_t *NUAcorrA = new Float_t[nbinPsi];
  Float_t *NUAcorrC = new Float_t[nbinPsi];

  for(Int_t i=0;i < nbinPsi;i++){
    NUAcorrA[i] = offsetA/(hPsiA->GetBinContent(i+1));
    NUAcorrC[i] = offsetC/(hPsiC->GetBinContent(i+1));
  }

  Float_t res1=0,res2=0,res3=0; 
  Float_t eres1=0,eres2=0,eres3=0; 

  for(Int_t i = icentr; i <= icentr+addbin;i++){
    if(p1->GetBinError(i+1)){
      eres1 += 1./p1->GetBinError(i+1)/p1->GetBinError(i+1);
      res1 += p1->GetBinContent(i+1)/p1->GetBinError(i+1)/p1->GetBinError(i+1);      
    }
    if(p2->GetBinError(i+1)){
      eres2 += 1./p2->GetBinError(i+1)/p2->GetBinError(i+1);
      res2 += p2->GetBinContent(i+1)/p2->GetBinError(i+1)/p2->GetBinError(i+1);      
    }
    if(p3->GetBinError(i+1)){
      eres3 += 1./p3->GetBinError(i+1)/p3->GetBinError(i+1);
      res3 += p3->GetBinContent(i+1)/p3->GetBinError(i+1)/p3->GetBinError(i+1);      
    }
  }

  res1 /= eres1;
  res2 /= eres2;
  res3 /= eres3;
  
  eres1 = sqrt(1./eres1);
  eres2 = sqrt(1./eres2);
  eres3 = sqrt(1./eres3);

  AliFlowVZEROResults *a = (AliFlowVZEROResults *) cont->At(0);
  AliFlowVZEROResults *b = (AliFlowVZEROResults *) cont->At(1);
  TProfile *pp,*pp2;
  if(kNUAcorr){ // with NUA corrections
    pp = a->GetV2reweight(spec,xMin,xMax,3,NUAcorrA);
    pp2 = b->GetV2reweight(spec,xMin,xMax,3,NUAcorrC);
  }
  else{
    pp = a->GetV2(spec,xMin,xMax);
    pp2 = b->GetV2(spec,xMin,xMax);
  }
  
  Float_t scaling = sqrt(res1*res3/res2);
  if(kVZEROrescorr){
    pp->Scale(1./scaling);
  }

  Float_t err1_2 = eres1*eres1/res1/res1/4 +
    eres2*eres2/res2/res2/4 +
    eres3*eres3/res3/res3/4;
  Float_t err2_2 = err1_2;
  err1_2 /= scaling*scaling;
  printf("resolution V0A = %f +/- %f\n",scaling,err1_2);
  scaling = sqrt(res2*res3/res1);
  err2_2 /= scaling*scaling;
  if(kVZEROrescorr){
    pp2->Scale(1./scaling);
  }
  printf("resolution V0C =%f +/- %f\n",scaling,err2_2);

  pp->SetName("V0A");
  pp2->SetName("V0C");

  if(! kCleanMemory){
    new TCanvas();  
    pp->Draw();
    pp2->Draw("SAME");
  }

  TProfile *pData = new TProfile(*pp);
  pData->Add(pp2);
  snprintf(stringa,100,"%sData",nameSp);
  pData->SetName(stringa);

  TProfile *pMc = NULL;
  
  TProfile *ppMC;
  TProfile *ppMC2;
  
  if(isMC){
    snprintf(name,100,"contVZEROmc");
    cont = (TList *) fo->Get(name);
    cont->ls();
    if(arm == 2){
      AliFlowVZEROResults *c = (AliFlowVZEROResults *) cont->At(0);
      if(! kCleanMemory) c->GetV2(spec,xMin,xMax)->Draw("SAME");
    }
    AliFlowVZEROResults *cA;
    if(fo->Get("contVZEROv2")) cA = (AliFlowVZEROResults *) cont->At(1+2*(arm==3));
    else cA = (AliFlowVZEROResults *) cont->At(0);
    AliFlowVZEROResults *cC;
    if(fo->Get("contVZEROv2")) cC = (AliFlowVZEROResults *) cont->At(2+2*(arm==3));
    else cC = (AliFlowVZEROResults *) cont->At(1);

    TProfile *p1mc = cont->At(5+3*(arm==3));
    TProfile *p2mc = cont->At(6+3*(arm==3));
    TProfile *p3mc = cont->At(7+3*(arm==3));

    Float_t resMC1=0,resMC2=0,resMC3=0; 
    Float_t eresMC1=0,eresMC2=0,eresMC3=0; 

    for(Int_t i = icentr; i <= icentr+addbin;i++){
      if(p1mc->GetBinError(i+1)){
	eresMC1 += 1./p1mc->GetBinError(i+1)/p1mc->GetBinError(i+1);
	resMC1 += p1mc->GetBinContent(i+1)/p1mc->GetBinError(i+1)/p1mc->GetBinError(i+1);      
      }
      if(p2mc->GetBinError(i+1)){
	eresMC2 += 1./p2mc->GetBinError(i+1)/p2mc->GetBinError(i+1);
	resMC2 += p2mc->GetBinContent(i+1)/p2mc->GetBinError(i+1)/p2mc->GetBinError(i+1);      
      }
      if(p3mc->GetBinError(i+1)){
	eresMC3 += 1./p3mc->GetBinError(i+1)/p3mc->GetBinError(i+1);
	resMC3 += p3mc->GetBinContent(i+1)/p3mc->GetBinError(i+1)/p3mc->GetBinError(i+1);      
      }
    }
    
    resMC1 /= eresMC1;
    resMC2 /= eresMC2;
    resMC3 /= eresMC3;
    
    eresMC1 = sqrt(1./eresMC1);
    eresMC2 = sqrt(1./eresMC2);
    eresMC3 = sqrt(1./eresMC3);

    ppMC = cA->GetV2(spec,xMin,xMax);
    ppMC2 = cC->GetV2(spec,xMin,xMax);
    
    scaling = sqrt(resMC1*resMC3/resMC2);
    ppMC->Scale(1./scaling);
  
    err1_2 = eresMC1*eresMC1/resMC1/resMC1/4 +
      eresMC2*eresMC2/resMC2/resMC2/4 +
      eresMC3*eresMC3/resMC3/resMC3/4;
    err2_2 = err1_2;
    err1_2 /= scaling*scaling;
    printf("resolution V0A (MC) = %f +/- %f\n",scaling,err1_2);
    scaling = sqrt(resMC2*resMC3/resMC1);
    err2_2 /= scaling*scaling;
    ppMC2->Scale(1./scaling);
    printf("resolution V0C (MC) =%f +/- %f\n",scaling,err2_2);

    ppMC->SetName("V0Amc");
    ppMC2->SetName("V0Cmc");

    if(! kCleanMemory){
      ppMC->Draw("SAME");
      ppMC2->Draw("SAME");
    }

    pMc = new TProfile(*ppMC);
    pMc->Add(ppMC2);
    snprintf(stringa,100,"%sMC",nameSp);
    pMc->SetName(stringa);
    pMc->SetLineColor(2);
  }

  if(! kCleanMemory){
    new TCanvas();  
    pData->Draw();
  }
  if(pMc && !kCleanMemory){
    pMc->Draw("SAME");
    TH1D *hData = pData->ProjectionX();
    TH1D *hMc = pMc->ProjectionX();
    hData->Divide(hMc);
    new TCanvas();  
    hData->Draw();
  }

  delete[] NUAcorrA;
  delete[] NUAcorrC;

  if(kCleanMemory){
    if(pp) delete pp;
    if(pp2) delete pp2;
    if(ppMC) delete ppMC;
    if(ppMC2) delete ppMC2;
  }

  delete cont;

  if(isMC) return pMc;
  return pData;
}
Пример #15
0
void fitBjetJES(int ppPbPb=1, int cbinlo=12, int cbinhi=40){

  if(!ppPbPb){
    cbinlo=0;
    cbinhi=40;
  }

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);

  TFile *fL;
  
  if(!ppPbPb)fL=new TFile("histos/ppMC_hiReco_jetTrig_highPurity_JEC.root");
  else     fL=new TFile("histos/PbPbQCDMC_pt30by3_ipHICalibCentWeight.root");

  // these are dummy files for pp
  TFile *fB=new TFile("histos/PbPbBMC_pt30by3_ipHICalibCentWeight.root");
  TFile *fC=new TFile("histos/PbPbCMC_pt30by3_ipHICalibCentWeight.root");


  TNtuple *tL = (TNtuple*) fL->Get("nt");
  TNtuple *tB = (TNtuple*) fB->Get("nt");
  TNtuple *tC = (TNtuple*) fC->Get("nt");
  
  float jtptL, refptL, jtetaL, weightL, refparton_flavorForBL, binL;

  tL->SetBranchAddress("jtpt",&jtptL);
  tL->SetBranchAddress("jteta",&jtetaL);
  tL->SetBranchAddress("refpt",&refptL);
  tL->SetBranchAddress("weight",&weightL);
  if(ppPbPb)tL->SetBranchAddress("bin",&binL);
  tL->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBL);

  float jtptB, refptB, jtetaB, weightB, refparton_flavorForBB, binB;

  tB->SetBranchAddress("jtpt",&jtptB);
  tB->SetBranchAddress("jteta",&jtetaB);
  tB->SetBranchAddress("refpt",&refptB);
  tB->SetBranchAddress("weight",&weightB);
  if(ppPbPb)tB->SetBranchAddress("bin",&binB);
  tB->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBB);

  float jtptC, refptC, jtetaC, weightC, refparton_flavorForBC, binC;

  tC->SetBranchAddress("jtpt",&jtptC);
  tC->SetBranchAddress("jteta",&jtetaC);
  tC->SetBranchAddress("refpt",&refptC);
  tC->SetBranchAddress("weight",&weightC);
  if(ppPbPb)tC->SetBranchAddress("bin",&binC);
  tC->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBC);

  TProfile  *hL = new TProfile("hL","hL",250,50,300,0,10);
  TProfile  *hB = new TProfile("hB","hB",250,50,300,0,10);
  TProfile  *hC = new TProfile("hC","hC",250,50,300,0,10);
  hL->Sumw2(),hB->Sumw2(),hC->Sumw2();


  for(int i=0;i<tL->GetEntries();i++){
    tL->GetEntry(i);
    if(!ppPbPb) binL=39;

    if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi)
      hL->Fill(refptL,jtptL/refptL,weightL); 


    if(!ppPbPb){
      if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi && abs(refparton_flavorForBL)==5)
	hB->Fill(refptL,jtptL/refptL,weightL);
      
      if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi && abs(refparton_flavorForBL)==4)
	hC->Fill(refptL,jtptL/refptL,weightL);      
    }
  }

  if(ppPbPb){
    for(int i=0;i<tB->GetEntries();i++){
      tB->GetEntry(i);
      if(fabs(jtetaB)<2 && binB>=cbinlo && binB<cbinhi && abs(refparton_flavorForBB)==5)
	hB->Fill(refptB,jtptB/refptB,weightB);
    }
    for(int i=0;i<tC->GetEntries();i++){
      tC->GetEntry(i);
      if(fabs(jtetaC)<2 && binC>=cbinlo && binC<cbinhi && abs(refparton_flavorForBC)==4)
	hC->Fill(refptC,jtptC/refptC,weightC);
    }
  }

  
 
  hL->SetMinimum(0.);
  
  hL->SetLineColor(kBlue);
  hB->SetLineColor(kRed);
  hC->SetLineColor(kGreen);

  hL->SetMarkerColor(kBlue);
  hB->SetMarkerColor(kRed);
  hC->SetMarkerColor(kGreen);
  
  //hL->SetMarkerStyle(4);
  //hB->SetMarkerStyle(4);
  //hC->SetMarkerStyle(4);
  
  hL->SetXTitle("genJet p_{T} (GeV/c)");
  hL->SetYTitle("<reco p_{T} / gen p_{T} >");

  hL->GetXaxis()->SetRangeUser(50.,199.999);
  hL->GetYaxis()->SetRangeUser(0.5,1.05);
  
  TCanvas *c1=new TCanvas("c1","c1",800,600);
  c1->SetGridx(1);
  c1->SetGridy(1);

  hL->Draw("e1");
  hB->Draw("e1,same");
  hC->Draw("e1,same");

  TLegend *leg=new TLegend(0.4,0.15,0.9,0.45);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  if(ppPbPb&&cbinlo==0&&cbinhi==40)leg->SetHeader("Pythia+Hydjet, 0-100%");
  leg->AddEntry(hL,"Inclusive jets","pl");
  leg->AddEntry(hC,"c-jets","pl");
  leg->AddEntry(hB,"b-jets","pl");
  leg->Draw();

  TCanvas *c2=new TCanvas("c2","c2",1);
  /*
  TH1F *hL2 = (TH1F*)hL->Clone("hL2");
  TH1F *hB2 = (TH1F*)hB->Clone("hB2");
  hL2->Add(hB2,-1);
  hL2->Draw();
  */

  TH1F  *hcorr = new TH1F("hcorr","hcorr",250,50,300);
  hcorr->Sumw2();

  for(int i=0;i<hL->GetNbinsX();i++){
    cout<<" b resp "<<hB->GetBinContent(i+1)<<endl;
    cout<<" l resp "<<hL->GetBinContent(i+1)<<endl;
    cout<<" l offset "<<1.-hL->GetBinContent(i+1)<<endl;
    cout<<" corrected b resp "<<hB->GetBinContent(i+1)+1.-hL->GetBinContent(i+1)<<endl;
    float jesOffset = 1.-hL->GetBinContent(i+1);

    hcorr->SetBinContent(i+1,hB->GetBinContent(i+1)+jesOffset);

    hcorr->SetBinError(i+1,sqrt(hB->GetBinError(i+1)*hB->GetBinError(i+1)+hL->GetBinError(i+1)*hL->GetBinError(i+1)));


  }

  hcorr->SetMinimum(0.5);
  hcorr->SetMaximum(1.1);
      
  hcorr->SetLineColor(kRed);
  hcorr->SetMarkerColor(kRed);
  hcorr->SetMarkerStyle(4);
  hcorr->Draw();

  TF1 *fCorr = new TF1("fCorr","[0]+[1]*log(x)+[2]*log(x)*log(x)",50,300);
  fCorr->SetLineWidth(1);
  fCorr->SetLineColor(kBlue);
  hcorr->Fit(fCorr);

  TFile *fout;
  if(ppPbPb) fout =new TFile(Form("bJEShistos/bJetScale_PbPb_Cent_fineBin_%d_%d.root",cbinlo,cbinhi),"recreate");
  else fout =new TFile("bJEShistos/bJetScale_PP_fineBin.root","recreate");
  hcorr->Write();
  fCorr->Write();
  fout->Close();

}
Пример #16
0
void deviationBosonPtOld() { 
  TFile *lFile = new TFile("ZTPMC.root");
  TTree *lTree = (TTree*) lFile->FindObjectAny("WNtupleIdEffNT");
  //lTree->Print();
  //lTree->Draw("mt");
  std::string lZPt = "sqrt((abs(pt)*cos(phi)+abs(jetpt)*cos(jetphi))*(abs(pt)*cos(phi)+abs(jetpt)*cos(jetphi)) + (abs(pt)*sin(phi)+abs(jetpt)*sin(jetphi))*(abs(pt)*sin(phi)+abs(jetpt)*sin(jetphi)))";
  TProfile *lPProf = new TProfile("A","A",8,0,40); lPProf->SetMarkerColor(kBlue); lPProf->SetMarkerStyle(21); lPProf->SetLineColor(kBlue);
  TProfile *lMProf = new TProfile("B","B",8,0,40); lMProf->SetMarkerColor(kRed);  lMProf->SetMarkerStyle(21); lMProf->SetLineColor(kRed);
  lTree->Draw(std::string("mt:"+lZPt+">>A").c_str(),std::string("mt > 80 && charge > 0 ").c_str());
  lTree->Draw(std::string("mt:"+lZPt+">>B").c_str(),std::string("mt > 80 && charge < 0 ").c_str());
  //lTree->Draw(std::string("mt>>A").c_str(),"mt > 80 && charge > 0");
  //lTree->Draw(std::string("mt>>B").c_str(),"mt > 80 && charge < 0");
  
  TLegend *lL = new TLegend(0.6,0.6,0.9,0.9);
  lL->SetFillColor(0);
  lL->AddEntry(lPProf,"Plus","lp");
  lL->AddEntry(lMProf,"Minus","lp");
  lPProf->Draw();
  lMProf->Draw("same");
  lL->Draw();
}
void drawOutputOfBensNumberZeroedChannel16BH(){

  // gStyle->SetOptStat("mre");
    

  
  auto cOld = new TChain("angResTree");
  // cOld->Add("januaryTests/photogrammetryNumbers/generateAngularResolutionTreePlots_3*.root");
  cOld->Add("januaryTests/photogrammetryNumbersZeroedChannel16BH_cosminV3Trees/generateAngularResolutionTreePlots_3*.root");  

  auto cNew = new TChain("angResTree");
  cNew->Add("januaryTests/bensNumbersZeroedChannel16BH_cosminV3Trees/generateAngularResolutionTreePlots_3*.root");
  
  const Int_t numVars = 2;
  TString drawVars[numVars] = {"deltaPhiDeg", "deltaThetaDeg"};
  TString varNames[numVars] = {"#delta#phi", "#delta#theta"};  

  for(int varInd=0; varInd < numVars; varInd++){
  
    auto c1 = new TCanvas();
    const Int_t numPhiBins = 128;

    TProfile* hProfOld = new TProfile("hProfOld", "Photogrammetry", numPhiBins, 0, 360);
    TH1D* hOld = new TH1D("hOld", "Photogrammetry", numPhiBins/2, -5, 5);    

    TString drawCommandOld = TString::Format("%s:phiExpected>>hProfOld", drawVars[varInd].Data());
    cOld->Draw(drawCommandOld, "TMath::Abs(deltaPhiDeg) < 5", "goff");

    TString drawCommandOld2 = TString::Format("%s>>hOld", drawVars[varInd].Data());
    cOld->Draw(drawCommandOld2, "TMath::Abs(deltaPhiDeg) < 5", "goff");    

    hProfOld->SetLineColor(kBlue);
    hOld->SetLineColor(kBlue);    


    TProfile* hProfNew = new TProfile("hProfNew", "Ben's numbers", numPhiBins, 0, 360);
    TH1D* hNew = new TH1D("hNew", "Ben's numbers", numPhiBins/2, -5, 5);

    TString drawCommandNew = TString::Format("%s:phiExpected>>hProfNew", drawVars[varInd].Data());
    cNew->Draw(drawCommandNew, "TMath::Abs(deltaPhiDeg) < 5", "goff");
    TString drawCommandNew2 = TString::Format("%s>>hNew", drawVars[varInd].Data());    
    cNew->Draw(drawCommandNew2, "TMath::Abs(deltaPhiDeg) < 5", "goff");    

    hProfNew->SetLineColor(kRed);
    hNew->SetLineColor(kRed);    
  
    hProfNew->Draw();  
    hProfOld->Draw("same");

    // hProfOld->Draw();
    // hProfNew->Draw("same");  

    auto l = c1->BuildLegend();
    l->Draw();


    // TH1D* hs[2] = {hOld, hNew};
    TH1D* hs[2] = {hNew, hOld};    
    TCanvas* c2 = RootTools::drawHistsWithStatsBoxes(2, hs, "", "mre");
    auto l2 = c2->BuildLegend();
    l2->Draw();
    
    hProfNew->SetTitle("Comparison of WAIS divide photogrammetry vs. Ben's numbers "+varNames[varInd]+" ; Expected #phi (Degrees); " + varNames[varInd] + " (Degrees)");
    hProfOld->SetTitle("Comparison of WAIS divide photogrammetry vs. Ben's numbers "+varNames[varInd]+" ; Expected #phi (Degrees); " + varNames[varInd] + " (Degrees)");    
    c1->Update();

    hOld->SetTitle("Comparison of WAIS divide pulses "+varNames[varInd]+", photogrammetry vs. Ben's numbers;"+varNames[varInd]+" (Degrees); Events/bin");
    hNew->SetTitle("Comparison of WAIS divide pulses "+varNames[varInd]+", photogrammetry vs. Ben's numbers;"+varNames[varInd]+" (Degrees); Events/bin");    
    c2->Update();
  }
}