CMS 3D CMS Logo

SimpleTrackListMerger.cc
Go to the documentation of this file.
1 // Package: RecoTracker/FinalTrackSelectors
2 // Class: SimpleTrackListMerger
3 //
4 // Description: Hit Dumper
5 //
6 // Original Author: Steve Wagner, stevew@pizero.colorado.edu
7 // Created: Sat Jan 14 22:00:00 UTC 2006
8 //
9 //
10 
11 
16 
17 
26 
28 
31 
32 // this class is obsolete use TrackListMerger
34  public:
35 
36  explicit SimpleTrackListMerger(const edm::ParameterSet& conf);
37 
38  virtual ~SimpleTrackListMerger();
39 
40  virtual void produce(edm::Event& e, const edm::EventSetup& c) override;
41 
42  private:
44 
45  std::unique_ptr<reco::TrackCollection> outputTrks;
46  std::unique_ptr<reco::TrackExtraCollection> outputTrkExtras;
47  std::unique_ptr<TrackingRecHitCollection> outputTrkHits;
48  std::unique_ptr<std::vector<Trajectory>> outputTrajs;
49  std::unique_ptr<TrajTrackAssociationCollection> outputTTAss;
50  std::unique_ptr<TrajectorySeedCollection> outputSeeds;
51 
56  std::vector<reco::TrackRef> trackRefs;
58 
68 
70  };
71 
72 
73 
74 
75 #include <memory>
76 #include <string>
77 #include <iostream>
78 #include <cmath>
79 #include <vector>
80 
81 
87 
89 
91 
96 
97 //#include "DataFormats/TrackReco/src/classes.h"
98 
100 
101 namespace {
102  // VI January 2012 to be migrated to omnicluster (or firstCluster)
103  edm::ProductID clusterProduct( const TrackingRecHit *hit){
104  edm::ProductID pID;
105  //cast it into the proper class and find productID
106  DetId detid = hit->geographicalId();
107  uint32_t subdet = detid.subdetId();
108  if ((subdet == PixelSubdetector::PixelBarrel) || (subdet == PixelSubdetector::PixelEndcap)) {
109  pID=reinterpret_cast<const SiPixelRecHit *>(hit)->cluster().id();
110  } else {
111  const std::type_info &type = typeid(*hit);
112  if (type == typeid(SiStripRecHit2D)) {
113  pID=reinterpret_cast<const SiStripRecHit2D *>(hit)->cluster().id();
114  } else if (type == typeid(SiStripRecHit1D)) {
115  pID=reinterpret_cast<const SiStripRecHit1D *>(hit)->cluster().id();
116  } else if (type == typeid(SiStripMatchedRecHit2D)) {
117  const SiStripMatchedRecHit2D *mhit = reinterpret_cast<const SiStripMatchedRecHit2D *>(hit);
118  pID=mhit->monoClusterRef().id();
119  } else if (type == typeid(ProjectedSiStripRecHit2D)) {
120  const ProjectedSiStripRecHit2D *phit = reinterpret_cast<const ProjectedSiStripRecHit2D *>(hit);
121  pID= phit->cluster().id();
122  } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)";
123  }
124 
125  return pID;
126  }
127 }
128 
129 
131  conf_(conf)
132  {
133 
134  edm::LogWarning("SimpleTrackListMerger") << "this class is obsolete, please use TrackListMerger";
135 
136  copyExtras_ = conf_.getUntrackedParameter<bool>("copyExtras", true);
137 
138  produces<reco::TrackCollection>();
139 
140  makeReKeyedSeeds_ = conf_.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
141  if (makeReKeyedSeeds_){
142  copyExtras_=true;
143  produces<TrajectorySeedCollection>();
144  }
145 
146  if (copyExtras_) {
147  produces<reco::TrackExtraCollection>();
148  produces<TrackingRecHitCollection>();
149  }
150  produces< std::vector<Trajectory> >();
151  produces< TrajTrackAssociationCollection >();
152 
153  trackProducer1 = conf_.getParameter<std::string>("TrackProducer1");
154  trackProducer2 = conf_.getParameter<std::string>("TrackProducer2");
155 
156  trackProducer1Token = consumes<reco::TrackCollection>(trackProducer1);
157  trackProducer2Token = consumes<reco::TrackCollection>(trackProducer2);
158  trackProducer1TrajToken = consumes< std::vector<Trajectory> >(trackProducer1);
159  trackProducer2TrajToken = consumes< std::vector<Trajectory> >(trackProducer2);
160  trackProducer1AssToken = consumes< TrajTrackAssociationCollection >(trackProducer1);
161  trackProducer2AssToken = consumes< TrajTrackAssociationCollection >(trackProducer2);
162 
163  priorityName_ = conf.getParameter<std::string>("trackAlgoPriorityOrder");
164  }
165 
166 
167  // Virtual destructor needed.
169 
170  // Functions that gets called by framework every event
172  {
173  // retrieve producer name of input TrackCollection(s)
174 
175  double maxNormalizedChisq = conf_.getParameter<double>("MaxNormalizedChisq");
176  double minPT = conf_.getParameter<double>("MinPT");
177  unsigned int minFound = (unsigned int)conf_.getParameter<int>("MinFound");
178  double epsilon = conf_.getParameter<double>("Epsilon");
179  bool use_sharesInput = true;
180  if ( epsilon > 0.0 )use_sharesInput = false;
181  double shareFrac = conf_.getParameter<double>("ShareFrac");
182  double foundHitBonus = conf_.getParameter<double>("FoundHitBonus");
183  double lostHitPenalty = conf_.getParameter<double>("LostHitPenalty");
184 
185  bool promoteQuality = conf_.getParameter<bool>("promoteTrackQuality");
186  bool allowFirstHitShare = conf_.getParameter<bool>("allowFirstHitShare");
187 //
188 
189  // New track quality should be read from the file
190  std::string qualityStr = conf_.getParameter<std::string>("newQuality");
192  if (qualityStr != "") {
193  qualityToSet = reco::TrackBase::qualityByName(conf_.getParameter<std::string>("newQuality"));
194  }
195  else
196  qualityToSet = reco::TrackBase::undefQuality;
197 
198  // extract tracker geometry
199  //
201  es.get<TrackerDigiGeometryRecord>().get(theG);
202 
204  es.get<CkfComponentsRecord>().get(priorityName_, priorityH);
205  auto const & trackAlgoPriorityOrder = *priorityH;
206 
207 // using namespace reco;
208 
209  // get Inputs
210  // if 1 input list doesn't exist, make an empty list, issue a warning, and continue
211  // this allows SimpleTrackListMerger to be used as a cleaner only if handed just one list
212  // if both input lists don't exist, will issue 2 warnings and generate an empty output collection
213  //
214  const reco::TrackCollection *TC1 = 0;
215  static const reco::TrackCollection s_empty1, s_empty2;
216  edm::Handle<reco::TrackCollection> trackCollection1;
217  e.getByToken(trackProducer1Token, trackCollection1);
218  if (trackCollection1.isValid()) {
219  TC1 = trackCollection1.product();
220  //std::cout << "1st collection " << trackProducer1 << " has "<< TC1->size() << " tracks" << std::endl ;
221  } else {
222  TC1 = &s_empty1;
223  edm::LogWarning("SimpleTrackListMerger") << "1st TrackCollection " << trackProducer1 << " not found; will only clean 2nd TrackCollection " << trackProducer2 ;
224  }
225  const reco::TrackCollection tC1 = *TC1;
226 
227  const reco::TrackCollection *TC2 = 0;
228  edm::Handle<reco::TrackCollection> trackCollection2;
229  e.getByToken(trackProducer2Token, trackCollection2);
230  if (trackCollection2.isValid()) {
231  TC2 = trackCollection2.product();
232  //std::cout << "2nd collection " << trackProducer2 << " has "<< TC2->size() << " tracks" << std::endl ;
233  } else {
234  TC2 = &s_empty2;
235  edm::LogWarning("SimpleTrackListMerger") << "2nd TrackCollection " << trackProducer2 << " not found; will only clean 1st TrackCollection " << trackProducer1 ;
236  }
237  const reco::TrackCollection tC2 = *TC2;
238 
239  // Step B: create empty output collection
240  outputTrks = std::make_unique<reco::TrackCollection>();
242 
243  if (copyExtras_) {
244  outputTrkExtras = std::make_unique<reco::TrackExtraCollection>();
245  outputTrkExtras->reserve(TC1->size()+TC2->size());
247  outputTrkHits = std::make_unique<TrackingRecHitCollection>();
248  outputTrkHits->reserve((TC1->size()+TC2->size())*25);
250  if (makeReKeyedSeeds_){
251  outputSeeds = std::make_unique<TrajectorySeedCollection>();
252  outputSeeds->reserve(TC1->size()+TC2->size());
254  }
255  }
256 
257  outputTrajs = std::make_unique<std::vector<Trajectory>>();
258  outputTrajs->reserve(TC1->size()+TC2->size());
259  outputTTAss = std::make_unique<TrajTrackAssociationCollection>();
260  //outputTTAss->reserve(TC1->size()+TC2->size());//how do I reserve space for an association map?
261 
262  //
263  // no input tracks
264  //
265 
266 // if ( tC1.empty() ){
267 // LogDebug("RoadSearch") << "Found " << output.size() << " clouds.";
268 // e.put(std::move(output);
269 // return;
270 // }
271 
272  //
273  // quality cuts first
274  //
275  int i;
276 
277  std::vector<int> selected1; for (unsigned int i=0; i<tC1.size(); ++i){selected1.push_back(1);}
278 
279  if ( 0<tC1.size() ){
280  i=-1;
281  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
282  i++;
283  if ((short unsigned)track->ndof() < 1){
284  selected1[i]=0;
285  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
286  continue;
287  }
288  if (track->normalizedChi2() > maxNormalizedChisq){
289  selected1[i]=0;
290  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
291  continue;
292  }
293  if (track->found() < minFound){
294  selected1[i]=0;
295  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
296  continue;
297  }
298  if (track->pt() < minPT){
299  selected1[i]=0;
300  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
301  continue;
302  }
303  }//end loop over tracks
304  }//end more than 0 track
305 
306 
307  std::vector<int> selected2; for (unsigned int i=0; i<tC2.size(); ++i){selected2.push_back(1);}
308 
309  if ( 0<tC2.size() ){
310  i=-1;
311  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
312  i++;
313  if ((short unsigned)track->ndof() < 1){
314  selected2[i]=0;
315  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
316  continue;
317  }
318  if (track->normalizedChi2() > maxNormalizedChisq){
319  selected2[i]=0;
320  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
321  continue;
322  }
323  if (track->found() < minFound){
324  selected2[i]=0;
325  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
326  continue;
327  }
328  if (track->pt() < minPT){
329  selected2[i]=0;
330  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
331  continue;
332  }
333  }//end loop over tracks
334  }//end more than 0 track
335 
336  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
337  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
338  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
339  trackingRecHit_iterator itB = track->recHitsBegin();
340  trackingRecHit_iterator itE = track->recHitsEnd();
341  for (trackingRecHit_iterator it = itB; it != itE; ++it) {
342  const TrackingRecHit* hit = &(**it);
343  rh1[track].push_back(hit);
344  }
345  }
346  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
347  trackingRecHit_iterator jtB = track->recHitsBegin();
348  trackingRecHit_iterator jtE = track->recHitsEnd();
349  for (trackingRecHit_iterator jt = jtB; jt != jtE; ++jt) {
350  const TrackingRecHit* hit = &(**jt);
351  rh2[track].push_back(hit);
352  }
353  }
354 
355  if ( (0<tC1.size())&&(0<tC2.size()) ){
356  i=-1;
357  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
358  i++;
359  if (!selected1[i])continue;
360  std::vector<const TrackingRecHit*>& iHits = rh1[track];
361  unsigned nh1 = iHits.size();
362  int qualityMaskT1 = track->qualityMask();
363  int j=-1;
364  for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
365  j++;
366  if ((!selected2[j])||(!selected1[i]))continue;
367  std::vector<const TrackingRecHit*>& jHits = rh2[track2];
368  unsigned nh2 = jHits.size();
369  int noverlap=0;
370  int firstoverlap=0;
371  for ( unsigned ih=0; ih<nh1; ++ih ) {
372  const TrackingRecHit* it = iHits[ih];
373  if (it->isValid()){
374  int jj=-1;
375  for ( unsigned jh=0; jh<nh2; ++jh ) {
376  const TrackingRecHit* jt = jHits[jh];
377  jj++;
378  if (jt->isValid()){
379  if (!use_sharesInput){
380  float delta = fabs ( it->localPosition().x()-jt->localPosition().x() );
381  if ((it->geographicalId()==jt->geographicalId())&&(delta<epsilon)) {
382  noverlap++;
383  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
384  }
385  }else{
386  if ( it->sharesInput(jt,TrackingRecHit::some) ) {
387  noverlap++;
388  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
389  }
390  }
391  }
392  }
393  }
394  }
395  int newQualityMask = (qualityMaskT1 | track2->qualityMask()); // take OR of trackQuality
396  int nhit1 = track->numberOfValidHits();
397  int nhit2 = track2->numberOfValidHits();
398  if ( (noverlap-firstoverlap) > (std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
399  double score1 = foundHitBonus*nhit1 - lostHitPenalty*track->numberOfLostHits() - track->chi2();
400  double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
401  const double almostSame = 1.001;
402  if ( score1 > almostSame * score2 ){
403  selected2[j]=0;
404  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
405  }else if ( score2 > almostSame * score1 ){
406  selected1[i]=0;
407  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
408  }else{
409  if (trackAlgoPriorityOrder.priority(track->algo()) <= trackAlgoPriorityOrder.priority(track2->algo())) {
410  selected2[j]=0;
411  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
412  }else{
413  selected1[i]=0;
414  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
415  }
416  }
417  }//end got a duplicate
418  }//end track2 loop
419  }//end track loop
420  }//end more than 1 track
421 
422  //
423  // output selected tracks - if any
424  //
425  trackRefs.resize(tC1.size()+tC2.size());
426  std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
427  size_t current = 0;
428 
429  if ( 0<tC1.size() ){
430  i=0;
431  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
432  ++track, ++current, ++i){
433  if (!selected1[i]){
434  trackRefs[current] = reco::TrackRef();
435  continue;
436  }
437  const reco::Track & theTrack = * track;
438  //fill the TrackCollection
439  outputTrks->push_back( reco::Track( theTrack ) );
440  if (selected1[i]>1 && promoteQuality){
441  outputTrks->back().setQualityMask(selected1[i]-10);
442  outputTrks->back().setQuality(qualityToSet);
443  }
444  if (copyExtras_) {
445  //--------NEW----------
446  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
447  //creating a seed with rekeyed clusters if required
448  if (makeReKeyedSeeds_){
449  bool doRekeyOnThisSeed=false;
450 
451  edm::InputTag clusterRemovalInfos("");
452  //grab on of the hits of the seed
453  if (origSeedRef->nHits()!=0){
454  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
455  const TrackingRecHit *hit = &*firstHit;
456  if (firstHit->isValid()){
457  edm::ProductID pID=clusterProduct(hit);
458  // the cluster collection either produced a removalInfo or mot
459  //get the clusterremoval info from the provenance: will rekey if this is found
461  edm::Provenance prov=e.getProvenance(pID);
462  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
463  prov.productInstanceName(),
464  prov.processName());
465  // In case this is switched on, will have to revist that, and declare mayConsumes...
466  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
467  }//valid hit
468  }//nhit!=0
469 
470  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
471  {
472  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
473  TrajectorySeed::recHitContainer newRecHitContainer;
474  newRecHitContainer.reserve(origSeedRef->nHits());
475  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
476  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
477  for (;iH!=iH_end;++iH){
478  newRecHitContainer.push_back(*iH);
479  refSetter.reKey(&newRecHitContainer.back());
480  }
481  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
482  newRecHitContainer,
483  origSeedRef->direction()));
484  }
485  //doRekeyOnThisSeed=true
486  else{
487  //just copy the one we had before
488  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
489  }
491  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
492  }//creating a new seed and rekeying it rechit clusters.
493  //--------NEW----------
494  // Fill TrackExtra collection
495  outputTrkExtras->push_back( reco::TrackExtra(
496  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
497  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
498  theTrack.outerStateCovariance(), theTrack.outerDetId(),
499  theTrack.innerStateCovariance(), theTrack.innerDetId(),
500  theTrack.seedDirection(), origSeedRef ) );
501  seedsRefs[current]=origSeedRef;
502  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
503  reco::TrackExtra & tx = outputTrkExtras->back();
504  tx.setResiduals(theTrack.residuals());
505  // fill TrackingRecHits
506  std::vector<const TrackingRecHit*>& iHits = rh1[track];
507  unsigned nh1 = iHits.size();
508  auto const firstHitIndex = outputTrkHits->size();
509  for ( unsigned ih=0; ih<nh1; ++ih ) {
510  const TrackingRecHit* hit = iHits[ih];
511  //for( trackingRecHit_iterator hit = itB; hit != itE; ++hit ) {
512  outputTrkHits->push_back( hit->clone() );
513  }
514  tx.setHits( refTrkHits, firstHitIndex, nh1 );
515  }
516  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
517 
518 
519  }//end faux loop over tracks
520  }//end more than 0 track
521 
522  //Fill the trajectories, etc. for 1st collection
527  refTrajs = e.getRefBeforePut< std::vector<Trajectory> >();
528 
529  if (!hTraj1.failedToGet() && !hTTAss1.failedToGet()){
530  for (size_t i = 0, n = hTraj1->size(); i < n; ++i) {
531  edm::Ref< std::vector<Trajectory> > trajRef(hTraj1, i);
533  if (match != hTTAss1->end()) {
534  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
535  short oldKey = static_cast<short>(trkRef.key());
536  if (trackRefs[oldKey].isNonnull()) {
537  outputTrajs->push_back( *trajRef );
538  //if making extras and the seeds at the same time, change the seed ref on the trajectory
540  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
541  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
542  trackRefs[oldKey] );
543  }
544  }
545  }
546  }
547 
548  short offset = current; //save offset into trackRefs
549 
550  if ( 0<tC2.size() ){
551  i=0;
552  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
553  ++track, ++current, ++i){
554  if (!selected2[i]){
555  trackRefs[current] = reco::TrackRef();
556  continue;
557  }
558  const reco::Track & theTrack = * track;
559  //fill the TrackCollection
560  outputTrks->push_back( reco::Track( theTrack ) );
561  if (selected2[i]>1 && promoteQuality){
562  outputTrks->back().setQualityMask(selected2[i]-10);
563  outputTrks->back().setQuality(qualityToSet);
564  }
565  if (copyExtras_) {
566  //--------NEW----------
567  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
568  //creating a seed with rekeyed clusters if required
569  if (makeReKeyedSeeds_){
570  bool doRekeyOnThisSeed=false;
571 
572  edm::InputTag clusterRemovalInfos("");
573  //grab on of the hits of the seed
574  if (origSeedRef->nHits()!=0){
575  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
576  const TrackingRecHit *hit = &*firstHit;
577  if (firstHit->isValid()){
578  edm::ProductID pID=clusterProduct(hit);
579  // the cluster collection either produced a removalInfo or mot
580  //get the clusterremoval info from the provenance: will rekey if this is found
582  edm::Provenance prov=e.getProvenance(pID);
583  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
584  prov.productInstanceName(),
585  prov.processName());
586  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
587  }//valid hit
588  }//nhit!=0
589 
590  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
591  {
592  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
593  TrajectorySeed::recHitContainer newRecHitContainer;
594  newRecHitContainer.reserve(origSeedRef->nHits());
595  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
596  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
597  for (;iH!=iH_end;++iH){
598  newRecHitContainer.push_back(*iH);
599  refSetter.reKey(&newRecHitContainer.back());
600  }
601  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
602  newRecHitContainer,
603  origSeedRef->direction()));
604  }//doRekeyOnThisSeed=true
605  else{
606  //just copy the one we had before
607  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
608  }
610  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
611  }//creating a new seed and rekeying it rechit clusters.
612  //--------NEW----------
613  // Fill TrackExtra collection
614  outputTrkExtras->push_back( reco::TrackExtra(
615  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
616  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
617  theTrack.outerStateCovariance(), theTrack.outerDetId(),
618  theTrack.innerStateCovariance(), theTrack.innerDetId(),
619  theTrack.seedDirection(), origSeedRef ) );
620  seedsRefs[current]=origSeedRef;
621  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
622  reco::TrackExtra & tx = outputTrkExtras->back();
623  tx.setResiduals(theTrack.residuals());
624  // fill TrackingRecHits
625  std::vector<const TrackingRecHit*>& jHits = rh2[track];
626  unsigned nh2 = jHits.size();
627  auto const firstHitIndex2 = outputTrkHits->size();
628  for ( unsigned jh=0; jh<nh2; ++jh ) {
629  const TrackingRecHit* hit = jHits[jh];
630  outputTrkHits->push_back( hit->clone() );
631  }
632  tx.setHits( refTrkHits, firstHitIndex2, nh2 );
633  }
634  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
635 
636  }//end faux loop over tracks
637  }//end more than 0 track
638 
639  //Fill the trajectories, etc. for 2nd collection
644 
645  if (!hTraj2.failedToGet() && !hTTAss2.failedToGet()){
646  for (size_t i = 0, n = hTraj2->size(); i < n; ++i) {
647  edm::Ref< std::vector<Trajectory> > trajRef(hTraj2, i);
649  if (match != hTTAss2->end()) {
650  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
651  short oldKey = static_cast<short>(trkRef.key()) + offset;
652  if (trackRefs[oldKey].isNonnull()) {
653  outputTrajs->push_back( Trajectory(*trajRef) );
654  //if making extras and the seeds at the same time, change the seed ref on the trajectory
656  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
657  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
658  trackRefs[oldKey] );
659  }
660  }
661  }}
662 
664  if (copyExtras_) {
667  if (makeReKeyedSeeds_)
669  }
670  e.put(std::move(outputTrajs));
672  return;
673 
674  }//end produce
675 
678 
679 
681 
PropagationDirection direction() const
dbl * delta
Definition: mlp_gen.cc:36
type
Definition: HCALResponse.h:21
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:213
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< reco::TrackCollection > outputTrks
reference back()
Definition: OwnVector.h:395
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
TrackQuality
track quality
Definition: TrackBase.h:151
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
void reKey(TrackingRecHit *hit) const
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
TrackingRecHitRefProd refTrkHits
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
key_type key() const
Accessor for product key.
Definition: Ref.h:264
std::unique_ptr< TrajectorySeedCollection > outputSeeds
std::string const & processName() const
Definition: Provenance.h:52
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
std::unique_ptr< std::vector< Trajectory > > outputTrajs
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
void push_back(D *&d)
Definition: OwnVector.h:290
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:75
virtual TrackingRecHit * clone() const =0
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
T min(T a, T b)
Definition: MathUtil.h:58
OmniClusterRef const & monoClusterRef() const
virtual LocalPoint localPosition() const =0
bool isValid() const
Definition: HandleBase.h:74
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
edm::RefProd< std::vector< Trajectory > > refTrajs
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
reco::TrackRefProd refTrks
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
bool failedToGet() const
Definition: HandleBase.h:78
Definition: DetId.h:18
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
PTrajectoryStateOnDet const & startingState() const
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
T const * product() const
Definition: Handle.h:81
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:204
const T & get() const
Definition: EventSetup.h:56
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:80
range recHits() const
bool isValid() const
std::string const & moduleLabel() const
Definition: Provenance.h:50
std::unique_ptr< reco::TrackExtraCollection > outputTrkExtras
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
unsigned int nHits() const
edm::ProductID id() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
SimpleTrackListMerger(const edm::ParameterSet &conf)
edm::EDGetTokenT< reco::TrackCollection > trackProducer2Token
const TrackResiduals & residuals() const
get the residuals
Definition: Track.h:218
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< reco::TrackRef > trackRefs
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
DetId geographicalId() const
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
std::string const & productInstanceName() const
Definition: Provenance.h:53
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:81
T x() const
Definition: PV3DBase.h:62
reco::TrackExtraRefProd refTrkExtras
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99
def move(src, dest)
Definition: eostools.py:510
void reserve(size_t)
Definition: OwnVector.h:284
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Our base class.
Definition: SiPixelRecHit.h:23
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:174