CMS 3D CMS Logo

TrackFromSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FastSimulation/TrackFromSeedProducer
4 // Class: TrackFromSeedProducer
5 //
13 //
14 // Original Author: Lukas Vanelderen
15 // Created: Thu, 28 May 2015 13:27:33 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
26 
29 
31 
43 
44 //
45 // class declaration
46 //
47 
49 public:
51  ~TrackFromSeedProducer() override;
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
57 
58  // ----------member data ---------------------------
62 };
63 
64 //
65 // constants, enums and typedefs
66 //
67 
68 //
69 // static data member definitions
70 //
71 
72 //
73 // constructors and destructor
74 //
76  //register your products
77  produces<reco::TrackCollection>();
78  produces<TrackingRecHitCollection>();
79  produces<reco::TrackExtraCollection>();
80 
81  // read parametes
84  tTRHBuilderName = iConfig.getParameter<std::string>("TTRHBuilder");
85 
86  //consumes
87  seedsToken = consumes<edm::View<TrajectorySeed> >(seedsTag);
88  beamSpotToken = consumes<reco::BeamSpot>(beamSpotTag);
89 }
90 
92 
93 // ------------ method called to produce the data ------------
95  using namespace edm;
96  using namespace reco;
97  using namespace std;
98 
99  // output collection
100  unique_ptr<TrackCollection> tracks(new TrackCollection);
101  unique_ptr<TrackingRecHitCollection> rechits(new TrackingRecHitCollection);
102  unique_ptr<TrackExtraCollection> trackextras(new TrackExtraCollection);
103 
104  // product references
105  TrackExtraRefProd ref_trackextras = iEvent.getRefBeforePut<TrackExtraCollection>();
106  TrackingRecHitRefProd ref_rechits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
107 
108  // input collection
110  iEvent.getByToken(seedsToken, hseeds);
111  const auto& seeds = *hseeds;
112 
113  // beam spot
115  iEvent.getByToken(beamSpotToken, beamSpot);
116 
117  // some objects to build to tracks
118  TSCBLBuilderNoMaterial tscblBuilder;
119 
121  iSetup.get<TransientRecHitRecord>().get(tTRHBuilderName, tTRHBuilder);
122 
124  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
125 
127  iSetup.get<TrackerTopologyRcd>().get(httopo);
128  const TrackerTopology& ttopo = *httopo;
129 
130  // create tracks from seeds
131  int nfailed = 0;
132  for (size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
133  auto const& seed = seeds[iSeed];
134  // try to create a track
135  TransientTrackingRecHit::RecHitPointer lastRecHit = tTRHBuilder->build(&*(seed.recHits().end() - 1));
137  trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF.product());
138  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed =
139  tscblBuilder(*state.freeState(), *beamSpot); //as in TrackProducerAlgorithm
140  if (tsAtClosestApproachSeed.isValid()) {
141  const reco::TrackBase::Point vSeed1(tsAtClosestApproachSeed.trackStateAtPCA().position().x(),
142  tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
143  tsAtClosestApproachSeed.trackStateAtPCA().position().z());
144  const reco::TrackBase::Vector pSeed(tsAtClosestApproachSeed.trackStateAtPCA().momentum().x(),
145  tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
146  tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
147  //GlobalPoint vSeed(vSeed1.x()-beamSpot->x0(),vSeed1.y()-beamSpot->y0(),vSeed1.z()-beamSpot->z0());
148  PerigeeTrajectoryError seedPerigeeErrors =
149  PerigeeConversions::ftsToPerigeeError(tsAtClosestApproachSeed.trackStateAtPCA());
150  tracks->emplace_back(0., 0., vSeed1, pSeed, state.charge(), seedPerigeeErrors.covarianceMatrix());
151  } else {
152  edm::LogVerbatim("SeedValidator") << "TrajectoryStateClosestToBeamLine not valid";
153  // use magic values chi2<0, ndof<0, charge=0 to denote a case where the fit has failed
154  // If this definition is changed, change also interface/trackFromSeedFitFailed.h
155  tracks->emplace_back(
157  nfailed++;
158  }
159 
160  tracks->back().appendHits(seed.recHits().begin(), seed.recHits().end(), ttopo);
161  // store the hits
162  size_t firsthitindex = rechits->size();
163  for (auto const& recHit : seed.recHits()) {
164  rechits->push_back(recHit);
165  }
166 
167  // create a trackextra, just to store the hit range
168  trackextras->push_back(TrackExtra());
169  trackextras->back().setHits(ref_rechits, firsthitindex, rechits->size() - firsthitindex);
170  trackextras->back().setSeedRef(edm::RefToBase<TrajectorySeed>(hseeds, iSeed));
171  // create link between track and trackextra
172  tracks->back().setExtra(TrackExtraRef(ref_trackextras, trackextras->size() - 1));
173  }
174 
175  if (nfailed > 0) {
176  edm::LogInfo("SeedValidator") << "failed to create tracks from " << nfailed << " out of " << seeds.size()
177  << " seeds ";
178  }
179  iEvent.put(std::move(tracks));
180  iEvent.put(std::move(rechits));
181  iEvent.put(std::move(trackextras));
182 }
183 
184 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
186  //The following says we do not know what parameters are allowed so do no validation
187  // Please change this to state exactly what you do use, even if it is no parameters
189  desc.setUnknown();
190  descriptions.addDefault(desc);
191 }
192 
193 //define this as a plug-in
edm::RefProd< TrackExtraCollection >
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::StreamID
Definition: StreamID.h:30
TSCBLBuilderNoMaterial.h
TrajectoryStateClosestToBeamLine
Definition: TrajectoryStateClosestToBeamLine.h:15
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
TrackFromSeedProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: TrackFromSeedProducer.cc:94
FreeTrajectoryState.h
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
TransientRecHitRecord.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
TransientTrackingRecHitBuilder::build
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
edm::Handle
Definition: AssociativeIterator.h:50
PerigeeTrajectoryError
Definition: PerigeeTrajectoryError.h:14
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
fileCollector.seed
seed
Definition: fileCollector.py:127
uncleanedOnlyElectronSequence_cff.seedsTag
seedsTag
Definition: uncleanedOnlyElectronSequence_cff.py:148
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
reco::TrackExtra
Definition: TrackExtra.h:26
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
PerigeeConversions.h
IdealMagneticFieldRecord.h
edm::ESHandle< TransientTrackingRecHitBuilder >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
AlignmentProducer_cff.beamSpotTag
beamSpotTag
Definition: AlignmentProducer_cff.py:50
TrackFromSeedProducer::seedsToken
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
Definition: TrackFromSeedProducer.cc:59
TrajectorySeed.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:230
edm::ParameterSet
Definition: ParameterSet.h:47
TrackFromSeedProducer::tTRHBuilderName
std::string tTRHBuilderName
Definition: TrackFromSeedProducer.cc:61
Event.h
reco::TrackExtraRef
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
TrackFromSeedProducer
Definition: TrackFromSeedProducer.cc:48
TrackFromSeedProducer::beamSpotToken
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: TrackFromSeedProducer.cc:60
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::EventSetup
Definition: EventSetup.h:57
get
#define get
TrackFromSeedProducer::TrackFromSeedProducer
TrackFromSeedProducer(const edm::ParameterSet &)
Definition: TrackFromSeedProducer.cc:75
reco::TrackBase::Point
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TSCBLBuilderNoMaterial
Definition: TSCBLBuilderNoMaterial.h:13
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< TrajectorySeed >
TrajectoryStateTransform.h
TrackFromSeedProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TrackFromSeedProducer.cc:185
TransientTrackingRecHitBuilder.h
TrackFromSeedProducer::~TrackFromSeedProducer
~TrackFromSeedProducer() override
Definition: TrackFromSeedProducer.cc:91
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
EDProducer.h
PerigeeConversions::ftsToPerigeeError
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
Definition: PerigeeConversions.cc:51
reco::TrackBase::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::OwnVector< TrackingRecHit >
reco::TrackBase::Vector
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:77