7#include "CLHEP/Random/RandGaussZiggurat.h"
8#include "CLHEP/Random/RandFlat.h"
11 constexpr double percentage(
unsigned int numerator,
unsigned int denom) {
12 return 100. * numerator / std::max(denom, 1u);
14 using ChVec_t = std::vector<std::uint16_t>;
24 return StatusCode::SUCCESS;
27 std::stringstream statstr{};
29 for (
unsigned int g = 0; g < m_allHits.size(); ++g) {
30 allHits += m_allHits[g];
31 statstr<<
" *** Layer "<<(g+1)<<
" "<<percentage(m_acceptedHits[g],m_allHits[g])
32 <<
"% of "<<m_allHits[g]<<std::endl;
34 if(!allHits)
return StatusCode::SUCCESS;
35 ATH_MSG_INFO(
"Tried to convert "<<allHits<<
" hits. Successes rate per layer "<<std::endl<<statstr.str());
36 return StatusCode::SUCCESS;
54 for (
const TimedHit& simHit : viewer) {
59 const double hitKineticEnergy = simHit->kineticEnergy();
70 const Amg::Vector2D locPos{xAOD::toEigen(simHit->localPosition()).block<2,1>(0,0)};
73 const unsigned int hitGapInNsw = (idHelper.
multilayer(hitId) -1) * 4 + idHelper.
gasGap(hitId) -1;
74 ++m_allHits[hitGapInNsw];
83 <<
" is outside bounds "<<std::endl<<design<<
" rejecting it");
94 <<
" channel " << channelNumber <<
" locPos " <<
Amg::toString(locPos));
98 if(efficiencyMap && efficiencyMap->
getEfficiency(clusId) < CLHEP::RandFlat::shoot(rndEngine, 0., 1.)){
106 errorCalibInput.
stripId = clusId;
107 errorCalibInput.
locTheta =
M_PI- simHit->localDirection().theta();
110 ATH_MSG_VERBOSE(
"mm hit has theta " << errorCalibInput.
locTheta / Gaudi::Units::deg <<
" and uncertainty " << uncert);
115 constexpr int dummyResponseTime = 100;
116 constexpr float dummyDepositedCharge = 666666;
118 const double newLocalX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
119 const int newChannel = design.
stripNumber(newLocalX * Amg::Vector2D::UnitX());
120 if (newChannel < 0) {
131 <<
" channel " << newChannel <<
" locPos " <<
Amg::toString(locPos));
157 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - pull));
158 const double w2 = 1 - pull -2*w1;
159 const double w3 = pull + w1;
164 ChVec_t& sdoCh{dec_etaChannel(*sdoHit)};
171 outColl->
push_back(std::make_unique<MmDigit>(digitIdB, dummyResponseTime, w1 * dummyDepositedCharge));
172 sdoCh.push_back(newChannel - 1);
174 outColl->
push_back(std::make_unique<MmDigit>(digitId,dummyResponseTime, w2 * dummyDepositedCharge));
181 outColl->
push_back(std::make_unique<MmDigit>(digitIdA, dummyResponseTime, w3 * dummyDepositedCharge));
182 sdoCh.push_back(newChannel + 1);
185 ++m_acceptedHits[hitGapInNsw];
187 }
while(viewer.
next());
190 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
bool isValid() const
Test to see if the link can be dereferenced.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ATLAS-specific HepMC functions.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
const StripLayer & stripLayer(const Identifier &measId) const
double stereoAngle() const
Returns the value of the stereo angle.
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.
virtual int stripNumber(const Amg::Vector2D &pos) const
Calculates the number of the strip whose center is closest to the given point.
const StripDesign & design(bool phiView=false) const
Returns the underlying strip design.
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.
double clusterUncertainty(const Input &clustInfo) const
bool next()
Loads the hits from the next chamber.
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
bool isElectron(const T &p)
This header ties the generic definitions in this package.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.