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);
25 return StatusCode::SUCCESS;
28 std::stringstream statstr{};
30 for (
unsigned int g = 0; g < m_allHits.size(); ++g) {
31 allHits += m_allHits[g];
32 statstr<<
" *** Layer "<<(g+1)<<
" "<<percentage(m_acceptedHits[g],m_allHits[g])
33 <<
"% of "<<m_allHits[g]<<std::endl;
35 if(!allHits)
return StatusCode::SUCCESS;
36 ATH_MSG_INFO(
"Tried to convert "<<allHits<<
" hits. Successes rate per layer "<<std::endl<<statstr.str());
37 return StatusCode::SUCCESS;
55 for (
const TimedHit& simHit : viewer) {
60 const double hitKineticEnergy = simHit->kineticEnergy();
71 const Amg::Vector2D locPos{xAOD::toEigen(simHit->localPosition()).block<2,1>(0,0)};
74 const unsigned int hitGapInNsw = (idHelper.
multilayer(hitId) -1) * 4 + idHelper.
gasGap(hitId) -1;
75 ++m_allHits[hitGapInNsw];
84 <<
" is outside bounds "<<std::endl<<design<<
" rejecting it");
95 <<
" channel " << channelNumber <<
" locPos " <<
Amg::toString(locPos));
99 if(efficiencyMap && efficiencyMap->
getEfficiency(clusId) < CLHEP::RandFlat::shoot(rndEngine, 0., 1.)){
107 errorCalibInput.
stripId = clusId;
108 errorCalibInput.
locTheta =
M_PI- simHit->localDirection().theta();
111 ATH_MSG_VERBOSE(
"mm hit has theta " << errorCalibInput.
locTheta / Gaudi::Units::deg <<
" and uncertainty " << uncert);
116 constexpr int dummyResponseTime = 100;
117 constexpr float dummyDepositedCharge = 666666;
119 const double newLocalX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
120 const int newChannel = design.
stripNumber(newLocalX * Amg::Vector2D::UnitX());
121 if (newChannel < 0) {
132 <<
" channel " << newChannel <<
" locPos " <<
Amg::toString(locPos));
158 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - pull));
159 const double w2 = 1 - pull -2*w1;
160 const double w3 = pull + w1;
169 outColl->
push_back(std::make_unique<MmDigit>(digitIdB, dummyResponseTime, w1 * dummyDepositedCharge));
171 outColl->
push_back(std::make_unique<MmDigit>(digitId,dummyResponseTime, w2 * dummyDepositedCharge));
178 outColl->
push_back(std::make_unique<MmDigit>(digitIdA, dummyResponseTime, w3 * dummyDepositedCharge));
183 ++m_acceptedHits[hitGapInNsw];
185 }
while(viewer.
next());
188 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.
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() noexcept
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.
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.