32 std::cout <<
"FastTrackMerger created" << std::endl;
36 produces<reco::TrackCollection>();
42 std::vector<edm::InputTag> defaultRemove;
77 produces<reco::TrackExtraCollection>();
78 produces<TrackingRecHitCollection>();
79 produces<std::vector<Trajectory> >();
80 produces<TrajTrackAssociationCollection>();
82 produces<reco::TrackExtraCollection>();
83 produces<TrackingRecHitCollection>();
93 std::cout <<
"################################################################" << std::endl;
94 std::cout <<
" FastTrackMerger produce init " << std::endl;
114 std::auto_ptr<std::vector<Trajectory> > recoTrajectories(
new std::vector<Trajectory>);
120 std::vector<reco::TrackRef> trackRefs;
126 e.
put(recoTrackExtras);
128 e.
put(recoTrajectories);
129 e.
put(recoTrajTrackMap);
131 e.
put(recoTrackExtras);
148 std::set<unsigned> removeTracks;
151 if (!isTrackCollection)
continue;
152 reco::TrackCollection::const_iterator aTrack = theTrackCollection->begin();
153 reco::TrackCollection::const_iterator lastTrack = theTrackCollection->end();
154 for ( ; aTrack!=lastTrack; ++aTrack ) {
156 int recoTrackId =
findId(*aTrack);
157 if ( recoTrackId < 0 )
continue;
159 if ( removeTracks.find((
unsigned)recoTrackId) != removeTracks.end() )
continue;
160 removeTracks.insert((
unsigned)recoTrackId);
165 std::set<unsigned> alreadyAddedTracks;
168 for (
unsigned aProducer=0; aProducer<
trackProducers.size(); ++aProducer ) {
171 if ( ! isTrackCollection ) {
173 std::cout <<
"***FastTrackMerger*** Warning! The track collection "
175 <<
" does not exist." << std::endl;
181 std::cout <<
"***FastTrackMerger*** of track collection "
183 <<
" with " << theTrackCollection->size()
184 <<
" tracks to be copied"
187 reco::TrackCollection::const_iterator aTrack = theTrackCollection->begin();
188 reco::TrackCollection::const_iterator lastTrack = theTrackCollection->end();
197 for ( ; aTrack!=lastTrack; ++aTrack,++
index ) {
200 int recoTrackId =
findId(*aTrack);
201 if ( recoTrackId < 0 )
continue;
204 std::set<unsigned>::iterator iR = removeTracks.find((
unsigned)recoTrackId);
206 if( iR != removeTracks.end() )
std::cout << recoTrackId <<
"(REMOVED) ";
208 if( iR != removeTracks.end() )
continue;
211 std::set<unsigned>::iterator iA = alreadyAddedTracks.find((
unsigned)recoTrackId);
213 if( iA != alreadyAddedTracks.end() )
std::cout << recoTrackId <<
"(ALREADY ADDED) ";
215 if( iA != alreadyAddedTracks.end() )
continue;
217 alreadyAddedTracks.insert(recoTrackId);
226 if ( aTrack->innerMomentum().Perp2() <
pTMin2 )
227 std::cout <<
"PTMIN CUT APPLIED = " << aTrack->innerMomentum().Perp2() << std::endl;
230 if ( aTrack->innerMomentum().Perp2() <
pTMin2 )
continue;
233 if ( aTrack->recHitsSize() <
minHits )
continue;
237 recoTracks->push_back(aRecoTrack);
253 recoHits->push_back( (*hit)->clone() );
259 if (
trackAlgo ) recoTracks->back().setAlgorithm(algo);
271 unsigned nRecoHits = 0;
272 for ( ; aTrack!=lastTrack; ++aTrack ) nRecoHits+= aTrack->recHitsSize();
273 recoHits->reserve(nRecoHits);
281 anAssociation = theAssoMap->begin();
282 lastAssociation = theAssoMap->end();
284 std::cout <<
"List of tracks to be copied " << std::endl;
287 for ( ; anAssociation != lastAssociation; ++anAssociation ) {
291 int recoTrackId =
findId(*aTrackRef);
292 if ( recoTrackId < 0 )
continue;
295 std::set<unsigned>::iterator iR = removeTracks.find((
unsigned)recoTrackId);
297 if( iR != removeTracks.end() )
std::cout << recoTrackId <<
"(REMOVED) ";
299 if( iR != removeTracks.end() )
continue;
302 std::set<unsigned>::iterator iA = alreadyAddedTracks.find((
unsigned)recoTrackId);
304 if( iA != alreadyAddedTracks.end() )
std::cout << recoTrackId <<
"(ALREADY ADDED) ";
306 if( iA != alreadyAddedTracks.end() )
continue;
309 std::cout << recoTrackId <<
" Newly Added " << std::endl;
312 alreadyAddedTracks.insert(recoTrackId);
315 if ( aTrackRef->innerMomentum().Perp2() <
pTMin2 )
continue;
318 if ( aTrackRef->recHitsSize() <
minHits )
continue;
327 if((
unsigned)aTrajectoryRef->lostHits() >
theMaxLostHits )
continue;
336 unsigned consecLostHits = 0;
337 const std::vector<TrajectoryMeasurement> tms = aTrajectoryRef->measurements();
338 for(
int itm= tms.size();itm!=0; --itm){
339 if(tms[itm-1].recHit()->isValid())
break;
345 std::cout <<
"\tconsecLostHits = " << consecLostHits << std::endl;
356 recoTracks->push_back(aRecoTrack);
359 if (
trackAlgo ) recoTracks->back().setAlgorithm(algo);
364 for (
unsigned ih=0; ih<nh; ++ih ) {
366 recoHits->push_back(hit);
370 recoTrajectories->push_back(*aTrajectoryRef);
382 << recoTracks->size() <<
" reco::Tracks " << std::endl;
389 e.
put(recoTrackExtras);
399 unsigned nTracks = recoTracks->size();
400 recoTrackExtras->reserve(nTracks);
422 for (
unsigned int ih=0; ih<nHits; ++ih) {
425 recoTrackExtras->push_back(aTrackExtra);
434 (recoTracks->at(
index)).setExtra(theTrackExtraRef);
447 recoTrajTrackMap->insert(trajRef,tkRef);
451 e.
put(recoTrajTrackMap);
462 for ( ; aHit!=lastHit; ++aHit ) {
463 if ( !aHit->get()->isValid() )
continue;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned theMinimumNumberOfHits
static bool lost(const TransientTrackingRecHit &hit)
std::vector< edm::InputTag > removeTrackProducers
int findId(const reco::Track &aTrack) const
friend struct const_iterator
FastTrackMerger(const edm::ParameterSet &conf)
TrackQuality
track quality
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
std::vector< Track > TrackCollection
collection of Tracks
bool innerOk() const
return true if the innermost hit is valid
const math::XYZPoint & outerPosition() const
position of the outermost hit
TrackAlgorithm
track algorithm
const math::XYZPoint & innerPosition() const
position of the innermost hit
const int & simtrackId() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
unsigned theMaxConsecutiveLostHits
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
edm::RefToBase< TrajectorySeed > seedRef() const
static TrackQuality qualityByName(const std::string &name)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
virtual void produce(edm::Event &e, const edm::EventSetup &es)
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
key_type key() const
Accessor for product key.
std::vector< edm::InputTag > trackProducers
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
const TrackResiduals & residuals() const
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.