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::TrackListMerger Class Reference

#include <TrackListMerger.h>

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

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
 TrackListMerger (const edm::ParameterSet &conf)
 
 TrackListMerger (const edm::ParameterSet &conf)
 
virtual ~TrackListMerger ()
 
virtual ~TrackListMerger ()
 
- 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

bool allowFirstHitShare_
 
edm::ParameterSet conf_
 
bool copyExtras_
 
double epsilon_
 
double foundHitBonus_
 
std::vector< int > hasSelector_
 
std::vector< std::vector< int > > listsToMerge_
 
double lostHitPenalty_
 
bool makeReKeyedSeeds_
 
double maxNormalizedChisq_
 
unsigned int minFound_
 
double minPT_
 
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
 
std::vector< bool > promoteQuality_
 
reco::TrackBase::TrackQuality qualityToSet_
 
edm::RefProd< std::vector
< Trajectory > > 
refTrajs
 
edm::RefProd
< TrajectorySeedCollection
refTrajSeeds
 
reco::TrackExtraRefProd refTrkExtras
 
TrackingRecHitRefProd refTrkHits
 
reco::TrackRefProd refTrks
 
std::vector< edm::InputTagselectors_
 
double shareFrac_
 
std::vector< edm::InputTagtrackProducers_
 
std::vector< reco::TrackReftrackRefs
 
bool trkQualMod_
 
bool use_sharesInput_
 

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 36 of file TrackListMerger.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file TrackListMerger.cc.

References allowFirstHitShare_, copyExtras_, epsilon_, edm::hlt::Exception, foundHitBonus_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hasSelector_, i, listsToMerge_, lostHitPenalty_, makeReKeyedSeeds_, maxNormalizedChisq_, minFound_, minPT_, convertSQLiteXML::ok, promoteQuality_, reco::TrackBase::qualityByName(), qualityToSet_, selectors_, shareFrac_, trackProducers_, trkQualMod_, reco::TrackBase::undefQuality, and use_sharesInput_.

