CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
cms::SimpleTrackListMerger Class Reference

#include <SimpleTrackListMerger.h>

Inheritance diagram for cms::SimpleTrackListMerger:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
 SimpleTrackListMerger (const edm::ParameterSet &conf)
 
virtual ~SimpleTrackListMerger ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::ParameterSet conf_
 
bool copyExtras_
 
bool makeReKeyedSeeds_
 
std::auto_ptr
< TrajectorySeedCollection
outputSeeds
 
std::auto_ptr< std::vector
< Trajectory > > 
outputTrajs
 
std::auto_ptr
< reco::TrackExtraCollection
outputTrkExtras
 
std::auto_ptr
< TrackingRecHitCollection
outputTrkHits
 
std::auto_ptr
< reco::TrackCollection
outputTrks
 
std::auto_ptr
< TrajTrackAssociationCollection
outputTTAss
 
edm::RefProd< std::vector
< Trajectory > > 
refTrajs
 
edm::RefProd
< TrajectorySeedCollection
refTrajSeeds
 
reco::TrackExtraRefProd refTrkExtras
 
TrackingRecHitRefProd refTrkHits
 
reco::TrackRefProd refTrks
 
std::vector< reco::TrackReftrackRefs
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 38 of file SimpleTrackListMerger.h.

Constructor & Destructor Documentation

cms::SimpleTrackListMerger::SimpleTrackListMerger ( const edm::ParameterSet conf)
explicit

Definition at line 72 of file SimpleTrackListMerger.cc.

References conf_, copyExtras_, edm::ParameterSet::getUntrackedParameter(), and makeReKeyedSeeds_.

72  :
73  conf_(conf)
74  {
75  copyExtras_ = conf_.getUntrackedParameter<bool>("copyExtras", true);
76 
77  produces<reco::TrackCollection>();
78 
79  makeReKeyedSeeds_ = conf_.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
80  if (makeReKeyedSeeds_){
81  copyExtras_=true;
82  produces<TrajectorySeedCollection>();
83  }
84 
85  if (copyExtras_) {
86  produces<reco::TrackExtraCollection>();
87  produces<TrackingRecHitCollection>();
88  }
89  produces< std::vector<Trajectory> >();
90  produces< TrajTrackAssociationCollection >();
91 
92 
93  }
T getUntrackedParameter(std::string const &, T const &) const
cms::SimpleTrackListMerger::~SimpleTrackListMerger ( )
virtual

Definition at line 97 of file SimpleTrackListMerger.cc.

97 { }

Member Function Documentation

void cms::SimpleTrackListMerger::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 100 of file SimpleTrackListMerger.cc.

References reco::TrackExtraBase::add(), edm::OwnVector< T, P >::back(), TrackingRecHit::clone(), cms::clusterProduct(), conf_, copyExtras_, cond::rpcobimon::current, delta, TrajectorySeed::direction(), epsilon, edm::HandleBase::failedToGet(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), edm::Event::getProvenance(), edm::Event::getRefBeforePut(), i, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), TrackingRecHit::isValid(), edm::HandleBase::isValid(), j, edm::Ref< C, T, F >::key(), TrackingRecHit::localPosition(), makeReKeyedSeeds_, match(), min, edm::Provenance::moduleLabel(), n, TrajectorySeed::nHits(), evf::evtn::offset(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), outputSeeds, outputTrajs, outputTrkExtras, outputTrkHits, outputTrks, outputTTAss, edm::Provenance::processName(), edm::Handle< T >::product(), edm::Provenance::productInstanceName(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), reco::TrackBase::qualityByName(), TrajectorySeed::recHits(), refTrajs, refTrajSeeds, refTrkExtras, refTrkHits, refTrks, ClusterRemovalRefSetter::reKey(), edm::OwnVector< T, P >::reserve(), reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackExtra::setResiduals(), TrackingRecHit::sharesInput(), TrackingRecHit::some, TrajectorySeed::startingState(), ExpressReco_HICollisions_FallBack::track, trackRefs, reco::TrackBase::undefQuality, edm::helpers::KeyVal< K, V >::val, and PV3DBase< T, PVType, FrameType >::x().

