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 39 of file DuplicateListMerger.cc.

Member Typedef Documentation

typedef container of candidate and input tracks

Definition at line 47 of file DuplicateListMerger.cc.

Definition at line 48 of file DuplicateListMerger.cc.

Constructor & Destructor Documentation

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

constructor

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

100 {
101  diffHitsCut_ = 9999;
102  minTrkProbCut_ = 0.0;
103  if(iPara.exists("diffHitsCut"))diffHitsCut_ = iPara.getParameter<int>("diffHitsCut");
104  if(iPara.exists("minTrkProbCut"))minTrkProbCut_ = iPara.getParameter<double>("minTrkProbCut");
105  if(iPara.exists("mergedSource")) mergedTrackSource_ = threeTokens(iPara.getParameter<edm::InputTag>("mergedSource"));
106  if(iPara.exists("originalSource"))originalTrackSource_ = threeTokens(iPara.getParameter<edm::InputTag>("originalSource"));
107  if(iPara.exists("candidateSource"))candidateSource_ = consumes<edm::View<DuplicateRecord> >(iPara.getParameter<edm::InputTag>("candidateSource"));
108 
109 
110  if(iPara.exists("mergedMVAVals")){
111  mergedMVAVals_ = iPara.getParameter<edm::InputTag>("mergedMVAVals");
112  }else{
114  }
115  mergedMVAValsToken_ = consumes<edm::ValueMap<float> >(mergedMVAVals_);
116  if(iPara.exists("originalMVAVals")){
117  originalMVAVals_ = iPara.getParameter<edm::InputTag>("originalMVAVals");
118  }else{
120  }
121  originalMVAValsToken_ = consumes<edm::ValueMap<float> >(originalMVAVals_);
122 
123  copyExtras_ = iPara.getUntrackedParameter<bool>("copyExtras",true);
125  if (iPara.exists("newQuality")) {
126  std::string qualityStr = iPara.getParameter<std::string>("newQuality");
127  if (qualityStr != "") {
128  qualityToSet_ = reco::TrackBase::qualityByName(qualityStr);
129  }
130  }
131 
132  produces<std::vector<reco::Track> >();
133  produces< std::vector<Trajectory> >();
134  produces< TrajTrackAssociationCollection >();
135 
136  produces<edm::ValueMap<float> >("MVAVals");
137 
138  makeReKeyedSeeds_ = iPara.getUntrackedParameter<bool>("makeReKeyedSeeds",false);
139  if (makeReKeyedSeeds_){
140  copyExtras_=true;
141  produces<TrajectorySeedCollection>();
142  }
143  if(copyExtras_){
144  produces<reco::TrackExtraCollection>();
145  produces<TrackingRecHitCollection>();
146  }
147 
148 }
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:114
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 150 of file DuplicateListMerger.cc.

151 {
152 
153  /* no op */
154 
155 }

Member Function Documentation

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

Definition at line 56 of file DuplicateListMerger.cc.

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

Definition at line 490 of file DuplicateListMerger.cc.

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

490  {
491  int track = -1;
492  std::vector<int> rawIds;
493  RecHitContainer::const_iterator candBegin = candidate.recHits().first;
494  RecHitContainer::const_iterator candEnd = candidate.recHits().second;
495  for(; candBegin != candEnd; candBegin++){
496  rawIds.push_back((*(candBegin)).rawId());
497  }
498 
499 
500  for(int i = 0; i < (int)tracks->size() && track < 0;i++){
501  if( (*tracks)[i].seedRef() != candidate.seedRef())continue;
502  int match = 0;
503  trackingRecHit_iterator trackRecBegin = (*tracks)[i].recHitsBegin();
504  trackingRecHit_iterator trackRecEnd = (*tracks)[i].recHitsEnd();
505  for(;trackRecBegin != trackRecEnd; trackRecBegin++){
506  if(std::find(rawIds.begin(),rawIds.end(),(*(trackRecBegin))->rawId()) != rawIds.end()) match++;
507  }
508  if(match != (int)( (*tracks)[i].recHitsSize() ) ) continue;
509  track = i;
510  }
511 
512  return track;
513 }
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 157 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::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(), TrajectorySeed::startingState(), and trackAlgoPriorityOrder.

