ROOT logo
TList *GetResults(const Char_t *testfile,const Char_t *plus="");
TObject* GetSpectrum(AliCFContainer *c, Int_t step);
TObject* GetEfficiency(AliCFContainer *c, Int_t step = 9);
TObject* GetEfficiency(AliCFContainer *c, Int_t step, Int_t step0);


void DrawReductionFactorpp(const char *testfile,const char *name) {
  
  gStyle->SetPalette(1);
  gStyle->SetOptStat(1111);
  gStyle->SetPadBorderMode(0);
  gStyle->SetCanvasColor(10);
  gStyle->SetPadLeftMargin(0.13);
  gStyle->SetPadRightMargin(0.13);
  
  ///////////////////////////////////
  // Take the stuff
  //////////////////////////////////

  TList *results = GetResults(testfile,name);
  if(!results){
    printf("No output objects: Calculation will terminate here\n");
    return;
  }

  AliHFEcontainer *containerhfe = (AliHFEcontainer *) results->FindObject("trackContainer");
  if(!containerhfe) {
    printf("No hfe container \n");
    return;
  }

  AliCFContainer *sumcontainer = containerhfe->GetCFContainer("recTrackContReco");
  if(!sumcontainer) {
    printf("No container sum esd\n");
    return;
  }
  
  Int_t numberOfEvents = (Int_t) containerhfe->GetNumberOfEvents();
  
  printf("Number of events for  %d after Event cut\n",numberOfEvents);
  
  /////////////////////////////////////
  // Take efficiencies
  /////////////////////////////////////
  
  // ESD values

  AliCFEffGrid  *efficiencystepkineITSTPC  = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepRecKineITSTPC,AliHFEcuts::kStepRecNoCut);
  AliCFEffGrid  *efficiencystepPrim        = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepRecPrim,AliHFEcuts::kStepRecKineITSTPC);
  AliCFEffGrid  *efficiencystepHFEcutsITS  = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsITS,AliHFEcuts::kStepRecPrim);
  AliCFEffGrid  *efficiencystepHFEcutsTRD  = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsTRD,AliHFEcuts::kStepHFEcutsITS);
  

  AliCFEffGrid  *efficiencystepPIDTOF      = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsTRD + 1,AliHFEcuts::kStepHFEcutsTRD);
  AliCFEffGrid  *efficiencystepPIDTPC      = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kStepHFEcutsTRD + 1);

  AliCFEffGrid  *efficiencystepPIDall      = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kStepHFEcutsTRD);

  AliCFEffGrid  *efficiencystepall      = (AliCFEffGrid*)  GetEfficiency(sumcontainer,AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kStepRecNoCut);
  

  ///////////////////////////////////////
  // Plot 1D
  ///////////////////////////////////////

  TCanvas * canvascomparisonbis = new TCanvas("ITSTPCrefitStep","ITSTPCrefitStep",1000,700);
  canvascomparisonbis->Divide(2,2);
 
  canvascomparisonbis->cd(1);
  TH1D* h_effstepkineITSTPC1Donly = (TH1D *) efficiencystepkineITSTPC->Project(0);
  h_effstepkineITSTPC1Donly->SetTitle("(ITS & TPC refit) / (No cut)");
  h_effstepkineITSTPC1Donly->SetStats(0);
  h_effstepkineITSTPC1Donly->SetLineColor(kBlue);
  h_effstepkineITSTPC1Donly->SetMarkerColor(kBlue);
  h_effstepkineITSTPC1Donly->SetMarkerStyle(25);
  h_effstepkineITSTPC1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepkineITSTPC1Donly->SetXTitle("p_{T} [GeV/c]");
  h_effstepkineITSTPC1Donly->SetYTitle("Efficiency");
  h_effstepkineITSTPC1Donly->Draw();

  canvascomparisonbis->cd(2);
  TH1D* h_effstepPrim1Donly = (TH1D *) efficiencystepPrim->Project(0);
  h_effstepPrim1Donly->SetTitle("No Kink");
  h_effstepPrim1Donly->SetStats(0);
  h_effstepPrim1Donly->SetLineColor(kBlue);
  h_effstepPrim1Donly->SetMarkerColor(kBlue);
  h_effstepPrim1Donly->SetMarkerStyle(25);
  h_effstepPrim1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepPrim1Donly->SetXTitle("p_{T} [GeV/c]");
  h_effstepPrim1Donly->SetYTitle("Efficiency");
  h_effstepPrim1Donly->Draw();

  canvascomparisonbis->cd(3);
  TH1D* h_effstepHFEcutsITS1Donlya = (TH1D *) efficiencystepHFEcutsITS->Project(0);
  h_effstepHFEcutsITS1Donlya->SetTitle("First pixel");
  h_effstepHFEcutsITS1Donlya->SetStats(0);
  h_effstepHFEcutsITS1Donlya->SetLineColor(kBlue);
  h_effstepHFEcutsITS1Donlya->SetMarkerColor(kBlue);
  h_effstepHFEcutsITS1Donlya->SetMarkerStyle(25);
  h_effstepHFEcutsITS1Donlya->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepHFEcutsITS1Donlya->GetYaxis()->SetRangeUser(0.0,1.0);
  h_effstepHFEcutsITS1Donlya->SetXTitle("p_{T} [GeV/c]");
  h_effstepHFEcutsITS1Donlya->SetYTitle("Efficiency");
  h_effstepHFEcutsITS1Donlya->Draw();
 
  canvascomparisonbis->cd(4);
  TH1D* h_effstepHFEcutsTRDonly = (TH1D *) efficiencystepHFEcutsTRD->Project(0);
  h_effstepHFEcutsTRDonly->SetTitle("TOF matching");
  h_effstepHFEcutsTRDonly->SetStats(0);
  h_effstepHFEcutsTRDonly->SetLineColor(kBlue);
  h_effstepHFEcutsTRDonly->SetMarkerColor(kBlue);
  h_effstepHFEcutsTRDonly->SetMarkerStyle(25);
  h_effstepHFEcutsTRDonly->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepHFEcutsTRDonly->SetXTitle("p_{T} [GeV/c]");
  h_effstepHFEcutsTRDonly->SetYTitle("Efficiency");
  h_effstepHFEcutsTRDonly->Draw();
  
  /////////
  // PID
  /////////

  TCanvas * canvasc1Don = new TCanvas("PIDstep","PIDstep",1000,700);
  canvasc1Don->Divide(2,1);
  
  canvasc1Don->cd(1);
  TH1D* h_effstepPID1Donly = (TH1D *) efficiencystepPIDTOF->Project(0);
  h_effstepPID1Donly->SetTitle("TOF 3 sigma cut");
  h_effstepPID1Donly->SetStats(0);
  h_effstepPID1Donly->SetLineColor(kBlue);
  h_effstepPID1Donly->SetMarkerColor(kBlue);
  h_effstepPID1Donly->SetMarkerStyle(25);
  h_effstepPID1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepPID1Donly->SetXTitle("p_{T} [GeV/c]");
  h_effstepPID1Donly->SetYTitle("Efficiency");
  h_effstepPID1Donly->Draw();
 
  canvasc1Don->cd(2);
  gPad->SetLogy();
  TH1D* h_effstepPID1Donlyy = (TH1D *) efficiencystepPIDTPC->Project(0);
  h_effstepPID1Donlyy->SetTitle("TPC PID cut");
  h_effstepPID1Donlyy->SetStats(0);
  h_effstepPID1Donlyy->SetLineColor(kBlue);
  h_effstepPID1Donlyy->SetMarkerColor(kBlue);
  h_effstepPID1Donlyy->SetMarkerStyle(25);
  h_effstepPID1Donlyy->GetXaxis()->SetRangeUser(0.3,6.0);
  h_effstepPID1Donlyy->SetXTitle("p_{T} [GeV/c]");
  h_effstepPID1Donlyy->SetYTitle("Efficiency");
  h_effstepPID1Donlyy->Draw();
  

  
  
}

