39 fNumOfFirstBinSteps(1),
40 fNumOfLowLimFitSteps(6),
42 fNumOfUpLimFitSteps(6),
44 fNumOfnSigmaBinCSteps(11),
45 fnSigmaBinCSteps(0x0),
48 fSigmaMCVariation(0.15),
58 fUsePowLawBkg(kFALSE),
59 fUsePowLawTimesExpoBkg(kFALSE),
60 fUseFixSigUpFreeMean(kTRUE),
61 fUseFixSigDownFreeMean(kTRUE),
63 fUseFixedMeanFreeS(kTRUE),
64 fUseFixSigFreeMean(kTRUE),
65 fUseFixSigFixMean(kTRUE),
67 fDrawIndividualFits(kFALSE),
68 fHistoRawYieldDistAll(0x0),
69 fHistoRawYieldTrialAll(0x0),
70 fHistoSigmaTrialAll(0x0),
71 fHistoMeanTrialAll(0x0),
72 fHistoChi2TrialAll(0x0),
73 fHistoSignifTrialAll(0x0),
74 fHistoBkgTrialAll(0x0),
75 fHistoBkgInBinEdgesTrialAll(0x0),
76 fHistoRawYieldDistBinCAll(0x0),
77 fHistoRawYieldTrialBinCAll(0x0),
78 fHistoRawYieldDist(0x0),
79 fHistoRawYieldTrial(0x0),
80 fHistoSigmaTrial(0x0),
83 fHistoSignifTrial(0x0),
85 fHistoBkgInBinEdgesTrial(0x0),
86 fHistoRawYieldDistBinC(0x0),
87 fHistoRawYieldTrialBinC(0x0),
90 fNtupleMultiTrials(0x0),
96 Int_t rebinStep[4]={3,4,5,6};
97 Double_t minMassStep[6]={1.68,1.70,1.72,1.74,1.76,1.78};
98 Double_t maxMassStep[6]={2.06,2.04,2.02,2.00,1.98,1.96};
99 Double_t nSigmasBC[11]={2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0};
123 TString gausSig[
kNFitConfCases]={
"FixedS",
"FixedSp20",
"FixedSm20",
"FreeS",
"FixedMeanFixedS",
"FixedMeanFreeS"};
128 fHistoRawYieldTrialAll =
new TH1F(Form(
"hRawYieldTrialAll%s",
fSuffix.Data()),
" ; Trial # ; Raw Yield",nCases*totTrials,-0.5,nCases*totTrials-0.5);
129 fHistoSigmaTrialAll =
new TH1F(Form(
"hSigmaTrialAll%s",
fSuffix.Data()),
" ; Trial # ; Sigma (GeV/c^{2})",nCases*totTrials,-0.5,nCases*totTrials-0.5);
130 fHistoMeanTrialAll =
new TH1F(Form(
"hMeanTrialAll%s",
fSuffix.Data()),
" ; Trial # ; Mean (GeV/c^{2})",nCases*totTrials,-0.5,nCases*totTrials-0.5);
131 fHistoChi2TrialAll =
new TH1F(Form(
"hChi2TrialAll%s",
fSuffix.Data()),
" ; Trial # ; #chi^{2}",nCases*totTrials,-0.5,nCases*totTrials-0.5);
132 fHistoSignifTrialAll =
new TH1F(Form(
"hSignifTrialAll%s",
fSuffix.Data()),
" ; Trial # ; Significance",nCases*totTrials,-0.5,nCases*totTrials-0.5);
134 fHistoBkgTrialAll =
new TH1F(Form(
"hBkgTrialAll%s",
fSuffix.Data()),
" ; Background",nCases*totTrials,-0.5,nCases*totTrials-0.5);
158 Int_t theCase=igs*kNBkgFuncCases+ib;
161 fHistoRawYieldTrial[theCase]=
new TH1F(Form(
"hRawYieldTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; Raw Yield",totTrials,-0.5,totTrials-0.5);
162 fHistoRawYieldTrialBinC[theCase]=
new TH2F(Form(
"hRawYieldTrialBinC%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; Range for count ; Raw Yield (bin count)",totTrials,-0.5,totTrials-0.5,
fNumOfnSigmaBinCSteps,-0.5,
fNumOfnSigmaBinCSteps-0.5);
163 fHistoSigmaTrial[theCase]=
new TH1F(Form(
"hSigmaTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; Sigma (GeV/c^{2})",totTrials,-0.5,totTrials-0.5);
164 fHistoMeanTrial[theCase]=
new TH1F(Form(
"hMeanTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; Mean (GeV/c^{2})",totTrials,-0.5,totTrials-0.5);
165 fHistoChi2Trial[theCase]=
new TH1F(Form(
"hChi2Trial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; #chi^{2}",totTrials,-0.5,totTrials-0.5);
166 fHistoSignifTrial[theCase]=
new TH1F(Form(
"hSignifTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Trial # ; Significance",totTrials,-0.5,totTrials-0.5);
168 fHistoBkgTrial[theCase] =
new TH1F(Form(
"hBkgTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Background",totTrials,-0.5,totTrials-0.5);
169 fHistoBkgInBinEdgesTrial[theCase] =
new TH1F(Form(
"hBkgInBinEdgesTrial%s%s%s",funcBkg[ib].
Data(),gausSig[igs].
Data(),
fSuffix.Data()),
" ; Background in bin edges",totTrials,-0.5,totTrials-0.5);
183 fNtupleMultiTrials =
new TNtuple(Form(
"ntuMultiTrial%s",
fSuffix.Data()),Form(
"ntuMultiTrial%s",
fSuffix.Data()),
"rebin:firstb:minfit:maxfit:bkgfunc:confsig:confmean:chi2:signif:mean:emean:sigma:esigma:rawy:erawy",128000);
194 if(!hOK)
return kFALSE;
210 else hRebinned=
RebinHisto(hInvMassHisto,rebin,iFirstBin);
213 Double_t hmin=TMath::Max(minMassForFit,hRebinned->GetBinLowEdge(2));
216 Double_t hmax=TMath::Min(maxMassForFit,hRebinned->GetBinLowEdge(hRebinned->GetNbinsX()));
236 for(
Int_t j=0; j<15; j++) xnt[j]=0.;
238 Bool_t mustDeleteFitter = kTRUE;
263 Printf(
"Using likelihood fit");
267 Printf(
"Using chi2 fit");
271 Printf(
"Using likelihood fit with weights");
317 if(typeb<kNBkgFuncCases){
318 printf(
"****** START FIT OF HISTO %s WITH REBIN %d FIRST BIN %d MASS RANGE %f-%f BACKGROUND FIT FUNCTION=%d CONFIG SIGMA/MEAN=%d\n",hInvMassHisto->GetName(),
rebin,iFirstBin,
minMassForFit,
maxMassForFit,
typeb,igs);
325 if(esigma<0.00001) esigma=0.0001;
327 if(epos<0.00001) epos=0.0001;
334 fitter->
Background(minval,maxval,bkgBEdge,erbkgBEdge);
339 mustDeleteFitter = kFALSE;
341 thePad->SaveAs(Form(
"FitOutput_%s_Trial%d.%s",hInvMassHisto->GetName(),globBin,
format.c_str()));
419 if(minMassBC>minMassForFit &&
420 maxMassBC<maxMassForFit &&
421 minMassBC>(hRebinned->GetXaxis()->GetXmin()) &&
422 maxMassBC<(hRebinned->GetXaxis()->GetXmax())){
424 BinCount(hRebinned,fB1,1,minMassBC,maxMassBC,cnts,ecnts);
435 if (mustDeleteFitter)
delete fitter;
451 TFile outHistos(fileName.Data(),option.Data());
452 if (outHistos.IsZombie()) {
453 Printf(
"Could not open file '%s'!", fileName.Data());
468 for(
Int_t ic=0; ic<nCases; ic++){
504 TLatex* tmax=
new TLatex(0.6,0.8,Form(
"max=%.1f",
fMaxYieldGlob));
507 TLatex* tmin=
new TLatex(0.6,0.72,Form(
"min=%.1f",
fMinYieldGlob));
520 Int_t nBinOrig=hOrig->GetNbinsX();
521 Int_t firstBinOrig=1;
522 Int_t lastBinOrig=nBinOrig;
523 Int_t nBinOrigUsed=nBinOrig;
524 Int_t nBinFinal=nBinOrig/reb;
526 firstBinOrig=firstUse;
527 nBinFinal=(nBinOrig-firstUse+1)/reb;
528 nBinOrigUsed=nBinFinal*reb;
529 lastBinOrig=firstBinOrig+nBinOrigUsed-1;
531 Int_t exc=nBinOrigUsed%reb;
535 lastBinOrig=firstBinOrig+nBinOrigUsed-1;
539 printf(
"Rebin from %d bins to %d bins -- Used bins=%d in range %d-%d\n",nBinOrig,nBinFinal,nBinOrigUsed,firstBinOrig,lastBinOrig);
540 Float_t lowLim=hOrig->GetXaxis()->GetBinLowEdge(firstBinOrig);
541 Float_t hiLim=hOrig->GetXaxis()->GetBinUpEdge(lastBinOrig);
542 TH1F* hRebin=
new TH1F(Form(
"%s-rebin%d_%d",hOrig->GetName(),reb,firstUse),hOrig->GetTitle(),nBinFinal,lowLim,hiLim);
543 Int_t lastSummed=firstBinOrig-1;
544 for(
Int_t iBin=1;iBin<=nBinFinal; iBin++){
547 for(
Int_t iOrigBin=0;iOrigBin<reb;iOrigBin++){
548 sum+=hOrig->GetBinContent(lastSummed+1);
549 sum2+=hOrig->GetBinError(lastSummed+1)*hOrig->GetBinError(lastSummed+1);
552 hRebin->SetBinContent(iBin,sum);
553 hRebin->SetBinError(iBin,TMath::Sqrt(sum2));
561 Int_t minBinSum=h->FindBin(minMass);
562 Int_t maxBinSum=h->FindBin(maxMass);
565 for(
Int_t iMB=minBinSum; iMB<=maxBinSum; iMB++){
567 cntSig+=(h->GetBinContent(iMB)-bkg);
568 cntErr+=(h->GetBinError(iMB)*h->GetBinError(iMB));
571 ecount=TMath::Sqrt(cntErr);
578 TH1F *hCutTmp=(TH1F*)histoToFit->Clone(
"hCutTmp");
579 for(
Int_t ib=1; ib<=hCutTmp->GetNbinsX(); ib++){
580 Double_t xc=hCutTmp->GetBinCenter(ib);
582 hCutTmp->SetBinContent(ib,0.);
583 hCutTmp->SetBinError(ib,0.);
587 hCutTmp->Fit(
"pol2",
"E0",
"",hmin,hmax);
588 TF1* f2=(TF1*)hCutTmp->GetListOfFunctions()->FindObject(
"pol2");
589 TF1* f3=
new TF1(
"myPol3",
"pol3");
590 for(
Int_t i=0; i<3;i++) f3->SetParameter(i,f2->GetParameter(i));
591 hCutTmp->Fit(f3,
"E0",
"",hmin,hmax);
593 for(
Int_t ib=1; ib<=histoToFit->GetNbinsX(); ib++){
594 Double_t xc=hCutTmp->GetBinCenter(ib);
596 quickCount+=(histoToFit->GetBinContent(ib)-f3->Eval(xc));
599 TF1* fSB=
new TF1(
"fSB",
"[0]*1./(TMath::Sqrt(2.*TMath::Pi())*[2])*TMath::Exp(-(x-[1])*(x-[1])/(2.*[2]*[2]))+[3]+[4]*x+[5]*x*x+[6]*x*x*x");
600 fSB->SetParameter(0,quickCount);
601 fSB->SetParameter(1,
fMassD);
603 for(
Int_t j=0; j<4; j++) fSB->SetParameter(j+3,f3->GetParameter(j));
608 fSB->FixParameter(1,
fMassD);
611 fSB->FixParameter(1,
fMassD);
613 histoToFit->Fit(fSB,
"ME0",
"",hmin,hmax);
615 if(fSB->GetParError(0)<0.01*fSB->GetParameter(0))
return kFALSE;
616 if(fSB->GetParError(0)>0.6*fSB->GetParameter(0))
return kFALSE;
void Significance(Double_t nOfSigma, Double_t &significance, Double_t &errsignificance) const
backgournd in (min, max) with error
void Background(Double_t nOfSigma, Double_t &background, Double_t &errbackground) const
signal in (min, max) with error
void SetFixReflOverS(Double_t val, Bool_t fixpar=kTRUE)
TH1F ** fHistoBkgTrial
histo with chi2 from subsamples of trials
Double_t fMaxYieldGlob
minimum yield
Bool_t fUsePowLawBkg
switch for pol5 background
TH1F * fhTemplRefl
histo with bin counts from subsamples of trials
TH1F * fHistoSigmaTrialAll
histo with yield from all trials
TNtuple * fNtupleMultiTrials
Bool_t fSaveBkgVal
switch for FixSigFixMean
Double_t fMinYieldGlob
tree
TH1F * SetTemplateRefl(const TH1F *hTemplRefl)
TH1F * fHistoRawYieldDistAll
flag for drawing fits
Bool_t fUseLinBkg
switch for exponential background
TString format
file names tag, basically the trigger and calorimeter combination
void SetInitialGaussianMean(Double_t mean)
Double_t * fLowLimFitSteps
number of steps on the min. mass for fit
void DrawHere(TVirtualPad *pd, Double_t nsigma=3, Int_t writeFitInfo=1)
Bool_t fUseFixSigFixMean
switch for FixSigFreeMean
void SetBackHighPolDegree(Int_t deg)
Int_t fNumOfFirstBinSteps
void ConfigurenSigmaBinCSteps(Int_t nSteps, Double_t *values)
TString fSuffix
mass of D meson
TH1F * fHistoMeanTrialAll
histo with gauss sigma from all trials
Int_t fNumOfUpLimFitSteps
Bool_t MassFitter(Bool_t draw=kTRUE)
TH1F ** fHistoRawYieldTrial
histo with yield from subsamples of trials
Double_t fMassD
relative variation of the sigma
TF1 * GetBackgroundFullRangeFunc()
Int_t * fRebinSteps
number of rebin steps
TH2F ** fHistoRawYieldTrialBinC
histo with bin counts from subsamples of trials
TH1F ** fHistoSigmaTrial
histo with yield from subsamples of trials
Int_t fNumOfLowLimFitSteps
number of steps in the first bin for rebin
void DrawHistos(TCanvas *cry) const
Double_t GetRawYieldError() const
AliHFMassFitterVAR for the fit of invariant mass distribution of charmed mesons.
void SetUseLikelihoodWithWeightsFit()
TH1F ** fHistoSignifTrial
histo with chi2 from subsamples of trials
TH1F ** fHistoRawYieldDist
histo with bin counts from all trials
Double_t * fnSigmaBinCSteps
number of steps on the bin counting
Int_t fFitOption
name to characterize analysis case
TH1F * fHistoSignifTrialAll
histo with chi2 from all trials
void ConfigureLowLimFitSteps(Int_t nSteps, Double_t *values)
Bool_t fDrawIndividualFits
switch for saving bkg values in nsigma
Double_t GetMeanUncertainty() const
Bool_t fUsePol2Bkg
switch for linear background
Bool_t fUsePol5Bkg
switch for pol4 background
Bool_t fUseFreeS
switch for FixSigDownFreeMean
TH1F ** fHistoRawYieldDistBinC
histo with bkg in mass bin edges from subsamples of trials
Double_t fnSigmaForBkgEval
Double_t GetReducedChiSquare() const
Bool_t fUseFixedMeanFreeS
switch for FreeSigma
void SetReflectionSigmaFactor(Int_t constant)
Bool_t fUseFixSigUpFreeMean
switch for power law background
void SetUseLikelihoodFit()
TH1F * fHistoRawYieldDistBinCAll
histo with bkg in mass bin edges from all trials
Bool_t DoFitWithPol3Bkg(TH1F *histoToFit, Double_t hmin, Double_t hmax, Int_t theCase)
Double_t GetRawYield() const
TH1F * SetTemplateReflections(const TH1F *h, TString option="templ", Double_t minRange=1.72, Double_t maxRange=2.05)
void SetInitialGaussianSigma(Double_t sigma)
change the default value of the mean
TH1F ** fHistoMeanTrial
histo with gauss sigma from subsamples of trials
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TH1F * fHistoBkgInBinEdgesTrialAll
histo with bkg from all trials
std::set< std::string > fInvMassFitSaveAsFormats
TH1F * RebinHisto(TH1D *hOrig, Int_t reb, Int_t firstUse) const
Int_t fNumOfRebinSteps
saves the invariant mass fit canvases in the file formats listed in this vector (if empty...
void BinCount(TH1F *h, TF1 *fB, Int_t rebin, Double_t minMass, Double_t maxMass, Double_t &count, Double_t &ecount) const
TH2F * fHistoRawYieldTrialBinCAll
histo with bin counts from all trials
Double_t fSigmaMCVariation
sigma of D meson peak from MC
Bool_t fUsePol3Bkg
switch for pol2 background
void SetFixGaussianSigma(Double_t sigma=0.012, Bool_t fixpar=kTRUE)
Bool_t fUseFixSigDownFreeMean
switch for FixSigUpFreeMean
Bool_t fUsePol4Bkg
switch for pol3 background
TH1F * fHistoBkgTrialAll
histo with chi2 from all trials
Int_t fNumOfnSigmaBinCSteps
TH1F ** fHistoChi2Trial
histo with gauss mean from subsamples of trials
TH1F * fHistoRawYieldTrialAll
histo with yield from all trials
void ConfigureRebinSteps(Int_t nSteps, Int_t *values)
void ConfigureUpLimFitSteps(Int_t nSteps, Double_t *values)
void SaveToRoot(TString fileName, TString option="recreate") const
Bool_t fUseFixSigFreeMean
switch for FixedMeanFreeS
TH1F ** fHistoBkgInBinEdgesTrial
histo with bkg from subsamples of trials
Double_t GetSigma() const
virtual ~AliHFMultiTrials()
Bool_t fUseExpoBkg
LL or chi2 fit.
Bool_t DoMultiTrials(TH1D *hInvMassHisto, TPad *thePad=0x0)
std::vector< AliHFMassFitterVAR * > fMassFitters
maximum yield
void SetFixGaussianMean(Double_t mean=1.865, Bool_t fixpar=kTRUE)
Double_t * fUpLimFitSteps
number of steps on the max. mass for fit
Float_t fFixRefloS
template of reflection contribution
TH1F * fHistoChi2TrialAll
histo with gauss mean from all trials
Double_t GetSigmaUncertainty() const
Bool_t fUsePowLawTimesExpoBkg
switch for power law background