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());
192 std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
194 std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
196 std::auto_ptr<TrajectorySeedCollection> outputSeeds;
210 outputTrkExtras->reserve(originalHandle->size());
213 outputTrkHits->reserve(originalHandle->size()*25);
217 outputSeeds->
reserve(originalHandle->size());
223 std::vector<std::pair<int,const DuplicateRecord*> >
matches;
224 for(
int i = 0;
i < (int)candidateHandle->size();
i++){
227 if(matchTrack < 0)
continue;
228 const reco::Track& matchedTrack(mergedTracks[matchTrack]);
230 unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.recHitsSize();
232 matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
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();
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());
250 double nchi2_1 = mergedTracks[matchIter1->first].
normalizedChi2();
253 matches.erase(matchIter0);
255 matches.erase(matchIter1);
260 if(advance)matchIter0++;
264 std::vector<reco::Track> inputTracks;
268 std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(
new TrajTrackAssociationCollection(refTrajs, refTrks));
270 for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
280 inputTracks.push_back(inTrk1);
281 inputTracks.push_back(inTrk2);
282 out_generalTracks->push_back(mergedTracks[matchIter0->first]);
284 float mergedMVA = (*mergedMVAStore)[matchIter0->first];
285 mvaVec.push_back(mergedMVA);
286 out_generalTracks->back().setAlgorithm(newTrkAlgo);
287 out_generalTracks->back().setQualityMask(combinedQualityMask);
291 const reco::Track& track = mergedTracks[matchIter0->first];
295 bool doRekeyOnThisSeed=
false;
299 if (origSeedRef->
nHits()!=0){
302 if (firstHit->isValid()){
311 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
315 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
321 for (;iH!=iH_end;++iH){
323 refSetter.reKey(&newRecHitContainer.
back());
344 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
349 auto const firstTrackIndex = outputTrkHits->size();
350 for (
unsigned ih=0; ih<nh1; ++ih ) {
352 outputTrkHits->push_back( track.
recHit(ih)->clone() );
354 tx.
setHits( refTrkHits, firstTrackIndex, outputTrkHits->size() - firstTrackIndex );
358 if (match != mergedTrajTrackHandle->end()) {
360 outputTrajs->push_back( *trajRef );
362 outputTrajs->back().setSeedRef( origSeedRef );
363 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
368 for(
int i = 0;
i < (int)originalHandle->size();
i++){
371 for(
int j = 0;
j < (int)inputTracks.size() && good;
j++){
381 out_generalTracks->push_back(origTrack);
385 mvaVec.push_back((*originalMVAStore)[
i]);
391 bool doRekeyOnThisSeed=
false;
395 if (origSeedRef->nHits()!=0){
398 if (firstHit->isValid()){
407 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
411 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
414 newRecHitContainer.
reserve(origSeedRef->nHits());
417 for (;iH!=iH_end;++iH){
419 refSetter.reKey(&newRecHitContainer.
back());
421 outputSeeds->push_back(
TrajectorySeed( origSeedRef->startingState(),
423 origSeedRef->direction()));
441 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
447 tx.
setHits(refTrkHits,outputTrkHits->size(),nh1);
449 outputTrkHits->push_back( (*hh)->clone() );
456 if (match != originalTrajTrackHandle->end()) {
458 outputTrajs->push_back( *trajRef );
460 outputTrajs->back().setSeedRef( origSeedRef );
461 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
472 out_generalTracks->shrink_to_fit(); iEvent.
put(out_generalTracks);
474 outputTrkExtras->shrink_to_fit(); iEvent.
put(outputTrkExtras);
475 outputTrkHits->shrink_to_fit(); iEvent.
put(outputTrkHits);
477 outputSeeds->shrink_to_fit(); iEvent.
put(outputSeeds);
480 outputTrajs->shrink_to_fit(); iEvent.
put(outputTrajs);
481 iEvent.
put(outputTTAss);
PropagationDirection direction() const
const Point & referencePoint() const
Reference point on the track.
edm::EDGetTokenT< MVACollection > mergedMVAValsToken_
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< TrajTrackAssociationCollection > tass
ThreeTokens mergedTrackSource_
std::vector< float > MVACollection
friend struct const_iterator
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
std::vector< Track > TrackCollection
collection of Tracks
edm::EDGetTokenT< std::vector< Trajectory > > traj
bool innerOk() const
return true if the innermost hit is valid
const Vector & momentum() const
track momentum vector
std::string const & processName() const
const math::XYZPoint & outerPosition() const
position of the outermost hit
TrackAlgorithm
track algorithm
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
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.
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
unsigned int diffHitsCut_
float ChiSquaredProbability(double chiSquared, double nrDOF)
T const * get() const
Returns C++ pointer to the item.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
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
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
edm::RefToBase< TrajectorySeed > seedRef() const
PTrajectoryStateOnDet const & startingState() const
int matchCandidateToTrack(TrackCandidate, edm::Handle< reco::TrackCollection >)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
reco::TrackBase::TrackQuality qualityToSet_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
std::string const & moduleLabel() const
edm::ProductID clusterProductB(const TrackingRecHit *hit)
unsigned int nHits() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
const TrackResiduals & residuals() const
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
int charge() const
track electric charge
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::string const & productInstanceName() const
Provenance getProvenance(BranchID const &theID) const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.