CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SimpleTrackListMerger Class Reference
Inheritance diagram for SimpleTrackListMerger:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
 SimpleTrackListMerger (const edm::ParameterSet &conf)
 
virtual ~SimpleTrackListMerger ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::ParameterSet conf_
 
bool copyExtras_
 
bool makeReKeyedSeeds_
 
std::unique_ptr< TrajectorySeedCollectionoutputSeeds
 
std::unique_ptr< std::vector< Trajectory > > outputTrajs
 
std::unique_ptr< reco::TrackExtraCollectionoutputTrkExtras
 
std::unique_ptr< TrackingRecHitCollectionoutputTrkHits
 
std::unique_ptr< reco::TrackCollectionoutputTrks
 
std::unique_ptr< TrajTrackAssociationCollectionoutputTTAss
 
std::string priorityName_
 
edm::RefProd< std::vector< Trajectory > > refTrajs
 
edm::RefProd< TrajectorySeedCollectionrefTrajSeeds
 
reco::TrackExtraRefProd refTrkExtras
 
TrackingRecHitRefProd refTrkHits
 
reco::TrackRefProd refTrks
 
std::string trackProducer1
 
edm::EDGetTokenT< TrajTrackAssociationCollectiontrackProducer1AssToken
 
edm::EDGetTokenT< reco::TrackCollectiontrackProducer1Token
 
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
 
std::string trackProducer2
 
edm::EDGetTokenT< TrajTrackAssociationCollectiontrackProducer2AssToken
 
edm::EDGetTokenT< reco::TrackCollectiontrackProducer2Token
 
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
 
std::vector< reco::TrackReftrackRefs
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 33 of file SimpleTrackListMerger.cc.

Constructor & Destructor Documentation

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

Definition at line 130 of file SimpleTrackListMerger.cc.

References conf_, copyExtras_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), makeReKeyedSeeds_, priorityName_, AlCaHLTBitMon_QueryRunRegistry::string, trackProducer1, trackProducer1AssToken, trackProducer1Token, trackProducer1TrajToken, trackProducer2, trackProducer2AssToken, trackProducer2Token, and trackProducer2TrajToken.

130  :
131  conf_(conf)
132  {
133 
134  edm::LogWarning("SimpleTrackListMerger") << "this class is obsolete, please use TrackListMerger";
135 
136  copyExtras_ = conf_.getUntrackedParameter<bool>("copyExtras", true);
137 
138  produces<reco::TrackCollection>();
139 
140  makeReKeyedSeeds_ = conf_.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
141  if (makeReKeyedSeeds_){
142  copyExtras_=true;
143  produces<TrajectorySeedCollection>();
144  }
145 
146  if (copyExtras_) {
147  produces<reco::TrackExtraCollection>();
148  produces<TrackingRecHitCollection>();
149  }
150  produces< std::vector<Trajectory> >();
151  produces< TrajTrackAssociationCollection >();
152 
153  trackProducer1 = conf_.getParameter<std::string>("TrackProducer1");
154  trackProducer2 = conf_.getParameter<std::string>("TrackProducer2");
155 
156  trackProducer1Token = consumes<reco::TrackCollection>(trackProducer1);
157  trackProducer2Token = consumes<reco::TrackCollection>(trackProducer2);
158  trackProducer1TrajToken = consumes< std::vector<Trajectory> >(trackProducer1);
159  trackProducer2TrajToken = consumes< std::vector<Trajectory> >(trackProducer2);
160  trackProducer1AssToken = consumes< TrajTrackAssociationCollection >(trackProducer1);
161  trackProducer2AssToken = consumes< TrajTrackAssociationCollection >(trackProducer2);
162 
163  priorityName_ = conf.getParameter<std::string>("trackAlgoPriorityOrder");
164  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
edm::EDGetTokenT< reco::TrackCollection > trackProducer2Token
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
SimpleTrackListMerger::~SimpleTrackListMerger ( )
virtual

Definition at line 168 of file SimpleTrackListMerger.cc.

168 { }

Member Function Documentation

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

Definition at line 171 of file SimpleTrackListMerger.cc.

References conversionTrackMerger_cfi::allowFirstHitShare, edm::OwnVector< T, P >::back(), TrackingRecHit::clone(), conf_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, copyExtras_, DEFINE_FWK_MODULE, delta, TrajectorySeed::direction(), edm::AssociationMap< Tag >::end(), geometryDiff::epsilon, edm::HandleBase::failedToGet(), edm::AssociationMap< Tag >::find(), DisplacedMuonSeededStep_cff::foundHitBonus, TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), edm::Event::getProvenance(), edm::Event::getRefBeforePut(), mps_fire::i, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), createfilelist::int, edm::HandleBase::isValid(), TrackingRecHit::isValid(), findQualityFiles::jj, edm::Ref< C, T, F >::key(), TrackingRecHit::localPosition(), gsfElectronCkfTrackCandidateMaker_cff::lostHitPenalty, makeReKeyedSeeds_, match(), min(), edm::Provenance::moduleLabel(), eostools::move(), gen::n, TrajectorySeed::nHits(), PFRecoTauDiscriminationByIsolation_cfi::offset, reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), outputSeeds, outputTrajs, outputTrkExtras, outputTrkHits, outputTrks, outputTTAss, priorityName_, edm::Provenance::processName(), edm::Handle< T >::product(), edm::Provenance::productInstanceName(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), reco::TrackBase::qualityByName(), HICaloCompatibleTracks_cfi::qualityToSet, TrajectorySeed::recHits(), refTrajs, refTrajSeeds, refTrkExtras, refTrkHits, refTrks, ClusterRemovalRefSetter::reKey(), edm::OwnVector< T, P >::reserve(), reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), DetachedQuadStep_cff::shareFrac, TrackingRecHit::sharesInput(), TrackingRecHit::some, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, HiIsolationCommonParameters_cff::track, trackAlgoPriorityOrder, trackProducer1, trackProducer1AssToken, trackProducer1Token, trackProducer1TrajToken, trackProducer2, trackProducer2AssToken, trackProducer2Token, trackProducer2TrajToken, trackRefs, reco::TrackBase::undefQuality, and PV3DBase< T, PVType, FrameType >::x().