158 {
160  iEvent.getByToken(originalTrackSource_.tk,originalHandle);
162  iEvent.getByToken(mergedTrackSource_.tk,mergedHandle);
163 
164  const reco::TrackCollection& mergedTracks(*mergedHandle);
165  reco::TrackRefProd originalTrackRefs(originalHandle);
166  reco::TrackRefProd mergedTrackRefs(mergedHandle);
167 
168  edm::Handle< std::vector<Trajectory> > mergedTrajHandle;
169  iEvent.getByToken(mergedTrackSource_.traj,mergedTrajHandle);
170  edm::Handle< TrajTrackAssociationCollection > mergedTrajTrackHandle;
171  iEvent.getByToken(mergedTrackSource_.tass,mergedTrajTrackHandle);
172 
173  edm::Handle< std::vector<Trajectory> > originalTrajHandle;
174  iEvent.getByToken(originalTrackSource_.traj,originalTrajHandle);
175  edm::Handle< TrajTrackAssociationCollection > originalTrajTrackHandle;
176  iEvent.getByToken(originalTrackSource_.tass,originalTrajTrackHandle);
177 
178  edm::Handle<edm::View<DuplicateRecord> > candidateHandle;
179  iEvent.getByToken(candidateSource_,candidateHandle);
180 
181  std::auto_ptr<std::vector<reco::Track> > out_generalTracks(new std::vector<reco::Track>());
182  out_generalTracks->reserve(originalHandle->size());
184  std::auto_ptr< std::vector<Trajectory> > outputTrajs = std::auto_ptr< std::vector<Trajectory> >(new std::vector<Trajectory>());
185  outputTrajs->reserve(originalTrajHandle->size()+mergedTrajHandle->size());
187  //std::auto_ptr< TrajectorySeedCollection > outputSeeds
188 
189  std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
190  reco::TrackExtraRefProd refTrkExtras;
191  std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
192  TrackingRecHitRefProd refTrkHits;
193  std::auto_ptr<TrajectorySeedCollection> outputSeeds;
195 
196  edm::Handle<edm::ValueMap<float> > originalMVAStore;
197  edm::Handle<edm::ValueMap<float> > mergedMVAStore;
198 
199  iEvent.getByToken(originalMVAValsToken_,originalMVAStore);
200  iEvent.getByToken(mergedMVAValsToken_,mergedMVAStore);
201 
202  std::auto_ptr<edm::ValueMap<float> > vmMVA(new edm::ValueMap<float>);
203  edm::ValueMap<float>::Filler fillerMVA(*vmMVA);
204  std::vector<float> mvaVec;
205 
206 
207  if(copyExtras_){
208  outputTrkExtras = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
209  outputTrkExtras->reserve(originalHandle->size());
210  refTrkExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
211  outputTrkHits = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
212  outputTrkHits->reserve(originalHandle->size()*25);
213  refTrkHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
214  if (makeReKeyedSeeds_){
215  outputSeeds = std::auto_ptr<TrajectorySeedCollection>(new TrajectorySeedCollection);
216  outputSeeds->reserve(originalHandle->size());
217  refTrajSeeds = iEvent.getRefBeforePut<TrajectorySeedCollection>();
218  }
219  }
220 
221  //match new tracks to their candidates
222  std::vector<std::pair<int,const DuplicateRecord*> > matches;
223  for(int i = 0; i < (int)candidateHandle->size(); i++){
224  const DuplicateRecord& duplicateRecord = candidateHandle->at(i);
225  int matchTrack = matchCandidateToTrack(duplicateRecord.first,mergedHandle);
226  if(matchTrack < 0)continue;
227  const reco::Track& matchedTrack(mergedTracks[matchTrack]);
228  if( ChiSquaredProbability(matchedTrack.chi2(),matchedTrack.ndof()) < minTrkProbCut_)continue;
229  unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.recHitsSize();
230  if(dHits > diffHitsCut_)continue;
231  matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
232  }
233 
234  //check for candidates/tracks that share merged tracks, select minimum chi2, remove the rest
235  std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter0 = matches.begin();
236  std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter1;
237  while(matchIter0 != matches.end()){
238  double nchi2 = mergedTracks[matchIter0->first].normalizedChi2();
239  bool advance = true;
240  for(matchIter1 = matchIter0+1; matchIter1 != matches.end(); matchIter1++){
241  const reco::Track& match0first = *(matchIter0->second->second.first.get());
242  const reco::Track& match0second = *(matchIter0->second->second.second.get());
243  const reco::Track& match1first = *(matchIter1->second->second.first.get());
244  const reco::Track& match1second = *(matchIter1->second->second.second.get());
245  if(match1first.seedRef() == match0first.seedRef() ||
246  match1first.seedRef() == match0second.seedRef() ||
247  match1second.seedRef() == match0first.seedRef() ||
248  match1second.seedRef() == match0second.seedRef()){
249  double nchi2_1 = mergedTracks[matchIter1->first].normalizedChi2();
250  advance = false;
251  if(nchi2_1 < nchi2){
252  matches.erase(matchIter0);
253  }else{
254  matches.erase(matchIter1);
255  }
256  break;
257  }
258  }
259  if(advance)matchIter0++;
260  }
261 
262  //add the good merged tracks to the output list, remove input tracks
263  std::vector<reco::Track> inputTracks;
264 
265  refTrajs = iEvent.getRefBeforePut< std::vector<Trajectory> >();
266 
267  std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection());
268 
269  for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
270  reco::TrackRef inTrkRef1 = matchIter0->second->second.first;
271  reco::TrackRef inTrkRef2 = matchIter0->second->second.second;
272  const reco::Track& inTrk1 = *(inTrkRef1.get());
273  const reco::Track& inTrk2 = *(inTrkRef2.get());
274  reco::TrackBase::TrackAlgorithm newTrkAlgo = std::min(inTrk1.algo(),inTrk2.algo(),
277  });
278  int combinedQualityMask = (inTrk1.qualityMask() | inTrk2.qualityMask());
279  inputTracks.push_back(inTrk1);
280  inputTracks.push_back(inTrk2);
281  out_generalTracks->push_back(mergedTracks[matchIter0->first]);
282  reco::TrackRef curTrackRef = reco::TrackRef(refTrks, out_generalTracks->size() - 1);
283  float mergedMVA = (*mergedMVAStore)[reco::TrackRef(mergedTrackRefs,matchIter0->first)];
284  mvaVec.push_back(mergedMVA);
285  out_generalTracks->back().setAlgorithm(newTrkAlgo);
286  out_generalTracks->back().setQualityMask(combinedQualityMask);
287  out_generalTracks->back().setQuality(qualityToSet_);
288  edm::RefToBase<TrajectorySeed> origSeedRef;
289  if(copyExtras_){
290  const reco::Track& track = mergedTracks[matchIter0->first];
291  origSeedRef = track.seedRef();
292  //creating a seed with rekeyed clusters if required
293  if (makeReKeyedSeeds_){
294  bool doRekeyOnThisSeed=false;
295 
296  edm::InputTag clusterRemovalInfos("");
297  //grab on of the hits of the seed
298  if (origSeedRef->nHits()!=0){
299  TrajectorySeed::const_iterator firstHit=origSeedRef->recHits().first;
300  const TrackingRecHit *hit = &*firstHit;
301  if (firstHit->isValid()){
303  // the cluster collection either produced a removalInfo or mot
304  //get the clusterremoval info from the provenance: will rekey if this is found
306  edm::Provenance prov=iEvent.getProvenance(pID);
307  clusterRemovalInfos=edm::InputTag(prov.moduleLabel(),
308  prov.productInstanceName(),
309  prov.processName());
310  doRekeyOnThisSeed=iEvent.getByLabel(clusterRemovalInfos,CRIh);
311  }//valid hit
312  }//nhit!=0
313 
314  if (doRekeyOnThisSeed && !(clusterRemovalInfos==edm::InputTag(""))) {
315  ClusterRemovalRefSetter refSetter(iEvent,clusterRemovalInfos);
316  TrajectorySeed::recHitContainer newRecHitContainer;
317  newRecHitContainer.reserve(origSeedRef->nHits());
318  TrajectorySeed::const_iterator iH=origSeedRef->recHits().first;
319  TrajectorySeed::const_iterator iH_end=origSeedRef->recHits().second;
320  for (;iH!=iH_end;++iH){
321  newRecHitContainer.push_back(*iH);
322  refSetter.reKey(&newRecHitContainer.back());
323  }
324  outputSeeds->push_back( TrajectorySeed( origSeedRef->startingState(),
325  newRecHitContainer,
326  origSeedRef->direction()));
327  }
328  //doRekeyOnThisSeed=true
329  else{
330  //just copy the one we had before
331  outputSeeds->push_back( TrajectorySeed(*origSeedRef));
332  }
333  edm::Ref<TrajectorySeedCollection> pureRef(refTrajSeeds, outputSeeds->size()-1);
334  origSeedRef=edm::RefToBase<TrajectorySeed>( pureRef);
335  }//creating a new seed and rekeying it rechit clusters.
336  // Fill TrackExtra collection
337  outputTrkExtras->push_back( reco::TrackExtra(
338  track.outerPosition(), track.outerMomentum(), track.outerOk(),
339  track.innerPosition(), track.innerMomentum(), track.innerOk(),
340  track.outerStateCovariance(), track.outerDetId(),
341  track.innerStateCovariance(), track.innerDetId(),
342  track.seedDirection(), origSeedRef ) );
343  out_generalTracks->back().setExtra( reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
344  reco::TrackExtra & tx = outputTrkExtras->back();
345  tx.setResiduals(track.residuals());
346  // fill TrackingRecHits
347  unsigned nh1=track.recHitsSize();
348  auto const firstTrackIndex = outputTrkHits->size();
349  for ( unsigned ih=0; ih<nh1; ++ih ) {
350  //const TrackingRecHit*hit=&((*(track->recHit(ih))));
351  outputTrkHits->push_back( track.recHit(ih)->clone() );
352  }
353  tx.setHits( refTrkHits, firstTrackIndex, outputTrkHits->size() - firstTrackIndex );
354  }
355  edm::Ref< std::vector<Trajectory> > trajRef(mergedTrajHandle, (*matchIter0).first);
356  TrajTrackAssociationCollection::const_iterator match = mergedTrajTrackHandle->find(trajRef);
357  if (match != mergedTrajTrackHandle->end()) {
358  if(curTrackRef.isNonnull()){
359  outputTrajs->push_back( *trajRef );
361  outputTrajs->back().setSeedRef( origSeedRef );
362  outputTTAss->insert(edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
363  }
364  }
365  }
366 
367  for(int i = 0; i < (int)originalHandle->size(); i++){
368  bool good = true;
369  const reco::Track& origTrack = originalHandle->at(i);
370  for(int j = 0; j < (int)inputTracks.size() && good; j++){
371  const reco::Track& inputTrack = inputTracks[j];
372  if(origTrack.seedRef() != inputTrack.seedRef())continue;
373  if(origTrack.charge() != inputTrack.charge())continue;
374  if(origTrack.momentum() != inputTrack.momentum())continue;
375  if(origTrack.referencePoint() != inputTrack.referencePoint())continue;
376  good = false;
377  }
378 
379  if(good){
380  out_generalTracks->push_back(origTrack);
381  reco::TrackRef curTrackRef = reco::TrackRef(refTrks, out_generalTracks->size() - 1);
382  edm::RefToBase<TrajectorySeed> origSeedRef;
383  reco::TrackRef origTrackRef = reco::TrackRef(originalHandle,i);
384  mvaVec.push_back((*originalMVAStore)[origTrackRef]);
385  //mvaVec.push_back((*originalMVAStore)[reco::TrackRef(originalTrackRefs,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  fillerMVA.insert(out_gtHandle,mvaVec.begin(),mvaVec.end());
471  fillerMVA.fill();
472  iEvent.put(vmMVA,"MVAVals");
473 
474  out_generalTracks->shrink_to_fit(); iEvent.put(out_generalTracks);
475  if (copyExtras_) {
476  outputTrkExtras->shrink_to_fit(); iEvent.put(outputTrkExtras);
477  outputTrkHits->shrink_to_fit(); iEvent.put(outputTrkHits);
478  if (makeReKeyedSeeds_) {
479  outputSeeds->shrink_to_fit(); iEvent.put(outputSeeds);
480  }
481  }
482  outputTrajs->shrink_to_fit(); iEvent.put(outputTrajs);
483  iEvent.put(outputTTAss);
484 }
PropagationDirection direction() const
const Point & referencePoint() const
Reference point on the track.
Definition: TrackBase.h:634
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:514
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:628
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:450
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:815
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
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:520
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:179
ThreeTokens DuplicateListMerger::threeTokens ( const edm::InputTag tag)
inlineprivate

Definition at line 70 of file DuplicateListMerger.cc.

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

Member Data Documentation

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

Definition at line 74 of file DuplicateListMerger.cc.

bool DuplicateListMerger::copyExtras_
private

Definition at line 84 of file DuplicateListMerger.cc.

unsigned int DuplicateListMerger::diffHitsCut_
private

Definition at line 82 of file DuplicateListMerger.cc.

bool DuplicateListMerger::makeReKeyedSeeds_
private

Definition at line 85 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::mergedMVAVals_
private

Definition at line 77 of file DuplicateListMerger.cc.

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

Definition at line 79 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::mergedTrackSource_
private

Definition at line 73 of file DuplicateListMerger.cc.

float DuplicateListMerger::minTrkProbCut_
private

Definition at line 83 of file DuplicateListMerger.cc.

edm::InputTag DuplicateListMerger::originalMVAVals_
private

Definition at line 76 of file DuplicateListMerger.cc.

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

Definition at line 78 of file DuplicateListMerger.cc.

ThreeTokens DuplicateListMerger::originalTrackSource_
private

Definition at line 73 of file DuplicateListMerger.cc.

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

Definition at line 81 of file DuplicateListMerger.cc.