+ // Get charge asymmetry or mu+/mu-
+ THashList histoListRatio;
+ TString basePlotName = plotChargeAsymmetry ? "ChargeAsymmetry" : "ChargeRatio";
+ histoListRatio.SetName(basePlotName.Data());
+ Int_t baseCharge = 1;
+ Int_t auxCharge = 1-baseCharge;
+ for ( Int_t ihisto=0; ihisto<histoList[baseCharge].GetEntries(); ihisto++ ) {
+ TObject* obj = histoList[baseCharge].At(ihisto);
+ TString histoName = obj->GetName();
+ if ( histoName.Contains(gridSparseName[2].Data()) ) continue;
+ TString searchName = histoName;
+ searchName.ReplaceAll(fChargeKeys->At(baseCharge)->GetName(), fChargeKeys->At(auxCharge)->GetName());
+ TH1* auxHisto = static_cast<TH1*> (histoList[auxCharge].FindObject(searchName.Data()));
+ if ( ! auxHisto ) continue;
+ histoName.ReplaceAll(fChargeKeys->At(baseCharge)->GetName(),basePlotName.Data());
+ TH1* histo = static_cast<TH1*> (obj->Clone(histoName.Data()));
+ if ( plotChargeAsymmetry ) {
+ histo->Add(auxHisto, -1.);
+ // h2 + h1 = 2xh2 + (h1-h2)
+ auxHisto->Add(auxHisto, histo, 2.);
+ }
+ histo->Divide(auxHisto);
+ TString axisTitle = plotChargeAsymmetry ? Form("(%s - %s) / (%s + %s)", fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName(), fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName()) : Form("%s / %s", fChargeKeys->At(1)->GetName(), fChargeKeys->At(0)->GetName());
+ axisTitle.ReplaceAll("MuPlus","#mu^{+}");
+ axisTitle.ReplaceAll("MuMinus","#mu^{-}");
+ histo->GetYaxis()->SetTitle(axisTitle.Data());
+ histo->SetStats(kFALSE);
+ histoListRatio.Add(histo);
+ }
+
+ // Plot kinematics
+ TString histoName = "", drawOpt = "";
+ for ( Int_t itype=0; itype<3; itype++ ) {
+ THashList* currList = 0x0;
+ Int_t nCharges = 1;
+ if ( itype == 1 ) currList = &histoListRatio;
+ else if ( itype == 2 ) currList = &histoList[2];
+ else nCharges = 2;
+ for ( Int_t igrid=0; igrid<3; ++igrid ) {
+ igroup1 = igrid;
+ TCanvas* canKine = 0x0;
+ TLegend* legKine = 0x0;
+ for ( Int_t iproj=0; iproj<4; ++iproj ) {
+ for ( Int_t isrc = firstSrcBin; isrc <= lastSrcBin; ++isrc ) {
+ for ( Int_t icharge=0; icharge<nCharges; ++icharge ) {
+ if ( itype == 0 ) currList = &histoList[icharge];
+ histoName = Form("proj%i_%s_%s_%s", iproj, gridSparseName[igrid].Data(), srcAxis->GetBinLabel(isrc), currList->GetName());
+ TH1* histo = static_cast<TH1*>(currList->FindObject(histoName.Data()));
+ if ( ! histo ) continue;
+ if ( ! canKine ) {
+ igroup2 = itype;
+ igroup1 = igrid;
+ currName = Form("%s_%s_%s", GetName(), currList->GetName(), gridSparseName[igrid].Data());
+ canKine = new TCanvas(currName.Data(),currName.Data(),igroup1*xshift,igroup2*yshift,600,600);
+ canKine->Divide(2,2);
+ legKine = new TLegend(0.6, 0.6, 0.8, 0.8);
+ }
+ canKine->cd(iproj+1);
+ if ( itype != 1 ) {
+ if ( ( iproj == kHvarPt || iproj == kHvarVz ) && gridSparseArray[igrid]->IsA() != AliCFEffGrid::Class() ) gPad->SetLogy();
+ }
+ Bool_t isFirst = ( gPad->GetListOfPrimitives()->GetEntries() == 0 );
+ drawOpt = isFirst ? "e" : "esames";
+ histo->SetLineColor(srcColors[isrc-1]);
+ histo->SetMarkerColor(srcColors[isrc-1]);
+ histo->SetMarkerStyle(20+4*icharge);
+ histo->Draw(drawOpt.Data());
+ TPaveStats* paveStats = (TPaveStats*)histo->FindObject("stats");
+ if ( paveStats ) paveStats->SetTextColor(srcColors[isrc-1]);
+ if ( iproj == 0 ) {
+ TString legEntry = ( itype == 0 ) ? fChargeKeys->At(icharge)->GetName() : "";
+ if ( isMC ) legEntry += Form(" %s", srcAxis->GetBinLabel(isrc));
+ if ( ! legEntry.IsNull() ) legKine->AddEntry(histo,legEntry.Data(), "lp");
+ }
+ } // loop on mu charge
+ } // loop on track sources
+ } // loop on projections
+ if ( legKine && legKine->GetNRows() > 0 ) {
+ canKine->cd(1);
+ legKine->Draw("same");
+ }
+ } // loop on grid sparse
+ } // loop on types
+