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 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 beginRun (edm::Run const &run, const edm::EventSetup &es) override
 
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
 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 Member Functions

void addSplitHits (const TrajectorySeedHitCandidate &, std::vector< TrajectorySeedHitCandidate > &)
 

Private Attributes

double estimatorCut_
 
edm::InputTag hitProducer
 
unsigned int maxNumberOfCrossedLayers
 
unsigned int minNumberOfCrossedLayers
 
edm::EDGetTokenT
< SiTrackerGSMatchedRecHit2DCollection
recHitToken
 
bool rejectOverlaps
 
bool seedCleaning
 
edm::InputTag seedProducer
 
edm::EDGetTokenT< edm::View
< TrajectorySeed > > 
seedToken
 
edm::InputTag simTracks_
 
edm::EDGetTokenT
< edm::SimTrackContainer
simTrackToken
 
edm::EDGetTokenT
< edm::SimVertexContainer
simVertexToken
 
bool splitHits
 
const TrackerGeometrytheGeometry
 
const MagneticFieldtheMagField
 
PropagatorWithMaterialthePropagator
 
std::vector< edm::InputTagtrackProducers
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 48 of file TrackCandidateProducer.cc.

References assert(), gather_cfg::cout, estimatorCut_, edm::ParameterSet::exists(), cmsRelvalreport::exit, edm::ParameterSet::getParameter(), hitProducer, maxNumberOfCrossedLayers, minNumberOfCrossedLayers, recHitToken, rejectOverlaps, seedCleaning, seedProducer, seedToken, simTracks_, simTrackToken, simVertexToken, and splitHits.

48  :thePropagator(0)
49 {
50 #ifdef FAMOS_DEBUG
51  std::cout << "TrackCandidateProducer created" << std::endl;
52 #endif
53 
54  if(conf.exists("keepFittedTracks")){
55  std::cout << "TrackCandidateProducer no longer supports option keepFittedTracks" << std::endl;
56  assert(false);
57  }
58  if(conf.exists("TrackProducers")){
59  edm::LogError("TrackCandidateProducer") << "TrackCandidateProducer no longer supports TrackProducers" << std::endl;
60  exit (0);
61  }
62 
63  // The main product is a track candidate collection.
64  produces<TrackCandidateCollection>();
65 
66  // The name of the seed producer
67  seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
68 
69  // The name of the recHit producer
70  hitProducer = conf.getParameter<edm::InputTag>("HitProducer");
71 
72  // The minimum number of crossed layers
73  minNumberOfCrossedLayers = conf.getParameter<unsigned int>("MinNumberOfCrossedLayers");
74 
75  // The maximum number of crossed layers
76  maxNumberOfCrossedLayers = conf.getParameter<unsigned int>("MaxNumberOfCrossedLayers");
77 
78  // Reject overlapping hits?
79  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
80 
81  // Split hits ?
82  splitHits = conf.getParameter<bool>("SplitHits");
83 
84  // Reject tracks with several seeds ?
85  // Typically don't do that at HLT for electrons, but do it otherwise
86  seedCleaning = conf.getParameter<bool>("SeedCleaning");
87 
88  simTracks_ = conf.getParameter<edm::InputTag>("SimTracks");
89  estimatorCut_= conf.getParameter<double>("EstimatorCut");
90 
91  // consumes
92  seedToken = consumes<edm::View<TrajectorySeed> >(seedProducer);
93  recHitToken = consumes<SiTrackerGSMatchedRecHit2DCollection>(hitProducer);
94  edm::InputTag _label("famosSimHits");
95  simVertexToken = consumes<edm::SimVertexContainer>(_label);
96  simTrackToken = consumes<edm::SimTrackContainer>(_label);
97 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
assert(m_qm.get())
bool exists(std::string const &parameterName) const
checks if a parameter exists
PropagatorWithMaterial * thePropagator
edm::EDGetTokenT< SiTrackerGSMatchedRecHit2DCollection > recHitToken
tuple cout
Definition: gather_cfg.py:121
TrackCandidateProducer::~TrackCandidateProducer ( )
virtual

Definition at line 100 of file TrackCandidateProducer.cc.

References thePropagator.

100  {
101 
102  if(thePropagator) delete thePropagator;
103 }
PropagatorWithMaterial * thePropagator

Member Function Documentation

void TrackCandidateProducer::addSplitHits ( const TrajectorySeedHitCandidate theCurrentRecHit,
std::vector< TrajectorySeedHitCandidate > &  theTrackerRecHits 
)
private

Definition at line 462 of file TrackCandidateProducer.cc.

References TrajectorySeedHitCandidate::matchedHit(), SiTrackerGSMatchedRecHit2D::monoHit(), SiTrackerGSRecHit2D::simhitId(), and SiTrackerGSMatchedRecHit2D::stereoHit().

Referenced by produce().

463  {
464 
465  const SiTrackerGSRecHit2D* mHit = theCurrentRecHit.matchedHit()->monoHit();
466  const SiTrackerGSRecHit2D* sHit = theCurrentRecHit.matchedHit()->stereoHit();
467 
468  // Add the new hits
469  if( mHit->simhitId() < sHit->simhitId() ) {
470 
471  theTrackerRecHits.push_back(TrajectorySeedHitCandidate(mHit,theCurrentRecHit));
472  theTrackerRecHits.push_back(TrajectorySeedHitCandidate(sHit,theCurrentRecHit));
473 
474  } else {
475 
476  theTrackerRecHits.push_back(TrajectorySeedHitCandidate(sHit,theCurrentRecHit));
477  theTrackerRecHits.push_back(TrajectorySeedHitCandidate(mHit,theCurrentRecHit));
478 
479  }
480 }
const int & simhitId() const
const SiTrackerGSRecHit2D * stereoHit() const
const SiTrackerGSRecHit2D * monoHit() const
const SiTrackerGSMatchedRecHit2D * matchedHit() const
The Hit itself.
void TrackCandidateProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup es 
)
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 106 of file TrackCandidateProducer.cc.

References alongMomentum, geometry, edm::EventSetup::get(), theGeometry, theMagField, and thePropagator.

106  {
107 
108  //services
111 
112  es.get<IdealMagneticFieldRecord>().get(magField);
113  es.get<TrackerDigiGeometryRecord>().get(geometry);
114 
115  theMagField = &(*magField);
116  theGeometry = &(*geometry);
117 
119 }
const MagneticField * theMagField
PropagatorWithMaterial * thePropagator
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
const TrackerGeometry * theGeometry
void TrackCandidateProducer::produce ( edm::Event e,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 123 of file TrackCandidateProducer.cc.

References addSplitHits(), PV3DBase< T, PVType, FrameType >::basicVector(), funct::C, CoreSimTrack::charge(), TrackingRecHit::clone(), gather_cfg::cout, TrajectoryStateOnSurface::curvilinearError(), PTrajectoryStateOnDet::detId(), TrajectorySeed::direction(), Basic3DVector< T >::dot(), estimatorCut_, edm::OwnVector< T, P >::front(), g, TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), TrajectoryStateOnSurface::globalPosition(), TrackingRecHit::hit(), TrackerGeometry::idToDet(), SiTrackerGSMatchedRecHit2D::isMatched(), TrajectorySeedHitCandidate::isOnTheSameLayer(), TrajectoryStateOnSurface::isValid(), TrajectorySeedHitCandidate::layerNumber(), TrajectoryStateOnSurface::localError(), TrajectorySeedHitCandidate::localError(), TrajectoryStateOnSurface::localParameters(), LogDebug, visualization-live-secondInstance_cfg::m, TrajectorySeedHitCandidate::matchedHit(), LocalTrajectoryError::matrix(), CurvilinearTrajectoryError::matrix(), maxNumberOfCrossedLayers, minNumberOfCrossedLayers, FreeTrajectoryState::momentum(), TrajectorySeed::nHits(), oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), position, edm::ESHandle< class >::product(), Propagator::propagate(), HLT_25ns14e33_v1_cff::propagator, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectorySeed::recHits(), HLT_25ns14e33_v3_cff::recHits, recHitToken, rejectOverlaps, edm::OwnVector< T, P >::reserve(), seedCleaning, seedProducer, seedToken, SiTrackerGSMatchedRecHit2D::simtrackId(), simTrackToken, simVertexToken, splitHits, TrajectorySeed::startingState(), TrajectorySeedHitCandidate::subDetId(), GeomDet::surface(), TrajectoryStateOnSurface::surface(), theGeometry, theMagField, thePropagator, SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), trajectoryStateTransform::transientState(), findQualityFiles::v, LocalTrajectoryParameters::vector(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

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

123  {
124 
125  // Useful typedef's to avoid retyping
126  typedef std::pair<reco::TrackRef,edm::Ref<std::vector<Trajectory> > > TrackPair;
127 
128  // The produced objects
129  std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
130 
131  // Get the seeds
133  e.getByToken(seedToken,theSeeds);
134 
135  //Retrieve tracker topology from geometry
137  es.get<IdealGeometryRecord>().get(tTopoHand);
138  const TrackerTopology *tTopo=tTopoHand.product();
139 
140 
141  // No seed -> output an empty track collection
142  if(theSeeds->size() == 0) {
143  e.put(output);
144  return;
145  }
146 
147  // Get the GS RecHits
149  e.getByToken(recHitToken, theGSRecHits);
150 
151  //get other general things
152  const std::vector<unsigned> theSimTrackIds = theGSRecHits->ids();
153 
154  // SimTracks and SimVertices
156  e.getByToken(simVertexToken,theSimVtx);
158  e.getByToken(simTrackToken,theSTC);
159 
160  const edm::SimTrackContainer* theSimTracks = &(*theSTC);
161  LogDebug("FastTracking")<<"looking at: "<< theSimTrackIds.size()<<" simtracks.";
162 
163  // Loop over the seeds
164  int currentTrackId = -1;
165 
166 #ifdef FAMOS_DEBUG
167  std::cout << "Input seed Producer : " << seedProducer << std::endl;
168  std::cout << "Number of seeds : " << theSeeds->size() << std::endl;
169 #endif
170  unsigned seed_size = theSeeds->size();
171  for (unsigned seednr = 0; seednr < seed_size; ++seednr){
172 
173  LogDebug("FastTracking")<<"looking at seed #:"<<seednr;
174 
175  // The seed
176  const BasicTrajectorySeed* aSeed = &((*theSeeds)[seednr]);
177 
178  std::vector<int> simTrackIds;
179  std::map<int,TrajectoryStateOnSurface> seedStates;
180  std::map<int,TrajectoryStateOnSurface> simtkStates;
181 
182  TrajectorySeedHitCandidate theFirstSeedingTrackerRecHit;
183  if (theSeeds->at(seednr).nHits()==0){
184  //new stuff for no hits on seed
185 
186  LogDebug("FastTracking")<<" seed with no hits to be considered.";
187 
188  PTrajectoryStateOnDet ptod =theSeeds->at(seednr).startingState();
189  DetId id(ptod.detId());
190  const GeomDet * g = theGeometry->idToDet(id);
191  const Surface * surface=&g->surface();
192 
194 
196  es.get<TrackingComponentsRecord>().get("AnyDirectionAnalyticalPropagator",propagator);
197 
198  double minimunEst=1000000;
199  LogDebug("FastTracking")<<"looking at: "<< theSimTrackIds.size()<<" simtracks.";
200  for ( unsigned tkId=0; tkId != theSimTrackIds.size(); ++tkId ) {
201 
202  const SimTrack & simtrack = (*theSimTracks)[theSimTrackIds[tkId]];
203 
205  simtrack.trackerSurfacePosition().y(),
206  simtrack.trackerSurfacePosition().z());
207 
208  GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(),
209  simtrack.trackerSurfaceMomentum().y(),
210  simtrack.trackerSurfaceMomentum().z());
211 
212  if (position.basicVector().dot( momentum.basicVector() ) * seedState.globalPosition().basicVector().dot(seedState.globalMomentum().basicVector()) <0. ){
213  LogDebug("FastTracking")<<"not on the same direction.";
214  continue;
215  }
216 
217  //no charge mis-identification ... FIXME
218  int charge = (int) simtrack.charge();
219  GlobalTrajectoryParameters glb_parameters(position,
220  momentum,
221  charge,
222  theMagField);
223  FreeTrajectoryState simtrack_trackerstate(glb_parameters);
224 
225  TrajectoryStateOnSurface simtrack_comparestate = propagator->propagate(simtrack_trackerstate,*surface);
226 
227 
228  if (!simtrack_comparestate.isValid()){
229  LogDebug("FastTracking")<<" ok this is a state-based seed. simtrack state does not propagate to the seed surface. skipping.";
230  continue;}
231 
232  if (simtrack_comparestate.globalPosition().basicVector().dot(simtrack_comparestate.globalMomentum().basicVector()) * seedState.globalPosition().basicVector().dot(seedState.globalMomentum().basicVector()) <0. ){
233  LogDebug("FastTracking")<<"not on the same direction.";
234  continue;
235  }
236 
237  AlgebraicVector5 v(seedState.localParameters().vector() - simtrack_comparestate.localParameters().vector());
238  AlgebraicSymMatrix55 m(seedState.localError().matrix());
239  bool ierr = !m.Invert();
240  if ( ierr ){
241  edm::LogWarning("FastTracking") <<" Candidate Producer cannot invert the error matrix! - Skipping...";
242  continue;
243  }
244  double est = ROOT::Math::Similarity(v,m);
245  LogDebug("FastTracking")<<"comparing two state on the seed surface:\n"
246  <<"seed: "<<seedState
247  <<"sim: "<<simtrack_comparestate
248  <<"\n estimator is: "<<est;
249 
250  if (est<minimunEst) minimunEst=est;
251  if (est<estimatorCut_){
252  simTrackIds.push_back(theSimTrackIds[tkId]);
253  //making a state with exactly the sim track parameters
254  //the initial errors are set to unity just for kicks
255  // AlgebraicSymMatrix C(5,1);// C*=50;
256  //new attempt!!!!
257  AlgebraicSymMatrix55 C = seedState.curvilinearError().matrix();
258  C *= 0.0000001;
259 
260  seedStates[theSimTrackIds[tkId]] = TrajectoryStateOnSurface(simtrack_comparestate.globalParameters(),
262  seedState.surface());
263  LogDebug("FastTracking")<<"the compatibility estimator is: "<<est<<" for track id: "<<simTrackIds.back();
264  }
265  }//SimTrack loop
266  if (simTrackIds.size()==0) LogDebug("FastTracking")<<"could not find any simtrack within errors, closest was at: "<<minimunEst;
267  }//seed has 0 hit.
268  else{
269  //same old stuff
270  // Find the first hit of the Seed
271  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
272  const SiTrackerGSMatchedRecHit2D * theFirstSeedingRecHit = (const SiTrackerGSMatchedRecHit2D*) (&(*(theSeedingRecHitRange.first)));
273  theFirstSeedingTrackerRecHit = TrajectorySeedHitCandidate(theFirstSeedingRecHit,theGeometry,tTopo);
274  // The SimTrack id associated to that recHit
275  simTrackIds.push_back( theFirstSeedingRecHit->simtrackId() );
276  }
277 
278  //from then on, only the simtrack IDs are usefull.
279  //now loop over all possible trackid for this seed.
280  //an actual seed can be shared by two tracks in dense envirronement, and also for hit-less seeds.
281  for (unsigned int iToMake=0;iToMake!=simTrackIds.size();++iToMake){
282  int simTrackId = simTrackIds[iToMake];
283 
284  // Don't consider seeds belonging to a track already considered
285  // (Equivalent to seed cleaning)
286  if ( seedCleaning && currentTrackId == simTrackId ) continue;
287  currentTrackId = simTrackId;
288 
289  // A vector of TrackerRecHits belonging to the track and the number of crossed layers
290  std::vector<TrajectorySeedHitCandidate> theTrackerRecHits;
291  unsigned theNumberOfCrossedLayers = 0;
292 
293  LogDebug("FastTracking")<<"Track " << simTrackId << " is considered to return a track candidate" ;
294 
295  // Get all the rechits associated to this track
296  SiTrackerGSMatchedRecHit2DCollection::range theRecHitRange = theGSRecHits->get(simTrackId);
297  SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorBegin = theRecHitRange.first;
298  SiTrackerGSMatchedRecHit2DCollection::const_iterator theRecHitRangeIteratorEnd = theRecHitRange.second;
300 
301  LogDebug("FastTracking")<<"counting: "<<theRecHitRangeIteratorEnd-theRecHitRangeIteratorBegin<<" hits to be considered.";
302 
303  bool firstRecHit = true;
304  TrajectorySeedHitCandidate theCurrentRecHit, thePreviousRecHit;
305  TrajectorySeedHitCandidate theFirstHitComp, theSecondHitComp;
306 
307  for ( iterRecHit = theRecHitRangeIteratorBegin;
308  iterRecHit != theRecHitRangeIteratorEnd;
309  ++iterRecHit) {
310 
311  // Check the number of crossed layers
312  if ( theNumberOfCrossedLayers >= maxNumberOfCrossedLayers ) continue;
313 
314  // Get current and previous rechits
315  if(!firstRecHit) thePreviousRecHit = theCurrentRecHit;
316  theCurrentRecHit = TrajectorySeedHitCandidate(&(*iterRecHit),theGeometry,tTopo);
317 
318  //>>>>>>>>>BACKBUILDING CHANGE: DO NOT STAT FROM THE FIRST HIT OF THE SEED
319 
320  // NOTE: checking the direction --> specific for OIHit only
321  // if( aSeed->direction()!=oppositeToMomentum ) {
322  // // Check that the first rechit is indeed the first seeding hit
323  // if ( firstRecHit && theCurrentRecHit != theFirstSeedingTrackerRecHit && theSeeds->at(seednr).nHits()!=0 ) continue;
324  // }
325  //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
326 
327  // Count the number of crossed layers
328  if ( !theCurrentRecHit.isOnTheSameLayer(thePreviousRecHit) )
329  ++theNumberOfCrossedLayers;
330 
331  // Add all rechits (Grouped Trajectory Builder) from this hit onwards
332  // Always add the first seeding rechit anyway
333  if ( !rejectOverlaps || firstRecHit ) {
334  // Split matched hits (if requested / possible )
335  if ( splitHits && theCurrentRecHit.matchedHit()->isMatched() ) addSplitHits(theCurrentRecHit,theTrackerRecHits);
336  else theTrackerRecHits.push_back(theCurrentRecHit); // No splitting
337  firstRecHit = false;
338 
339  // And now treat the following RecHits if hits in the same layer
340  // have to be rejected - The split option is not
341  } else {
342 
343  // Not the same layer : Add the current hit
344  if ( theCurrentRecHit.subDetId() != thePreviousRecHit.subDetId() ||
345  theCurrentRecHit.layerNumber() != thePreviousRecHit.layerNumber() ) {
346 
347  // Split matched hits (if requested / possible )
348  if ( splitHits && theCurrentRecHit.matchedHit()->isMatched() ) addSplitHits(theCurrentRecHit,theTrackerRecHits);
349  else theTrackerRecHits.push_back(theCurrentRecHit); // No splitting
350 
351  // Same layer : keep the current hit if better, and drop the other - otherwise do nothing
352  } else if ( theCurrentRecHit.localError() < thePreviousRecHit.localError() ) {
353 
354  // Split matched hits (if requested / possible )
355  if( splitHits && theCurrentRecHit.matchedHit()->isMatched() ){
356  // Remove the previous hit(s)
357  theTrackerRecHits.pop_back();
358  if ( thePreviousRecHit.matchedHit()->isMatched() ) theTrackerRecHits.pop_back();
359 
360  // Replace by the new hits
361  addSplitHits(theCurrentRecHit,theTrackerRecHits);
362  }
363  // No splitting
364  else {
365  theTrackerRecHits.back() = theCurrentRecHit; // Replace the previous hit by the current hit
366  }
367 
368  } else {
369 
370  //keep the older rechit as a reference if the error of the new one is worse
371  theCurrentRecHit = thePreviousRecHit;
372  }
373  }
374  }// End of loop over the track rechits
375 
376 
377  LogDebug("FastTracking")<<" number of hits: " << theTrackerRecHits.size()<<" after counting overlaps and splitting.";
378 
379  // 1) Create the OwnVector of TrackingRecHits
381  unsigned nTrackerHits = theTrackerRecHits.size();
382  recHits.reserve(nTrackerHits); // To save some time at push_back
383 
384  if (aSeed->direction()==oppositeToMomentum){
385  LogDebug("FastTracking")<<"reversing the order of the hits";
386  std::reverse(theTrackerRecHits.begin(),theTrackerRecHits.end());
387  }
388 
389  for ( unsigned ih=0; ih<nTrackerHits; ++ih ) {
390  TrackingRecHit* aTrackingRecHit = theTrackerRecHits[ih].hit()->clone();
391  recHits.push_back(aTrackingRecHit);
392 
393  }//loop over the rechits
394 
395  // Check the number of crossed layers
396  if ( theNumberOfCrossedLayers < minNumberOfCrossedLayers ) {
397  LogDebug("FastTracking")<<"not enough layer crossed ("<<theNumberOfCrossedLayers<<")";
398  continue;
399  }
400 
401  //>>>>>>>>>BACKBUILDING CHANGE: REPLACE THE STARTING STATE
402 
403  // Create a track Candidate (now with the reference to the seed!) .
404  //PTrajectoryStateOnDet PTSOD = aSeed->startingState();
405  PTrajectoryStateOnDet PTSOD;
406 
407  if (aSeed->nHits()==0){
408  //stabilize the fit with the true simtrack state
409  //in case of zero hits
410 
411  PTSOD = trajectoryStateTransform::persistentState(seedStates[simTrackId],aSeed->startingState().detId());
412 
413  } else {
414  //create the initial state from the SimTrack
415  int vertexIndex = (*theSimTracks)[currentTrackId].vertIndex();
416  // a) origin vertex
417  GlobalPoint position((*theSimVtx)[vertexIndex].position().x(),
418  (*theSimVtx)[vertexIndex].position().y(),
419  (*theSimVtx)[vertexIndex].position().z());
420 
421  // b) initial momentum
422  GlobalVector momentum( (*theSimTracks)[currentTrackId].momentum().x() ,
423  (*theSimTracks)[currentTrackId].momentum().y() ,
424  (*theSimTracks)[currentTrackId].momentum().z() );
425  // c) electric charge
426  float charge = (*theSimTracks)[simTrackId].charge();
427  // -> inital parameters
428  GlobalTrajectoryParameters initialParams(position,momentum,(int)charge,theMagField);
429  // -> large initial errors
430  AlgebraicSymMatrix55 errorMatrix= AlgebraicMatrixID();
431  CurvilinearTrajectoryError initialError(errorMatrix);
432  // -> initial state
433  FreeTrajectoryState initialFTS(initialParams, initialError);
434 #ifdef FAMOS_DEBUG
435  std::cout << "TrajectorySeedProducer: FTS momentum " << initialFTS.momentum() << std::endl;
436 #endif
437  const GeomDet* initialLayer = theGeometry->idToDet(recHits.front().geographicalId());
438  //this is wrong because the FTS is defined at vertex, and it need to be properly propagated to the first rechit
439  // const TrajectoryStateOnSurface initialTSOS(initialFTS, initialLayer->surface());
440  const TrajectoryStateOnSurface initialTSOS = thePropagator->propagate(initialFTS,initialLayer->surface()) ;
441  if (!initialTSOS.isValid()) continue;
442 
443 
444  PTSOD = trajectoryStateTransform::persistentState(initialTSOS,recHits.front().geographicalId().rawId());
445  }
446 
447  TrackCandidate newTrackCandidate(recHits,*aSeed,PTSOD,edm::RefToBase<TrajectorySeed>(theSeeds,seednr));
448 
449  output->push_back(newTrackCandidate);
450 
451  }//loop over possible simtrack associated.
452  }//loop over all possible seeds.
453 
454  // Save the track candidates in the event
455  LogDebug("FastTracking") << "Saving "
456  << output->size() << " track candidates" ;
457  // Save the track candidates
458  e.put(output);
459 }
#define LogDebug(id)
PropagationDirection direction() const
const math::XYZVectorD & trackerSurfacePosition() const
Definition: SimTrack.h:36
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
const LocalTrajectoryParameters & localParameters() const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
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)
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
float charge() const
charge
Definition: CoreSimTrack.cc:18
const MagneticField * theMagField
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
float float float z
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
AlgebraicVector5 vector() const
void push_back(D *&d)
Definition: OwnVector.h:280
void addSplitHits(const TrajectorySeedHitCandidate &, std::vector< TrajectorySeedHitCandidate > &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
PropagatorWithMaterial * thePropagator
edm::EDGetTokenT< SiTrackerGSMatchedRecHit2DCollection > recHitToken
const SiTrackerGSMatchedRecHit2D * matchedHit() const
The Hit itself.
std::pair< const_iterator, const_iterator > range
unsigned int detId() const
virtual TrackingRecHit * clone() const =0
Definition: DetId.h:18
virtual TrackingRecHit const * hit() const
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const GlobalTrajectoryParameters & globalParameters() const
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
Definition: SimTrack.h:38
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
range recHits() const
unsigned int nHits() const
GlobalVector globalMomentum() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
tuple cout
Definition: gather_cfg.py:121
const TrackerGeometry * theGeometry
unsigned int layerNumber() const
The Layer Number.
DetId geographicalId() const
Definition: DDAxes.h:10
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.
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
std::vector< SimTrack > SimTrackContainer
reference front()
Definition: OwnVector.h:355
void reserve(size_t)
Definition: OwnVector.h:274
virtual const TrackerGeomDet * idToDet(DetId) const
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.

Member Data Documentation

double TrackCandidateProducer::estimatorCut_
private

Definition at line 68 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::InputTag TrackCandidateProducer::hitProducer
private

Definition at line 57 of file TrackCandidateProducer.h.

Referenced by TrackCandidateProducer().

unsigned int TrackCandidateProducer::maxNumberOfCrossedLayers
private

Definition at line 61 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

unsigned int TrackCandidateProducer::minNumberOfCrossedLayers
private

Definition at line 60 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 72 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 63 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::seedCleaning
private

Definition at line 65 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::InputTag TrackCandidateProducer::seedProducer
private

Definition at line 56 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 71 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::InputTag TrackCandidateProducer::simTracks_
private

Definition at line 67 of file TrackCandidateProducer.h.

Referenced by TrackCandidateProducer().

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

Definition at line 74 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 73 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 64 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

const TrackerGeometry* TrackCandidateProducer::theGeometry
private

Definition at line 51 of file TrackCandidateProducer.h.

Referenced by beginRun(), and produce().

const MagneticField* TrackCandidateProducer::theMagField
private

Definition at line 52 of file TrackCandidateProducer.h.

Referenced by beginRun(), and produce().

PropagatorWithMaterial* TrackCandidateProducer::thePropagator
private

Definition at line 53 of file TrackCandidateProducer.h.

Referenced by beginRun(), produce(), and ~TrackCandidateProducer().

std::vector<edm::InputTag> TrackCandidateProducer::trackProducers
private

Definition at line 58 of file TrackCandidateProducer.h.