172  {
173  // retrieve producer name of input TrackCollection(s)
174 
175  double maxNormalizedChisq = conf_.getParameter<double>("MaxNormalizedChisq");
176  double minPT = conf_.getParameter<double>("MinPT");
177  unsigned int minFound = (unsigned int)conf_.getParameter<int>("MinFound");
178  double epsilon = conf_.getParameter<double>("Epsilon");
179  bool use_sharesInput = true;
180  if ( epsilon > 0.0 )use_sharesInput = false;
181  double shareFrac = conf_.getParameter<double>("ShareFrac");
182  double foundHitBonus = conf_.getParameter<double>("FoundHitBonus");
183  double lostHitPenalty = conf_.getParameter<double>("LostHitPenalty");
184 
185  bool promoteQuality = conf_.getParameter<bool>("promoteTrackQuality");
186  bool allowFirstHitShare = conf_.getParameter<bool>("allowFirstHitShare");
187 //
188 
189  // New track quality should be read from the file
190  std::string qualityStr = conf_.getParameter<std::string>("newQuality");
192  if (qualityStr != "") {
193  qualityToSet = reco::TrackBase::qualityByName(conf_.getParameter<std::string>("newQuality"));
194  }
195  else
196  qualityToSet = reco::TrackBase::undefQuality;
197 
198  // extract tracker geometry
199  //
201  es.get<TrackerDigiGeometryRecord>().get(theG);
202 
204  es.get<CkfComponentsRecord>().get(priorityName_, priorityH);
205  auto const & trackAlgoPriorityOrder = *priorityH;
206 
207 // using namespace reco;
208 
209  // get Inputs
210  // if 1 input list doesn't exist, make an empty list, issue a warning, and continue
211  // this allows SimpleTrackListMerger to be used as a cleaner only if handed just one list
212  // if both input lists don't exist, will issue 2 warnings and generate an empty output collection
213  //
214  const reco::TrackCollection *TC1 = 0;
215  static const reco::TrackCollection s_empty1, s_empty2;
216  edm::Handle<reco::TrackCollection> trackCollection1;
217  e.getByToken(trackProducer1Token, trackCollection1);
218  if (trackCollection1.isValid()) {
219  TC1 = trackCollection1.product();
220  //std::cout << "1st collection " << trackProducer1 << " has "<< TC1->size() << " tracks" << std::endl ;
221  } else {
222  TC1 = &s_empty1;
223  edm::LogWarning("SimpleTrackListMerger") << "1st TrackCollection " << trackProducer1 << " not found; will only clean 2nd TrackCollection " << trackProducer2 ;
224  }
225  const reco::TrackCollection tC1 = *TC1;
226 
227  const reco::TrackCollection *TC2 = 0;
228  edm::Handle<reco::TrackCollection> trackCollection2;
229  e.getByToken(trackProducer2Token, trackCollection2);
230  if (trackCollection2.isValid()) {
231  TC2 = trackCollection2.product();
232  //std::cout << "2nd collection " << trackProducer2 << " has "<< TC2->size() << " tracks" << std::endl ;
233  } else {
234  TC2 = &s_empty2;
235  edm::LogWarning("SimpleTrackListMerger") << "2nd TrackCollection " << trackProducer2 << " not found; will only clean 1st TrackCollection " << trackProducer1 ;
236  }
237  const reco::TrackCollection tC2 = *TC2;
238 
239  // Step B: create empty output collection
240  outputTrks = std::make_unique<reco::TrackCollection>();
242 
243  if (copyExtras_) {
244  outputTrkExtras = std::make_unique<reco::TrackExtraCollection>();
245  outputTrkExtras->reserve(TC1->size()+TC2->size());
247  outputTrkHits = std::make_unique<TrackingRecHitCollection>();
248  outputTrkHits->reserve((TC1->size()+TC2->size())*25);
250  if (makeReKeyedSeeds_){
251  outputSeeds = std::make_unique<TrajectorySeedCollection>();
252  outputSeeds->reserve(TC1->size()+TC2->size());
254  }
255  }
256 
257  outputTrajs = std::make_unique<std::vector<Trajectory>>();
258  outputTrajs->reserve(TC1->size()+TC2->size());
259  outputTTAss = std::make_unique<TrajTrackAssociationCollection>();
260  //outputTTAss->reserve(TC1->size()+TC2->size());//how do I reserve space for an association map?
261 
262  //
263  // no input tracks
264  //
265 
266 // if ( tC1.empty() ){
267 // LogDebug("RoadSearch") << "Found " << output.size() << " clouds.";
268 // e.put(std::move(output);
269 // return;
270 // }
271 
272  //
273  // quality cuts first
274  //
275  int i;
276 
277  std::vector<int> selected1; for (unsigned int i=0; i<tC1.size(); ++i){selected1.push_back(1);}
278 
279  if ( 0<tC1.size() ){
280  i=-1;
281  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
282  i++;
283  if ((short unsigned)track->ndof() < 1){
284  selected1[i]=0;
285  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
286  continue;
287  }
288  if (track->normalizedChi2() > maxNormalizedChisq){
289  selected1[i]=0;
290  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
291  continue;
292  }
293  if (track->found() < minFound){
294  selected1[i]=0;
295  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
296  continue;
297  }
298  if (track->pt() < minPT){
299  selected1[i]=0;
300  //std::cout << "L1Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
301  continue;
302  }
303  }//end loop over tracks
304  }//end more than 0 track
305 
306 
307  std::vector<int> selected2; for (unsigned int i=0; i<tC2.size(); ++i){selected2.push_back(1);}
308 
309  if ( 0<tC2.size() ){
310  i=-1;
311  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
312  i++;
313  if ((short unsigned)track->ndof() < 1){
314  selected2[i]=0;
315  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; ndof() < 1" << std::endl ;
316  continue;
317  }
318  if (track->normalizedChi2() > maxNormalizedChisq){
319  selected2[i]=0;
320  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; normalizedChi2() > maxNormalizedChisq " << track->normalizedChi2() << " " << maxNormalizedChisq << std::endl ;
321  continue;
322  }
323  if (track->found() < minFound){
324  selected2[i]=0;
325  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; found() < minFound " << track->found() << " " << minFound << std::endl ;
326  continue;
327  }
328  if (track->pt() < minPT){
329  selected2[i]=0;
330  //std::cout << "L2Track "<< i << " rejected in SimpleTrackListMerger; pt() < minPT " << track->pt() << " " << minPT << std::endl ;
331  continue;
332  }
333  }//end loop over tracks
334  }//end more than 0 track
335 
336  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
337  std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
338  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
339  trackingRecHit_iterator itB = track->recHitsBegin();
340  trackingRecHit_iterator itE = track->recHitsEnd();
341  for (trackingRecHit_iterator it = itB; it != itE; ++it) {
342  const TrackingRecHit* hit = &(**it);
343  rh1[track].push_back(hit);
344  }
345  }
346  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
347  trackingRecHit_iterator jtB = track->recHitsBegin();
348  trackingRecHit_iterator jtE = track->recHitsEnd();
349  for (trackingRecHit_iterator jt = jtB; jt != jtE; ++jt) {
350  const TrackingRecHit* hit = &(**jt);
351  rh2[track].push_back(hit);
352  }
353  }
354 
355  if ( (0<tC1.size())&&(0<tC2.size()) ){
356  i=-1;
357  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
358  i++;
359  if (!selected1[i])continue;
360  std::vector<const TrackingRecHit*>& iHits = rh1[track];
361  unsigned nh1 = iHits.size();
362  int qualityMaskT1 = track->qualityMask();
363  int j=-1;
364  for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
365  j++;
366  if ((!selected2[j])||(!selected1[i]))continue;
367  std::vector<const TrackingRecHit*>& jHits = rh2[track2];
368  unsigned nh2 = jHits.size();
369  int noverlap=0;
370  int firstoverlap=0;
371  for ( unsigned ih=0; ih<nh1; ++ih ) {
372  const TrackingRecHit* it = iHits[ih];
373  if (it->isValid()){
374  int jj=-1;
375  for ( unsigned jh=0; jh<nh2; ++jh ) {
376  const TrackingRecHit* jt = jHits[jh];
377  jj++;
378  if (jt->isValid()){
379  if (!use_sharesInput){
380  float delta = fabs ( it->localPosition().x()-jt->localPosition().x() );
381  if ((it->geographicalId()==jt->geographicalId())&&(delta<epsilon)) {
382  noverlap++;
383  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
384  }
385  }else{
386  if ( it->sharesInput(jt,TrackingRecHit::some) ) {
387  noverlap++;
388  if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
389  }
390  }
391  }
392  }
393  }
394  }
395  int newQualityMask = (qualityMaskT1 | track2->qualityMask()); // take OR of trackQuality
396  int nhit1 = track->numberOfValidHits();
397  int nhit2 = track2->numberOfValidHits();
398  if ( (noverlap-firstoverlap) > (std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
399  double score1 = foundHitBonus*nhit1 - lostHitPenalty*track->numberOfLostHits() - track->chi2();
400  double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
401  const double almostSame = 1.001;
402  if ( score1 > almostSame * score2 ){
403  selected2[j]=0;
404  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
405  }else if ( score2 > almostSame * score1 ){
406  selected1[i]=0;
407  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
408  }else{
409  if (trackAlgoPriorityOrder.priority(track->algo()) <= trackAlgoPriorityOrder.priority(track2->algo())) {
410  selected2[j]=0;
411  selected1[i]=10+newQualityMask; // add 10 to avoid the case where mask = 1
412  }else{
413  selected1[i]=0;
414  selected2[j]=10+newQualityMask; // add 10 to avoid the case where mask = 1
415  }
416  }
417  }//end got a duplicate
418  }//end track2 loop
419  }//end track loop
420  }//end more than 1 track
421 
422  //
423  // output selected tracks - if any
424  //
425  trackRefs.resize(tC1.size()+tC2.size());
426  std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
427  size_t current = 0;
428 
429  if ( 0<tC1.size() ){
430  i=0;
431  for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
432  ++track, ++current, ++i){
433  if (!selected1[i]){
434  trackRefs[current] = reco::TrackRef();
435  continue;
436  }
437  const reco::Track & theTrack = * track;
438  //fill the TrackCollection
439  outputTrks->push_back( reco::Track( theTrack ) );
440  if (selected1[i]>1 && promoteQuality){
441  outputTrks->back().setQualityMask(selected1[i]-10);
442  outputTrks->back().setQuality(qualityToSet);
443  }
444  if (copyExtras_) {
445  //--------NEW----------
446  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
447  //creating a seed with rekeyed clusters if required
448  if (makeReKeyedSeeds_){
449  bool doRekeyOnThisSeed=false;
450 
451  edm::InputTag clusterRemovalInfos("");
452  //grab on of the hits of the seed
453  if (origSeedRef->nHits()!=0){
454  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
455  const TrackingRecHit *hit = &*firstHit;
456  if (firstHit->isValid()){
457  edm::ProductID pID=clusterProduct(hit);
458  // the cluster collection either produced a removalInfo or mot
459  //get the clusterremoval info from the provenance: will rekey if this is found
461  edm::Provenance prov=e.getProvenance(pID);
462  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
463  prov.productInstanceName(),
464  prov.processName());
465  // In case this is switched on, will have to revist that, and declare mayConsumes...
466  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
467  }//valid hit
468  }//nhit!=0
469 
470  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
471  {
472  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
473  TrajectorySeed::recHitContainer newRecHitContainer;
474  newRecHitContainer.reserve(origSeedRef->nHits());
475  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
476  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
477  for (;iH!=iH_end;++iH){
478  newRecHitContainer.push_back(*iH);
479  refSetter.reKey(&newRecHitContainer.back());
480  }
481  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
482  newRecHitContainer,
483  origSeedRef->direction()));
484  }
485  //doRekeyOnThisSeed=true
486  else{
487  //just copy the one we had before
488  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
489  }
491  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
492  }//creating a new seed and rekeying it rechit clusters.
493  //--------NEW----------
494  // Fill TrackExtra collection
495  outputTrkExtras->push_back( reco::TrackExtra(
496  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
497  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
498  theTrack.outerStateCovariance(), theTrack.outerDetId(),
499  theTrack.innerStateCovariance(), theTrack.innerDetId(),
500  theTrack.seedDirection(), origSeedRef ) );
501  seedsRefs[current]=origSeedRef;
502  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
503  reco::TrackExtra & tx = outputTrkExtras->back();
504  tx.setResiduals(theTrack.residuals());
505  // fill TrackingRecHits
506  std::vector<const TrackingRecHit*>& iHits = rh1[track];
507  unsigned nh1 = iHits.size();
508  auto const firstHitIndex = outputTrkHits->size();
509  for ( unsigned ih=0; ih<nh1; ++ih ) {
510  const TrackingRecHit* hit = iHits[ih];
511  //for( trackingRecHit_iterator hit = itB; hit != itE; ++hit ) {
512  outputTrkHits->push_back( hit->clone() );
513  }
514  tx.setHits( refTrkHits, firstHitIndex, nh1 );
515  }
516  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
517 
518 
519  }//end faux loop over tracks
520  }//end more than 0 track
521 
522  //Fill the trajectories, etc. for 1st collection
527  refTrajs = e.getRefBeforePut< std::vector<Trajectory> >();
528 
529  if (!hTraj1.failedToGet() && !hTTAss1.failedToGet()){
530  for (size_t i = 0, n = hTraj1->size(); i < n; ++i) {
531  edm::Ref< std::vector<Trajectory> > trajRef(hTraj1, i);
533  if (match != hTTAss1->end()) {
534  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
535  short oldKey = static_cast<short>(trkRef.key());
536  if (trackRefs[oldKey].isNonnull()) {
537  outputTrajs->push_back( *trajRef );
538  //if making extras and the seeds at the same time, change the seed ref on the trajectory
540  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
541  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
542  trackRefs[oldKey] );
543  }
544  }
545  }
546  }
547 
548  short offset = current; //save offset into trackRefs
549 
550  if ( 0<tC2.size() ){
551  i=0;
552  for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
553  ++track, ++current, ++i){
554  if (!selected2[i]){
555  trackRefs[current] = reco::TrackRef();
556  continue;
557  }
558  const reco::Track & theTrack = * track;
559  //fill the TrackCollection
560  outputTrks->push_back( reco::Track( theTrack ) );
561  if (selected2[i]>1 && promoteQuality){
562  outputTrks->back().setQualityMask(selected2[i]-10);
563  outputTrks->back().setQuality(qualityToSet);
564  }
565  if (copyExtras_) {
566  //--------NEW----------
567  edm::RefToBase<TrajectorySeed> origSeedRef = theTrack.seedRef();
568  //creating a seed with rekeyed clusters if required
569  if (makeReKeyedSeeds_){
570  bool doRekeyOnThisSeed=false;
571 
572  edm::InputTag clusterRemovalInfos("");
573  //grab on of the hits of the seed
574  if (origSeedRef->nHits()!=0){
575  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
576  const TrackingRecHit *hit = &*firstHit;
577  if (firstHit->isValid()){
578  edm::ProductID pID=clusterProduct(hit);
579  // the cluster collection either produced a removalInfo or mot
580  //get the clusterremoval info from the provenance: will rekey if this is found
582  edm::Provenance prov=e.getProvenance(pID);
583  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
584  prov.productInstanceName(),
585  prov.processName());
586  doRekeyOnThisSeed=e.getByLabel(clusterRemovalInfos,CRIh);
587  }//valid hit
588  }//nhit!=0
589 
590  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag("")))
591  {
592  ClusterRemovalRefSetter refSetter(e,clusterRemovalInfos);
593  TrajectorySeed::recHitContainer newRecHitContainer;
594  newRecHitContainer.reserve(origSeedRef->nHits());
595  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
596  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
597  for (;iH!=iH_end;++iH){
598  newRecHitContainer.push_back(*iH);
599  refSetter.reKey(&newRecHitContainer.back());
600  }
601  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
602  newRecHitContainer,
603  origSeedRef->direction()));
604  }//doRekeyOnThisSeed=true
605  else{
606  //just copy the one we had before
607  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
608  }
610  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
611  }//creating a new seed and rekeying it rechit clusters.
612  //--------NEW----------
613  // Fill TrackExtra collection
614  outputTrkExtras->push_back( reco::TrackExtra(
615  theTrack.outerPosition(), theTrack.outerMomentum(), theTrack.outerOk(),
616  theTrack.innerPosition(), theTrack.innerMomentum(), theTrack.innerOk(),
617  theTrack.outerStateCovariance(), theTrack.outerDetId(),
618  theTrack.innerStateCovariance(), theTrack.innerDetId(),
619  theTrack.seedDirection(), origSeedRef ) );
620  seedsRefs[current]=origSeedRef;
621  outputTrks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
622  reco::TrackExtra & tx = outputTrkExtras->back();
623  tx.setResiduals(theTrack.residuals());
624  // fill TrackingRecHits
625  std::vector<const TrackingRecHit*>& jHits = rh2[track];
626  unsigned nh2 = jHits.size();
627  auto const firstHitIndex2 = outputTrkHits->size();
628  for ( unsigned jh=0; jh<nh2; ++jh ) {
629  const TrackingRecHit* hit = jHits[jh];
630  outputTrkHits->push_back( hit->clone() );
631  }
632  tx.setHits( refTrkHits, firstHitIndex2, nh2 );
633  }
634  trackRefs[current] = reco::TrackRef(refTrks, outputTrks->size() - 1);
635 
636  }//end faux loop over tracks
637  }//end more than 0 track
638 
639  //Fill the trajectories, etc. for 2nd collection
644 
645  if (!hTraj2.failedToGet() && !hTTAss2.failedToGet()){
646  for (size_t i = 0, n = hTraj2->size(); i < n; ++i) {
647  edm::Ref< std::vector<Trajectory> > trajRef(hTraj2, i);
648  TrajTrackAssociationCollection::const_iterator match = hTTAss2->find(trajRef);
649  if (match != hTTAss2->end()) {
650  const edm::Ref<reco::TrackCollection> &trkRef = match->val;
651  short oldKey = static_cast<short>(trkRef.key()) + offset;
652  if (trackRefs[oldKey].isNonnull()) {
653  outputTrajs->push_back( Trajectory(*trajRef) );
654  //if making extras and the seeds at the same time, change the seed ref on the trajectory
656  outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
657  outputTTAss->insert ( edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
658  trackRefs[oldKey] );
659  }
660  }
661  }}
662 
664  if (copyExtras_) {
666  e.put(std::move(outputTrkHits));
667  if (makeReKeyedSeeds_)
669  }
670  e.put(std::move(outputTrajs));
672  return;
673 
674  }//end produce
PropagationDirection direction() const
dbl * delta
Definition: mlp_gen.cc:36
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:213
T getParameter(std::string const &) const
std::unique_ptr< reco::TrackCollection > outputTrks
reference back()
Definition: OwnVector.h:395
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
TrackQuality
track quality
Definition: TrackBase.h:151
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
TrackingRecHitRefProd refTrkHits
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
key_type key() const
Accessor for product key.
Definition: Ref.h:264
std::unique_ptr< TrajectorySeedCollection > outputSeeds
std::string const & processName() const
Definition: Provenance.h:52
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
std::unique_ptr< std::vector< Trajectory > > outputTrajs
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
void push_back(D *&d)
Definition: OwnVector.h:290
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:75
virtual TrackingRecHit * clone() const =0
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
T min(T a, T b)
Definition: MathUtil.h:58
virtual LocalPoint localPosition() const =0
bool isValid() const
Definition: HandleBase.h:74
edm::RefProd< std::vector< Trajectory > > refTrajs
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
reco::TrackRefProd refTrks
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
bool failedToGet() const
Definition: HandleBase.h:78
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
PTrajectoryStateOnDet const & startingState() const
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
T const * product() const
Definition: Handle.h:81
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:204
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:80
range recHits() const
bool isValid() const
std::string const & moduleLabel() const
Definition: Provenance.h:50
std::unique_ptr< reco::TrackExtraCollection > outputTrkExtras
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
unsigned int nHits() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
edm::EDGetTokenT< reco::TrackCollection > trackProducer2Token
const TrackResiduals & residuals() const
get the residuals
Definition: Track.h:218
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< reco::TrackRef > trackRefs
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
DetId geographicalId() const
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
std::string const & productInstanceName() const
Definition: Provenance.h:53
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:81
T x() const
Definition: PV3DBase.h:62
reco::TrackExtraRefProd refTrkExtras
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99
def move(src, dest)
Definition: eostools.py:510
void reserve(size_t)
Definition: OwnVector.h:284
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:174

