109 pID=
reinterpret_cast<const SiPixelRecHit *
>(hit)->cluster().id();
111 const std::type_info &
type =
typeid(*hit);
122 }
else throw cms::Exception(
"Unknown RecHit Type") <<
"RecHit of type " << type.name() <<
" not supported. (use c++filt to demangle the name)";
134 edm::LogWarning(
"SimpleTrackListMerger") <<
"this class is obsolete, please use TrackListMerger";
138 produces<reco::TrackCollection>();
141 if (makeReKeyedSeeds_){
143 produces<TrajectorySeedCollection>();
147 produces<reco::TrackExtraCollection>();
148 produces<TrackingRecHitCollection>();
150 produces< std::vector<Trajectory> >();
151 produces< TrajTrackAssociationCollection >();
179 bool use_sharesInput =
true;
180 if ( epsilon > 0.0 )use_sharesInput =
false;
192 if (qualityStr !=
"") {
218 if (trackCollection1.
isValid()) {
219 TC1 = trackCollection1.
product();
230 if (trackCollection2.
isValid()) {
231 TC2 = trackCollection2.
product();
240 outputTrks = std::make_unique<reco::TrackCollection>();
247 outputTrkHits = std::make_unique<TrackingRecHitCollection>();
248 outputTrkHits->reserve((TC1->size()+TC2->size())*25);
251 outputSeeds = std::make_unique<TrajectorySeedCollection>();
257 outputTrajs = std::make_unique<std::vector<Trajectory>>();
258 outputTrajs->reserve(TC1->size()+TC2->size());
259 outputTTAss = std::make_unique<TrajTrackAssociationCollection>();
277 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
281 for (reco::TrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end();
track++){
283 if ((
short unsigned)
track->ndof() < 1){
288 if (
track->normalizedChi2() > maxNormalizedChisq){
293 if (
track->found() < minFound){
298 if (
track->pt() < minPT){
307 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
311 for (reco::TrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end();
track++){
313 if ((
short unsigned)
track->ndof() < 1){
318 if (
track->normalizedChi2() > maxNormalizedChisq){
323 if (
track->found() < minFound){
328 if (
track->pt() < minPT){
336 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
337 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
338 for (reco::TrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
343 rh1[
track].push_back(hit);
346 for (reco::TrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end(); ++
track){
351 rh2[
track].push_back(hit);
355 if ( (0<tC1.size())&&(0<tC2.size()) ){
357 for (reco::TrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
359 if (!selected1[i])
continue;
360 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
361 unsigned nh1 = iHits.size();
362 int qualityMaskT1 =
track->qualityMask();
364 for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
366 if ((!selected2[j])||(!selected1[
i]))
continue;
367 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
368 unsigned nh2 = jHits.size();
371 for (
unsigned ih=0; ih<nh1; ++ih ) {
375 for (
unsigned jh=0; jh<nh2; ++jh ) {
379 if (!use_sharesInput){
383 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
388 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
395 int newQualityMask = (qualityMaskT1 | track2->qualityMask());
396 int nhit1 =
track->numberOfValidHits();
397 int nhit2 = track2->numberOfValidHits();
398 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
399 double score1 = foundHitBonus*nhit1 - lostHitPenalty*
track->numberOfLostHits() -
track->chi2();
400 double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
401 const double almostSame = 1.001;
402 if ( score1 > almostSame * score2 ){
404 selected1[
i]=10+newQualityMask;
405 }
else if ( score2 > almostSame * score1 ){
407 selected2[j]=10+newQualityMask;
411 selected1[
i]=10+newQualityMask;
414 selected2[j]=10+newQualityMask;
426 std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
431 for (reco::TrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end();
440 if (selected1[i]>1 && promoteQuality){
441 outputTrks->back().setQualityMask(selected1[i]-10);
449 bool doRekeyOnThisSeed=
false;
453 if (origSeedRef->
nHits()!=0){
456 if (firstHit->isValid()){
466 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
470 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
477 for (;iH!=iH_end;++iH){
479 refSetter.
reKey(&newRecHitContainer.
back());
501 seedsRefs[current]=origSeedRef;
506 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
507 unsigned nh1 = iHits.size();
509 for (
unsigned ih=0; ih<nh1; ++ih ) {
529 if (!hTraj1.failedToGet() && !hTTAss1.
failedToGet()){
530 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
533 if (match != hTTAss1->
end()) {
535 short oldKey =
static_cast<short>(trkRef.
key());
537 outputTrajs->push_back( *trajRef );
540 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
552 for (reco::TrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end();
561 if (selected2[i]>1 && promoteQuality){
562 outputTrks->back().setQualityMask(selected2[i]-10);
570 bool doRekeyOnThisSeed=
false;
574 if (origSeedRef->
nHits()!=0){
577 if (firstHit->isValid()){
586 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
590 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
597 for (;iH!=iH_end;++iH){
599 refSetter.
reKey(&newRecHitContainer.
back());
620 seedsRefs[current]=origSeedRef;
625 std::vector<const TrackingRecHit*>& jHits = rh2[
track];
626 unsigned nh2 = jHits.size();
628 for (
unsigned jh=0; jh<nh2; ++jh ) {
645 if (!hTraj2.failedToGet() && !hTTAss2.
failedToGet()){
646 for (
size_t i = 0,
n = hTraj2->size(); i <
n; ++
i) {
649 if (match != hTTAss2->
end()) {
651 short oldKey =
static_cast<short>(trkRef.
key()) + offset;
653 outputTrajs->push_back(
Trajectory(*trajRef) );
656 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
PropagationDirection direction() const
const edm::RefToBase< TrajectorySeed > & seedRef() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< reco::TrackCollection > outputTrks
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
qualityToSet
set to false on AOD
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
void reKey(TrackingRecHit *hit) const
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< Track > TrackCollection
collection of Tracks
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
TrackingRecHitRefProd refTrkHits
bool innerOk() const
return true if the innermost hit is valid
key_type key() const
Accessor for product key.
std::unique_ptr< TrajectorySeedCollection > outputSeeds
std::string const & processName() const
const math::XYZPoint & outerPosition() const
position of the outermost hit
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer1TrajToken
ProductID id() const
Accessor for product ID.
std::unique_ptr< std::vector< Trajectory > > outputTrajs
const math::XYZPoint & innerPosition() const
position of the innermost hit
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
std::string trackProducer2
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
virtual TrackingRecHit * clone() const =0
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
OmniClusterRef const & monoClusterRef() const
virtual LocalPoint localPosition() const =0
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::RefProd< std::vector< Trajectory > > refTrajs
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
reco::TrackRefProd refTrks
std::string trackProducer1
RefProd< PROD > getRefBeforePut()
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
PTrajectoryStateOnDet const & startingState() const
static TrackQuality qualityByName(const std::string &name)
ClusterRef cluster() const
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
T const * product() const
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
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
std::string const & moduleLabel() const
std::unique_ptr< reco::TrackExtraCollection > outputTrkExtras
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
unsigned int nHits() const
edm::ProductID id() const
std::unique_ptr< TrackingRecHitCollection > outputTrkHits
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
SimpleTrackListMerger(const edm::ParameterSet &conf)
edm::EDGetTokenT< reco::TrackCollection > trackProducer2Token
const TrackResiduals & residuals() const
get the residuals
virtual ~SimpleTrackListMerger()
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.
std::vector< reco::TrackRef > trackRefs
std::unique_ptr< TrajTrackAssociationCollection > outputTTAss
DetId geographicalId() const
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
std::string const & productInstanceName() const
std::string priorityName_
Provenance getProvenance(BranchID const &theID) const
reco::TrackExtraRefProd refTrkExtras
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection