329 std::vector<const reco::TrackCollection *> trackColls;
330 std::vector<edm::Handle<reco::TrackCollection> > trackHandles(
trackProducers_.size());
332 trackColls.push_back(
nullptr);
335 if (trackHandles[i].isValid()) {
336 trackColls[
i]= trackHandles[
i].product();
339 trackColls[
i]=&s_empty;
343 unsigned int collsSize =trackColls.size();
344 unsigned int rSize=0;
345 unsigned int trackCollSizes[collsSize];
346 unsigned int trackCollFirsts[collsSize];
347 for (
unsigned int i=0; i!=collsSize; i++) {
348 trackCollSizes[
i]=trackColls[
i]->size();
349 trackCollFirsts[
i]=rSize;
350 rSize+=trackCollSizes[
i];
353 statCount.begin(rSize);
362 bool trkUpdated[rSize];
363 int trackCollNum[rSize];
364 int trackQuals[rSize];
365 float trackMVAs[rSize];
367 std::vector<reco::TrackBase::AlgoMask> algoMask(rSize);
368 for (
unsigned int j=0; j<rSize;j++) {
373 for (
unsigned int j=0; j!= collsSize; j++) {
384 if ( !tC1->empty() ){
386 for (reco::TrackCollection::const_iterator
track=tC1->begin();
track!=tC1->end();
track++){
389 trackQuals[
i]=
track->qualityMask();
390 oriAlgo[
i]=
track->originalAlgo();
391 algoMask[
i]=
track->algoMask();
395 if( (*trackMVAStore).contains(trkRef.
id()) ) trackMVAs[
i] = (*trackMVAStore)[trkRef];
397 int qual=(*trackSelColl)[trkRef];
407 selected[
i]=trackQuals[
i]+10;
408 if ((
short unsigned)
track->ndof() < 1){
432 statCount.pre(ngood);
435 typedef std::pair<unsigned int, const TrackingRecHit*> IHit;
436 std::vector<std::vector<IHit>> rh1(ngood);
442 for (
unsigned int j=0; j<rSize; j++) {
443 if (selected[j]==0)
continue;
446 unsigned int collNum=trackCollNum[j];
447 unsigned int trackNum=j-trackCollFirsts[collNum];
450 algo[
i]=track->
algo();
457 rh1[
i].reserve(validHits) ;
458 auto compById = [](IHit
const & h1, IHit
const & h2) {
return h1.first < h2.first;};
461 unsigned int id = hit->
rawId() ;
463 if likely(hit->
isValid()) { rh1[
i].emplace_back(
id,hit); std::push_heap(rh1[i].
begin(),rh1[i].
end(),compById); }
465 std::sort_heap(rh1[i].
begin(),rh1[i].
end(),compById);
469 if likely(ngood>1 && collsSize>1)
471 int saveSelected[rSize];
472 bool notActive[collsSize];
473 for (
unsigned int cn=0;cn!=collsSize;++cn)
476 for (
unsigned int i=0; i<rSize; i++) saveSelected[i]=selected[i];
479 for (
unsigned int i=0; i<rSize-1; i++) {
480 if (selected[i]==0)
continue;
481 unsigned int collNum=trackCollNum[
i];
484 if (notActive[collNum])
continue;
487 unsigned int nh1=rh1[k1].size();
488 int qualityMaskT1 = trackQuals[
i];
491 float score1 = score[k1];
494 for (
unsigned int j=i+1; j<rSize; j++) {
495 if (selected[j]==0)
continue;
496 unsigned int collNum2=trackCollNum[j];
497 if ( (collNum == collNum2) &&
indivShareFrac_[collNum] > 0.99)
continue;
499 if (notActive[collNum2])
continue;
503 int newQualityMask = -9;
505 int maskT1= saveSelected[
i]>1? saveSelected[
i]-10 : qualityMaskT1;
506 int maskT2= saveSelected[j]>1? saveSelected[j]-10 : trackQuals[j];
507 newQualityMask =(maskT1 | maskT2);
509 unsigned int nh2=rh1[k2].size();
529 if (share(it,jt,
epsilon_)) firstoverlap=1;
536 while (ih!=nh1 && jh!=nh2) {
540 auto const id1 = rh1[k1][ih].first;
541 auto const id2 = rh1[k2][jh].first;
543 else if (id2<id1) ++jh;
546 auto li=ih;
while( (++li)!=nh1 && id1 == rh1[k1][li].first);
547 auto lj=jh;
while( (++lj)!=nh2 && id2 == rh1[k2][lj].first);
548 for (
auto ii=ih;
ii!=li; ++
ii)
549 for (
auto jj=jh;
jj!=lj; ++
jj) {
552 if (share(it,jt,
epsilon_)) noverlap++;
559 bool dupfound = (collNum != collNum2) ? (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*
shareFrac_ :
562 auto seti = [&](
unsigned int ii,
unsigned int jj) {
564 selected[
ii]=10+newQualityMask;
567 algoMask[
ii] |= algoMask[
jj];
568 algoMask[
jj] = algoMask[
ii];
572 float score2 = score[k2];
574 if ( score1 - score2 > almostSame ) {
576 }
else if ( score2 - score1 > almostSame ) {
604 statCount.noOverlap();
607 if (selected[i]==0)
break;
614 auto vmMVA = std::make_unique<edm::ValueMap<float>>();
621 unsigned int tSize=trackColls[0]->size();
622 auto vm = std::make_unique<edm::ValueMap<int>>();
625 std::vector<int> finalQuals(tSize,-1);
626 for (
unsigned int i=0; i<rSize; i++) {
627 unsigned int tNum=i%tSize;
629 if (selected[i]>1 ) {
630 finalQuals[tNum]=selected[
i]-10;
634 if ( selected[i]==1 )
635 finalQuals[tNum]=trackQuals[
i];
638 filler.insert(trackHandles[0], finalQuals.begin(),finalQuals.end());
643 auto quals = std::make_unique<QualityMaskCollection>(finalQuals.begin(),finalQuals.end());
646 std::vector<float> mvaVec(tSize,-99);
648 for(
unsigned int i = 0; i < rSize; i++){
649 unsigned int tNum = i % tSize;
650 mvaVec[tNum] = trackMVAs[tNum];
653 fillerMVA.insert(trackHandles[0],mvaVec.begin(),mvaVec.end());
657 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(),mvaVec.end());
668 std::vector<reco::TrackRef> trackRefs(rSize);
669 std::vector<edm::RefToBase<TrajectorySeed>> seedsRefs(rSize);
671 unsigned int nToWrite=0;
672 for (
unsigned int i=0; i<rSize; i++)
673 if (selected[i]!=0) nToWrite++;
675 std::vector<float> mvaVec;
677 outputTrks = std::make_unique<reco::TrackCollection>();
685 outputTrkHits = std::make_unique<TrackingRecHitCollection>();
686 outputTrkHits->reserve(nToWrite*25);
689 outputSeeds = std::make_unique<TrajectorySeedCollection>();
696 outputTrajs = std::make_unique<std::vector<Trajectory>>();
697 outputTrajs->reserve(rSize);
699 for (
unsigned int i=0; i<rSize; i++) {
700 if (selected[i]==0) {
705 unsigned int collNum=trackCollNum[
i];
706 unsigned int trackNum=i-trackCollFirsts[collNum];
707 const reco::Track *track=&((trackColls[collNum])->at(trackNum));
709 mvaVec.push_back(trackMVAs[i]);
710 if (selected[i]>1 ) {
711 outputTrks->back().setQualityMask(selected[i]-10);
716 if ( selected[i]==1 )
717 outputTrks->back().setQualityMask(trackQuals[i]);
718 outputTrks->back().setOriginalAlgorithm(oriAlgo[i]);
728 bool doRekeyOnThisSeed=
false;
732 if (origSeedRef->
nHits()!=0){
735 if (firstHit->isValid()){
744 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
748 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
754 for (;iH!=iH_end;++iH){
756 refSetter.reKey(&newRecHitContainer.
back());
778 seedsRefs[
i]=origSeedRef;
789 outputTrkHits->push_back( (*hh)->clone() );
802 for (
unsigned int ti=0; ti<trackColls.size(); ti++) {
810 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
813 if (match != hTTAss1->
end()) {
815 uint32_t oldKey = trackCollFirsts[ti]+
static_cast<uint32_t
>(trkRef.
key());
816 if (trackRefs[oldKey].isNonnull()) {
817 outputTrajs->push_back( *trajRef );
820 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
821 outputTTAss->insert (
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),
832 fillerMVA.insert(outHandle,mvaVec.begin(),mvaVec.end());
838 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(),mvaVec.end());
PropagationDirection direction() const
const edm::RefToBase< TrajectorySeed > & seedRef() const
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< bool > promoteQuality_
const TrackExtraRef & extra() const
reference to "extra" object
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
reco::TrackRefProd refTrks
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::RefProd< std::vector< Trajectory > > refTrajs
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
const_iterator find(const key_type &k) const
find element with specified reference key
reco::TrackBase::TrackQuality qualityToSet_
std::vector< Track > TrackCollection
collection of Tracks
bool innerOk() const
return true if the innermost hit is valid
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
std::unique_ptr< TrajectorySeedCollection > outputSeeds
key_type key() const
Accessor for product key.
std::string const & processName() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const math::XYZPoint & outerPosition() const
position of the outermost hit
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
std::unique_ptr< std::vector< Trajectory > > outputTrajs
ProductID id() const
Accessor for product ID.
TrackAlgorithm
track algorithm
TrackingRecHitRefProd refTrkHits
std::vector< double > indivShareFrac_
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
std::vector< TrajectorySeed > TrajectorySeedCollection
double chi2() const
chi-squared of the fit
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.
Abs< T >::type abs(const T &t)
unsigned short numberOfValidHits() const
number of valid hits found
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
virtual LocalPoint localPosition() const =0
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
std::unique_ptr< reco::TrackExtraCollection > outputTrkExtras
std::vector< int > hasSelector_
ProductID id() const
Accessor for product ID.
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
double maxNormalizedChisq_
PTrajectoryStateOnDet const & startingState() const
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
std::string const & moduleLabel() const
unsigned int nHits() const
std::vector< TkEDGetTokenss > trackProducers_
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
const TrackResiduals & residuals() const
get the residuals
int numberOfValidPixelHits() const
std::unique_ptr< reco::TrackCollection > outputTrks
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
DetId geographicalId() const
std::string const & productInstanceName() const
std::string priorityName_
std::vector< std::vector< int > > listsToMerge_
Provenance getProvenance(BranchID const &theID) const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
reco::TrackExtraRefProd refTrkExtras
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.