49  {
50  copyExtras_ = conf.getUntrackedParameter<bool>("copyExtras", true);
51 
52  trackProducers_ = conf.getParameter<std::vector<edm::InputTag> >("TrackProducers");
53  //which of these do I need to turn into vectors?
54  maxNormalizedChisq_ = conf.getParameter<double>("MaxNormalizedChisq");
55  minPT_ = conf.getParameter<double>("MinPT");
56  minFound_ = (unsigned int)conf.getParameter<int>("MinFound");
57  epsilon_ = conf.getParameter<double>("Epsilon");
58  shareFrac_ = conf.getParameter<double>("ShareFrac");
59  allowFirstHitShare_ = conf.getParameter<bool>("allowFirstHitShare");
60  foundHitBonus_ = conf.getParameter<double>("FoundHitBonus");
61  lostHitPenalty_ = conf.getParameter<double>("LostHitPenalty");
62  std::string qualityStr = conf.getParameter<std::string>("newQuality");
63 
64  if (qualityStr != "") {
65  qualityToSet_ = reco::TrackBase::qualityByName(conf.getParameter<std::string>("newQuality"));
66  }
67  else
69 
70  use_sharesInput_ = true;
71  if ( epsilon_ > 0.0 )use_sharesInput_ = false;
72 
73  edm::VParameterSet setsToMerge=conf.getParameter<edm::VParameterSet>("setsToMerge");
74 
75  for ( unsigned int i=0; i<setsToMerge.size(); i++) {
76  listsToMerge_.push_back(setsToMerge[i].getParameter<std::vector< int> >("tLists"));
77  promoteQuality_.push_back(setsToMerge[i].getParameter<bool>("pQual"));
78  }
79 
80  hasSelector_=conf.getParameter<std::vector<int> >("hasSelector");
81  selectors_=conf.getParameter<std::vector<edm::InputTag> >("selectedTrackQuals");
82 
83  trkQualMod_=conf.getParameter<bool>("writeOnlyTrkQuals");
84  if ( trkQualMod_) {
85  bool ok=true;
86  for ( unsigned int i=1; i<trackProducers_.size(); i++) {
87  if (!(trackProducers_[i]==trackProducers_[0])) ok=false;
88  }
89  if ( !ok) {
90  throw cms::Exception("Bad input") << "to use writeOnlyTrkQuals=True all input InputTags must be the same";
91  }
92  produces<edm::ValueMap<int> >();
93  }
94  else{
95  produces<reco::TrackCollection>();
96 
97  makeReKeyedSeeds_ = conf.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
98  if (makeReKeyedSeeds_){
99  copyExtras_=true;
100  produces<TrajectorySeedCollection>();
101  }
102 
103  if (copyExtras_) {
104  produces<reco::TrackExtraCollection>();
105  produces<TrackingRecHitCollection>();
106  }
107  produces< std::vector<Trajectory> >();
108  produces< TrajTrackAssociationCollection >();
109  }
110 
111  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
std::vector< std::vector< int > > listsToMerge_
unsigned int minFound_
std::vector< edm::InputTag > selectors_
std::vector< edm::InputTag > trackProducers_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
std::vector< bool > promoteQuality_
reco::TrackBase::TrackQuality qualityToSet_
std::vector< int > hasSelector_
cms::TrackListMerger::~TrackListMerger ( )
virtual

Definition at line 115 of file TrackListMerger.cc.

115 { }
cms::TrackListMerger::TrackListMerger ( const edm::ParameterSet conf)
explicit
virtual cms::TrackListMerger::~TrackListMerger ( )
virtual

Member Function Documentation

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

Implements edm::EDProducer.

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

Implements edm::EDProducer.

Definition at line 118 of file TrackListMerger.cc.

References reco::TrackExtraBase::add(), reco::TrackBase::algo(), allowFirstHitShare_, asciidump::at, edm::OwnVector< T, P >::back(), begin, reco::TrackBase::chi2(), cms::clusterProductB(), copyExtras_, delta, TrajectorySeed::direction(), end, epsilon_, edm::HandleBase::failedToGet(), spr::find(), foundHitBonus_, TrackingRecHit::geographicalId(), edm::Event::getByLabel(), edm::Event::getProvenance(), edm::Event::getRefBeforePut(), hasSelector_, i, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), TrackingRecHit::isValid(), j, edm::Ref< C, T, F >::key(), listsToMerge_, TrackingRecHit::localPosition(), lostHitPenalty_, makeReKeyedSeeds_, match(), maxNormalizedChisq_, min, minFound_, minPT_, edm::Provenance::moduleLabel(), n, TrajectorySeed::nHits(), reco::TrackBase::numberOfLostHits(), reco::TrackBase::numberOfValidHits(), 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::Provenance::productInstanceName(), promoteQuality_, edm::OwnVector< T, P >::push_back(), edm::Event::put(), qualityToSet_, reco::Track::recHit(), TrajectorySeed::recHits(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), reco::Track::recHitsSize(), refTrajs, refTrajSeeds, refTrkExtras, refTrkHits, refTrks, ClusterRemovalRefSetter::reKey(), edm::OwnVector< T, P >::reserve(), reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), selectors_, reco::TrackExtra::setResiduals(), shareFrac_, TrackingRecHit::sharesInput(), TrackingRecHit::some, TrajectorySeed::startingState(), trackProducers_, trackRefs, trkQualMod_, use_sharesInput_, edm::helpers::KeyVal< K, V >::val, and PV3DBase< T, PVType, FrameType >::x().

