86 if (trackCollection1.
isValid()) {
87 TC1 = trackCollection1.
product();
91 edm::LogWarning(
"ConversionTrackMerger") <<
"1st TrackCollection not found;"
92 <<
" will only clean 2nd TrackCollection ";
99 if (trackCollection2.
isValid()) {
100 TC2 = trackCollection2.
product();
104 edm::LogWarning(
"ConversionTrackMerger") <<
"2nd TrackCollection not found;"
105 <<
" will only clean 1st TrackCollection ";
110 outputTrks = std::make_unique<reco::ConversionTrackCollection>();
113 std::vector<int> selected1;
114 for (
unsigned int i = 0;
i < tC1.size(); ++
i) {
115 selected1.push_back(1);
117 std::vector<int> selected2;
118 for (
unsigned int i = 0;
i < tC2.size(); ++
i) {
119 selected2.push_back(1);
122 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
123 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
124 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
132 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track) {
141 if ((!tC1.empty()) && (!tC2.empty())) {
143 for (reco::ConversionTrackCollection::iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
151 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
154 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
155 unsigned nh1 = iHits.size();
157 for (reco::ConversionTrackCollection::iterator track2 = tC2.begin(); track2 != tC2.end(); ++track2) {
163 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
166 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
169 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
170 unsigned nh2 = jHits.size();
172 int firstoverlap = 0;
173 for (
unsigned ih = 0; ih < nh1; ++ih) {
177 for (
unsigned jh = 0; jh < nh2; ++jh) {
190 int nhit1 =
track->track()->numberOfValidHits();
191 int nhit2 = track2->track()->numberOfValidHits();
194 if ((noverlap - firstoverlap) > (
std::min(nhit1, nhit2) - firstoverlap) *
shareFrac &&
195 (!
checkCharge ||
track->track()->charge() * track2->track()->charge() > 0)) {
203 bool keepFirst = (nhit1 > nhit2 ||
204 (nhit1 == nhit2 &&
track->track()->normalizedChi2() < track2->track()->normalizedChi2()));
208 keepFirst &= !(probFirst <= minProb && probSecond >
minProb);
210 bool keepSecond = !keepFirst;
216 track->setIsTrackerOnly(
track->isTrackerOnly() &&
219 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() &&
223 track->setIsArbitratedMerged(
track->isArbitratedMerged() &&
227 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
234 track2->setIsTrackerOnly(track2->isTrackerOnly() &&
237 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
241 track2->setIsArbitratedMerged(track2->isArbitratedMerged() &&
245 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
261 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track, ++
i) {
275 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track, ++
i) {