+ if(!fIsQAOn) return;
+ // cast TObject into VParticle
+ AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
+ if (!esd ) return ;
+
+ // index = 0: fill histograms before cuts
+ // index = 1: fill histograms after cuts
+ Int_t index = -1;
+ index = ((b) ? 1 : 0);
+
+
+ //number of charged tracks:
+ Int_t nTracks = esd->GetNumberOfTracks();
+ fhQA[kNTracks][index]->Fill(nTracks);
+
+ //look at vertex parameters:
+ const AliESDVertex* vtxESD = 0x0;
+ if (fVtxTPC) vtxESD = esd->GetPrimaryVertexTPC() ;
+ else if (fVtxSPD) vtxESD = esd->GetPrimaryVertexSPD() ;
+ else vtxESD = esd->GetPrimaryVertexTracks() ;
+ if(!vtxESD)return;
+ // Require the vertex to have been reconstructed successfully
+ if (strcmp(vtxESD->GetName(), "default")==0)return;
+ // vertex position and uncertainties
+ fhQA[kVtxPosX] [index]->Fill(vtxESD->GetXv());
+ fhQA[kVtxPosY] [index]->Fill(vtxESD->GetYv());
+ fhQA[kVtxPosZ] [index]->Fill(vtxESD->GetZv());
+ fhQA[kVtxResX] [index]->Fill(vtxESD->GetXRes());
+ fhQA[kVtxResY] [index]->Fill(vtxESD->GetYRes());
+ fhQA[kVtxResZ] [index]->Fill(vtxESD->GetZRes());
+ fhQA[kVtxNCtrb][index]->Fill(vtxESD->GetNContributors());
+
+}
+
+//____________________________________________________________________
+void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
+{
+ //
+ //setting x-axis bin limits of QA histogram fhQA[index]
+ //
+
+ for(Int_t i=0;i<kNStepQA;i++){
+ if(!fhQA[index][i]){AliWarning("non-existing histogram!");
+ return;
+ }
+ fhQA[index][i]->GetXaxis()->Set(nbins,bins);
+ }
+}
+//____________________________________________________________________
+void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
+{
+ //
+ //setting x-axis bins and range of QA histogram fhQA[index]
+ //
+
+ for(Int_t i=0;i<kNStepQA;i++){
+ if(!fhQA[index][i]){AliWarning("non-existing histogram!");
+ return;
+ }
+ fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
+ }
+}
+
+//_____________________________________________________________________________
+ void AliCFEventRecCuts::DefineHistograms() {
+ //
+ // histograms for cut variables
+ //
+ Int_t color = 2;
+
+ if(!fIsQAOn) {
+ AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
+ return;
+ }
+
+ // book QA histograms
+
+ Char_t str[256];
+ for (Int_t i=0; i<kNStepQA; i++) {
+ if (i==0) sprintf(str," ");
+ else sprintf(str,"_cut");
+
+ fhQA[kNTracks][i] = new TH1F(Form("%s_NTracks%s",GetName(),str), "",501,-0.5,500.5);
+ fhQA[kVtxPosX][i] = new TH1F(Form("%s_Vtx_Pos_X%s",GetName(),str), "",100,-5.,5.);
+ fhQA[kVtxPosY][i] = new TH1F(Form("%s_Vtx_Pos_Y%s",GetName(),str), "",100,-5.,5.);
+ fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
+ fhQA[kVtxResX][i] = new TH1F(Form("%s_Vtx_Res_X%s",GetName(),str), "",100,-1.,1.);
+ fhQA[kVtxResY][i] = new TH1F(Form("%s_Vtx_Res_Y%s",GetName(),str), "",100,-1.,1.);
+ fhQA[kVtxResZ][i] = new TH1F(Form("%s_Vtx_Res_Z%s",GetName(),str), "",100,-1.,1.);
+ fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
+
+ fhQA[kNTracks][i] ->SetXTitle("Number of ESD tracks");
+ fhQA[kVtxPosX][i] ->SetXTitle("Vertex Position X (cm)");
+ fhQA[kVtxPosY][i] ->SetXTitle("Vertex Position Y (cm)");
+ fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
+ fhQA[kVtxResX][i] ->SetXTitle("Vertex Resolution X (cm)");
+ fhQA[kVtxResY][i] ->SetXTitle("Vertex Resolution Y (cm)");
+ fhQA[kVtxResZ][i] ->SetXTitle("Vertex Resolution Z (cm)");
+ fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
+ }
+
+ for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
+
+}
+
+//_____________________________________________________________________________
+void AliCFEventRecCuts::AddQAHistograms(TList *qaList) {
+ //
+ // saves the histograms in a TList
+ //
+
+ DefineHistograms();
+
+ for (Int_t j=0; j<kNStepQA; j++) {
+ for(Int_t i=0; i<kNCuts; i++)
+ qaList->Add(fhQA[i][j]);
+ }