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

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::copyExtras_
private

Definition at line 64 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 65 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 55 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 53 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 51 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 52 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 50 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 54 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 60 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 62 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 58 of file SimpleTrackListMerger.h.

Referenced by produce().

TrackingRecHitRefProd cms::SimpleTrackListMerger::refTrkHits
private

Definition at line 59 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 57 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 61 of file SimpleTrackListMerger.h.

Referenced by produce().