36 #include "CLHEP/Units/SystemOfUnits.h"
37 #include "CLHEP/Random/RandFlat.h"
38 #include "CLHEP/Random/RandGauss.h"
39 #include "CLHEP/Random/RandLandau.h"
60 m_randomEngine = m_randomSvc->GetEngine(m_randomEngineName);
61 if (!m_randomEngine) {
62 ATH_MSG_ERROR(
"[ --- ] Could not get random engine '" << m_randomEngineName <<
"'" );
63 return StatusCode::FAILURE;
66 ATH_CHECK ( m_condSummaryTool.retrieve( DisableTool{ !m_useConditionsTool } ) );
69 if ( m_siIdHelperName ==
"PixelID" ) {
72 else if ( m_siIdHelperName ==
"SCT_ID" ) {
80 m_incidentSvc->addListener(
this, IncidentType::BeginEvent);
83 return StatusCode::SUCCESS;
89 delete m_dEdX_function;
90 return StatusCode::SUCCESS;
96 if ( inc.type() == IncidentType::BeginEvent ){
99 if ( evtStore()->contains<SiHitCollection>(m_collectionName) ){
100 if ( (evtStore()->
retrieve(m_hitColl , m_collectionName)).isFailure() )
101 ATH_MSG_ERROR(
"[ --- ] Unable to retrieve SiHitCollection " << m_collectionName);
105 if ( (evtStore()->record(m_hitColl, m_collectionName,
true)).isFailure() ) {
106 ATH_MSG_ERROR(
"[ --- ] Unable to record SiHitCollection " << m_collectionName);
107 delete m_hitColl; m_hitColl=0;
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];
164 for(
i=0;
i <
np/2;
i++) {
166 fland = TMath::Landau(xx,mpc,
par[0]) /
par[0];
167 sum += fland * gauss_lut[
i];
170 fland = TMath::Landau(xx,mpc,
par[0]) /
par[0];
171 sum += fland * gauss_lut[
i];
182 double randLand = CLHEP::RandLandau::shoot(m_randomEngine);
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));
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);
249 m_dEdX_function->SetNpx(4);
253 m_dEdX_function->SetParameters(0.009807, 0.3 ,453.7,0.03733);
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));
264 if(abs(pdg_id)==211){
266 m_dEdX_function->SetParameters(0.0250, MPV ,453.7,0.0109);
269 m_dEdX_function->SetParameters(0.0205, MPV ,453.7,0.0219);
272 else if(abs(pdg_id)==321){
274 m_dEdX_function->SetParameters(0.0458, MPV ,453.7,0.0064);
277 m_dEdX_function->SetParameters(0.0465, MPV,453.7,0.000);
280 else if(abs(pdg_id)==13){
282 m_dEdX_function->SetParameters(0.0140, MPV,453.7,0.0245);
285 m_dEdX_function->SetParameters(0.0064, MPV ,453.7,0.0480);
288 else if(abs(pdg_id)==2212){
290 m_dEdX_function->SetParameters(0.0458, MPV ,453.7,0.0064);
293 m_dEdX_function->SetParameters(0.0465, MPV ,453.7,0.000);
298 else if(Momentum>= 1000){
300 m_dEdX_function->SetParameters(0.0135, MPV ,453.7,0.0245);
303 m_dEdX_function->SetParameters(0.0102, MPV ,453.7,0.0297);
310 double ymax = m_dEdX_function -> GetMaximum(
xmin,
xmax);
311 double energyLoss = 0;
314 double ry = CLHEP::RandFlat::shoot(m_randomEngine)*(
ymax-
ymin) +
ymin;
315 double rx = CLHEP::RandFlat::shoot(m_randomEngine)*(
xmax-
xmin) +
xmin;
316 double y = m_dEdX_function->Eval(rx);
317 if ( ry <=
y ){ energyLoss = rx;
break;}
336 if ( !SiDetElement ){
337 ATH_MSG_WARNING(
"[ sihit ] No Silicon Detector element available. Ignore this one.");
341 return createSimHit( isp,
pars, time, *SiDetElement, 1);
354 if ( m_useConditionsTool ) {
355 const EventContext& ctx = Gaudi::Hive::currentContext();
356 bool isActive = m_condSummaryTool->isActive(hitIdHash, hitId, ctx);
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;
395 bool isSCT = hitSiDetElement.
isSCT();
398 const double dEdX = m_fastEnergyDepositionModel ?
399 energyDeposit_fast(isp,
isPix,isSCT)
400 : energyDeposit_exact(isp,
isPix,isSCT);
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.");
416 m_hitColl->Emplace(localEntryHep,
421 m_pixIdHelper ? 0 : 1,
422 m_pixIdHelper ? m_pixIdHelper->barrel_ec(hitId) : m_sctIdHelper->barrel_ec(hitId),
423 m_pixIdHelper ? m_pixIdHelper->layer_disk(hitId) : m_sctIdHelper->layer_disk(hitId),
424 m_pixIdHelper ? m_pixIdHelper->eta_module(hitId) : m_sctIdHelper->eta_module(hitId),
425 m_pixIdHelper ? m_pixIdHelper->phi_module(hitId) : m_sctIdHelper->phi_module(hitId),
426 m_pixIdHelper ? 0 : m_sctIdHelper->side(hitId));