24 if(iPara.
exists(
"mergedMVAVals")){
29 if(iPara.
exists(
"originalMVAVals")){
37 if (iPara.
exists(
"newQuality")) {
39 if (qualityStr !=
"") {
44 produces<std::vector<reco::Track> >();
45 produces< std::vector<Trajectory> >();
46 produces< TrajTrackAssociationCollection >();
48 produces<edm::ValueMap<float> >(
"MVAVals");
51 if (makeReKeyedSeeds_){
53 produces<TrajectorySeedCollection>();
56 produces<reco::TrackExtraCollection>();
57 produces<TrackingRecHitCollection>();
93 std::auto_ptr<std::vector<reco::Track> > out_generalTracks(
new std::vector<reco::Track>());
94 out_generalTracks->reserve(originalHandle->size());
96 std::auto_ptr< std::vector<Trajectory> > outputTrajs = std::auto_ptr< std::vector<Trajectory> >(
new std::vector<Trajectory>());
97 outputTrajs->reserve(originalTrajHandle->size()+mergedTrajHandle->size());
99 std::auto_ptr< TrajTrackAssociationCollection > outputTTAss = std::auto_ptr< TrajTrackAssociationCollection >(
new TrajTrackAssociationCollection());
102 std::auto_ptr<reco::TrackExtraCollection> outputTrkExtras;
104 std::auto_ptr<TrackingRecHitCollection> outputTrkHits;
106 std::auto_ptr<TrajectorySeedCollection> outputSeeds;
109 const int rSize = (int)originalHandle->size();
118 std::auto_ptr<edm::ValueMap<float> > vmMVA = std::auto_ptr<edm::ValueMap<float> >(
new edm::ValueMap<float>);
120 std::vector<float> mvaVec;
125 outputTrkExtras->reserve(originalHandle->size());
128 outputTrkHits->reserve(originalHandle->size()*25);
132 outputSeeds->
reserve(originalHandle->size());
138 std::vector<std::pair<int,const DuplicateRecord*> > matches;
139 for(
int i = 0;
i < (int)candidateHandle->size();
i++){
142 if(matchTrack < 0)
continue;
143 const reco::Track& matchedTrack(mergedTracks[matchTrack]);
145 unsigned int dHits = (duplicateRecord.first.recHits().second - duplicateRecord.first.recHits().first) - matchedTrack.
recHitsSize();
147 matches.push_back(std::pair<int,const DuplicateRecord*>(matchTrack,&duplicateRecord));
151 std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter0 = matches.begin();
152 std::vector<std::pair<int,const DuplicateRecord*> >::iterator matchIter1;
153 while(matchIter0 != matches.end()){
154 double nchi2 = mergedTracks[matchIter0->first].normalizedChi2();
156 for(matchIter1 = matchIter0+1; matchIter1 != matches.end(); matchIter1++){
157 const reco::Track& match0first = *(matchIter0->second->second.first.get());
158 const reco::Track& match0second = *(matchIter0->second->second.second.get());
159 const reco::Track& match1first = *(matchIter1->second->second.first.get());
160 const reco::Track& match1second = *(matchIter1->second->second.second.get());
165 double nchi2_1 = mergedTracks[matchIter1->first].
normalizedChi2();
168 matches.erase(matchIter0);
170 matches.erase(matchIter1);
175 if(advance)matchIter0++;
179 std::vector<reco::Track> inputTracks;
183 for(matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
190 inputTracks.push_back(inTrk1);
191 inputTracks.push_back(inTrk2);
192 out_generalTracks->push_back(mergedTracks[matchIter0->first]);
194 float mergedMVA = (*mergedMVAStore)[
reco::TrackRef(mergedTrackRefs,matchIter0->first)];
195 mvaVec.push_back(mergedMVA);
196 out_generalTracks->back().setAlgorithm(newTrkAlgo);
197 out_generalTracks->back().setQualityMask(combinedQualityMask);
201 const reco::Track& track = mergedTracks[matchIter0->first];
205 bool doRekeyOnThisSeed=
false;
209 if (origSeedRef->
nHits()!=0){
212 if (firstHit->isValid()){
221 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
225 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
231 for (;iH!=iH_end;++iH){
233 refSetter.
reKey(&newRecHitContainer.
back());
254 seedsRefs[(*matchIter0).first]=origSeedRef;
255 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
260 for (
unsigned ih=0; ih<nh1; ++ih ) {
262 outputTrkHits->push_back( track.
recHit(ih)->clone() );
268 if (match != mergedTrajTrackHandle->end()) {
270 outputTrajs->push_back( *trajRef );
272 outputTrajs->back().setSeedRef( origSeedRef );
273 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
278 for(
int i = 0;
i < (int)originalHandle->size();
i++){
281 for(
int j = 0;
j < (int)inputTracks.size() && good;
j++){
291 out_generalTracks->push_back(origTrack);
295 mvaVec.push_back((*originalMVAStore)[origTrackRef]);
302 bool doRekeyOnThisSeed=
false;
306 if (origSeedRef->nHits()!=0){
309 if (firstHit->isValid()){
318 doRekeyOnThisSeed=iEvent.
getByLabel(clusterRemovalInfos,CRIh);
322 if (doRekeyOnThisSeed && !(clusterRemovalInfos==
edm::InputTag(
""))) {
325 newRecHitContainer.
reserve(origSeedRef->nHits());
328 for (;iH!=iH_end;++iH){
330 refSetter.
reKey(&newRecHitContainer.
back());
332 outputSeeds->push_back(
TrajectorySeed( origSeedRef->startingState(),
334 origSeedRef->direction()));
352 seedsRefs[
i]=origSeedRef;
353 out_generalTracks->back().setExtra(
reco::TrackExtraRef( refTrkExtras, outputTrkExtras->size() - 1) );
359 for (
unsigned ih=0; ih<nh1; ++ih ) {
361 outputTrkHits->push_back( track.
recHit(ih)->clone() );
369 if (match != originalTrajTrackHandle->end()) {
371 outputTrajs->push_back( *trajRef );
373 outputTrajs->back().setSeedRef( origSeedRef );
374 outputTTAss->insert(
edm::Ref< std::vector<Trajectory> >(refTrajs, outputTrajs->size() - 1),curTrackRef );
383 fillerMVA.insert(out_gtHandle,mvaVec.begin(),mvaVec.end());
386 iEvent.
put(vmMVA,
"MVAVals");
387 iEvent.
put(out_generalTracks);
389 iEvent.
put(outputTrkExtras);
390 iEvent.
put(outputTrkHits);
392 iEvent.
put(outputSeeds);
394 iEvent.
put(outputTrajs);
395 iEvent.
put(outputTTAss);
404 std::vector<int> rawIds;
405 RecHitContainer::const_iterator candBegin = candidate.
recHits().first;
406 RecHitContainer::const_iterator candEnd = candidate.
recHits().second;
407 for(; candBegin != candEnd; candBegin++){
408 rawIds.push_back((*(candBegin)).rawId());
412 for(
int i = 0;
i < (int)tracks->size() && track < 0;
i++){
413 if((tracks->at(
i)).seedRef() != candidate.
seedRef())
continue;
417 for(;trackRecBegin != trackRecEnd; trackRecBegin++){
418 if(
std::find(rawIds.begin(),rawIds.end(),(*(trackRecBegin)).get()->rawId()) != rawIds.end())match++;
420 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::InputTag candidateSource_
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
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
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
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
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::InputTag mergedTrackSource_
track input collection
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)
edm::InputTag originalTrackSource_
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)
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
std::string const & moduleLabel() const
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
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_