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);
26 return StatusCode::SUCCESS;
29 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[channelType::Strip]<<
"/"
30 <<m_allHits[channelType::Wire]<<
"/"
31 <<m_allHits[channelType::Pad]<<
" strip/wire/pad hits. In, "
32 <<percentage(m_acceptedHits[channelType::Strip], m_allHits[channelType::Strip]) <<
"/"
33 <<percentage(m_acceptedHits[channelType::Wire], m_allHits[channelType::Wire])<<
"/"
34 <<percentage(m_acceptedHits[channelType::Pad], m_allHits[channelType::Pad])
35 <<
"% of the cases, the conversion was successful");
36 return StatusCode::SUCCESS;
53 for (
const TimedHit& simHit : viewer) {
60 ATH_MSG_VERBOSE(
"Hit with Energy Deposit of " << simHit->energyDeposit()
65 const double hitKineticEnergy = simHit->kineticEnergy();
67 ATH_MSG_DEBUG(
"Skip electron hit with kinetic energy " << hitKineticEnergy
72 const bool digitizedPad =
digitizePad(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
73 const int16_t padChannel = digitizedPad ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
74 const bool digitizedWire =
digitizeWire(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
75 const int16_t wireChannel = digitizedWire ? idHelper.
channel(digiColl->
back()->
identify()) : -1;
76 const bool digitizedStrip =
digitizeStrip(ctx, simHit, nswUncertDB, efficiencyMap, rndEngine, *digiColl);
78 if (digitizedStrip || digitizedPad || digitizedWire) {
80 dec_sdoPadChannel(*sdo) = padChannel;
81 dec_sdoWireChannel(*sdo) = wireChannel;
85 }
while (viewer.
next());
89 return StatusCode::SUCCESS;
95 CLHEP::HepRandomEngine* rndEngine,
101 ++m_allHits[channelType::Strip];
116 <<
" is out of range "<<std::endl<<design);
122 const int gasGap = idHelper.
gasGap(hitId);
124 gasGap, channelType::Strip, stripNum,
isValid);
128 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
134 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
136 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
141 errorCalibInput.
stripId= stripId;
146 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
148 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
150 const int digitStrip = design.
stripNumber(digitPos);
151 if (digitStrip < 0) {
153 <<
" is out of range "<<std::endl<<design);
157 gasGap, channelType::Strip, digitStrip,
isValid);
161 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
164 constexpr double dummyCharge = 66666;
185 const double pull = (smearedX - (*design.
center(digitStrip)).
x()) / design.
stripPitch();
186 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - pull));
187 const double w2 = 1. - pull -2.*w1;
188 const double w3 = pull + w1;
192 gasGap, channelType::Strip, digitStrip -1);
193 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
195 hitTime(timedHit), dummyCharge * w1,
false,
false));
197 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
199 hitTime(timedHit), dummyCharge * w2,
false,
false));
201 if (digitStrip + 1 <= design.
numStrips()) {
203 gasGap, channelType::Strip, digitStrip + 1);
205 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
207 hitTime(timedHit), dummyCharge * w3,
false,
false));
209 ++m_acceptedHits[channelType::Strip];
216 CLHEP::HepRandomEngine* rndEngine,
223 ++m_allHits[channelType::Wire];
227 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
229 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
235 const int gasGap = idHelper.
gasGap(hitId);
239 bool isInnerQ1 = readOutEle->
isEtaZero(hitHash, wirePos);
244 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
246 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
252 const int wireGrpNum = design.
stripNumber(wirePos);
253 if (wireGrpNum < 0) {
255 <<
" is outside of the acceptance of "<<std::endl<<design);
260 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
262 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
264 const int digitWire = design.
stripNumber(digitPos);
267 <<
" is out of range "<<std::endl<<design);
272 gasGap, channelType::Wire, digitWire,
isValid);
276 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
279 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
281 hitTime(timedHit), 666,
false,
false));
284 ++m_acceptedHits[channelType::Wire];
296 CLHEP::HepRandomEngine* rndEngine,
303 ++m_allHits[channelType::Pad];
308 const int gasGap = idHelper.
gasGap(hitId);
318 if (padEta < 0 || padPhi < 0) {
320 <<
" is outside of the acceptance of "<<std::endl<<design);
325 gasGap, channelType::Pad, padEta, padPhi,
isValid);
336 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
338 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
342 outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
344 hitTime(timedHit), 666,
false,
false));
346 ++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.