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

typedef std::pair
< TrackCandidate, std::pair
< reco::TrackRef,
reco::TrackRef > > 
DuplicateRecord
 typedef container of candidate and input tracks More...
 
typedef edm::OwnVector
< TrackingRecHit
RecHitContainer
 
- 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 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
 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::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)
 

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
< edm::ValueMap< float > > 
mergedMVAValsToken_
 
ThreeTokens mergedTrackSource_
 
float minTrkProbCut_
 
edm::InputTag originalMVAVals_
 
edm::EDGetTokenT
< edm::ValueMap< float > > 
originalMVAValsToken_
 
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 37 of file DuplicateListMerger.cc.

Member Typedef Documentation

typedef container of candidate and input tracks

Definition at line 45 of file DuplicateListMerger.cc.

Definition at line 46 of file DuplicateListMerger.cc.

Constructor & Destructor Documentation

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

constructor

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

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

destructor

Definition at line 148 of file DuplicateListMerger.cc.

149 {
150 
151  /* no op */
152 
153 }

Member Function Documentation

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

Definition at line 54 of file DuplicateListMerger.cc.

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

Definition at line 484 of file DuplicateListMerger.cc.

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

484  {
485  int track = -1;
486  std::vector<int> rawIds;
487  RecHitContainer::const_iterator candBegin = candidate.recHits().first;
488  RecHitContainer::const_iterator candEnd = candidate.recHits().second;
489  for(; candBegin != candEnd; candBegin++){
490  rawIds.push_back((*(candBegin)).rawId());
491  }
492 
493 
494  for(int i = 0; i < (int)tracks->size() && track < 0;i++){
495  if( (*tracks)[i].seedRef() != candidate.seedRef())continue;
496  int match = 0;
497  trackingRecHit_iterator trackRecBegin = (*tracks)[i].recHitsBegin();
498  trackingRecHit_iterator trackRecEnd = (*tracks)[i].recHitsEnd();
499  for(;trackRecBegin != trackRecEnd; trackRecBegin++){
500  if(std::find(rawIds.begin(),rawIds.end(),(*(trackRecBegin))->rawId()) != rawIds.end()) match++;
501  }
502  if(match != (int)( (*tracks)[i].recHitsSize() ) ) continue;
503  track = i;
504  }
505 
506  return track;
507 }
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 155 of file DuplicateListMerger.cc.

References reco::TrackBase::algo(), 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::helper::Filler< Map >::fill(), 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::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), j, match(), min(), edm::Provenance::moduleLabel(), reco::TrackBase::momentum(), 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(), and TrajectorySeed::startingState().

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

Definition at line 68 of file DuplicateListMerger.cc.

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

Member Data Documentation

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

Definition at line 72 of file DuplicateListMerger.cc.

bool DuplicateListMerger::copyExtras_
private

Definition at line 82 of file DuplicateListMerger.cc.

unsigned int DuplicateListMerger::diffHitsCut_
private

Definition at line 80 of file DuplicateListMerger.cc.

bool DuplicateListMerger::makeReKeyedSeeds_
private

Definition at line 83 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::mergedMVAVals_
private

Definition at line 75 of file DuplicateListMerger.cc.

edm::EDGetTokenT<edm::ValueMap<float> > DuplicateListMerger::mergedMVAValsToken_
private

Definition at line 77 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::mergedTrackSource_
private

Definition at line 71 of file DuplicateListMerger.cc.

float DuplicateListMerger::minTrkProbCut_
private

Definition at line 81 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::originalMVAVals_
private

Definition at line 74 of file DuplicateListMerger.cc.

edm::EDGetTokenT<edm::ValueMap<float> > DuplicateListMerger::originalMVAValsToken_
private

Definition at line 76 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::originalTrackSource_
private

Definition at line 71 of file DuplicateListMerger.cc.

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

Definition at line 79 of file DuplicateListMerger.cc.