added correction for events with vertex but 0 tracks
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / drawSystematics.C
index 691fbb7..97dd60e 100644 (file)
@@ -676,187 +676,6 @@ void Composition()
   Track2Particle1DComposition(fileNames, nCompositions, folderNames);
 }
 
-Double_t ConvSigma1To2D(Double_t sigma)
-{
-  return TMath::Sqrt( - TMath::Log( 1 - TMath::Erf(sigma / TMath::Sqrt(2)) ) * 2);
-}
-
-Double_t ConvDistance1DTo2D(Double_t distance)
-{
-  return TMath::ErfInverse(1 - TMath::Exp(-distance * distance / 2)) * TMath::Sqrt(2);
-}
-
-Double_t Sigma2VertexCount(TH2F* tracks, Double_t nSigma)
-{
-  Double_t count = 0;
-
-  //nSigma = ConvSigma1To2D(nSigma);
-
-  for (Int_t x=1; x<=tracks->GetNbinsX(); ++x)
-    for (Int_t y=1; y<=tracks->GetNbinsY(); ++y)
-    {
-      Double_t impactX = tracks->GetXaxis()->GetBinCenter(x);
-      Double_t impactY = tracks->GetYaxis()->GetBinCenter(y);
-
-      Float_t d = TMath::Sqrt(impactX*impactX + impactY*impactY);
-
-      d = ConvDistance1DTo2D(d);
-
-      if (d < nSigma)
-        count += tracks->GetBinContent(x, y);
-    }
-
-  return count;
-}
-
-TH2F* Sigma2VertexGaussianTracksHist()
-{
-  TH2F* tracks = new TH2F("Sigma2Vertex_tracks", "Sigma2Vertex_tracks", 200, -5, 5, 200, -5, 5);
-
-  TF2* gaussian2D = new TF2("gaussian2D", "xgausn(0) * ygausn(3)", -5, 5, -5, 5);
-  gaussian2D->SetParameters(1, 0, 1, 1, 0, 1);
-
-  for (Int_t x=1; x<=tracks->GetNbinsX(); ++x)
-    for (Int_t y=1; y<=tracks->GetNbinsY(); ++y)
-      tracks->SetBinContent(x, y, gaussian2D->Eval(tracks->GetXaxis()->GetBinCenter(x), tracks->GetYaxis()->GetBinCenter(y)));
-
-  //normalize
-  tracks->Scale(1.0 / tracks->Integral());
-
-  return tracks;
-}
-
-TH1F* Sigma2VertexGaussian()
-{
-  TH2F* tracks = Sigma2VertexGaussianTracksHist();
-
-  TCanvas* canvas = new TCanvas("Sigma2VertexGaussian", "Sigma2VertexGaussian", 1000, 1000);
-  canvas->Divide(2, 2);
-
-  canvas->cd(1);
-  tracks->Draw("COLZ");
-
-  TH1F* ratio = new TH1F("Sigma2Vertex_ratio", "Sigma2Vertex_ratio;n sigma;included", 50, 0.05, 5.05);
-  for (Double_t nSigma = 0.1; nSigma < 5.05; nSigma += 0.1)
-    ratio->Fill(nSigma, Sigma2VertexCount(tracks, nSigma));
-  ratio->SetMarkerStyle(21);
-
-  canvas->cd(2);
-  ratio->DrawCopy("P");
-
-  TH1F* ratio2 = new TH1F("Sigma2Vertex_ratio2", "Sigma2Vertex_ratio2;nSigma;% included 4 sigma / % included n sigma", 50, 0.05, 5.05);
-  Double_t sigma3 = Sigma2VertexCount(tracks, 4);
-  for (Double_t nSigma = 0.1; nSigma < 5.05; nSigma += 0.1)
-    ratio2->Fill(nSigma, sigma3 / ratio->GetBinContent(ratio->FindBin(nSigma)));
-  ratio2->SetMarkerStyle(21);
-
-  canvas->cd(3);
-  ratio2->DrawCopy("P");
-
-  canvas->SaveAs("Sigma2Vertex.eps");
-
-  return ratio2;
-}
-
-TH1F** Sigma2VertexSimulation(const char* fileName = "systematics.root")
-{
-  TFile* file = TFile::Open(fileName);
-
-  TH1F* sigmavertex = dynamic_cast<TH1F*> (file->Get("fSigmaVertexTracks"));
-  TH1F* sigmavertexPrim = dynamic_cast<TH1F*> (file->Get("fSigmaVertexPrim"));
-  if (!sigmavertex || !sigmavertexPrim)
-  {
-    printf("Could not read histogram(s)\n");
-    return;
-  }
-
-  // calculate ratio
-  TH1F* ratio = new TH1F("sigmavertexsimulation_ratio", "sigmavertexsimulation_ratio;N#sigma;% included in 4 #sigma / % included in N#sigma", sigmavertex->GetNbinsX(), sigmavertex->GetXaxis()->GetXmin(), sigmavertex->GetXaxis()->GetXmax());
-
-  // calculate contamination
-  TH1F* contamination = ratio->Clone("sigmavertexsimulation_contamination");
-  contamination->SetTitle("sigmavertexsimulation_contamination;N#sigma;1 + N_{secondaries} / N_{all}");
-
-  for (Int_t i=1; i<=sigmavertex->GetNbinsX(); ++i)
-  {
-    ratio->SetBinContent(i, sigmavertex->GetBinContent(sigmavertex->GetXaxis()->FindBin(4)) / sigmavertex->GetBinContent(i));
-    contamination->SetBinContent(i, 1 + (sigmavertex->GetBinContent(i) - sigmavertexPrim->GetBinContent(i)) / sigmavertex->GetBinContent(i));
-  }
-
-  // print stats
-  for (Float_t sigma = 2.0; sigma < 5.25; sigma += 0.5)
-  {
-    Float_t error1 = 1 - ratio->GetBinContent(sigmavertex->GetXaxis()->FindBin(sigma)) / ratio->GetBinContent(sigmavertex->GetXaxis()->FindBin(sigma - 0.5));
-    Float_t error2 = -1 + ratio->GetBinContent(sigmavertex->GetXaxis()->FindBin(sigma)) / ratio->GetBinContent(sigmavertex->GetXaxis()->FindBin(sigma + 0.5));
-    Float_t cont = -1 + contamination->GetBinContent(sigmavertex->GetXaxis()->FindBin(sigma));
-    Printf("%.2f sigma --> syst. error = - %.2f %% + %.2f %%, cont. = %.2f %%", sigma, error1 * 100, error2 * 100, cont * 100);
-  }
-
-  TCanvas* canvas = new TCanvas("Sigma2VertexSimulation", "Sigma2VertexSimulation", 1000, 500);
-  canvas->Divide(2, 1);
-
-  canvas->cd(1);
-  sigmavertex->SetMarkerStyle(21);
-  sigmavertex->Draw("P");
-
-  canvas->cd(2);
-  ratio->SetMarkerStyle(21);
-  ratio->DrawCopy("P");
-
-  contamination->DrawCopy("SAME");
-
-  TH1F** returnContainer = new TH1F*[2];
-  returnContainer[0] = ratio;
-  returnContainer[1] = contamination;
-
-  return returnContainer;
-}
-
-void Sigma2VertexCompare(const char* fileName = "systematics.root")
-{
-  TH1F* ratio1 = Sigma2VertexGaussian();
-
-  TH1F** hists = Sigma2VertexSimulation(fileName);
-  TH1F* ratio2 = hists[0];
-  TH1F* contamination = hists[1];
-
-  ratio1->SetStats(kFALSE);
-  ratio2->SetStats(kFALSE);
-
-  ratio1->SetMarkerStyle(0);
-  ratio2->SetMarkerStyle(0);
-
-  ratio1->SetLineWidth(2);
-  ratio2->SetLineWidth(2);
-
-  TLegend* legend = new TLegend(0.6, 0.8, 0.95, 0.95);
-  legend->SetFillColor(0);
-  legend->AddEntry(ratio1, "Gaussian");
-  legend->AddEntry(ratio2, "Simulation");
-  legend->AddEntry(contamination, "1 + Contamination");
-
-  ratio2->SetTitle("");
-  ratio2->GetYaxis()->SetTitleOffset(1.5);
-  ratio2->GetXaxis()->SetRangeUser(2, 5);
-
-  TCanvas* canvas = new TCanvas("Sigma2VertexCompare", "Sigma2VertexCompare", 500, 500);
-  InitPad();
-
-  ratio2->SetMarkerStyle(21);
-  ratio1->SetMarkerStyle(22);
-
-  ratio2->GetYaxis()->SetRangeUser(0.8, 1.2);
-  ratio2->SetLineColor(kRed);
-  ratio2->SetMarkerColor(kRed);
-  ratio2->Draw("PL");
-  ratio1->Draw("SAMEPL");
-
-  contamination->Draw("SAME");
-
-  legend->Draw();
-
-  canvas->SaveAs("Sigma2VertexCompare.eps");
-}
 
 void drawSystematics()
 {