40 produces<reco::ConversionTrackCollection>();
69 if (trackCollection1.
isValid()) {
70 TC1 = trackCollection1.
product();
74 edm::LogWarning(
"ConversionTrackMerger") <<
"1st TrackCollection not found;"
75 <<
" will only clean 2nd TrackCollection ";
82 if (trackCollection2.
isValid()) {
83 TC2 = trackCollection2.
product();
87 edm::LogWarning(
"ConversionTrackMerger") <<
"2nd TrackCollection not found;"
88 <<
" will only clean 1st TrackCollection ";
93 outputTrks = std::make_unique<reco::ConversionTrackCollection>();
96 std::vector<int> selected1;
97 for (
unsigned int i = 0;
i < tC1.size(); ++
i) {
98 selected1.push_back(1);
100 std::vector<int> selected2;
101 for (
unsigned int i = 0;
i < tC2.size(); ++
i) {
102 selected2.push_back(1);
105 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
106 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
107 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
115 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track) {
124 if ((!tC1.empty()) && (!tC2.empty())) {
126 for (reco::ConversionTrackCollection::iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
134 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
137 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
138 unsigned nh1 = iHits.size();
140 for (reco::ConversionTrackCollection::iterator track2 = tC2.begin(); track2 != tC2.end(); ++track2) {
146 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
149 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
152 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
153 unsigned nh2 = jHits.size();
155 int firstoverlap = 0;
156 for (
unsigned ih = 0; ih < nh1; ++ih) {
160 for (
unsigned jh = 0; jh < nh2; ++jh) {
173 int nhit1 =
track->track()->numberOfValidHits();
174 int nhit2 = track2->track()->numberOfValidHits();
177 if ((noverlap - firstoverlap) > (
std::min(nhit1, nhit2) - firstoverlap) *
shareFrac &&
178 (!
checkCharge ||
track->track()->charge() * track2->track()->charge() > 0)) {
186 bool keepFirst = (nhit1 > nhit2 ||
187 (nhit1 == nhit2 &&
track->track()->normalizedChi2() < track2->track()->normalizedChi2()));
191 keepFirst &= !(probFirst <= minProb && probSecond >
minProb);
193 bool keepSecond = !keepFirst;
199 track->setIsTrackerOnly(
track->isTrackerOnly() &&
202 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() &&
206 track->setIsArbitratedMerged(
track->isArbitratedMerged() &&
210 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
217 track2->setIsTrackerOnly(track2->isTrackerOnly() &&
220 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
224 track2->setIsArbitratedMerged(track2->isArbitratedMerged() &&
228 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
244 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track, ++
i) {
258 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track, ++
i) {