324 std::vector<const reco::TrackCollection*> trackColls;
325 std::vector<edm::Handle<reco::TrackCollection>> trackHandles(
trackProducers_.size());
327 trackColls.push_back(
nullptr);
331 trackColls[
i] = trackHandles[
i].product();
334 trackColls[
i] = &s_empty;
338 if (trackColls.empty()) {
344 unsigned int collsSize = trackColls.size();
345 unsigned int rSize = 0;
346 unsigned int trackCollSizes[collsSize];
347 unsigned int trackCollFirsts[collsSize];
348 for (
unsigned int i = 0;
i != collsSize;
i++) {
349 trackCollSizes[
i] = trackColls[
i]->size();
350 trackCollFirsts[
i] = rSize;
351 rSize += trackCollSizes[
i];
360 statCount.begin(rSize);
369 bool trkUpdated[rSize];
370 int trackCollNum[rSize];
371 int trackQuals[rSize];
372 float trackMVAs[rSize];
374 std::vector<reco::TrackBase::AlgoMask> algoMask(rSize);
375 for (
unsigned int j = 0;
j < rSize;
j++) {
378 trkUpdated[
j] =
false;
381 trackMVAs[
j] = -998.0;
386 for (
unsigned int j = 0;
j != collsSize;
j++) {
399 for (reco::TrackCollection::const_iterator
track = tC1->begin();
track != tC1->end();
track++) {
402 trackQuals[
i] =
track->qualityMask();
403 oriAlgo[
i] =
track->originalAlgo();
404 algoMask[
i] =
track->algoMask();
408 if ((*trackMVAStore).contains(trkRef.
id()))
409 trackMVAs[
i] = (*trackMVAStore)[trkRef];
411 int qual = (*trackSelColl)[trkRef];
417 trackQuals[
i] = qual;
421 selected[
i] = trackQuals[
i] + 10;
422 if ((
short unsigned)
track->ndof() < 1) {
445 statCount.pre(ngood);
448 typedef std::pair<unsigned int, const TrackingRecHit*> IHit;
449 std::vector<std::vector<IHit>> rh1(ngood);
454 for (
unsigned int j = 0;
j < rSize;
j++) {
455 if (selected[
j] == 0)
459 unsigned int collNum = trackCollNum[
j];
460 unsigned int trackNum =
j - trackCollFirsts[collNum];
464 int validHits =
track->numberOfValidHits();
465 int validPixelHits =
track->hitPattern().numberOfValidPixelHits();
470 rh1[
i].reserve(validHits);
471 auto compById = [](IHit
const& h1, IHit
const& h2) {
return h1.first < h2.first; };
474 unsigned int id =
hit->rawId();
475 if (
hit->geographicalId().subdetId() > 2)
478 rh1[
i].emplace_back(
id,
hit);
479 std::push_heap(rh1[
i].begin(), rh1[
i].
end(), compById);
482 std::sort_heap(rh1[
i].begin(), rh1[
i].
end(), compById);
486 if LIKELY (ngood > 1 && collsSize > 1)
488 int saveSelected[rSize];
489 bool notActive[collsSize];
490 for (
unsigned int cn = 0; cn != collsSize; ++cn)
493 for (
unsigned int i = 0;
i < rSize;
i++)
494 saveSelected[
i] = selected[
i];
497 for (
unsigned int i = 0;
i < rSize - 1;
i++) {
498 if (selected[
i] == 0)
500 unsigned int collNum = trackCollNum[
i];
503 if (notActive[collNum])
507 unsigned int nh1 = rh1[k1].size();
508 int qualityMaskT1 = trackQuals[
i];
511 float score1 =
score[k1];
514 for (
unsigned int j =
i + 1;
j < rSize;
j++) {
515 if (selected[
j] == 0)
517 unsigned int collNum2 = trackCollNum[
j];
521 if (notActive[collNum2])
526 int newQualityMask = -9;
528 int maskT1 = saveSelected[
i] > 1 ? saveSelected[
i] - 10 : qualityMaskT1;
529 int maskT2 = saveSelected[
j] > 1 ? saveSelected[
j] - 10 : trackQuals[
j];
530 newQualityMask = (maskT1 | maskT2);
532 unsigned int nh2 = rh1[k2].size();
547 int firstoverlap = 0;
559 while (ih != nh1 && jh != nh2) {
563 auto const id1 = rh1[k1][ih].first;
564 auto const id2 = rh1[k2][jh].first;
572 while ((++li) != nh1 &&
id1 == rh1[k1][li].
first) {
575 while ((++lj) != nh2 &&
id2 == rh1[k2][lj].
first) {
577 for (
auto ii = ih;
ii != li; ++
ii)
578 for (
auto jj = jh;
jj != lj; ++
jj) {
591 (collNum != collNum2)
595 auto seti = [&](
unsigned int ii,
unsigned int jj) {
597 selected[
ii] = 10 + newQualityMask;
598 trkUpdated[
ii] =
true;
600 oriAlgo[
ii] = oriAlgo[
jj];
601 algoMask[
ii] |= algoMask[
jj];
602 algoMask[
jj] = algoMask[
ii];
606 float score2 =
score[k2];
607 constexpr
float almostSame =
609 if (score1 - score2 > almostSame) {
611 }
else if (score2 - score1 > almostSame) {
643 statCount.noOverlap();
646 if (selected[
i] == 0)
652 auto vmMVA = std::make_unique<edm::ValueMap<float>>();
657 unsigned int tSize = trackColls[0]->size();
658 auto vm = std::make_unique<edm::ValueMap<int>>();
661 std::vector<int> finalQuals(tSize, -1);
662 for (
unsigned int i = 0;
i < rSize;
i++) {
663 unsigned int tNum =
i % tSize;
665 if (selected[
i] > 1) {
666 finalQuals[tNum] = selected[
i] - 10;
668 finalQuals[tNum] = (finalQuals[tNum] | (1 <<
qualityToSet_));
670 if (selected[
i] == 1)
671 finalQuals[tNum] = trackQuals[
i];
674 filler.insert(trackHandles[0], finalQuals.begin(), finalQuals.end());
678 for (
auto&
q : finalQuals)
680 auto quals = std::make_unique<QualityMaskCollection>(finalQuals.begin(), finalQuals.end());
683 std::vector<float> mvaVec(tSize, -99);
685 for (
unsigned int i = 0;
i < rSize;
i++) {
686 unsigned int tNum =
i % tSize;
687 mvaVec[tNum] = trackMVAs[tNum];
690 fillerMVA.insert(trackHandles[0], mvaVec.begin(), mvaVec.end());
694 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(), mvaVec.end());
704 std::vector<reco::TrackRef> trackRefs(rSize);
705 std::vector<edm::RefToBase<TrajectorySeed>> seedsRefs(rSize);
707 unsigned int nToWrite = 0;
708 for (
unsigned int i = 0;
i < rSize;
i++)
709 if (selected[
i] != 0)
712 std::vector<float> mvaVec;
714 outputTrks = std::make_unique<reco::TrackCollection>();
722 outputTrkHits = std::make_unique<TrackingRecHitCollection>();
726 outputSeeds = std::make_unique<TrajectorySeedCollection>();
732 outputTrajs = std::make_unique<std::vector<Trajectory>>();
735 for (
unsigned int i = 0;
i < rSize;
i++) {
736 if (selected[
i] == 0) {
741 unsigned int collNum = trackCollNum[
i];
742 unsigned int trackNum =
i - trackCollFirsts[collNum];
745 mvaVec.push_back(trackMVAs[
i]);
746 if (selected[
i] > 1) {
747 outputTrks->back().setQualityMask(selected[
i] - 10);
752 if (selected[
i] == 1)
754 outputTrks->back().setOriginalAlgorithm(oriAlgo[
i]);
764 bool doRekeyOnThisSeed =
false;
768 if (origSeedRef->
nHits() != 0) {
777 doRekeyOnThisSeed =
e.getByLabel(clusterRemovalInfos, CRIh);
781 if (doRekeyOnThisSeed && !(clusterRemovalInfos ==
edm::InputTag(
""))) {
787 refSetter.reKey(&newRecHitContainer.
back());
803 track->outerMomentum(),
805 track->innerPosition(),
806 track->innerMomentum(),
808 track->outerStateCovariance(),
810 track->innerStateCovariance(),
812 track->seedDirection(),
814 seedsRefs[
i] = origSeedRef;
820 unsigned nh1 =
track->recHitsSize();
824 for (
auto hh =
track->recHitsBegin(), eh =
track->recHitsEnd();
hh != eh; ++
hh) {
833 refTrajs =
e.getRefBeforePut<std::vector<Trajectory>>();
837 for (
unsigned int ti = 0; ti < trackColls.size(); ti++) {
846 for (
size_t i = 0,
n = hTraj1->size();
i <
n; ++
i) {
851 uint32_t oldKey = trackCollFirsts[ti] +
static_cast<uint32_t
>(trkRef.
key());
852 if (trackRefs[oldKey].isNonnull()) {
867 fillerMVA.insert(outHandle, mvaVec.begin(), mvaVec.end());
873 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