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