CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedToTrackProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SeedToTrackProducer
4 // Class: SeedToTrackProducer
5 //
13 //
14 // Original Author: Hugues Brun
15 // Created: Tue, 05 Nov 2013 13:42:04 GMT
16 // $Id$
17 //
18 //
19 
20 
21 
22 
23 #include "SeedToTrackProducer.h"
24 
25 //
26 // class declaration
27 //
28 
29 
30 
31 //
32 // constants, enums and typedefs
33 //
34 
35 
36 //
37 // static data member definitions
38 //
39 
40 //
41 // constructors and destructor
42 //
44 {
45 
46  L2seedsTag_ = iConfig.getParameter<edm::InputTag>("L2seedsCollection");
47 
48 
49 
50  produces<reco::TrackCollection>();
51  produces<reco::TrackExtraCollection>();
52  produces<TrackingRecHitCollection>();
53 
54 
55 }
56 
57 
59 {
60 
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 
64 }
65 
66 
67 //
68 // member functions
69 //
70 
71 // ------------ method called to produce the data ------------
72 void
74 {
75  using namespace edm;
76  using namespace std;
77 
78  std::auto_ptr<reco::TrackCollection> selectedTracks(new reco::TrackCollection);
79  std::auto_ptr<reco::TrackExtraCollection> selectedTrackExtras( new reco::TrackExtraCollection() );
80  std::auto_ptr<TrackingRecHitCollection> selectedTrackHits( new TrackingRecHitCollection() );
81 
85 
88 
89  // magnetic fied and detector geometry
92 
93  // now read the L2 seeds collection :
94  edm::Handle<TrajectorySeedCollection> L2seedsCollection;
95  iEvent.getByLabel(L2seedsTag_,L2seedsCollection);
96  const std::vector<TrajectorySeed>* L2seeds = 0;
97  if (L2seedsCollection.isValid()) L2seeds = L2seedsCollection.product();
98  else edm::LogError("SeedToTrackProducer") << "L2 seeds collection not found !! " << endl;
99 
101  iEvent.getByLabel(L2seedsTag_, seedHandle);
102 
103 
104  int countRH = 0;
105 
106  // now loop on the seeds :
107  for (unsigned int i = 0; i < L2seeds->size() ; i++){
108 
109 
110  //get the kinematic extrapolation from the seed
111  TrajectoryStateOnSurface theTrajectory = seedTransientState(L2seeds->at(i));
112  float seedEta = theTrajectory.globalMomentum().eta();
113  float seedPhi = theTrajectory.globalMomentum().phi();
114  float seedPt = theTrajectory.globalMomentum().perp();
115  CovarianceMatrix matrixSeedErr = theTrajectory.curvilinearError().matrix();
116  edm::LogVerbatim("SeedToTrackProducer") << "seedPt=" << seedPt << " seedEta=" << seedEta << " seedPhi=" << seedPhi << endl;
117  /*AlgebraicSymMatrix66 errors = theTrajectory.cartesianError().matrix();
118  double partialPterror = errors(3,3)*pow(theTrajectory.globalMomentum().x(),2) + errors(4,4)*pow(theTrajectory.globalMomentum().y(),2);
119  edm::LogVerbatim("SeedToTrackProducer") << "seedPtError=" << sqrt(partialPterror)/theTrajectory.globalMomentum().perp() << "seedPhiError=" << theTrajectory.curvilinearError().matrix()(2,2) << endl;*/
120  //fill the track in a way that its pt, phi and eta will be the same as the seed
121  math::XYZPoint initPoint(0,0,0);
122  math::XYZVector initMom(seedPt*cos(seedPhi),seedPt*sin(seedPhi),seedPt*sinh(seedEta));
123  reco::Track theTrack(1, 1, //dummy Chi2 and ndof
124  initPoint, initMom,
125  1, matrixSeedErr,
126  reco::TrackBase::TrackAlgorithm::globalMuon, reco::TrackBase::TrackQuality::tight);
127 
128  //fill the extra track with dummy information
129  math::XYZPoint dummyFinalPoint(1,1,1);
130  math::XYZVector dummyFinalMom(0,0,10);
131  edm::RefToBase<TrajectorySeed> seed(seedHandle, i);
132  CovarianceMatrix matrixExtra = ROOT::Math::SMatrixIdentity();
133  reco::TrackExtra theTrackExtra(dummyFinalPoint, dummyFinalMom, true, initPoint, initMom, true,
134  matrixSeedErr, 1,
135  matrixExtra, 2,
136  (L2seeds->at(i)).direction(), seed);
137  theTrack.setExtra( reco::TrackExtraRef( rTrackExtras, idx++ ) );
138  edm::LogVerbatim("SeedToTrackProducer") << "trackPt=" << theTrack.pt() << " trackEta=" << theTrack.eta() << " trackPhi=" << theTrack.phi() << endl;
139  edm::LogVerbatim("SeedToTrackProducer") << "trackPtError=" << theTrack.ptError() << "trackPhiError=" << theTrack.phiError() << endl;
140 
141  //fill the seed segments in the track
142  unsigned int index_hit = 0;
143  for(TrajectorySeed::recHitContainer::const_iterator itRecHits=(L2seeds->at(i)).recHits().first; itRecHits!=(L2seeds->at(i)).recHits().second; ++itRecHits, ++countRH) {
144  TrackingRecHit* hit = (itRecHits)->clone();
145  theTrack.setHitPattern( *hit, index_hit);
146  selectedTrackHits->push_back(hit);
147  index_hit++;
148  theTrackExtra.add(TrackingRecHitRef( rHits, hidx ++ ) );
149  }
150  selectedTracks->push_back(theTrack);
151  selectedTrackExtras->push_back(theTrackExtra);
152 
153  }
154  iEvent.put(selectedTracks);
155  iEvent.put(selectedTrackExtras);
156  iEvent.put(selectedTrackHits);
157 
158 }
159 
161 
162  PTrajectoryStateOnDet tmpTSOD = tmpSeed.startingState();
163  DetId tmpDetId(tmpTSOD.detId());
164  const GeomDet* tmpGeomDet = theTrackingGeometry->idToDet(tmpDetId);
165  TrajectoryStateOnSurface tmpTSOS = trajectoryStateTransform::transientState(tmpTSOD, &(tmpGeomDet->surface()), &(*theMGField));
166  return tmpTSOS;
167 }
168 
169 // ------------ method called once each job just before starting event loop ------------
170 void
172 {
173 }
174 
175 // ------------ method called once each job just after ending the event loop ------------
176 void
178 }
179 
180 // ------------ method called when starting to processes a run ------------
181 /*
182 void
183 SeedToTrackProducer::beginRun(edm::Run const&, edm::EventSetup const&)
184 {
185 }
186 */
187 
188 // ------------ method called when ending the processing of a run ------------
189 /*
190 void
191 SeedToTrackProducer::endRun(edm::Run const&, edm::EventSetup const&)
192 {
193 }
194 */
195 
196 // ------------ method called when starting to processes a luminosity block ------------
197 /*
198 void
199 SeedToTrackProducer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
200 {
201 }
202 */
203 
204 // ------------ method called when ending the processing of a luminosity block ------------
205 /*
206 void
207 SeedToTrackProducer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
208 {
209 }
210 */
211 
212 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
213 void
215  //The following says we do not know what parameters are allowed so do no validation
216  // Please change this to state exactly what you do use, even if it is no parameters
218  desc.setUnknown();
219  descriptions.addDefault(desc);
220 }
221 
222 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const CurvilinearTrajectoryError & curvilinearError() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:137
virtual void beginJob() override
edm::ESHandle< MagneticField > theMGField
virtual void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:243
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
void addDefault(ParameterSetDescription const &psetDescription)
virtual TrajectoryStateOnSurface seedTransientState(const TrajectorySeed &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
double pt() const
track transverse momentum
Definition: TrackBase.h:129
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:192
double phiError() const
error on phi
Definition: TrackBase.h:205
unsigned int detId() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
SeedToTrackProducer(const edm::ParameterSet &)
Definition: DetId.h:18
void setHitPattern(const C &c)
set hit patterns from vector of hit references
Definition: TrackBase.h:244
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
void setExtra(const TrackExtraRef &ref)
set reference to &quot;extra&quot; object
Definition: Track.h:94
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:55
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T eta() const
Definition: PV3DBase.h:76
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
tuple clone
Definition: statics.py:58
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
virtual void endJob() override