119  {
120  // extract tracker geometry
121  //
122  //edm::ESHandle<TrackerGeometry> theG;
123  //es.get<TrackerDigiGeometryRecord>().get(theG);
124 
125  // using namespace reco;
126 
127  // get Inputs
128  // if 1 input list doesn't exist, make an empty list, issue a warning, and continue
129  // this allows TrackListMerger to be used as a cleaner only if handed just one list
130  // if both input lists don't exist, will issue 2 warnings and generate an empty output collection
131  //
132  static const reco::TrackCollection s_empty;
133 
134  std::vector<const reco::TrackCollection *> trackColls;
135  std::vector<edm::Handle<reco::TrackCollection> > trackHandles(trackProducers_.size());
136  for ( unsigned int i=0; i<trackProducers_.size(); i++) {
137  trackColls.push_back(0);
138  //edm::Handle<reco::TrackCollection> trackColl;
139  e.getByLabel(trackProducers_[i], trackHandles[i]);
140  if (trackHandles[i].isValid()) {
141  trackColls[i]= trackHandles[i].product();
142  } else {
143  edm::LogWarning("TrackListMerger") << "TrackCollection " << trackProducers_[i] <<" not found";
144  trackColls[i]=&s_empty;
145  }
146  }
147 
148  unsigned int rSize=0;
149  unsigned int trackCollSizes[trackColls.size()];
150  unsigned int trackCollFirsts[trackColls.size()];
151  for (unsigned int i=0; i<trackColls.size(); i++) {
152  trackCollSizes[i]=trackColls[i]->size();
153  trackCollFirsts[i]=rSize;
154  rSize+=trackCollSizes[i];
155  }
156 
157 
158  //
159  // quality cuts first
160  //
161  int i=-1;
162 
163  int selected[rSize];
164  bool trkUpdated[rSize];
165  int trackCollNum[rSize];
166  int trackQuals[rSize];
167  for (unsigned int j=0; j<rSize;j++) {
168  selected[j]=1; trkUpdated[j]=false; trackCollNum[j]=0; trackQuals[j]=0;
169  }
170 
171  for (unsigned int j=0; j< trackColls.size(); j++) {
172  const reco::TrackCollection *tC1=trackColls[j];
173 
174  edm::Handle<edm::ValueMap<int> > trackSelColl;
175  if ( hasSelector_[j]>0 ){
176  e.getByLabel(selectors_[j], trackSelColl);
177  }
178 
179  if ( 0<tC1->size() ){
180  unsigned int iC=0;
181  for (reco::TrackCollection::const_iterator track=tC1->begin(); track!=tC1->end(); track++){
182  i++;
183  trackCollNum[i]=j;
184  trackQuals[i]=track->qualityMask();
185 
186  if ( hasSelector_[j]>0 ) {
187  reco::TrackRef trkRef=reco::TrackRef(trackHandles[j],iC);
188  int qual=(*trackSelColl)[trkRef];
189  if ( qual < 0 ) {
190  selected[i]=0;
191  iC++;
192  continue;
193  }
194  else{
195  trackQuals[i]=qual;
196  }
197  }
198  iC++;
199  selected[i]=trackQuals[i]+10;//10 is magic number used throughout...
200  if ((short unsigned)track->ndof() < 1){
201  selected[i]=0;
202  continue;
203  }
204  if (track->normalizedChi2() > maxNormalizedChisq_){
205  selected[i]=0;
206  continue;
207  }
208  if (track->found() < minFound_){
209  selected[i]=0;
210  continue;
211  }
212  if (track->pt() < minPT_){
213  selected[i]=0;
214  continue;
215  }
216  //if ( beVerb) std::cout << "inverb " << track->pt() << " " << selected[i] << std::endl;
217  }//end loop over tracks
218  }//end more than 0 track
219  } // loop over trackcolls
220 
221 
222 
223  //cache the rechits and valid hits
224  std::vector<const TrackingRecHit*> rh1[rSize]; // an array of vectors!
225  int validHits[rSize];
226  int lostHits[rSize];
227  for ( unsigned int i=0; i<rSize; i++) {
228  validHits[i]=0;
229  lostHits[i]=0;
230  if (selected[i]==0) continue;
231  unsigned int collNum=trackCollNum[i];
232  unsigned int trackNum=i-trackCollFirsts[collNum];
233  const reco::Track *track=&((trackColls[collNum])->at(trackNum));
234  validHits[i]=track->numberOfValidHits();
235  lostHits[i]=track->numberOfLostHits();
236 
237  rh1[i].reserve(track->recHitsSize());
238  for (trackingRecHit_iterator it = track->recHitsBegin(); it != track->recHitsEnd(); ++it) {
239  const TrackingRecHit* hit = &(**it);
240  rh1[i].push_back(hit);
241  }
242  }
243 
244  //DL here
245  for ( unsigned int ltm=0; ltm<listsToMerge_.size(); ltm++) {
246  if ( rSize==0 ) continue;
247  int saveSelected[rSize];
248  for ( unsigned int i=0; i<rSize; i++) saveSelected[i]=selected[i];
249 
250  //DL protect against 0 tracks?
251  for ( unsigned int i=0; i<rSize-1; i++) {
252  if (selected[i]==0) continue;
253  unsigned int collNum=trackCollNum[i];
254  //nothing to do if this is the last collection
255  if (collNum==(rSize-1)) continue;
256 
257  //check that this track is in one of the lists for this iteration
258  std::vector<int>::iterator isActive=find(listsToMerge_[ltm].begin(),listsToMerge_[ltm].end(),collNum);
259  if ( isActive==listsToMerge_[ltm].end() ) continue;
260  unsigned int trackNum=i-trackCollFirsts[collNum];
261  const reco::Track *track=&((trackColls[collNum])->at(trackNum));
262  unsigned nh1=rh1[i].size();
263  int qualityMaskT1 = trackQuals[i];
264 
265  int nhit1 = validHits[i];
266  int lhit1 = lostHits[i];
267 
268  for ( unsigned int j=i+1; j<rSize; j++) {
269  if (selected[j]==0) continue;
270  unsigned int collNum2=trackCollNum[j];
271  if ( collNum == collNum2) continue;
272 
273  //check that this track is in one of the lists for this iteration
274  std::vector<int>::iterator isActive=find(listsToMerge_[ltm].begin(),listsToMerge_[ltm].end(),collNum2);
275  if ( isActive==listsToMerge_[ltm].end() ) continue;
276 
277  unsigned int trackNum2=j-trackCollFirsts[collNum2];
278  const reco::Track *track2=&((trackColls[collNum2])->at(trackNum2));
279 
280  //loop over rechits
281  int noverlap=0;
282  int firstoverlap=0;
283  unsigned nh2=track2->recHitsSize();
284 
285  for ( unsigned ih=0; ih<nh1; ++ih ) {
286  const TrackingRecHit* it = rh1[i][ih];
287  if (!it->isValid()) continue;
288  for ( unsigned jh=0; jh<nh2; ++jh ) {
289  const TrackingRecHit *jt=rh1[j][jh];
290  if (!jt->isValid() ) continue;
291  if ( (it->geographicalId()|3) !=(jt->geographicalId()|3) ) continue; // VI: mask mono/stereo...
292  if (!use_sharesInput_){
293  float delta = fabs ( it->localPosition().x()-jt->localPosition().x() );
294  if ((it->geographicalId()==jt->geographicalId())&&(delta<epsilon_)) {
295  noverlap++;
296  if ( allowFirstHitShare_ && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
297  }
298  }else{
299  if ( it->sharesInput(jt,TrackingRecHit::some) ) {
300  noverlap++;
301  if ( allowFirstHitShare_ && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
302  } // tracks share input
303  } //else use_sharesInput
304  } // rechits on second track
305  } //loop over ih (rechits on first track
306 
307  int newQualityMask = -9; //avoid resetting quality mask if not desired 10+ -9 =1
308  if (promoteQuality_[ltm]) {
309  int maskT1= saveSelected[i]>1? saveSelected[i]-10 : qualityMaskT1;
310  int maskT2= saveSelected[j]>1? saveSelected[j]-10 : trackQuals[j];
311  newQualityMask =(maskT1 | maskT2); // take OR of trackQuality
312  }
313  int nhit2 = validHits[j];
314  int lhit2 = lostHits[j];
315 
316  if ( (noverlap-firstoverlap) > (std::min(nhit1,nhit2)-firstoverlap)*shareFrac_ ) {
317  double score1 = foundHitBonus_*nhit1 - lostHitPenalty_*lhit1 - track->chi2();
318  double score2 = foundHitBonus_*nhit2 - lostHitPenalty_*lhit2 - track2->chi2();
319  const double almostSame = 1.001;
320  if ( score1 > almostSame * score2 ) {
321  selected[j]=0;
322  selected[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
323  trkUpdated[i]=true;
324  } else if ( score2 > almostSame * score1 ) {
325  selected[i]=0;
326  selected[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
327  trkUpdated[j]=true;
328  }else{
329  // If tracks from both iterations are virtually identical, choose the one from the first iteration.
330  if (track->algo() <= track2->algo()) {
331  selected[j]=0;
332  selected[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
333  trkUpdated[i]=true;
334  }else{
335  selected[i]=0;
336  selected[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
337  trkUpdated[j]=true;
338  }
339  }//end fi < fj
340  }//end got a duplicate
341  //stop if the ith track is now unselected
342  if (selected[i]==0) break;
343  }//end track2 loop
344  }//end track loop
345  } //end loop over track list sets
346 
347 
348 
349  // special case - if just doing the trkquals
350  if (trkQualMod_) {
351  std::auto_ptr<edm::ValueMap<int> > vm = std::auto_ptr<edm::ValueMap<int> >(new edm::ValueMap<int>);
352  edm::ValueMap<int>::Filler filler(*vm);
353 
354  unsigned int tSize=trackColls[0]->size();
355  std::vector<int> finalQuals(tSize,-1); //default is unselected
356  for ( unsigned int i=0; i<rSize; i++) {
357  unsigned int tNum=i%tSize;
358 
359  if (selected[i]>1 ) {
360  finalQuals[tNum]=selected[i]-10;
361  if (trkUpdated[i])
362  finalQuals[tNum]=(finalQuals[tNum] | (1<<qualityToSet_));
363  }
364  if ( selected[i]==1 )
365  finalQuals[tNum]=trackQuals[i];
366  }
367 
368  filler.insert(trackHandles[0], finalQuals.begin(),finalQuals.end());
369  filler.fill();
370 
371  e.put(vm);
372  return;
373  }
374 
375 
376  //
377  // output selected tracks - if any
378  //
379 
380  trackRefs.resize(rSize);
381  std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(rSize);
382 
383  unsigned int nToWrite=0;
384  for ( unsigned int i=0; i<rSize; i++)
385  if (selected[i]!=0) nToWrite++;
386 
387 
388  outputTrks = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection);
389  outputTrks->reserve(nToWrite);
391 
392  if (copyExtras_) {
393  outputTrkExtras = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
394  outputTrkExtras->reserve(nToWrite);
396  outputTrkHits = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
397  outputTrkHits->reserve(nToWrite*25);
399  if (makeReKeyedSeeds_){
400  outputSeeds = std::auto_ptr<TrajectorySeedCollection>(new TrajectorySeedCollection);
401  outputSeeds->reserve(nToWrite);
403  }
404  }
405 
406 
407  outputTrajs = std::auto_ptr< std::vector<Trajectory> >(new std::vector<Trajectory>());
408  outputTrajs->reserve(rSize);
409  outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection());
410 
411 
412 
413  for ( unsigned int i=0; i<rSize; i++) {
414  if (selected[i]==0) {
416  continue;
417  }
418 
419  unsigned int collNum=trackCollNum[i];
420  unsigned int trackNum=i-trackCollFirsts[collNum];
421  const reco::Track *track=&((trackColls[collNum])->at(trackNum));
422  outputTrks->push_back( reco::Track( *track ) );
423  if (selected[i]>1 ) {
424  outputTrks->back().setQualityMask(selected[i]-10);
425  if (trkUpdated[i])
426  outputTrks->back().setQuality(qualityToSet_);
427  }
428  //might duplicate things, but doesnt hurt
429  if ( selected[i]==1 )
430  outputTrks->back().setQualityMask(trackQuals[i]);
431 
432  // if ( beVerb ) std::cout << "selected " << outputTrks->back().pt() << " " << outputTrks->back().qualityMask() << " " << selected[i] << std::endl;
433 
434  //fill the TrackCollection
435  if (copyExtras_) {
436  edm::RefToBase<TrajectorySeed> origSeedRef = track->seedRef();
437  //creating a seed with rekeyed clusters if required
438  if (makeReKeyedSeeds_){
439  bool doRekeyOnThisSeed=false;
440 
441  edm::InputTag clusterRemovalInfos("");
442  //grab on of the hits of the seed
443  if (origSeedRef->nHits()!=0){
444  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
445  const TrackingRecHit *hit = &*firstHit;
446  if (firstHit->isValid()){
448  // the cluster collection either produced a removalInfo or mot
449  //get the clusterremoval info from the provenance: will rekey if this is found
451  edm::Provenance prov=e.getProvenance(pID);
452  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
453  prov.productInstanceName(),
454  prov.processName());
455  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
456  }//valid hit
457  }//nhit!=0
458 
459  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag(""))) {
460  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
461  TrajectorySeed::recHitContainer newRecHitContainer;
462  newRecHitContainer.reserve(origSeedRef->nHits());
463  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
464  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
465  for (;iH!=iH_end;++iH){
466  newRecHitContainer.push_back(*iH);
467  refSetter.reKey(&newRecHitContainer.back());
468  }
469  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
470  newRecHitContainer,
471  origSeedRef->direction()));
472  }
473  //doRekeyOnThisSeed=true
474  else{
475  //just copy the one we had before
476  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
477  }
479  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
480  }//creating a new seed and rekeying it rechit clusters.
481 
482  // Fill TrackExtra collection
483  outputTrkExtras->push_back( reco::TrackExtra(
484  track->outerPosition(), track->outerMomentum(), track->outerOk(),
485  track->innerPosition(), track->innerMomentum(), track->innerOk(),
486  track->outerStateCovariance(), track->outerDetId(),
487  track->innerStateCovariance(), track->innerDetId(),
488  track->seedDirection(), origSeedRef ) );
489  seedsRefs[i]=origSeedRef;
490  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
491  reco::TrackExtra & tx = outputTrkExtras->back();
492  tx.setResiduals(track->residuals());
493 
494  // fill TrackingRecHits
495  unsigned nh1=track->recHitsSize();
496  for ( unsigned ih=0; ih<nh1; ++ih ) {
497  //const TrackingRecHit*hit=&((*(track->recHit(ih))));
498  outputTrkHits->push_back( track->recHit(ih)->clone() );
499  tx.add( TrackingRecHitRef( refTrkHits, outputTrkHits->size() - 1) );
500  }
501  }
502  trackRefs[i] = reco::TrackRef(refTrks, outputTrks->size() - 1);
503 
504 
505  }//end faux loop over tracks
506 
507  //Fill the trajectories, etc. for 1st collection
508  refTrajs = e.getRefBeforePut< std::vector<Trajectory> >();
509 
510  for (unsigned int ti=0; ti<trackColls.size(); ti++) {
513  e.getByLabel(trackProducers_[ti], hTraj1);
514  e.getByLabel(trackProducers_[ti], hTTAss1);
515 
516  if (hTraj1.failedToGet() || hTTAss1.failedToGet()) continue;
517 
518  for (size_t i = 0, n = hTraj1->size(); i < n; ++i) {
519  edm::Ref< std::vector<Trajectory> > trajRef(hTraj1, i);
520  TrajTrackAssociationCollection::const_iterator match = hTTAss1->find(trajRef);
521  if (match != hTTAss1->end()) {
522  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
523  short oldKey = trackCollFirsts[ti]+static_cast<short>(trkRef.key());
524  if (trackRefs[oldKey].isNonnull()) {
525  outputTrajs->push_back( *trajRef );
526  //if making extras and the seeds at the same time, change the seed ref on the trajectory
528  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
529  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
530  trackRefs[oldKey] );
531  }
532  }
533  }
534  }
535 
536  e.put(outputTrks);
537  if (copyExtras_) {
538  e.put(outputTrkExtras);
539  e.put(outputTrkHits);
540  if (makeReKeyedSeeds_)
541  e.put(outputSeeds);
542  }
543  e.put(outputTrajs);
544  e.put(outputTTAss);
545  return;
546 
547  }//end produce
PropagationDirection direction() const
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
reference back()
Definition: OwnVector.h:320
std::auto_ptr< TrajectorySeedCollection > outputSeeds
std::auto_ptr< std::vector< Trajectory > > outputTrajs
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:69
std::auto_ptr< reco::TrackCollection > outputTrks
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
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:234
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< std::vector< int > > listsToMerge_
std::string const & processName() const
Definition: Provenance.h:63
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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
TrackAlgorithm algo() const
Definition: TrackBase.h:332
void push_back(D *&d)
Definition: OwnVector.h:273
std::vector< TrajectorySeed > TrajectorySeedCollection
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:107
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
TrackingRecHitRefProd refTrkHits
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:51
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:59
unsigned int minFound_
int j
Definition: DBlmapReader.cc:9
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
edm::ProductID clusterProductB(const TrackingRecHit *hit)
reco::TrackRefProd refTrks
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:232
#define end
Definition: vmac.h:38
std::auto_ptr< reco::TrackExtraCollection > outputTrkExtras
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
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
std::vector< edm::InputTag > selectors_
std::vector< edm::InputTag > trackProducers_
bool failedToGet() const
Definition: HandleBase.h:80
reco::TrackExtraRefProd refTrkExtras
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
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
std::vector< bool > promoteQuality_
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
std::vector< reco::TrackRef > trackRefs
unsigned int nHits() const
#define begin
Definition: vmac.h:31
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:67
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
std::auto_ptr< TrackingRecHitCollection > outputTrkHits
DetId geographicalId() const
std::string const & productInstanceName() const
Definition: Provenance.h:64
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:60
reco::TrackBase::TrackQuality qualityToSet_
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
edm::RefProd< std::vector< Trajectory > > refTrajs
std::vector< int > hasSelector_
list at
Definition: asciidump.py:428
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
std::auto_ptr< TrajTrackAssociationCollection > outputTTAss
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:131

