ROOT logo
AliCFContainer *MakeSlice(AliCFContainer *cont, Double_t pmin = 2., Int_t charge = 0){
  TArrayI steps(cont->GetNStep()); for(Int_t istep = 0; istep < cont->GetNStep(); istep++) steps[istep] = istep;
  Int_t vars[2] = {1,2};
  TArrayD min(cont->GetNVar()), max(cont->GetNVar());
  for(Int_t ivar = 0; ivar < cont->GetNVar(); ivar++){
    if(ivar == 0){
      min[ivar] = pmin;
      max[ivar] = 10.;
    } else if(ivar == 3){
      if(charge == -1){
        min[ivar] = max[ivar] = -1;
      } else if(charge == 1){
        min[ivar] = max[ivar] = 1;
      } else {
        min[ivar] = 1;
        max[ivar] = -1;
      }
    } else {
      min[ivar] = cont->GetAxis(ivar, 0)->GetXmin();
      max[ivar] = cont->GetAxis(ivar, 0)->GetXmax();
    }
  }
  return cont->MakeSlice(cont->GetNStep(), steps.GetArray(), 2, vars, min.GetArray(), max.GetArray());
}

void DrawEtaPhi(Double_t pmin = 2.){
  TFile *in = TFile::Open("HFEtaskTRD2.root");
  TList *res = (TList *)in->Get("TRD_HFE_Results2");
  // Container with tracks
  AliHFEcontainer *hfecont = (AliHFEcontainer *)res->FindObject("trackContainer");
  AliCFContainer *cont = hfecont->GetCFContainer("recTrackContReco");
  // Container with number of events for normalization
  AliCFContainer *evc = (AliCFContainer *)res->FindObject("eventContainer");
  TH1 *h1 = (TH1 *)evc->Project(4, 0);
  Int_t nEvents = h1->GetEntries();
  cout << "Number of events: " << nEvents << endl;
  // For plotting
  Double_t rm = 0.2;
  Double_t ts = 0.045;

  Int_t steps = cont->GetNStep() - 1;
  TH2 *htpr = 0;
  TCanvas *plotall = new TCanvas("plot", "Eta-phi maps for different cut steps (all charge)", 1000, 600);
  plotall->Divide(steps/2, 2);
  AliCFContainer *scall= MakeSlice(cont, pmin, 0);
  for(Int_t istep = 1; istep < cont->GetNStep(); istep++){
    plotall->cd(istep);
    gPad->SetRightMargin(rm);
    hptr = (TH2 *)scall->Project(istep, 0,1);
    hptr->Scale(1e5/static_cast<Double_t>(nEvents));
    hptr->SetStats(0);
    hptr->SetName(Form("%sall", cont->GetStepTitle(istep)));
    hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep)));
    hptr->GetXaxis()->SetTitle("#eta");
    hptr->GetYaxis()->SetTitle("#phi");
    hptr->GetZaxis()->SetTitle("Tracks / 100000 Events");
    hptr->GetZaxis()->SetTitleOffset(1.2);
    hptr->GetXaxis()->SetTitleSize(ts);
    hptr->GetYaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetRangeUser(0, 2.2);
    hptr->Draw("colz");
  }
  plotall->cd();

  TCanvas *plotpos = new TCanvas("plotpos", "Eta-phi maps for different cut steps (pos charge)", 1000, 600);
  plotpos->Divide(steps/2, 2);
  AliCFContainer *scpos = MakeSlice(cont, pmin, 1);
  for(Int_t istep = 1; istep < cont->GetNStep(); istep++){
    plotpos->cd(istep);
    gPad->SetRightMargin(rm);
    hptr = (TH2 *)scpos->Project(istep, 0,1);
    hptr->Scale(1e5/static_cast<Double_t>(nEvents));
    hptr->SetStats(0);
    hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep)));
    hptr->SetName(Form("%spos", cont->GetStepTitle(istep)));
    hptr->GetXaxis()->SetTitle("#eta");
    hptr->GetYaxis()->SetTitle("#phi");
    hptr->GetZaxis()->SetTitle("Tracks / 100000 Events");
    hptr->GetZaxis()->SetTitleOffset(1.2);
    hptr->GetXaxis()->SetTitleSize(ts);
    hptr->GetYaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetRangeUser(0, 1.1);
    hptr->Draw("colz");
  }
  plotpos->cd();

  TCanvas *plotneg = new TCanvas("plotneg", "Eta-phi maps for different cut steps (neg charge)", 1000, 600);
  plotneg->Divide(steps/2, 2);
  AliCFContainer *scneg = MakeSlice(cont, pmin, -1);
  for(Int_t istep = 1; istep < cont->GetNStep(); istep++){
    plotneg->cd(istep);
    gPad->SetRightMargin(rm);
    hptr = (TH2 *)scneg->Project(istep, 0,1);
    hptr->Scale(1e5/static_cast<Double_t>(nEvents));
    hptr->SetStats(0);
    hptr->SetName(Form("%sneg", cont->GetStepTitle(istep)));
    hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep)));
    hptr->GetXaxis()->SetTitle("#eta");
    hptr->GetYaxis()->SetTitle("#phi");
    hptr->GetZaxis()->SetTitle("Tracks / 100000 Events");
    hptr->GetZaxis()->SetTitleOffset(1.2);
    hptr->GetXaxis()->SetTitleSize(ts);
    hptr->GetYaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetTitleSize(ts);
    hptr->GetZaxis()->SetRangeUser(0, 1.1);
    hptr->Draw("colz");
  }
  plotneg->cd();

}
 DrawEtaPhi.C:1
 DrawEtaPhi.C:2
 DrawEtaPhi.C:3
 DrawEtaPhi.C:4
 DrawEtaPhi.C:5
 DrawEtaPhi.C:6
 DrawEtaPhi.C:7
 DrawEtaPhi.C:8
 DrawEtaPhi.C:9
 DrawEtaPhi.C:10
 DrawEtaPhi.C:11
 DrawEtaPhi.C:12
 DrawEtaPhi.C:13
 DrawEtaPhi.C:14
 DrawEtaPhi.C:15
 DrawEtaPhi.C:16
 DrawEtaPhi.C:17
 DrawEtaPhi.C:18
 DrawEtaPhi.C:19
 DrawEtaPhi.C:20
 DrawEtaPhi.C:21
 DrawEtaPhi.C:22
 DrawEtaPhi.C:23
 DrawEtaPhi.C:24
 DrawEtaPhi.C:25
 DrawEtaPhi.C:26
 DrawEtaPhi.C:27
 DrawEtaPhi.C:28
 DrawEtaPhi.C:29
 DrawEtaPhi.C:30
 DrawEtaPhi.C:31
 DrawEtaPhi.C:32
 DrawEtaPhi.C:33
 DrawEtaPhi.C:34
 DrawEtaPhi.C:35
 DrawEtaPhi.C:36
 DrawEtaPhi.C:37
 DrawEtaPhi.C:38
 DrawEtaPhi.C:39
 DrawEtaPhi.C:40
 DrawEtaPhi.C:41
 DrawEtaPhi.C:42
 DrawEtaPhi.C:43
 DrawEtaPhi.C:44
 DrawEtaPhi.C:45
 DrawEtaPhi.C:46
 DrawEtaPhi.C:47
 DrawEtaPhi.C:48
 DrawEtaPhi.C:49
 DrawEtaPhi.C:50
 DrawEtaPhi.C:51
 DrawEtaPhi.C:52
 DrawEtaPhi.C:53
 DrawEtaPhi.C:54
 DrawEtaPhi.C:55
 DrawEtaPhi.C:56
 DrawEtaPhi.C:57
 DrawEtaPhi.C:58
 DrawEtaPhi.C:59
 DrawEtaPhi.C:60
 DrawEtaPhi.C:61
 DrawEtaPhi.C:62
 DrawEtaPhi.C:63
 DrawEtaPhi.C:64
 DrawEtaPhi.C:65
 DrawEtaPhi.C:66
 DrawEtaPhi.C:67
 DrawEtaPhi.C:68
 DrawEtaPhi.C:69
 DrawEtaPhi.C:70
 DrawEtaPhi.C:71
 DrawEtaPhi.C:72
 DrawEtaPhi.C:73
 DrawEtaPhi.C:74
 DrawEtaPhi.C:75
 DrawEtaPhi.C:76
 DrawEtaPhi.C:77
 DrawEtaPhi.C:78
 DrawEtaPhi.C:79
 DrawEtaPhi.C:80
 DrawEtaPhi.C:81
 DrawEtaPhi.C:82
 DrawEtaPhi.C:83
 DrawEtaPhi.C:84
 DrawEtaPhi.C:85
 DrawEtaPhi.C:86
 DrawEtaPhi.C:87
 DrawEtaPhi.C:88
 DrawEtaPhi.C:89
 DrawEtaPhi.C:90
 DrawEtaPhi.C:91
 DrawEtaPhi.C:92
 DrawEtaPhi.C:93
 DrawEtaPhi.C:94
 DrawEtaPhi.C:95
 DrawEtaPhi.C:96
 DrawEtaPhi.C:97
 DrawEtaPhi.C:98
 DrawEtaPhi.C:99
 DrawEtaPhi.C:100
 DrawEtaPhi.C:101
 DrawEtaPhi.C:102
 DrawEtaPhi.C:103
 DrawEtaPhi.C:104
 DrawEtaPhi.C:105
 DrawEtaPhi.C:106
 DrawEtaPhi.C:107
 DrawEtaPhi.C:108
 DrawEtaPhi.C:109
 DrawEtaPhi.C:110
 DrawEtaPhi.C:111
 DrawEtaPhi.C:112
 DrawEtaPhi.C:113