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
 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 31 of file SimpleTrackListMerger.cc.

Constructor & Destructor Documentation

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

Definition at line 126 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.

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

163 { }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 166 of file SimpleTrackListMerger.cc.

References reco::TrackExtraBase::add(), edm::OwnVector< T, P >::back(), TrackingRecHit::clone(), conf_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, copyExtras_, cond::rpcobimon::current, delta, TrajectorySeed::direction(), geometryDiff::epsilon, edm::HandleBase::failedToGet(), 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(), edm::HandleBase::isValid(), TrackingRecHit::isValid(), j, findQualityFiles::jj, edm::Ref< C, T, F >::key(), TrackingRecHit::localPosition(), makeReKeyedSeeds_, match(), min(), edm::Provenance::moduleLabel(), n, TrajectorySeed::nHits(), evf::evtn::offset(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), outputSeeds, outputTrajs, outputTrkExtras, outputTrkHits, outputTrks, outputTTAss, edm::Provenance::processName(), edm::Handle< T >::product(), edm::Provenance::productInstanceName(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), reco::TrackBase::qualityByName(), TrajectorySeed::recHits(), refTrajs, refTrajSeeds, refTrkExtras, refTrkHits, refTrks, ClusterRemovalRefSetter::reKey(), edm::OwnVector< T, P >::reserve(), reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackExtra::setResiduals(), TrackingRecHit::sharesInput(), TrackingRecHit::some, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, trackProducer1, trackProducer1AssToken, trackProducer1Token, trackProducer1TrajToken, trackProducer2, trackProducer2AssToken, trackProducer2Token, trackProducer2TrajToken, trackRefs, reco::TrackBase::undefQuality, and PV3DBase< T, PVType, FrameType >::x().

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

Member Data Documentation

edm::ParameterSet SimpleTrackListMerger::conf_
private

Definition at line 41 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::copyExtras_
private

Definition at line 57 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

bool SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 58 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 48 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 46 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 44 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 45 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 43 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 47 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 53 of file SimpleTrackListMerger.cc.

Referenced by produce().

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

Definition at line 55 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackExtraRefProd SimpleTrackListMerger::refTrkExtras
private

Definition at line 51 of file SimpleTrackListMerger.cc.

Referenced by produce().

TrackingRecHitRefProd SimpleTrackListMerger::refTrkHits
private

Definition at line 52 of file SimpleTrackListMerger.cc.

Referenced by produce().

reco::TrackRefProd SimpleTrackListMerger::refTrks
private

Definition at line 50 of file SimpleTrackListMerger.cc.

Referenced by produce().

std::string SimpleTrackListMerger::trackProducer1
private

Definition at line 59 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 63 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 60 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 62 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

std::string SimpleTrackListMerger::trackProducer2
private

Definition at line 59 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 65 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 61 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 64 of file SimpleTrackListMerger.cc.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 54 of file SimpleTrackListMerger.cc.

Referenced by produce().