CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TrackFromSeedProducer Class Reference

#include <FastSimulation/TrackFromSeedProducer/plugins/TrackFromSeedProducer.cc>

Inheritance diagram for TrackFromSeedProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TrackFromSeedProducer (const edm::ParameterSet &)
 
 ~TrackFromSeedProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
 
std::string tTRHBuilderName
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file TrackFromSeedProducer.cc.

Constructor & Destructor Documentation

TrackFromSeedProducer::TrackFromSeedProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 75 of file TrackFromSeedProducer.cc.

References AlignmentProducer_cff::beamSpotTag, beamSpotToken, edm::ParameterSet::getParameter(), uncleanedOnlyElectronSequence_cff::seedsTag, seedsToken, AlCaHLTBitMon_QueryRunRegistry::string, and tTRHBuilderName.

75  {
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 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
TrackFromSeedProducer::~TrackFromSeedProducer ( )
override

Definition at line 91 of file TrackFromSeedProducer.cc.

91 {}

Member Function Documentation

void TrackFromSeedProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 185 of file TrackFromSeedProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

185  {
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 }
void addDefault(ParameterSetDescription const &psetDescription)
void TrackFromSeedProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 94 of file TrackFromSeedProducer.cc.

References pwdgSkimBPark_cfi::beamSpot, beamSpotToken, TransientTrackingRecHitBuilder::build(), TrajectoryStateOnSurface::charge(), TrajectoryStateOnSurface::freeState(), PerigeeConversions::ftsToPerigeeError(), edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), eostools::move(), edm::ESHandle< T >::product(), edm::Event::put(), TrackInfoProducer_cfi::rechits, SurveyInfoScenario_cff::seed, seedsToken, PDWG_EXOHSCP_cff::tracks, trajectoryStateTransform::transientState(), and tTRHBuilderName.

94  {
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>();
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().second - 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().first, seed.recHits().second, ttopo);
161  // store the hits
162  size_t firsthitindex = rechits->size();
163  for (auto hitit = seed.recHits().first; hitit != seed.recHits().second; ++hitit) {
164  rechits->push_back(*hitit);
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 }
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
FreeTrajectoryState const * freeState(bool withErrors=true) const
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
std::shared_ptr< TrackingRecHit const > RecHitPointer
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:77
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> TrackFromSeedProducer::beamSpotToken
private

Definition at line 60 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().

edm::EDGetTokenT<edm::View<TrajectorySeed> > TrackFromSeedProducer::seedsToken
private

Definition at line 59 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().

std::string TrackFromSeedProducer::tTRHBuilderName
private

Definition at line 61 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().