Member Data Documentation

edm::ParameterSet SimpleTrackListMerger::conf_
private

Definition at line 43 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::copyExtras_
private

Definition at line 59 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 60 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

std::unique_ptr<TrajectorySeedCollection> SimpleTrackListMerger::outputSeeds
private

Definition at line 50 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::unique_ptr<std::vector<Trajectory> > SimpleTrackListMerger::outputTrajs
private

Definition at line 48 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::unique_ptr<reco::TrackExtraCollection> SimpleTrackListMerger::outputTrkExtras
private

Definition at line 46 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::unique_ptr<TrackingRecHitCollection> SimpleTrackListMerger::outputTrkHits
private

Definition at line 47 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::unique_ptr<reco::TrackCollection> SimpleTrackListMerger::outputTrks
private

Definition at line 45 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::unique_ptr<TrajTrackAssociationCollection> SimpleTrackListMerger::outputTTAss
private

Definition at line 49 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::string SimpleTrackListMerger::priorityName_
private

Definition at line 69 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 55 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 57 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackExtraRefProd SimpleTrackListMerger::refTrkExtras
private

Definition at line 53 of file SimpleTrackListMerger.cc.

Referenced by produce().

TrackingRecHitRefProd SimpleTrackListMerger::refTrkHits
private

Definition at line 54 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackRefProd SimpleTrackListMerger::refTrks
private

Definition at line 52 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::string SimpleTrackListMerger::trackProducer1
private

Definition at line 61 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT< TrajTrackAssociationCollection > SimpleTrackListMerger::trackProducer1AssToken
private

Definition at line 65 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT<reco::TrackCollection> SimpleTrackListMerger::trackProducer1Token
private

Definition at line 62 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT< std::vector<Trajectory> > SimpleTrackListMerger::trackProducer1TrajToken
private

Definition at line 64 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

std::string SimpleTrackListMerger::trackProducer2
private

Definition at line 61 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT< TrajTrackAssociationCollection > SimpleTrackListMerger::trackProducer2AssToken
private

Definition at line 67 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT<reco::TrackCollection> SimpleTrackListMerger::trackProducer2Token
private

Definition at line 63 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

edm::EDGetTokenT< std::vector<Trajectory> > SimpleTrackListMerger::trackProducer2TrajToken
private

Definition at line 66 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 56 of file SimpleTrackListMerger.cc.

Referenced by produce().