test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DuplicateListMerger Class Referencefinal
Inheritance diagram for DuplicateListMerger:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  ThreeTokens
 track input collection More...
 

Public Types

using DuplicateRecord = std::pair< TrackCandidate, std::pair< reco::TrackRef, reco::TrackRef > >
 alias for container of candidate and input tracks More...
 
using MVACollection = std::vector< float >
 
using RecHitContainer = edm::OwnVector< TrackingRecHit >
 
- 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
 

Public Member Functions

 DuplicateListMerger (const edm::ParameterSet &iPara)
 constructor More...
 
virtual ~DuplicateListMerger ()
 destructor More...
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 ()
 

Protected Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 produce one event More...
 
- 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)
 

Private Member Functions

edm::ProductID clusterProductB (const TrackingRecHit *hit)
 
int matchCandidateToTrack (TrackCandidate, edm::Handle< reco::TrackCollection >)
 
ThreeTokens threeTokens (const edm::InputTag &tag)
 

Private Attributes

edm::EDGetTokenT< edm::View
< DuplicateRecord > > 
candidateSource_
 
bool copyExtras_
 
unsigned int diffHitsCut_
 
bool makeReKeyedSeeds_
 
edm::InputTag mergedMVAVals_
 
edm::EDGetTokenT< MVACollectionmergedMVAValsToken_
 
ThreeTokens mergedTrackSource_
 
float minTrkProbCut_
 
edm::InputTag originalMVAVals_
 
edm::EDGetTokenT< MVACollectionoriginalMVAValsToken_
 
ThreeTokens originalTrackSource_
 
reco::TrackBase::TrackQuality qualityToSet_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

merges list of merge duplicate tracks with its parent list

Author
Matthew Walker

Definition at line 40 of file DuplicateListMerger.cc.

Member Typedef Documentation

alias for container of candidate and input tracks

Definition at line 48 of file DuplicateListMerger.cc.

using DuplicateListMerger::MVACollection = std::vector<float>

Definition at line 51 of file DuplicateListMerger.cc.

Definition at line 49 of file DuplicateListMerger.cc.

Constructor & Destructor Documentation

DuplicateListMerger::DuplicateListMerger ( const edm::ParameterSet iPara)
explicit

constructor

Definition at line 102 of file DuplicateListMerger.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::InputTag, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, and reco::TrackBase::undefQuality.

