42 produces<reco::ConversionTrackCollection>();
71 if (trackCollection1.
isValid()) {
72 TC1 = trackCollection1.
product();
76 edm::LogWarning(
"ConversionTrackMerger") <<
"1st TrackCollection not found;"
77 <<
" will only clean 2nd TrackCollection ";
84 if (trackCollection2.
isValid()) {
85 TC2 = trackCollection2.
product();
89 edm::LogWarning(
"ConversionTrackMerger") <<
"2nd TrackCollection not found;"
90 <<
" will only clean 1st TrackCollection ";
95 outputTrks = std::make_unique<reco::ConversionTrackCollection>();
98 std::vector<int> selected1;
99 for (
unsigned int i = 0;
i < tC1.size(); ++
i) {
100 selected1.push_back(1);
102 std::vector<int> selected2;
103 for (
unsigned int i = 0;
i < tC2.size(); ++
i) {
104 selected2.push_back(1);
107 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
108 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
109 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
117 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track) {
126 if ((!tC1.empty()) && (!tC2.empty())) {
128 for (reco::ConversionTrackCollection::iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
136 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
139 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
140 unsigned nh1 = iHits.size();
142 for (reco::ConversionTrackCollection::iterator track2 = tC2.begin(); track2 != tC2.end(); ++track2) {
148 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
151 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
154 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
155 unsigned nh2 = jHits.size();
157 int firstoverlap = 0;
158 for (
unsigned ih = 0; ih < nh1; ++ih) {
162 for (
unsigned jh = 0; jh < nh2; ++jh) {
175 int nhit1 =
track->track()->numberOfValidHits();
176 int nhit2 = track2->track()->numberOfValidHits();
179 if ((noverlap - firstoverlap) > (
std::min(nhit1, nhit2) - firstoverlap) *
shareFrac &&
180 (!
checkCharge ||
track->track()->charge() * track2->track()->charge() > 0)) {
188 bool keepFirst = (nhit1 > nhit2 ||
189 (nhit1 == nhit2 &&
track->track()->normalizedChi2() < track2->track()->normalizedChi2()));
193 keepFirst &= !(probFirst <= minProb && probSecond >
minProb);
195 bool keepSecond = !keepFirst;
201 track->setIsTrackerOnly(
track->isTrackerOnly() &&
204 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() &&
208 track->setIsArbitratedMerged(
track->isArbitratedMerged() &&
212 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
219 track2->setIsTrackerOnly(track2->isTrackerOnly() &&
222 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
226 track2->setIsArbitratedMerged(track2->isArbitratedMerged() &&
230 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
246 for (reco::ConversionTrackCollection::const_iterator
track = tC1.begin();
track != tC1.end(); ++
track, ++
i) {
260 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track, ++
i) {