Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:54

0001 #include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
0002 
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 
0007 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0010 
0011 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0012 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0013 
0014 #include "MagneticField/Engine/interface/MagneticField.h"
0015 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0016 
0017 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0018 #include "DataFormats/TrackReco/interface/Track.h"
0019 
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 SeedFromProtoTrack::Config::Config(edm::ConsumesCollector iC)
0023     : trackerToken_(iC.esConsumes()),
0024       propagatorToken_(iC.esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))),
0025       fieldToken_(iC.esConsumes()) {}
0026 
0027 SeedFromProtoTrack::SeedFromProtoTrack(const Config& config,
0028                                        const reco::Track& proto,
0029                                        const SeedingHitSet& hits,
0030                                        const edm::EventSetup& es)
0031     : theValid(true) {
0032   for (unsigned int i = 0, n = hits.size(); i < n; ++i) {
0033     const TrackingRecHit* trh = hits[i]->hit();
0034     theHits.push_back(trh->clone());
0035   }
0036   init(config, proto, es);
0037 }
0038 
0039 SeedFromProtoTrack::SeedFromProtoTrack(const Config& config, const reco::Track& proto, const edm::EventSetup& es)
0040     : theValid(true) {
0041   const TrackingRecHit* hit = nullptr;
0042   for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
0043     TrackingRecHitRef refHit = proto.recHit(iHit);
0044     hit = &(*refHit);
0045     theHits.push_back(hit->clone());
0046   }
0047   init(config, proto, es);
0048 }
0049 
0050 void SeedFromProtoTrack::init(const Config& config, const reco::Track& proto, const edm::EventSetup& es) {
0051   TrackerGeometry const& tracker = es.getData(config.trackerToken_);
0052 
0053   const Propagator* propagator = &es.getData(config.propagatorToken_);
0054 
0055   const MagneticField* field = &es.getData(config.fieldToken_);
0056 
0057   const reco::TrackBase::Point& vtx = proto.referencePoint();
0058   const reco::TrackBase::Vector& mom = proto.momentum();
0059   GlobalTrajectoryParameters gtp(
0060       GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(mom.x(), mom.y(), mom.z()), proto.charge(), field);
0061 
0062   CurvilinearTrajectoryError err = proto.covariance();
0063 
0064   FreeTrajectoryState fts(gtp, err);
0065 
0066   const TrackingRecHit& lastHit = theHits.back();
0067 
0068   TrajectoryStateOnSurface outerState =
0069       propagator->propagate(fts, tracker.idToDet(lastHit.geographicalId())->surface());
0070 
0071   if (!outerState.isValid()) {
0072     const Surface& surface = tracker.idToDet(lastHit.geographicalId())->surface();
0073     edm::LogError("SeedFromProtoTrack") << " was trying to create a seed from:\n"
0074                                         << fts << "\n propagating to: " << std::hex << lastHit.geographicalId().rawId()
0075                                         << std::dec << ' ' << surface.position();
0076     theValid = false;
0077     return;
0078   }
0079   theValid = true;
0080 
0081   thePTraj = trajectoryStateTransform::persistentState(outerState, lastHit.geographicalId().rawId());
0082 }
0083 
0084 TrajectorySeed SeedFromProtoTrack::trajectorySeed() const {
0085   return TrajectorySeed(trajectoryState(), hits(), direction());
0086 }