325 std::vector<const reco::TrackCollection*> trackColls;
326 std::vector<edm::Handle<reco::TrackCollection>> trackHandles(
trackProducers_.size());
328 trackColls.push_back(
nullptr);
331 if (trackHandles[i].
isValid()) {
332 trackColls[
i] = trackHandles[
i].product();
335 trackColls[
i] = &s_empty;
339 unsigned int collsSize = trackColls.size();
340 unsigned int rSize = 0;
341 unsigned int trackCollSizes[collsSize];
342 unsigned int trackCollFirsts[collsSize];
343 for (
unsigned int i = 0; i != collsSize; i++) {
344 trackCollSizes[
i] = trackColls[
i]->size();
345 trackCollFirsts[
i] = rSize;
346 rSize += trackCollSizes[
i];
349 statCount.begin(rSize);
358 bool trkUpdated[rSize];
359 int trackCollNum[rSize];
360 int trackQuals[rSize];
361 float trackMVAs[rSize];
363 std::vector<reco::TrackBase::AlgoMask> algoMask(rSize);
364 for (
unsigned int j = 0;
j < rSize;
j++) {
367 trkUpdated[
j] =
false;
370 trackMVAs[
j] = -998.0;
375 for (
unsigned int j = 0;
j != collsSize;
j++) {
388 for (reco::TrackCollection::const_iterator
track = tC1->begin();
track != tC1->end();
track++) {
391 trackQuals[
i] =
track->qualityMask();
392 oriAlgo[
i] =
track->originalAlgo();
393 algoMask[
i] =
track->algoMask();
397 if ((*trackMVAStore).contains(trkRef.
id()))
398 trackMVAs[
i] = (*trackMVAStore)[trkRef];
400 int qual = (*trackSelColl)[trkRef];
406 trackQuals[
i] = qual;
410 selected[
i] = trackQuals[
i] + 10;
411 if ((
short unsigned)
track->ndof() < 1) {
434 statCount.pre(ngood);
437 typedef std::pair<unsigned int, const TrackingRecHit*> IHit;
438 std::vector<std::vector<IHit>> rh1(ngood);
443 for (
unsigned int j = 0;
j < rSize;
j++) {
444 if (selected[
j] == 0)
448 unsigned int collNum = trackCollNum[
j];
449 unsigned int trackNum =
j - trackCollFirsts[collNum];
452 algo[
i] = track->
algo();
459 rh1[
i].reserve(validHits);
460 auto compById = [](IHit
const& h1, IHit
const& h2) {
return h1.first < h2.first; };
463 unsigned int id = hit->
rawId();
467 rh1[
i].emplace_back(
id, hit);
468 std::push_heap(rh1[i].
begin(), rh1[i].
end(), compById);
471 std::sort_heap(rh1[i].
begin(), rh1[i].
end(), compById);
475 if LIKELY (ngood > 1 && collsSize > 1)
477 int saveSelected[rSize];
478 bool notActive[collsSize];
479 for (
unsigned int cn = 0; cn != collsSize; ++cn)
482 for (
unsigned int i = 0; i < rSize; i++)
483 saveSelected[i] = selected[i];
486 for (
unsigned int i = 0; i < rSize - 1; i++) {
487 if (selected[i] == 0)
489 unsigned int collNum = trackCollNum[
i];
492 if (notActive[collNum])
496 unsigned int nh1 = rh1[k1].size();
497 int qualityMaskT1 = trackQuals[
i];
500 float score1 = score[k1];
503 for (
unsigned int j = i + 1;
j < rSize;
j++) {
504 if (selected[
j] == 0)
506 unsigned int collNum2 = trackCollNum[
j];
510 if (notActive[collNum2])
515 int newQualityMask = -9;
517 int maskT1 = saveSelected[
i] > 1 ? saveSelected[
i] - 10 : qualityMaskT1;
518 int maskT2 = saveSelected[
j] > 1 ? saveSelected[
j] - 10 : trackQuals[
j];
519 newQualityMask = (maskT1 | maskT2);
521 unsigned int nh2 = rh1[
k2].size();
536 int firstoverlap = 0;
548 while (ih != nh1 && jh != nh2) {
552 auto const id1 = rh1[k1][ih].first;
553 auto const id2 = rh1[
k2][jh].first;
561 while ((++li) != nh1 && id1 == rh1[k1][li].first) {
564 while ((++lj) != nh2 && id2 == rh1[k2][lj].first) {
566 for (
auto ii = ih;
ii != li; ++
ii)
567 for (
auto jj = jh;
jj != lj; ++
jj) {
580 (collNum != collNum2)
584 auto seti = [&](
unsigned int ii,
unsigned int jj) {
586 selected[
ii] = 10 + newQualityMask;
587 trkUpdated[
ii] =
true;
589 oriAlgo[ii] = oriAlgo[jj];
590 algoMask[
ii] |= algoMask[
jj];
591 algoMask[
jj] = algoMask[
ii];
595 float score2 = score[
k2];
596 constexpr
float almostSame =
598 if (score1 - score2 > almostSame) {
600 }
else if (score2 - score1 > almostSame) {
632 statCount.noOverlap();
635 if (selected[i] == 0)
641 auto vmMVA = std::make_unique<edm::ValueMap<float>>();
646 unsigned int tSize = trackColls[0]->size();
647 auto vm = std::make_unique<edm::ValueMap<int>>();
650 std::vector<int> finalQuals(tSize, -1);
651 for (
unsigned int i = 0; i < rSize; i++) {
652 unsigned int tNum = i % tSize;
654 if (selected[i] > 1) {
655 finalQuals[tNum] = selected[
i] - 10;
657 finalQuals[tNum] = (finalQuals[tNum] | (1 <<
qualityToSet_));
659 if (selected[i] == 1)
660 finalQuals[tNum] = trackQuals[
i];
663 filler.insert(trackHandles[0], finalQuals.begin(), finalQuals.end());
667 for (
auto&
q : finalQuals)
669 auto quals = std::make_unique<QualityMaskCollection>(finalQuals.begin(), finalQuals.end());
672 std::vector<float> mvaVec(tSize, -99);
674 for (
unsigned int i = 0; i < rSize; i++) {
675 unsigned int tNum = i % tSize;
676 mvaVec[tNum] = trackMVAs[tNum];
679 fillerMVA.insert(trackHandles[0], mvaVec.begin(), mvaVec.end());
683 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(), mvaVec.end());
693 std::vector<reco::TrackRef> trackRefs(rSize);
694 std::vector<edm::RefToBase<TrajectorySeed>> seedsRefs(rSize);
696 unsigned int nToWrite = 0;
697 for (
unsigned int i = 0; i < rSize; i++)
698 if (selected[i] != 0)
701 std::vector<float> mvaVec;
703 outputTrks = std::make_unique<reco::TrackCollection>();
711 outputTrkHits = std::make_unique<TrackingRecHitCollection>();
712 outputTrkHits->reserve(nToWrite * 25);
715 outputSeeds = std::make_unique<TrajectorySeedCollection>();
721 outputTrajs = std::make_unique<std::vector<Trajectory>>();
724 for (
unsigned int i = 0; i < rSize; i++) {
725 if (selected[i] == 0) {
730 unsigned int collNum = trackCollNum[
i];
731 unsigned int trackNum = i - trackCollFirsts[collNum];
732 const reco::Track* track = &((trackColls[collNum])->at(trackNum));
734 mvaVec.push_back(trackMVAs[i]);
735 if (selected[i] > 1) {
736 outputTrks->back().setQualityMask(selected[i] - 10);
741 if (selected[i] == 1)
742 outputTrks->back().setQualityMask(trackQuals[i]);
743 outputTrks->back().setOriginalAlgorithm(oriAlgo[i]);
753 bool doRekeyOnThisSeed =
false;
757 if (origSeedRef->
nHits() != 0) {
766 doRekeyOnThisSeed = e.
getByLabel(clusterRemovalInfos, CRIh);
770 if (doRekeyOnThisSeed && !(clusterRemovalInfos ==
edm::InputTag(
""))) {
774 for (
auto const& recHit : origSeedRef->
recHits()) {
776 refSetter.reKey(&newRecHitContainer.
back());
803 seedsRefs[
i] = origSeedRef;
814 outputTrkHits->push_back((*hh)->clone());
826 for (
unsigned int ti = 0; ti < trackColls.size(); ti++) {
835 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
838 if (match != hTTAss1->end()) {
840 uint32_t oldKey = trackCollFirsts[ti] +
static_cast<uint32_t
>(trkRef.
key());
841 if (trackRefs[oldKey].isNonnull()) {
846 outputTTAss->insert(
edm::Ref<std::vector<Trajectory>>(refTrajs,
outputTrajs->size() - 1), trackRefs[oldKey]);
856 fillerMVA.insert(outHandle, mvaVec.begin(), mvaVec.end());
862 auto mvas = std::make_unique<MVACollection>(mvaVec.begin(), mvaVec.end());
PropagationDirection direction() const
const edm::RefToBase< TrajectorySeed > & seedRef() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< bool > promoteQuality_
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
const TrackExtraRef & extra() const
reference to "extra" object
friend struct const_iterator
reco::TrackRefProd refTrks
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)...
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.
key_type key() const
Accessor for product key.
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
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::string const & productInstanceName() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
std::vector< TrajectorySeed > TrajectorySeedCollection
double chi2() const
chi-squared of the fit
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Abs< T >::type abs(const T &t)
edm::ESGetToken< TrackAlgoPriorityOrder, CkfComponentsRecord > priorityToken
unsigned short numberOfValidHits() const
number of valid hits found
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::RefProd< std::vector< Trajectory > > refTrajs
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
std::unique_ptr< reco::TrackExtraCollection > outputTrkExtras
std::vector< int > hasSelector_
for(Iditer=Id.begin();Iditer!=Id.end();Iditer++)
RecHitRange recHits() const
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
std::unique_ptr< TrajectorySeedCollection > outputSeeds
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
constexpr std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
unsigned int nHits() const
std::vector< TkEDGetTokenss > trackProducers_
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
std::string const & processName() const
ProductID id() const
Accessor for product ID.
const TrackResiduals & residuals() const
get the residuals
int numberOfValidPixelHits() const
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.
DetId geographicalId() const
Log< level::Warning, false > LogWarning
std::string const & moduleLabel() const
StableProvenance const & getStableProvenance(BranchID const &theID) const
virtual LocalPoint localPosition() const =0
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
tuple size
Write out results.
reco::TrackExtraRefProd refTrkExtras
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.