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

bool hitMasks_exists
 
edm::EDGetTokenT< std::vector
< bool > > 
hitMasksToken
 
FastTrackerRecHitSplitter hitSplitter
 
unsigned int maxNumberOfCrossedLayers
 
unsigned int minNumberOfCrossedLayers
 
std::string propagatorLabel
 
edm::EDGetTokenT
< FastTrackerRecHitCombinationCollection
recHitCombinationsToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View
< TrajectorySeed > > 
seedToken
 
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 18 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::exists(), edm::ParameterSet::getParameter(), hitMasks_exists, hitMasksToken, minNumberOfCrossedLayers, propagatorLabel, recHitCombinationsToken, rejectOverlaps, seedToken, simTrackToken, simVertexToken, splitHits, and AlCaHLTBitMon_QueryRunRegistry::string.

44  : hitSplitter()
45 {
46  // products
47  produces<TrackCandidateCollection>();
48 
49  // general parameters
50  minNumberOfCrossedLayers = conf.getParameter<unsigned int>("MinNumberOfCrossedLayers");
51  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
52  splitHits = conf.getParameter<bool>("SplitHits");
53 
54  // input tags, labels, tokens
55  hitMasks_exists = conf.exists("hitMasks");
56  if (hitMasks_exists){
57  hitMasksToken = consumes<std::vector<bool> >(conf.getParameter<edm::InputTag>("hitMasks"));
58  }
59 
60  edm::InputTag simTrackLabel = conf.getParameter<edm::InputTag>("simTracks");
61  simVertexToken = consumes<edm::SimVertexContainer>(simTrackLabel);
62  simTrackToken = consumes<edm::SimTrackContainer>(simTrackLabel);
63 
64  edm::InputTag seedLabel = conf.getParameter<edm::InputTag>("src");
65  seedToken = consumes<edm::View<TrajectorySeed> >(seedLabel);
66 
67  edm::InputTag recHitCombinationsLabel = conf.getParameter<edm::InputTag>("recHitCombinations");
68  recHitCombinationsToken = consumes<FastTrackerRecHitCombinationCollection>(recHitCombinationsLabel);
69 
70  propagatorLabel = conf.getParameter<std::string>("propagator");
71 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
bool exists(std::string const &parameterName) const
checks if a parameter exists
FastTrackerRecHitSplitter hitSplitter
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
virtual TrackCandidateProducer::~TrackCandidateProducer ( )
inlinevirtual

Definition at line 24 of file TrackCandidateProducer.h.

24 {;}

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 74 of file TrackCandidateProducer.cc.

References clone(), PTrajectoryStateOnDet::detId(), TrajectorySeed::direction(), Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), fastTrackingHelper::getRecHitCombinationIndex(), hitMasks_exists, hitMasksToken, hitSplitter, 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(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), HLT_25ns14e33_v1_cff::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), recHitCombinationsToken, rejectOverlaps, fileCollector::seed, seedToken, fastTrackingHelper::setRecHitCombinationIndex(), simTrackToken, simVertexToken, FastTrackerRecHitSplitter::split(), splitHits, TrajectorySeed::startingState(), TrajectorySeedHitCandidate::subDetId(), TrajectoryStateOnSurface::surface(), and trajectoryStateTransform::transientState().

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

