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
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::string trackProducer1
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
trackProducer1AssToken
 
edm::EDGetTokenT
< reco::TrackCollection
trackProducer1Token
 
edm::EDGetTokenT< std::vector
< Trajectory > > 
trackProducer1TrajToken
 
std::string trackProducer2
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
trackProducer2AssToken
 
edm::EDGetTokenT
< reco::TrackCollection
trackProducer2Token
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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 32 of file SimpleTrackListMerger.cc.

Constructor & Destructor Documentation

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

Definition at line 127 of file SimpleTrackListMerger.cc.

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

127  :
128  conf_(conf)
129  {
130 
131  edm::LogWarning("SimpleTrackListMerger") << "this class is obsolete, please use TrackListMerger";
132 
133  copyExtras_ = conf_.getUntrackedParameter<bool>("copyExtras", true);
134 
135  produces<reco::TrackCollection>();
136 
137  makeReKeyedSeeds_ = conf_.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
138  if (makeReKeyedSeeds_){
139  copyExtras_=true;
140  produces<TrajectorySeedCollection>();
141  }
142 
143  if (copyExtras_) {
144  produces<reco::TrackExtraCollection>();
145  produces<TrackingRecHitCollection>();
146  }
147  produces< std::vector<Trajectory> >();
148  produces< TrajTrackAssociationCollection >();
149 
150  trackProducer1 = conf_.getParameter<std::string>("TrackProducer1");
151  trackProducer2 = conf_.getParameter<std::string>("TrackProducer2");
152 
153  trackProducer1Token = consumes<reco::TrackCollection>(trackProducer1);
154  trackProducer2Token = consumes<reco::TrackCollection>(trackProducer2);
155  trackProducer1TrajToken = consumes< std::vector<Trajectory> >(trackProducer1);
156  trackProducer2TrajToken = consumes< std::vector<Trajectory> >(trackProducer2);
157  trackProducer1AssToken = consumes< TrajTrackAssociationCollection >(trackProducer1);
158  trackProducer2AssToken = consumes< TrajTrackAssociationCollection >(trackProducer2);
159 
160  }
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 164 of file SimpleTrackListMerger.cc.

164 { }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 167 of file SimpleTrackListMerger.cc.

References HLT_25ns10e33_v2_cff::allowFirstHitShare, edm::OwnVector< T, P >::back(), TrackingRecHit::clone(), conf_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, copyExtras_, delta, TrajectorySeed::direction(), geometryDiff::epsilon, edm::HandleBase::failedToGet(), HLT_25ns10e33_v2_cff::foundHitBonus, TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::getByToken(), 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(), HLT_25ns10e33_v2_cff::InputTag, edm::HandleBase::isValid(), TrackingRecHit::isValid(), j, findQualityFiles::jj, edm::Ref< C, T, F >::key(), TrackingRecHit::localPosition(), HLT_25ns10e33_v2_cff::lostHitPenalty, makeReKeyedSeeds_, match(), min(), HLT_25ns10e33_v2_cff::minPT, edm::Provenance::moduleLabel(), gen::n, TrajectorySeed::nHits(), hltrates_dqm_sourceclient-live_cfg::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::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), HLT_25ns10e33_v2_cff::shareFrac, TrackingRecHit::sharesInput(), TrackingRecHit::some, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, trackAlgoPriorityOrder, trackProducer1, trackProducer1AssToken, trackProducer1Token, trackProducer1TrajToken, trackProducer2, trackProducer2AssToken, trackProducer2Token, trackProducer2TrajToken, trackRefs, reco::TrackBase::undefQuality, and PV3DBase< T, PVType, FrameType >::x().

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

Member Data Documentation

edm::ParameterSet SimpleTrackListMerger::conf_
private

Definition at line 42 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::copyExtras_
private

Definition at line 58 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 59 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 49 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 47 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 45 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 46 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 44 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 48 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 54 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 56 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackExtraRefProd SimpleTrackListMerger::refTrkExtras
private

Definition at line 52 of file SimpleTrackListMerger.cc.

Referenced by produce().

TrackingRecHitRefProd SimpleTrackListMerger::refTrkHits
private

Definition at line 53 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackRefProd SimpleTrackListMerger::refTrks
private

Definition at line 51 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::string SimpleTrackListMerger::trackProducer1
private

Definition at line 60 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 64 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 61 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 63 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

std::string SimpleTrackListMerger::trackProducer2
private

Definition at line 60 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 66 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 62 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 65 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 55 of file SimpleTrackListMerger.cc.

Referenced by produce().