101  {
102  // retrieve producer name of input TrackCollection(s)
103  std::string trackProducer1 = conf_.getParameter<std::string>("TrackProducer1");
104  std::string trackProducer2 = conf_.getParameter<std::string>("TrackProducer2");
105 
106  double maxNormalizedChisq = conf_.getParameter<double>("MaxNormalizedChisq");
107  double minPT = conf_.getParameter<double>("MinPT");
108  unsigned int minFound = (unsigned int)conf_.getParameter<int>("MinFound");
109  double epsilon = conf_.getParameter<double>("Epsilon");
110  bool use_sharesInput = true;
111  if ( epsilon > 0.0 )use_sharesInput = false;
112  double shareFrac = conf_.getParameter<double>("ShareFrac");
113 
114  bool promoteQuality = conf_.getParameter<bool>("promoteTrackQuality");
115  bool allowFirstHitShare = conf_.getParameter<bool>("allowFirstHitShare");
116 //
117 
118  // New track quality should be read from the file
119  std::string qualityStr = conf_.getParameter<std::string>("newQuality");
120  reco::TrackBase::TrackQuality qualityToSet;
121  if (qualityStr != "") {
122  qualityToSet = reco::TrackBase::qualityByName(conf_.getParameter<std::string>("newQuality"));
123  }
124  else
125  qualityToSet = reco::TrackBase::undefQuality;
126 
127  // extract tracker geometry
128  //
130  es.get<TrackerDigiGeometryRecord>().get(theG);
131 
132 // using namespace reco;
133 
134  // get Inputs
135  // if 1 input list doesn't exist, make an empty list, issue a warning, and continue
136  // this allows SimpleTrackListMerger to be used as a cleaner only if handed just one list
137  // if both input lists don't exist, will issue 2 warnings and generate an empty output collection
138  //
139  const reco::TrackCollection *TC1 = 0;
140  static const reco::TrackCollection s_empty1, s_empty2;
141  edm::Handle<reco::TrackCollection> trackCollection1;
142  e.getByLabel(trackProducer1, trackCollection1);
143  if (trackCollection1.isValid()) {
144  TC1 = trackCollection1.product();
145  //std::cout << "1st collection " << trackProducer1 << " has "<< TC1->size() << " tracks" << std::endl ;
146  } else {
147  TC1 = &s_empty1;
148  edm::LogWarning("SimpleTrackListMerger") << "1st TrackCollection " << trackProducer1 << " not found; will only clean 2nd TrackCollection " << trackProducer2 ;
149  }
150  const reco::TrackCollection tC1 = *TC1;
151 
152  const reco::TrackCollection *TC2 = 0;
153  edm::Handle<reco::TrackCollection> trackCollection2;
154  e.getByLabel(trackProducer2, trackCollection2);
155  if (trackCollection2.isValid()) {
156  TC2 = trackCollection2.product();
157  //std::cout << "2nd collection " << trackProducer2 << " has "<< TC2->size() << " tracks" << std::endl ;
158  } else {
159  TC2 = &s_empty2;
160  edm::LogWarning("SimpleTrackListMerger") << "2nd TrackCollection " << trackProducer2 << " not found; will only clean 1st TrackCollection " << trackProducer1 ;
161  }
162  const reco::TrackCollection tC2 = *TC2;
163 
164  // Step B: create empty output collection
165  outputTrks = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection);
167 
168  if (copyExtras_) {
169  outputTrkExtras = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
170  outputTrkExtras->reserve(TC1->size()+TC2->size());
172  outputTrkHits = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
173  outputTrkHits->reserve((TC1->size()+TC2->size())*25);
175  if (makeReKeyedSeeds_){
176  outputSeeds = std::auto_ptr<TrajectorySeedCollection>(new TrajectorySeedCollection);
177  outputSeeds->reserve(TC1->size()+TC2->size());
179  }
180  }
181 
182  outputTrajs = std::auto_ptr< std::vector<Trajectory> >(new std::vector<Trajectory>());
183  outputTrajs->reserve(TC1->size()+TC2->size());
184  outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection());
185  //outputTTAss->reserve(TC1->size()+TC2->size());//how do I reserve space for an association map?
186 
187  //
188  // no input tracks
189  //
190 
191 // if ( tC1.empty() ){
192 // LogDebug("RoadSearch") << "Found " << output.size() << " clouds.";
193 // e.put(output);
194 // return;
195 // }
196 
197  //
198  // quality cuts first
199  //
200  int i;
201 
202  std::vector<int> selected1; for (unsigned int i=0; i<tC1.size(); ++i){selected1.push_back(1);}
203 
204  if ( 0<tC1.size() ){
205  i=-1;
206  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
207  i++;
208  if ((short unsigned)track->ndof() < 1){
209  selected1[i]=0;
210  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
211  continue;
212  }
213  if (track->normalizedChi2() > maxNormalizedChisq){
214  selected1[i]=0;
215  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
216  continue;
217  }
218  if (track->found() < minFound){
219  selected1[i]=0;
220  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
221  continue;
222  }
223  if (track->pt() < minPT){
224  selected1[i]=0;
225  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
226  continue;
227  }
228  }//end loop over tracks
229  }//end more than 0 track
230 
231 
232  std::vector<int> selected2; for (unsigned int i=0; i<tC2.size(); ++i){selected2.push_back(1);}
233 
234  if ( 0<tC2.size() ){
235  i=-1;
236  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
237  i++;
238  if ((short unsigned)track->ndof() < 1){
239  selected2[i]=0;
240  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
241  continue;
242  }
243  if (track->normalizedChi2() > maxNormalizedChisq){
244  selected2[i]=0;
245  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
246  continue;
247  }
248  if (track->found() < minFound){
249  selected2[i]=0;
250  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
251  continue;
252  }
253  if (track->pt() < minPT){
254  selected2[i]=0;
255  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
256  continue;
257  }
258  }//end loop over tracks
259  }//end more than 0 track
260 
261  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
262  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
263  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
264  trackingRecHit_iterator itB = track->recHitsBegin();
265  trackingRecHit_iterator itE = track->recHitsEnd();
266  for (trackingRecHit_iterator it = itB; it != itE; ++it) {
267  const TrackingRecHit* hit = &(**it);
268  rh1[track].push_back(hit);
269  }
270  }
271  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
272  trackingRecHit_iterator jtB = track->recHitsBegin();
273  trackingRecHit_iterator jtE = track->recHitsEnd();
274  for (trackingRecHit_iterator jt = jtB; jt != jtE; ++jt) {
275  const TrackingRecHit* hit = &(**jt);
276  rh2[track].push_back(hit);
277  }
278  }
279 
280  if ( (0<tC1.size())&&(0<tC2.size()) ){
281  i=-1;
282  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
283  i++;
284  if (!selected1[i])continue;
285  std::vector<const TrackingRecHit*>& iHits = rh1[track];
286  unsigned nh1 = iHits.size();
287  int qualityMaskT1 = track->qualityMask();
288  int j=-1;
289  for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
290  j++;
291  if ((!selected2[j])||(!selected1[i]))continue;
292  std::vector<const TrackingRecHit*>& jHits = rh2[track2];
293  unsigned nh2 = jHits.size();
294  int noverlap=0;
295  int firstoverlap=0;
296  for ( unsigned ih=0; ih<nh1; ++ih ) {
297  const TrackingRecHit* it = iHits[ih];
298  if (it->isValid()){
299  int jj=-1;
300  for ( unsigned jh=0; jh<nh2; ++jh ) {
301  const TrackingRecHit* jt = jHits[jh];
302  jj++;
303  if (jt->isValid()){
304  if (!use_sharesInput){
305  float delta = fabs ( it->localPosition().x()-jt->localPosition().x() );
306  if ((it->geographicalId()==jt->geographicalId())&&(delta<epsilon)) {
307  noverlap++;
308  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
309  }
310  }else{
311  if ( it->sharesInput(jt,TrackingRecHit::some) ) {
312  noverlap++;
313  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
314  }
315  }
316  }
317  }
318  }
319  }
320  int newQualityMask = (qualityMaskT1 | track2->qualityMask()); // take OR of trackQuality
321  int nhit1 = track->numberOfValidHits();
322  int nhit2 = track2->numberOfValidHits();
323  //std::cout << " trk1 trk2 nhits1 nhits2 nover " << i << " " << j << " " << track->numberOfValidHits() << " " << track2->numberOfValidHits() << " " << noverlap << " " << fi << " " << fj <<std::endl;
324  if ( (noverlap-firstoverlap) > (std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
325  if ( nhit1 > nhit2 ){
326  selected2[j]=0;
327  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
328  //std::cout << " removing L2 trk in pair " << std::endl;
329  }else{
330  if ( nhit1 < nhit2 ){
331  selected1[i]=0;
332  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
333  //std::cout << " removing L1 trk in pair " << std::endl;
334  }else{
335  //std::cout << " removing worst chisq in pair " << track->normalizedChi2() << " " << track2->normalizedChi2() << std::endl;
336  const double almostSame = 1.001;
337  if (track->normalizedChi2() > almostSame * track2->normalizedChi2()) {
338  selected1[i]=0;
339  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
340  }else if (track2->normalizedChi2() > almostSame * track->normalizedChi2()) {
341  selected2[j]=0;
342  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
343  }else{
344  // If tracks from both iterations are virtually identical, choose the one from the first iteration.
345  // std::cout<<"MERGE "<<track->algo()<<" "<<track2->algo()<<" "<<track->normalizedChi2()<<" "<<track2->normalizedChi2()<<" "<<(track->normalizedChi2()-track2->normalizedChi2())/track->normalizedChi2()<<std::endl;
346  if (track->algo() <= track2->algo()) {
347  selected2[j]=0;
348  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
349  }else{
350  selected1[i]=0;
351  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
352  }
353  }
354  }//end fi > or = fj
355  }//end fi < fj
356  }//end got a duplicate
357  }//end track2 loop
358  }//end track loop
359  }//end more than 1 track
360 
361  //
362  // output selected tracks - if any
363  //
364  trackRefs.resize(tC1.size()+tC2.size());
365  std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
366  size_t current = 0;
367 
368  if ( 0<tC1.size() ){
369  i=0;
370  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
371  ++track, ++current, ++i){
372  if (!selected1[i]){
374  continue;
375  }
376  const reco::Track & theTrack = * track;
377  //fill the TrackCollection
378  outputTrks->push_back( reco::Track( theTrack ) );
379  if (selected1[i]>1 && promoteQuality){
380  outputTrks->back().setQualityMask(selected1[i]-10);
381  outputTrks->back().setQuality(qualityToSet);
382  }
383  if (copyExtras_) {
384  //--------NEW----------
385  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
386  //creating a seed with rekeyed clusters if required
387  if (makeReKeyedSeeds_){
388  bool doRekeyOnThisSeed=false;
389 
390  edm::InputTag clusterRemovalInfos("");
391  //grab on of the hits of the seed
392  if (origSeedRef->nHits()!=0){
393  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
394  const TrackingRecHit *hit = &*firstHit;
395  if (firstHit->isValid()){
397  // the cluster collection either produced a removalInfo or mot
398  //get the clusterremoval info from the provenance: will rekey if this is found
400  edm::Provenance prov=e.getProvenance(pID);
401  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
402  prov.productInstanceName(),
403  prov.processName());
404  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
405  }//valid hit
406  }//nhit!=0
407 
408  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
409  {
410  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
411  TrajectorySeed::recHitContainer newRecHitContainer;
412  newRecHitContainer.reserve(origSeedRef->nHits());
413  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
414  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
415  for (;iH!=iH_end;++iH){
416  newRecHitContainer.push_back(*iH);
417  refSetter.reKey(&newRecHitContainer.back());
418  }
419  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
420  newRecHitContainer,
421  origSeedRef->direction()));
422  }
423  //doRekeyOnThisSeed=true
424  else{
425  //just copy the one we had before
426  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
427  }
429  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
430  }//creating a new seed and rekeying it rechit clusters.
431  //--------NEW----------
432  // Fill TrackExtra collection
433  outputTrkExtras->push_back( reco::TrackExtra(
434  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
435  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
436  theTrack.outerStateCovariance(), theTrack.outerDetId(),
437  theTrack.innerStateCovariance(), theTrack.innerDetId(),
438  theTrack.seedDirection(), origSeedRef ) );
439  seedsRefs[current]=origSeedRef;
440  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
441  reco::TrackExtra & tx = outputTrkExtras->back();
442  tx.setResiduals(theTrack.residuals());
443  // fill TrackingRecHits
444  std::vector<const TrackingRecHit*>& iHits = rh1[track];
445  unsigned nh1 = iHits.size();
446  for ( unsigned ih=0; ih<nh1; ++ih ) {
447  const TrackingRecHit* hit = iHits[ih];
448  //for( trackingRecHit_iterator hit = itB; hit != itE; ++hit ) {
449  outputTrkHits->push_back( hit->clone() );
450  tx.add( TrackingRecHitRef( refTrkHits, outputTrkHits->size() - 1) );
451  }
452  }
453  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
454 
455 
456  }//end faux loop over tracks
457  }//end more than 0 track
458 
459  //Fill the trajectories, etc. for 1st collection
461  e.getByLabel(trackProducer1, hTraj1);
463  e.getByLabel(trackProducer1, hTTAss1);
464  refTrajs = e.getRefBeforePut< std::vector<Trajectory> >();
465 
466  if (!hTraj1.failedToGet() && !hTTAss1.failedToGet()){
467  for (size_t i = 0, n = hTraj1->size(); i < n; ++i) {
468  edm::Ref< std::vector<Trajectory> > trajRef(hTraj1, i);
469  TrajTrackAssociationCollection::const_iterator match = hTTAss1->find(trajRef);
470  if (match != hTTAss1->end()) {
471  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
472  short oldKey = static_cast<short>(trkRef.key());
473  if (trackRefs[oldKey].isNonnull()) {
474  outputTrajs->push_back( *trajRef );
475  //if making extras and the seeds at the same time, change the seed ref on the trajectory
477  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
478  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
479  trackRefs[oldKey] );
480  }
481  }
482  }
483  }
484 
485  short offset = current; //save offset into trackRefs
486 
487  if ( 0<tC2.size() ){
488  i=0;
489  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
490  ++track, ++current, ++i){
491  if (!selected2[i]){
493  continue;
494  }
495  const reco::Track & theTrack = * track;
496  //fill the TrackCollection
497  outputTrks->push_back( reco::Track( theTrack ) );
498  if (selected2[i]>1 && promoteQuality){
499  outputTrks->back().setQualityMask(selected2[i]-10);
500  outputTrks->back().setQuality(qualityToSet);
501  }
502  if (copyExtras_) {
503  //--------NEW----------
504  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
505  //creating a seed with rekeyed clusters if required
506  if (makeReKeyedSeeds_){
507  bool doRekeyOnThisSeed=false;
508 
509  edm::InputTag clusterRemovalInfos("");
510  //grab on of the hits of the seed
511  if (origSeedRef->nHits()!=0){
512  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
513  const TrackingRecHit *hit = &*firstHit;
514  if (firstHit->isValid()){
516  // the cluster collection either produced a removalInfo or mot
517  //get the clusterremoval info from the provenance: will rekey if this is found
519  edm::Provenance prov=e.getProvenance(pID);
520  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
521  prov.productInstanceName(),
522  prov.processName());
523  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
524  }//valid hit
525  }//nhit!=0
526 
527  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
528  {
529  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
530  TrajectorySeed::recHitContainer newRecHitContainer;
531  newRecHitContainer.reserve(origSeedRef->nHits());
532  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
533  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
534  for (;iH!=iH_end;++iH){
535  newRecHitContainer.push_back(*iH);
536  refSetter.reKey(&newRecHitContainer.back());
537  }
538  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
539  newRecHitContainer,
540  origSeedRef->direction()));
541  }//doRekeyOnThisSeed=true
542  else{
543  //just copy the one we had before
544  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
545  }
547  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
548  }//creating a new seed and rekeying it rechit clusters.
549  //--------NEW----------
550  // Fill TrackExtra collection
551  outputTrkExtras->push_back( reco::TrackExtra(
552  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
553  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
554  theTrack.outerStateCovariance(), theTrack.outerDetId(),
555  theTrack.innerStateCovariance(), theTrack.innerDetId(),
556  theTrack.seedDirection(), origSeedRef ) );
557  seedsRefs[current]=origSeedRef;
558  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
559  reco::TrackExtra & tx = outputTrkExtras->back();
560  tx.setResiduals(theTrack.residuals());
561  // fill TrackingRecHits
562  std::vector<const TrackingRecHit*>& jHits = rh2[track];
563  unsigned nh2 = jHits.size();
564  for ( unsigned jh=0; jh<nh2; ++jh ) {
565  const TrackingRecHit* hit = jHits[jh];
566  outputTrkHits->push_back( hit->clone() );
567  tx.add( TrackingRecHitRef( refTrkHits, outputTrkHits->size() - 1) );
568  }
569  }
570  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
571 
572  }//end faux loop over tracks
573  }//end more than 0 track
574 
575  //Fill the trajectories, etc. for 2nd collection
577  e.getByLabel(trackProducer2, hTraj2);
579  e.getByLabel(trackProducer2, hTTAss2);
580 
581  if (!hTraj2.failedToGet() && !hTTAss2.failedToGet()){
582  for (size_t i = 0, n = hTraj2->size(); i < n; ++i) {
583  edm::Ref< std::vector<Trajectory> > trajRef(hTraj2, i);
584  TrajTrackAssociationCollection::const_iterator match = hTTAss2->find(trajRef);
585  if (match != hTTAss2->end()) {
586  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
587  short oldKey = static_cast<short>(trkRef.key()) + offset;
588  if (trackRefs[oldKey].isNonnull()) {
589  outputTrajs->push_back( Trajectory(*trajRef) );
590  //if making extras and the seeds at the same time, change the seed ref on the trajectory
592  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
593  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
594  trackRefs[oldKey] );
595  }
596  }
597  }}
598 
599  e.put(outputTrks);
600  if (copyExtras_) {
601  e.put(outputTrkExtras);
602  e.put(outputTrkHits);
603  if (makeReKeyedSeeds_)
604  e.put(outputSeeds);
605  }
606  e.put(outputTrajs);
607  e.put(outputTTAss);
608  return;
609 
610  }//end produce
PropagationDirection direction() const
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
reference back()
Definition: OwnVector.h:340
std::auto_ptr< reco::TrackExtraCollection > outputTrkExtras
TrackQuality
track quality
Definition: TrackBase.h:94
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:40
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< reco::TrackRef > trackRefs
TrackingRecHitRefProd refTrkHits
edm::ProductID clusterProduct(const TrackingRecHit *hit)
std::string const & processName() const
Definition: Provenance.h:63
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:47
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
void push_back(D *&d)
Definition: OwnVector.h:288
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
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:51
std::auto_ptr< TrajectorySeedCollection > outputSeeds
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:59
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
RefProd< PROD > getRefBeforePut()
Definition: Event.h:96
virtual TrackingRecHit * clone() const =0
bool failedToGet() const
Definition: HandleBase.h:80
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:112
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:49
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:38
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:53
key_type key() const
Accessor for product key.
Definition: Ref.h:264
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:62
T const * product() const
Definition: Handle.h:74
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:45
const TrackResiduals & residuals() const
Definition: Track.h:117
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:105
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
std::string const & productInstanceName() const
Definition: Provenance.h:65
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:61
std::auto_ptr< std::vector< Trajectory > > outputTrajs
T x() const
Definition: PV3DBase.h:56
virtual LocalPoint localPosition() const =0
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:61
void reserve(size_t)
Definition: OwnVector.h:282
std::auto_ptr< TrajTrackAssociationCollection > outputTTAss
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:131

