14#include "CLHEP/Random/RandGaussZiggurat.h"
15#include "CLHEP/Random/RandFlat.h"
33 return StatusCode::SUCCESS;
38 return StatusCode::SUCCESS;
42 CLHEP::HepRandomEngine* rndmEngine)
const {
62 const EventContext& ctx{Gaudi::Hive::currentContext()};
82 for (
auto &[mapId,mapDiode]:chargedDiodes) {
89 int phiGanged = pixelId->
phi_index(gangedID);
92 if (gangedChargeDiode) {
93 bool maskGanged = ((phiGanged > 159) && (phiGanged < 168));
94 bool maskThis = ((phiThis > 159) && (phiThis < 168));
97 if (maskGanged && maskThis) {
98 ATH_MSG_ERROR(
"FEI3SimTool: both ganged pixels are in the mask out region -> BUG!");
104 gangedChargeDiode->
add(mapDiode.totalCharge());
112 i_chargedDiode != chargedDiodes.
orderedEnd(); ++i_chargedDiode) {
126 double th0 = thresholds.
value;
127 double ith0 = thresholds.inTimeValue;
135 const std::vector<float> & totCharges = moduleData->
getTimingIndex(barrel_ec, layerIndex);
136 const std::vector<float> & probArray = moduleData->
getTimingProbability(barrel_ec, layerIndex, moduleIndex);
139 if (selectedTuneYear==2023) { prob =
getProbability(totCharges, probArray, tot); }
140 if (selectedTuneYear==2022) { prob =
getProbability(totCharges, probArray, tot); }
145 double rnd = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);
147 double timeWalk = 0.0;
148 if (
rnd<prob) { timeWalk = 25.0; }
151 if (selectedTuneYear == 2009) {
152 double intimethreshold = (ith0 / th0) *
threshold;
171 double totsig = calibData->
getTotRes(moduleHash, FE, tot);
172 int nToT =
static_cast<int>(CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot, totsig));
178 if (nToT <= moduleData->getToTThreshold(barrel_ec, layerIndex)) {
199 int flag = diode.
flag();
200 int bunch = (flag >> 8) & 0xff;
212 static constexpr int smallHitThreshold{7};
213 bool smallHitChk =
false;
214 if (nToT <= smallHitThreshold) {
226 CLHEP::HepRandomEngine* rndmEngine)
const {
228 double myTimeWalkEff = 0.;
229 double overdrive = intimethreshold -
threshold;
237 double p1 = 20. / std::log(intimethreshold / overdrive);
238 double p0 = p1 * std::log(1. -
threshold / 100000.);
240 double myTimeWalk = -p0 - p1 * std::log(1. -
threshold / totalCharge.
charge());
242 myTimeWalkEff = myTimeWalk + myTimeWalk * 0.2 * CLHEP::RandGaussZiggurat::shoot(rndmEngine);
244 double randomJitter = CLHEP::RandFlat::shoot(rndmEngine, - limit, limit);
249 double timing =
m_timeOffset + myTimeWalkEff + randomJitter + G4Time;
250 BCID =
static_cast<int>(std::floor(timing /
m_bunchSpace));
257 auto pCategory = std::upper_bound(bounds.begin(), bounds.end(),val);
258 if (pCategory == bounds.end())
return 0.0;
259 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)