49 pID=
reinterpret_cast<const SiPixelRecHit *
>(hit)->cluster().id();
51 const std::type_info &
type =
typeid(*hit);
52 if (type ==
typeid(SiStripRecHit2D)) {
53 pID=
reinterpret_cast<const SiStripRecHit2D *
>(hit)->cluster().
id();
54 }
else if (type ==
typeid(SiStripRecHit1D)) {
55 pID=
reinterpret_cast<const SiStripRecHit1D *
>(hit)->cluster().
id();
56 }
else if (type ==
typeid(SiStripMatchedRecHit2D)) {
57 const SiStripMatchedRecHit2D *mhit =
reinterpret_cast<const SiStripMatchedRecHit2D *
>(hit);
58 pID=mhit->monoClusterRef().
id();
62 }
else throw cms::Exception(
"Unknown RecHit Type") <<
"RecHit of type " << type.name() <<
" not supported. (use c++filt to demangle the name)";
74 produces<reco::TrackCollection>();
77 if (makeReKeyedSeeds_){
79 produces<TrajectorySeedCollection>();
83 produces<reco::TrackExtraCollection>();
84 produces<TrackingRecHitCollection>();
86 produces< std::vector<Trajectory> >();
87 produces< TrajTrackAssociationCollection >();
107 bool use_sharesInput =
true;
108 if ( epsilon > 0.0 )use_sharesInput =
false;
120 if (qualityStr !=
"") {
141 e.
getByLabel(trackProducer1, trackCollection1);
142 if (trackCollection1.
isValid()) {
143 TC1 = trackCollection1.
product();
147 edm::LogWarning(
"SimpleTrackListMerger") <<
"1st TrackCollection " << trackProducer1 <<
" not found; will only clean 2nd TrackCollection " << trackProducer2 ;
153 e.
getByLabel(trackProducer2, trackCollection2);
154 if (trackCollection2.
isValid()) {
155 TC2 = trackCollection2.
product();
159 edm::LogWarning(
"SimpleTrackListMerger") <<
"2nd TrackCollection " << trackProducer2 <<
" not found; will only clean 1st TrackCollection " << trackProducer1 ;
172 outputTrkHits->reserve((TC1->size()+TC2->size())*25);
181 outputTrajs = std::auto_ptr< std::vector<Trajectory> >(
new std::vector<Trajectory>());
201 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
205 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
207 if ((
short unsigned)track->ndof() < 1){
212 if (track->normalizedChi2() > maxNormalizedChisq){
217 if (track->found() < minFound){
222 if (track->pt() < minPT){
231 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
235 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
237 if ((
short unsigned)track->ndof() < 1){
242 if (track->normalizedChi2() > maxNormalizedChisq){
247 if (track->found() < minFound){
252 if (track->pt() < minPT){
260 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
261 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
262 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
267 rh1[track].push_back(hit);
270 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
275 rh2[track].push_back(hit);
279 if ( (0<tC1.size())&&(0<tC2.size()) ){
281 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
283 if (!selected1[i])
continue;
284 std::vector<const TrackingRecHit*>& iHits = rh1[track];
285 unsigned nh1 = iHits.size();
286 int qualityMaskT1 = track->qualityMask();
288 for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
290 if ((!selected2[j])||(!selected1[
i]))
continue;
291 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
292 unsigned nh2 = jHits.size();
295 for (
unsigned ih=0; ih<nh1; ++ih ) {
299 for (
unsigned jh=0; jh<nh2; ++jh ) {
303 if (!use_sharesInput){
307 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
312 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
319 int newQualityMask = (qualityMaskT1 | track2->qualityMask());
320 int nhit1 = track->numberOfValidHits();
321 int nhit2 = track2->numberOfValidHits();
322 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
323 double score1 = foundHitBonus*nhit1 - lostHitPenalty*track->numberOfLostHits() - track->chi2();
324 double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
325 const double almostSame = 1.001;
326 if ( score1 > almostSame * score2 ){
328 selected1[
i]=10+newQualityMask;
329 }
else if ( score2 > almostSame * score1 ){
331 selected2[
j]=10+newQualityMask;
333 if (track->algo() <= track2->algo()) {
335 selected1[
i]=10+newQualityMask;
338 selected2[
j]=10+newQualityMask;
350 std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
355 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
364 if (selected1[i]>1 && promoteQuality){
365 outputTrks->back().setQualityMask(selected1[i]-10);
373 bool doRekeyOnThisSeed=
false;
377 if (origSeedRef->
nHits()!=0){
380 if (firstHit->isValid()){
389 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
393 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
400 for (;iH!=iH_end;++iH){
402 refSetter.
reKey(&newRecHitContainer.
back());
424 seedsRefs[
current]=origSeedRef;
429 std::vector<const TrackingRecHit*>& iHits = rh1[track];
430 unsigned nh1 = iHits.size();
431 for (
unsigned ih=0; ih<nh1; ++ih ) {
452 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
455 if (match != hTTAss1->end()) {
457 short oldKey =
static_cast<short>(trkRef.
key());
462 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
474 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
483 if (selected2[i]>1 && promoteQuality){
484 outputTrks->back().setQualityMask(selected2[i]-10);
492 bool doRekeyOnThisSeed=
false;
496 if (origSeedRef->
nHits()!=0){
499 if (firstHit->isValid()){
508 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
512 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
519 for (;iH!=iH_end;++iH){
521 refSetter.
reKey(&newRecHitContainer.
back());
542 seedsRefs[
current]=origSeedRef;
547 std::vector<const TrackingRecHit*>& jHits = rh2[track];
548 unsigned nh2 = jHits.size();
549 for (
unsigned jh=0; jh<nh2; ++jh ) {
567 for (
size_t i = 0,
n = hTraj2->size(); i <
n; ++
i) {
570 if (match != hTTAss2->end()) {
572 short oldKey =
static_cast<short>(trkRef.
key()) + offset;
577 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
PropagationDirection direction() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
friend struct const_iterator
std::auto_ptr< reco::TrackExtraCollection > outputTrkExtras
TrackQuality
track quality
void reKey(TrackingRecHit *hit) const
SimpleTrackListMerger(const edm::ParameterSet &conf)
std::vector< Track > TrackCollection
collection of Tracks
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
bool innerOk() const
return true if the innermost hit is valid
std::vector< reco::TrackRef > trackRefs
TrackingRecHitRefProd refTrkHits
edm::ProductID clusterProduct(const TrackingRecHit *hit)
std::string const & processName() const
const math::XYZPoint & outerPosition() const
position of the outermost hit
const math::XYZPoint & innerPosition() const
position of the innermost hit
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
recHitContainer::const_iterator const_iterator
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
std::auto_ptr< TrajectorySeedCollection > outputSeeds
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
std::auto_ptr< reco::TrackCollection > outputTrks
unsigned int offset(bool)
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) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
std::auto_ptr< TrackingRecHitCollection > outputTrkHits
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
edm::RefProd< TrajectorySeedCollection > refTrajSeeds
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
key_type key() const
Accessor for product key.
std::string const & moduleLabel() const
T const * product() const
reco::TrackExtraRefProd refTrkExtras
reco::TrackRefProd refTrks
unsigned int nHits() const
edm::RefProd< std::vector< Trajectory > > refTrajs
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
const TrackResiduals & residuals() const
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
DetId geographicalId() const
std::string const & productInstanceName() const
Provenance getProvenance(BranchID const &theID) const
std::auto_ptr< std::vector< Trajectory > > outputTrajs
virtual LocalPoint localPosition() const =0
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
const SiStripRecHit2D & originalHit() const
virtual ~SimpleTrackListMerger()
std::auto_ptr< TrajTrackAssociationCollection > outputTTAss