78 if (trackCollection1.
isValid()) {
79 TC1 = trackCollection1.
product();
84 <<
"1st TrackCollection not found;" 85 <<
" will only clean 2nd TrackCollection ";
92 if (trackCollection2.
isValid()) {
93 TC2 = trackCollection2.
product();
98 <<
"2nd TrackCollection not found;" 99 <<
" will only clean 1st TrackCollection ";
104 outputTrks = std::make_unique<reco::ConversionTrackCollection>();
107 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
108 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
111 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
112 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
113 for (reco::ConversionTrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
118 rh1[
track].push_back(hit);
121 for (reco::ConversionTrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end(); ++
track){
126 rh2[
track].push_back(hit);
130 if ( (!tC1.empty())&&(!tC2.empty()) ){
132 for (reco::ConversionTrackCollection::iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
136 selected1[
i] = selected1[
i] && outputPreferCollection!=0;
137 track->setIsTrackerOnly (
track->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
138 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
139 track->setIsArbitratedMerged(
track->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
140 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
143 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
144 unsigned nh1 = iHits.size();
146 for (reco::ConversionTrackCollection::iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
150 selected2[j] = selected2[j] && outputPreferCollection!=0;
151 track2->setIsTrackerOnly ( track2->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
152 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
153 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
154 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
156 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
157 unsigned nh2 = jHits.size();
160 for (
unsigned ih=0; ih<nh1; ++ih ) {
164 for (
unsigned jh=0; jh<nh2; ++jh ) {
170 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
176 int nhit1 =
track->track()->numberOfValidHits();
177 int nhit2 = track2->track()->numberOfValidHits();
180 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac && (!checkCharge ||
track->track()->charge()*track2->track()->charge()>0) ) {
188 bool keepFirst = ( nhit1>nhit2 || (nhit1==nhit2 &&
track->track()->normalizedChi2()<track2->track()->normalizedChi2()) );
191 keepFirst |= (probFirst>minProb && probSecond<=
minProb);
192 keepFirst &= !(probFirst<=minProb && probSecond>
minProb);
194 bool keepSecond = !keepFirst;
198 selected1[
i] = selected1[
i] && ( (keepFirst && outputPreferCollection==3) || outputPreferCollection==-1 || outputPreferCollection==1 );
199 track->setIsTrackerOnly (
track->isTrackerOnly() && ( (keepFirst && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==1 ) );
200 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && ( (keepFirst && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==1 ) );
201 track->setIsArbitratedMerged(
track->isArbitratedMerged() && ( (keepFirst && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==1 ) );
202 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() && ( (keepFirst && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==1 ) );
204 selected2[j] = selected2[j] && ( (keepSecond && outputPreferCollection==3) || outputPreferCollection==-1 || outputPreferCollection==2 );
205 track2->setIsTrackerOnly ( track2->isTrackerOnly() && ( (keepSecond && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==2 ) );
206 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && ( (keepSecond && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==2 ) );
207 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && ( (keepSecond && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==2 ) );
208 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && ( (keepSecond && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==2 ) );
221 for (reco::ConversionTrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end();
237 for (reco::ConversionTrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end();
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
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection