52 pID=
reinterpret_cast<const SiPixelRecHit *
>(hit)->cluster().id();
54 const std::type_info &
type =
typeid(*hit);
65 }
else throw cms::Exception(
"Unknown RecHit Type") <<
"RecHit of type " << type.name() <<
" not supported. (use c++filt to demangle the name)";
77 produces<reco::TrackCollection>();
80 if (makeReKeyedSeeds_){
82 produces<TrajectorySeedCollection>();
86 produces<reco::TrackExtraCollection>();
87 produces<TrackingRecHitCollection>();
89 produces< std::vector<Trajectory> >();
90 produces< TrajTrackAssociationCollection >();
110 bool use_sharesInput =
true;
111 if ( epsilon > 0.0 )use_sharesInput =
false;
123 if (qualityStr !=
"") {
144 e.
getByLabel(trackProducer1, trackCollection1);
145 if (trackCollection1.
isValid()) {
146 TC1 = trackCollection1.
product();
150 edm::LogWarning(
"SimpleTrackListMerger") <<
"1st TrackCollection " << trackProducer1 <<
" not found; will only clean 2nd TrackCollection " << trackProducer2 ;
156 e.
getByLabel(trackProducer2, trackCollection2);
157 if (trackCollection2.
isValid()) {
158 TC2 = trackCollection2.
product();
162 edm::LogWarning(
"SimpleTrackListMerger") <<
"2nd TrackCollection " << trackProducer2 <<
" not found; will only clean 1st TrackCollection " << trackProducer1 ;
175 outputTrkHits->reserve((TC1->size()+TC2->size())*25);
184 outputTrajs = std::auto_ptr< std::vector<Trajectory> >(
new std::vector<Trajectory>());
204 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
208 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); track++){
210 if ((
short unsigned)track->ndof() < 1){
215 if (track->normalizedChi2() > maxNormalizedChisq){
220 if (track->found() < minFound){
225 if (track->pt() < minPT){
234 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
238 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); track++){
240 if ((
short unsigned)track->ndof() < 1){
245 if (track->normalizedChi2() > maxNormalizedChisq){
250 if (track->found() < minFound){
255 if (track->pt() < minPT){
263 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
264 std::map<reco::TrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
265 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
270 rh1[track].push_back(hit);
273 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
278 rh2[track].push_back(hit);
282 if ( (0<tC1.size())&&(0<tC2.size()) ){
284 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
286 if (!selected1[i])
continue;
287 std::vector<const TrackingRecHit*>& iHits = rh1[track];
288 unsigned nh1 = iHits.size();
289 int qualityMaskT1 = track->qualityMask();
291 for (reco::TrackCollection::const_iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
293 if ((!selected2[j])||(!selected1[
i]))
continue;
294 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
295 unsigned nh2 = jHits.size();
298 for (
unsigned ih=0; ih<nh1; ++ih ) {
302 for (
unsigned jh=0; jh<nh2; ++jh ) {
306 if (!use_sharesInput){
310 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
315 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
322 int newQualityMask = (qualityMaskT1 | track2->qualityMask());
323 int nhit1 = track->numberOfValidHits();
324 int nhit2 = track2->numberOfValidHits();
325 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac ) {
326 double score1 = foundHitBonus*nhit1 - lostHitPenalty*track->numberOfLostHits() - track->chi2();
327 double score2 = foundHitBonus*nhit2 - lostHitPenalty*track2->numberOfLostHits() - track2->chi2();
328 const double almostSame = 1.001;
329 if ( score1 > almostSame * score2 ){
331 selected1[
i]=10+newQualityMask;
332 }
else if ( score2 > almostSame * score1 ){
334 selected2[
j]=10+newQualityMask;
336 if (track->algo() <= track2->algo()) {
338 selected1[
i]=10+newQualityMask;
341 selected2[
j]=10+newQualityMask;
353 std::vector<edm::RefToBase<TrajectorySeed> > seedsRefs(tC1.size()+tC2.size());
358 for (reco::TrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
367 if (selected1[i]>1 && promoteQuality){
368 outputTrks->back().setQualityMask(selected1[i]-10);
376 bool doRekeyOnThisSeed=
false;
380 if (origSeedRef->
nHits()!=0){
383 if (firstHit->isValid()){
392 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
396 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
403 for (;iH!=iH_end;++iH){
405 refSetter.
reKey(&newRecHitContainer.
back());
427 seedsRefs[
current]=origSeedRef;
432 std::vector<const TrackingRecHit*>& iHits = rh1[track];
433 unsigned nh1 = iHits.size();
434 for (
unsigned ih=0; ih<nh1; ++ih ) {
455 for (
size_t i = 0,
n = hTraj1->size(); i <
n; ++
i) {
458 if (match != hTTAss1->end()) {
460 short oldKey =
static_cast<short>(trkRef.
key());
465 outputTrajs->back().setSeedRef( seedsRefs[oldKey] );
477 for (reco::TrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
486 if (selected2[i]>1 && promoteQuality){
487 outputTrks->back().setQualityMask(selected2[i]-10);
495 bool doRekeyOnThisSeed=
false;
499 if (origSeedRef->
nHits()!=0){
502 if (firstHit->isValid()){
511 doRekeyOnThisSeed=e.
getByLabel(clusterRemovalInfos,CRIh);
515 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
"")))
522 for (;iH!=iH_end;++iH){
524 refSetter.
reKey(&newRecHitContainer.
back());
545 seedsRefs[
current]=origSeedRef;
550 std::vector<const TrackingRecHit*>& jHits = rh2[track];
551 unsigned nh2 = jHits.size();
552 for (
unsigned jh=0; jh<nh2; ++jh ) {
570 for (
size_t i = 0,
n = hTraj2->size(); i <
n; ++
i) {
573 if (match != hTTAss2->end()) {
575 short oldKey =
static_cast<short>(trkRef.
key()) + offset;
580 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< 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
bool innerOk() const
return true if the innermost hit is valid
virtual void produce(edm::Event &e, const edm::EventSetup &c)
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)
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) ...
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::ProductID id() 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