+
+TH2* GetAcceptance(void* corr2d_void)
+{
+ corr2d = (AliCorrectionMatrix2D*) corr2d_void;
+ corr_xy = (TH2*) corr2d->GetCorrectionHistogram()->Clone("acceptance");
+
+ // fold in acceptance
+ for (Int_t x=1; x<=corr_xy->GetNbinsX(); ++x)
+ for (Int_t y=1; y<=corr_xy->GetNbinsY(); ++y)
+ {
+ if (corr_xy->GetBinContent(x, y) > 1.5)
+ corr_xy->SetBinContent(x, y, 0);
+
+ if (corr_xy->GetBinContent(x, y) > 0)
+ corr_xy->SetBinContent(x, y, 1);
+
+ corr_xy->SetBinError(x, y, 0);
+ }
+
+ return corr_xy;
+}
+
+void ZeroOutsideAcceptance(TH2* acc, TH3* hist)
+{
+ for (Int_t x=0; x<=acc->GetNbinsX()+1; ++x)
+ for (Int_t y=0; y<=acc->GetNbinsY()+1; ++y)
+ {
+ if (acc->GetBinContent(x, y) > 1.5 || acc->GetBinContent(x, y) == 0)
+ {
+ for (Int_t z=0; z<=hist->GetNbinsZ()+1; ++z)
+ {
+ hist->SetBinContent(x, y, z, 0);
+ hist->SetBinError(x, y, z, 0);
+ }
+ }
+ }
+}
+
+void DrawPhi()
+{
+ loadlibs();
+
+ TFile::Open("correction_map.root");
+ AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction");
+ if (!dNdEtaCorrection->LoadHistograms())
+ return 0;
+
+ TFile::Open("analysis_esd.root");
+ dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaTrVtx", "dndetaTrVtx");
+ fdNdEtaAnalysis->LoadHistograms();
+
+ // acc. map!
+ //acc = GetAcceptance(dNdEtaCorrection->GetCorrection(1)->GetTrackCorrection()->Get2DCorrection("yx", 0, 1000));
+ acc = dNdEtaCorrection->GetCorrection(1)->GetTrackCorrection()->Get2DCorrection("yx", 0, 1000)->GetCorrectionHistogram();
+ //new TCanvas; acc->Draw("COLZ");
+
+ histG = fdNdEtaAnalysis->GetData()->GetTrackCorrection()->GetGeneratedHistogram();
+ ZeroOutsideAcceptance(acc, histG);
+ //new TCanvas; histG->Project3D("yx")->Draw("COLZ");
+ //histG->GetYaxis()->SetRangeUser(-0.9, 0.9);
+
+ histM = fdNdEtaAnalysis->GetData()->GetTrackCorrection()->GetMeasuredHistogram();
+ ZeroOutsideAcceptance(acc, histM);
+ //histM->GetYaxis()->SetRangeUser(-0.9, 0.9);
+
+ TFile::Open("analysis_mc.root");
+ dNdEtaAnalysis* fdNdEtaAnalysis2 = new dNdEtaAnalysis("dndetaTrVtxMC", "dndetaTrVtxMC");
+ fdNdEtaAnalysis2->LoadHistograms("dndetaTrVtx");
+
+ histMC = fdNdEtaAnalysis2->GetData()->GetTrackCorrection()->GetMeasuredHistogram();
+ ZeroOutsideAcceptance(acc, histMC);
+ //new TCanvas; histMC->Project3D("yx2")->Draw("COLZ");
+
+ //histG->GetZaxis()->SetRangeUser(1,2); histMC->GetZaxis()->SetRangeUser(1,2);
+ new TCanvas; a = histG->Project3D("yx3"); a->Add(histMC->Project3D("yx4"), -1); a->Draw("COLZ");
+
+ //histMC->GetYaxis()->SetRangeUser(-0.9, 0.9);
+
+ c = new TCanvas;
+
+ histG->GetXaxis()->SetRangeUser(-9.9, 9.9);
+ histG->Project3D("z")->Draw();
+
+ histM->GetXaxis()->SetRangeUser(-9.9, 9.9);
+ proj = histM->Project3D("z2");
+ proj->SetLineColor(2);
+ proj->Draw("SAME");
+
+ histMC->GetXaxis()->SetRangeUser(-9.9, 9.9);
+ projMC = histMC->Project3D("z3");
+ projMC->SetLineColor(3);
+ projMC->Draw("SAME");
+}
+
+void PrintEventStats(Int_t corrID = 3)
+{
+ loadlibs();
+
+ /*
+ TFile::Open("analysis_mc.root");
+ fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaNSD", "dndetaNSD");
+ fdNdEtaAnalysis->LoadHistograms();
+ trackHist = fdNdEtaAnalysis->GetData()->GetTrackCorrection()->GetGeneratedHistogram();
+ eventHist = fdNdEtaAnalysis->GetData()->GetEventCorrection()->GetGeneratedHistogram();
+ */
+
+ TFile::Open("correction_map.root");
+ AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction");
+ if (!dNdEtaCorrection->LoadHistograms())
+ return;
+ trackHist = dNdEtaCorrection->GetCorrection(corrID)->GetTrackCorrection()->GetGeneratedHistogram();
+ eventHist = dNdEtaCorrection->GetCorrection(corrID)->GetEventCorrection()->GetGeneratedHistogram();
+
+ trackHist->GetXaxis()->SetRange(0, trackHist->GetNbinsX()+1);
+ trackHist->GetZaxis()->SetRange(0, trackHist->GetNbinsZ()+1);
+ eta = trackHist->Project3D("y");
+
+ events = eventHist->Integral(0, eventHist->GetNbinsX()+1, 0, eventHist->GetNbinsY()+1);
+
+ eta->Scale(1.0 / events);
+
+ Float_t avgN = eta->Integral(0, eta->GetNbinsX()+1);
+ Printf("<N> = %f", avgN);
+
+ eta->Scale(1.0 / eta->GetXaxis()->GetBinWidth(1));
+
+ Printf("dndeta | eta = 0 is %f", (eta->GetBinContent(eta->FindBin(0.01)) + eta->GetBinContent(eta->FindBin(-0.01))) / 2);
+ Printf("dndeta in |eta| < 1 is %f", eta->Integral(eta->FindBin(-0.99), eta->FindBin(0.99)) / (eta->FindBin(0.99) - eta->FindBin(-0.99) + 1));
+ Printf("dndeta in |eta| < 1.5 is %f", eta->Integral(eta->FindBin(-1.49), eta->FindBin(1.49)) / (eta->FindBin(1.49) - eta->FindBin(-1.49) + 1));
+
+ stats = (TH2*) gFile->Get("fEventStats");
+ proj = stats->ProjectionX();
+ gROOT->ProcessLine(".L PrintHist.C");
+ PrintHist2D(stats);
+ PrintHist(proj);
+
+ Printf("+++ TRIGGER EFFICIENCIES +++");
+
+ Printf("INEL = %.1f", 100. * (proj->GetBinContent(1) - stats->GetBinContent(1, 1)) / proj->GetBinContent(1));
+ Printf("NSD = %.1f", 100. * (proj->GetBinContent(2) - stats->GetBinContent(2, 1)) / proj->GetBinContent(2));
+ Printf("ND = %.1f", 100. * (proj->GetBinContent(3) - stats->GetBinContent(3, 1)) / proj->GetBinContent(3));
+ Printf("SD = %.1f", 100. * (proj->GetBinContent(4) - stats->GetBinContent(4, 1)) / proj->GetBinContent(4));
+ Printf("DD = %.1f", 100. * (proj->GetBinContent(5) - stats->GetBinContent(5, 1)) / proj->GetBinContent(5));
+
+ for (Int_t i=7; i<=proj->GetNbinsX(); i++)
+ if (proj->GetBinContent(i) > 0)
+ Printf("bin %d (process type %d) = %.2f", i, (Int_t) proj->GetXaxis()->GetBinCenter(i), 100.0 * (proj->GetBinContent(i) - stats->GetBinContent(i, 1)) / proj->GetBinContent(i));
+
+ //eta->Draw();
+}
+
+void TestAsymmetry()
+{
+ loadlibs();
+
+ TFile* file2 = TFile::Open("analysis_mc.root");
+
+ dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
+ fdNdEtaAnalysis->LoadHistograms();
+ fdNdEtaAnalysis->Finish(0, 0, AlidNdEtaCorrection::kNone, "...");
+
+ fdNdEtaAnalysis->GetdNdEtaHistogram(0)->DrawCopy();
+
+ hist = (TH1*) fdNdEtaAnalysis->GetData()->GetTrackCorrection()->GetMeasuredHistogram();
+ hist2 = (TH1*) hist->Clone("hist2");
+ for (Int_t x=1; x<=hist->GetNbinsX(); x++)
+ for (Int_t y=1; y<=hist->GetNbinsY(); y++)
+ for (Int_t z=1; z<=hist->GetNbinsZ(); z++)
+ {
+ Printf("%d %d %d %d", x, y, z, hist->GetNbinsY() + 1 - y);
+ hist->SetBinContent(x, y, z, hist2->GetBinContent(hist->GetNbinsX() / 2, TMath::Min(y, hist->GetNbinsY() + 1 - y), z));
+ }
+
+ hist = fdNdEtaAnalysis->GetData()->GetEventCorrection()->GetMeasuredHistogram();
+ for (Int_t x=1; x<=hist->GetNbinsX(); x++)
+ for (Int_t y=1; y<=hist->GetNbinsY(); y++)
+ {
+ //Printf("%d %d %d %d", x, y, z, hist->GetNbinsY() + 1 - y);
+ hist->SetBinContent(x, y, hist->GetBinContent(hist->GetNbinsX() / 2, y));
+ }
+
+ fdNdEtaAnalysis->Finish(0, 0, AlidNdEtaCorrection::kNone, "...");
+ fdNdEtaAnalysis->GetdNdEtaHistogram(0)->SetMarkerColor(2);
+ fdNdEtaAnalysis->GetdNdEtaHistogram(0)->SetLineColor(2);
+ fdNdEtaAnalysis->GetdNdEtaHistogram(0)->SetMarkerStyle(5);
+ fdNdEtaAnalysis->GetdNdEtaHistogram(0)->DrawCopy("SAMEP");
+}
+
+void DeltaPhiFromPt(Float_t smearing = 0.005)
+{
+ loadlibs();
+
+ TFile::Open("analysis_mc.root");
+ hist = (TH1*) gFile->Get("dndeta_check_pt");
+
+ dPhiHist = new TH1F("dPhiHist", ";#Delta phi", 400, -0.1, 0.1);
+ dPhiHist2 = new TH1F("dPhiHist2", ";#Delta phi", 400, -0.1, 0.1);
+
+ for (Int_t i=1; i<=hist->GetNbinsX(); i++)
+ {
+ Float_t pt = hist->GetBinCenter(i);
+ Float_t deltaPhi = (0.076 - 0.039) / 2 / (pt / 0.15);
+
+ if (smearing > 0)
+ {
+ gaus = new TF1("mygaus", "gaus(0)", -0.1, 0.1);
+ gaus->SetParameters(1, -deltaPhi, smearing);
+
+ dPhiHist->FillRandom("mygaus", hist->GetBinContent(i) / 2 * 1000);
+
+ dPhiHist2->FillRandom("mygaus", hist->GetBinContent(i) / 2 * 1000);
+ gaus->SetParameters(1, deltaPhi, smearing);
+ dPhiHist2->FillRandom("mygaus", hist->GetBinContent(i) / 2 * 1000);
+ }
+ else
+{
+dPhiHist->Fill(deltaPhi, hist->GetBinContent(i) / 2);
+dPhiHist2->Fill(deltaPhi, hist->GetBinContent(i) / 2);
+dPhiHist2->Fill(-deltaPhi, hist->GetBinContent(i) / 2);
+}
+ }
+
+ new TCanvas;
+ dPhiHist->Draw();
+ dPhiHist2->SetLineColor(2);
+ dPhiHist2->Draw("SAME");
+ gPad->SetLogy();
+
+ TFile::Open("trackletsDePhi.root");
+ //TFile::Open("tmp/correction_maponly-positive.root");
+ //TFile::Open("tmp/correction_map.root");
+ //tracklets = (TH1*) gFile->Get(Form("fDeltaPhi_%d", 0));
+ tracklets = (TH1*) gFile->Get("DePhiPPTracklets");
+ tracklets->Scale(1.0 / tracklets->GetMaximum() * dPhiHist->GetMaximum());
+ tracklets->SetLineColor(4);
+ tracklets->Draw("SAME");
+}