using namespace std;
#include <sstream>
#include <iostream>
#include <iomanip>
#include "PBreitWigner.h"
ClassImp(PBreitWigner)
PBreitWigner::PBreitWigner() {
};
PBreitWigner::PBreitWigner(const Char_t *id, const Char_t *de, Int_t key) :
PHadronModel(id, de, key) {
width_model = NULL;
mr = makeStaticData()->GetParticleMassByKey(primary_key);
};
PDistribution *PBreitWigner::Clone(const char *) const {
return new PBreitWigner((const PBreitWigner &)* this);
};
Bool_t PBreitWigner::SampleMass(Double_t *mass, Int_t *didx) {
if (didx) {
if (didx_option != didx[0]) {
didx_option = didx[0];
SetParameter(1, didx_option);
}
} else {
if (didx_option != -1) {
didx_option = -1;
SetParameter(1, didx_option);
}
}
mass[0] = this->GetRandom();
return kTRUE;
}
Double_t PBreitWigner::GetWeight(Double_t *mass, Int_t *didx) {
double m = mass[0];
if ((m < GetMin()) || (m > GetMax())) return 0.;
double m2 = m*m,
mm = mr*mr-m2;
int didx_local = -1;
if (didx) didx_local = didx[0];
global_weight_scaling = makeDynamicData()->GetParticleScalingFactor(is_pid);
double wmt = 1.;
if (!GetWidth(m, &width)) {
Warning("GetWeight", "GetWidth failed");
return -1;
}
double g = width,
g2 = g*g;
double partial_width;
if (didx_local >= 0) {
if (!GetWidth(m, &partial_width, didx_local)) {
Warning("GetWeight", "GetWidth failed");
return -1;
}
if (width_model) {
width_model->GetWidth(m, &partial_width, didx_local);
}
} else
partial_width = width;
Double_t w = global_weight_scaling*wmt*m2*partial_width/(mm*mm+m2*g2);
return w;
}