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());
189 std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
191 std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
193 std::auto_ptr<TrajectorySeedCollection> outputSeeds;
204 std::vector<float> mvaVec;
209 outputTrkExtras->reserve(originalHandle->size());
212 outputTrkHits->reserve(originalHandle->size()*25);
216 outputSeeds->
reserve(originalHandle->size());
222 std::vector<std::pair<int,const DuplicateRecord*> >
matches;
223 for(
int i = 0;
i < (int)candidateHandle->size();
i++){
226 if(matchTrack < 0)
continue;
227 const reco::Track& matchedTrack(mergedTracks[matchTrack]);
229 unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.recHitsSize();
231 matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
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();
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());
249 double nchi2_1 = mergedTracks[matchIter1->first].
normalizedChi2();
252 matches.erase(matchIter0);
254 matches.erase(matchIter1);
259 if(advance)matchIter0++;
263 std::vector<reco::Track> inputTracks;
267 std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(
new TrajTrackAssociationCollection(refTrajs, refTrks));
269 for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
279 inputTracks.push_back(inTrk1);
280 inputTracks.push_back(inTrk2);
281 out_generalTracks->push_back(mergedTracks[matchIter0->first]);
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);
290 const reco::Track& track = mergedTracks[matchIter0->first];
294 bool doRekeyOnThisSeed=
false;
298 if (origSeedRef->
nHits()!=0){
301 if (firstHit->isValid()){
310 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
314 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
320 for (;iH!=iH_end;++iH){
322 refSetter.reKey(&newRecHitContainer.
back());
343 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
348 auto const firstTrackIndex = outputTrkHits->size();
349 for (
unsigned ih=0; ih<nh1; ++ih ) {
351 outputTrkHits->push_back( track.
recHit(ih)->clone() );
353 tx.
setHits( refTrkHits, firstTrackIndex, outputTrkHits->size() - firstTrackIndex );
357 if (match != mergedTrajTrackHandle->end()) {
359 outputTrajs->push_back( *trajRef );
361 outputTrajs->back().setSeedRef( origSeedRef );
362 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
367 for(
int i = 0;
i < (int)originalHandle->size();
i++){
370 for(
int j = 0;
j < (int)inputTracks.size() && good;
j++){
380 out_generalTracks->push_back(origTrack);
384 mvaVec.push_back((*originalMVAStore)[origTrackRef]);
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 );
470 fillerMVA.insert(out_gtHandle,mvaVec.begin(),mvaVec.end());
472 iEvent.
put(vmMVA,
"MVAVals");
474 out_generalTracks->shrink_to_fit(); iEvent.
put(out_generalTracks);
476 outputTrkExtras->shrink_to_fit(); iEvent.
put(outputTrkExtras);
477 outputTrkHits->shrink_to_fit(); iEvent.
put(outputTrkHits);
479 outputSeeds->shrink_to_fit(); iEvent.
put(outputSeeds);
482 outputTrajs->shrink_to_fit(); iEvent.
put(outputTrajs);
483 iEvent.
put(outputTTAss);
PropagationDirection direction() const
const Point & referencePoint() const
Reference point on the track.
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< TrajTrackAssociationCollection > tass
ThreeTokens mergedTrackSource_
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)...
edm::EDGetTokenT< edm::ValueMap< float > > originalMVAValsToken_
std::vector< Track > TrackCollection
collection of Tracks
edm::EDGetTokenT< std::vector< Trajectory > > traj
bool innerOk() const
return true if the innermost hit is valid
std::pair< TrackCandidate, std::pair< reco::TrackRef, reco::TrackRef > > DuplicateRecord
typedef container of candidate and input tracks
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< 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::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.
edm::EDGetTokenT< edm::ValueMap< float > > mergedMVAValsToken_
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.