Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:10:24

0001 #include "TrackingTools/TransientTrack/interface/TransientTrackFromFTS.h"
0002 #include "DataFormats/Math/interface/Error.h"
0003 #include "DataFormats/Math/interface/Vector3D.h"
0004 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
0005 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0006 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
0007 // #include <iostream>
0008 #include "FWCore/Utilities/interface/Likely.h"
0009 
0010 using namespace reco;
0011 
0012 TransientTrackFromFTS::TransientTrackFromFTS()
0013     : hasTime(false),
0014       timeExt_(0.),
0015       dtErrorExt_(0.),
0016       theField(nullptr),
0017       initialTSOSAvailable(false),
0018       initialTSCPAvailable(false),
0019       trackAvailable(false),
0020       blStateAvailable(false) {}
0021 
0022 TransientTrackFromFTS::TransientTrackFromFTS(const FreeTrajectoryState& fts)
0023     : initialFTS(fts),
0024       hasTime(false),
0025       timeExt_(0.),
0026       dtErrorExt_(0.),
0027       theField(&(initialFTS.parameters().magneticField())),
0028       initialTSOSAvailable(false),
0029       initialTSCPAvailable(false),
0030       trackAvailable(false),
0031       blStateAvailable(false) {}
0032 
0033 TransientTrackFromFTS::TransientTrackFromFTS(const FreeTrajectoryState& fts, const double time, const double dtime)
0034     : initialFTS(fts),
0035       hasTime(true),
0036       timeExt_(time),
0037       dtErrorExt_(dtime),
0038       theField(&(initialFTS.parameters().magneticField())),
0039       initialTSOSAvailable(false),
0040       initialTSCPAvailable(false),
0041       trackAvailable(false),
0042       blStateAvailable(false) {}
0043 
0044 TransientTrackFromFTS::TransientTrackFromFTS(const FreeTrajectoryState& fts,
0045                                              const edm::ESHandle<GlobalTrackingGeometry>& tg)
0046     : initialFTS(fts),
0047       hasTime(false),
0048       timeExt_(0.),
0049       dtErrorExt_(0.),
0050       theField(&(initialFTS.parameters().magneticField())),
0051       initialTSOSAvailable(false),
0052       initialTSCPAvailable(false),
0053       trackAvailable(false),
0054       blStateAvailable(false),
0055       theTrackingGeometry(tg) {}
0056 
0057 TransientTrackFromFTS::TransientTrackFromFTS(const FreeTrajectoryState& fts,
0058                                              const double time,
0059                                              const double dtime,
0060                                              const edm::ESHandle<GlobalTrackingGeometry>& tg)
0061     : initialFTS(fts),
0062       hasTime(true),
0063       timeExt_(time),
0064       dtErrorExt_(dtime),
0065       theField(&(initialFTS.parameters().magneticField())),
0066       initialTSOSAvailable(false),
0067       initialTSCPAvailable(false),
0068       trackAvailable(false),
0069       blStateAvailable(false),
0070       theTrackingGeometry(tg) {}
0071 
0072 TransientTrackFromFTS::TransientTrackFromFTS(const TransientTrackFromFTS& tt)
0073     : initialFTS(tt.initialFreeState()),
0074       hasTime(tt.hasTime),
0075       timeExt_(tt.timeExt_),
0076       dtErrorExt_(tt.dtErrorExt_),
0077       theField(tt.field()),
0078       initialTSOSAvailable(false),
0079       initialTSCPAvailable(false),
0080       trackAvailable(false) {
0081   if (tt.initialTSOSAvailable) {
0082     initialTSOS = tt.impactPointState();
0083     initialTSOSAvailable = true;
0084   }
0085   if (tt.initialTSCPAvailable) {
0086     initialTSCP = tt.impactPointTSCP();
0087     initialTSCPAvailable = true;
0088   }
0089 }
0090 
0091 void TransientTrackFromFTS::setTrackingGeometry(const edm::ESHandle<GlobalTrackingGeometry>& tg) {
0092   theTrackingGeometry = tg;
0093 }
0094 
0095 void TransientTrackFromFTS::setBeamSpot(const BeamSpot& beamSpot) {
0096   theBeamSpot = beamSpot;
0097   blStateAvailable = false;
0098 }
0099 
0100 TrajectoryStateOnSurface TransientTrackFromFTS::impactPointState() const {
0101   if UNLIKELY (!initialTSOSAvailable)
0102     calculateTSOSAtVertex();
0103   return initialTSOS;
0104 }
0105 
0106 TrajectoryStateClosestToPoint TransientTrackFromFTS::impactPointTSCP() const {
0107   if UNLIKELY (!initialTSCPAvailable) {
0108     initialTSCP = builder(initialFTS, initialFTS.position());
0109     initialTSCPAvailable = true;
0110   }
0111   return initialTSCP;
0112 }
0113 
0114 TrajectoryStateOnSurface TransientTrackFromFTS::outermostMeasurementState() const {
0115   throw cms::Exception("LogicError") << "TransientTrack built from a FreeTrajectoryState (TransientTrackFromFTS) can "
0116                                         "not have an outermostMeasurementState";
0117 }
0118 
0119 TrajectoryStateOnSurface TransientTrackFromFTS::innermostMeasurementState() const {
0120   throw cms::Exception("LogicError") << "TransientTrack built from a FreeTrajectoryState (TransientTrackFromFTS) can "
0121                                         "not have an innermostMeasurementState";
0122 }
0123 
0124 void TransientTrackFromFTS::calculateTSOSAtVertex() const {
0125   TransverseImpactPointExtrapolator tipe(theField);
0126   initialTSOS = tipe.extrapolate(initialFTS, initialFTS.position());
0127   initialTSOSAvailable = true;
0128 }
0129 
0130 TrajectoryStateOnSurface TransientTrackFromFTS::stateOnSurface(const GlobalPoint& point) const {
0131   TransverseImpactPointExtrapolator tipe(theField);
0132   return tipe.extrapolate(initialFTS, point);
0133 }
0134 
0135 const Track& TransientTrackFromFTS::track() const {
0136   if UNLIKELY (!trackAvailable) {
0137     GlobalPoint v = initialFTS.position();
0138     math::XYZPoint pos(v.x(), v.y(), v.z());
0139     GlobalVector p = initialFTS.momentum();
0140     math::XYZVector mom(p.x(), p.y(), p.z());
0141 
0142     theTrack = Track(0., 0., pos, mom, initialFTS.charge(), initialFTS.curvilinearError());
0143     trackAvailable = true;
0144   }
0145   return theTrack;
0146 }
0147 
0148 TrajectoryStateClosestToBeamLine TransientTrackFromFTS::stateAtBeamLine() const {
0149   if UNLIKELY (!blStateAvailable) {
0150     TSCBLBuilderNoMaterial blsBuilder;
0151     trajectoryStateClosestToBeamLine = blsBuilder(initialFTS, theBeamSpot);
0152     blStateAvailable = true;
0153   }
0154   return trajectoryStateClosestToBeamLine;
0155 }