// ====================================================================
TList *GetResults(const Char_t *testfile,const Char_t *plus){
  //
  // read output
  //
  TFile *f = TFile::Open(testfile);
  if(!f || f->IsZombie()){
    printf("File not readable\n");
    return 0x0;
  }
  TString name("HFE_Results");
  name += plus; 
  printf("Name of TList %s\n",(const char*)name); 
  TList *l = dynamic_cast<TList *>(f->Get((const char*)name));
  if(!l){
    printf("Output container not found\n");
    f->Close(); delete f;
    return 0x0;
  } 
  TList *returnlist = dynamic_cast<TList *>(l->Clone());
  f->Close(); delete f;
  return returnlist;
}
//_________________________________________________________________________
TObject* GetSpectrum(AliCFContainer *c, Int_t step) {
  AliCFDataGrid* data = new AliCFDataGrid("data","",*c,step);
  //data->SetMeasured(step);
  return data;
}
//__________________________________________________________________________
TObject* GetEfficiency(AliCFContainer *c, Int_t step) {
  TString name("eff");
  name += step;
  AliCFEffGrid* eff = new AliCFEffGrid((const char*)name,"",*c);
  eff->CalculateEfficiency(step,0);
  return eff;
}
//_________________________________________________________________________
TObject* GetEfficiency(AliCFContainer *c, Int_t step, Int_t step0) {
  TString name("eff");
  name += step;
  name+= step0;
  AliCFEffGrid* eff = new AliCFEffGrid((const char*)name,"",*c);
  eff->CalculateEfficiency(step,step0);
  return eff;
}
 DrawReductionFactorpp.C:1
 DrawReductionFactorpp.C:2
 DrawReductionFactorpp.C:3
 DrawReductionFactorpp.C:4
 DrawReductionFactorpp.C:5
 DrawReductionFactorpp.C:6
 DrawReductionFactorpp.C:7
 DrawReductionFactorpp.C:8
 DrawReductionFactorpp.C:9
 DrawReductionFactorpp.C:10
 DrawReductionFactorpp.C:11
 DrawReductionFactorpp.C:12
 DrawReductionFactorpp.C:13
 DrawReductionFactorpp.C:14
 DrawReductionFactorpp.C:15
 DrawReductionFactorpp.C:16
 DrawReductionFactorpp.C:17
 DrawReductionFactorpp.C:18
 DrawReductionFactorpp.C:19
 DrawReductionFactorpp.C:20
 DrawReductionFactorpp.C:21
 DrawReductionFactorpp.C:22
 DrawReductionFactorpp.C:23
 DrawReductionFactorpp.C:24
 DrawReductionFactorpp.C:25
 DrawReductionFactorpp.C:26
 DrawReductionFactorpp.C:27
 DrawReductionFactorpp.C:28
 DrawReductionFactorpp.C:29
 DrawReductionFactorpp.C:30
 DrawReductionFactorpp.C:31
 DrawReductionFactorpp.C:32
 DrawReductionFactorpp.C:33
 DrawReductionFactorpp.C:34
 DrawReductionFactorpp.C:35
 DrawReductionFactorpp.C:36
 DrawReductionFactorpp.C:37
 DrawReductionFactorpp.C:38
 DrawReductionFactorpp.C:39
 DrawReductionFactorpp.C:40
 DrawReductionFactorpp.C:41
 DrawReductionFactorpp.C:42
 DrawReductionFactorpp.C:43
 DrawReductionFactorpp.C:44
 DrawReductionFactorpp.C:45
 DrawReductionFactorpp.C:46
 DrawReductionFactorpp.C:47
 DrawReductionFactorpp.C:48
 DrawReductionFactorpp.C:49
 DrawReductionFactorpp.C:50
 DrawReductionFactorpp.C:51
 DrawReductionFactorpp.C:52
 DrawReductionFactorpp.C:53
 DrawReductionFactorpp.C:54
 DrawReductionFactorpp.C:55
 DrawReductionFactorpp.C:56
 DrawReductionFactorpp.C:57
 DrawReductionFactorpp.C:58
 DrawReductionFactorpp.C:59
 DrawReductionFactorpp.C:60
 DrawReductionFactorpp.C:61
 DrawReductionFactorpp.C:62
 DrawReductionFactorpp.C:63
 DrawReductionFactorpp.C:64
 DrawReductionFactorpp.C:65
 DrawReductionFactorpp.C:66
 DrawReductionFactorpp.C:67
 DrawReductionFactorpp.C:68
 DrawReductionFactorpp.C:69
 DrawReductionFactorpp.C:70
 DrawReductionFactorpp.C:71
 DrawReductionFactorpp.C:72
 DrawReductionFactorpp.C:73
 DrawReductionFactorpp.C:74
 DrawReductionFactorpp.C:75
 DrawReductionFactorpp.C:76
 DrawReductionFactorpp.C:77
 DrawReductionFactorpp.C:78
 DrawReductionFactorpp.C:79
 DrawReductionFactorpp.C:80
 DrawReductionFactorpp.C:81
 DrawReductionFactorpp.C:82
 DrawReductionFactorpp.C:83
 DrawReductionFactorpp.C:84
 DrawReductionFactorpp.C:85
 DrawReductionFactorpp.C:86
 DrawReductionFactorpp.C:87
 DrawReductionFactorpp.C:88
 DrawReductionFactorpp.C:89
 DrawReductionFactorpp.C:90
 DrawReductionFactorpp.C:91
 DrawReductionFactorpp.C:92
 DrawReductionFactorpp.C:93
 DrawReductionFactorpp.C:94
 DrawReductionFactorpp.C:95
 DrawReductionFactorpp.C:96
 DrawReductionFactorpp.C:97
 DrawReductionFactorpp.C:98
 DrawReductionFactorpp.C:99
 DrawReductionFactorpp.C:100
 DrawReductionFactorpp.C:101
 DrawReductionFactorpp.C:102
 DrawReductionFactorpp.C:103
 DrawReductionFactorpp.C:104
 DrawReductionFactorpp.C:105
 DrawReductionFactorpp.C:106
 DrawReductionFactorpp.C:107
 DrawReductionFactorpp.C:108
 DrawReductionFactorpp.C:109
 DrawReductionFactorpp.C:110
 DrawReductionFactorpp.C:111
 DrawReductionFactorpp.C:112
 DrawReductionFactorpp.C:113
 DrawReductionFactorpp.C:114
 DrawReductionFactorpp.C:115
 DrawReductionFactorpp.C:116
 DrawReductionFactorpp.C:117
 DrawReductionFactorpp.C:118
 DrawReductionFactorpp.C:119
 DrawReductionFactorpp.C:120
 DrawReductionFactorpp.C:121
 DrawReductionFactorpp.C:122
 DrawReductionFactorpp.C:123
 DrawReductionFactorpp.C:124
 DrawReductionFactorpp.C:125
 DrawReductionFactorpp.C:126
 DrawReductionFactorpp.C:127
 DrawReductionFactorpp.C:128
 DrawReductionFactorpp.C:129
 DrawReductionFactorpp.C:130
 DrawReductionFactorpp.C:131
 DrawReductionFactorpp.C:132
 DrawReductionFactorpp.C:133
 DrawReductionFactorpp.C:134
 DrawReductionFactorpp.C:135
 DrawReductionFactorpp.C:136
 DrawReductionFactorpp.C:137
 DrawReductionFactorpp.C:138
 DrawReductionFactorpp.C:139
 DrawReductionFactorpp.C:140
 DrawReductionFactorpp.C:141
 DrawReductionFactorpp.C:142
 DrawReductionFactorpp.C:143
 DrawReductionFactorpp.C:144
 DrawReductionFactorpp.C:145
 DrawReductionFactorpp.C:146
 DrawReductionFactorpp.C:147
 DrawReductionFactorpp.C:148
 DrawReductionFactorpp.C:149
 DrawReductionFactorpp.C:150
 DrawReductionFactorpp.C:151
 DrawReductionFactorpp.C:152
 DrawReductionFactorpp.C:153
 DrawReductionFactorpp.C:154
 DrawReductionFactorpp.C:155
 DrawReductionFactorpp.C:156
 DrawReductionFactorpp.C:157
 DrawReductionFactorpp.C:158
 DrawReductionFactorpp.C:159
 DrawReductionFactorpp.C:160
 DrawReductionFactorpp.C:161
 DrawReductionFactorpp.C:162
 DrawReductionFactorpp.C:163
 DrawReductionFactorpp.C:164
 DrawReductionFactorpp.C:165
 DrawReductionFactorpp.C:166
 DrawReductionFactorpp.C:167
 DrawReductionFactorpp.C:168
 DrawReductionFactorpp.C:169
 DrawReductionFactorpp.C:170
 DrawReductionFactorpp.C:171
 DrawReductionFactorpp.C:172
 DrawReductionFactorpp.C:173
 DrawReductionFactorpp.C:174
 DrawReductionFactorpp.C:175
 DrawReductionFactorpp.C:176
 DrawReductionFactorpp.C:177
 DrawReductionFactorpp.C:178
 DrawReductionFactorpp.C:179
 DrawReductionFactorpp.C:180
 DrawReductionFactorpp.C:181
 DrawReductionFactorpp.C:182
 DrawReductionFactorpp.C:183
 DrawReductionFactorpp.C:184
 DrawReductionFactorpp.C:185
 DrawReductionFactorpp.C:186
 DrawReductionFactorpp.C:187
 DrawReductionFactorpp.C:188
 DrawReductionFactorpp.C:189
 DrawReductionFactorpp.C:190
 DrawReductionFactorpp.C:191
 DrawReductionFactorpp.C:192
 DrawReductionFactorpp.C:193
 DrawReductionFactorpp.C:194
 DrawReductionFactorpp.C:195
 DrawReductionFactorpp.C:196
 DrawReductionFactorpp.C:197
 DrawReductionFactorpp.C:198
 DrawReductionFactorpp.C:199
 DrawReductionFactorpp.C:200
 DrawReductionFactorpp.C:201