180 float ran_one = CLHEP::RandFlat::shoot(engine,0.,1.);
182 r_val = ran_one*max_r;
183 float ran_two = CLHEP::RandFlat::shoot(engine,0.,1.);
190 r_val = std::sqrt(
m_radius*max_r*ran_one);
194 float ran_three= CLHEP::RandFlat::shoot(engine, 0.,2*
M_PI);
195 float x_val = r_val*cos(ran_three);
196 float z_val = r_val*sin(ran_three);
207 CLHEP::HepLorentzVector p(x_val,
m_yval,z_val, t_val*CLHEP::c_light);
223 const EventContext& ctx = Gaudi::Hive::currentContext();
244 HepMC::Polarization thePolarization(0.0,0.0);
259 return StatusCode::FAILURE;
266 CLHEP::HepLorentzVector pp;
268 CLHEP::HepLorentzVector vert;
269 CLHEP::Hep3Vector vert3;
280 vert3 = CLHEP::Hep3Vector(vert.x(),vert.y(),vert.z());
282 double vert_radius=sqrt(vert3.x()*vert3.x() + vert3.z()*vert3.z());
291 phi1=atan2(vert.z(),vert.x())+
M_PI;
292 float delta_phi=std::asin(
m_radius/vert_radius);
293 phi1=phi1+CLHEP::RandFlat::shoot(engine, -delta_phi, delta_phi);
295 pp.setX(mag1*sin(theta1)*std::cos(phi1));
296 pp.setY(mag1*sin(theta1)*std::sin(phi1));
300 vert3 = CLHEP::Hep3Vector(vert.x(),vert.y(),vert.z());
309 CLHEP::Hep3Vector pp_corr(mag1*sin(theta1)*std::cos(phi1),
310 -mag1*std::cos(theta1),
311 mag1*std::sin(theta1)*std::sin(phi1));
312 CLHEP::Hep3Vector direction(pp_corr.x(),pp_corr.y(), pp_corr.z());
317 CLHEP::Hep3Vector center_dir=
m_center-vert3;
318 double beta=direction.angle(center_dir);
319 double alpha=std::asin(
m_radius/center_dir.r());
321 if(std::abs(beta)<alpha) {
325 CLHEP::HepLorentzVector pp2(pp_corr.x(),pp_corr.y(), pp_corr.z(), pp.e());
334 <<
", y0 = " << vert3.y()
335 <<
", z0 = " << vert3.z()
336 <<
", theta = " << pp.theta()
337 <<
", phi = " << pp.phi()
338 <<
", energy = " << pp.e()*
m_GeV );
341 double path =
pathLengthInRock(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
342 double energyLoss = 2.33e-3 * 244. * path;
344 <<
" --> " << (energyLoss>pp.e()*
m_GeV ?
"REJECTED" :
"ACCEPTED") <<
" by pathlength cut");
349 bool aimedAtPixels =
pointsAtPixels(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
350 ATH_MSG_DEBUG( (aimedAtPixels ?
"AIMED AT PIXELS" :
"NOT AIMED AT PIXELS") );
351 if (!aimedAtPixels) accepted =
false;
356 ATH_MSG_VERBOSE(
"The following event has been accepted for simulation:");
357 ATH_MSG_VERBOSE(
"x0 = " << vert3.x() <<
", y0 = " << vert3.y() <<
", z0 = " << vert3.z()
358 <<
", theta = " << pp.theta() <<
", phi = " << pp.phi() <<
", energy = " << pp.e()*
m_GeV );
361 double path =
pathLengthInRock(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
362 double energyLoss = 2.33e-3 * 244. * path;
364 <<
" --> " << (energyLoss>pp.e()*
m_GeV ?
"REJECTED" :
"ACCEPTED") <<
" by pathlength cut" );
368 bool aimedAtPixels =
pointsAtPixels(vert3.x(),vert3.y(),vert3.z(),pp.theta(),pp.phi());
369 ATH_MSG_VERBOSE( (aimedAtPixels ?
"AIMED AT PIXELS" :
"NOT AIMED AT PIXELS") );
385 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
389 if( (srOneVec.phi() >= -2.25) && (srOneVec.phi() <= -1.7) &&
390 (srOneVec.theta() >= 0.85) && (srOneVec.theta() <= 2.25) ) {
395 ATH_MSG_DEBUG(
"Rejected muon due to SR1 SCT/TRT optimization request!");
400 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
404 if( (srOneVec.phi() >= -1.68) && (srOneVec.phi() <= -1.08) &&
405 (srOneVec.theta() >= 0.29) && (srOneVec.theta() <= 0.72) ) {
408 ATH_MSG_DEBUG(
"Muon accepted by SR1 SCT/TRT EndCapC optimization!");
410 ATH_MSG_DEBUG(
"Rejected muon due to SR1 SCT/TRT EndcapC optimization request!");
416 CLHEP::Hep3Vector srOneVec(direction.x(), direction.y(), direction.z());
424 ATH_MSG_DEBUG(
"Muon accepted by SR1 Pixel EndCap optimization!");
426 ATH_MSG_DEBUG(
"Rejected muon due to SR1 Pixel EndCap optimization request!");
432 double coor_x, coor_y, coor_z;
434 coor_x = direction.x()*(coor_z - vert.z())/direction.z() +vert.x();
435 coor_y = direction.y()*(coor_z - vert.z())/direction.z() +vert.y();
441 coor_x = direction.x()*(coor_z - vert.z())/direction.z() +vert.x();
442 coor_y = direction.y()*(coor_z - vert.z())/direction.z() +vert.y();
447 ATH_MSG_DEBUG(
"Rejected muon due to Muon EndCap optimization request!");
456 pp.setX(pp.x()*
m_GeV);
457 pp.setY(pp.y()*
m_GeV);
458 pp.setZ(pp.z()*
m_GeV);
459 pp.setT(pp.t()*
m_GeV);
467 if (particle==
nullptr){
469 return StatusCode::FAILURE;
472 double mass = particle->mass().value();
493 HepMC::Polarization thePolarization(0.0);
500 double theta = pp.theta();
501 double phi = pp.phi();
506 double p2 = e*e - mass*mass;
510 <<
" E=" << e <<
", mass=" << mass
511 <<
" -- you have generated a tachyon! Increase energy or change particle ID." );
512 return StatusCode::FAILURE;
515 double p = std::sqrt(p2);
516 double px = p*std::sin(
theta)*std::cos(
phi);
517 double pz = p*std::sin(
theta)*std::sin(
phi);
518 double py = -p*std::cos(
theta);
529 m_fourMom.push_back(CLHEP::HepLorentzVector(px,py,pz,pp.e()));
532 m_fourMom.push_back(CLHEP::HepLorentzVector(px,pz,-py,pp.e()));
539 <<
m_fourPos.back().t() <<
"), (Px,Py,Pz,E) = ("
545 " (theta,phi) = (" <<
theta <<
"," <<
phi <<
"), "
548 return StatusCode::SUCCESS;
699 double p14_z = 13500;
700 double p14_radius = 9000.;
702 double p16_z = -20000;
703 double p16_radius = 6300.;
708 double cosphi = std::cos(
phi);
709 double sinphi = std::sin(
phi);
710 double costh = std::cos(
theta);
711 double sinth = std::sin(
theta);
714 double t = (ygen-y0)/costh;
715 double x0 = xgen + t*sinth*cosphi;
716 double z0 = zgen + t*sinth*sinphi;
719 double full_distance = (y0-y1)/costh;
722 double z_mid14 = (x0-p14_x)*sinphi-(z0-p14_z)*cosphi;
723 double min_dist14 = std::abs(z_mid14);
724 double shaft_distance14 = 0.;
725 if (min_dist14<p14_radius) {
728 double z_plus14 = -cosphi*z_mid14+sinphi*std::sqrt(std::pow(p14_radius,2.)-std::pow(z_mid14,2.)) + p14_z;
729 double z_minus14 = -cosphi*z_mid14-sinphi*std::sqrt(std::pow(p14_radius,2.)-std::pow(z_mid14,2.)) + p14_z;
732 double y_plus14 = y0-costh*(z_plus14-z0)/sinth/sinphi;
733 double y_minus14 = y0-costh*(z_minus14-z0)/sinth/sinphi;
734 double y_great14 = y_plus14>y_minus14 ? y_plus14 : y_minus14;
735 double y_less14 = y_plus14>y_minus14 ? y_minus14 : y_plus14;
738 if ( (y_great14>y1) && (y_less14<y0) ) {
739 double y_top14 = y_great14<y0 ? y_great14 : y0;
740 double y_bottom14 = y_less14>y1 ? y_less14 : y1;
741 shaft_distance14 = (y_top14-y_bottom14)/costh;
746 double z_mid16 = (x0-p16_x)*sinphi-(z0-p16_z)*cosphi;
747 double min_dist16 = std::abs(z_mid16);
748 double shaft_distance16 = 0.;
749 if (min_dist16<p16_radius) {
752 double z_plus16 = -cosphi*z_mid16+sinphi*std::sqrt(std::pow(p16_radius,2.)-std::pow(z_mid16,2.)) + p16_z;
753 double z_minus16 = -cosphi*z_mid16-sinphi*std::sqrt(std::pow(p16_radius,2.)-std::pow(z_mid16,2.)) + p16_z;
756 double y_plus16 = y0-costh*(z_plus16-z0)/sinth/sinphi;
757 double y_minus16 = y0-costh*(z_minus16-z0)/sinth/sinphi;
758 double y_great16 = y_plus16>y_minus16 ? y_plus16 : y_minus16;
759 double y_less16 = y_plus16>y_minus16 ? y_minus16 : y_plus16;
762 if ( (y_great16>y1) && (y_less16<y0) ) {
763 double y_top16 = y_great16<y0 ? y_great16 : y0;
764 double y_bottom16 = y_less16>y1 ? y_less16 : y1;
765 shaft_distance16 = (y_top16-y_bottom16)/costh;
769 double rock_distance = full_distance - shaft_distance14-shaft_distance16;
770 return rock_distance;