11 #include "CLHEP/Vector/ThreeVector.h"
12 #include "CLHEP/Geometry/Normal3D.h"
13 #include "CLHEP/Units/PhysicalConstants.h"
14 #include "CLHEP/Random/RandFlat.h"
57 const EventContext& ctx = Gaudi::Hive::currentContext();
65 for (
auto iterTTR : *coll) {
69 double en = std::sqrt(
mass*
mass+iterTTR.GetMomentum().mag2());
72 <<
"\n mom is "<<iterTTR.GetMomentum()
73 <<
"\n pdg is "<<iterTTR.GetPDGCode() );
75 CLHEP::HepLorentzVector particle4Position( iterTTR.GetPosition(), iterTTR.GetTime());
79 ATH_MSG_DEBUG(
"Track record started at " << particle4Position );
82 if ( particle4Position.z() == 22031 || particle4Position.z() == -22031 ){
83 particle4Position.setX( particle4Position.x() + CLHEP::RandFlat::shoot(rndmEngine, -
m_smearTR,
m_smearTR) );
84 particle4Position.setY( particle4Position.y() + CLHEP::RandFlat::shoot(rndmEngine, -
m_smearTR,
m_smearTR) );
86 particle4Position.setZ( particle4Position.z() + CLHEP::RandFlat::shoot(rndmEngine, -
m_smearTR,
m_smearTR) );
87 double R = std::sqrt(
std::pow( particle4Position.x(),2 ) +
std::pow(particle4Position.y(),2 ) );
89 dPhi = CLHEP::RandFlat::shoot( rndmEngine, -
dPhi,
dPhi );
90 double theta = std::atan2( particle4Position.x() , particle4Position.y() );
94 ATH_MSG_DEBUG(
"Shifted track record to " << particle4Position );
96 CLHEP::HepLorentzVector particle4Momentum( iterTTR.GetMomentum(),
en );
98 ATH_MSG_DEBUG(
"Track record momentum was " << particle4Momentum );
101 double dTheta = CLHEP::RandFlat::shoot(rndmEngine, 0,
m_smearTRp);
102 double dPhi = CLHEP::RandFlat::shoot(rndmEngine, 0, 2*
M_PI);
105 CLHEP::HepLorentzVector perpendicularMomentum( 1 , 0 , 0 , 0);
106 if ( particle4Momentum.x() != 0 ){
107 if (particle4Momentum.y() == 0){
108 perpendicularMomentum.setX( 0 );
109 perpendicularMomentum.setY( 1 );
111 perpendicularMomentum.setX( particle4Momentum.y() );
112 perpendicularMomentum.setY( particle4Momentum.x() );
117 double tempP =
std::pow(particle4Momentum.x(),2)+
std::pow(particle4Momentum.y(),2)+
std::pow(particle4Momentum.z(),2);
120 perpendicularMomentum.setX(0);
121 perpendicularMomentum.setY(0);
122 }
else if (
std::tan(dTheta) == 0 ){
123 ATH_MSG_DEBUG(
"Randomly deciding to keep the vector's direction...");
124 perpendicularMomentum.setX(0);
125 perpendicularMomentum.setY(0);
128 perpendicularMomentum.setX( perpendicularMomentum.x() *
scale );
129 perpendicularMomentum.setY( perpendicularMomentum.y() *
scale );
132 perpendicularMomentum.rotate(
dPhi , particle4Momentum.vect() );
134 particle4Momentum.setX( particle4Momentum.x() + perpendicularMomentum.x() );
135 particle4Momentum.setY( particle4Momentum.y() + perpendicularMomentum.y() );
136 particle4Momentum.setZ( particle4Momentum.z() + perpendicularMomentum.z() );
139 double scale2 = tempP==0? 1 : (
pow(particle4Momentum.x(),2)+
pow(particle4Momentum.y(),2)+
pow(particle4Momentum.z(),2)) / tempP;
140 particle4Momentum.setX( particle4Momentum.x() *
scale2 );
141 particle4Momentum.setY( particle4Momentum.y() *
scale2 );
142 particle4Momentum.setZ( particle4Momentum.z() *
scale2 );
143 ATH_MSG_DEBUG(
"Rotated the vector by " << perpendicularMomentum );
144 ATH_MSG_DEBUG(
"And resulting momentum is " << particle4Momentum );
147 ATH_MSG_DEBUG(
"Will stop the track record where it is and give it mass " <<
mass );
148 particle4Momentum.setX(0);
149 particle4Momentum.setY(0);
150 particle4Momentum.setZ(0);
151 particle4Momentum.setT(
mass);
161 m_fourPos.push_back( particle4Position );
162 m_fourMom.push_back( particle4Momentum );
164 m_pdgCode.push_back(iterTTR.GetPDGCode());
165 HepMC::Polarization thePolarization(0.0,0.0);
174 return StatusCode::SUCCESS;
181 ATH_MSG_ERROR(
"Wrong different number of vertexes/momenta/polaritazions!");
182 return StatusCode::FAILURE;
196 event->add_vertex(
vertex );
203 if (
event->weights().empty()){
204 event->weights().push_back(1.0);
206 return StatusCode::SUCCESS;