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) {
114 rh1[
track].push_back(hit);
117 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track) {
122 rh2[
track].push_back(hit);
126 if ((!tC1.empty()) && (!tC2.empty())) {
128 for (reco::ConversionTrackCollection::iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
132 selected1[
i] = selected1[
i] && outputPreferCollection != 0;
133 track->setIsTrackerOnly(
track->isTrackerOnly() && trackerOnlyPreferCollection != 0);
134 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection != 0);
135 track->setIsArbitratedMerged(
track->isArbitratedMerged() && arbitratedMergedPreferCollection != 0);
136 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
137 arbitratedMergedEcalGeneralPreferCollection != 0);
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) {
146 selected2[
j] = selected2[
j] && outputPreferCollection != 0;
147 track2->setIsTrackerOnly(track2->isTrackerOnly() && trackerOnlyPreferCollection != 0);
148 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
149 arbitratedEcalSeededPreferCollection != 0);
150 track2->setIsArbitratedMerged(track2->isArbitratedMerged() && arbitratedMergedPreferCollection != 0);
151 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
152 arbitratedMergedEcalGeneralPreferCollection != 0);
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) {
168 if (allowFirstHitShare && (ih == 0) && (jh == 0))
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()));
192 keepFirst |= (probFirst > minProb && probSecond <=
minProb);
193 keepFirst &= !(probFirst <= minProb && probSecond >
minProb);
195 bool keepSecond = !keepFirst;
199 selected1[
i] = selected1[
i] && ((keepFirst && outputPreferCollection == 3) || outputPreferCollection == -1 ||
200 outputPreferCollection == 1);
201 track->setIsTrackerOnly(
track->isTrackerOnly() &&
202 ((keepFirst && trackerOnlyPreferCollection == 3) ||
203 trackerOnlyPreferCollection == -1 || trackerOnlyPreferCollection == 1));
204 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() &&
205 ((keepFirst && arbitratedEcalSeededPreferCollection == 3) ||
206 arbitratedEcalSeededPreferCollection == -1 ||
207 arbitratedEcalSeededPreferCollection == 1));
208 track->setIsArbitratedMerged(
track->isArbitratedMerged() &&
209 ((keepFirst && arbitratedMergedPreferCollection == 3) ||
210 arbitratedMergedPreferCollection == -1 ||
211 arbitratedMergedPreferCollection == 1));
212 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
213 ((keepFirst && arbitratedMergedEcalGeneralPreferCollection == 3) ||
214 arbitratedMergedEcalGeneralPreferCollection == -1 ||
215 arbitratedMergedEcalGeneralPreferCollection == 1));
217 selected2[
j] = selected2[
j] && ((keepSecond && outputPreferCollection == 3) || outputPreferCollection == -1 ||
218 outputPreferCollection == 2);
219 track2->setIsTrackerOnly(track2->isTrackerOnly() &&
220 ((keepSecond && trackerOnlyPreferCollection == 3) ||
221 trackerOnlyPreferCollection == -1 || trackerOnlyPreferCollection == 2));
222 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
223 ((keepSecond && arbitratedEcalSeededPreferCollection == 3) ||
224 arbitratedEcalSeededPreferCollection == -1 ||
225 arbitratedEcalSeededPreferCollection == 2));
226 track2->setIsArbitratedMerged(track2->isArbitratedMerged() &&
227 ((keepSecond && arbitratedMergedPreferCollection == 3) ||
228 arbitratedMergedPreferCollection == -1 ||
229 arbitratedMergedPreferCollection == 2));
230 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
231 ((keepSecond && arbitratedMergedEcalGeneralPreferCollection == 3) ||
232 arbitratedMergedEcalGeneralPreferCollection == -1 ||
233 arbitratedMergedEcalGeneralPreferCollection == 2));
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) {
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
edm::EDGetTokenT< reco::ConversionTrackCollection > trackProducer1
std::vector< ConversionTrack > ConversionTrackCollection
collection of ConversionTracks
arbitratedMergedPreferCollection
std::unique_ptr< reco::ConversionTrackCollection > outputTrks
arbitratedEcalSeededPreferCollection
float ChiSquaredProbability(double chiSquared, double nrDOF)
T const * product() const
trackerOnlyPreferCollection
arbitratedMergedEcalGeneralPreferCollection
edm::EDGetTokenT< reco::ConversionTrackCollection > trackProducer2