71 int trackerOnlyPreferCollection =
conf_.
getParameter<
int>(
"trackerOnlyPreferCollection");
72 int arbitratedEcalSeededPreferCollection =
conf_.
getParameter<
int>(
"arbitratedEcalSeededPreferCollection");
73 int arbitratedMergedPreferCollection =
conf_.
getParameter<
int>(
"arbitratedMergedPreferCollection");
74 int arbitratedMergedEcalGeneralPreferCollection =
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) {
129 rh1[
track].push_back(hit);
132 for (reco::ConversionTrackCollection::const_iterator
track = tC2.begin();
track != tC2.end(); ++
track) {
137 rh2[
track].push_back(hit);
141 if ((!tC1.empty()) && (!tC2.empty())) {
143 for (reco::ConversionTrackCollection::iterator
track = tC1.begin();
track != tC1.end(); ++
track) {
147 selected1[
i] = selected1[
i] && outputPreferCollection != 0;
148 track->setIsTrackerOnly(
track->isTrackerOnly() && trackerOnlyPreferCollection != 0);
149 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection != 0);
150 track->setIsArbitratedMerged(
track->isArbitratedMerged() && arbitratedMergedPreferCollection != 0);
151 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
152 arbitratedMergedEcalGeneralPreferCollection != 0);
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) {
161 selected2[
j] = selected2[
j] && outputPreferCollection != 0;
162 track2->setIsTrackerOnly(track2->isTrackerOnly() && trackerOnlyPreferCollection != 0);
163 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
164 arbitratedEcalSeededPreferCollection != 0);
165 track2->setIsArbitratedMerged(track2->isArbitratedMerged() && arbitratedMergedPreferCollection != 0);
166 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
167 arbitratedMergedEcalGeneralPreferCollection != 0);
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) {
183 if (allowFirstHitShare && (ih == 0) && (jh == 0))
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()));
207 keepFirst |= (probFirst > minProb && probSecond <= minProb);
208 keepFirst &= !(probFirst <= minProb && probSecond > minProb);
210 bool keepSecond = !keepFirst;
214 selected1[
i] = selected1[
i] && ((keepFirst && outputPreferCollection == 3) || outputPreferCollection == -1 ||
215 outputPreferCollection == 1);
216 track->setIsTrackerOnly(
track->isTrackerOnly() &&
217 ((keepFirst && trackerOnlyPreferCollection == 3) ||
218 trackerOnlyPreferCollection == -1 || trackerOnlyPreferCollection == 1));
219 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() &&
220 ((keepFirst && arbitratedEcalSeededPreferCollection == 3) ||
221 arbitratedEcalSeededPreferCollection == -1 ||
222 arbitratedEcalSeededPreferCollection == 1));
223 track->setIsArbitratedMerged(
track->isArbitratedMerged() &&
224 ((keepFirst && arbitratedMergedPreferCollection == 3) ||
225 arbitratedMergedPreferCollection == -1 ||
226 arbitratedMergedPreferCollection == 1));
227 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() &&
228 ((keepFirst && arbitratedMergedEcalGeneralPreferCollection == 3) ||
229 arbitratedMergedEcalGeneralPreferCollection == -1 ||
230 arbitratedMergedEcalGeneralPreferCollection == 1));
232 selected2[
j] = selected2[
j] && ((keepSecond && outputPreferCollection == 3) || outputPreferCollection == -1 ||
233 outputPreferCollection == 2);
234 track2->setIsTrackerOnly(track2->isTrackerOnly() &&
235 ((keepSecond && trackerOnlyPreferCollection == 3) ||
236 trackerOnlyPreferCollection == -1 || trackerOnlyPreferCollection == 2));
237 track2->setIsArbitratedEcalSeeded(track2->isArbitratedEcalSeeded() &&
238 ((keepSecond && arbitratedEcalSeededPreferCollection == 3) ||
239 arbitratedEcalSeededPreferCollection == -1 ||
240 arbitratedEcalSeededPreferCollection == 2));
241 track2->setIsArbitratedMerged(track2->isArbitratedMerged() &&
242 ((keepSecond && arbitratedMergedPreferCollection == 3) ||
243 arbitratedMergedPreferCollection == -1 ||
244 arbitratedMergedPreferCollection == 2));
245 track2->setIsArbitratedMergedEcalGeneral(track2->isArbitratedMergedEcalGeneral() &&
246 ((keepSecond && arbitratedMergedEcalGeneralPreferCollection == 3) ||
247 arbitratedMergedEcalGeneralPreferCollection == -1 ||
248 arbitratedMergedEcalGeneralPreferCollection == 2));
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) {
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
std::unique_ptr< reco::ConversionTrackCollection > outputTrks
float ChiSquaredProbability(double chiSquared, double nrDOF)
T const * product() const
T getParameter(std::string const &) const
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< reco::ConversionTrackCollection > trackProducer2