74  {
75 
76  // get services
78  es.get<IdealMagneticFieldRecord>().get(magneticField);
79 
80  edm::ESHandle<TrackerGeometry> trackerGeometry;
81  es.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
82 
83  edm::ESHandle<TrackerTopology> trackerTopology;
84  es.get<TrackerTopologyRcd>().get(trackerTopology);
85 
87  es.get<TrackingComponentsRecord>().get(propagatorLabel,propagator);
88  // Propagator* thePropagator = propagator.product()->clone();
89 
90  // get products
92  e.getByToken(seedToken,seeds);
93 
95  e.getByToken(recHitCombinationsToken, recHitCombinations);
96 
98  e.getByToken(simVertexToken,simVertices);
99 
101  e.getByToken(simTrackToken,simTracks);
102 
103  // the hits to be skipped
104  std::unique_ptr<HitMaskHelper> hitMaskHelper;
105  if (hitMasks_exists == true){
107  e.getByToken(hitMasksToken,hitMasks);
108  hitMaskHelper.reset(new HitMaskHelper(hitMasks.product()));
109  }
110 
111  // output collection
112  std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
113 
114  // loop over the seeds
115  for (unsigned seednr = 0; seednr < seeds->size(); ++seednr){
116 
117 
118  const TrajectorySeed seed = (*seeds)[seednr];
119  if(seed.nHits()==0){
120  edm::LogError("TrackCandidateProducer") << "empty trajectory seed in TrajectorySeedCollection: skip" << std::endl;
121  continue;
122  }
123 
124  // Get the combination of hits that produced the seed
125  int32_t icomb = fastTrackingHelper::getRecHitCombinationIndex(seed);
126  if(icomb < 0 || unsigned(icomb) >= recHitCombinations->size()){
127  throw cms::Exception("TrackCandidateProducer") << " found seed with recHitCombination out or range: " << icomb << std::endl;
128  }
129  const FastTrackerRecHitCombination & recHitCombination = (*recHitCombinations)[icomb];
130 
131  // select hits, temporarily store as TrajectorySeedHitCandidates
132  std::vector<TrajectorySeedHitCandidate> recHitCandidates;
133  TrajectorySeedHitCandidate recHitCandidate;
134  unsigned numberOfCrossedLayers = 0;
135  for (const auto & _hit : recHitCombination) {
136 
137 
138  // apply hit masking
139  if(hitMaskHelper
140  && hitMaskHelper->mask(_hit.get())){
141  continue;
142  }
143 
144  recHitCandidate = TrajectorySeedHitCandidate(_hit.get(),trackerGeometry.product(),trackerTopology.product());
145  if ( recHitCandidates.size() == 0 || !recHitCandidate.isOnTheSameLayer(recHitCandidates.back()) ) {
146  ++numberOfCrossedLayers;
147  }
148 
149  // hit selection
150  // - always select first hit
151  if( recHitCandidates.size() == 0 ) {
152  recHitCandidates.push_back(recHitCandidate);
153  }
154  // - in case of *no* verlap rejection: select all hits
155  else if( !rejectOverlaps) {
156  recHitCandidates.push_back(recHitCandidate);
157  }
158  // - in case of overlap rejection:
159  // - select hit if it is not on same layer as previous hit
160  else if( recHitCandidate.subDetId() != recHitCandidates.back().subDetId() ||
161  recHitCandidate.layerNumber() != recHitCandidates.back().layerNumber() ) {
162  recHitCandidates.push_back(recHitCandidate);
163  }
164  // - in case of overlap rejection and hit is on same layer as previous hit
165  // - replace previous hit with current hit if it has better precision
166  else if ( recHitCandidate.localError() < recHitCandidates.back().localError() ){
167  recHitCandidates.back() = recHitCandidate;
168 
169  }
170  }
171 
172  // TODO: verify it makes sense to have this selection
173  if ( numberOfCrossedLayers < minNumberOfCrossedLayers ) {
174  continue;
175  }
176 
177  // Convert TrajectorySeedHitCandidate to TrackingRecHit and split hits
178  edm::OwnVector<TrackingRecHit> trackRecHits;
179  for ( unsigned index = 0; index<recHitCandidates.size(); ++index ) {
180  if(splitHits){
181  hitSplitter.split(*recHitCandidates[index].hit(),trackRecHits);
182  }
183  else {
184  trackRecHits.push_back(recHitCandidates[index].hit()->clone());
185  }
186  }
187 
188  // order hits along the seed direction
189  if (seed.direction()==oppositeToMomentum){
190  LogDebug("FastTracking")<<"reversing the order of the hits";
191  std::reverse(recHitCandidates.begin(),recHitCandidates.end());
192  }
193 
194  // set the recHitCombinationIndex
196 
197  // create track candidate state
198  // - get seed state
199  DetId seedDetId(seed.startingState().detId());
200  const GeomDet* gdet = trackerGeometry->idToDet(seedDetId);
201  TrajectoryStateOnSurface seedTSOS = trajectoryStateTransform::transientState(seed.startingState(), &(gdet->surface()),magneticField.product());
202  // - backPropagate seedState to first recHit
203  const GeomDet* initialLayer = trackerGeometry->idToDet(trackRecHits.front().geographicalId());
204  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(seedTSOS,initialLayer->surface()) ;
205  // - check validity and transform
206  if (!initialTSOS.isValid()) continue;
208 
209  // add track candidate to output collection
210  output->push_back(TrackCandidate(trackRecHits,seed,PTSOD,edm::RefToBase<TrajectorySeed>(seeds,seednr)));
211  }
212 
213  // Save the track candidates
214  e.put(output);
215 
216 }
#define LogDebug(id)
PropagationDirection direction() const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
std::vector< TrackCandidate > TrackCandidateCollection
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
void split(const FastTrackerRecHit &hitIn, edm::OwnVector< TrackingRecHit > &hitsOut) const
FastTrackerRecHitSplitter hitSplitter
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void push_back(D *&d)
Definition: OwnVector.h:280
const SurfaceType & surface() const
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
unsigned int detId() const
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
Definition: DetId.h:18
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
unsigned int nHits() const
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
unsigned int layerNumber() const
The Layer Number.
DetId geographicalId() const
int32_t getRecHitCombinationIndex(const T &object)
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

bool TrackCandidateProducer::hitMasks_exists
private

Definition at line 35 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<std::vector<bool> > TrackCandidateProducer::hitMasksToken
private

Definition at line 44 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

FastTrackerRecHitSplitter TrackCandidateProducer::hitSplitter
private

Definition at line 37 of file TrackCandidateProducer.h.

Referenced by produce().

unsigned int TrackCandidateProducer::maxNumberOfCrossedLayers
private

Definition at line 31 of file TrackCandidateProducer.h.

unsigned int TrackCandidateProducer::minNumberOfCrossedLayers
private

Definition at line 30 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 45 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<FastTrackerRecHitCombinationCollection> TrackCandidateProducer::recHitCombinationsToken
private

Definition at line 41 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 33 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 40 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 43 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 42 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 34 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().