106 pID=
reinterpret_cast<const SiPixelRecHit *
>(hit)->cluster().id();
108 const std::type_info &
type =
typeid(*hit);
119 }
else throw cms::Exception(
"Unknown RecHit Type") <<
"RecHit of type " << type.name() <<
" not supported. (use c++filt to demangle the name)";
131 edm::LogWarning(
"SimpleTrackListMerger") <<
"this class is obsolete, please use TrackListMerger";
135 produces<reco::TrackCollection>();
138 if (makeReKeyedSeeds_){
140 produces<TrajectorySeedCollection>();
144 produces<reco::TrackExtraCollection>();
145 produces<TrackingRecHitCollection>();
147 produces< std::vector<Trajectory> >();
148 produces< TrajTrackAssociationCollection >();
175 bool use_sharesInput =
true;
176 if ( epsilon > 0.0 )use_sharesInput =
false;
188 if (qualityStr !=
"") {
210 if (trackCollection1.
isValid()) {
211 TC1 = trackCollection1.
product();
222 if (trackCollection2.
isValid()) {
223 TC2 = trackCollection2.
product();
240 outputTrkHits->reserve((TC1->size()+TC2->size())*25);
249 outputTrajs = std::auto_ptr< std::vector<Trajectory> >(
new std::vector<Trajectory>());
269 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
273 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
275 if ((
short unsigned)track->ndof() < 1){
280 if (track->normalizedChi2() > maxNormalizedChisq){
285 if (track->found() < minFound){
290 if (track->pt() <
minPT){
299 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
303 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
305 if ((
short unsigned)track->ndof() < 1){
310 if (track->normalizedChi2() > maxNormalizedChisq){
315 if (track->found() < minFound){
320 if (track->pt() <
minPT){
328 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
329 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
330 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
335 rh1[track].push_back(hit);
338 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
343 rh2[track].push_back(hit);
347 if ( (0<tC1.size())&&(0<tC2.size()) ){
349 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
351 if (!selected1[i])
continue;
352 std::vector<const TrackingRecHit*>& iHits = rh1[track];
353 unsigned nh1 = iHits.size();
354 int qualityMaskT1 = track->qualityMask();
356 for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
358 if ((!selected2[j])||(!selected1[
i]))
continue;
359 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
360 unsigned nh2 = jHits.size();
363 for (
unsigned ih=0; ih<nh1; ++ih ) {
367 for (
unsigned jh=0; jh<nh2; ++jh ) {
371 if (!use_sharesInput){
375 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
380 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
387 int newQualityMask = (qualityMaskT1 | track2->qualityMask());
388 int nhit1 = track->numberOfValidHits();
389 int nhit2 = track2->numberOfValidHits();
390 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
391 double score1 = foundHitBonus*nhit1 - lostHitPenalty*track->numberOfLostHits() - track->chi2();
392 double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
393 const double almostSame = 1.001;
394 if ( score1 > almostSame * score2 ){
396 selected1[
i]=10+newQualityMask;
397 }
else if ( score2 > almostSame * score1 ){
399 selected2[
j]=10+newQualityMask;
403 selected1[
i]=10+newQualityMask;
406 selected2[
j]=10+newQualityMask;
418 std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
423 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
424 ++track, ++current, ++
i){
432 if (selected1[i]>1 && promoteQuality){
433 outputTrks->back().setQualityMask(selected1[i]-10);
441 bool doRekeyOnThisSeed=
false;
445 if (origSeedRef->
nHits()!=0){
448 if (firstHit->isValid()){
458 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
462 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
469 for (;iH!=iH_end;++iH){
471 refSetter.
reKey(&newRecHitContainer.
back());
493 seedsRefs[current]=origSeedRef;
498 std::vector<const TrackingRecHit*>& iHits = rh1[track];
499 unsigned nh1 = iHits.size();
501 for (
unsigned ih=0; ih<nh1; ++ih ) {
522 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
525 if (match != hTTAss1->end()) {
527 short oldKey =
static_cast<short>(trkRef.
key());
532 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
544 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
545 ++track, ++current, ++
i){
553 if (selected2[i]>1 && promoteQuality){
554 outputTrks->back().setQualityMask(selected2[i]-10);
562 bool doRekeyOnThisSeed=
false;
566 if (origSeedRef->
nHits()!=0){
569 if (firstHit->isValid()){
578 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
582 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
589 for (;iH!=iH_end;++iH){
591 refSetter.
reKey(&newRecHitContainer.
back());
612 seedsRefs[current]=origSeedRef;
617 std::vector<const TrackingRecHit*>& jHits = rh2[track];
618 unsigned nh2 = jHits.size();
620 for (
unsigned jh=0; jh<nh2; ++jh ) {
638 for (
size_t i = 0,
n = hTraj2->size(); i <
n; ++
i) {
641 if (match != hTTAss2->end()) {
643 short oldKey =
static_cast<short>(trkRef.
key()) + offset;
648 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
PropagationDirection direction() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< TrackingRecHitCollection > outputTrkHits
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
std::auto_ptr< TrajTrackAssociationCollection > outputTTAss
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
void reKey(TrackingRecHit *hit) const
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::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::auto_ptr< reco::TrackCollection > outputTrks
const math::XYZPoint & innerPosition() const
position of the innermost hit
edm::EDGetTokenT< std::vector< Trajectory > > trackProducer2TrajToken
std::string trackProducer2
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
std::auto_ptr< TrajectorySeedCollection > outputSeeds
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
recHitContainer::const_iterator const_iterator
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer1AssToken
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
std::auto_ptr< reco::TrackExtraCollection > outputTrkExtras
OmniClusterRef const & monoClusterRef() const
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
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()
virtual TrackingRecHit * clone() const =0
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
edm::RefToBase< TrajectorySeed > seedRef() const
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
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
std::string const & moduleLabel() const
std::auto_ptr< std::vector< Trajectory > > outputTrajs
edm::EDGetTokenT< reco::TrackCollection > trackProducer1Token
unsigned int nHits() const
edm::ProductID id() const
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
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
virtual ~SimpleTrackListMerger()
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< reco::TrackRef > trackRefs
DetId geographicalId() const
edm::EDGetTokenT< TrajTrackAssociationCollection > trackProducer2AssToken
std::string const & productInstanceName() const
Provenance getProvenance(BranchID const &theID) const
virtual LocalPoint localPosition() const =0
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