// -*- C++ -*- // $Id: PuncturedSmearedExp.cc,v 1.4 2010/06/16 18:22:01 garren Exp $ #include "CLHEP/GenericFunctions/PuncturedSmearedExp.hh" #include #include namespace Genfun { FUNCTION_OBJECT_IMP(PuncturedSmearedExp) PuncturedSmearedExp::PuncturedSmearedExp() : _lifetime ("Lifetime", 1.0, 0.0), // Bounded from below by zero, by default _sigma ("Sigma", 1.0, 0.0) // Bounded from below by zero, by default { } PuncturedSmearedExp::PuncturedSmearedExp(const PuncturedSmearedExp & right): _lifetime (right._lifetime), _sigma (right._sigma), _punctures (right._punctures) { } void PuncturedSmearedExp::puncture(double min, double max) { std::ostringstream mn, mx; mn << "Min_" << _punctures.size()/2; mx << "Max_" << _punctures.size()/2; _punctures.push_back(Parameter(mn.str(), min, 0.0, 10.0)); _punctures.push_back(Parameter(mx.str(), max, 0.0, 10.0)); } Parameter & PuncturedSmearedExp::min(unsigned int i) { return _punctures[2*i]; } const Parameter & PuncturedSmearedExp::min(unsigned int i) const { return _punctures[2*i]; } Parameter & PuncturedSmearedExp::max(unsigned int i) { return _punctures[2*i+1]; } const Parameter & PuncturedSmearedExp::max(unsigned int i) const { return _punctures[2*i+1]; } PuncturedSmearedExp::~PuncturedSmearedExp() { } Parameter & PuncturedSmearedExp::lifetime() { return _lifetime; } const Parameter & PuncturedSmearedExp::lifetime() const { return _lifetime; } Parameter & PuncturedSmearedExp::sigma() { return _sigma; } const Parameter & PuncturedSmearedExp::sigma() const { return _sigma; } double PuncturedSmearedExp::operator() (double argument) const { // Fetch the paramters. This operator does not convolve numerically. static const double sqrtTwo = sqrt(2.0); double sigma = _sigma.getValue(); double tau = _lifetime.getValue(); double x = argument; // Copy: std::vector punctures(_punctures.size()); for (size_t i=0;i<_punctures.size();i++) punctures[i]=_punctures[i].getValue(); // Overlap elimination: bool overlap=true; while (overlap) { overlap=false; for (size_t i=0;imin1 && max1>min2) || (min1>min2 && max2::iterator t0=punctures.begin()+2*j, t1=t0+2; punctures.erase(t0,t1); overlap=true; break; } } if (overlap) break; } } double expG=0,norm=0; for (size_t i=0;i