36#include "CLHEP/Units/SystemOfUnits.h"
37#include "CLHEP/Random/RandFlat.h"
38#include "CLHEP/Random/RandGauss.h"
39#include "CLHEP/Random/RandLandau.h"
63 return StatusCode::FAILURE;
83 return StatusCode::SUCCESS;
90 return StatusCode::SUCCESS;
96 if ( inc.type() == IncidentType::BeginEvent ){
127 float invsq2pi = 0.3989422804014;
128 float mpshift = -0.22278298;
131 double gauss_lut[50] = {0.998750780887374456,0.988813043727165275,0.96923323447634413,0.940588065326561695,0.903707082721058597,
132 0.859632757966350525,0.809571661213986715,0.754839601989007347,0.696804761374882342,0.636831621583786367,
133 0.576229102522380576,0.516205688098894111,0.457833361771614267,0.402021370154990454,0.349500576034800337,
134 0.300817976590658676,0.256340161499255759,0.216265166829887306,0.180639843651333204,0.149381761360416171,
135 0.122303465302261424,0.0991372321836489212,0.0795595087182276867,0.0632127172421080297,0.0497248676032363973,
136 0.0387257750604656018,0.0298595590948963728,0.0227941808836123437,0.0172274759940137939,0.0128906873307075114,
137 0.00954965878387800497,0.00700416504525899417,0.00508606923101270064,0.00365649704823364612,0.0026025848245772071,
138 0.0018340111405293852,0.00127954549250140965,0.000883826306935049958,0.000604414925679283501,0.000409223053150731654,
139 0.000274310255595171487,0.000182046138317709796,0.000119612883581024366,7.78093008945889215e-05,5.01120454198365631e-05,
140 3.19527960443799922e-05,2.01712861314266379e-05,1.26071051770485227e-05,7.8010709105552431e-06,4.77914424437207415e-06};
155 mpc = par[1] - mpshift * par[0];
158 xlow =
x[0] -
sc * par[3];
159 xupp =
x[0] +
sc * par[3];
161 step = (xupp-xlow) / np;
164 for(i=0; i < np/2; i++) {
165 xx =
x[0] +(((float) i)-.5) * step;
166 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
167 sum += fland * gauss_lut[i];
169 xx =
x[0] -(((float) i)-.5) * step;
170 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
171 sum += fland * gauss_lut[i];
174 return (par[2] * step * sum * invsq2pi / par[3]);
181 double Momentum = sqrt((mom.x()*mom.x()) +( mom.y()*mom.y())+(mom.z()*mom.z()));
185 energyLoss = (randLand*0.032)+0.32;
188 double rest_mass= isp.
mass();
189 double para0 = -1.12409e-02;
190 double para1 = 1.42786e-11;
194 double beta = Momentum/ sqrt((Momentum*Momentum)+(rest_mass*rest_mass));
195 double MPV = (para0/
pow(beta,2))*(log(para1*(
pow(beta,2)/(1-
pow(beta,2))))-
pow(beta,2));
198 if(abs(pdg_id)==211){
200 energyLoss = (randLand*0.023)+(MPV+0.008);
203 energyLoss = (randLand*0.0225)+(MPV+0.008);
206 else if(abs(pdg_id)==321){
208 energyLoss = (randLand*0.048)+(MPV+0.01);
211 energyLoss = (randLand*0.0465)+(MPV+0.01);
214 else if(abs(pdg_id)==13){
216 energyLoss = (randLand*0.025)+(MPV+0.011);
219 energyLoss = (randLand*0.048)+(MPV+0.011);
222 else if(abs(pdg_id)==2212){
224 energyLoss = (randLand*0.0458)+(MPV+0.008);
227 energyLoss = (randLand*0.0465)+(MPV+0.008);
232 else if(Momentum >= 1000){
234 energyLoss = (randLand*0.025)+(MPV+0.013);
237 energyLoss = (randLand*0.025)+(MPV+0.014);
248 double Momentum = sqrt((mom.x()*mom.x()) +( mom.y()*mom.y())+(mom.z()*mom.z()));
258 double rest_mass= isp.
mass();
259 double para0 = -1.12409e-02;
260 double para1 = 1.42786e-11;
261 double beta = Momentum/ sqrt((Momentum*Momentum)+(rest_mass*rest_mass));
262 double MPV = (para0/
pow(beta,2))*(log(para1*(
pow(beta,2)/(1-
pow(beta,2))))-
pow(beta,2));
264 if(abs(pdg_id)==211){
272 else if(abs(pdg_id)==321){
280 else if(abs(pdg_id)==13){
288 else if(abs(pdg_id)==2212){
298 else if(Momentum>= 1000){
311 double energyLoss = 0;
317 if ( ry <=
y ){ energyLoss = rx;
break;}
329 const Trk::Surface &hitSurface = pars.associatedSurface();
336 if ( !SiDetElement ){
337 ATH_MSG_WARNING(
"[ sihit ] No Silicon Detector element available. Ignore this one.");
341 return createSimHit( isp, pars, time, *SiDetElement, 1);
348 const Trk::Surface &hitSurface = pars.associatedSurface();
355 const EventContext& ctx = Gaudi::Hive::currentContext();
357 bool isGood = isActive ?
m_condSummaryTool->isGood(hitIdHash, hitId, ctx) :
false;
359 ATH_MSG_VERBOSE(
"[ sihit ] ID " << hitId <<
", hash " << hitIdHash <<
" is not active. ");
361 ATH_MSG_VERBOSE(
"[ sihit ] ID " << hitId <<
", hash " << hitIdHash <<
" is active but not good. ");
363 ATH_MSG_VERBOSE(
"[ sihit ] ID " << hitId <<
", hash " << hitIdHash <<
" is active and good.");
364 if (!isActive || !isGood)
return;
372 const double thickness = hitSiDetElement.
thickness();
376 Amg::Vector3D localDirection = sTransform.inverse().linear() * particleDir;
377 localDirection *= thickness/cos(localDirection.theta());
379 int movingDirection = localDirection.z() > 0. ? 1 : -1;
381 double distX = localDirection.x();
382 double distY = localDirection.y();
384 double localEntryX = interX-0.5*distX;
385 double localEntryY = interY-0.5*distY;
386 double localExitX = interX+0.5*distX;
387 double localExitY = interY+0.5*distY;
394 bool isPix = hitSiDetElement.
isPixel();
395 bool isSCT = hitSiDetElement.
isSCT();
402 const double energyDeposit = dEdX * (localExit - localEntry).
mag();
405 const HepGeom::Point3D<double> localEntryHep( localEntry.x(), localEntry.y(), localEntry.z() );
406 const HepGeom::Point3D<double> localExitHep( localExit.x(), localExit.y(), localExit.z() );
408 if ( isSiDetElement )
409 ATH_MSG_VERBOSE(
"[ sihit ] Adding an SiHit SiDetElement to the SiHitCollection.");
411 ATH_MSG_VERBOSE(
"[ sihit ] SiHit SiDetElement not found to add to the SiHitCollection.");
Scalar mag() const
mag method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double langaufun_fast(double *x, double *par)
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
AtlasHitsVector< SiHit > SiHitCollection
constexpr int pow(int base, int exp) noexcept
a link optimized in size for a GenParticle in a McEventCollection
The generic ISF particle definition,.
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
int pdgCode() const
PDG value.
double mass() const
mass of the particle
This is a "hash" representation of an Identifier.
Class to hold geometrical description of a silicon detector element.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
const GeoTrf::Transform3D & transformHit() const
Local (simulation/hit frame) to global transform.
Abstract Base Class for tracking surfaces.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
This is the base class for all tracking detector elements with read-out relevant information.
StringProperty m_collectionName
name of the collection on storegate
void handle(const Incident &inc)
handle for incident service
double energyDeposit_exact(const ISF::ISFParticle &isp, bool &isPix, bool &isSCT) const
Calculate Energyloss with exact Landau*Gauss.
TF1 * m_dEdX_function
function to evaluate dEdx
BooleanProperty m_useConditionsTool
HitCreatorSilicon(const std::string &, const std::string &, const IInterface *)
Constructor.
ServiceHandle< IIncidentSvc > m_incidentSvc
void createSimHit(const ISF::ISFParticle &isp, const Trk::TrackParameters &, double) const
Return nothing - store the HIT in hit collection.
CLHEP::HepRandomEngine * m_randomEngine
Random Engine.
StatusCode finalize()
AlgTool finalize method.
const PixelID * m_pixIdHelper
the Pixel ID helper
StringProperty m_siIdHelperName
where to find the Si helper
StatusCode initialize()
AlgTool initailize method.
StringProperty m_randomEngineName
Name of the random number stream.
double energyDeposit_fast(const ISF::ISFParticle &isp, bool &isPix, bool &isSCT) const
Calculate Energyloss with simple Landau approximation.
ToolHandle< IInDetConditionsTool > m_condSummaryTool
ToolHandle to ClusterMaker.
ServiceHandle< IAtRndmGenSvc > m_randomSvc
Pointer to the random number generator service.
SiHitCollection * m_hitColl
the SiHit collection
const SCT_ID * m_sctIdHelper
the SCT ID helper
BooleanProperty m_fastEnergyDepositionModel
use fast energy deposition model (landau approximation )
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters