@@ -395,7 +395,7 @@ TProfile* FlowContainer::GetCorrXXVsMulti(const char* order, int l_pti)
395395 }
396396 return retSubset;
397397};
398- TProfile * FlowContainer::GetCorrXXVsPt (const char * order, double lminmulti, double lmaxmulti)
398+ TH1D * FlowContainer::GetCorrXXVsPt (const char * order, double lminmulti, double lmaxmulti)
399399{
400400 int minm = 1 ;
401401 int maxm = fProf ->GetXaxis ()->GetNbins ();
@@ -408,35 +408,31 @@ TProfile* FlowContainer::GetCorrXXVsPt(const char* order, double lminmulti, doub
408408 if (lmaxmulti > lminmulti)
409409 maxm = fProf ->GetXaxis ()->FindBin (lmaxmulti - 0.001 );
410410 ProfileSubset* rhProfSub = new ProfileSubset (*fProf );
411- TProfile* retSubset = 0 ;
412411 TString l_name (" " );
413412 Ssiz_t l_pos = 0 ;
414413 while (fIDName .Tokenize (l_name, l_pos)) {
415414 TString ybl1 (Form (" %s%s_pt_1" , l_name.Data (), order));
416415 TString ybl2 (Form (" %s%s_pt_%i" , l_name.Data (), order, fNbinsPt ));
417416 int ybn1 = fProf ->GetYaxis ()->FindBin (ybl1.Data ());
418417 int ybn2 = fProf ->GetYaxis ()->FindBin (ybl2.Data ());
419- rhProfSub->GetYaxis ()->SetRange (ybn1, ybn2);
420- TProfile* tempprof = rhProfSub->GetSubset (kFALSE , " tempprof" , minm, maxm, fNbinsPt , fbinsPt);
421- if (!retSubset) {
422- TString profname = Form (" %s_MultiB_%i_%i" , order, minm, maxm);
423- retSubset = dynamic_cast <TProfile*>(tempprof->Clone (profname.Data ()));
424- } else {
425- retSubset->Add (tempprof);
418+ if (fNbinsPt != (ybn2 - ybn1 + 1 )) {
419+ printf (" fNbinsPt is not matching the num of found histograms" );
420+ return nullptr ;
426421 }
427- delete tempprof;
428- }
429- delete rhProfSub;
430- if (fPtRebinEdges ) {
431- TString pnbu (retSubset->GetName ());
432- retSubset->SetName (" TempName" );
433- TProfile* tempprof = dynamic_cast <TProfile*>(retSubset->Rebin (fPtRebin , pnbu.Data (), fPtRebinEdges ));
434- delete retSubset;
435- retSubset = tempprof;
436- } else {
437- retSubset->RebinX (fPtRebin );
422+ TProfile* profY = rhProfSub->ProfileY (" profY" , minm, maxm);
423+ TH1D* histY = ProfToHist (profY);
424+ TH1D* hist = new TH1D (" temphist" , " temphist" , fNbinsPt , fbinsPt);
425+ for (int ibin = 1 ; ibin < hist->GetNbinsX (); ibin++) {
426+ TString bLabel = rhProfSub->GetYaxis ()->GetBinLabel (ibin + ybn1 - 1 );
427+ hist->GetXaxis ()->SetBinLabel (ibin, bLabel.Data ());
428+ hist->SetBinContent (ibin, histY->GetBinContent (ibin + ybn1 - 1 ));
429+ hist->SetBinError (ibin, histY->GetBinError (ibin + ybn1 - 1 ));
430+ }
431+ delete histY;
432+ delete rhProfSub;
433+ return hist;
438434 }
439- return retSubset ;
435+ return nullptr ;
440436};
441437TH1D* FlowContainer::ProfToHist (TProfile* inpf)
442438{
@@ -462,16 +458,18 @@ TH1D* FlowContainer::GetHistCorrXXVsMulti(const char* order, int l_pti)
462458}
463459TH1D* FlowContainer::GetHistCorrXXVsPt (const char * order, double lminmulti, double lmaxmulti)
464460{
465- TProfile* tpf = GetCorrXXVsPt (order, lminmulti, lmaxmulti);
466- TH1D* rethist = ProfToHist (tpf);
461+ TH1D* rethist = GetCorrXXVsPt (order, lminmulti, lmaxmulti);
462+ if (!rethist) {
463+ printf (" GetCorrXXVsPt return nullptr!" );
464+ return nullptr ;
465+ }
467466 TProfile* refflow = GetRefFlowProfile (order, lminmulti, lmaxmulti);
468467 if (refflow) {
469468 refflow->RebinX (refflow->GetNbinsX ());
470469 rethist->SetBinContent (0 , refflow->GetBinContent (1 ));
471470 rethist->SetBinError (0 , refflow->GetBinError (1 ));
472471 }
473472 delete refflow;
474- delete tpf;
475473 return rethist;
476474}
477475TH1D* FlowContainer::GetVN2 (TH1D* cn2)
0 commit comments