Member Data Documentation

edm::ParameterSet cms::SimpleTrackListMerger::conf_
private

Definition at line 49 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::copyExtras_
private

Definition at line 65 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 66 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

std::auto_ptr< TrajectorySeedCollection > cms::SimpleTrackListMerger::outputSeeds
private

Definition at line 56 of file SimpleTrackListMerger.h.

Referenced by produce().

std::auto_ptr< std::vector<Trajectory> > cms::SimpleTrackListMerger::outputTrajs
private

Definition at line 54 of file SimpleTrackListMerger.h.

Referenced by produce().

std::auto_ptr<reco::TrackExtraCollection> cms::SimpleTrackListMerger::outputTrkExtras
private

Definition at line 52 of file SimpleTrackListMerger.h.

Referenced by produce().

std::auto_ptr< TrackingRecHitCollection> cms::SimpleTrackListMerger::outputTrkHits
private

Definition at line 53 of file SimpleTrackListMerger.h.

Referenced by produce().

std::auto_ptr<reco::TrackCollection> cms::SimpleTrackListMerger::outputTrks
private

Definition at line 51 of file SimpleTrackListMerger.h.

Referenced by produce().

std::auto_ptr< TrajTrackAssociationCollection > cms::SimpleTrackListMerger::outputTTAss
private

Definition at line 55 of file SimpleTrackListMerger.h.

Referenced by produce().

edm::RefProd< std::vector<Trajectory> > cms::SimpleTrackListMerger::refTrajs
private

Definition at line 61 of file SimpleTrackListMerger.h.

Referenced by produce().

edm::RefProd< TrajectorySeedCollection > cms::SimpleTrackListMerger::refTrajSeeds
private

Definition at line 63 of file SimpleTrackListMerger.h.

Referenced by produce().

reco::TrackExtraRefProd cms::SimpleTrackListMerger::refTrkExtras
private

Definition at line 59 of file SimpleTrackListMerger.h.

Referenced by produce().

TrackingRecHitRefProd cms::SimpleTrackListMerger::refTrkHits
private

Definition at line 60 of file SimpleTrackListMerger.h.

Referenced by produce().

reco::TrackRefProd cms::SimpleTrackListMerger::refTrks
private

Definition at line 58 of file SimpleTrackListMerger.h.

Referenced by produce().

std::vector<reco::TrackRef> cms::SimpleTrackListMerger::trackRefs
private

Definition at line 62 of file SimpleTrackListMerger.h.

Referenced by produce().