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);
23 return StatusCode::SUCCESS;
26 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
"/"<<m_allHits[1]<<
" hits. In, "
27 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
"/"
28 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
"% of the cases, the conversion was successful");
29 return StatusCode::SUCCESS;
45 for (
const TimedHit& simHit : viewer) {
52 bool run4_BI =
m_detMgr->getRpcReadoutElement(hitId)->nPhiStrips() == 0;
55 const bool digitizedPhi =
digitizeHit(simHit,
true, efficiencyMap, *digiColl, rndEngine, deadTimes);
56 std::int16_t phiChannel = digitizedPhi ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
57 const bool digitizedEta =
digitizeHit(simHit,
false, efficiencyMap, *digiColl, rndEngine, deadTimes);
59 if (digitizedEta || digitizedPhi) {
62 dec_phiChannel(*sdo) = phiChannel;
64 }
else if (
digitizeHitBI(simHit, efficiencyMap, *digiColl, rndEngine, deadTimes)) {
69 }
while (viewer.
next());
72 return StatusCode::SUCCESS;
75 const bool measuresPhi,
78 CLHEP::HepRandomEngine* rndEngine,
81 ++(m_allHits[measuresPhi]);
100 const double uncert = design.
stripPitch() / std::sqrt(12.);
102 locHitPos[measuresPhi] = CLHEP::RandGaussZiggurat::shoot(rndEngine, locHitPos[measuresPhi], uncert);
104 const Amg::Vector2D locPos2D = layerDesign->to2D(locHitPos, measuresPhi);
107 <<
" is outside of the trapezoid bounds for "<<
m_idHelperSvc->toString(layerId));
113 <<
" cannot trigger any signal in a strip for " <<
m_idHelperSvc->toString(layerId)
114 <<std::endl<<design);
121 idHelper.
gasGap(gasGapId),
131 if (effiMap && effiMap->
getEfficiency(digitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)) {
142 const double digitTime = CLHEP::RandGaussZiggurat::shoot(rndEngine, signalTime,
m_stripTimeResolution);
144 <<
", recorded time: "<<digitTime);
146 ++(m_acceptedHits[measuresPhi]);
152 CLHEP::HepRandomEngine* rndEngine,
155 ++(m_allHits[
false]);
164 const double uncert = design.
stripPitch() / std::sqrt(12.);
165 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
174 const double smearedTimeL = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeL,
m_stripTimeResolution);
175 const double smearedTimeR = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeR,
m_stripTimeResolution);
177 const double smearedDeltaT = smearedTimeR - smearedTimeL;
203 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<std::endl<<design);
212 idHelper.
gasGap(gasGapId),
216 <<
", strip: "<<
strip);
226 const bool effiSignal1 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
227 const bool effiSignal2 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
234 if (effiSignal1 || effiSignal2) {
235 ++(m_acceptedHits[
false]);
243 constexpr double tot_mean_narrow = 16.;
244 constexpr double tot_sigma_narrow = 2.;
245 constexpr double tot_mean_wide = 15.;
246 constexpr double tot_sigma_wide = 4.5;
250 if (CLHEP::RandFlat::shoot(rndmEngine)<0.75) {
251 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_narrow, tot_sigma_narrow);
253 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_wide, tot_sigma_wide);
256 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.