16#include "CLHEP/Random/RandGaussZiggurat.h"
17#include "CLHEP/Random/RandFlat.h"
30 constexpr std::array<double,17> sigmas{0.0,0.50,0.50,0.50,0.50,0.50,0.60,0.60,0.60,0.60,0.65,0.70,0.75,0.80,0.80,0.80,0.80};
31 return sigmas.at(tot);
49 return StatusCode::SUCCESS;
54 return StatusCode::SUCCESS;
58 CLHEP::HepRandomEngine* rndmEngine)
const {
77 const EventContext& ctx{Gaudi::Hive::currentContext()};
83 int maxFEI4SmallHit = 2;
86 std::vector<std::unique_ptr<Pixel1RawData>> p_rdo_small_fei4;
87 int nSmallHitsFEI4 = 0;
88 std::vector<int> row, col;
91 std::vector<std::vector<int> > FEI4Map(maxRow + 16, std::vector<int>(maxCol + 16));
108 i_chargedDiode != chargedDiodes.
orderedEnd(); ++i_chargedDiode) {
116 double corrQ = 1.11 *
117 (1.0 - (-7.09 * 1000.0) / (23.72 * 1000.0 +
charge) + (-0.22 * 1000.0) /
118 (-0.42 * 1000.0 +
charge));
157 double totsig = calibData->
getTotRes(moduleHash, FE, tot);
158 int nToT =
static_cast<int>(CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot, totsig));
162 double totIBLsig = getSigma(nToT);
164 if (CLHEP::RandFlat::shoot(rndmEngine,0.0,1.0)<std::exp(-0.5/totIBLsig/totIBLsig)) {
165 if (CLHEP::RandFlat::shoot(rndmEngine,0.0,1.0)<0.5) { nToT--; }
174 if (nToT == 2 && maxFEI4SmallHit == 2) {
178 nToT=std::clamp(nToT, 1, overflowToT);
180 if (nToT <= moduleData->getToTThreshold(barrel_ec, layerIndex)) {
197 int flag = diode.
flag();
198 int bunch = (flag >> 8) & 0xff;
205 if (iicol >= maxCol) {
206 iicol = iicol - maxCol;
211 auto p_rdo = std::make_unique<Pixel1RawData>(id_readout, nToT, bunch, 0, bunch);
212 if (nToT > maxFEI4SmallHit) {
213 rdoCollection.
push_back(p_rdo.release());
214 FEI4Map[iirow][iicol] = 2;
216 p_rdo_small_fei4.push_back(std::move(p_rdo));
217 row.push_back(iirow);
218 col.push_back(iicol);
219 FEI4Map[iirow][iicol] = 1;
226 if (nSmallHitsFEI4 > 0) {
227 bool recorded =
false;
230 for (
int ismall = 0; ismall < nSmallHitsFEI4; ismall++) {
231 int rowPDR = row[ismall] / 2;
232 int colPDR = col[ismall] / 2;
233 for (
int rowBigHit = 2 * rowPDR; rowBigHit != 2 * rowPDR + 2 && rowBigHit < maxRow; ++rowBigHit) {
234 for (
int colBigHit = 2 * colPDR; colBigHit != 2 * colPDR + 2 && colBigHit < maxCol; ++colBigHit) {
236 "rowBig = " << rowBigHit <<
" colBig = " << colBigHit <<
" Map Content = " <<
237 FEI4Map[rowBigHit][colBigHit]);
238 if (FEI4Map[rowBigHit][colBigHit] == 2 && !recorded) {
246 if (!recorded && row[ismall] < maxRow - 1) {
247 if (FEI4Map[row[ismall] + 1][col[ismall]] == 2) {
252 if (!recorded && row[ismall] != 0) {
253 if (FEI4Map[row[ismall] - 1][col[ismall]] == 2) {
#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
int rowsPerCircuit() const
Number of cell rows per circuit:
int columnsPerCircuit() const
Number of cell columns per circuit:
int phiIndex() const
Get phi index. Equivalent to strip().
int etaIndex() const
Get eta index.
Identifier for the strip or pixel readout cell.
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...
constexpr int getFEI4OverflowToT() const
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
double getCrossTalk(int barrel_ec, int layer) const
virtual Identifier identify() const override final
SiChargedDiodeOrderedIterator orderedEnd()
SiChargedDiodeOrderedIterator orderedBegin()
Identifier getId(const InDetDD::SiCellId &id) const
const InDetDD::SolidStateDetectorElementBase * element() const
const InDetDD::SiCellId & diode() const
const SiTotalCharge & totalCharge() const
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 belowThreshold(SiChargedDiode &chDiode, bool flag, bool mask=false)
static bool isDisabled(SiChargedDiode &chDiode)
static std::string release
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)