CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
TrackCandidateProducer Class Reference

#include <TrackCandidateProducer.h>

Inheritance diagram for TrackCandidateProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &es) override
 
 TrackCandidateProducer (const edm::ParameterSet &conf)
 
virtual ~TrackCandidateProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

unsigned int maxNumberOfCrossedLayers
 
unsigned int minNumberOfCrossedLayers
 
std::string propagatorLabel
 
edm::EDGetTokenT
< SiTrackerGSMatchedRecHit2DCollection
recHitToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View
< TrajectorySeed > > 
seedToken
 
edm::InputTag simTracks_
 
edm::EDGetTokenT
< edm::SimTrackContainer
simTrackToken
 
edm::EDGetTokenT
< edm::SimVertexContainer
simVertexToken
 
bool splitHits
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Definition at line 36 of file TrackCandidateProducer.h.

Constructor & Destructor Documentation

TrackCandidateProducer::TrackCandidateProducer ( const edm::ParameterSet conf)
explicit

Definition at line 43 of file TrackCandidateProducer.cc.

References edm::ParameterSet::getParameter(), minNumberOfCrossedLayers, propagatorLabel, recHitToken, rejectOverlaps, seedToken, simTrackToken, simVertexToken, splitHits, and AlCaHLTBitMon_QueryRunRegistry::string.

44 {
45  // products
46  produces<TrackCandidateCollection>();
47 
48  // general parameters
49  minNumberOfCrossedLayers = conf.getParameter<unsigned int>("MinNumberOfCrossedLayers");
50  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
51  splitHits = conf.getParameter<bool>("SplitHits");
52 
53  // input tags, labels, tokens
54  edm::InputTag simTrackLabel = conf.getParameter<edm::InputTag>("simTracks");
55  simVertexToken = consumes<edm::SimVertexContainer>(simTrackLabel);
56  simTrackToken = consumes<edm::SimTrackContainer>(simTrackLabel);
57 
58  edm::InputTag seedLabel = conf.getParameter<edm::InputTag>("src");
59  seedToken = consumes<edm::View<TrajectorySeed> >(seedLabel);
60 
61  edm::InputTag recHitLabel = conf.getParameter<edm::InputTag>("recHits");
62  recHitToken = consumes<SiTrackerGSMatchedRecHit2DCollection>(recHitLabel);
63 
64  propagatorLabel = conf.getParameter<std::string>("propagator");
65 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
edm::EDGetTokenT< SiTrackerGSMatchedRecHit2DCollection > recHitToken
virtual TrackCandidateProducer::~TrackCandidateProducer ( )
inlinevirtual

Definition at line 42 of file TrackCandidateProducer.h.

42 {;}

Member Function Documentation

void TrackCandidateProducer::produce ( edm::Event e,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 68 of file TrackCandidateProducer.cc.

References clone(), TrajectorySeed::direction(), edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), cmsHarvester::index, TrajectorySeedHitCandidate::isOnTheSameLayer(), TrajectoryStateOnSurface::isValid(), TrajectorySeedHitCandidate::layerNumber(), TrajectorySeedHitCandidate::localError(), LogDebug, HLT_25ns14e33_v1_cff::magneticField, minNumberOfCrossedLayers, TrajectorySeed::nHits(), oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), position, edm::ESHandle< class >::product(), HLT_25ns14e33_v1_cff::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectorySeed::recHits(), HLT_50ns_5e33_v3_cff::recHits, recHitToken, rejectOverlaps, fileCollector::seed, seedToken, simTrackToken, simVertexToken, splitHits, TrajectorySeedHitCandidate::subDetId(), and GeomDet::surface().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

