+
+//___________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::dNdz2dNdxi()
+{
+ // transform dN/dz distribution into dN/dxi
+ // for current corr level, all jet pt slices
+
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histZ = fCorrFF[fNCorrectionLevels-1]->GetZ(i);
+ Int_t nBins = histZ->GetNbinsX();
+
+ Double_t* binLims = new Double_t[nBins+1];
+
+ for(Int_t bin = 0; bin<nBins; bin++){
+
+ Int_t binZ = nBins-bin;
+
+ Double_t zLo = histZ->GetXaxis()->GetBinLowEdge(binZ);
+ Double_t zUp = histZ->GetXaxis()->GetBinUpEdge(binZ);
+
+ Double_t xiLo = TMath::Log(1/zUp);
+ Double_t xiUp = TMath::Log(1/zLo);
+
+ if(bin == 0) binLims[0] = xiLo;
+ binLims[bin+1] = xiUp;
+ }
+
+ // for(Int_t bin = 0; bin<=nBins; bin++) std::cout<<" bin "<<bin<<" binLims "<<binLims[bin]<<std::endl;
+
+ TString strTitle = histZ->GetTitle();
+ TString strName = histZ->GetName();
+
+ strName.ReplaceAll("Z","XiNew");
+ strTitle.ReplaceAll("Z","XiNew");
+
+
+ TH1F* histXiNew = new TH1F("histXiNew","",nBins,binLims);
+ histXiNew->SetNameTitle(strName,strTitle);
+
+
+ for(Int_t binZ = 1; binZ<=nBins; binZ++){
+
+ Double_t meanZ = histZ->GetBinCenter(binZ);
+ Double_t cont = histZ->GetBinContent(binZ);
+ Double_t err = histZ->GetBinError(binZ);
+
+ Double_t meanXi = TMath::Log(1/meanZ);
+ Int_t binXi = histXiNew->FindBin(meanXi);
+
+ histXiNew->SetBinContent(binXi,cont);
+ histXiNew->SetBinError(binXi,err);
+
+ //std::cout<<" binZ "<<binZ<<" meanZ "<<meanZ<<" binXi "<<binXi<<" meanXi "<<meanXi<<" cont "<<cont<<" err "<<err<<std::endl;
+ }
+
+ fCorrFF[fNCorrectionLevels-1]->ReplaceCorrHistos(i,0,0,histXiNew);
+
+ delete histXiNew;
+ delete[] binLims;
+ }
+}
+
+//________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::WriteBinShiftCorr(TString strInfile, TString strIDGen, TString strIDRec,
+ TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim,
+ TString strOutDir,Double_t scaleFacBgrRec)
+{
+ TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen;
+ TString strlistGen = "fracfunc_" + strIDGen;
+
+ TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec;
+ TString strlistRec = "fracfunc_" + strIDRec;
+
+ WriteBinShiftCorr(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim, strOutDir, kFALSE, "",scaleFacBgrRec);
+}
+
+//________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::WriteBgrBinShiftCorr(TString strInfile, TString strBgrID, TString strIDGen, TString strIDRec,
+ TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim,
+ TString strOutDir,Double_t scaleFacBgrRec)
+{
+ TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen;
+ TString strlistGen = "fracfunc_" + strIDGen;
+
+ TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec;
+ TString strlistRec = "fracfunc_" + strIDRec;
+
+ WriteBinShiftCorr(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim, strOutDir, kTRUE, strBgrID,scaleFacBgrRec);
+}
+
+//___________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::WriteBinShiftCorr(TString strInfile, TString strdirGen, TString strlistGen,
+ TString strdirRec, TString strlistRec,
+ TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim,
+ TString strOutDir, Bool_t writeBgr, TString strBgrID, Double_t scaleFacBgrRec)
+{
+
+ if((writeBgr && strBgrID.Length() == 0) || (!writeBgr && strBgrID.Length()>0) ){
+ Printf("%s:%d -- inconsistent arguments to WriteBinShiftCorr FF/UE", (char*)__FILE__,__LINE__);
+ return;
+ }
+
+ TH1F* hCorrPt[fNJetPtSlices];
+ TH1F* hCorrXi[fNJetPtSlices];
+ TH1F* hCorrZ[fNJetPtSlices];
+
+ TH1F* hdNdptTracksMCGen[fNJetPtSlices];
+ TH1F* hdNdxiMCGen[fNJetPtSlices];
+ TH1F* hdNdzMCGen[fNJetPtSlices];
+
+ TH1F* hdNdptTracksMCRec[fNJetPtSlices];
+ TH1F* hdNdxiMCRec[fNJetPtSlices];
+ TH1F* hdNdzMCRec[fNJetPtSlices];
+
+ TH1F* fh1FFJetPtMCGen = 0;
+ TH1F* fh1FFJetPtMCRec = 0;
+
+ TH2F* fh2FFTrackPtMCGen = 0;
+ TH2F* fh2FFZMCGen = 0;
+ TH2F* fh2FFXiMCGen = 0;
+
+ TH2F* fh2FFTrackPtMCRec = 0;
+ TH2F* fh2FFZMCRec = 0;
+ TH2F* fh2FFXiMCRec = 0;
+
+ // gen level FF
+
+ TFile f(strInfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- writeBinShiftCorr: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data());
+
+ if(strdirGen && strdirGen.Length()) gDirectory->cd(strdirGen);
+
+ TList* listGen = 0;
+
+ if(strlistGen && strlistGen.Length()){
+
+ if(!(listGen = (TList*) gDirectory->Get(strlistGen))){
+ Printf("%s:%d -- error retrieving listGen %s from directory %s", (char*)__FILE__,__LINE__,strlistGen.Data(),strdirGen.Data());
+ return;
+ }
+ }
+
+ if(listGen){
+
+ fh1FFJetPtMCGen = (TH1F*) listGen->FindObject("fh1FFJetPtGen");
+
+ if(writeBgr){
+ fh2FFTrackPtMCGen = (TH2F*) listGen->FindObject(Form("fh2FFTrackPt%sGen",strBgrID.Data()));
+ fh2FFZMCGen = (TH2F*) listGen->FindObject(Form("fh2FFZ%sGen",strBgrID.Data()));
+ fh2FFXiMCGen = (TH2F*) listGen->FindObject(Form("fh2FFXi%sGen",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCGen = (TH2F*) listGen->FindObject("fh2FFTrackPtGen");
+ fh2FFZMCGen = (TH2F*) listGen->FindObject("fh2FFZGen");
+ fh2FFXiMCGen = (TH2F*) listGen->FindObject("fh2FFXiGen");
+ }
+ }
+ else{
+ fh1FFJetPtMCGen = (TH1F*) gDirectory->Get("fh1FFJetPtGen");
+ if(writeBgr){
+ fh2FFTrackPtMCGen = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sGen",strBgrID.Data()));
+ fh2FFZMCGen = (TH2F*) gDirectory->Get(Form("fh2FFZ%sGen",strBgrID.Data()));
+ fh2FFXiMCGen = (TH2F*) gDirectory->Get(Form("fh2FFXi%sGen",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCGen = (TH2F*) gDirectory->Get("fh2FFTrackPtGen");
+ fh2FFZMCGen = (TH2F*) gDirectory->Get("fh2FFZGen");
+ fh2FFXiMCGen = (TH2F*) gDirectory->Get("fh2FFXiGen");
+ }
+ }
+
+ fh1FFJetPtMCGen->SetDirectory(0);
+ fh2FFTrackPtMCGen->SetDirectory(0);
+ fh2FFZMCGen->SetDirectory(0);
+ fh2FFXiMCGen->SetDirectory(0);
+
+ f.Close();
+
+ // rec level FF
+
+ TFile g(strInfile,"READ");
+
+ if(!g.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- writeBinShiftCorr: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data());
+
+ if(strdirRec && strdirRec.Length()) gDirectory->cd(strdirRec);
+
+ TList* listRec = 0;
+
+ if(strlistRec && strlistRec.Length()){
+
+ if(!(listRec = (TList*) gDirectory->Get(strlistRec))){
+ Printf("%s:%d -- error retrieving listRec %s from directory %s", (char*)__FILE__,__LINE__,strlistRec.Data(),strdirRec.Data());
+ return;
+ }
+ }
+
+ if(useRecPrim){
+ if(listRec){
+ fh1FFJetPtMCRec = (TH1F*) listRec->FindObject("fh1FFJetPtRecEffRec");
+
+ if(writeBgr){
+ fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data()));
+ fh2FFZMCRec = (TH2F*) listRec->FindObject(Form("fh2FFZ%sRecEffRec",strBgrID.Data()));
+ fh2FFXiMCRec = (TH2F*) listRec->FindObject(Form("fh2FFXi%sRecEffRec",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject("fh2FFTrackPtRecEffRec");
+ fh2FFZMCRec = (TH2F*) listRec->FindObject("fh2FFZRecEffRec");
+ fh2FFXiMCRec = (TH2F*) listRec->FindObject("fh2FFXiRecEffRec");
+ }
+ }
+ else{
+ fh1FFJetPtMCRec = (TH1F*) gDirectory->Get("fh1FFJetPtRecEffRec");
+ if(writeBgr){
+ fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sRecEffRec",strBgrID.Data()));
+ fh2FFZMCRec = (TH2F*) gDirectory->Get(Form("fh2FFZ%sRecEffRec",strBgrID.Data()));
+ fh2FFXiMCRec = (TH2F*) gDirectory->Get(Form("fh2FFXi%sRecEffRec",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecEffRec");
+ fh2FFZMCRec = (TH2F*) gDirectory->Get("fh2FFZRecEffRec");
+ fh2FFXiMCRec = (TH2F*) gDirectory->Get("fh2FFXiRecEffRec");
+ }
+ }
+ }
+ else{
+ if(listRec){
+ fh1FFJetPtMCRec = (TH1F*) listRec->FindObject("fh1FFJetPtRecCuts");
+ if(writeBgr){
+ fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject(Form("fh2FFTrackPt%sRecCuts",strBgrID.Data()));
+ fh2FFZMCRec = (TH2F*) listRec->FindObject(Form("fh2FFZ%sRecCuts",strBgrID.Data()));
+ fh2FFXiMCRec = (TH2F*) listRec->FindObject(Form("fh2FFXi%sRecCuts",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCRec = (TH2F*) listRec->FindObject("fh2FFTrackPtRecCuts");
+ fh2FFZMCRec = (TH2F*) listRec->FindObject("fh2FFZRecCuts");
+ fh2FFXiMCRec = (TH2F*) listRec->FindObject("fh2FFXiRecCuts");
+ }
+ }
+ else{
+ fh1FFJetPtMCRec = (TH1F*) gDirectory->Get("fh1FFJetPtRecCuts");
+ if(writeBgr){
+ fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get(Form("fh2FFTrackPt%sRecCuts",strBgrID.Data()));
+ fh2FFZMCRec = (TH2F*) gDirectory->Get(Form("fh2FFZ%sRecCuts",strBgrID.Data()));
+ fh2FFXiMCRec = (TH2F*) gDirectory->Get(Form("fh2FFXi%sRecCuts",strBgrID.Data()));
+ }
+ else{
+ fh2FFTrackPtMCRec = (TH2F*) gDirectory->Get("fh2FFTrackPtRecCuts");
+ fh2FFZMCRec = (TH2F*) gDirectory->Get("fh2FFZRecCuts");
+ fh2FFXiMCRec = (TH2F*) gDirectory->Get("fh2FFXiRecCuts");
+ }
+ }
+ }
+
+
+ fh1FFJetPtMCRec->SetDirectory(0);
+ fh2FFTrackPtMCRec->SetDirectory(0);
+ fh2FFZMCRec->SetDirectory(0);
+ fh2FFXiMCRec->SetDirectory(0);
+
+ g.Close();
+
+ // projections: FF for generated and reconstructed
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ Float_t jetPtLoLim = fJetPtSlices->At(i);
+ Float_t jetPtUpLim = fJetPtSlices->At(i+1);
+
+ Int_t binLo = static_cast<Int_t>(fh2FFTrackPtMCGen->GetXaxis()->FindBin(jetPtLoLim));
+ Int_t binUp = static_cast<Int_t>(fh2FFTrackPtMCGen->GetXaxis()->FindBin(jetPtUpLim))-1;
+
+ if(binUp > fh2FFTrackPtMCGen->GetNbinsX()){
+ Printf("%s:%d -- jet pt range %0.3f exceeds histo limits",(char*)__FILE__,__LINE__,jetPtUpLim);
+ return;
+ }
+
+ TString strNameFFPtGen(Form("fh1FFTrackPtGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+ TString strNameFFZGen(Form("fh1FFZGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+ TString strNameFFXiGen(Form("fh1FFXiGenBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+
+ TString strNameFFPtRec(Form("fh1FFTrackPtRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+ TString strNameFFZRec(Form("fh1FFZRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+ TString strNameFFXiRec(Form("fh1FFXiRecBinShift_%02d_%02d",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim)));
+
+ if(writeBgr){
+ strNameFFPtGen.Form("fh1TrackPtGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+ strNameFFZGen.Form("fh1ZGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+ strNameFFXiGen.Form("fh1XiGenBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+
+ strNameFFPtRec.Form("fh1TrackPtRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+ strNameFFZRec.Form("fh1ZRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+ strNameFFXiRec.Form("fh1XiRecBinShiftBgr_%02d_%02d_%s",static_cast<Int_t> (jetPtLoLim),static_cast<Int_t> (jetPtUpLim),strBgrID.Data());
+ }
+
+ // project
+ // appendix 'unbinned' to avoid histos with same name after rebinning
+
+ hdNdptTracksMCGen[i] = (TH1F*) fh2FFTrackPtMCGen->ProjectionY(strNameFFPtGen+"_unBinned",binLo,binUp,"o"); // option "o": original axis range
+ hdNdzMCGen[i] = (TH1F*) fh2FFZMCGen->ProjectionY(strNameFFZGen+"_unBinned",binLo,binUp,"o");
+ hdNdxiMCGen[i] = (TH1F*) fh2FFXiMCGen->ProjectionY(strNameFFXiGen+"_unBinned",binLo,binUp,"o");
+
+ hdNdptTracksMCRec[i] = (TH1F*) fh2FFTrackPtMCRec->ProjectionY(strNameFFPtRec+"_unBinned",binLo,binUp,"o"); // option "o": original axis range
+ hdNdzMCRec[i] = (TH1F*) fh2FFZMCRec->ProjectionY(strNameFFZRec+"_unBinned",binLo,binUp,"o");
+ hdNdxiMCRec[i] = (TH1F*) fh2FFXiMCRec->ProjectionY(strNameFFXiRec+"_unBinned",binLo,binUp,"o");
+
+
+ // rebin
+
+ if(fNHistoBinsPt[i]) hdNdptTracksMCGen[i] = (TH1F*) hdNdptTracksMCGen[i]->Rebin(fNHistoBinsPt[i],strNameFFPtGen,fHistoBinsPt[i]->GetArray());
+ if(fNHistoBinsZ[i]) hdNdzMCGen[i] = (TH1F*) hdNdzMCGen[i]->Rebin(fNHistoBinsZ[i],strNameFFZGen,fHistoBinsZ[i]->GetArray());
+ if(fNHistoBinsXi[i]) hdNdxiMCGen[i] = (TH1F*) hdNdxiMCGen[i]->Rebin(fNHistoBinsXi[i],strNameFFXiGen,fHistoBinsXi[i]->GetArray());
+
+ if(fNHistoBinsPt[i]) hdNdptTracksMCRec[i] = (TH1F*) hdNdptTracksMCRec[i]->Rebin(fNHistoBinsPt[i],strNameFFPtRec,fHistoBinsPt[i]->GetArray());
+ if(fNHistoBinsZ[i]) hdNdzMCRec[i] = (TH1F*) hdNdzMCRec[i]->Rebin(fNHistoBinsZ[i],strNameFFZRec,fHistoBinsZ[i]->GetArray());
+ if(fNHistoBinsXi[i]) hdNdxiMCRec[i] = (TH1F*) hdNdxiMCRec[i]->Rebin(fNHistoBinsXi[i],strNameFFXiRec,fHistoBinsXi[i]->GetArray());
+
+
+ hdNdptTracksMCGen[i]->SetNameTitle(strNameFFPtGen,"");
+ hdNdzMCGen[i]->SetNameTitle(strNameFFZGen,"");
+ hdNdxiMCGen[i]->SetNameTitle(strNameFFXiGen,"");
+
+ hdNdptTracksMCRec[i]->SetNameTitle(strNameFFPtRec,"");
+ hdNdzMCRec[i]->SetNameTitle(strNameFFZRec,"");
+ hdNdxiMCRec[i]->SetNameTitle(strNameFFXiRec,"");
+
+ // normalize
+
+ Double_t nJetsBinGen = fh1FFJetPtMCGen->Integral(binLo,binUp);
+ Double_t nJetsBinRec = fh1FFJetPtMCRec->Integral(binLo,binUp);
+
+ // scale fac for perp2 bgr
+ if(useRecPrim && writeBgr && scaleFacBgrRec && (scaleFacBgrRec != 1)) nJetsBinRec /= scaleFacBgrRec;
+
+ NormalizeTH1(hdNdptTracksMCGen[i],nJetsBinGen);
+ NormalizeTH1(hdNdzMCGen[i],nJetsBinGen);
+ NormalizeTH1(hdNdxiMCGen[i],nJetsBinGen);
+
+ NormalizeTH1(hdNdptTracksMCRec[i],nJetsBinRec);
+ NormalizeTH1(hdNdzMCRec[i],nJetsBinRec);
+ NormalizeTH1(hdNdxiMCRec[i],nJetsBinRec);
+
+ // divide gen/rec : corr factor
+
+ TString strNameCorrPt(Form("hBbBCorrPt_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim)));
+ TString strNameCorrZ(Form("hBbBCorrZ_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim)));
+ TString strNameCorrXi(Form("hBbBCorrXi_%02d_%02d",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim)));
+
+ if(writeBgr){
+ strNameCorrPt.Form("hBbBCorrBgrPt_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ strNameCorrZ.Form("hBbBCorrBgrZ_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ strNameCorrXi.Form("hBbBCorrBgrXi_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ }
+
+ hCorrPt[i] = (TH1F*) hdNdptTracksMCGen[i]->Clone(strNameCorrPt);
+ hCorrPt[i]->Divide(hdNdptTracksMCGen[i],hdNdptTracksMCRec[i],1,1,"B"); // binominal errors
+
+ hCorrXi[i] = (TH1F*) hdNdxiMCGen[i]->Clone(strNameCorrXi);
+ hCorrXi[i]->Divide(hdNdxiMCGen[i],hdNdxiMCRec[i],1,1,"B"); // binominal errors
+
+ hCorrZ[i] = (TH1F*) hdNdzMCGen[i]->Clone(strNameCorrZ);
+ hCorrZ[i]->Divide(hdNdzMCGen[i],hdNdzMCRec[i],1,1,"B"); // binominal errors
+ }
+
+ // write
+
+ TString outfileOption = "RECREATE";
+ if(updateOutfile) outfileOption = "UPDATE";
+
+ TFile out(strOutfile,outfileOption);
+
+ if(!out.IsOpen()){
+ Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- write bin shift correction to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data());
+
+ if(strOutDir && strOutDir.Length()){
+
+ TDirectory* dir;
+ if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd();
+ else{
+ dir = out.mkdir(strOutDir);
+ dir->cd();
+ }
+ }
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ hdNdptTracksMCGen[i]->Write();
+ hdNdxiMCGen[i]->Write();
+ hdNdzMCGen[i]->Write();
+
+ hdNdptTracksMCRec[i]->Write();
+ hdNdxiMCRec[i]->Write();
+ hdNdzMCRec[i]->Write();
+
+ hCorrPt[i]->Write();
+ hCorrXi[i]->Write();
+ hCorrZ[i]->Write();
+ }
+
+ // out.Close();
+
+ delete fh1FFJetPtMCGen;
+ delete fh1FFJetPtMCRec;
+
+ delete fh2FFTrackPtMCGen;
+ delete fh2FFZMCGen;
+ delete fh2FFXiMCGen;
+
+ delete fh2FFTrackPtMCRec;
+ delete fh2FFZMCRec;
+ delete fh2FFXiMCRec;
+}
+
+//________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadBgrBinShiftCorr(TString strfile, TString strBgrID, TString strdir, TString strlist)
+{
+
+ ReadBinShiftCorr(strfile, strdir, strlist, kTRUE, strBgrID);
+}
+
+//___________________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadBinShiftCorr(TString strfile, TString strdir, TString strlist, Bool_t readBgr, TString strBgrID)
+{
+
+ if((readBgr && strBgrID.Length() == 0) || (!readBgr && strBgrID.Length()>0) ){
+ Printf("%s:%d -- inconsistent arguments to ReadBinShiftCorr FF/UE", (char*)__FILE__,__LINE__);
+ return;
+ }
+
+ // temporary histos to hold histos from file
+ TH1F* hCorrPt[fNJetPtSlices];
+ TH1F* hCorrZ[fNJetPtSlices];
+ TH1F* hCorrXi[fNJetPtSlices];
+
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0;
+
+ TFile f(strfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- read FF / UE bin shift correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data());
+
+ if(strdir && strdir.Length()) gDirectory->cd(strdir);
+
+ TList* list = 0;
+
+ if(strlist && strlist.Length()){
+
+ if(!(list = (TList*) gDirectory->Get(strlist))){
+ Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data());
+ return;
+ }
+ }
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i));
+ Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1));
+
+ TString strNameCorrPt(Form("hBbBCorrPt_%02d_%02d",jetPtLoLim,jetPtUpLim));
+ TString strNameCorrZ(Form("hBbBCorrZ_%02d_%02d",jetPtLoLim,jetPtUpLim));
+ TString strNameCorrXi(Form("hBbBCorrXi_%02d_%02d",jetPtLoLim,jetPtUpLim));
+
+ if(readBgr){
+ strNameCorrPt.Form("hBbBCorrBgrPt_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ strNameCorrZ.Form("hBbBCorrBgrZ_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ strNameCorrXi.Form("hBbBCorrBgrXi_%02d_%02d_%s",static_cast<Int_t>(jetPtLoLim),static_cast<Int_t>(jetPtUpLim),strBgrID.Data());
+ }
+
+
+ if(list){
+ hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi);
+ }
+ else{
+ hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi);
+ }
+
+ if(!hCorrPt[i]){
+ Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data());
+ }
+
+ if(!hCorrZ[i]){
+ Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data());
+ }
+
+ if(!hCorrXi[i]){
+ Printf("%s:%d -- error retrieving bin by bin correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data());
+ }
+
+
+ if(fNHistoBinsPt[i]) hCorrPt[i] = (TH1F*) hCorrPt[i]->Rebin(fNHistoBinsPt[i],strNameCorrPt+"_rebin",fHistoBinsPt[i]->GetArray());
+ if(fNHistoBinsZ[i]) hCorrZ[i] = (TH1F*) hCorrZ[i]->Rebin(fNHistoBinsZ[i],strNameCorrZ+"_rebin",fHistoBinsZ[i]->GetArray());
+ if(fNHistoBinsXi[i]) hCorrXi[i] = (TH1F*) hCorrXi[i]->Rebin(fNHistoBinsXi[i],strNameCorrXi+"_rebin",fHistoBinsXi[i]->GetArray());
+
+ if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0);
+ if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0);
+ if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0);
+
+ } // jet slices loop
+
+ f.Close();
+
+ if(readBgr){
+ for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos
+ if(hCorrPt[i]) new(fh1BbBBgrPt[i]) TH1F(*hCorrPt[i]);
+ if(hCorrZ[i]) new(fh1BbBBgrZ[i]) TH1F(*hCorrZ[i]);
+ if(hCorrXi[i]) new(fh1BbBBgrXi[i]) TH1F(*hCorrXi[i]);
+ }
+ }
+ else{
+ for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos
+ if(hCorrPt[i]) new(fh1BbBPt[i]) TH1F(*hCorrPt[i]);
+ if(hCorrZ[i]) new(fh1BbBZ[i]) TH1F(*hCorrZ[i]);
+ if(hCorrXi[i]) new(fh1BbBXi[i]) TH1F(*hCorrXi[i]);
+ }
+ }
+}
+
+// ________________________________________________
+void AliFragmentationFunctionCorrections::BbBCorr()
+{
+ // apply bin-by-bin correction
+
+ AddCorrectionLevel("BbB");
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i);
+ TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i);
+ TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i);
+
+ TString histNamePt = histPt->GetName();
+ TString histNameZ = histZ->GetName();
+ TString histNameXi = histXi->GetName();
+
+ TH1F* hFFTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt);
+ hFFTrackPtBbBCorr->Multiply(histPt,fh1BbBPt[i],1,1,"");
+
+ TH1F* hFFZBbBCorr = (TH1F*) histZ->Clone(histNameZ);
+ hFFZBbBCorr->Multiply(histZ,fh1BbBZ[i],1,1,"");
+
+ TH1F* hFFXiBbBCorr = (TH1F*) histXi->Clone(histNameXi);
+ hFFXiBbBCorr->Multiply(histXi,fh1BbBXi[i],1,1,"");
+
+ fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtBbBCorr,hFFZBbBCorr,hFFXiBbBCorr);
+ }
+}
+
+// ___________________________________________________
+void AliFragmentationFunctionCorrections::BbBCorrBgr()
+{
+ // apply bin-by-bin correction
+
+ AddCorrectionLevelBgr("BbB");
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histPt = fCorrBgr[fNCorrectionLevelsBgr-2]->GetTrackPt(i);
+ TH1F* histZ = fCorrBgr[fNCorrectionLevelsBgr-2]->GetZ(i);
+ TH1F* histXi = fCorrBgr[fNCorrectionLevelsBgr-2]->GetXi(i);
+
+ TString histNamePt = histPt->GetName();
+ TString histNameZ = histZ->GetName();
+ TString histNameXi = histXi->GetName();
+
+ TH1F* hBgrTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt);
+ hBgrTrackPtBbBCorr->Multiply(histPt,fh1BbBBgrPt[i],1,1,"");
+
+ TH1F* hBgrZBbBCorr = (TH1F*) histZ->Clone(histNameZ);
+ hBgrZBbBCorr->Multiply(histZ,fh1BbBBgrZ[i],1,1,"");
+
+ TH1F* hBgrXiBbBCorr = (TH1F*) histXi->Clone(histNameXi);
+ hBgrXiBbBCorr->Multiply(histXi,fh1BbBBgrXi[i],1,1,"");
+
+ fCorrBgr[fNCorrectionLevelsBgr-1]->AddCorrHistos(i,hBgrTrackPtBbBCorr,hBgrZBbBCorr,hBgrXiBbBCorr);
+ }
+}
+
+//_______________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadFoldingCorr(TString strfile, TString strdir, TString strlist)
+{
+
+ // temporary histos to hold histos from file
+ TH1F* hCorrPt[fNJetPtSlices];
+ TH1F* hCorrZ[fNJetPtSlices];
+ TH1F* hCorrXi[fNJetPtSlices];
+
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0;
+
+ TFile f(strfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- read bin shift correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data());
+
+ if(strdir && strdir.Length()) gDirectory->cd(strdir);
+
+ TList* list = 0;
+
+ if(strlist && strlist.Length()){
+
+ if(!(list = (TList*) gDirectory->Get(strlist))){
+ Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data());
+ return;
+ }
+ }
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i));
+ Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1));
+
+ TString strNameCorrPt(Form("hCorrFoldingPt_%02d_%02d",jetPtLoLim,jetPtUpLim));
+ TString strNameCorrZ(Form("hCorrFoldingZ_%02d_%02d",jetPtLoLim,jetPtUpLim));
+ TString strNameCorrXi(Form("hCorrFoldingXi_%02d_%02d",jetPtLoLim,jetPtUpLim));
+
+
+ if(list){
+ hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi);
+ }
+ else{
+ hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi);
+ }
+
+ if(!hCorrPt[i]){
+ //Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data());
+ }
+
+ if(!hCorrZ[i]){
+ //Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data());
+ }
+
+ if(!hCorrXi[i]){
+ Printf("%s:%d -- error retrieving folding correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data());
+ }
+
+ if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0);
+ if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0);
+ if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0);
+
+ } // jet slices loop
+
+ f.Close();
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos
+ if(hCorrPt[i]) new(fh1FoldingCorrPt[i]) TH1F(*hCorrPt[i]);
+ if(hCorrZ[i]) new(fh1FoldingCorrZ[i]) TH1F(*hCorrZ[i]);
+ if(hCorrXi[i]) new(fh1FoldingCorrXi[i]) TH1F(*hCorrXi[i]);
+ }
+}
+
+// ___________________________________________________
+void AliFragmentationFunctionCorrections::FoldingCorr()
+{
+ // apply bin-by-bin correction
+
+ AddCorrectionLevel("FoldingCorr");
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i);
+ TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i);
+ TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i);
+
+ TString histNamePt = histPt->GetName();
+ TString histNameZ = histZ->GetName();
+ TString histNameXi = histXi->GetName();
+
+ std::cout<<" foldingCorr: i "<<i<<" corr pt "<<fh1FoldingCorrPt[i]<<" z "<<fh1FoldingCorrZ[i]<<" xi "
+ <<fh1FoldingCorrXi[i]<<std::endl;
+
+ std::cout<<" foldingCorr: i "<<i<<" mean corr pt "<<fh1FoldingCorrPt[i]->GetMean()<<" z "<<fh1FoldingCorrZ[i]->GetMean()<<" xi "
+ <<fh1FoldingCorrXi[i]->GetMean()<<std::endl;
+
+
+
+ TH1F* hFFTrackPtFoldingCorr = (TH1F*) histPt->Clone(histNamePt);
+ if(fh1FoldingCorrPt[i] && fh1FoldingCorrPt[i]->GetMean()>0) hFFTrackPtFoldingCorr->Multiply(histPt,fh1FoldingCorrPt[i],1,1,"");
+ else hFFTrackPtFoldingCorr->Reset();
+
+ TH1F* hFFZFoldingCorr = (TH1F*) histZ->Clone(histNameZ);
+ if(fh1FoldingCorrZ[i] && fh1FoldingCorrZ[i]->GetMean()>0) hFFZFoldingCorr->Multiply(histZ,fh1FoldingCorrZ[i],1,1,"");
+ else hFFZFoldingCorr->Reset();
+
+ TH1F* hFFXiFoldingCorr = (TH1F*) histXi->Clone(histNameXi);
+ if(fh1FoldingCorrXi[i]&& fh1FoldingCorrXi[i]->GetMean()>0) hFFXiFoldingCorr->Multiply(histXi,fh1FoldingCorrXi[i],1,1,"");
+ else hFFXiFoldingCorr->Reset();
+
+ fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtFoldingCorr,hFFZFoldingCorr,hFFXiFoldingCorr);
+ }
+}
+
+//________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadBgrJetSecCorr(TString strfile, TString strBgrID, TString strdir, TString strlist,
+ Bool_t useScaledStrangeness)
+{
+
+ ReadJetSecCorr(strfile, strdir, strlist, useScaledStrangeness, kTRUE, strBgrID);
+}
+
+//_______________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadJetSecCorr(TString strfile, TString strdir, TString strlist, Bool_t useScaledStrangeness,
+ Bool_t readBgr, TString strBgrID){
+
+ // read reconstruction efficiency from file
+ // argument strlist optional - read from directory strdir if not specified
+
+ // temporary histos to hold histos from file
+ TH1F* hCorrPt[fNJetPtSlices];
+ TH1F* hCorrZ[fNJetPtSlices];
+ TH1F* hCorrXi[fNJetPtSlices];
+
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrPt[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrZ[i] = 0;
+ for(Int_t i=0; i<fNJetPtSlices; i++) hCorrXi[i] = 0;
+
+ TFile f(strfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- read secondary correction from file %s ",(char*)__FILE__,__LINE__,strfile.Data());
+
+ if(strdir && strdir.Length()) gDirectory->cd(strdir);
+
+ TList* list = 0;
+
+ if(strlist && strlist.Length()){
+
+ if(!(list = (TList*) gDirectory->Get(strlist))){
+ Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data());
+ return;
+ }
+ }
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ Int_t jetPtLoLim = static_cast<Int_t> (fJetPtSlices->At(i));
+ Int_t jetPtUpLim = static_cast<Int_t> (fJetPtSlices->At(i+1));
+
+ TString strNameCorrPt("");
+ TString strNameCorrZ("");
+ TString strNameCorrXi("");
+
+ if(readBgr){
+ strNameCorrPt.Form("hSecCorrBgrPt_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+ strNameCorrZ.Form("hSecCorrBgrZ_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+ strNameCorrXi.Form("hSecCorrBgrXi_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+
+ if(!useScaledStrangeness){
+ Printf("%s:%d -- readJetSecCorr bgr: using naive Pythia strangenss ", (char*)__FILE__,__LINE__);
+ strNameCorrPt.Form("hSecCorrBgrPt_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+ strNameCorrZ.Form("hSecCorrBgrZ_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+ strNameCorrXi.Form("hSecCorrBgrXi_nonSc_%02d_%02d_%s",jetPtLoLim,jetPtUpLim,strBgrID.Data());
+ }
+ }
+ else{
+ strNameCorrPt.Form("hSecCorrPt_%02d_%02d",jetPtLoLim,jetPtUpLim);
+ strNameCorrZ.Form("hSecCorrZ_%02d_%02d",jetPtLoLim,jetPtUpLim);
+ strNameCorrXi.Form("hSecCorrXi_%02d_%02d",jetPtLoLim,jetPtUpLim);
+
+ if(!useScaledStrangeness){
+ Printf("%s:%d -- readJetSecCorr: using naive Pythia strangenss ", (char*)__FILE__,__LINE__);
+ strNameCorrPt.Form("hSecCorrPt_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim);
+ strNameCorrZ.Form("hSecCorrZ_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim);
+ strNameCorrXi.Form("hSecCorrXi_nonSc_%02d_%02d",jetPtLoLim,jetPtUpLim);
+ }
+ }
+
+ if(list){
+ hCorrPt[i] = (TH1F*) list->FindObject(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) list->FindObject(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) list->FindObject(strNameCorrXi);
+ }
+ else{
+ hCorrPt[i] = (TH1F*) gDirectory->Get(strNameCorrPt);
+ hCorrZ[i] = (TH1F*) gDirectory->Get(strNameCorrZ);
+ hCorrXi[i] = (TH1F*) gDirectory->Get(strNameCorrXi);
+ }
+
+ if(!hCorrPt[i]){
+ Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrPt.Data());
+ }
+
+ if(!hCorrZ[i]){
+ Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrZ.Data());
+ }
+
+ if(!hCorrXi[i]){
+ Printf("%s:%d -- error retrieving secondaries correction %s", (char*)__FILE__,__LINE__,strNameCorrXi.Data());
+ }
+
+ if(fNHistoBinsPt[i]) hCorrPt[i] = (TH1F*) hCorrPt[i]->Rebin(fNHistoBinsPt[i],strNameCorrPt+"_rebin",fHistoBinsPt[i]->GetArray());
+ if(fNHistoBinsZ[i]) hCorrZ[i] = (TH1F*) hCorrZ[i]->Rebin(fNHistoBinsZ[i],strNameCorrZ+"_rebin",fHistoBinsZ[i]->GetArray());
+ if(fNHistoBinsXi[i]) hCorrXi[i] = (TH1F*) hCorrXi[i]->Rebin(fNHistoBinsXi[i],strNameCorrXi+"_rebin",fHistoBinsXi[i]->GetArray());
+
+ if(hCorrPt[i]) hCorrPt[i]->SetDirectory(0);
+ if(hCorrZ[i]) hCorrZ[i]->SetDirectory(0);
+ if(hCorrXi[i]) hCorrXi[i]->SetDirectory(0);
+
+ } // jet slices loop
+
+ f.Close();
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){ // 2nd loop: need to close input file before placing histos
+
+ if(readBgr){
+ if(hCorrPt[i]) new(fh1SecCorrBgrPt[i]) TH1F(*hCorrPt[i]);
+ if(hCorrZ[i]) new(fh1SecCorrBgrZ[i]) TH1F(*hCorrZ[i]);
+ if(hCorrXi[i]) new(fh1SecCorrBgrXi[i]) TH1F(*hCorrXi[i]);
+ }
+ else{
+ if(hCorrPt[i]) new(fh1SecCorrPt[i]) TH1F(*hCorrPt[i]);
+ if(hCorrZ[i]) new(fh1SecCorrZ[i]) TH1F(*hCorrZ[i]);
+ if(hCorrXi[i]) new(fh1SecCorrXi[i]) TH1F(*hCorrXi[i]);
+ }
+ }
+}
+
+// ___________________________________________________
+void AliFragmentationFunctionCorrections::JetSecCorr()
+{
+ // apply secondaries correction
+
+ AddCorrectionLevel("SecCorr");
+
+ Printf("%s:%d -- apply jet secondaries correction", (char*)__FILE__,__LINE__);
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histPt = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i);
+ TH1F* histZ = fCorrFF[fNCorrectionLevels-2]->GetZ(i);
+ TH1F* histXi = fCorrFF[fNCorrectionLevels-2]->GetXi(i);
+
+ TString histNamePt = histPt->GetName();
+ TString histNameZ = histZ->GetName();
+ TString histNameXi = histXi->GetName();
+
+ TH1F* hFFTrackPtSecCorr = (TH1F*) histPt->Clone(histNamePt);
+ hFFTrackPtSecCorr->Multiply(histPt,fh1SecCorrPt[i],1,1,"");
+
+ TH1F* hFFZSecCorr = (TH1F*) histZ->Clone(histNameZ);
+ hFFZSecCorr->Multiply(histZ,fh1SecCorrZ[i],1,1,"");
+
+ TH1F* hFFXiSecCorr = (TH1F*) histXi->Clone(histNameXi);
+ hFFXiSecCorr->Multiply(histXi,fh1SecCorrXi[i],1,1,"");
+
+ fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hFFTrackPtSecCorr,hFFZSecCorr,hFFXiSecCorr);
+ }
+}
+
+
+
+// ___________________________________________________
+void AliFragmentationFunctionCorrections::JetSecCorrBgr()
+{
+ // apply secondaries correction to UE
+
+ AddCorrectionLevelBgr("SecCorr");
+
+ Printf("%s:%d -- apply jet secondaries correction", (char*)__FILE__,__LINE__);
+
+ for(Int_t i=0; i<fNJetPtSlices; i++){
+
+ TH1F* histPt = fCorrBgr[fNCorrectionLevelsBgr-2]->GetTrackPt(i);
+ TH1F* histZ = fCorrBgr[fNCorrectionLevelsBgr-2]->GetZ(i);
+ TH1F* histXi = fCorrBgr[fNCorrectionLevelsBgr-2]->GetXi(i);
+
+ TString histNamePt = histPt->GetName();
+ TString histNameZ = histZ->GetName();
+ TString histNameXi = histXi->GetName();
+
+ TH1F* hFFTrackPtSecCorr = (TH1F*) histPt->Clone(histNamePt);
+ hFFTrackPtSecCorr->Multiply(histPt,fh1SecCorrBgrPt[i],1,1,"");
+
+ TH1F* hFFZSecCorr = (TH1F*) histZ->Clone(histNameZ);
+ hFFZSecCorr->Multiply(histZ,fh1SecCorrBgrZ[i],1,1,"");
+
+ TH1F* hFFXiSecCorr = (TH1F*) histXi->Clone(histNameXi);
+ hFFXiSecCorr->Multiply(histXi,fh1SecCorrBgrXi[i],1,1,"");
+
+ fCorrBgr[fNCorrectionLevelsBgr-1]->AddCorrHistos(i,hFFTrackPtSecCorr,hFFZSecCorr,hFFXiSecCorr);
+ }
+}
+
+
+//________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::WriteBinShiftCorrSinglePt(TString strInfile, TString strIDGen, TString strIDRec,
+ TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim,
+ TString strOutDir)
+{
+ TString strdirGen = "PWGJE_FragmentationFunction_" + strIDGen;
+ TString strlistGen = "fracfunc_" + strIDGen;
+
+ TString strdirRec = "PWGJE_FragmentationFunction_" + strIDRec;
+ TString strlistRec = "fracfunc_" + strIDRec;
+
+ WriteBinShiftCorrSinglePt(strInfile,strdirGen,strlistGen,strdirRec,strlistRec,strOutfile,updateOutfile,useRecPrim,strOutDir);
+}
+
+//___________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::WriteBinShiftCorrSinglePt(TString strInfile, TString strdirGen, TString strlistGen,
+ TString strdirRec, TString strlistRec,
+ TString strOutfile, Bool_t updateOutfile, Bool_t useRecPrim,
+ TString strOutDir){
+
+
+ TH1F* hCorrPt = 0;
+ TH1F* hdNdptTracksMCGen = 0;
+ TH1F* hdNdptTracksMCRec = 0;
+
+ // gen level FF
+
+ TFile f(strInfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- writeBinShiftCorrSinglePt: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data());
+
+ if(strdirGen && strdirGen.Length()) gDirectory->cd(strdirGen);
+
+ TList* listGen = 0;
+
+ if(strlistGen && strlistGen.Length()){
+
+ if(!(listGen = (TList*) gDirectory->Get(strlistGen))){
+ Printf("%s:%d -- error retrieving listGen %s from directory %s", (char*)__FILE__,__LINE__,strlistGen.Data(),strdirGen.Data());
+ return;
+ }
+ }
+
+ if(listGen){
+ hdNdptTracksMCGen = (TH1F*) listGen->FindObject("fh1TrackQAPtGen");
+ }
+ else{
+ hdNdptTracksMCGen = (TH1F*) gDirectory->Get("fh1TrackQAPtGen");
+ }
+
+ hdNdptTracksMCGen->SetDirectory(0);
+
+ f.Close();
+
+ // rec level FF
+
+ TFile g(strInfile,"READ");
+
+ if(!g.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strInfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- writeBinShiftCorrSinglePt: open task ouput file %s",(char*)__FILE__,__LINE__,strInfile.Data());
+
+ if(strdirRec && strdirRec.Length()) gDirectory->cd(strdirRec);
+
+ TList* listRec = 0;
+
+ if(strlistRec && strlistRec.Length()){
+
+ if(!(listRec = (TList*) gDirectory->Get(strlistRec))){
+ Printf("%s:%d -- error retrieving listRec %s from directory %s", (char*)__FILE__,__LINE__,strlistRec.Data(),strdirRec.Data());
+ return;
+ }
+ }
+
+
+ if(useRecPrim){
+ if(listRec){
+ hdNdptTracksMCRec = (TH1F*) listRec->FindObject("fh1TrackQAPtRecEffRec");
+ }
+ else{
+ hdNdptTracksMCRec = (TH1F*) gDirectory->Get("fh1TrackQAPtRecEffRec");
+ }
+ }
+ else{
+ if(listRec){
+ hdNdptTracksMCRec = (TH1F*) listRec->FindObject("fh1TrackQAPtRecCuts");
+ }
+ else{
+ hdNdptTracksMCRec = (TH1F*) gDirectory->Get("fh1TrackQAPtRecCuts");
+ }
+ }
+
+ hdNdptTracksMCRec->SetDirectory(0);
+
+ g.Close();
+
+ TString strNamePtGen = "fh1SinglePtGenBbB";
+ TString strNamePtRec = "fh1SinglePtRecBbB";
+
+ // rebin
+ if(fNHistoBinsSinglePt) hdNdptTracksMCGen = (TH1F*) hdNdptTracksMCGen->Rebin(fNHistoBinsSinglePt,strNamePtGen+"_rebin",fHistoBinsSinglePt->GetArray());
+ if(fNHistoBinsSinglePt) hdNdptTracksMCRec = (TH1F*) hdNdptTracksMCRec->Rebin(fNHistoBinsSinglePt,strNamePtRec+"_rebin",fHistoBinsSinglePt->GetArray());
+
+ hdNdptTracksMCGen->SetNameTitle(strNamePtGen,"");
+ hdNdptTracksMCRec->SetNameTitle(strNamePtRec,"");
+
+ // corr fac
+ TString strTitCorr = "hBbBCorrSinglePt";
+ if(useRecPrim) strTitCorr = "hBbBCorrRecPrimSinglePt";
+
+ hCorrPt = (TH1F*) hdNdptTracksMCGen->Clone(strTitCorr);
+ hCorrPt->Divide(hdNdptTracksMCGen,hdNdptTracksMCRec,1,1,"B"); // binominal errors
+
+ // write
+
+ TString outfileOption = "RECREATE";
+ if(updateOutfile) outfileOption = "UPDATE";
+
+ TFile out(strOutfile,outfileOption);
+
+ if(!out.IsOpen()){
+ Printf("%s:%d -- error opening efficiency output file %s", (char*)__FILE__,__LINE__,strOutfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- write bin shift correction to file %s ",(char*)__FILE__,__LINE__,strOutfile.Data());
+
+ if(strOutDir && strOutDir.Length()){
+
+ TDirectory* dir;
+ if((dir = ((TDirectory*) gDirectory->Get(strOutDir)))) dir->cd();
+ else{
+ dir = out.mkdir(strOutDir);
+ dir->cd();
+ }
+ }
+
+
+ hdNdptTracksMCGen->Write();
+ hdNdptTracksMCRec->Write();
+ hCorrPt->Write();
+
+ out.Close();
+
+ delete hdNdptTracksMCGen;
+ delete hdNdptTracksMCRec;
+ delete hCorrPt;
+}
+
+//___________________________________________________________________________________________________________________________________
+void AliFragmentationFunctionCorrections::ReadBinShiftCorrSinglePt(TString strfile, TString strdir, TString strlist, Bool_t useRecPrim)
+{
+ // read reconstruction efficiency from file
+ // argument strlist optional - read from directory strdir if not specified
+
+ // temporary histos to hold histos from file
+ TH1F* hBbBCorrPt = 0;
+
+ TFile f(strfile,"READ");
+
+ if(!f.IsOpen()){
+ Printf("%s:%d -- error opening raw data file %s", (char*)__FILE__,__LINE__,strfile.Data());
+ return;
+ }
+
+ if(fDebug>0) Printf("%s:%d -- read BbB corr from file %s ",(char*)__FILE__,__LINE__,strfile.Data());
+
+ if(strdir && strdir.Length()) gDirectory->cd(strdir);
+
+ TList* list = 0;
+
+ if(strlist && strlist.Length()){
+
+ if(!(list = (TList*) gDirectory->Get(strlist))){
+ Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data());
+ return;
+ }
+ }
+
+
+ TString strNameBbBCorrPt = "hBbBCorrSinglePt";
+ if(useRecPrim) strNameBbBCorrPt = "hBbBCorrRecPrimSinglePt";
+
+ if(list){
+ hBbBCorrPt = (TH1F*) list->FindObject(strNameBbBCorrPt);
+ }
+ else{
+ hBbBCorrPt = (TH1F*) gDirectory->Get(strNameBbBCorrPt);
+ }
+
+ if(!hBbBCorrPt){
+ Printf("%s:%d -- error retrieving BbB corr single pt %s", (char*)__FILE__,__LINE__,strNameBbBCorrPt.Data());
+ }
+
+
+ if(fNHistoBinsPt && hBbBCorrPt)
+ hBbBCorrPt = (TH1F*) hBbBCorrPt->Rebin(fNHistoBinsSinglePt,strNameBbBCorrPt+"_rebin",fHistoBinsSinglePt->GetArray());
+
+ if(hBbBCorrPt) hBbBCorrPt->SetDirectory(0);
+
+ f.Close();
+
+ fh1BbBCorrSinglePt = hBbBCorrPt;
+}
+
+// ------------------------------------------------------------------
+
+void AliFragmentationFunctionCorrections::BbBCorrSinglePt()
+{
+ // apply efficiency correction to inclusive track pt spec
+
+ AddCorrectionLevelSinglePt("BbB");
+
+ TH1F* histPt = fCorrSinglePt[fNCorrectionLevelsSinglePt-2]->GetTrackPt(0);
+
+ if(histPt->GetNbinsX() != fh1BbBCorrSinglePt->GetNbinsX()){
+ Printf("%s:%d: inconsistency pt spec and BbB corr binning ", (char*)__FILE__,__LINE__);
+ return;
+ }
+
+ TString histNamePt = histPt->GetName();
+ TH1F* hTrackPtBbBCorr = (TH1F*) histPt->Clone(histNamePt);
+
+ hTrackPtBbBCorr->Multiply(histPt,fh1BbBCorrSinglePt,1,1,"");
+
+ fCorrSinglePt[fNCorrectionLevelsSinglePt-1]->AddCorrHistos(0,hTrackPtBbBCorr);
+}
+