182 float ran_one = CLHEP::RandFlat::shoot(engine,0.,1.);
184 r_val = ran_one*max_r;
185 float ran_two = CLHEP::RandFlat::shoot(engine,0.,1.);
192 r_val = std::sqrt(
m_radius*max_r*ran_one);
196 float ran_three= CLHEP::RandFlat::shoot(engine, 0.,2*
M_PI);
197 float x_val = r_val*cos(ran_three);
198 float z_val = r_val*sin(ran_three);
209 CLHEP::HepLorentzVector p(x_val,
m_yval,z_val, t_val*CLHEP::c_light);
225 const EventContext& ctx = Gaudi::Hive::currentContext();
261 return StatusCode::FAILURE;
268 CLHEP::HepLorentzVector pp;
270 CLHEP::HepLorentzVector vert;
271 CLHEP::Hep3Vector vert3;
282 vert3 = CLHEP::Hep3Vector(vert.x(),vert.y(),vert.z());
284 double vert_radius=sqrt(vert3.x()*vert3.x() + vert3.z()*vert3.z());
293 phi1=atan2(vert.z(),vert.x())+
M_PI;
294 float delta_phi=std::asin(
m_radius/vert_radius);
295 phi1=phi1+CLHEP::RandFlat::shoot(engine, -delta_phi, delta_phi);
297 pp.setX(mag1*sin(theta1)*std::cos(phi1));
298 pp.setY(mag1*sin(theta1)*std::sin(phi1));
302 vert3 = CLHEP::Hep3Vector(vert.x(),vert.y(),vert.z());
311 CLHEP::Hep3Vector pp_corr(mag1*sin(theta1)*std::cos(phi1),
312 -mag1*std::cos(theta1),
313 mag1*std::sin(theta1)*std::sin(phi1));
314 CLHEP::Hep3Vector direction(pp_corr.x(),pp_corr.y(), pp_corr.z());
319 CLHEP::Hep3Vector center_dir=
m_center-vert3;
320 double beta=direction.angle(center_dir);
321 double alpha=std::asin(
m_radius/center_dir.r());
323 if(std::abs(beta)<alpha) {
327 CLHEP::HepLorentzVector pp2(pp_corr.x(),pp_corr.y(), pp_corr.z(), pp.e());
336 <<
", y0 = " << vert3.y()
337 <<
", z0 = " << vert3.z()
338 <<
", theta = " << pp.theta()
339 <<
", phi = " << pp.phi()
340 <<
", energy = " << pp.e()*
m_GeV );
343 double path =
pathLengthInRock(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
344 double energyLoss = 2.33e-3 * 244. * path;
346 <<
" --> " << (energyLoss>pp.e()*
m_GeV ?
"REJECTED" :
"ACCEPTED") <<
" by pathlength cut");
351 bool aimedAtPixels =
pointsAtPixels(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
352 ATH_MSG_DEBUG( (aimedAtPixels ?
"AIMED AT PIXELS" :
"NOT AIMED AT PIXELS") );
353 if (!aimedAtPixels) accepted =
false;
358 ATH_MSG_VERBOSE(
"The following event has been accepted for simulation:");
359 ATH_MSG_VERBOSE(
"x0 = " << vert3.x() <<
", y0 = " << vert3.y() <<
", z0 = " << vert3.z()
360 <<
", theta = " << pp.theta() <<
", phi = " << pp.phi() <<
", energy = " << pp.e()*
m_GeV );
363 double path =
pathLengthInRock(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
364 double energyLoss = 2.33e-3 * 244. * path;
366 <<
" --> " << (energyLoss>pp.e()*
m_GeV ?
"REJECTED" :
"ACCEPTED") <<
" by pathlength cut" );
370 bool aimedAtPixels =
pointsAtPixels(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
371 ATH_MSG_VERBOSE( (aimedAtPixels ?
"AIMED AT PIXELS" :
"NOT AIMED AT PIXELS") );
387 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
391 if( (srOneVec.phi() >= -2.25) && (srOneVec.phi() <= -1.7) &&
392 (srOneVec.theta() >= 0.85) && (srOneVec.theta() <= 2.25) ) {
397 ATH_MSG_DEBUG(
"Rejected muon due to SR1 SCT/TRT optimization request!");
402 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
406 if( (srOneVec.phi() >= -1.68) && (srOneVec.phi() <= -1.08) &&
407 (srOneVec.theta() >= 0.29) && (srOneVec.theta() <= 0.72) ) {
410 ATH_MSG_DEBUG(
"Muon accepted by SR1 SCT/TRT EndCapC optimization!");
412 ATH_MSG_DEBUG(
"Rejected muon due to SR1 SCT/TRT EndcapC optimization request!");
418 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
426 ATH_MSG_DEBUG(
"Muon accepted by SR1 Pixel EndCap optimization!");
428 ATH_MSG_DEBUG(
"Rejected muon due to SR1 Pixel EndCap optimization request!");
434 double coor_x, coor_y, coor_z;
436 coor_x = direction.x()*(coor_z - vert.z())/direction.z() +vert.x();
437 coor_y = direction.y()*(coor_z - vert.z())/direction.z() +vert.y();
443 coor_x = direction.x()*(coor_z - vert.z())/direction.z() +vert.x();
444 coor_y = direction.y()*(coor_z - vert.z())/direction.z() +vert.y();
449 ATH_MSG_DEBUG(
"Rejected muon due to Muon EndCap optimization request!");
458 pp.setX(pp.x()*
m_GeV);
459 pp.setY(pp.y()*
m_GeV);
460 pp.setZ(pp.z()*
m_GeV);
461 pp.setT(pp.t()*
m_GeV);
471 return StatusCode::FAILURE;
474 double mass = *pmass;
502 double theta = pp.theta();
503 double phi = pp.phi();
508 double p2 = e*e - mass*mass;
512 <<
" E=" << e <<
", mass=" << mass
513 <<
" -- you have generated a tachyon! Increase energy or change particle ID." );
514 return StatusCode::FAILURE;
517 double p = std::sqrt(p2);
518 double px = p*std::sin(
theta)*std::cos(
phi);
519 double pz = p*std::sin(
theta)*std::sin(
phi);
520 double py = -p*std::cos(
theta);
531 m_fourMom.push_back(CLHEP::HepLorentzVector(px,py,pz,pp.e()));
534 m_fourMom.push_back(CLHEP::HepLorentzVector(px,pz,-py,pp.e()));
541 <<
m_fourPos.back().t() <<
"), (Px,Py,Pz,E) = ("
547 " (theta,phi) = (" <<
theta <<
"," <<
phi <<
"), "
550 return StatusCode::SUCCESS;
701 double p14_z = 13500;
702 double p14_radius = 9000.;
704 double p16_z = -20000;
705 double p16_radius = 6300.;
710 double cosphi = std::cos(
phi);
711 double sinphi = std::sin(
phi);
712 double costh = std::cos(
theta);
713 double sinth = std::sin(
theta);
716 double t = (ygen-y0)/costh;
717 double x0 = xgen + t*sinth*cosphi;
718 double z0 = zgen + t*sinth*sinphi;
721 double full_distance = (y0-y1)/costh;
724 double z_mid14 = (x0-p14_x)*sinphi-(z0-p14_z)*cosphi;
725 double min_dist14 = std::abs(z_mid14);
726 double shaft_distance14 = 0.;
727 if (min_dist14<p14_radius) {
730 double z_plus14 = -cosphi*z_mid14+sinphi*std::sqrt(std::pow(p14_radius,2.)-std::pow(z_mid14,2.)) + p14_z;
731 double z_minus14 = -cosphi*z_mid14-sinphi*std::sqrt(std::pow(p14_radius,2.)-std::pow(z_mid14,2.)) + p14_z;
734 double y_plus14 = y0-costh*(z_plus14-z0)/sinth/sinphi;
735 double y_minus14 = y0-costh*(z_minus14-z0)/sinth/sinphi;
736 double y_great14 = y_plus14>y_minus14 ? y_plus14 : y_minus14;
737 double y_less14 = y_plus14>y_minus14 ? y_minus14 : y_plus14;
740 if ( (y_great14>y1) && (y_less14<y0) ) {
741 double y_top14 = y_great14<y0 ? y_great14 : y0;
742 double y_bottom14 = y_less14>y1 ? y_less14 : y1;
743 shaft_distance14 = (y_top14-y_bottom14)/costh;
748 double z_mid16 = (x0-p16_x)*sinphi-(z0-p16_z)*cosphi;
749 double min_dist16 = std::abs(z_mid16);
750 double shaft_distance16 = 0.;
751 if (min_dist16<p16_radius) {
754 double z_plus16 = -cosphi*z_mid16+sinphi*std::sqrt(std::pow(p16_radius,2.)-std::pow(z_mid16,2.)) + p16_z;
755 double z_minus16 = -cosphi*z_mid16-sinphi*std::sqrt(std::pow(p16_radius,2.)-std::pow(z_mid16,2.)) + p16_z;
758 double y_plus16 = y0-costh*(z_plus16-z0)/sinth/sinphi;
759 double y_minus16 = y0-costh*(z_minus16-z0)/sinth/sinphi;
760 double y_great16 = y_plus16>y_minus16 ? y_plus16 : y_minus16;
761 double y_less16 = y_plus16>y_minus16 ? y_minus16 : y_plus16;
764 if ( (y_great16>y1) && (y_less16<y0) ) {
765 double y_top16 = y_great16<y0 ? y_great16 : y0;
766 double y_bottom16 = y_less16>y1 ? y_less16 : y1;
767 shaft_distance16 = (y_top16-y_bottom16)/costh;
771 double rock_distance = full_distance - shaft_distance14-shaft_distance16;
772 return rock_distance;