14#include "CLHEP/Random/RandGaussZiggurat.h"
15#include "CLHEP/Random/RandFlat.h"
31 return StatusCode::SUCCESS;
36 CLHEP::HepRandomEngine* rndmEngine)
const {
75 for (
auto &[mapId,mapDiode]:chargedDiodes) {
82 int phiGanged = pixelId->
phi_index(gangedID);
85 if (gangedChargeDiode) {
86 bool maskGanged = ((phiGanged > 159) && (phiGanged < 168));
87 bool maskThis = ((phiThis > 159) && (phiThis < 168));
90 if (maskGanged && maskThis) {
91 ATH_MSG_ERROR(
"FEI3SimTool: both ganged pixels are in the mask out region -> BUG!");
97 gangedChargeDiode->
add(mapDiode.totalCharge());
105 i_chargedDiode != chargedDiodes.
orderedEnd(); ++i_chargedDiode) {
119 double th0 = thresholds.
value;
120 double ith0 = thresholds.inTimeValue;
128 const std::vector<float> & totCharges = moduleData->
getTimingIndex(barrel_ec, layerIndex);
129 const std::vector<float> & probArray = moduleData->
getTimingProbability(barrel_ec, layerIndex, moduleIndex);
132 if (selectedTuneYear==2023) { prob =
getProbability(totCharges, probArray, tot); }
133 if (selectedTuneYear==2022) { prob =
getProbability(totCharges, probArray, tot); }
138 double rnd = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);
140 double timeWalk = 0.0;
141 if (
rnd<prob) { timeWalk = 25.0; }
144 if (selectedTuneYear == 2009) {
145 double intimethreshold = (ith0 / th0) *
threshold;
164 double totsig = calibData->
getTotRes(moduleHash, FE, tot);
165 int nToT =
static_cast<int>(CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot, totsig));
171 if (nToT <= moduleData->getToTThreshold(barrel_ec, layerIndex)) {
192 int flag = diode.
flag();
193 int bunch = (flag >> 8) & 0xff;
205 static constexpr int smallHitThreshold{7};
206 bool smallHitChk =
false;
207 if (nToT <= smallHitThreshold) {
219 CLHEP::HepRandomEngine* rndmEngine)
const {
221 double myTimeWalkEff = 0.;
222 double overdrive = intimethreshold -
threshold;
230 double p1 = 20. / std::log(intimethreshold / overdrive);
231 double p0 = p1 * std::log(1. -
threshold / 100000.);
233 double myTimeWalk = -p0 - p1 * std::log(1. -
threshold / totalCharge.
charge());
235 myTimeWalkEff = myTimeWalk + myTimeWalk * 0.2 * CLHEP::RandGaussZiggurat::shoot(rndmEngine);
237 double randomJitter = CLHEP::RandFlat::shoot(rndmEngine, - limit, limit);
242 double timing =
m_timeOffset + myTimeWalkEff + randomJitter + G4Time;
243 BCID =
static_cast<int>(std::floor(timing /
m_bunchSpace));
250 auto pCategory = std::upper_bound(bounds.begin(), bounds.end(),val);
251 if (pCategory == bounds.end())
return 0.0;
252 auto idx = std::distance(bounds.begin(), pCategory);
#define ATH_CHECK
Evaluate an expression and check for errors.
double charge(const T &p)
Structs for holding charge calibration parameterisation and data.
This is an Identifier helper class for the Pixel subdetector.
InDetRawDataCollection< PixelRDORawData > PixelRDO_Collection
SiChargedDiodeOrderedSet::iterator SiChargedDiodeOrderedIterator
value_type push_back(value_type pElem)
This is a "hash" representation of an Identifier.
Class used to describe the design of a module (diode segmentation and readout scheme).
PixelReadoutTechnology getReadoutTechnology() const
Identifier for the strip or pixel cell.
bool isValid() const
Test if its in a valid state.
Class to hold geometrical description of a silicon detector element.
SiCellId gangedCell(const SiCellId &cellId) const
If cell is ganged return the id of the other cell which shares the readout for this cell,...
Identifier for the strip or pixel readout cell.
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const =0
SiCellId from Identifier.
virtual Identifier identify() const override final
identifier of this detector element (inline)
virtual Identifier identifierFromCellId(const SiCellId &cellId) const =0
Identifier <-> SiCellId (ie strip number or pixel eta_index,phi_index) Identifier from SiCellId (ie s...
PixelChargeCalib::Thresholds getThresholds(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE) const
float getToT(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float Q) const
float getTotRes(unsigned int moduleHash, unsigned int FE, float Q) const
This is an Identifier helper class for the Pixel subdetector.
int layer_disk(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
int eta_module(const Identifier &id) const
int phi_index(const Identifier &id) const
int getFEI3Latency(int barrel_ec, int layer) const
int getFEI3TimingSimTune(int barrel_ec, int layer) const
std::vector< float > getTimingProbability(int barrel_ec, int layer, int eta) const
std::vector< float > getTimingIndex(int barrel_ec, int layer) const
double getCrossTalk(int barrel_ec, int layer) const
virtual Identifier identify() const override final
SiChargedDiodeOrderedIterator orderedEnd()
SiChargedDiodeOrderedIterator orderedBegin()
SiChargedDiode * find(const InDetDD::SiCellId &siId)
Identifier getId(const InDetDD::SiCellId &id) const
const InDetDD::SolidStateDetectorElementBase * element() const
const InDetDD::SiCellId & diode() const
const SiTotalCharge & totalCharge() const
void add(const SiCharge &charge)
const InDetDD::SiReadoutCellId & getReadoutCell() const
static bool isMaskOut(SiChargedDiode &chDiode)
static void SetBunch(SiChargedDiode &chDiode, int bunch, MsgStream *log=nullptr)
static void disabled(SiChargedDiode &chDiode, bool flag, bool mask=false)
static void maskOut(SiChargedDiode &chDiode, bool flag)
static void belowThreshold(SiChargedDiode &chDiode, bool flag, bool mask=false)
static bool isDisabled(SiChargedDiode &chDiode)
constexpr uint32_t invalidFrontEnd
void randomDisable(SiChargedDiodeCollection &chargedDiodes, const PixelModuleData *moduleData, CLHEP::HepRandomEngine *rndmEngine)
void crossTalk(double crossTalk, SiChargedDiodeCollection &chargedDiodes)
void thermalNoise(double thermalNoise, SiChargedDiodeCollection &chargedDiodes, CLHEP::HepRandomEngine *rndmEngine)
double randomThreshold(const PixelChargeCalib::Thresholds &t, CLHEP::HepRandomEngine *pEngine)
void randomNoise(SiChargedDiodeCollection &chargedDiodes, const PixelModuleData *moduleData, int nBcid, const PixelChargeCalibCondData *chargeCalibData, CLHEP::HepRandomEngine *rndmEngine, InDetDD::IPixelReadoutManager *pixelReadout)
double getG4Time(const SiTotalCharge &totalCharge)