Skip to content

Commit

Permalink
put checks in particle having sufficient mass possibility to decay to…
Browse files Browse the repository at this point in the history
… its products
  • Loading branch information
dglazier committed May 3, 2022
1 parent 75b861e commit b26f798
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 8 deletions.
13 changes: 13 additions & 0 deletions core/DecayingParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ namespace elSpectro{
}
}

if(Pdg()!=0&&Pdg()!=-2211){//for real particles
Double_t productMasses = 0.0;
for(auto* prod: products){
productMasses+=prod->MinimumMassPossible();
}
auto mmp=MaximumMassPossible();
if(mmp<productMasses){
std::cerr<<"DecayingParticle::PostInit insufficient mass to decay to its products, max mass = "<<mmp<<" while product masses "<<productMasses<<std::endl;
Print();
exit(0);
}
}

if(_decay)_decay->PostInit(info);
if(_decayer)_decayer->PostInit(info);

Expand Down
12 changes: 12 additions & 0 deletions core/DecayingParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ namespace elSpectro{

// virtual const CurrentEventInfo* EventInfo() const {return nullptr;}

double MaximumMassPossible() const noexcept override {

Double_t maxMass=0;
if(MassDistribution()!=nullptr){
maxMass=MassDistribution()->GetMaxX();
}
else if(Pdg()!=-2211)
maxMass = Particle::MaximumMassPossible();

return maxMass;
}

double MinimumMassPossible() const noexcept override {
if(_minMass) return _minMass;

Expand Down
25 changes: 24 additions & 1 deletion core/DistTF1.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DistTF1.h"
#include "TH1.h"
namespace elSpectro{

DistTF1::DistTF1(const TF1& ff):
Expand All @@ -7,5 +8,27 @@ namespace elSpectro{
_min_val = _tf1.GetMinimum();
_tf1.SetNpx(1E4);
}

double DistTF1::GetMinX() const noexcept{

Int_t ib=0;
for(ib=1;ib<_tf1.GetHistogram()->GetNbinsX();ib++){
auto xval= _tf1.GetHistogram()->GetBinCenter(ib);
auto fval=_tf1.Eval(xval);
if(fval>0)break;
}

return _tf1.GetHistogram()->GetBinLowEdge(ib);
}
double DistTF1::GetMaxX() const noexcept{
Int_t ib=0;
for(ib=_tf1.GetHistogram()->GetNbinsX(); ib>0 ;ib--){
auto xval= _tf1.GetHistogram()->GetBinCenter(ib);
auto fval=_tf1.Eval(xval);
if(fval>0)break;
}
double max=_tf1.GetHistogram()->GetBinLowEdge(ib)+_tf1.GetHistogram()->GetBinWidth(ib);
return max;

}

}
4 changes: 2 additions & 2 deletions core/DistTF1.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace elSpectro{

double GetX() const noexcept { return _x;}

double GetMinX() const noexcept final{return _tf1.GetXmin();}
double GetMaxX() const noexcept final{return _tf1.GetXmax();}
double GetMinX() const noexcept final;
double GetMaxX() const noexcept final;

double GetWeightFor(double valX) const {return _tf1.Eval(valX)/_max_val;}
double GetValueFor(double valX,double valY=0) final {return _tf1.Eval(valX);}
Expand Down
22 changes: 21 additions & 1 deletion core/DistTH1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,25 @@ namespace elSpectro{
_min_val = ff.GetMinimum();

}

double DistTH1::GetMinX() const noexcept{

Int_t ib=0;
for(ib=1;ib<_th1.GetNbinsX();ib++){
auto fval=_th1.GetBinContent(ib);
if(fval>0)break;
}

return _th1.GetBinLowEdge(ib);
}
double DistTH1::GetMaxX() const noexcept{
Int_t ib=0;
for(ib=_th1.GetNbinsX(); ib>0 ;ib--){
auto fval=_th1.GetBinContent(ib);
if(fval>0)break;
}

return _th1.GetBinLowEdge(ib)+_th1.GetBinWidth(ib);

}

}
4 changes: 2 additions & 2 deletions core/DistTH1.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace elSpectro{

double GetX() const noexcept { return _x;}

double GetMinX() const noexcept final{return _th1.GetXaxis()->GetXmin();}
double GetMaxX() const noexcept final{return _th1.GetXaxis()->GetXmax();}
double GetMinX() const noexcept final;
double GetMaxX() const noexcept final;

// double GetWeightFor(double valX) {return (static_cast<TH1D*>(&_th1))->GetBinContent((static_cast<TH1D*>(&_th1))->FindBin(valX))/_max_val;}
// double GetWeightFor(double valX) {return (static_cast<TH1D*>(&_th1))->Interpolate(valX)/_max_val;}
Expand Down
3 changes: 3 additions & 0 deletions core/Particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ namespace elSpectro{
virtual double MinimumMassPossible()const noexcept{
return PdgMass();
}
virtual double MaximumMassPossible()const noexcept{
return PdgMass();
}

double MassWeight() const noexcept {
return _massWeight;
Expand Down
9 changes: 7 additions & 2 deletions core/ParticleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ namespace elSpectro{
auto pdg=p->Pdg();
//assign mass distribution if exists
//note maybe this should be just for unstable
if(_massDist.count(pdg)!=0)
if(_massDist.count(pdg)!=0){
p->SetMassDist(_massDist.at(pdg).get());


//Just take minimum mass as pdg value as default in case needed
if(dynamic_cast<DecayingParticle* >(p)!=nullptr)
dynamic_cast<DecayingParticle* >(p)->SetPdgMass(_massDist.at(pdg)->GetMinX());
}

auto dp=dynamic_cast<DecayingParticle* >( p );
auto cp=dynamic_cast<CollidingParticle* >( p );

Expand Down

0 comments on commit b26f798

Please sign in to comment.