CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
cms::SimpleTrackListMerger Class Reference

#include <SimpleTrackListMerger.h>

Inheritance diagram for cms::SimpleTrackListMerger:
edm::EDProducer edm::ProducerBase edm::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::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::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 34 of file SimpleTrackListMerger.h.

Constructor & Destructor Documentation

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

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

69  :
70  conf_(conf)
71  {
72  copyExtras_ = conf_.getUntrackedParameter<bool>("copyExtras", true);
73 
74  produces<reco::TrackCollection>();
75 
76  makeReKeyedSeeds_ = conf_.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
77  if (makeReKeyedSeeds_){
78  copyExtras_=true;
79  produces<TrajectorySeedCollection>();
80  }
81 
82  if (copyExtras_) {
83  produces<reco::TrackExtraCollection>();
84  produces<TrackingRecHitCollection>();
85  }
86  produces< std::vector<Trajectory> >();
87  produces< TrajTrackAssociationCollection >();
88 
89  trackProducer1 = conf_.getParameter<std::string>("TrackProducer1");
90  trackProducer2 = conf_.getParameter<std::string>("TrackProducer2");
91 
92  trackProducer1Token = consumes<reco::TrackCollection>(trackProducer1);
93  trackProducer2Token = consumes<reco::TrackCollection>(trackProducer2);
94  trackProducer1TrajToken = consumes< std::vector<Trajectory> >(trackProducer1);
95  trackProducer2TrajToken = consumes< std::vector<Trajectory> >(trackProducer2);
96  trackProducer1AssToken = consumes< TrajTrackAssociationCollection >(trackProducer1);
97  trackProducer2AssToken = consumes< TrajTrackAssociationCollection >(trackProducer2);
98 
99  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
edm::EDGetTokenT< reco::TrackCollection > trackProducer2Token
cms::SimpleTrackListMerger::~SimpleTrackListMerger ( )
virtual

Definition at line 103 of file SimpleTrackListMerger.cc.

103 { }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 106 of file SimpleTrackListMerger.cc.

References reco::TrackExtraBase::add(), edm::OwnVector< T, P >::back(), TrackingRecHit::clone(), cms::clusterProduct(), conf_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, copyExtras_, cond::rpcobimon::current, delta, TrajectorySeed::direction(), 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().

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

Member Data Documentation

edm::ParameterSet cms::SimpleTrackListMerger::conf_
private

Definition at line 45 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::copyExtras_
private

Definition at line 61 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

bool cms::SimpleTrackListMerger::makeReKeyedSeeds_
private

Definition at line 62 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 52 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 50 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 48 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 49 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 47 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 51 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 57 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 59 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 55 of file SimpleTrackListMerger.h.

Referenced by produce().

TrackingRecHitRefProd cms::SimpleTrackListMerger::refTrkHits
private

Definition at line 56 of file SimpleTrackListMerger.h.

Referenced by produce().

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

Definition at line 54 of file SimpleTrackListMerger.h.

Referenced by produce().

std::string cms::SimpleTrackListMerger::trackProducer1
private

Definition at line 63 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 67 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 64 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 66 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

std::string cms::SimpleTrackListMerger::trackProducer2
private

Definition at line 63 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 69 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 65 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 68 of file SimpleTrackListMerger.h.

Referenced by produce(), and SimpleTrackListMerger().

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

Definition at line 58 of file SimpleTrackListMerger.h.

Referenced by produce().