11 #include <top/dbobjects/TOPNominalTTS.h>
12 #include <framework/logging/Logger.h>
24 void TOPNominalTTS::appendGaussian(
double norm,
double mean,
double sigma)
27 B2ERROR(
"TOPNominalTTS::appendGaussian: normalization is non-positive number");
34 m_tts.push_back(gauss);
38 double TOPNominalTTS::normalize()
41 for (
const auto& tts : m_tts) sum += tts.fraction;
42 if (sum == 0)
return 0;
43 for (
auto& tts : m_tts) tts.fraction /= sum;
48 double TOPNominalTTS::generateTTS()
const
50 double prob = gRandom->Rndm();
52 for (
const auto& tts : m_tts) {
55 return gRandom->Gaus(tts.position, tts.sigma);
62 bool TOPNominalTTS::isConsistent()
const
64 if (m_tts.empty())
return false;
65 if (!m_normalized)
return false;
70 void TOPNominalTTS::print(
const std::string& title)
const
72 TOPGeoBase::printUnderlined(title);
74 cout <<
" -> vector is empty!" << endl;
77 cout <<
" PMT type: " << m_type << endl;
80 for (
const auto& tts : m_tts) {
82 cout <<
" Gaussian " << i <<
": ";
83 cout << tts.fraction <<
", ";
84 cout << tts.position <<
" ns, ";
85 cout << tts.sigma <<
" ns" << endl;
87 if (!m_normalized) cout <<
" warning: fractions not normalized" << endl;