46 produces<reco::ConversionTrackCollection>();
79 if (trackCollection1.
isValid()) {
80 TC1 = trackCollection1.
product();
85 <<
"1st TrackCollection not found;" 86 <<
" will only clean 2nd TrackCollection ";
93 if (trackCollection2.
isValid()) {
94 TC2 = trackCollection2.
product();
99 <<
"2nd TrackCollection not found;" 100 <<
" will only clean 1st TrackCollection ";
105 outputTrks = std::make_unique<reco::ConversionTrackCollection>();
108 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
109 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
112 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
113 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
114 for (reco::ConversionTrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
119 rh1[
track].push_back(hit);
122 for (reco::ConversionTrackCollection::const_iterator
track=tC2.begin();
track!=tC2.end(); ++
track){
127 rh2[
track].push_back(hit);
131 if ( (0<tC1.size())&&(0<tC2.size()) ){
133 for (reco::ConversionTrackCollection::iterator
track=tC1.begin();
track!=tC1.end(); ++
track){
137 selected1[
i] = selected1[
i] && outputPreferCollection!=0;
138 track->setIsTrackerOnly (
track->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
139 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
140 track->setIsArbitratedMerged(
track->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
141 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
144 std::vector<const TrackingRecHit*>& iHits = rh1[
track];
145 unsigned nh1 = iHits.size();
147 for (reco::ConversionTrackCollection::iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
151 selected2[j] = selected2[j] && outputPreferCollection!=0;
152 track2->setIsTrackerOnly ( track2->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
153 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
154 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
155 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
157 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
158 unsigned nh2 = jHits.size();
161 for (
unsigned ih=0; ih<nh1; ++ih ) {
165 for (
unsigned jh=0; jh<nh2; ++jh ) {
171 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
177 int nhit1 =
track->track()->numberOfValidHits();
178 int nhit2 = track2->track()->numberOfValidHits();
181 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac && (!checkCharge ||
track->track()->charge()*track2->track()->charge()>0) ) {
189 bool keepFirst = ( nhit1>nhit2 || (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 || outputPreferCollection==1 );
200 track->setIsTrackerOnly (
track->isTrackerOnly() && ( (keepFirst && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==1 ) );
201 track->setIsArbitratedEcalSeeded(
track->isArbitratedEcalSeeded() && ( (keepFirst && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==1 ) );
202 track->setIsArbitratedMerged(
track->isArbitratedMerged() && ( (keepFirst && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==1 ) );
203 track->setIsArbitratedMergedEcalGeneral(
track->isArbitratedMergedEcalGeneral() && ( (keepFirst && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==1 ) );
205 selected2[j] = selected2[j] && ( (keepSecond && outputPreferCollection==3) || outputPreferCollection==-1 || outputPreferCollection==2 );
206 track2->setIsTrackerOnly ( track2->isTrackerOnly() && ( (keepSecond && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==2 ) );
207 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && ( (keepSecond && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==2 ) );
208 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && ( (keepSecond && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==2 ) );
209 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && ( (keepSecond && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==2 ) );
222 for (reco::ConversionTrackCollection::const_iterator
track=tC1.begin();
track!=tC1.end();
238 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)
ConversionTrackMerger(const edm::ParameterSet &conf)
T const * product() const
virtual void produce(edm::Event &e, const edm::EventSetup &c)
virtual ~ConversionTrackMerger()
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