60 #include "CLHEP/Vector/ThreeVector.h"
61 #include "CLHEP/Geometry/Normal3D.h"
62 #include "CLHEP/Units/PhysicalConstants.h"
63 #include "CLHEP/Random/RandFlat.h"
81 ISvcLocator* pSvcLocator)
108 ATH_MSG_INFO(
"Accepted diff flux after E and cos(theta) cuts = " << flux_withCT <<
" /cm^2/s" );
111 ATH_MSG_INFO(
"Accepted total flux after E and cos(theta) cuts = " <<
121 return StatusCode::FAILURE;
128 return StatusCode::SUCCESS;
140 float x_val = CLHEP::RandFlat::shoot(engine,
m_xlow,
m_xhig);
141 float z_val = CLHEP::RandFlat::shoot(engine,
m_zlow,
m_zhig);
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);
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;
300 vert3 = CLHEP::Hep3Vector(vert.x(),vert.y(),vert.z());
309 CLHEP::Hep3Vector pp_corr(mag1*
sin(theta1)*
std::cos(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 );
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 );
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);
469 return StatusCode::FAILURE;
493 HepMC::Polarization thePolarization(0.0);
500 double theta = pp.theta();
501 double phi = pp.phi();
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);
539 <<
m_fourPos.back().t() <<
"), (Px,Py,Pz,E) = ("
545 " (theta,phi) = (" <<
theta <<
"," <<
phi <<
"), "
548 return StatusCode::SUCCESS;
560 ATH_MSG_INFO(
"********************************************");
561 ATH_MSG_INFO(
"** you have run CosmicGenerator with some ");
565 ATH_MSG_INFO(
"********************************************");
570 ATH_MSG_INFO(
"**********************************************");
571 ATH_MSG_INFO(
"** you have run CosmicGenerator with some ");
572 ATH_MSG_INFO(
"** optimizations for SR1 SCT/TRT simulation");
575 ATH_MSG_INFO(
"**********************************************");
580 ATH_MSG_INFO(
"**********************************************");
581 ATH_MSG_INFO(
"** you have run CosmicGenerator with some ");
582 ATH_MSG_INFO(
"** optimizations for SR1 SCT/TRT EndcapC simulation");
585 ATH_MSG_INFO(
"**********************************************");
591 ATH_MSG_INFO(
"***************************************************");
592 ATH_MSG_INFO(
"** you have run CosmicGenerator with some ");
593 ATH_MSG_INFO(
"** optimizations for SR1 Pixel EndCap simulation");
596 ATH_MSG_INFO(
"***************************************************");
599 ATH_MSG_INFO(
"***************************************************");
600 ATH_MSG_INFO(
" You have swapped Y- and Z-axis, i.e. muons are ");
602 ATH_MSG_INFO(
"***************************************************");
609 ATH_MSG_INFO(
"***************************************************");
610 ATH_MSG_INFO(
"** you have run CosmicGenerator with some " );
614 ATH_MSG_INFO(
"***************************************************");
617 return StatusCode::SUCCESS;
644 event->add_vertex(
vertex );
649 if (
event->weights().empty()){
650 event->weights().push_back(1.0);
652 return StatusCode::SUCCESS;
654 ATH_MSG_ERROR(
"Wrong different number of vertexes/momenta/polaritazions!");
655 return StatusCode::FAILURE;
670 double e = 0.45238*
r+5000 ;
680 double e = 0.461538*(
r-15000)+10000 ;
699 double p14_z = 13500;
700 double p14_radius = 9000.;
702 double p16_z = -20000;
703 double p16_radius = 6300.;
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;
785 double t = ygen/costh;
786 double x_pos = xgen +
t*sinth*cosphi;
787 double z_pos = zgen +
t*sinth*sinphi;