File indexing completed on 2024-04-06 12:11:22
0001 #include "FastSimulation/SimplifiedGeometryPropagator/interface/StraightTrajectory.h"
0002 #include "FastSimulation/SimplifiedGeometryPropagator/interface/Constants.h"
0003
0004 #include "FastSimulation/SimplifiedGeometryPropagator/interface/SimplifiedGeometry.h"
0005 #include "FastSimulation/SimplifiedGeometryPropagator/interface/BarrelSimplifiedGeometry.h"
0006 #include "FastSimulation/SimplifiedGeometryPropagator/interface/ForwardSimplifiedGeometry.h"
0007
0008 double fastsim::StraightTrajectory::nextCrossingTimeC(const fastsim::BarrelSimplifiedGeometry& layer,
0009 bool onLayer) const {
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 double a = momentum_.Perp2();
0031 double b = (position_.X() * momentum_.X() + position_.Y() * momentum_.Y());
0032 double c = position_.Perp2() - layer.getRadius() * layer.getRadius();
0033
0034 double delta = b * b - a * c;
0035 if (delta < 0) {
0036 return -1;
0037 }
0038 double sqrtDelta = sqrt(delta);
0039
0040
0041
0042
0043
0044
0045 double tc1 = (-b - sqrtDelta) / a * momentum_.E();
0046 double tc2 = (-b + sqrtDelta) / a * momentum_.E();
0047
0048 if (onLayer && tc2 > 0) {
0049 bool particleMovesInwards = momentum_.X() * position_.X() + momentum_.Y() * position_.Y() < 0;
0050
0051 double posX2 = position_.X() + momentum_.X() / momentum_.E() * tc2;
0052 double posY2 = position_.Y() + momentum_.Y() / momentum_.E() * tc2;
0053 bool particleMovesInwards2 = momentum_.X() * posX2 + momentum_.Y() * posY2 < 0;
0054
0055 if (particleMovesInwards != particleMovesInwards2) {
0056 return tc2;
0057 }
0058
0059 return -1;
0060 }
0061
0062 if (tc1 > 0) {
0063 return tc1;
0064 } else if (tc2 > 0) {
0065 return tc2;
0066 }
0067
0068 return -1.;
0069 }
0070
0071 void fastsim::StraightTrajectory::move(double deltaTimeC) {
0072 position_.SetXYZT(position_.X() + momentum_.X() / momentum_.E() * deltaTimeC,
0073 position_.Y() + momentum_.Y() / momentum_.E() * deltaTimeC,
0074 position_.Z() + momentum_.Z() / momentum_.E() * deltaTimeC,
0075 position_.T() + deltaTimeC / fastsim::Constants::speedOfLight);
0076 }