68  {
69 
70  // get services
72  es.get<IdealMagneticFieldRecord>().get(magneticField);
73 
74  edm::ESHandle<TrackerGeometry> trackerGeometry;
75  es.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
76 
77  edm::ESHandle<TrackerTopology> trackerTopology;
78  es.get<TrackerTopologyRcd>().get(trackerTopology);
79 
81  es.get<TrackingComponentsRecord>().get(propagatorLabel,propagator);
82 
83  // get products
85  e.getByToken(seedToken,seeds);
86 
88  e.getByToken(recHitToken, recHits);
89 
91  e.getByToken(simVertexToken,simVertices);
92 
94  e.getByToken(simTrackToken,simTracks);
95 
96  // output collection
97  std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
98 
99  // loop over the seeds
100  for (unsigned seednr = 0; seednr < seeds->size(); ++seednr){
101 
102  const BasicTrajectorySeed seed = seeds->at(seednr);
103  if(seed.nHits()==0){
104  edm::LogError("TrackCandidateProducer") << "empty trajectory seed in TrajectorySeedCollection" << std::endl;
105  return;
106  }
107 
108  // Get all the rechits associated to this track
109  int simTrackId = ((const SiTrackerGSMatchedRecHit2D*) (&*(seed.recHits().first)))->simtrackId();
110  SiTrackerGSMatchedRecHit2DCollection::range recHitRange = recHits->get(simTrackId);
111  SiTrackerGSMatchedRecHit2DCollection::const_iterator recHitIter = recHitRange.first;
112  SiTrackerGSMatchedRecHit2DCollection::const_iterator recHitEnd = recHitRange.second;
113 
114  // Count number of crossed layers, apply overlap rejection
115  std::vector<TrajectorySeedHitCandidate> recHitCandidates;
116  TrajectorySeedHitCandidate recHitCandidate;
117  unsigned numberOfCrossedLayers = 0;
118  for ( ; recHitIter != recHitEnd; ++recHitIter) {
119  recHitCandidate = TrajectorySeedHitCandidate(&(*recHitIter),trackerGeometry.product(),trackerTopology.product());
120  if ( recHitCandidates.size() == 0 || !recHitCandidate.isOnTheSameLayer(recHitCandidates.back()) ) {
121  ++numberOfCrossedLayers;
122  }
123 
124  if( recHitCandidates.size() == 0 || // add the first seeding hit in any case
125  !rejectOverlaps || // without overlap rejection: add each hit
126  recHitCandidate.subDetId() != recHitCandidates.back().subDetId() || // with overlap rejection: only add if hits are not on the same layer
127  recHitCandidate.layerNumber() != recHitCandidates.back().layerNumber() ){
128  recHitCandidates.push_back(recHitCandidate);
129  }
130  else if ( recHitCandidate.localError() < recHitCandidates.back().localError() ){
131  recHitCandidates.back() = recHitCandidate;
132  }
133  }
134  if ( numberOfCrossedLayers < minNumberOfCrossedLayers ) {
135  continue;
136  }
137 
138  // Convert TrajectorySeedHitCandidate to TrackingRecHit and split hits
139  edm::OwnVector<TrackingRecHit> trackRecHits;
140  for ( unsigned index = 0; index<recHitCandidates.size(); ++index ) {
141  if(splitHits && recHitCandidates[index].matchedHit()->isMatched()){
142  trackRecHits.push_back(recHitCandidates[index].matchedHit()->firstHit()->clone());
143  trackRecHits.push_back(recHitCandidates[index].matchedHit()->secondHit()->clone());
144  }
145  else {
146  trackRecHits.push_back(recHitCandidates[index].hit()->clone());
147  }
148  }
149  // reverse order if needed
150  // when is this relevant? perhaps for the cases when track finding goes backwards?
151  if (seed.direction()==oppositeToMomentum){
152  LogDebug("FastTracking")<<"reversing the order of the hits";
153  std::reverse(recHitCandidates.begin(),recHitCandidates.end());
154  }
155 
156  // initial track candidate parameters parameters
157  int vertexIndex = simTracks->at(simTrackId).vertIndex();
158  GlobalPoint position(simVertices->at(vertexIndex).position().x(),
159  simVertices->at(vertexIndex).position().y(),
160  simVertices->at(vertexIndex).position().z());
161  GlobalVector momentum( simTracks->at(simTrackId).momentum().x() ,
162  simTracks->at(simTrackId).momentum().y() ,
163  simTracks->at(simTrackId).momentum().z() );
164  float charge = simTracks->at(simTrackId).charge();
165  GlobalTrajectoryParameters initialParams(position,momentum,(int)charge,magneticField.product());
166  AlgebraicSymMatrix55 errorMatrix= AlgebraicMatrixID();
167  CurvilinearTrajectoryError initialError(errorMatrix);
168  FreeTrajectoryState initialFTS(initialParams, initialError);
169 
170  // create track candidate
171  const GeomDet* initialLayer = trackerGeometry->idToDet(trackRecHits.front().geographicalId());
172  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(initialFTS,initialLayer->surface()) ;
173  if (!initialTSOS.isValid()) continue;
175  TrackCandidate newTrackCandidate(trackRecHits,seed,PTSOD,edm::RefToBase<TrajectorySeed>(seeds,seednr));
176 
177  // add track candidate to output collection
178  output->push_back(newTrackCandidate);
179 
180  }
181 
182  // Save the track candidates
183  e.put(output);
184 }
#define LogDebug(id)
PropagationDirection direction() const
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
std::vector< TrackCandidate > TrackCandidateCollection
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void push_back(D *&d)
Definition: OwnVector.h:280
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
edm::EDGetTokenT< SiTrackerGSMatchedRecHit2DCollection > recHitToken
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
range recHits() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
unsigned int nHits() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int layerNumber() const
The Layer Number.
DetId geographicalId() const
bool isOnTheSameLayer(const TrajectorySeedHitCandidate &other) const
Check if two hits are on the same layer of the same subdetector.
unsigned int subDetId() const
The subdet Id.
reference front()
Definition: OwnVector.h:355

Member Data Documentation

unsigned int TrackCandidateProducer::maxNumberOfCrossedLayers
private

Definition at line 49 of file TrackCandidateProducer.h.

unsigned int TrackCandidateProducer::minNumberOfCrossedLayers
private

Definition at line 48 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 61 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<SiTrackerGSMatchedRecHit2DCollection> TrackCandidateProducer::recHitToken
private

Definition at line 58 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 51 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<edm::View<TrajectorySeed> > TrackCandidateProducer::seedToken
private

Definition at line 57 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::InputTag TrackCandidateProducer::simTracks_
private

Definition at line 54 of file TrackCandidateProducer.h.

edm::EDGetTokenT<edm::SimTrackContainer> TrackCandidateProducer::simTrackToken
private

Definition at line 60 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<edm::SimVertexContainer> TrackCandidateProducer::simVertexToken
private

Definition at line 59 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 52 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().