46 produces<reco::ConversionTrackCollection>();
67 int trackerOnlyPreferCollection =
conf_.
getParameter<
int>(
"trackerOnlyPreferCollection");
68 int arbitratedEcalSeededPreferCollection =
conf_.
getParameter<
int>(
"arbitratedEcalSeededPreferCollection");
69 int arbitratedMergedPreferCollection =
conf_.
getParameter<
int>(
"arbitratedMergedPreferCollection");
70 int arbitratedMergedEcalGeneralPreferCollection =
conf_.
getParameter<
int>(
"arbitratedMergedEcalGeneralPreferCollection");
80 e.
getByLabel(trackProducer1, trackCollection1);
81 if (trackCollection1.
isValid()) {
82 TC1 = trackCollection1.
product();
86 edm::LogWarning(
"ConversionTrackMerger") <<
"1st TrackCollection " << trackProducer1 <<
" not found; will only clean 2nd TrackCollection " << trackProducer2 ;
92 e.
getByLabel(trackProducer2, trackCollection2);
93 if (trackCollection2.
isValid()) {
94 TC2 = trackCollection2.
product();
98 edm::LogWarning(
"ConversionTrackMerger") <<
"2nd TrackCollection " << trackProducer2 <<
" not found; will only clean 1st TrackCollection " << trackProducer1 ;
106 std::vector<int> selected1;
for (
unsigned int i=0; i<tC1.size(); ++
i){selected1.push_back(1);}
107 std::vector<int> selected2;
for (
unsigned int i=0; i<tC2.size(); ++
i){selected2.push_back(1);}
110 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh1;
111 std::map<reco::ConversionTrackCollection::const_iterator, std::vector<const TrackingRecHit*> > rh2;
112 for (reco::ConversionTrackCollection::const_iterator track=tC1.begin(); track!=tC1.end(); ++track){
117 rh1[track].push_back(hit);
120 for (reco::ConversionTrackCollection::const_iterator track=tC2.begin(); track!=tC2.end(); ++track){
125 rh2[track].push_back(hit);
129 if ( (0<tC1.size())&&(0<tC2.size()) ){
131 for (reco::ConversionTrackCollection::iterator track=tC1.begin(); track!=tC1.end(); ++track){
135 selected1[
i] = selected1[
i] && outputPreferCollection!=0;
136 track->setIsTrackerOnly ( track->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
137 track->setIsArbitratedEcalSeeded( track->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
138 track->setIsArbitratedMerged( track->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
139 track->setIsArbitratedMergedEcalGeneral( track->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
142 std::vector<const TrackingRecHit*>& iHits = rh1[track];
143 unsigned nh1 = iHits.size();
145 for (reco::ConversionTrackCollection::iterator track2=tC2.begin(); track2!=tC2.end(); ++track2){
149 selected2[
j] = selected2[
j] && outputPreferCollection!=0;
150 track2->setIsTrackerOnly ( track2->isTrackerOnly() && trackerOnlyPreferCollection!=0 );
151 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && arbitratedEcalSeededPreferCollection!=0 );
152 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && arbitratedMergedPreferCollection!=0 );
153 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && arbitratedMergedEcalGeneralPreferCollection!=0 );
155 std::vector<const TrackingRecHit*>& jHits = rh2[track2];
156 unsigned nh2 = jHits.size();
159 for (
unsigned ih=0; ih<nh1; ++ih ) {
163 for (
unsigned jh=0; jh<nh2; ++jh ) {
169 if ( allowFirstHitShare && ( ih == 0 ) && ( jh == 0 ) ) firstoverlap=1;
175 int nhit1 = track->track()->numberOfValidHits();
176 int nhit2 = track2->track()->numberOfValidHits();
179 if ( (noverlap-firstoverlap) > (
std::min(nhit1,nhit2)-firstoverlap)*shareFrac && (!checkCharge || track->track()->charge()*track2->track()->charge()>0) ) {
187 bool keepFirst = ( nhit1>nhit2 || (nhit1==nhit2 && track->track()->normalizedChi2()<track2->track()->normalizedChi2()) );
190 keepFirst |= (probFirst>minProb && probSecond<=minProb);
191 keepFirst &= !(probFirst<=minProb && probSecond>minProb);
193 bool keepSecond = !keepFirst;
197 selected1[
i] = selected1[
i] && ( (keepFirst && outputPreferCollection==3) || outputPreferCollection==-1 || outputPreferCollection==1 );
198 track->setIsTrackerOnly ( track->isTrackerOnly() && ( (keepFirst && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==1 ) );
199 track->setIsArbitratedEcalSeeded( track->isArbitratedEcalSeeded() && ( (keepFirst && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==1 ) );
200 track->setIsArbitratedMerged( track->isArbitratedMerged() && ( (keepFirst && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==1 ) );
201 track->setIsArbitratedMergedEcalGeneral( track->isArbitratedMergedEcalGeneral() && ( (keepFirst && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==1 ) );
203 selected2[
j] = selected2[
j] && ( (keepSecond && outputPreferCollection==3) || outputPreferCollection==-1 || outputPreferCollection==2 );
204 track2->setIsTrackerOnly ( track2->isTrackerOnly() && ( (keepSecond && trackerOnlyPreferCollection==3) || trackerOnlyPreferCollection==-1 || trackerOnlyPreferCollection==2 ) );
205 track2->setIsArbitratedEcalSeeded( track2->isArbitratedEcalSeeded() && ( (keepSecond && arbitratedEcalSeededPreferCollection==3) || arbitratedEcalSeededPreferCollection==-1 || arbitratedEcalSeededPreferCollection==2 ) );
206 track2->setIsArbitratedMerged( track2->isArbitratedMerged() && ( (keepSecond && arbitratedMergedPreferCollection==3) || arbitratedMergedPreferCollection==-1 || arbitratedMergedPreferCollection==2 ) );
207 track2->setIsArbitratedMergedEcalGeneral( track2->isArbitratedMergedEcalGeneral() && ( (keepSecond && arbitratedMergedEcalGeneralPreferCollection==3) || arbitratedMergedEcalGeneralPreferCollection==-1 || arbitratedMergedEcalGeneralPreferCollection==2 ) );
220 for (reco::ConversionTrackCollection::const_iterator track=tC1.begin(); track!=tC1.end();
236 for (reco::ConversionTrackCollection::const_iterator track=tC2.begin(); track!=tC2.end();
T getParameter(std::string const &) const
std::auto_ptr< reco::ConversionTrackCollection > outputTrks
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
std::vector< ConversionTrack > ConversionTrackCollection
collection of ConversionTracks
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
float ChiSquaredProbability(double chiSquared, double nrDOF)
ConversionTrackMerger(const edm::ParameterSet &conf)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
virtual void produce(edm::Event &e, const edm::EventSetup &c)
virtual ~ConversionTrackMerger()