328 std::vector<const reco::TrackCollection*> trackColls;
329 std::vector<edm::Handle<reco::TrackCollection>> trackHandles(
trackProducers_.size());
331 trackColls.push_back(
nullptr);
335 trackColls[
i] = trackHandles[
i].product();
338 trackColls[
i] = &s_empty;
342 if (trackColls.empty()) {
348 unsigned int collsSize = trackColls.size();
349 unsigned int rSize = 0;
350 unsigned int trackCollSizes[collsSize];
351 unsigned int trackCollFirsts[collsSize];
352 for (
unsigned int i = 0;
i != collsSize;
i++) {
353 trackCollSizes[
i] = trackColls[
i]->size();
354 trackCollFirsts[
i] = rSize;
355 rSize += trackCollSizes[
i];
364 statCount.begin(rSize);
373 bool trkUpdated[rSize];
374 int trackCollNum[rSize];
375 int trackQuals[rSize];
376 float trackMVAs[rSize];
378 std::vector<reco::TrackBase::AlgoMask> algoMask(rSize);
379 for (
unsigned int j = 0;
j < rSize;
j++) {
382 trkUpdated[
j] =
false;
385 trackMVAs[
j] = -998.0;
390 for (
unsigned int j = 0;
j != collsSize;
j++) {
403 for (reco::TrackCollection::const_iterator
track = tC1->begin();
track != tC1->end();
track++) {
406 trackQuals[
i] =
track->qualityMask();
407 oriAlgo[
i] =
track->originalAlgo();
408 algoMask[
i] =
track->algoMask();
412 if ((*trackMVAStore).contains(trkRef.
id()))
413 trackMVAs[
i] = (*trackMVAStore)[trkRef];
415 int qual = (*trackSelColl)[trkRef];
421 trackQuals[
i] = qual;
425 selected[
i] = trackQuals[
i] + 10;
426 if ((
short unsigned)
track->ndof() < 1) {
449 statCount.pre(ngood);
452 typedef std::pair<unsigned int, const TrackingRecHit*> IHit;
453 std::vector<std::vector<IHit>> rh1(ngood);
458 for (
unsigned int j = 0;
j < rSize;
j++) {
459 if (selected[
j] == 0)
463 unsigned int collNum = trackCollNum[
j];
464 unsigned int trackNum =
j - trackCollFirsts[collNum];
468 int validHits =
track->numberOfValidHits();
469 int validPixelHits =
track->hitPattern().numberOfValidPixelHits();
474 rh1[
i].reserve(validHits);
475 auto compById = [](IHit
const& h1, IHit
const& h2) {
return h1.first < h2.first; };
478 unsigned int id =
hit->rawId();
479 if (
hit->geographicalId().subdetId() > 2)
482 rh1[
i].emplace_back(
id,
hit);
483 std::push_heap(rh1[
i].
begin(), rh1[
i].
end(), compById);
486 std::sort_heap(rh1[
i].
begin(), rh1[
i].
end(), compById);
490 if LIKELY (ngood > 1 && collsSize > 1)
492 int saveSelected[rSize];
493 bool notActive[collsSize];
494 for (
unsigned int cn = 0; cn != collsSize; ++cn)
497 for (
unsigned int i = 0;
i < rSize;
i++)
498 saveSelected[
i] = selected[
i];
501 for (
unsigned int i = 0;
i < rSize - 1;
i++) {
502 if (selected[
i] == 0)
504 unsigned int collNum = trackCollNum[
i];
507 if (notActive[collNum])
511 unsigned int nh1 = rh1[k1].size();
512 int qualityMaskT1 = trackQuals[
i];
515 float score1 =
score[k1];
518 for (
unsigned int j =
i + 1;
j < rSize;
j++) {
519 if (selected[
j] == 0)
521 unsigned int collNum2 = trackCollNum[
j];
525 if (notActive[collNum2])
530 int newQualityMask = -9;
532 int maskT1 = saveSelected[
i] > 1 ? saveSelected[
i] - 10 : qualityMaskT1;
533 int maskT2 = saveSelected[
j] > 1 ? saveSelected[
j] - 10 : trackQuals[
j];
534 newQualityMask = (maskT1 | maskT2);
536 unsigned int nh2 = rh1[k2].size();
551 int firstoverlap = 0;
563 while (ih != nh1 && jh != nh2) {
567 auto const id1 = rh1[k1][ih].first;
568 auto const id2 = rh1[k2][jh].first;
576 while ((++li) != nh1 &&
id1 == rh1[k1][li].
first) {
579 while ((++lj) != nh2 &&
id2 == rh1[k2][lj].
first) {
581 for (
auto ii = ih;
ii != li; ++
ii)
582 for (
auto jj = jh;
jj != lj; ++
jj) {
595 (collNum != collNum2)
599 auto seti = [&](
unsigned int ii,
unsigned int jj) {
601 selected[
ii] = 10 + newQualityMask;
602 trkUpdated[
ii] =
true;
604 oriAlgo[
ii] = oriAlgo[
jj];
605 algoMask[
ii] |= algoMask[
jj];
606 algoMask[
jj] = algoMask[
ii];
610 float score2 =
score[k2];
611 constexpr
float almostSame =
613 if (score1 - score2 > almostSame) {
615 }
else if (score2 - score1 > almostSame) {
647 statCount.noOverlap();
650 if (selected[
i] == 0)
656 auto vmMVA = std::make_unique<edm::ValueMap<float>>();
661 unsigned int tSize = trackColls[0]->size();
662 auto vm = std::make_unique<edm::ValueMap<int>>();
665 std::vector<int> finalQuals(tSize, -1);
666 for (
unsigned int i = 0;
i < rSize;
i++) {
667 unsigned int tNum =
i % tSize;
669 if (selected[
i] > 1) {
670 finalQuals[tNum] = selected[
i] - 10;
672 finalQuals[tNum] = (finalQuals[tNum] | (1 <<
qualityToSet_));
674 if (selected[
i] == 1)
675 finalQuals[tNum] = trackQuals[
i];
678 filler.insert(trackHandles[0], finalQuals.begin(), finalQuals.end());
682 for (
auto&
q : finalQuals)
684 auto quals = std::make_unique<QualityMaskCollection>(finalQuals.begin(), finalQuals.end());
687 std::vector<float> mvaVec(tSize, -99);
689 for (
unsigned int i = 0;
i < rSize;
i++) {
690 unsigned int tNum =
i % tSize;
691 mvaVec[tNum] = trackMVAs[tNum];
694 fillerMVA.insert(trackHandles[0], mvaVec.begin(), mvaVec.end());
698 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(), mvaVec.end());
708 std::vector<reco::TrackRef> trackRefs(rSize);
709 std::vector<edm::RefToBase<TrajectorySeed>> seedsRefs(rSize);
711 unsigned int nToWrite = 0;
712 for (
unsigned int i = 0;
i < rSize;
i++)
713 if (selected[
i] != 0)
716 std::vector<float> mvaVec;
718 outputTrks = std::make_unique<reco::TrackCollection>();
726 outputTrkHits = std::make_unique<TrackingRecHitCollection>();
730 outputSeeds = std::make_unique<TrajectorySeedCollection>();
736 outputTrajs = std::make_unique<std::vector<Trajectory>>();
739 for (
unsigned int i = 0;
i < rSize;
i++) {
740 if (selected[
i] == 0) {
745 unsigned int collNum = trackCollNum[
i];
746 unsigned int trackNum =
i - trackCollFirsts[collNum];
749 mvaVec.push_back(trackMVAs[
i]);
750 if (selected[
i] > 1) {
751 outputTrks->back().setQualityMask(selected[
i] - 10);
756 if (selected[
i] == 1)
758 outputTrks->back().setOriginalAlgorithm(oriAlgo[
i]);
768 bool doRekeyOnThisSeed =
false;
772 if (origSeedRef->
nHits() != 0) {
781 doRekeyOnThisSeed =
e.getByLabel(clusterRemovalInfos, CRIh);
785 if (doRekeyOnThisSeed && !(clusterRemovalInfos ==
edm::InputTag(
""))) {
791 refSetter.reKey(&newRecHitContainer.
back());
807 track->outerMomentum(),
809 track->innerPosition(),
810 track->innerMomentum(),
812 track->outerStateCovariance(),
814 track->innerStateCovariance(),
816 track->seedDirection(),
818 seedsRefs[
i] = origSeedRef;
824 unsigned nh1 =
track->recHitsSize();
828 for (
auto hh =
track->recHitsBegin(), eh =
track->recHitsEnd();
hh != eh; ++
hh) {
837 refTrajs =
e.getRefBeforePut<std::vector<Trajectory>>();
841 for (
unsigned int ti = 0; ti < trackColls.size(); ti++) {
850 for (
size_t i = 0,
n = hTraj1->size();
i <
n; ++
i) {
855 uint32_t oldKey = trackCollFirsts[ti] +
static_cast<uint32_t
>(trkRef.
key());
856 if (trackRefs[oldKey].isNonnull()) {
871 fillerMVA.insert(outHandle, mvaVec.begin(), mvaVec.end());
877 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(), mvaVec.end());
std::vector< bool > promoteQuality_
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
ProductID id() const
Accessor for product ID.
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
friend struct const_iterator
reco::TrackRefProd refTrks
RecHitRange recHits() const
void returnEmptyCollections(edm::Event &e)
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
std::string const & productInstanceName() const
reco::TrackBase::TrackQuality qualityToSet_
std::vector< Track > TrackCollection
collection of Tracks
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::unique_ptr< std::vector< Trajectory > > outputTrajs
key_type key() const
Accessor for product key.
const_iterator find(const key_type &k) const
find element with specified reference key
TrackAlgorithm
track algorithm
TrackingRecHitRefProd refTrkHits
std::vector< double > indivShareFrac_
const_iterator end() const
last iterator over the map (read only)
PropagationDirection direction() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
std::vector< TrajectorySeed > TrajectorySeedCollection
std::string const & moduleLabel() const
unsigned int nHits() const
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
Abs< T >::type abs(const T &t)
std::string const & processName() const
edm::ESGetToken< TrackAlgoPriorityOrder, CkfComponentsRecord > priorityToken
edm::RefProd< std::vector< Trajectory > > refTrajs
PTrajectoryStateOnDet const & startingState() const
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_
DetId geographicalId() const
std::unique_ptr< TrajectorySeedCollection > outputSeeds
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
constexpr std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
std::vector< TkEDGetTokenss > trackProducers_
std::vector< std::vector< int > > listsToMerge_
std::unique_ptr< reco::TrackCollection > outputTrks
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Log< level::Warning, false > LogWarning
virtual LocalPoint localPosition() const =0
reco::TrackExtraRefProd refTrkExtras