29 std::cout <<
"FastTrackMerger created" << std::endl;
33 produces<reco::TrackCollection>();
39 std::vector<edm::InputTag> defaultRemove;
74 produces<reco::TrackExtraCollection>();
75 produces<TrackingRecHitCollection>();
76 produces<std::vector<Trajectory> >();
77 produces<TrajTrackAssociationCollection>();
79 produces<reco::TrackExtraCollection>();
80 produces<TrackingRecHitCollection>();
87 for (
unsigned aProducer=0; aProducer<trackProducers.size(); ++aProducer ) {
88 trackTokens.push_back(consumes<reco::TrackCollection>(trackProducers[aProducer]));
90 assoMapTokens.push_back(consumes<TrajTrackAssociationCollection>(trackProducers[aProducer]));
100 std::cout <<
"################################################################" << std::endl;
101 std::cout <<
" FastTrackMerger produce init " << std::endl;
121 std::auto_ptr<std::vector<Trajectory> > recoTrajectories(
new std::vector<Trajectory>);
127 std::vector<reco::TrackRef> trackRefs;
133 e.
put(recoTrackExtras);
135 e.
put(recoTrajectories);
136 e.
put(recoTrajTrackMap);
138 e.
put(recoTrackExtras);
155 std::set<unsigned> removeTracks;
158 if (!isTrackCollection)
continue;
159 reco::TrackCollection::const_iterator aTrack = theTrackCollection->begin();
160 reco::TrackCollection::const_iterator lastTrack = theTrackCollection->end();
161 for ( ; aTrack!=lastTrack; ++aTrack ) {
163 int recoTrackId =
findId(*aTrack);
164 if ( recoTrackId < 0 )
continue;
166 if ( removeTracks.find((
unsigned)recoTrackId) != removeTracks.end() )
continue;
167 removeTracks.insert((
unsigned)recoTrackId);
172 std::set<unsigned> alreadyAddedTracks;
175 for (
unsigned aProducer=0; aProducer<
trackProducers.size(); ++aProducer ) {
178 if ( ! isTrackCollection ) {
180 std::cout <<
"***FastTrackMerger*** Warning! The track collection "
182 <<
" does not exist." << std::endl;
188 std::cout <<
"***FastTrackMerger*** of track collection "
190 <<
" with " << theTrackCollection->size()
191 <<
" tracks to be copied"
194 reco::TrackCollection::const_iterator aTrack = theTrackCollection->begin();
195 reco::TrackCollection::const_iterator lastTrack = theTrackCollection->end();
204 for ( ; aTrack!=lastTrack; ++aTrack,++
index ) {
207 int recoTrackId =
findId(*aTrack);
208 if ( recoTrackId < 0 )
continue;
211 std::set<unsigned>::iterator iR = removeTracks.find((
unsigned)recoTrackId);
213 if( iR != removeTracks.end() )
std::cout << recoTrackId <<
"(REMOVED) ";
215 if( iR != removeTracks.end() )
continue;
218 std::set<unsigned>::iterator iA = alreadyAddedTracks.find((
unsigned)recoTrackId);
220 if( iA != alreadyAddedTracks.end() )
std::cout << recoTrackId <<
"(ALREADY ADDED) ";
222 if( iA != alreadyAddedTracks.end() )
continue;
224 alreadyAddedTracks.insert(recoTrackId);
233 if ( aTrack->innerMomentum().Perp2() <
pTMin2 )
234 std::cout <<
"PTMIN CUT APPLIED = " << aTrack->innerMomentum().Perp2() << std::endl;
237 if ( aTrack->innerMomentum().Perp2() <
pTMin2 )
continue;
240 if ( aTrack->recHitsSize() <
minHits )
continue;
244 recoTracks->push_back(aRecoTrack);
260 recoHits->push_back( (*hit)->clone() );
266 if (
trackAlgo ) recoTracks->back().setAlgorithm(algo);
278 unsigned nRecoHits = 0;
279 for ( ; aTrack!=lastTrack; ++aTrack ) nRecoHits+= aTrack->recHitsSize();
280 recoHits->reserve(nRecoHits);
288 anAssociation = theAssoMap->begin();
289 lastAssociation = theAssoMap->end();
291 std::cout <<
"List of tracks to be copied " << std::endl;
294 for ( ; anAssociation != lastAssociation; ++anAssociation ) {
298 int recoTrackId =
findId(*aTrackRef);
299 if ( recoTrackId < 0 )
continue;
302 std::set<unsigned>::iterator iR = removeTracks.find((
unsigned)recoTrackId);
304 if( iR != removeTracks.end() )
std::cout << recoTrackId <<
"(REMOVED) ";
306 if( iR != removeTracks.end() )
continue;
309 std::set<unsigned>::iterator iA = alreadyAddedTracks.find((
unsigned)recoTrackId);
311 if( iA != alreadyAddedTracks.end() )
std::cout << recoTrackId <<
"(ALREADY ADDED) ";
313 if( iA != alreadyAddedTracks.end() )
continue;
316 std::cout << recoTrackId <<
" Newly Added " << std::endl;
319 alreadyAddedTracks.insert(recoTrackId);
322 if ( aTrackRef->innerMomentum().Perp2() <
pTMin2 )
continue;
325 if ( aTrackRef->recHitsSize() <
minHits )
continue;
334 if((
unsigned)aTrajectoryRef->lostHits() >
theMaxLostHits )
continue;
343 unsigned consecLostHits = 0;
344 const std::vector<TrajectoryMeasurement> tms = aTrajectoryRef->measurements();
345 for(
int itm= tms.size();itm!=0; --itm){
346 if(tms[itm-1].recHit()->isValid())
break;
352 std::cout <<
"\tconsecLostHits = " << consecLostHits << std::endl;
363 recoTracks->push_back(aRecoTrack);
366 if (
trackAlgo ) recoTracks->back().setAlgorithm(algo);
371 for (
unsigned ih=0; ih<nh; ++ih ) {
373 recoHits->push_back(hit);
377 recoTrajectories->push_back(*aTrajectoryRef);
389 << recoTracks->size() <<
" reco::Tracks " << std::endl;
396 e.
put(recoTrackExtras);
406 unsigned nTracks = recoTracks->size();
407 recoTrackExtras->reserve(nTracks);
429 for (
unsigned int ih=0; ih<nHits; ++ih) {
432 recoTrackExtras->push_back(aTrackExtra);
441 (recoTracks->at(
index)).setExtra(theTrackExtraRef);
454 recoTrajTrackMap->insert(trajRef,tkRef);
458 e.
put(recoTrajTrackMap);
469 for ( ; aHit!=lastHit; ++aHit ) {
470 if ( !(*aHit)->isValid() )
continue;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned theMinimumNumberOfHits
std::vector< edm::EDGetTokenT< reco::TrackCollection > > removeTrackTokens
std::vector< edm::InputTag > removeTrackProducers
int findId(const reco::Track &aTrack) const
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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< edm::EDGetTokenT< std::vector< Trajectory > > > trajectoryTokens
std::vector< Track > TrackCollection
collection of Tracks
bool innerOk() const
return true if the innermost hit is valid
key_type key() const
Accessor for product key.
const math::XYZPoint & outerPosition() const
position of the outermost hit
TrackAlgorithm
track algorithm
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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.
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
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
std::vector< edm::InputTag > trackProducers
std::vector< edm::EDGetTokenT< TrajTrackAssociationCollection > > assoMapTokens
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.
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
static bool lost(const TrackingRecHit &hit)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.