6#include "CLHEP/Random/RandGaussZiggurat.h"
7#include "CLHEP/Random/RandFlat.h"
10 constexpr double percentage(
unsigned int numerator,
unsigned int denom) {
11 return 100. * numerator / std::max(denom, 1u);
21 return StatusCode::SUCCESS;
24 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
"/"<<m_allHits[1]<<
" hits. In, "
25 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
"/"
26 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
"% of the cases, the conversion was successful");
27 return StatusCode::SUCCESS;
39 CLHEP::HepRandomEngine* rndEngine,
54 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
56 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
65 <<
" is outside of the trapezoid "<<design);
68 const int wireGrpNum = design.
stripNumber(locPos2D);
72 <<
" is not covered by any wire gang");
77 const double locX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos2D.x(), uncert);
81 const int prdWireNum = design.
stripNumber(smearedPos);
86 <<
Amg::toString(smearedPos)<<
" "<<uncert<<
" is outside of "<<design);
102 <<
Amg::toString(locSimHitPos, 2)<<
" wire group number: "<<prdWireNum<<
", time: "<<
hitTime(timedHit)
103 <<
" wiregroup pos "<<
Amg::toString(design.
center(prdWireNum).value_or(Amg::Vector2D::Zero()), 2));
105 ++m_acceptedHits[
false];
112 CLHEP::HepRandomEngine* rndEngine,
127 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
129 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
140 <<
" is outside of the trapezoid "<<std::endl<<design);
155 locSimHitPos, stripNorm)) +
157 locSimHitPos, stripNorm));
159 const double uncert = stripPitch / std::sqrt(12);
160 const double locX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locSimHitPos.x(), uncert);
164 const int digitStripNum = design.
stripNumber(smearedPos);
166 if (digitStripNum < 0) {
169 <<
Amg::toString(smearedPos)<<
" "<<uncert<<
" is outside of "<<design);
186 <<
Amg::toString(locSimHitPos, 2)<<
" phi strip number: "<<digitStripNum<<
", time: "<<
hitTime(timedHit)
187 <<
" strip position "<<
Amg::toString(design.
center(digitStripNum).value_or(Amg::Vector2D::Zero()), 2));
191 ++(m_acceptedHits[
true]);
210 for (
const TimedHit& simHit : viewer) {
217 const bool digitizedPhi =
digitizeStripHit(ctx, simHit, efficiencyMap,*outColl, rndEngine, deadTimes);
218 std::int16_t phiChannel = digitizedPhi ? idHelper.
channel(outColl->
back()->
identify()) : -1;
219 const bool digitizedEta =
digitizeWireHit(ctx,simHit, efficiencyMap,*outColl, rndEngine, deadTimes);
221 if (digitizedEta || digitizedPhi) {
224 dec_phiChannel(*sdo) = phiChannel;
227 }
while(viewer.
next());
230 return StatusCode::SUCCESS;
#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
Amg::Vector2D stripNormal(int stripNumber) const
@bief: Returns the vector perpendicular to the stripDir and pointing to the next strip
Amg::Vector2D stripLeftEdge(int stripNumber) const
: Returns the direction of the left edge
Amg::Vector2D stripRightBottom(int stripNumber) const
: Returns the intersecton of the strip right edge at the bottom panel's edge
Amg::Vector2D stripRightEdge(int stripNumber) const
: Returns the direction of the right edge
int stripNumber(const Amg::Vector2D &extPos) const override final
Returns the associated channel number of an external vector.
Amg::Vector2D stripLeftBottom(int stripNumber) const
: Returns the intersection of the left strip edge at the bottom panel's edge
CheckVector2D center(int stripNumb) const
Returns the bisector of the strip (Global numbering scheme)
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.
const StripLayerPtr & sensorLayout(const IdentifierHash &hash) const
Returns the pointer to the strip layer associated with the gas gap.
unsigned numWireGangs(const IdentifierHash &layHash) const
Returns the number of wire gangs for a given gasGap [1-3].
static unsigned gasGapNumber(const IdentifierHash &measHash)
Unpacks the gas gap number from the measurement hash.
const RadialStripDesign & stripLayout(const IdentifierHash &layHash) const
Returns access to the strip design of the given gasGap [1-3] If the gap does not have strips an excep...
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
const WireGroupDesign & wireGangLayout(const IdentifierHash &layHash) const
Returns access to the wire group design of the given gasGap [1-3] If the gap does not have a wires an...
unsigned numStrips(const IdentifierHash &layHash) const
Returns the number of strips for a given gasGap [1-3].
int stripNumber(const Amg::Vector2D &pos) const override
Calculates the number of the strip whose center is closest to the given point.
unsigned int numWiresInGroup(unsigned int groupNum) const
Returns the number of wires in a given group.
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.
Helper class to provide type-safe access to aux data.
int channel(const Identifier &id) const override
Identifier channelID(int stationName, int stationEta, int stationPhi, int gasGap, int isStrip, int channel) const
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::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
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.