15 #include "StMessMgr.h"
17 #include "StGlauberUtilities/StGlauberUtilities.h"
18 #include "StNegativeBinomial.h"
26 const Double_t efficiency, const Double_t triggerbias, const Bool_t isConstEfficiency)
27 : mEfficiency(efficiency), mTriggerBias(triggerbias), mNpp(npp), mK(k), mX(x), mIsConstEfficiency(isConstEfficiency)
29 LOG_INFO << Form(
"StNegativeBinomial (npp, k, x, eff, trig. bias) = (%1.3f, %1.3f, %1.3f, %1.3f, %1.3f)",
30 mNpp, mK, mX, mEfficiency, mTriggerBias)
33 if(mIsConstEfficiency){
34 LOG_INFO <<
"StNegativeBinomial Use constant efficiency" << endm;
37 LOG_INFO <<
"StNegativeBinomial Use multiplicity dependent efficiency" << endm;
52 void StNegativeBinomial::InitHistogram()
54 const Int_t nbin = 100 ;
61 mhNbd =
new TH1D(Form(
"mhNbd_%d", mCounter++),
"", nbin, 0, nbin);
64 for(Int_t i=0;i<nbin;i++){
65 mhNbd->SetBinContent(i+1, GetNegativeBinomial(i));
88 return (mX==0.0) ? npart : 0.5*(1.0-mX)*npart + mX*ncoll ;
98 const Double_t nchSampled = nchPP ;
101 const Int_t nchInt = TMath::Nint(nchSampled);
103 for(Int_t ich=0; ich<nchInt; ich++){
104 multIdeal += (Int_t)mhNbd->GetRandom();
108 const Double_t efficiency = (mIsConstEfficiency) ? mEfficiency :
GetEfficiency(multIdeal) ;
112 for(Int_t im=0; im<2*multIdeal; im++){
113 if( StGlauberUtilities::instance()->
GetUniform2() <= efficiency ){
118 if ( mTriggerBias == 1.0 )
return mult ;
120 const Int_t nmult = mult ;
122 for(Int_t im=0; im<nmult; im++){
123 if( StGlauberUtilities::instance()->
GetUniform() <= mTriggerBias ){
133 const Double_t weight)
const
137 const Int_t nch = TMath::Nint(nchPP * mTriggerBias) ;
142 const Double_t efficiency = (mIsConstEfficiency) ? mEfficiency :
GetEfficiency(nch) ;
143 const Int_t nchSampled = TMath::Nint(nch * efficiency) ;
145 const Int_t nbin = 1000 ;
146 TH1* h =
new TH1D(
"hmultTmp",
"", nbin, 0, static_cast<Double_t>(nbin));
148 for(Int_t ix=0; ix<nbin; ix++){
150 const Double_t probability = GetNegativeBinomial(ix, nchSampled) ;
153 if(probability>0.0 && probability<DBL_MAX){
154 h->Fill(ix+0.5, probability*weight);
162 Double_t StNegativeBinomial::GetNegativeBinomial(
const Int_t n)
const
164 const Double_t Const = TMath::Exp( TMath::LnGamma(n+mK) - TMath::LnGamma(n+1) - TMath::LnGamma(mK) );
165 const Double_t term = n * TMath::Log(mNpp/mK) - (n+mK) * TMath::Log(mNpp/mK+1.0) ;
167 return Const * TMath::Exp(term);
171 Double_t StNegativeBinomial::GetNegativeBinomial(
const Int_t n,
const Double_t m)
const
175 const Double_t Const = TMath::Exp( TMath::LnGamma(n+mK*m) - TMath::LnGamma(n+1) - TMath::LnGamma(mK*m) );
176 const Double_t term = n * TMath::Log(mNpp/mK) - (n+mK*m) * TMath::Log(mNpp/mK+1.0) ;
178 return Const * TMath::Exp(term);
185 if( mIsConstEfficiency ){
186 Error(
"StNegativeBinomial::GetEfficiency",
"Something is wrong, supposed to be constant efficiency. abort");
191 if ( mult < 0 )
return mEfficiency ;
196 const Double_t eff0 = 0.98 ;
198 const Double_t d = mEfficiency ;
200 return eff0 * (1.0 - mult * d/540.0) ;
207 if(mhNbd) mhNbd->Draw() ;
void SetParameters(const Double_t npp, const Double_t k, const Double_t x=-1.0)
Get NBD(npp*m, k*m; n)
void DrawNbd() const
Get flag for efficiency.
Double_t GetUniform() const
Get uniform distribution in 0 < x < 1.
Double_t GetUniform2() const
Double_t GetEfficiency() const
Get x parameter.
virtual ~StNegativeBinomial()
Default destructor.
Int_t GetMultiplicity(const Double_t npart, const Double_t ncoll) const
Get multiplcity by convoluting NBD.
Double_t GetTwoComponentMultiplicity(const Double_t npart, const Double_t ncoll) const
(1-x)*npart/2 + x*ncoll