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);
14 using ChVec_t = std::vector<std::uint16_t>;
28 return StatusCode::SUCCESS;
31 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[channelType::Strip]<<
"/"
32 <<m_allHits[channelType::Wire]<<
"/"
33 <<m_allHits[channelType::Pad]<<
" strip/wire/pad hits. In, "
34 <<percentage(m_acceptedHits[channelType::Strip], m_allHits[channelType::Strip]) <<
"/"
35 <<percentage(m_acceptedHits[channelType::Wire], m_allHits[channelType::Wire])<<
"/"
36 <<percentage(m_acceptedHits[channelType::Pad], m_allHits[channelType::Pad])
37 <<
"% of the cases, the conversion was successful");
38 return StatusCode::SUCCESS;
55 for (
const TimedHit& simHit : viewer) {
62 ATH_MSG_VERBOSE(
"Hit with Energy Deposit of " << simHit->energyDeposit()
67 const double hitKineticEnergy = simHit->kineticEnergy();
69 ATH_MSG_DEBUG(
"Skip electron hit with kinetic energy " << hitKineticEnergy
74 const bool digitizedPad =
digitizePad(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
75 const std::int16_t padChannel = digitizedPad ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
76 const bool digitizedWire =
digitizeWire(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
77 const std::int16_t wireChannel = digitizedWire ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
78 const bool digitizedStrip =
digitizeStrip(ctx, simHit, nswUncertDB, efficiencyMap, rndEngine, *digiColl);
79 const std::int16_t stripCh = digitizedStrip ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
81 if (digitizedStrip || digitizedPad || digitizedWire) {
83 ChVec_t& stripChV{dec_stripCh(*sdo)};
84 ChVec_t& wireChV{dec_wireCh(*sdo)};
85 ChVec_t& padChV{dec_padCh(*sdo)};
86 if (stripCh > 0) { stripChV.push_back(stripCh); }
87 if (wireChannel > 0) { wireChV.push_back(wireChannel); }
88 if (padChannel > 0) { padChV.push_back(padChannel); }
92 }
while (viewer.
next());
96 return StatusCode::SUCCESS;
102 CLHEP::HepRandomEngine* rndEngine,
108 ++m_allHits[channelType::Strip];
123 <<
" is out of range "<<std::endl<<design);
129 const int gasGap = idHelper.
gasGap(hitId);
131 gasGap, channelType::Strip, stripNum,
isValid);
135 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
141 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
143 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
148 errorCalibInput.
stripId= stripId;
153 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
155 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
157 const int digitStrip = design.
stripNumber(digitPos);
158 if (digitStrip < 0) {
160 <<
" is out of range "<<std::endl<<design);
164 gasGap, channelType::Strip, digitStrip,
isValid);
168 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
171 constexpr double dummyCharge = 66666;
192 const double pull = (smearedX - (*design.
center(digitStrip)).
x()) / design.
stripPitch();
193 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - pull));
194 const double w2 = 1. - pull -2.*w1;
195 const double w3 = pull + w1;
199 gasGap, channelType::Strip, digitStrip -1);
200 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
202 hitTime(timedHit), dummyCharge * w1,
false,
false));
204 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
206 hitTime(timedHit), dummyCharge * w2,
false,
false));
208 if (digitStrip + 1 <= design.
numStrips()) {
210 gasGap, channelType::Strip, digitStrip + 1);
212 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
214 hitTime(timedHit), dummyCharge * w3,
false,
false));
216 ++m_acceptedHits[channelType::Strip];
223 CLHEP::HepRandomEngine* rndEngine,
230 ++m_allHits[channelType::Wire];
234 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
236 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
242 const int gasGap = idHelper.
gasGap(hitId);
246 bool isInnerQ1 = readOutEle->
isEtaZero(hitHash, xAOD::toEigen(timedHit->
localPosition()).block<2,1>(0,0));
251 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
253 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
259 const int wireGrpNum = design.
stripNumber(wirePos);
260 if (wireGrpNum < 0) {
262 <<
" is outside of the acceptance of "<<std::endl<<design);
267 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
269 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
271 const int digitWire = design.
stripNumber(digitPos);
274 <<
" is out of range "<<std::endl<<design);
279 gasGap, channelType::Wire, digitWire,
isValid);
283 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
286 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
288 hitTime(timedHit), 666,
false,
false));
291 ++m_acceptedHits[channelType::Wire];
303 CLHEP::HepRandomEngine* rndEngine,
310 ++m_allHits[channelType::Pad];
315 const int gasGap = idHelper.
gasGap(hitId);
325 if (padEta <= 0 || padPhi <= 0) {
327 <<
" is outside of the acceptance of "<<std::endl<<design);
332 gasGap, channelType::Pad, padEta, padPhi,
isValid);
343 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
345 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
349 outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
351 hitTime(timedHit), 666,
false,
false));
353 ++m_acceptedHits[channelType::Pad];
#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
std::pair< int, int > channelNumber(const Amg::Vector2D &hitPos) const
Function to retrieve the pad eta and phi given a local position coordinate.
CheckVector2D center(int stripNumb) const
Returns the bisector of the strip (Global numbering scheme)
double stripPitch() const
Distance between two adjacent strips.
virtual int stripNumber(const Amg::Vector2D &pos) const
Calculates the number of the strip whose center is closest to the given point.
virtual int numStrips() const
Number of strips on the panel.
Amg::Vector2D to2D(const Amg::Vector3D &vec, const bool phiView) const
Transforms a 3D vector from the strip design into a 2D vector.
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.
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
const PadDesign & padDesign(const IdentifierHash &measHash) const
Retrieves the readoutElement Layer given the Identifier/Hash.
int multilayer() const
Returns the multilayer of the sTgcReadoutElement.
const StripDesign & stripDesign(const IdentifierHash &measHash) const
Retrieves the readoutElement Layer given the Identifier/Hash.
bool isEtaZero(const IdentifierHash &measurementHash, const Amg::Vector2D &localPosition) const
const WireGroupDesign & wireDesign(const IdentifierHash &measHash) const
Retrieves the readoutElement Layer given the Identifier/Hash.
static IdentifierHash createHash(const unsigned gasGap, const unsigned channelType, const unsigned channel, const unsigned wireInGrp=0)
Create a measurement hash from the Identifier fields.
const StripLayer & stripLayer(const IdentifierHash &measId) const
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
Helper class to provide type-safe access to aux data.
int channel(const Identifier &id) const override
Identifier padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi) const
int gasGap(const Identifier &id) const override
get the hashes
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
bool next() noexcept
Loads the hits from the next chamber.
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
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
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.