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)}, wireCh{dec_wireCh(*sdo)}, padCh{dec_padCh(*sdo)};
84 if (stripCh > 0) { stripChV.push_back(stripCh); }
85 if (wireChannel > 0) { stripChV.push_back(wireChannel); }
86 if (padChannel > 0) { stripChV.push_back(padChannel); }
90 }
while (viewer.
next());
94 return StatusCode::SUCCESS;
100 CLHEP::HepRandomEngine* rndEngine,
106 ++m_allHits[channelType::Strip];
121 <<
" is out of range "<<std::endl<<design);
127 const int gasGap = idHelper.
gasGap(hitId);
129 gasGap, channelType::Strip, stripNum,
isValid);
133 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
139 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
141 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
146 errorCalibInput.
stripId= stripId;
151 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
153 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
155 const int digitStrip = design.
stripNumber(digitPos);
156 if (digitStrip < 0) {
158 <<
" is out of range "<<std::endl<<design);
162 gasGap, channelType::Strip, digitStrip,
isValid);
166 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
169 constexpr double dummyCharge = 66666;
190 const double pull = (smearedX - (*design.
center(digitStrip)).
x()) / design.
stripPitch();
191 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - pull));
192 const double w2 = 1. - pull -2.*w1;
193 const double w3 = pull + w1;
197 gasGap, channelType::Strip, digitStrip -1);
198 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
200 hitTime(timedHit), dummyCharge * w1,
false,
false));
202 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
204 hitTime(timedHit), dummyCharge * w2,
false,
false));
206 if (digitStrip + 1 <= design.
numStrips()) {
208 gasGap, channelType::Strip, digitStrip + 1);
210 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
212 hitTime(timedHit), dummyCharge * w3,
false,
false));
214 ++m_acceptedHits[channelType::Strip];
221 CLHEP::HepRandomEngine* rndEngine,
228 ++m_allHits[channelType::Wire];
232 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
234 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
240 const int gasGap = idHelper.
gasGap(hitId);
244 bool isInnerQ1 = readOutEle->
isEtaZero(hitHash, wirePos);
249 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
251 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
257 const int wireGrpNum = design.
stripNumber(wirePos);
258 if (wireGrpNum < 0) {
260 <<
" is outside of the acceptance of "<<std::endl<<design);
265 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
267 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
269 const int digitWire = design.
stripNumber(digitPos);
272 <<
" is out of range "<<std::endl<<design);
277 gasGap, channelType::Wire, digitWire,
isValid);
281 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
284 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
286 hitTime(timedHit), 666,
false,
false));
289 ++m_acceptedHits[channelType::Wire];
301 CLHEP::HepRandomEngine* rndEngine,
308 ++m_allHits[channelType::Pad];
313 const int gasGap = idHelper.
gasGap(hitId);
323 if (padEta < 0 || padPhi < 0) {
325 <<
" is outside of the acceptance of "<<std::endl<<design);
330 gasGap, channelType::Pad, padEta, padPhi,
isValid);
341 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
343 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
347 outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
349 hitTime(timedHit), 666,
false,
false));
351 ++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.