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 ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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 & itemsToGetFromEvent () 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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

virtual 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
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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 49 of file TrackFromSeedProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file TrackFromSeedProducer.cc.

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

78 {
79  //register your products
80  produces<reco::TrackCollection>();
81  produces<TrackingRecHitCollection>();
82  produces<reco::TrackExtraCollection>();
83 
84  // read parametes
87  tTRHBuilderName = iConfig.getParameter<std::string>("TTRHBuilder");
88 
89  //consumes
90  seedsToken = consumes<edm::View<TrajectorySeed> >(seedsTag);
91  beamSpotToken = consumes<reco::BeamSpot>(beamSpotTag);
92 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
TrackFromSeedProducer::~TrackFromSeedProducer ( )

Definition at line 95 of file TrackFromSeedProducer.cc.

95 {}

Member Function Documentation

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

Definition at line 188 of file TrackFromSeedProducer.cc.

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

188  {
189  //The following says we do not know what parameters are allowed so do no validation
190  // Please change this to state exactly what you do use, even if it is no parameters
192  desc.setUnknown();
193  descriptions.addDefault(desc);
194 }
void addDefault(ParameterSetDescription const &psetDescription)
void TrackFromSeedProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Definition at line 99 of file TrackFromSeedProducer.cc.

References ecalDrivenElectronSeedsParameters_cff::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, l1t::tracks, trajectoryStateTransform::transientState(), and tTRHBuilderName.

100 {
101  using namespace edm;
102  using namespace reco;
103  using namespace std;
104 
105  // output collection
106  unique_ptr<TrackCollection> tracks(new TrackCollection);
107  unique_ptr<TrackingRecHitCollection> rechits(new TrackingRecHitCollection);
108  unique_ptr<TrackExtraCollection> trackextras(new TrackExtraCollection);
109 
110  // product references
111  TrackExtraRefProd ref_trackextras = iEvent.getRefBeforePut<TrackExtraCollection>();
113 
114  // input collection
116  iEvent.getByToken(seedsToken,hseeds);
117  const auto& seeds = *hseeds;
118 
119  // beam spot
121  iEvent.getByToken(beamSpotToken,beamSpot);
122 
123  // some objects to build to tracks
124  TSCBLBuilderNoMaterial tscblBuilder;
125 
127  iSetup.get<TransientRecHitRecord>().get(tTRHBuilderName,tTRHBuilder);
128 
130  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
131 
133  iSetup.get<TrackerTopologyRcd>().get(httopo);
134  const TrackerTopology& ttopo = *httopo;
135 
136  // create tracks from seeds
137  int nfailed = 0;
138  for(size_t iSeed=0; iSeed < seeds.size(); ++iSeed) {
139  auto const& seed = seeds[iSeed];
140  // try to create a track
141  TransientTrackingRecHit::RecHitPointer lastRecHit = tTRHBuilder->build(&*(seed.recHits().second-1));
142  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( seed.startingState(), lastRecHit->surface(), theMF.product());
143  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),*beamSpot);//as in TrackProducerAlgorithm
144  if(tsAtClosestApproachSeed.isValid()) {
145  const reco::TrackBase::Point vSeed1(tsAtClosestApproachSeed.trackStateAtPCA().position().x(),
146  tsAtClosestApproachSeed.trackStateAtPCA().position().y(),
147  tsAtClosestApproachSeed.trackStateAtPCA().position().z());
148  const reco::TrackBase::Vector pSeed(tsAtClosestApproachSeed.trackStateAtPCA().momentum().x(),
149  tsAtClosestApproachSeed.trackStateAtPCA().momentum().y(),
150  tsAtClosestApproachSeed.trackStateAtPCA().momentum().z());
151  //GlobalPoint vSeed(vSeed1.x()-beamSpot->x0(),vSeed1.y()-beamSpot->y0(),vSeed1.z()-beamSpot->z0());
152  PerigeeTrajectoryError seedPerigeeErrors = PerigeeConversions::ftsToPerigeeError(tsAtClosestApproachSeed.trackStateAtPCA());
153  tracks->emplace_back(0.,0., vSeed1, pSeed, state.charge(), seedPerigeeErrors.covarianceMatrix());
154  }
155  else {
156  edm::LogVerbatim("SeedValidator")<<"TrajectoryStateClosestToBeamLine not valid";
157  // use magic values chi2<0, ndof<0, charge=0 to denote a case where the fit has failed
158  // If this definition is changed, change also interface/trackFromSeedFitFailed.h
160  nfailed++;
161  }
162 
163  tracks->back().appendHits(seed.recHits().first,seed.recHits().second,ttopo);
164  // store the hits
165  size_t firsthitindex = rechits->size();
166  for(auto hitit = seed.recHits().first;hitit != seed.recHits().second;++hitit){
167  rechits->push_back(*hitit);
168  }
169 
170  // create a trackextra, just to store the hit range
171  trackextras->push_back(TrackExtra());
172  trackextras->back().setHits(ref_rechits,firsthitindex,rechits->size() - firsthitindex);
173  trackextras->back().setSeedRef(edm::RefToBase<TrajectorySeed>(hseeds, iSeed));
174  // create link between track and trackextra
175  tracks->back().setExtra( TrackExtraRef( ref_trackextras, trackextras->size() - 1) );
176  }
177 
178  if (nfailed > 0) {
179  edm::LogInfo("SeedValidator") << "failed to create tracks from " << nfailed << " out of " << seeds.size() << " seeds ";
180  }
181  iEvent.put(std::move(tracks));
182  iEvent.put(std::move(rechits));
183  iEvent.put(std::move(trackextras));
184 }
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedsToken
FreeTrajectoryState const * freeState(bool withErrors=true) const
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
std::shared_ptr< TrackingRecHit const > RecHitPointer
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
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:11
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const T & get() const
Definition: EventSetup.h:56
fixed size matrix
HLT enums.
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:80
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:77

Member Data Documentation

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

Definition at line 61 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().

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

Definition at line 60 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().

std::string TrackFromSeedProducer::tTRHBuilderName
private

Definition at line 62 of file TrackFromSeedProducer.cc.

Referenced by produce(), and TrackFromSeedProducer().