Member Data Documentation

bool cms::TrackListMerger::allowFirstHitShare_
private

Definition at line 78 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

edm::ParameterSet cms::TrackListMerger::conf_
private

Definition at line 39 of file TrackListMerger.h.

bool cms::TrackListMerger::copyExtras_
private

Definition at line 61 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::epsilon_
private

Definition at line 68 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::foundHitBonus_
private

Definition at line 70 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

std::vector<int> cms::TrackListMerger::hasSelector_
private

Definition at line 75 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

std::vector< std::vector< int> > cms::TrackListMerger::listsToMerge_
private

Definition at line 73 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::lostHitPenalty_
private

Definition at line 71 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

bool cms::TrackListMerger::makeReKeyedSeeds_
private

Definition at line 62 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::maxNormalizedChisq_
private

Definition at line 65 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

unsigned int cms::TrackListMerger::minFound_
private

Definition at line 67 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::minPT_
private

Definition at line 66 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

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

Definition at line 52 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 50 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 48 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 49 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 47 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 51 of file TrackListMerger.h.

Referenced by produce().

std::vector<bool> cms::TrackListMerger::promoteQuality_
private

Definition at line 74 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

reco::TrackBase::TrackQuality cms::TrackListMerger::qualityToSet_
private

Definition at line 79 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

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

Definition at line 57 of file TrackListMerger.h.

Referenced by produce().

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

Definition at line 59 of file TrackListMerger.h.

Referenced by produce().

reco::TrackExtraRefProd cms::TrackListMerger::refTrkExtras
private

Definition at line 55 of file TrackListMerger.h.

Referenced by produce().

TrackingRecHitRefProd cms::TrackListMerger::refTrkHits
private

Definition at line 56 of file TrackListMerger.h.

Referenced by produce().

reco::TrackRefProd cms::TrackListMerger::refTrks
private

Definition at line 54 of file TrackListMerger.h.

Referenced by produce().

std::vector<edm::InputTag> cms::TrackListMerger::selectors_
private

Definition at line 76 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

double cms::TrackListMerger::shareFrac_
private

Definition at line 69 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

std::vector<edm::InputTag> cms::TrackListMerger::trackProducers_
private

Definition at line 64 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

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

Definition at line 58 of file TrackListMerger.h.

Referenced by produce().

bool cms::TrackListMerger::trkQualMod_
private

Definition at line 81 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().

bool cms::TrackListMerger::use_sharesInput_
private

Definition at line 80 of file TrackListMerger.h.

Referenced by produce(), and TrackListMerger().