24 if(iPara.
exists(
"mergedMVAVals")){
30 if(iPara.
exists(
"originalMVAVals")){
39 if (iPara.
exists(
"newQuality")) {
41 if (qualityStr !=
"") {
46 produces<std::vector<reco::Track> >();
47 produces< std::vector<Trajectory> >();
48 produces< TrajTrackAssociationCollection >();
50 produces<edm::ValueMap<float> >(
"MVAVals");
53 if (makeReKeyedSeeds_){
55 produces<TrajectorySeedCollection>();
58 produces<reco::TrackExtraCollection>();
59 produces<TrackingRecHitCollection>();
95 std::auto_ptr<std::vector<reco::Track> > out_generalTracks(
new std::vector<reco::Track>());
96 out_generalTracks->reserve(originalHandle->size());
98 std::auto_ptr< std::vector<Trajectory> > outputTrajs = std::auto_ptr< std::vector<Trajectory> >(
new std::vector<Trajectory>());
99 outputTrajs->reserve(originalTrajHandle->size()+mergedTrajHandle->size());
101 std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(
new TrajTrackAssociationCollection());
104 std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
106 std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
108 std::auto_ptr<TrajectorySeedCollection> outputSeeds;
111 const int rSize = (int)originalHandle->size();
120 std::auto_ptr<edm::ValueMap<float> > vmMVA = std::auto_ptr<edm::ValueMap<float> >(
new edm::ValueMap<float>);
122 std::vector<float> mvaVec;
127 outputTrkExtras->reserve(originalHandle->size());
130 outputTrkHits->reserve(originalHandle->size()*25);
134 outputSeeds->
reserve(originalHandle->size());
140 std::vector<std::pair<int,const DuplicateRecord*> > matches;
141 for(
int i = 0;
i < (int)candidateHandle->size();
i++){
144 if(matchTrack < 0)
continue;
145 const reco::Track& matchedTrack(mergedTracks[matchTrack]);
147 unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.
recHitsSize();
149 matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
153 std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter0 = matches.begin();
154 std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter1;
155 while(matchIter0 != matches.end()){
156 double nchi2 = mergedTracks[matchIter0->first].normalizedChi2();
158 for(matchIter1 = matchIter0+1; matchIter1 != matches.end(); matchIter1++){
159 const reco::Track& match0first = *(matchIter0->second->second.first.get());
160 const reco::Track& match0second = *(matchIter0->second->second.second.get());
161 const reco::Track& match1first = *(matchIter1->second->second.first.get());
162 const reco::Track& match1second = *(matchIter1->second->second.second.get());
167 double nchi2_1 = mergedTracks[matchIter1->first].
normalizedChi2();
170 matches.erase(matchIter0);
172 matches.erase(matchIter1);
177 if(advance)matchIter0++;
181 std::vector<reco::Track> inputTracks;
185 for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
192 inputTracks.push_back(inTrk1);
193 inputTracks.push_back(inTrk2);
194 out_generalTracks->push_back(mergedTracks[matchIter0->first]);
196 float mergedMVA = (*mergedMVAStore)[
reco::TrackRef(mergedTrackRefs,matchIter0->first)];
197 mvaVec.push_back(mergedMVA);
198 out_generalTracks->back().setAlgorithm(newTrkAlgo);
199 out_generalTracks->back().setQualityMask(combinedQualityMask);
203 const reco::Track& track = mergedTracks[matchIter0->first];
207 bool doRekeyOnThisSeed=
false;
211 if (origSeedRef->
nHits()!=0){
214 if (firstHit->isValid()){
223 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
227 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
233 for (;iH!=iH_end;++iH){
235 refSetter.
reKey(&newRecHitContainer.
back());
256 seedsRefs[(*matchIter0).first]=origSeedRef;
257 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
262 for (
unsigned ih=0; ih<nh1; ++ih ) {
264 outputTrkHits->push_back( track.
recHit(ih)->clone() );
270 if (match != mergedTrajTrackHandle->end()) {
272 outputTrajs->push_back( *trajRef );
274 outputTrajs->back().setSeedRef( origSeedRef );
275 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
280 for(
int i = 0;
i < (int)originalHandle->size();
i++){
283 for(
int j = 0;
j < (int)inputTracks.size() && good;
j++){
293 out_generalTracks->push_back(origTrack);
297 mvaVec.push_back((*originalMVAStore)[origTrackRef]);
304 bool doRekeyOnThisSeed=
false;
308 if (origSeedRef->nHits()!=0){
311 if (firstHit->isValid()){
320 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
324 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
327 newRecHitContainer.
reserve(origSeedRef->nHits());
330 for (;iH!=iH_end;++iH){
332 refSetter.
reKey(&newRecHitContainer.
back());
334 outputSeeds->push_back(
TrajectorySeed( origSeedRef->startingState(),
336 origSeedRef->direction()));
354 seedsRefs[
i]=origSeedRef;
355 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
361 for (
unsigned ih=0; ih<nh1; ++ih ) {
363 outputTrkHits->push_back( track.
recHit(ih)->clone() );
371 if (match != originalTrajTrackHandle->end()) {
373 outputTrajs->push_back( *trajRef );
375 outputTrajs->back().setSeedRef( origSeedRef );
376 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
385 fillerMVA.insert(out_gtHandle,mvaVec.begin(),mvaVec.end());
388 iEvent.
put(vmMVA,
"MVAVals");
389 iEvent.
put(out_generalTracks);
391 iEvent.
put(outputTrkExtras);
392 iEvent.
put(outputTrkHits);
394 iEvent.
put(outputSeeds);
396 iEvent.
put(outputTrajs);
397 iEvent.
put(outputTTAss);
406 std::vector<int> rawIds;
407 RecHitContainer::const_iterator candBegin = candidate.
recHits().first;
408 RecHitContainer::const_iterator candEnd = candidate.
recHits().second;
409 for(; candBegin != candEnd; candBegin++){
410 rawIds.push_back((*(candBegin)).rawId());
414 for(
int i = 0;
i < (int)tracks->size() && track < 0;
i++){
415 if((tracks->at(
i)).seedRef() != candidate.
seedRef())
continue;
419 for(;trackRecBegin != trackRecEnd; trackRecBegin++){
420 if(
std::find(rawIds.begin(),rawIds.end(),(*(trackRecBegin)).get()->rawId()) != rawIds.end())match++;
422 if(match != (
int)tracks->at(
i).recHitsSize())
continue;
PropagationDirection direction() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const Vector & momentum() const
track momentum vector
edm::EDGetTokenT< edm::View< DuplicateRecord > > candidateSource_
friend struct const_iterator
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
edm::EDGetTokenT< edm::ValueMap< float > > originalMVAValsToken_
void reKey(TrackingRecHit *hit) const
std::vector< Track > TrackCollection
collection of Tracks
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool innerOk() const
return true if the innermost hit is valid
ThreeTokens threeTokens(const edm::InputTag &tag)
std::string const & processName() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const math::XYZPoint & outerPosition() const
position of the outermost hit
const Point & referencePoint() const
Reference point on the track.
TrackAlgorithm
track algorithm
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
bool isNonnull() const
Checks for non-null.
std::vector< TrajectorySeed > TrajectorySeedCollection
virtual ~DuplicateListMerger()
destructor
double chi2() const
chi-squared of the fit
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
int matchCandidateToTrack(TrackCandidate, edm::Handle< reco::TrackCollection >)
recHitContainer::const_iterator const_iterator
double ndof() const
number of degrees of freedom of the fit
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
edm::EDGetTokenT< std::vector< Trajectory > > traj
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
unsigned int diffHitsCut_
float ChiSquaredProbability(double chiSquared, double nrDOF)
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
void produce(edm::Event &, const edm::EventSetup &) override
produce one event
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
edm::ProductID clusterProductB(const TrackingRecHit *hit)
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)
edm::EDGetTokenT< edm::ValueMap< float > > mergedMVAValsToken_
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
edm::InputTag originalMVAVals_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
edm::EDGetTokenT< TrajTrackAssociationCollection > tass
std::string const & moduleLabel() const
edm::EDGetTokenT< reco::TrackCollection > tk
ThreeTokens originalTrackSource_
unsigned int nHits() const
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.
ProductID id() const
Accessor for product ID.
const TrackResiduals & residuals() const
ThreeTokens mergedTrackSource_
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
int charge() const
track electric charge
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::string const & productInstanceName() const
edm::InputTag mergedMVAVals_
T const * get() const
Returns C++ pointer to the item.
Provenance getProvenance(BranchID const &theID) const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
std::pair< TrackCandidate, std::pair< reco::TrackRef, reco::TrackRef > > DuplicateRecord
typedef container of candidate and input tracks
edm::RefToBase< TrajectorySeed > seedRef() const
reco::TrackBase::TrackQuality qualityToSet_