5#include "CLHEP/Random/RandFlat.h"
25 if (Ekin_bin >= 1 && Ekin_bin <=
n_bins())
31 for (
int id :
pdgid()) {
65 int id, std::vector<float> prob) {
68 ATH_MSG_ERROR(
"TFCSEnergyBinParametrization::set_pdgid_Ekin_bin_"
69 "probability(): size of vectors does not match! in.size()="
75 for (
int iEbin = 0; iEbin <=
n_bins(); ++iEbin){
80 ATH_MSG_ERROR(
"TFCSEnergyBinParametrization::set_pdgid_Ekin_bin_probability: ptot is zero.");
83 for (
int iEbin = 0; iEbin <=
n_bins(); ++iEbin) {
84 p += prob[iEbin] / ptot;
90 int id, TFile *
file, std::string prob_object_name) {
95 dynamic_cast<TVectorF *
>(gDirectory->Get(prob_object_name.c_str()));
97 std::vector<float> prob;
99 if (probFromFile ==
nullptr) {
100 ATH_MSG_INFO(
"TFCSEnergyBinParametrization::load_pdgid_Ekin_bin_"
101 "probability_from_file(): "
103 <<
" is null. Using equal PCA probabilities.");
109 auto size =
static_cast<size_t>(probFromFile->GetNoElements());
112 "TFCSEnergyBinParametrization::load_pdgid_Ekin_bin_probability_from_"
113 "file(): size of prob array does not match! in.size()="
118 const float *probArray = probFromFile->GetMatrixArray();
119 for (
size_t i = 0; i <
size; i++) {
120 prob.push_back(probArray[i]);
125 for (
int iEbin = 0; iEbin <=
n_bins(); ++iEbin){
130 ATH_MSG_ERROR(
"TFCSEnergyBinParametrization::load_pdgid_Ekin_bin_probability_from_file: ptot is zero");
133 for (
int iEbin = 0; iEbin <=
n_bins(); ++iEbin) {
134 p += prob[iEbin] / ptot;
143 bool shortprint = opt.Index(
"short") >= 0;
144 bool longprint =
msgLvl(MSG::DEBUG) || (
msgLvl(MSG::INFO) && !shortprint);
145 TString optprint = opt;
146 optprint.ReplaceAll(
"short",
"");
149 for (std::set<int>::iterator it =
pdgid().begin(); it !=
pdgid().end();
151 ATH_MSG(INFO) << optprint <<
" PDGID=" << *it <<
" : ";
153 for (
int iEbin = 0; iEbin <=
n_bins(); ++iEbin) {
157 ATH_MSG(INFO) <<
"b" << iEbin <<
"="
158 << (mapit->second[iEbin] - p) / mapit->second.back() * 100
160 p = mapit->second[iEbin];
174 const int truth_pdgid = truth->
pdgid();
183 "TFCSEnergyBinParametrization::simulate(): cannot simulate pdgid="
188 const float searchRand = CLHEP::RandFlat::shoot(simulstate.
randomEngine());
191 TMath::BinarySearch(
n_bins() + 1, Ebin_probability.data(), searchRand) +
194 ATH_MSG_WARNING(
"TFCSEnergyBinParametrization::simulate(): chosenBin<0 "
195 "(will use chosenBin=0)");
196 std::string array =
"";
197 for (
const auto &prob : Ebin_probability) {
202 <<
" rnd=" << searchRand <<
" array=" << array);
204 }
else if (chosenBin >
n_bins()) {
206 "chosenBin>n_bins() (will use chosenBin=n_bins())");
207 std::string array =
"";
208 for (
const auto &prob : Ebin_probability) {
213 <<
" rnd=" << searchRand <<
" array=" << array);
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
virtual void set_pdgid(int id) override
virtual void clear_pdgid() override
int m_number_of_Ekin_bins
virtual void set_pdgid_Ekin_bin_probability(int id, std::vector< float > prob)
set_pdgid_Ekin_bin_probability(): format of probability should be a vector of float with probability ...
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
TFCSEnergyBinParametrization(const char *name=nullptr, const char *title=nullptr)
virtual int n_bins() const override
virtual bool load_pdgid_Ekin_bin_probability_from_file(int id, TFile *file, std::string prob_object_name)
virtual bool is_match_Ekin_bin(int Ekin_bin) const override
virtual void add_pdgid(int id) override
std::map< int, std::vector< float > > m_pdgid_Ebin_probability
void Print(Option_t *option="") const override
TFCSEnergyParametrization(const char *name=nullptr, const char *title=nullptr)
virtual unsigned int size() const
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
void Print(Option_t *option="") const
Print object information.
virtual void add_pdgid(int id)
const std::set< int > & pdgid() const override
virtual void clear_pdgid()
virtual bool is_match_pdgid(int id) const override
virtual void set_pdgid(int id)
CLHEP::HepRandomEngine * randomEngine()