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 
45 
46 //
47 // class declaration
48 //
49 
51 public:
53  ~TrackFromSeedProducer() override;
54 
55  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
56 
57 private:
58  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
59 
60  // ----------member data ---------------------------
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  : geoToken_(esConsumes()),
82  tTopoToken_(esConsumes()),
83  mfToken_(esConsumes()),
84  ttrhToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))) {
85  //register your products
86  produces<reco::TrackCollection>();
87  produces<TrackingRecHitCollection>();
88  produces<reco::TrackExtraCollection>();
89 
90  // read parametes
93 
94  //consumes
95  seedsToken = consumes<edm::View<TrajectorySeed> >(seedsTag);
96  beamSpotToken = consumes<reco::BeamSpot>(beamSpotTag);
97 }
98 
100 
101 // ------------ method called to produce the data ------------
103  using namespace edm;
104  using namespace reco;
105  using namespace std;
106 
107  // output collection
108  unique_ptr<TrackCollection> tracks(new TrackCollection);
109  unique_ptr<TrackingRecHitCollection> rechits(new TrackingRecHitCollection);
110  unique_ptr<TrackExtraCollection> trackextras(new TrackExtraCollection);
111 
112  // product references
113  TrackExtraRefProd ref_trackextras = iEvent.getRefBeforePut<TrackExtraCollection>();
114  TrackingRecHitRefProd ref_rechits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
115 
116  // input collection
118  iEvent.getByToken(seedsToken, hseeds);
119  const auto& seeds = *hseeds;
120 
121  // beam spot
123  iEvent.getByToken(beamSpotToken, beamSpot);
124 
125  // some objects to build to tracks
126  TSCBLBuilderNoMaterial tscblBuilder;
127 
128  const auto& tTRHBuilder = &iSetup.getData(ttrhToken_);
129  const auto& theMF = &iSetup.getData(mfToken_);
130  const TrackerTopology& ttopo = iSetup.getData(tTopoToken_);
131  const GlobalTrackingGeometry* const geometry_ = &iSetup.getData(geoToken_);
132 
133  // create tracks from seeds
134  int nfailed = 0;
135  for (size_t iSeed = 0; iSeed < seeds.size(); ++iSeed) {
136  auto const& seed = seeds[iSeed];
137  // try to create a track
139  if (seed.nHits() == 0) { //this is for deepCore seeds only
140  const Surface* deepCore_sruface = &geometry_->idToDet(seed.startingState().detId())->specificSurface();
141  state = trajectoryStateTransform::transientState(seed.startingState(), deepCore_sruface, theMF);
142  } else {
143  TransientTrackingRecHit::RecHitPointer lastRecHit = tTRHBuilder->build(&*(seed.recHits().end() - 1));
144  state = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF);
145  }
146  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed =
147  tscblBuilder(*state.freeState(), *beamSpot); //as in TrackProducerAlgorithm
148  if (tsAtClosestApproachSeed.isValid()) {
149  const reco::TrackBase::Point vSeed1(tsAtClosestApproachSeed.trackStateAtPCA().position().x(),
150  tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
151  tsAtClosestApproachSeed.trackStateAtPCA().position().z());
152  const reco::TrackBase::Vector pSeed(tsAtClosestApproachSeed.trackStateAtPCA().momentum().x(),
153  tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
154  tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
155  //GlobalPoint vSeed(vSeed1.x()-beamSpot->x0(),vSeed1.y()-beamSpot->y0(),vSeed1.z()-beamSpot->z0());
156  PerigeeTrajectoryError seedPerigeeErrors =
157  PerigeeConversions::ftsToPerigeeError(tsAtClosestApproachSeed.trackStateAtPCA());
158  tracks->emplace_back(0., 0., vSeed1, pSeed, state.charge(), seedPerigeeErrors.covarianceMatrix());
159  } else {
160  edm::LogVerbatim("SeedValidator") << "TrajectoryStateClosestToBeamLine not valid";
161  // use magic values chi2<0, ndof<0, charge=0 to denote a case where the fit has failed
162  // If this definition is changed, change also interface/trackFromSeedFitFailed.h
163  tracks->emplace_back(
165  nfailed++;
166  }
167 
168  tracks->back().appendHits(seed.recHits().begin(), seed.recHits().end(), ttopo);
169  // store the hits
170  size_t firsthitindex = rechits->size();
171  for (auto const& recHit : seed.recHits()) {
172  rechits->push_back(recHit);
173  }
174 
175  // create a trackextra, just to store the hit range
176  trackextras->push_back(TrackExtra());
177  trackextras->back().setHits(ref_rechits, firsthitindex, rechits->size() - firsthitindex);
178  trackextras->back().setSeedRef(edm::RefToBase<TrajectorySeed>(hseeds, iSeed));
179  // create link between track and trackextra
180  tracks->back().setExtra(TrackExtraRef(ref_trackextras, trackextras->size() - 1));
181  }
182 
183  if (nfailed > 0) {
184  edm::LogInfo("SeedValidator") << "failed to create tracks from " << nfailed << " out of " << seeds.size()
185  << " seeds ";
186  }
187  iEvent.put(std::move(tracks));
188  iEvent.put(std::move(rechits));
189  iEvent.put(std::move(trackextras));
190 }
191 
192 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
194  //The following says we do not know what parameters are allowed so do no validation
195  // Please change this to state exactly what you do use, even if it is no parameters
197  desc.setUnknown();
198  descriptions.addDefault(desc);
199 }
200 
201 //define this as a plug-in
edm::RefProd< TrackExtraCollection >
edm::StreamID
Definition: StreamID.h:30
TSCBLBuilderNoMaterial.h
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
TrajectoryStateClosestToBeamLine
Definition: TrajectoryStateClosestToBeamLine.h:15
TrackFromSeedProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: TrackFromSeedProducer.cc:102
FreeTrajectoryState.h
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
ESHandle.h
ESInputTag
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
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
Surface
Definition: Surface.h:36
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
edm::Handle
Definition: AssociativeIterator.h:50
TrackFromSeedProducer::ttrhToken_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > ttrhToken_
Definition: TrackFromSeedProducer.cc:66
PerigeeTrajectoryError
Definition: PerigeeTrajectoryError.h:14
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
fileCollector.seed
seed
Definition: fileCollector.py:127
uncleanedOnlyElectronSequence_cff.seedsTag
seedsTag
Definition: uncleanedOnlyElectronSequence_cff.py:148
reco::TrackExtra
Definition: TrackExtra.h:26
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
GlobalTrackingGeometry
Definition: GlobalTrackingGeometry.h:20
PerigeeConversions.h
IdealMagneticFieldRecord.h
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:61
TrajectorySeed.h
GlobalTrackingGeometryRecord.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:231
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
TrackFromSeedProducer::geoToken_
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geoToken_
Definition: TrackFromSeedProducer.cc:63
reco::TrackExtraRef
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
TrackFromSeedProducer
Definition: TrackFromSeedProducer.cc:50
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrackFromSeedProducer::beamSpotToken
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: TrackFromSeedProducer.cc:62
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:58
TrackFromSeedProducer::TrackFromSeedProducer
TrackFromSeedProducer(const edm::ParameterSet &)
Definition: TrackFromSeedProducer.cc:80
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
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
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
TrackFromSeedProducer::tTopoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: TrackFromSeedProducer.cc:64
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:193
TransientTrackingRecHitBuilder.h
TrackFromSeedProducer::~TrackFromSeedProducer
~TrackFromSeedProducer() override
Definition: TrackFromSeedProducer.cc:99
TrajectoryStateClosestToBeamLine::isValid
bool isValid() const
Definition: TrajectoryStateClosestToBeamLine.h:50
ParameterSet.h
EDProducer.h
TrajectoryStateClosestToBeamLine::trackStateAtPCA
FTS const & trackStateAtPCA() const
Definition: TrajectoryStateClosestToBeamLine.h:32
TrackFromSeedProducer::mfToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
Definition: TrackFromSeedProducer.cc:65
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
GlobalTrackingGeometry.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