Split and merge the proto-jets, assigning each tower in the protojets to one and only one final jet. Called by run but public method to allow testing and studies.
320 int numProtojets = stableCones->size();
321 for(
int i = 0;
i < numProtojets ; ++
i){
322 const ProtoJet* icone = (*stableCones)[
i];
324 cout << endl <<
"[CMSMidpointAlgorithm] ProtoJet " <<
i <<
": PT=" << (*stableCones)[
i]->pt()
325 <<
", y="<< icone->
y()
326 <<
", phi="<< icone->
phi()
327 <<
", ntow="<< numTowers << endl;
329 for(
int j = 0;
j < numTowers; ++
j){
330 cout <<
"[CMSMidpointAlgorithm] Tower " <<
j <<
": ET=" << protojetTowers[
j]->et()
331 <<
", eta="<< protojetTowers[
j]->eta()
332 <<
", phi="<< protojetTowers[
j]->phi() << endl;
338 bool mergingNotFinished =
true;
339 while(mergingNotFinished){
343 sort(stableCones->begin(),stableCones->end(),compJets);
347 stableCones->erase (
find (stableCones->begin(), stableCones->end(), (
ProtoJet*)0), stableCones->end());
351 InternalCollection::iterator stableConeIter1 = stableCones->begin();
353 if(stableConeIter1 == stableCones->end()) {
354 mergingNotFinished =
false;
357 ProtoJet* stableCone1 = *stableConeIter1;
359 std::cerr <<
"CMSMidpointAlgorithm::splitAndMerge-> Error: stableCone1 should never be 0" << std::endl;
362 bool coneNotModified =
true;
365 InternalCollection::iterator stableConeIter2 = stableConeIter1;
368 while(coneNotModified && stableConeIter2 != stableCones->end()){
369 ProtoJet* stableCone2 = *stableConeIter2;
371 std::cerr <<
"CMSMidpointAlgorithm::splitAndMerge-> Error: stableCone2 should never be 0" << std::endl;
377 vector<InputItem> overlapTowers;
382 for(ProtoJet::Constituents::const_iterator towerIter1 = stableCone1->
getTowerList().begin();
387 bool isInCone2 =
false;
392 for(ProtoJet::Constituents::const_iterator towerIter2 = stableCone2->
getTowerList().begin();
400 if(sameTower(*towerIter1, *towerIter2)) {
407 overlapTowers.push_back(*towerIter1);
417 coneNotModified =
false;
427 for(ProtoJet::Constituents::const_iterator towerIter2 = stableCone2->
getTowerList().begin();
430 bool isInOverlap =
false;
433 for(vector<InputItem>::iterator overlapTowerIter = overlapTowers.begin();
434 overlapTowerIter != overlapTowers.end();
438 if(sameTower(*overlapTowerIter, *towerIter2)) isInOverlap =
true;
441 if(!isInOverlap)stableCone1Towers.push_back(*towerIter2);
444 if(
theDebugLevel>=2)
cout << endl <<
"[CMSMidpointAlgorithm] Merging: 1st Proto-jet grows: "
445 " y=" << stableCone1->
y() <<
446 ", phi=" << stableCone1->
phi() <<
447 " increases from " << stableCone1->
getTowerList().size() <<
448 " to " << stableCone1Towers.size() <<
" towers." << endl;
451 stableCone1->
putTowers(stableCone1Towers);
453 if(
theDebugLevel>=2)
cout <<
"[CMSMidpointAlgorithm] Merging: 1st protojet now at y=" << stableCone1->
y() <<
454 ", phi=" << stableCone1->
phi() << endl;
456 if(
theDebugLevel>=2)
cout <<
"[CMSMidpointAlgorithm] Merging: 2nd Proto-jet removed:"
457 " y=" << stableCone2->
y() <<
458 ", phi=" << stableCone2->
phi() << endl;
461 delete *stableConeIter2;
462 *stableConeIter2 = 0;
469 vector<InputItem> removeFromCone1,removeFromCone2;
473 for(vector<InputItem>::iterator towerIter = overlapTowers.begin();
474 towerIter != overlapTowers.end();
476 double dR2Jet1 =
deltaR2 ((*towerIter)->p4().Rapidity(), (*towerIter)->phi(),
477 stableCone1->
y(), stableCone1->
phi());
479 double dR2Jet2 =
deltaR2 ((*towerIter)->p4().Rapidity(), (*towerIter)->phi(),
480 stableCone2->
y(), stableCone2->
phi());
482 if(dR2Jet1 < dR2Jet2){
484 removeFromCone2.push_back(*towerIter);
488 removeFromCone1.push_back(*towerIter);
497 for(vector<InputItem>::iterator towerIter = removeFromCone1.begin();
498 towerIter != removeFromCone1.end();
501 for(vector<InputItem>::iterator towerIter1 = towerList1.begin(); towerIter1 != towerList1.end(); ++towerIter1) {
503 if(sameTower(*towerIter, *towerIter1)) {
505 towerList1.erase(towerIter1);
511 if(
theDebugLevel>=2)
cout << endl <<
"[CMSMidpointAlgorithm] Splitting: 1st Proto-jet shrinks: y=" <<
513 ", phi=" << stableCone1->
phi() <<
514 " decreases from" << stableCone1->
getTowerList().size() <<
515 " to " << towerList1.size() <<
" towers." << endl;
523 for(vector<InputItem>::iterator towerIter = removeFromCone2.begin();
524 towerIter != removeFromCone2.end();
527 for(vector<InputItem>::iterator towerIter2 = towerList2.begin(); towerIter2 != towerList2.end(); ++towerIter2){
529 if(sameTower(*towerIter, *towerIter2)) {
531 towerList2.erase(towerIter2);
537 if(
theDebugLevel>=2)
cout <<
"[CMSMidpointAlgorithm] Splitting: 2nd Proto-jet shrinks: y=" <<
539 ", phi=" << stableCone2->
phi() <<
540 " decreases from" << stableCone2->
getTowerList().size() <<
541 " to " << towerList2.size() <<
" towers." << endl;
549 "[CMSMidpointAlgorithm] no overlap between 1st protojet at y=" << stableCone1->
y() <<
550 ", phi=" << stableCone1->
phi() <<
551 " and 2nd protojet at y=" << stableCone2->
y() <<
552 ", phi=" << stableCone2->
phi() <<endl;
560 "[CMSMidpointAlgorithm] Saving: Proto-jet at y=" << stableCone1->
y() <<
561 ", phi=" << stableCone1->
phi() <<
" has no overlap" << endl;
564 delete *stableConeIter1;
565 *stableConeIter1 = 0;
571 sort(fFinalJets->begin(),fFinalJets->end(),compJets);
JetReco::InputCollection Constituents
const Constituents & getTowerList()
Transient Jet class used by the reconstruction algorithms.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
double deltaR2(const Vector1 &v1, const Vector2 &v2)
const LorentzVector & p4() const
double theOverlapThreshold
void putTowers(const Constituents &towers)