CMS 3D CMS Logo

SeedToTrackProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SeedToTrackProducer
4 // Class: SeedToTrackProducer
5 //
14 //
15 // Original Author: Hugues Brun
16 // Created: Tue, 05 Nov 2013 13:42:04 GMT
17 // $Id$
18 //
19 //
20 
21 #include "SeedToTrackProducer.h"
22 
25 
26 //
27 // constructors and destructor
28 //
30  L2seedsTagT_ = consumes<TrajectorySeedCollection>(iConfig.getParameter<edm::InputTag>("L2seedsCollection"));
31  L2seedsTagS_ = consumes<edm::View<TrajectorySeed>>(iConfig.getParameter<edm::InputTag>("L2seedsCollection"));
32 
33  produces<reco::TrackCollection>();
34  produces<reco::TrackExtraCollection>();
35  produces<TrackingRecHitCollection>();
36 }
37 
39 
40 //
41 // member functions
42 //
43 
44 // ------------ method called to produce the data ------------
46  using namespace edm;
47  using namespace std;
48 
49  std::unique_ptr<reco::TrackCollection> selectedTracks(new reco::TrackCollection);
50  std::unique_ptr<reco::TrackExtraCollection> selectedTrackExtras(new reco::TrackExtraCollection());
51  std::unique_ptr<TrackingRecHitCollection> selectedTrackHits(new TrackingRecHitCollection());
52 
53  reco::TrackRefProd rTracks = iEvent.getRefBeforePut<reco::TrackCollection>();
54  reco::TrackExtraRefProd rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
55  TrackingRecHitRefProd rHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
56 
59 
60  // magnetic fied and detector geometry
63 
65  iSetup.get<TrackerTopologyRcd>().get(httopo);
66  const TrackerTopology &ttopo = *httopo;
67 
68  // now read the L2 seeds collection :
71  const std::vector<TrajectorySeed> *L2seeds = nullptr;
72  if (L2seedsCollection.isValid())
73  L2seeds = L2seedsCollection.product();
74  else
75  edm::LogError("SeedToTrackProducer") << "L2 seeds collection not found !! " << endl;
76 
78  iEvent.getByToken(L2seedsTagS_, seedHandle);
79 
80  int countRH = 0;
81 
82  // now loop on the seeds :
83  for (unsigned int i = 0; i < L2seeds->size(); i++) {
84  // get the kinematic extrapolation from the seed
85  TrajectoryStateOnSurface theTrajectory = seedTransientState(L2seeds->at(i));
86  float seedEta = theTrajectory.globalMomentum().eta();
87  float seedPhi = theTrajectory.globalMomentum().phi();
88  float seedPt = theTrajectory.globalMomentum().perp();
89  CovarianceMatrix matrixSeedErr = theTrajectory.curvilinearError().matrix();
90  edm::LogVerbatim("SeedToTrackProducer")
91  << "seedPt=" << seedPt << " seedEta=" << seedEta << " seedPhi=" << seedPhi << endl;
92  /*AlgebraicSymMatrix66 errors = theTrajectory.cartesianError().matrix();
93  double partialPterror =
94  errors(3,3)*pow(theTrajectory.globalMomentum().x(),2) +
95  errors(4,4)*pow(theTrajectory.globalMomentum().y(),2);
96  edm::LogVerbatim("SeedToTrackProducer") << "seedPtError=" <<
97  sqrt(partialPterror)/theTrajectory.globalMomentum().perp() <<
98  "seedPhiError=" << theTrajectory.curvilinearError().matrix()(2,2) << endl;*/
99  // fill the track in a way that its pt, phi and eta will be the same as the
100  // seed
101  math::XYZPoint initPoint(0, 0, 0);
102  math::XYZVector initMom(seedPt * cos(seedPhi), seedPt * sin(seedPhi), seedPt * sinh(seedEta));
103  reco::Track theTrack(1,
104  1, // dummy Chi2 and ndof
105  initPoint,
106  initMom,
107  1,
108  matrixSeedErr,
110  reco::TrackBase::TrackQuality::tight);
111 
112  // fill the extra track with dummy information
113  math::XYZPoint dummyFinalPoint(1, 1, 1);
114  math::XYZVector dummyFinalMom(0, 0, 10);
116  CovarianceMatrix matrixExtra = ROOT::Math::SMatrixIdentity();
117  reco::TrackExtra theTrackExtra(dummyFinalPoint,
118  dummyFinalMom,
119  true,
120  initPoint,
121  initMom,
122  true,
123  matrixSeedErr,
124  1,
125  matrixExtra,
126  2,
127  (L2seeds->at(i)).direction(),
128  seed);
129  theTrack.setExtra(reco::TrackExtraRef(rTrackExtras, idx++));
130  edm::LogVerbatim("SeedToTrackProducer")
131  << "trackPt=" << theTrack.pt() << " trackEta=" << theTrack.eta() << " trackPhi=" << theTrack.phi() << endl;
132  edm::LogVerbatim("SeedToTrackProducer")
133  << "trackPtError=" << theTrack.ptError() << "trackPhiError=" << theTrack.phiError() << endl;
134 
135  // fill the seed segments in the track
136  unsigned int nHitsAdded = 0;
137  for (TrajectorySeed::recHitContainer::const_iterator itRecHits = (L2seeds->at(i)).recHits().first;
138  itRecHits != (L2seeds->at(i)).recHits().second;
139  ++itRecHits, ++countRH) {
140  TrackingRecHit *hit = (itRecHits)->clone();
141  theTrack.appendHitPattern(*hit, ttopo);
142  selectedTrackHits->push_back(hit);
143  nHitsAdded++;
144  }
145  theTrackExtra.setHits(rHits, hidx, nHitsAdded);
146  hidx += nHitsAdded;
147  selectedTracks->push_back(theTrack);
148  selectedTrackExtras->push_back(theTrackExtra);
149  }
151  iEvent.put(std::move(selectedTrackExtras));
152  iEvent.put(std::move(selectedTrackHits));
153 }
154 
156  PTrajectoryStateOnDet tmpTSOD = tmpSeed.startingState();
157  DetId tmpDetId(tmpTSOD.detId());
158  const GeomDet *tmpGeomDet = theTrackingGeometry->idToDet(tmpDetId);
159  TrajectoryStateOnSurface tmpTSOS =
160  trajectoryStateTransform::transientState(tmpTSOD, &(tmpGeomDet->surface()), &(*theMGField));
161  return tmpTSOS;
162 }
163 
164 // ------------ method called once each job just before starting event loop
165 // ------------
167 
168 // ------------ method called once each job just after ending the event loop
169 // ------------
171 
172 // define this as a plug-in
edm::RefProd< TrackCollection >
mps_fire.i
i
Definition: mps_fire.py:355
reco::TrackBase::ptError
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:702
GeomDet
Definition: GeomDet.h:27
SeedToTrackProducer::seedTransientState
virtual TrajectoryStateOnSurface seedTransientState(const TrajectorySeed &)
Definition: SeedToTrackProducer.cc:155
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
SeedToTrackProducer::endJob
void endJob() override
Definition: SeedToTrackProducer.cc:170
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
CovarianceMatrix
Definition: CovarianceMatrix.h:27
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
SeedToTrackProducer::SeedToTrackProducer
SeedToTrackProducer(const edm::ParameterSet &)
Definition: SeedToTrackProducer.cc:29
edm::Ref< TrackExtraCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
SeedToTrackProducer_cfi.L2seedsCollection
L2seedsCollection
Definition: SeedToTrackProducer_cfi.py:4
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:608
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
reco::TrackExtra
Definition: TrackExtra.h:26
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackerTopology.h
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
reco::Track
Definition: Track.h:27
SeedToTrackProducer.h
edm::ESHandle< TrackerTopology >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
SeedToTrackProducer::L2seedsTagS_
edm::EDGetTokenT< edm::View< TrajectorySeed > > L2seedsTagS_
Definition: SeedToTrackProducer.h:63
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:620
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
SeedToTrackProducer::beginJob
void beginJob() override
Definition: SeedToTrackProducer.cc:166
edm::LogError
Definition: MessageLogger.h:183
SeedToTrackProducer::theTrackingGeometry
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
Definition: SeedToTrackProducer.h:66
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:623
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
iEvent
int iEvent
Definition: GenABIO.cc:224
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
SeedToTrackProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: SeedToTrackProducer.cc:45
SeedToTrackProducer
Definition: SeedToTrackProducer.h:50
get
#define get
edm::Ref::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
reco::TrackBase::appendHitPattern
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:495
TrackingRecHit
Definition: TrackingRecHit.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::Track::setExtra
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
Definition: Track.h:136
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
SeedToTrackProducer::L2seedsTagT_
edm::EDGetTokenT< TrajectorySeedCollection > L2seedsTagT_
Definition: SeedToTrackProducer.h:62
TrajectoryStateOnSurface::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: TrajectoryStateOnSurface.h:72
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
TrackingRecHitCollection
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
Definition: TrackingRecHitFwd.h:10
SeedToTrackProducer::theMGField
edm::ESHandle< MagneticField > theMGField
Definition: SeedToTrackProducer.h:65
TrajectorySeed
Definition: TrajectorySeed.h:17
edm::RefToBase< TrajectorySeed >
reco::TrackBase::phiError
double phiError() const
error on phi
Definition: TrackBase.h:719
TrajectorySeed::startingState
PTrajectoryStateOnDet const & startingState() const
Definition: TrajectorySeed.h:55
SeedToTrackProducer::~SeedToTrackProducer
~SeedToTrackProducer() override
Definition: SeedToTrackProducer.cc:38
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
edm::Event
Definition: Event.h:73
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
CurvilinearTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: CurvilinearTrajectoryError.h:61
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
TrackCollections2monitor_cff.selectedTracks
selectedTracks
Definition: TrackCollections2monitor_cff.py:32
susybsm::HSCParticleType::globalMuon
Definition: HSCParticle.h:20