9#include "CLHEP/Random/RandGaussZiggurat.h"
10#include "CLHEP/Random/RandFlat.h"
12 constexpr double percentage(
unsigned int numerator,
unsigned int denom) {
13 return 100. * numerator / std::max(denom, 1u);
15 using ChVec_t = std::vector<std::uint16_t>;
26 return StatusCode::SUCCESS;
29 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
"/"<<m_allHits[1]<<
" hits. In, "
30 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
"/"
31 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
"% of the cases, the conversion was successful");
32 return StatusCode::SUCCESS;
48 for (
const TimedHit& simHit : viewer) {
55 bool run4_BI =
m_detMgr->getRpcReadoutElement(hitId)->nPhiStrips() == 0;
58 const bool digitizedPhi =
digitizeHit(simHit,
true, efficiencyMap, *digiColl, rndEngine, deadTimes);
59 std::int16_t phiChannel = digitizedPhi ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
60 const bool digitizedEta =
digitizeHit(simHit,
false, efficiencyMap, *digiColl, rndEngine, deadTimes);
62 if (digitizedEta || digitizedPhi) {
65 ChVec_t& phiChs{dec_phiChannel(*sdo)};
67 phiChs.push_back(phiChannel);
69 dec_etaChannel(*sdo).clear();
71 }
else if (
digitizeHitBI(simHit, efficiencyMap, *digiColl, rndEngine, deadTimes)) {
74 dec_etaChannel(*sdo).clear();
75 dec_phiChannel(*sdo).clear();
78 }
while (viewer.
next());
81 return StatusCode::SUCCESS;
84 const bool measuresPhi,
87 CLHEP::HepRandomEngine* rndEngine,
90 ++(m_allHits[measuresPhi]);
101 idHelper.
gasGap(gasGapId),
109 const double uncert = design.
stripPitch() / std::sqrt(12.);
111 locHitPos[measuresPhi] = CLHEP::RandGaussZiggurat::shoot(rndEngine, locHitPos[measuresPhi], uncert);
113 const Amg::Vector2D locPos2D = layerDesign->to2D(locHitPos, measuresPhi);
116 <<
" is outside of the trapezoid bounds for "<<
m_idHelperSvc->toString(layerId));
122 <<
" cannot trigger any signal in a strip for " <<
m_idHelperSvc->toString(layerId)
123 <<std::endl<<design);
130 idHelper.
gasGap(gasGapId),
140 if (effiMap && effiMap->
getEfficiency(digitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)) {
151 const double digitTime = CLHEP::RandGaussZiggurat::shoot(rndEngine, signalTime,
m_stripTimeResolution);
153 <<
", recorded time: "<<digitTime);
155 ++(m_acceptedHits[measuresPhi]);
161 CLHEP::HepRandomEngine* rndEngine,
164 ++(m_allHits[
false]);
173 const double uncert = design.
stripPitch() / std::sqrt(12.);
174 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
183 const double smearedTimeL = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeL,
m_stripTimeResolution);
184 const double smearedTimeR = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeR,
m_stripTimeResolution);
186 const double smearedDeltaT = smearedTimeR - smearedTimeL;
212 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<std::endl<<design);
221 idHelper.
gasGap(gasGapId),
225 <<
", strip: "<<
strip);
235 const bool effiSignal1 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
236 const bool effiSignal2 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
243 if (effiSignal1 || effiSignal2) {
244 ++(m_acceptedHits[
false]);
252 constexpr double tot_mean_narrow = 16.;
253 constexpr double tot_sigma_narrow = 2.;
254 constexpr double tot_mean_wide = 15.;
255 constexpr double tot_sigma_wide = 4.5;
259 if (CLHEP::RandFlat::shoot(rndmEngine)<0.75) {
260 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_narrow, tot_sigma_narrow);
262 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_wide, tot_sigma_wide);
265 return std::max(thetot, 0.);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
ATLAS-specific HepMC functions.
const T * back() const
Access the last element in the collection as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
This is a "hash" representation of an Identifier.
Identifier identify() const
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
double distanceToEdge(const IdentifierHash &measHash, const Amg::Vector3D &posInStripPlane, const EdgeSide side) const
Returns the disance to the readout.
IdentifierHash layerHash(const Identifier &measId) const override final
The layer hash removes the bits from the IdentifierHash corresponding to the measurement's channel nu...
const StripLayerPtr & sensorLayout(const IdentifierHash &measHash) const
Access to the StripLayer associated to a given measurement Hash.
const parameterBook & getParameters() const
double stripPitch() const
Distance between two adjacent strips.
bool insideTrapezoid(const Amg::Vector2D &extPos) const
Checks whether an external point is inside the trapezoidal area.
virtual int stripNumber(const Amg::Vector2D &pos) const
Calculates the number of the strip whose center is closest to the given point.
size_type module_hash_max() const
the maximum hash value
double getEfficiency(const Identifier &channelId, bool isInnerQ1=false) const
Returns the signal generation efficiency of the sTgc channel.
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
int gasGap(const Identifier &id) const override
get the hashes
int channel(const Identifier &id) const override
int doubletPhi(const Identifier &id) const
int doubletZ(const Identifier &id) const
Helper class to provide type-safe access to aux data.
bool next() noexcept
Loads the hits from the next chamber.
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
Identifier identify() const
Returns the global ATLAS identifier of the SimHit.
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
GeoModel::TransientConstSharedPtr< StripLayer > StripLayerPtr
This header ties the generic definitions in this package.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.