Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:09

0001 #include "DataFormats/Math/interface/LorentzVector.h"
0002 #include "FastSimulation/SimplifiedGeometryPropagator/interface/StraightTrajectory.h"
0003 #include "FastSimulation/SimplifiedGeometryPropagator/interface/HelixTrajectory.h"
0004 #include "FastSimulation/SimplifiedGeometryPropagator/interface/ForwardSimplifiedGeometry.h"
0005 #include "FastSimulation/SimplifiedGeometryPropagator/interface/BarrelSimplifiedGeometry.h"
0006 #include "FastSimulation/SimplifiedGeometryPropagator/interface/Particle.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FastSimulation/SimplifiedGeometryPropagator/interface/Constants.h"
0009 
0010 fastsim::Trajectory::~Trajectory() {}
0011 
0012 fastsim::Trajectory::Trajectory(const fastsim::Particle &particle) {
0013   position_ = particle.position();
0014   momentum_ = particle.momentum();
0015 }
0016 
0017 std::unique_ptr<fastsim::Trajectory> fastsim::Trajectory::createTrajectory(const fastsim::Particle &particle,
0018                                                                            double magneticFieldZ) {
0019   if (particle.charge() == 0. || magneticFieldZ == 0.) {
0020     LogDebug("FastSim") << "create straight trajectory";
0021     return std::unique_ptr<fastsim::Trajectory>(new fastsim::StraightTrajectory(particle));
0022   } else if (std::abs(particle.momentum().Pt() /
0023                       (fastsim::Constants::speedOfLight * 1e-4 * particle.charge() * magneticFieldZ)) > 1e5) {
0024     LogDebug("FastSim") << "create straight trajectory (huge radius)";
0025     return std::unique_ptr<fastsim::Trajectory>(new fastsim::StraightTrajectory(particle));
0026   } else {
0027     LogDebug("FastSim") << "create helix trajectory";
0028     return std::unique_ptr<fastsim::Trajectory>(new fastsim::HelixTrajectory(particle, magneticFieldZ));
0029   }
0030 }
0031 
0032 double fastsim::Trajectory::nextCrossingTimeC(const fastsim::SimplifiedGeometry &layer, bool onLayer) const {
0033   if (layer.isForward()) {
0034     return this->nextCrossingTimeC(static_cast<const fastsim::ForwardSimplifiedGeometry &>(layer), onLayer);
0035   } else {
0036     return this->nextCrossingTimeC(static_cast<const fastsim::BarrelSimplifiedGeometry &>(layer), onLayer);
0037   }
0038 }
0039 
0040 double fastsim::Trajectory::nextCrossingTimeC(const fastsim::ForwardSimplifiedGeometry &layer, bool onLayer) const {
0041   if (onLayer) {
0042     return -1;
0043   }
0044   // t = (z - z_0) / v_z
0045   // substitute: v_z = p_z / E * c  ( note: extra * c absorbed in p_z units)
0046   // => t*c = (z - z_0) / p_z * E
0047   double deltaTimeC = (layer.getZ() - position_.Z()) / momentum_.Z() * momentum_.E();
0048   return deltaTimeC > 0. ? deltaTimeC : -1.;
0049 }