103 {
104  diffHitsCut_ = 9999;
105  minTrkProbCut_ = 0.0;
106  if(iPara.exists("diffHitsCut"))diffHitsCut_ = iPara.getParameter<int>("diffHitsCut");
107  if(iPara.exists("minTrkProbCut"))minTrkProbCut_ = iPara.getParameter<double>("minTrkProbCut");
108  if(iPara.exists("mergedSource")) mergedTrackSource_ = threeTokens(iPara.getParameter<edm::InputTag>("mergedSource"));
109  if(iPara.exists("originalSource"))originalTrackSource_ = threeTokens(iPara.getParameter<edm::InputTag>("originalSource"));
110  if(iPara.exists("candidateSource"))candidateSource_ = consumes<edm::View<DuplicateRecord> >(iPara.getParameter<edm::InputTag>("candidateSource"));
111 
112 
113  if(iPara.exists("mergedMVAVals")){
114  mergedMVAVals_ = iPara.getParameter<edm::InputTag>("mergedMVAVals");
115  }else{
117  }
118  mergedMVAValsToken_ = consumes<MVACollection>(mergedMVAVals_);
119  if(iPara.exists("originalMVAVals")){
120  originalMVAVals_ = iPara.getParameter<edm::InputTag>("originalMVAVals");
121  }else{
123  }
124  originalMVAValsToken_ = consumes<MVACollection>(originalMVAVals_);
125 
126  copyExtras_ = iPara.getUntrackedParameter<bool>("copyExtras",true);
128  if (iPara.exists("newQuality")) {
129  std::string qualityStr = iPara.getParameter<std::string>("newQuality");
130  if (qualityStr != "") {
131  qualityToSet_ = reco::TrackBase::qualityByName(qualityStr);
132  }
133  }
134 
135  produces<std::vector<reco::Track> >();
136  produces< std::vector<Trajectory> >();
137  produces< TrajTrackAssociationCollection >();
138 
139  produces<MVACollection>("MVAValues");
140 
141  makeReKeyedSeeds_ = iPara.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
142  if (makeReKeyedSeeds_){
143  copyExtras_=true;
144  produces<TrajectorySeedCollection>();
145  }
146  if(copyExtras_){
147  produces<reco::TrackExtraCollection>();
148  produces<TrackingRecHitCollection>();
149  }
150 
151 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< MVACollection > mergedMVAValsToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< MVACollection > originalMVAValsToken_
edm::EDGetTokenT< edm::View< DuplicateRecord > > candidateSource_
ThreeTokens originalTrackSource_
edm::InputTag originalMVAVals_
edm::InputTag mergedMVAVals_
ThreeTokens threeTokens(const edm::InputTag &tag)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:123
reco::TrackBase::TrackQuality qualityToSet_
std::string const & label() const
Definition: InputTag.h:43
DuplicateListMerger::~DuplicateListMerger ( )
virtual

destructor

Definition at line 153 of file DuplicateListMerger.cc.

154 {
155 
156  /* no op */
157 
158 }

Member Function Documentation

edm::ProductID DuplicateListMerger::clusterProductB ( const TrackingRecHit hit)
inlineprivate

Definition at line 60 of file DuplicateListMerger.cc.

60  {
61  return reinterpret_cast<const BaseTrackerRecHit *>(hit)->firstClusterRef().id();
62  }
int DuplicateListMerger::matchCandidateToTrack ( TrackCandidate  candidate,
edm::Handle< reco::TrackCollection tracks 
)
private

Definition at line 488 of file DuplicateListMerger.cc.

References spr::find(), i, match(), TrackCandidate::recHits(), and TrackCandidate::seedRef().

488  {
489  int track = -1;
490  std::vector<int> rawIds;
491  RecHitContainer::const_iterator candBegin = candidate.recHits().first;
492  RecHitContainer::const_iterator candEnd = candidate.recHits().second;
493  for(; candBegin != candEnd; candBegin++){
494  rawIds.push_back((*(candBegin)).rawId());
495  }
496 
497 
498  for(int i = 0; i < (int)tracks->size() && track < 0;i++){
499  if( (*tracks)[i].seedRef() != candidate.seedRef())continue;
500  int match = 0;
501  trackingRecHit_iterator trackRecBegin = (*tracks)[i].recHitsBegin();
502  trackingRecHit_iterator trackRecEnd = (*tracks)[i].recHitsEnd();
503  for(;trackRecBegin != trackRecEnd; trackRecBegin++){
504  if(std::find(rawIds.begin(),rawIds.end(),(*(trackRecBegin))->rawId()) != rawIds.end()) match++;
505  }
506  if(match != (int)( (*tracks)[i].recHitsSize() ) ) continue;
507  track = i;
508  }
509 
510  return track;
511 }
int i
Definition: DBlmapReader.cc:9
range recHits() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::RefToBase< TrajectorySeed > seedRef() const
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
void DuplicateListMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotectedvirtual

produce one event

Implements edm::stream::EDProducerBase.

Definition at line 160 of file DuplicateListMerger.cc.

References a, reco::TrackBase::algo(), b, edm::OwnVector< T, P >::back(), reco::TrackBase::charge(), reco::TrackBase::chi2(), ChiSquaredProbability(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, TrajectorySeed::direction(), edm::Ref< C, T, F >::get(), edm::Event::getByLabel(), edm::Event::getByToken(), edm::Event::getProvenance(), edm::Event::getRefBeforePut(), i, edm::RefProd< T >::id(), reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), HLT_25ns14e33_v1_cff::InputTag, edm::Ref< C, T, F >::isNonnull(), j, match(), matches, min(), edm::Provenance::moduleLabel(), reco::TrackBase::momentum(), eostools::move(), reco::TrackBase::ndof(), TrajectorySeed::nHits(), reco::TrackBase::normalizedChi2(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), edm::Provenance::processName(), edm::Provenance::productInstanceName(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), reco::TrackBase::qualityMask(), reco::Track::recHit(), TrajectorySeed::recHits(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), reco::Track::recHitsSize(), reco::TrackBase::referencePoint(), ClusterRemovalRefSetter::reKey(), edm::OwnVector< T, P >::reserve(), reco::Track::residuals(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrajectorySeed::startingState(), and trackAlgoPriorityOrder.

161 {
163  iEvent.getByToken(originalTrackSource_.tk,originalHandle);
165  iEvent.getByToken(mergedTrackSource_.tk,mergedHandle);
166 
167  const reco::TrackCollection& mergedTracks(*mergedHandle);
168  reco::TrackRefProd originalTrackRefs(originalHandle);
169  reco::TrackRefProd mergedTrackRefs(mergedHandle);
170 
171  edm::Handle< std::vector<Trajectory> > mergedTrajHandle;
172  iEvent.getByToken(mergedTrackSource_.traj,mergedTrajHandle);
173  edm::Handle< TrajTrackAssociationCollection > mergedTrajTrackHandle;
174  iEvent.getByToken(mergedTrackSource_.tass,mergedTrajTrackHandle);
175 
176  edm::Handle< std::vector<Trajectory> > originalTrajHandle;
177  iEvent.getByToken(originalTrackSource_.traj,originalTrajHandle);
178  edm::Handle< TrajTrackAssociationCollection > originalTrajTrackHandle;
179  iEvent.getByToken(originalTrackSource_.tass,originalTrajTrackHandle);
180 
181  edm::Handle<edm::View<DuplicateRecord> > candidateHandle;
182  iEvent.getByToken(candidateSource_,candidateHandle);
183 
184  std::auto_ptr<std::vector<reco::Track> > out_generalTracks(new std::vector<reco::Track>());
185  out_generalTracks->reserve(originalHandle->size());
187  std::auto_ptr< std::vector<Trajectory> > outputTrajs = std::auto_ptr< std::vector<Trajectory> >(new std::vector<Trajectory>());
188  outputTrajs->reserve(originalTrajHandle->size()+mergedTrajHandle->size());
190  //std::auto_ptr< TrajectorySeedCollection > outputSeeds
191 
192  std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
193  reco::TrackExtraRefProd refTrkExtras;
194  std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
195  TrackingRecHitRefProd refTrkHits;
196  std::auto_ptr<TrajectorySeedCollection> outputSeeds;
198 
199  edm::Handle<MVACollection> originalMVAStore;
200  edm::Handle<MVACollection> mergedMVAStore;
201 
202  iEvent.getByToken(originalMVAValsToken_,originalMVAStore);
203  iEvent.getByToken(mergedMVAValsToken_,mergedMVAStore);
204 
205  MVACollection mvaVec;
206 
207 
208  if(copyExtras_){
209  outputTrkExtras = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
210  outputTrkExtras->reserve(originalHandle->size());
211  refTrkExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
212  outputTrkHits = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
213  outputTrkHits->reserve(originalHandle->size()*25);
214  refTrkHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
215  if (makeReKeyedSeeds_){
216  outputSeeds = std::auto_ptr<TrajectorySeedCollection>(new TrajectorySeedCollection);
217  outputSeeds->reserve(originalHandle->size());
218  refTrajSeeds = iEvent.getRefBeforePut<TrajectorySeedCollection>();
219  }
220  }
221 
222  //match new tracks to their candidates
223  std::vector<std::pair<int,const DuplicateRecord*> > matches;
224  for(int i = 0; i < (int)candidateHandle->size(); i++){
225  const DuplicateRecord& duplicateRecord = candidateHandle->at(i);
226  int matchTrack = matchCandidateToTrack(duplicateRecord.first,mergedHandle);
227  if(matchTrack < 0)continue;
228  const reco::Track& matchedTrack(mergedTracks[matchTrack]);
229  if( ChiSquaredProbability(matchedTrack.chi2(),matchedTrack.ndof()) < minTrkProbCut_)continue;
230  unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.recHitsSize();
231  if(dHits > diffHitsCut_)continue;
232  matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
233  }
234 
235  //check for candidates/tracks that share merged tracks, select minimum chi2, remove the rest
236  std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter0 = matches.begin();
237  std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter1;
238  while(matchIter0 != matches.end()){
239  double nchi2 = mergedTracks[matchIter0->first].normalizedChi2();
240  bool advance = true;
241  for(matchIter1 = matchIter0+1; matchIter1 != matches.end(); matchIter1++){
242  const reco::Track& match0first = *(matchIter0->second->second.first.get());
243  const reco::Track& match0second = *(matchIter0->second->second.second.get());
244  const reco::Track& match1first = *(matchIter1->second->second.first.get());
245  const reco::Track& match1second = *(matchIter1->second->second.second.get());
246  if(match1first.seedRef() == match0first.seedRef() ||
247  match1first.seedRef() == match0second.seedRef() ||
248  match1second.seedRef() == match0first.seedRef() ||
249  match1second.seedRef() == match0second.seedRef()){
250  double nchi2_1 = mergedTracks[matchIter1->first].normalizedChi2();
251  advance = false;
252  if(nchi2_1 < nchi2){
253  matches.erase(matchIter0);
254  }else{
255  matches.erase(matchIter1);
256  }
257  break;
258  }
259  }
260  if(advance)matchIter0++;
261  }
262 
263  //add the good merged tracks to the output list, remove input tracks
264  std::vector<reco::Track> inputTracks;
265 
266  refTrajs = iEvent.getRefBeforePut< std::vector<Trajectory> >();
267 
268  std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection(refTrajs, refTrks));
269 
270  for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
271  reco::TrackRef inTrkRef1 = matchIter0->second->second.first;
272  reco::TrackRef inTrkRef2 = matchIter0->second->second.second;
273  const reco::Track& inTrk1 = *(inTrkRef1.get());
274  const reco::Track& inTrk2 = *(inTrkRef2.get());
275  reco::TrackBase::TrackAlgorithm newTrkAlgo = std::min(inTrk1.algo(),inTrk2.algo(),
278  });
279  int combinedQualityMask = (inTrk1.qualityMask() | inTrk2.qualityMask());
280  inputTracks.push_back(inTrk1);
281  inputTracks.push_back(inTrk2);
282  out_generalTracks->push_back(mergedTracks[matchIter0->first]);
283  reco::TrackRef curTrackRef = reco::TrackRef(refTrks, out_generalTracks->size() - 1);
284  float mergedMVA = (*mergedMVAStore)[matchIter0->first];
285  mvaVec.push_back(mergedMVA);
286  out_generalTracks->back().setAlgorithm(newTrkAlgo);
287  out_generalTracks->back().setQualityMask(combinedQualityMask);
288  out_generalTracks->back().setQuality(qualityToSet_);
289  edm::RefToBase<TrajectorySeed> origSeedRef;
290  if(copyExtras_){
291  const reco::Track& track = mergedTracks[matchIter0->first];
292  origSeedRef = track.seedRef();
293  //creating a seed with rekeyed clusters if required
294  if (makeReKeyedSeeds_){
295  bool doRekeyOnThisSeed=false;
296 
297  edm::InputTag clusterRemovalInfos("");
298  //grab on of the hits of the seed
299  if (origSeedRef->nHits()!=0){
300  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
301  const TrackingRecHit *hit = &*firstHit;
302  if (firstHit->isValid()){
304  // the cluster collection either produced a removalInfo or mot
305  //get the clusterremoval info from the provenance: will rekey if this is found
307  edm::Provenance prov=iEvent.getProvenance(pID);
308  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
309  prov.productInstanceName(),
310  prov.processName());
311  doRekeyOnThisSeed=iEvent.getByLabel(clusterRemovalInfos,CRIh);
312  }//valid hit
313  }//nhit!=0
314 
315  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag(""))) {
316  ClusterRemovalRefSetter refSetter(iEvent,clusterRemovalInfos);
317  TrajectorySeed::recHitContainer newRecHitContainer;
318  newRecHitContainer.reserve(origSeedRef->nHits());
319  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
320  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
321  for (;iH!=iH_end;++iH){
322  newRecHitContainer.push_back(*iH);
323  refSetter.reKey(&newRecHitContainer.back());
324  }
325  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
326  newRecHitContainer,
327  origSeedRef->direction()));
328  }
329  //doRekeyOnThisSeed=true
330  else{
331  //just copy the one we had before
332  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
333  }
334  edm::Ref<TrajectorySeedCollection> pureRef(refTrajSeeds, outputSeeds->size()-1);
335  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
336  }//creating a new seed and rekeying it rechit clusters.
337  // Fill TrackExtra collection
338  outputTrkExtras->push_back( reco::TrackExtra(
339  track.outerPosition(), track.outerMomentum(), track.outerOk(),
340  track.innerPosition(), track.innerMomentum(), track.innerOk(),
341  track.outerStateCovariance(), track.outerDetId(),
342  track.innerStateCovariance(), track.innerDetId(),
343  track.seedDirection(), origSeedRef ) );
344  out_generalTracks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
345  reco::TrackExtra & tx = outputTrkExtras->back();
346  tx.setResiduals(track.residuals());
347  // fill TrackingRecHits
348  unsigned nh1=track.recHitsSize();
349  auto const firstTrackIndex = outputTrkHits->size();
350  for ( unsigned ih=0; ih<nh1; ++ih ) {
351  //const TrackingRecHit*hit=&((*(track->recHit(ih))));
352  outputTrkHits->push_back( track.recHit(ih)->clone() );
353  }
354  tx.setHits( refTrkHits, firstTrackIndex, outputTrkHits->size() - firstTrackIndex );
355  }
356  edm::Ref< std::vector<Trajectory> > trajRef(mergedTrajHandle, (*matchIter0).first);
357  TrajTrackAssociationCollection::const_iterator match = mergedTrajTrackHandle->find(trajRef);
358  if (match != mergedTrajTrackHandle->end()) {
359  if(curTrackRef.isNonnull()){
360  outputTrajs->push_back( *trajRef );
362  outputTrajs->back().setSeedRef( origSeedRef );
363  outputTTAss->insert(edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
364  }
365  }
366  }
367 
368  for(int i = 0; i < (int)originalHandle->size(); i++){
369  bool good = true;
370  const reco::Track& origTrack = originalHandle->at(i);
371  for(int j = 0; j < (int)inputTracks.size() && good; j++){
372  const reco::Track& inputTrack = inputTracks[j];
373  if(origTrack.seedRef() != inputTrack.seedRef())continue;
374  if(origTrack.charge() != inputTrack.charge())continue;
375  if(origTrack.momentum() != inputTrack.momentum())continue;
376  if(origTrack.referencePoint() != inputTrack.referencePoint())continue;
377  good = false;
378  }
379 
380  if(good){
381  out_generalTracks->push_back(origTrack);
382  reco::TrackRef curTrackRef = reco::TrackRef(refTrks, out_generalTracks->size() - 1);
383  edm::RefToBase<TrajectorySeed> origSeedRef;
384  reco::TrackRef origTrackRef = reco::TrackRef(originalHandle,i);
385  mvaVec.push_back((*originalMVAStore)[i]);
386  if(copyExtras_){
387  const reco::Track& track = origTrack;
388  origSeedRef = track.seedRef();
389  //creating a seed with rekeyed clusters if required
390  if (makeReKeyedSeeds_){
391  bool doRekeyOnThisSeed=false;
392 
393  edm::InputTag clusterRemovalInfos("");
394  //grab on of the hits of the seed
395  if (origSeedRef->nHits()!=0){
396  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
397  const TrackingRecHit *hit = &*firstHit;
398  if (firstHit->isValid()){
400  // the cluster collection either produced a removalInfo or mot
401  //get the clusterremoval info from the provenance: will rekey if this is found
403  edm::Provenance prov=iEvent.getProvenance(pID);
404  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
405  prov.productInstanceName(),
406  prov.processName());
407  doRekeyOnThisSeed=iEvent.getByLabel(clusterRemovalInfos,CRIh);
408  }//valid hit
409  }//nhit!=0
410 
411  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag(""))) {
412  ClusterRemovalRefSetter refSetter(iEvent,clusterRemovalInfos);
413  TrajectorySeed::recHitContainer newRecHitContainer;
414  newRecHitContainer.reserve(origSeedRef->nHits());
415  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
416  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
417  for (;iH!=iH_end;++iH){
418  newRecHitContainer.push_back(*iH);
419  refSetter.reKey(&newRecHitContainer.back());
420  }
421  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
422  newRecHitContainer,
423  origSeedRef->direction()));
424  }
425  //doRekeyOnThisSeed=true
426  else{
427  //just copy the one we had before
428  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
429  }
430  edm::Ref<TrajectorySeedCollection> pureRef(refTrajSeeds, outputSeeds->size()-1);
431  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
432  }//creating a new seed and rekeying it rechit clusters.
433 
434  // Fill TrackExtra collection
435  outputTrkExtras->push_back( reco::TrackExtra(
436  track.outerPosition(), track.outerMomentum(), track.outerOk(),
437  track.innerPosition(), track.innerMomentum(), track.innerOk(),
438  track.outerStateCovariance(), track.outerDetId(),
439  track.innerStateCovariance(), track.innerDetId(),
440  track.seedDirection(), origSeedRef ) );
441  out_generalTracks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
442  reco::TrackExtra & tx = outputTrkExtras->back();
443  tx.setResiduals(track.residuals());
444 
445  // fill TrackingRecHits
446  unsigned nh1=track.recHitsSize();
447  tx.setHits(refTrkHits,outputTrkHits->size(),nh1);
448  for (auto hh = track.recHitsBegin(), eh=track.recHitsEnd(); hh!=eh; ++hh ) {
449  outputTrkHits->push_back( (*hh)->clone() );
450  }
451 
452  }
453 
454  edm::Ref< std::vector<Trajectory> > trajRef(originalTrajHandle, i);
455  TrajTrackAssociationCollection::const_iterator match = originalTrajTrackHandle->find(trajRef);
456  if (match != originalTrajTrackHandle->end()) {
457  if(curTrackRef.isNonnull()){
458  outputTrajs->push_back( *trajRef );
460  outputTrajs->back().setSeedRef( origSeedRef );
461  outputTTAss->insert(edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
462  }
463  }
464  }
465  }
466 
467  edm::ProductID nPID = refTrks.id();
468  edm::TestHandle<TrackCollection> out_gtHandle(out_generalTracks.get(),nPID);
469 
470  iEvent.put(std::move(std::make_unique<MVACollection>(std::move(mvaVec))),"MVAValues");
471 
472  out_generalTracks->shrink_to_fit(); iEvent.put(out_generalTracks);
473  if (copyExtras_) {
474  outputTrkExtras->shrink_to_fit(); iEvent.put(outputTrkExtras);
475  outputTrkHits->shrink_to_fit(); iEvent.put(outputTrkHits);
476  if (makeReKeyedSeeds_) {
477  outputSeeds->shrink_to_fit(); iEvent.put(outputSeeds);
478  }
479  }
480  outputTrajs->shrink_to_fit(); iEvent.put(outputTrajs);
481  iEvent.put(outputTTAss);
482 }
PropagationDirection direction() const
const Point & referencePoint() const
Reference point on the track.
Definition: TrackBase.h:668
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< MVACollection > mergedMVAValsToken_
reference back()
Definition: OwnVector.h:327
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
edm::EDGetTokenT< TrajTrackAssociationCollection > tass
std::vector< float > MVACollection
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:548
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< std::vector< Trajectory > > traj
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:662
std::string const & processName() const
Definition: Provenance.h:61
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
TrackAlgorithm algo() const
Definition: TrackBase.h:484
void push_back(D *&d)
Definition: OwnVector.h:280
edm::EDGetTokenT< MVACollection > originalMVAValsToken_
edm::EDGetTokenT< edm::View< DuplicateRecord > > candidateSource_
ThreeTokens originalTrackSource_
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:75
def move
Definition: eostools.py:510
int qualityMask() const
Definition: TrackBase.h:849
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
float ChiSquaredProbability(double chiSquared, double nrDOF)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
T min(T a, T b)
Definition: MathUtil.h:58
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
RefProd< PROD > getRefBeforePut()
Definition: Event.h:140
edm::EDGetTokenT< reco::TrackCollection > tk
std::pair< TrackCandidate, std::pair< reco::TrackRef, reco::TrackRef > > DuplicateRecord
alias for container of candidate and input tracks
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
int matchCandidateToTrack(TrackCandidate, edm::Handle< reco::TrackCollection >)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
reco::TrackBase::TrackQuality qualityToSet_
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
double b
Definition: hdecay.h:120
std::string const & moduleLabel() const
Definition: Provenance.h:60
edm::ProductID clusterProductB(const TrackingRecHit *hit)
unsigned int nHits() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
double a
Definition: hdecay.h:121
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:114
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
int charge() const
track electric charge
Definition: TrackBase.h:554
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
ProductIndex id() const
Definition: ProductID.h:38
std::string const & productInstanceName() const
Definition: Provenance.h:62
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:85
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
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:179
ThreeTokens DuplicateListMerger::threeTokens ( const edm::InputTag tag)
inlineprivate

