CMS 3D CMS Logo

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