35 m_number_of_hits_simul(nullptr) {}
56 TString(
"hit chain for ") +
72 const Chain_t::value_type &value) {
74 chain().push_back(value);
77 chain().insert(it, value);
107 if (param !=
nullptr) {
108 if (!param->InheritsFrom(TFCSLateralShapeParametrizationHitBase::Class())) {
109 ATH_MSG_ERROR(
"Wrong class type " << param->IsA()->GetName());
118 m_chain.at(ind - 1) = param_typed;
136 int n = hitsim->get_number_of_hits(simulstate, truth, extrapol);
145 float weight = hitsim->getMinWeight();
154 float weight = hitsim->getMaxWeight();
168 simulstate.
setAuxInfo<
int>(
"FCSHitChainNHits"_FCShash, nhits);
174 return simulstate.
E(sample);
175 const float maxWeight =
179 return simulstate.
E(sample) /
183 return simulstate.
E(sample) /
192 simulstate, truth, extrapol);
197 double sigma2 = hitsim->get_sigma2_fluctuation(simulstate, truth, extrapol);
206 MSG::Level
level)
const {
208 reset->setLevel(
level);
221 for (
auto hititr =
m_chain.begin(); hititr != initloopend; ++hititr) {
228 ATH_MSG_ERROR(
"TFCSLateralShapeParametrizationHitChain::simulate(): "
229 "simulate_hit init call failed");
240 MSG::Level old_level =
level();
255 const float Elayer = simulstate.
E(cs);
260 const float Ehit =
get_E_hit(simulstate, truth, extrapol);
261 if (Ehit * Elayer <= 0) {
262 ATH_MSG_ERROR(
"TFCSLateralShapeParametrizationHitChain::simulate(): Ehit "
263 "and Elayer have different sign! Ehit="
264 << Ehit <<
" Elayer=" << Elayer);
271 int nhit_signed = TMath::Nint(Elayer / Ehit);
274 unsigned int nhit = (
unsigned int)nhit_signed;
280 ATH_MSG_DEBUG(
"E(" << cs <<
")=" << simulstate.
E(cs) <<
" #hits~" << nhit);
288 bool our_chainA =
false;
289 if (cs > 0 && cs < 8 && cs != 4)
291 if (nhit >
MIN_GPU_HITS && our_chainA && simulstate.get_geold() !=
nullptr) {
293 "running FastCaloSim in GPU, nhits = " << nhit <<
" ; Ehit = " << Ehit);
307 args.pdgId = truth->
pdgid();
312 args.rd4h = simulstate.get_gpu_rand();
316 bool reweight =
false;
326 ->is_phi_symmetric();
332 if (ichn == 2 &&
m_chain.size() == 4) {
339 if ((ichn == 2 &&
m_chain.size() == 3) ||
340 (ichn == 3 &&
m_chain.size() == 4)) {
354 for (
unsigned int ii = 0; ii < args.ct; ++ii) {
357 gld->
index2cell(args.hitcells_E_h[ii].cellid);
359 m_geo->getDDE(cs, cellele->
eta(), cellele->
phi());
360 sumEhit += args.hitcells_E_h[ii].energy;
362 if (std::abs(sumEhit) > std::abs(Elayer))
363 simulstate.
deposit(cell_h, args.hitcells_E_h[ii].energy);
374 int retry_warning = 1;
388 for (
auto hititr = hitloopstart; hititr !=
m_chain.end(); ++hititr) {
405 retry_warning = retry >> 1;
406 if (retry_warning < 1)
416 if (((hit.
idx() == 20 * nhit) || (hit.
idx() == 100 * nhit)) && hit.
idx() >= 100) {
418 "TFCSLateralShapeParametrizationHitChain::simulate(): Iterated "
419 << hit.
idx() <<
" times, expected " << nhit <<
" times. Deposited E("
420 << cs <<
")=" << sumEhit <<
" expected E=" << Elayer);
422 if (hit.
idx() >= 1000 * nhit && hit.
idx() >= 1000) {
423 ATH_MSG_DEBUG(
"TFCSLateralShapeParametrizationHitChain::simulate():"
424 " Aborting hit chain, iterated "
425 << hit.
idx() <<
" times, expected " << nhit
426 <<
" times. Deposited E(" << cs <<
")=" << sumEhit
427 <<
" expected E=" << Elayer <<
", caused by:");
432 if (ifail >= retry) {
433 ATH_MSG_ERROR(
"TFCSLateralShapeParametrizationHitChain::simulate(): "
434 "simulate_hit call failed after "
435 << ifail <<
"/" << retry
436 <<
"retries, total fails=" << itotalfail);
441 if (ifail >= retry_warning) {
443 " retry simulate_hit calls "
444 << ifail <<
"/" << retry
445 <<
", total fails=" << itotalfail);
470 if (simulstate.
hasAuxInfo(
"FCSHitChainEnergySum"_FCShash) && hit.
idx() > 1) {
471 sumEhit = simulstate.
getAuxInfo<
float>(
"FCSHitChainEnergySum"_FCShash);
476 simulstate.
setAuxInfo<
float>(
"FCSHitChainEnergySum"_FCShash, sumEhit);
479 return (std::abs(sumEhit) >= std::abs(Elayer));
485 bool shortprint = opt.Index(
"short") >= 0;
486 bool longprint =
msgLvl(MSG::DEBUG) || (
msgLvl(MSG::INFO) && !shortprint);
487 TString optprint = opt;
488 optprint.ReplaceAll(
"short",
"");
492 ATH_MSG_INFO(optprint <<
"#:Number of hits simulation:");
498 for (
auto hititr =
m_chain.begin(); hititr != hitloopstart; ++hititr) {
500 hitsim->
Print(opt +
"> ");
505 for (
auto hititr = hitloopstart; hititr !=
m_chain.end(); ++hititr) {
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ATLAS-specific HepMC functions.
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
CUDA_HOSTDEV float phi() const
cell phi
CUDA_HOSTDEV float eta() const
cell eta
This class groups all DetDescr information related to a CaloCell.
unsigned long get_ncells() const
GeoGpu * get_geoPtr() const
const CaloDetDescrElement_Gpu * index2cell(unsigned long index)
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
MSG::Level level() const
Retrieve output level.
long unsigned int & idx()
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol)
simulated one hit position with some energy.
virtual float get_sigma2_fluctuation(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
Give the effective size sigma^2 of the fluctuations that should be generated.
const Chain_t & chain() const
virtual float getMaxWeight() const
void push_back_init(const Chain_t::value_type &value)
virtual const TFCSParametrizationBase * operator[](unsigned int ind) const override
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
TFCSLateralShapeParametrizationHitChain(const char *name=nullptr, const char *title=nullptr)
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
virtual unsigned int size() const override
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
unsigned int get_nr_of_init() const
virtual bool check_all_hits_simulated(TFCSLateralShapeParametrizationHitBase::Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, bool success) const
void Print(Option_t *option="") const override
Do not persistify!
virtual float getMinWeight() const
Get minimum and maximum value of weight for hit energy reweighting.
TFCSLateralShapeParametrizationHitBase * m_number_of_hits_simul
virtual void set_daughter(unsigned int ind, TFCSParametrizationBase *param) override
Some derived classes have daughter instances of TFCSParametrizationBase objects The set_daughter meth...
virtual FCSReturnCode init_hit(TFCSLateralShapeParametrizationHitBase::Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
static constexpr float s_max_sigma2_fluctuation
virtual float get_E_hit(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
Get hit energy from layer energy and number of hits.
void PropagateMSGLevel(MSG::Level level) const
virtual int get_number_of_hits(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
Call get_number_of_hits() only once, as it could contain a random number.
void Print(Option_t *option="") const override
TFCSLateralShapeParametrization(const char *name=nullptr, const char *title=nullptr)
virtual void set_pdgid_Ekin_eta_Ekin_bin_calosample(const TFCSLateralShapeParametrization &ref)
virtual void set_geometry(ICaloGeometry *geo)
Method to set the geometry access pointer.
TFCSParametrizationBase(const char *name=nullptr, const char *title=nullptr)
bool hasAuxInfo(std::uint32_t index) const
const T getAuxInfo(std::uint32_t index) const
void deposit(const CaloDetDescrElement *cellele, float E)
void setAuxInfo(std::uint32_t index, const T &val)
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
void simulate_hits(float, int, Chain0_Args &, bool)
double charge(const T &p)