Definition at line 74 of file DuplicateListMerger.cc.

74  {
75  return ThreeTokens(tag, consumes<reco::TrackCollection>(tag), consumes<std::vector<Trajectory> >(tag), consumes<TrajTrackAssociationCollection >(tag));
76  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)

Member Data Documentation

edm::EDGetTokenT<edm::View<DuplicateRecord> > DuplicateListMerger::candidateSource_
private

Definition at line 78 of file DuplicateListMerger.cc.

bool DuplicateListMerger::copyExtras_
private

Definition at line 88 of file DuplicateListMerger.cc.

unsigned int DuplicateListMerger::diffHitsCut_
private

Definition at line 86 of file DuplicateListMerger.cc.

bool DuplicateListMerger::makeReKeyedSeeds_
private

Definition at line 89 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::mergedMVAVals_
private

Definition at line 81 of file DuplicateListMerger.cc.

edm::EDGetTokenT<MVACollection> DuplicateListMerger::mergedMVAValsToken_
private

Definition at line 83 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::mergedTrackSource_
private

Definition at line 77 of file DuplicateListMerger.cc.

float DuplicateListMerger::minTrkProbCut_
private

Definition at line 87 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::originalMVAVals_
private

Definition at line 80 of file DuplicateListMerger.cc.

edm::EDGetTokenT<MVACollection> DuplicateListMerger::originalMVAValsToken_
private

Definition at line 82 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::originalTrackSource_
private

Definition at line 77 of file DuplicateListMerger.cc.

reco::TrackBase::TrackQuality DuplicateListMerger::qualityToSet_
private

Definition at line 85 of file DuplicateListMerger.cc.