5 #include "Math/GenVector/VectorUtil.h"
24 pfClusters_( new vector<
reco::PFCluster> ),
25 pfRecHitsCleaned_( new vector<
reco::PFRecHit> ),
28 threshSeedBarrel_(0.2),
29 threshPtSeedBarrel_(0.),
32 threshSeedEndcap_(0.6),
33 threshPtSeedEndcap_(0.),
34 threshCleanBarrel_(1E5),
36 threshDoubleSpikeBarrel_(1E9),
37 minS6S2DoubleSpikeBarrel_(-1.),
38 threshCleanEndcap_(1E5),
40 threshDoubleSpikeEndcap_(1E9),
41 minS6S2DoubleSpikeEndcap_(-1.),
47 useCornerCells_(
false),
48 cleanRBXandHPDs_(
false),
61 cout <<
"Benchmark output written to file " <<
file_->GetName() << endl;
87 const std::vector<bool> & mask ) {
101 if (mask.size() == rechits.size()) {
102 mask_.insert(
mask_.end(), mask.begin(), mask.end() );
104 edm::LogError(
"PClusterAlgo::doClustering") <<
"map size should be " << rechits.size() <<
". Will be reinitialized.";
144 if (mask.size() == rechits.size()) {
145 mask_.insert(
mask_.end(), mask.begin(), mask.end() );
147 edm::LogError(
"PClusterAlgo::doClustering") <<
"map size should be " << rechits.size() <<
". Will be reinitialized.";
162 pfClusters_.reset(
new std::vector<reco::PFCluster> );
173 for (
unsigned i = 0;
i < rechits.size();
i++ ){
179 color_.resize( rechits.size(), 0 );
218 unsigned iCoeff,
int iring )
const {
255 cerr<<
"PFClusterAlgo::parameter : unknown parameter type "
293 cerr<<
"PFClusterAlgo::parameter : unknown parameter type "
299 cerr<<
"PFClusterAlgo::parameter : unknown layer "<<layer<<endl;
311 std::map< int, std::vector<unsigned> > hpds;
312 std::map< int, std::vector<unsigned> > rbxs;
316 unsigned rhi = ih->second;
318 if(!
masked(rhi) )
continue;
322 int layer = rhit.
layer();
327 int ieta = theHcalDetId.
ieta();
328 int iphi = theHcalDetId.
iphi();
329 int ihpd = ieta < 0 ?
332 hpds[ihpd].push_back(rhi);
333 int irbx = ieta < 0 ?
336 if ( irbx == 19 ) irbx = 1;
337 else if ( irbx == -19 ) irbx = -1;
338 else if ( irbx == 39 ) irbx = 21;
339 else if ( irbx == -39 ) irbx = -21;
340 rbxs[irbx].push_back(rhi);
344 for (
std::map<
int, std::vector<unsigned> >::iterator itrbx = rbxs.begin();
345 itrbx != rbxs.end(); ++itrbx ) {
346 if ( (
abs(itrbx->first)<20 && itrbx->second.size() > 30 ) ||
347 (
abs(itrbx->first)>20 && itrbx->second.size() > 30 ) ) {
348 const std::vector<unsigned>& rhits = itrbx->second;
349 double totalEta = 0.;
350 double totalEtaW = 0.;
351 double totalPhi = 0.;
352 double totalPhiW = 0.;
353 double totalEta2 = 1E-9;
354 double totalEta2W = 1E-9;
355 double totalPhi2 = 1E-9;
356 double totalPhi2W = 1E-9;
357 double totalEnergy = 0.;
358 double totalEnergy2 = 1E-9;
359 unsigned nSeeds = rhits.size();
360 unsigned nSeeds0 = rhits.size();
361 std::map< int,std::vector<unsigned> > theHPDs;
362 std::multimap< double,unsigned > theEnergies;
363 for (
unsigned jh=0; jh < rhits.size(); ++jh ) {
368 const vector<unsigned>& neighbours4 = *(& hit.
neighbours4());
369 for(
unsigned in=0;
in<neighbours4.size();
in++) {
378 if ( neighbour.
energy() > 0.4 ) ++nN;
381 if ( isASeed && !nN ) --nSeeds0;
385 int iphi = theHcalDetId.
iphi();
388 theHPDs[iphi].push_back(rhits[jh]);
390 theHPDs[(iphi-1)/2].push_back(rhits[jh]);
391 theEnergies.insert(std::pair<double,unsigned>(hit.
energy(),rhits[jh]));
392 totalEnergy += hit.
energy();
393 totalPhi += fabs(hit.
position().phi());
404 totalPhi /= rhits.size();
405 totalEta /= rhits.size();
406 totalPhiW /= totalEnergy;
407 totalEtaW /= totalEnergy;
408 totalPhi2 /= rhits.size();
409 totalEta2 /= rhits.size();
410 totalPhi2W /= totalEnergy;
411 totalEta2W /= totalEnergy;
412 totalPhi2 =
std::sqrt(totalPhi2 - totalPhi*totalPhi);
413 totalEta2 =
std::sqrt(totalEta2 - totalEta*totalEta);
414 totalPhi2W =
std::sqrt(totalPhi2W - totalPhiW*totalPhiW);
415 totalEta2W =
std::sqrt(totalEta2W - totalEtaW*totalEtaW);
416 totalEnergy /= rhits.size();
417 totalEnergy2 /= rhits.size();
418 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
422 for (
std::map<
int, std::vector<unsigned> >::iterator itHPD = theHPDs.begin();
423 itHPD != theHPDs.end(); ++itHPD ) {
424 int hpdN = itHPD->first;
425 const std::vector<unsigned>& hpdHits = itHPD->second;
426 if ( (
abs(hpdN) < 100 && hpdHits.size() > 14 ) ||
427 (
abs(hpdN) > 100 && hpdHits.size() > 14 ) ) ++nHPD15;
445 std::multimap<double, unsigned >::iterator ntEn = theEnergies.end();
449 for ( std::multimap<double, unsigned >::iterator itEn = theEnergies.begin();
450 itEn != theEnergies.end(); ++itEn ) {
453 mask_[itEn->second] =
false;
454 }
else if ( nn == 5 ) {
455 threshold = itEn->first * 5.;
456 mask_[itEn->second] =
false;
458 if ( itEn->first < threshold )
mask_[itEn->second] =
false;
460 if ( !
masked(itEn->second) ) {
480 std::map<int, std::vector<unsigned> >::iterator neighbour1;
481 std::map<int, std::vector<unsigned> >::iterator neighbour2;
482 std::map<int, std::vector<unsigned> >::iterator neighbour0;
483 std::map<int, std::vector<unsigned> >::iterator neighbour3;
486 for (
std::map<
int, std::vector<unsigned> >::iterator ithpd = hpds.begin();
487 ithpd != hpds.end(); ++ithpd ) {
489 const std::vector<unsigned>& rhits = ithpd->second;
490 std::multimap< double,unsigned > theEnergies;
491 double totalEnergy = 0.;
492 double totalEnergy2 = 1E-9;
493 for (
unsigned jh=0; jh < rhits.size(); ++jh ) {
495 totalEnergy += hit.
energy();
497 theEnergies.insert(std::pair<double,unsigned>(hit.
energy(),rhits[jh]));
499 totalEnergy /= rhits.size();
500 totalEnergy2 /= rhits.size();
501 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
503 if ( ithpd->first == 1 ) neighbour1 = hpds.find(72);
504 else if ( ithpd->first == -1 ) neighbour1 = hpds.find(-72);
505 else if ( ithpd->first == 101 ) neighbour1 = hpds.find(136);
506 else if ( ithpd->first == -101 ) neighbour1 = hpds.find(-136);
507 else neighbour1 = ithpd->first > 0 ? hpds.find(ithpd->first-1) : hpds.find(ithpd->first+1) ;
509 if ( ithpd->first == 72 ) neighbour2 = hpds.find(1);
510 else if ( ithpd->first == -72 ) neighbour2 = hpds.find(-1);
511 else if ( ithpd->first == 136 ) neighbour2 = hpds.find(101);
512 else if ( ithpd->first == -136 ) neighbour2 = hpds.find(-101);
513 else neighbour2 = ithpd->first > 0 ? hpds.find(ithpd->first+1) : hpds.find(ithpd->first-1) ;
515 if ( neighbour1 != hpds.end() ) {
516 if ( neighbour1->first == 1 ) neighbour0 = hpds.find(72);
517 else if ( neighbour1->first == -1 ) neighbour0 = hpds.find(-72);
518 else if ( neighbour1->first == 101 ) neighbour0 = hpds.find(136);
519 else if ( neighbour1->first == -101 ) neighbour0 = hpds.find(-136);
520 else neighbour0 = neighbour1->first > 0 ? hpds.find(neighbour1->first-1) : hpds.find(neighbour1->first+1) ;
523 if ( neighbour2 != hpds.end() ) {
524 if ( neighbour2->first == 72 ) neighbour3 = hpds.find(1);
525 else if ( neighbour2->first == -72 ) neighbour3 = hpds.find(-1);
526 else if ( neighbour2->first == 136 ) neighbour3 = hpds.find(101);
527 else if ( neighbour2->first == -136 ) neighbour3 = hpds.find(-101);
528 else neighbour3 = neighbour2->first > 0 ? hpds.find(neighbour2->first+1) : hpds.find(neighbour2->first-1) ;
531 size1 = neighbour1 != hpds.end() ? neighbour1->second.size() : 0;
532 size2 = neighbour2 != hpds.end() ? neighbour2->second.size() : 0;
536 if ( (
abs(neighbour1->first) > 100 && neighbour1->second.size() > 15 ) ||
537 (
abs(neighbour1->first) < 100 && neighbour1->second.size() > 12 ) )
538 size1 = neighbour0 != hpds.end() ? neighbour0->second.size() : 0;
541 if ( (
abs(neighbour2->first) > 100 && neighbour2->second.size() > 15 ) ||
542 (
abs(neighbour2->first) < 100 && neighbour2->second.size() > 12 ) )
543 size2 = neighbour3 != hpds.end() ? neighbour3->second.size() : 0;
546 if ( (
abs(ithpd->first) > 100 && ithpd->second.size() > 15 ) ||
547 (
abs(ithpd->first) < 100 && ithpd->second.size() > 12 ) )
548 if ( (
float)(size1 + size2)/(
float)ithpd->second.size() < 1.0 ) {
555 std::multimap<double, unsigned >::iterator ntEn = theEnergies.end();
559 for ( std::multimap<double, unsigned >::iterator itEn = theEnergies.begin();
560 itEn != theEnergies.end(); ++itEn ) {
563 mask_[itEn->second] =
false;
564 }
else if ( nn == 5 ) {
565 threshold = itEn->first * 2.5;
566 mask_[itEn->second] =
false;
568 if ( itEn->first < threshold )
mask_[itEn->second] =
false;
570 if ( !
masked(itEn->second) ) {
597 cout<<
"PFClusterAlgo::findSeeds : start"<<endl;
602 const vector<unsigned> noNeighbours(0, static_cast<unsigned>(0));
608 unsigned rhi = ih->second;
610 if(!
masked(rhi) )
continue;
613 double rhenergy = ih->first;
620 int layer = wannaBeSeed.
layer();
627 static_cast<PFLayer::Layer>(layer), 0, iring );
630 static_cast<PFLayer::Layer>(layer), 0., iring );
633 static_cast<PFLayer::Layer>(layer), 0, iring );
636 static_cast<PFLayer::Layer>(layer), 0, iring );
639 static_cast<PFLayer::Layer>(layer), 1, iring );
642 static_cast<PFLayer::Layer>(layer), 0, iring );
645 static_cast<PFLayer::Layer>(layer), 0, iring );
649 cout<<
"layer:"<<layer<<
" seedThresh:"<<seedThresh<<endl;
653 if( rhenergy < seedThresh || (seedPtThresh>0. && wannaBeSeed.
pt2() < seedPtThresh*seedPtThresh )) {
659 const vector<unsigned>* nbp;
660 double tighterE = 1.0;
661 double tighterF = 1.0;
680 nbp = & noNeighbours;
685 cerr<<
"you're not allowed to set n neighbours to "
696 cerr<<
"CellsEF::PhotonSeeds : unknown layer "<<layer<<endl;
700 const vector<unsigned>& neighbours = *nbp;
706 for(
unsigned in=0;
in<neighbours.size();
in++) {
708 unsigned rhj = neighbours[
in];
710 if ( !
masked(rhj) )
continue;
721 if (
file_ || wannaBeSeed.
energy() > cleanThresh ) {
723 const vector<unsigned>& neighbours4 = *(& wannaBeSeed.
neighbours4());
725 double surroundingEnergy = wannaBeSeed.
energyUp();
726 double neighbourEnergy = 0.;
727 double layerEnergy = 0.;
728 for(
unsigned in4=0; in4<neighbours4.size(); in4++) {
729 unsigned rhj = neighbours4[in4];
731 if ( !
masked(rhj) )
continue;
735 layerEnergy += neighbour.
energy();
741 double fraction1 = surroundingEnergy/wannaBeSeed.
energy();
760 }
else if ( fabs(wannaBeSeed.
position().eta()) < 5.0 ) {
762 if ( wannaBeSeed.
energy() > 1000 ) {
763 if ( fabs(wannaBeSeed.
position().eta()) < 2.8 )
772 if ( wannaBeSeed.
energy() > cleanThresh ) {
773 double f1Cut = minS4S1_a * log10(wannaBeSeed.
energy()) + minS4S1_b;
774 if ( fraction1 < f1Cut ) {
778 std::pair<double,double> dcr =
dCrack(phi,eta);
782 ( ( eta < 2.85 && dcrmin > 1. ) ||
783 ( rhenergy > tighterE*cleanThresh &&
784 fraction1 < f1Cut/tighterF ) )
807 if (
mask_[rhi] && wannaBeSeed.
energy() > doubleSpikeThresh ) {
809 double surroundingEnergyi = 0.;
810 double enmax = -999.;
811 unsigned mostEnergeticNeighbour = 0;
812 const vector<unsigned>& neighbours4i = *(& wannaBeSeed.
neighbours4());
813 for(
unsigned in4=0; in4<neighbours4i.size(); in4++) {
814 unsigned rhj = neighbours4i[in4];
815 if ( !
masked(rhj) )
continue;
817 surroundingEnergyi += neighbouri.
energy();
818 if ( neighbouri.
energy() > enmax ) {
819 enmax = neighbouri.
energy();
820 mostEnergeticNeighbour = rhj;
825 unsigned rhj = mostEnergeticNeighbour;
827 double surroundingEnergyj = 0.;
830 const vector<unsigned>& neighbours4j = *(& neighbouri.
neighbours4());
831 for(
unsigned jn4=0; jn4<neighbours4j.size(); jn4++) {
832 unsigned rhk = neighbours4j[jn4];
834 surroundingEnergyj += neighbourj.
energy();
837 double surroundingEnergyFraction =
838 (surroundingEnergyi+surroundingEnergyj) / (wannaBeSeed.
energy()+neighbouri.
energy()) - 1.;
839 if ( surroundingEnergyFraction < doubleSpikeS6S2 ) {
842 std::pair<double,double> dcr =
dCrack(phi,eta);
845 if ( ( eta < 5.0 && dcrmin > 1. ) ||
846 ( wannaBeSeed.
energy() > tighterE*doubleSpikeThresh &&
847 surroundingEnergyFraction < doubleSpikeS6S2/tighterF ) ) {
885 for(
unsigned in=0;
in<neighbours.size();
in++) {
894 cout<<
"PFClusterAlgo::findSeeds : done"<<endl;
907 cout<<
"PFClusterAlgo::buildTopoClusters start"<<endl;
910 for(
unsigned is = 0; is<
seeds_.size(); is++) {
912 unsigned rhi =
seeds_[is];
914 if( !
masked(rhi) )
continue;
921 cout<<rhi<<
" used"<<endl;
926 vector< unsigned > topocluster;
929 if(topocluster.empty() )
continue;
937 cout<<
"PFClusterAlgo::buildTopoClusters done"<<endl;
952 cout<<
"PFClusterAlgo::buildTopoCluster in"<<endl;
958 int layer = rh.
layer();
965 static_cast<PFLayer::Layer>(layer), 0, iring );
967 static_cast<PFLayer::Layer>(layer), 0, iring );
970 if( e < thresh || (ptThresh > 0. && rh.
pt2() < ptThresh*ptThresh) ) {
973 cout<<
"return : "<<e<<
"<"<<thresh<<endl;
980 cluster.push_back( rhi );
989 const std::vector< unsigned >& nbs
992 for(
unsigned i=0;
i<nbs.size();
i++) {
1004 cout<<rhi<<
" used"<<endl;
1009 if( !
masked(nbs[i]) )
continue;
1014 cout<<
"PFClusterAlgo::buildTopoCluster out"<<endl;
1031 vector<reco::PFCluster> curpfclusters;
1032 vector<reco::PFCluster> curpfclusterswodepthcor;
1033 vector< unsigned > seedsintopocluster;
1036 for(
unsigned i=0;
i<topocluster.size();
i++ ) {
1038 unsigned rhi = topocluster[
i];
1045 double fraction = 1.0;
1060 curpfclusters.push_back( cluster );
1061 curpfclusterswodepthcor.push_back( clusterwodepthcor );
1064 cout <<
"PFClusterAlgo::buildPFClusters: seed "
1065 <<
rechit( rhi, rechits) <<endl;
1066 cout <<
"PFClusterAlgo::buildPFClusters: pfcluster initialized : "
1072 seedsintopocluster.push_back( rhi );
1080 double ns2 =
std::max(1.,(
double)(seedsintopocluster.size())-1.);
1086 unsigned niter = 50;
1090 vector<double> ener;
1091 vector<double> dist;
1092 vector<double>
frac;
1093 vector<math::XYZVector>
tmp;
1095 while ( iter++ < niter && diff > 1E-8*ns2 ) {
1101 for (
unsigned ic=0; ic<curpfclusters.size(); ic++ ) {
1102 ener.push_back( curpfclusters[ic].
energy() );
1105 v = curpfclusters[ic].position();
1111 cout<<
"saving photon pos "<<ic<<
" "<<curpfclusters[ic]<<endl;
1112 cout<<tmp[ic].X()<<
" "<<tmp[ic].Y()<<
" "<<tmp[ic].Z()<<endl;
1116 curpfclusters[ic].reset();
1120 for(
unsigned irh=0; irh<topocluster.size(); irh++ ) {
1121 unsigned rhindex = topocluster[irh];
1129 double fractot = 0.;
1131 bool isaseed =
isSeed(rhindex);
1139 cout<<
"start loop on curpfclusters"<<endl;
1144 for (
unsigned ic=0; ic<tmp.size(); ic++) {
1151 bool seedexclusion=
true;
1157 cposxyzclust = curpfclusterswodepthcor[ic].position();
1162 cout<<
"CLUSTER "<<cposxyzclust.X()<<
","
1163 <<cposxyzclust.Y()<<
","
1164 <<cposxyzclust.Z()<<
"\t\t"
1165 <<
"CELL "<<cposxyzcell.X()<<
","
1166 <<cposxyzcell.Y()<<
","
1167 <<cposxyzcell.Z()<<endl;
1175 deltav -= cposxyzcell;
1183 if( d > 10. &&
debug_ ) {
1185 cout<<
"PFClusterAlgo Warning: distance too large"<<d<<endl;
1188 dist.push_back( d );
1191 if( rhindex == seedsintopocluster[ic] && seedexclusion ) {
1194 if(
debug_)
cout<<
"this cell is a seed for the current photon"<<endl;
1197 else if( isaseed && seedexclusion ) {
1200 if(
debug_)
cout<<
"this cell is a seed for another photon"<<endl;
1206 frc = ener[ic] *
exp ( - dist[ic]*dist[ic] / 2. );
1210 cout<<
"dist["<<ic<<
"] "<<dist[ic]
1212 <<
", frc="<<frc<<endl;
1218 frac.push_back(frc);
1225 for (
unsigned ic=0; ic<tmp.size(); ++ic ) {
1228 cout<<
" frac["<<ic<<
"] "<<frac[ic]<<
" "<<fractot<<
" "<<rh<<endl;
1232 frac[ic] /= fractot;
1236 int layer = rh.
layer();
1237 cerr<<
"fractot = 0 ! "<<layer<<endl;
1239 for(
unsigned trh=0; trh<topocluster.size(); trh++ ) {
1240 unsigned tindex = topocluster[trh];
1263 if ( dist[ic] < 10. || frac[ic] > 0.99999 ) {
1267 curpfclusters[ic].addRecHitFraction( rhf );
1276 for (
unsigned ic=0; ic<tmp.size(); ++ic ) {
1279 true, posCalcNCrystal );
1285 double delta = ROOT::Math::VectorUtil::DeltaR(curpfclusters[ic].
position(),tmp[ic]);
1286 if ( delta > diff ) diff =
delta;
1293 if ( iter >= 50 &&
debug_ )
1294 cout <<
"PFClusterAlgo Warning: "
1295 <<
"more than "<<niter<<
" iterations in pfcluster finding: "
1296 << setprecision(10) << diff << endl;
1303 for(
unsigned ic=0; ic<curpfclusters.size(); ic++) {
1306 std::vector< reco::PFRecHitFraction > rhfracs = curpfclusters[ic].recHitFractions();
1308 curpfclusters[ic].reset();
1312 for (
const auto &rhf : rhfracs) {
1313 if (rhf.fraction()>1
e-7) {
1314 curpfclusters[ic].addRecHitFraction(rhf);
1319 true, posCalcNCrystal);
1331 int posCalcNCrystal) {
1336 throw "PFCluster::calculatePosition : posCalcNCrystal_ must be -1, 5, or 9.";
1339 std::vector< std::pair< DetId, float > > hits_and_fracts;
1353 map <PFLayer::Layer, double> layers;
1355 unsigned seedIndex = 0;
1356 bool seedIndexFound =
false;
1361 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1363 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1367 double fraction = cluster.
rechits_[ic].fraction();
1371 if(
isSeed(rhi) && fraction > 1
e-9 ) {
1373 seedIndexFound =
true;
1377 double recHitEnergy = rh.
energy() * fraction;
1380 if( recHitEnergy!=recHitEnergy ) {
1382 edm::LogError(
"PFClusterAlgo")<<
"rechit "<<rh.
detId()<<
" has a NaN energy... The input of the particle flow clustering seems to be corrupted.";
1385 cluster.
energy_ += recHitEnergy;
1390 map <PFLayer::Layer, double>:: iterator it = layers.find(layer);
1392 if (it != layers.end()) {
1393 it->second += recHitEnergy;
1396 layers.insert(make_pair(layer, recHitEnergy));
1402 assert(seedIndexFound);
1407 for (map<PFLayer::Layer, double>::iterator it = layers.begin();
1408 it != layers.end(); ++it) {
1409 double e = it->second;
1432 switch(cluster.
layer() ) {
1466 cerr<<
"Clusters weight_p1 -1 not yet allowed for layer "<<layer
1467 <<
". Chose a better value in the opt file"<<endl;
1472 else if( p1< 1
e-9 ) {
1481 double maxe = -9999;
1486 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1488 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1493 hits_and_fracts.push_back(std::make_pair(
DetId(rh.
detId()),
1495 if(rhi != seedIndex) {
1496 if( posCalcNCrystal == 5 ) {
1501 if( posCalcNCrystal == 9 ) {
1508 double fraction = hits_and_fracts.back().second;
1509 double recHitEnergy = rh.
energy() * fraction;
1510 double norm = fraction < 1E-9 ? 0. :
max(0.,
log(recHitEnergy/p1));
1514 if( recHitEnergy > maxe ) {
1515 firstrechitposxyz = rechitposxyz;
1516 maxe = recHitEnergy;
1519 x += rechitposxyz.X() * norm;
1520 y += rechitposxyz.Y() * norm;
1521 z += rechitposxyz.Z() * norm;
1529 if( normalize < 1
e-9 ) {
1532 cout <<
"Watch out : cluster too far from its seeding cell, set to 0,0,0" << endl;
1533 clusterposxyz.SetXYZ(0,0,0);
1534 clusterpos.SetCoordinates(0,0,0);
1542 clusterposxyz.SetCoordinates( x, y, z);
1544 clusterpos.SetCoordinates( clusterposxyz.Rho(), clusterposxyz.Eta(), clusterposxyz.Phi() );
1552 clusterwodepthcor = cluster;
1565 switch(cluster.
layer()) {
1567 clusterposxyzcor =
eg_pos_calc->Calculate_Location(hits_and_fracts,
1573 clusterposxyzcor =
eg_pos_calc->Calculate_Location(hits_and_fracts,
1581 cluster.
posrep_.SetCoordinates( clusterposxyzcor.Rho(),
1582 clusterposxyzcor.Eta(),
1583 clusterposxyzcor.Phi() );
1585 clusterposxyz = clusterposxyzcor;
1591 if(
abs(clusterpos.Eta() ) < 2.6 &&
1592 abs(clusterpos.Eta() ) > 1.65 ) {
1603 depth = corra * ( corrb +
log(cluster.
energy_) );
1610 <<
"PFClusterAlgo::calculateClusterPosition : unknown function"
1611 <<
" for depth correction! "<<endl;
1633 clusterposxyz.Z() );
1634 depthv /=
sqrt(depthv.Mag2() );
1645 cluster.
posrep_.SetXYZ(0,0,0);
1648 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1650 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1655 if(rhi != seedIndex) {
1656 if( posCalcNCrystal == 5 ) {
1661 if( posCalcNCrystal == 9 ) {
1668 double fraction = cluster.
rechits_[ic].fraction();
1669 double recHitEnergy = rh.
energy() * fraction;
1678 rechitaxisu /=
sqrt( rechitaxis.Mag2() );
1682 displacement *= rechitaxisu.Dot( depthv );
1685 rechitposxyzcor += displacement;
1687 if( recHitEnergy > maxe ) {
1688 firstrechitposxyz = rechitposxyzcor;
1689 maxe = recHitEnergy;
1693 double log_efrac = -1.0;
1697 if( recHitEnergy > 0 ) {
1703 norm = fraction < 1E-9 ? 0. :
max(0.,
log(recHitEnergy/p1));
1710 x += rechitposxyzcor.X() * norm;
1711 y += rechitposxyzcor.Y() * norm;
1712 z += rechitposxyzcor.Z() * norm;
1718 if(normalize < 1
e-9) {
1719 cerr<<
"--------------------"<<endl;
1720 cerr<< cluster <<endl;
1728 clusterposxyzcor.SetCoordinates(x,y,z);
1729 cluster.
posrep_.SetCoordinates( clusterposxyzcor.Rho(),
1730 clusterposxyzcor.Eta(),
1731 clusterposxyzcor.Phi() );
1733 clusterposxyz = clusterposxyzcor;
1745 if(i >= rechits.size() ) {
1746 string err =
"PFClusterAlgo::rechit : out of range";
1747 throw std::out_of_range(err);
1757 if(rhi>=
mask_.size() ) {
1758 string err =
"PFClusterAlgo::masked : out of range";
1759 throw std::out_of_range(err);
1768 if(rhi>=
color_.size() ) {
1769 string err =
"PFClusterAlgo::color : out of range";
1770 throw std::out_of_range(err);
1781 string err =
"PFClusterAlgo::isSeed : out of range";
1782 throw std::out_of_range(err);
1791 if(rhi>=
color_.size() ) {
1792 string err =
"PFClusterAlgo::color : out of range";
1793 throw std::out_of_range(err);
1814 if(!out)
return out;
1815 out<<
"PFClusterAlgo parameters : "<<endl;
1816 out<<
"-----------------------------------------------------"<<endl;
1837 out<<algo.
pfClusters_->size()<<
" clusters:"<<endl;
1842 if(!out)
return out;
1850 std::pair<double,double>
1853 static const double pi=
M_PI;
1856 static std::vector<double> cPhi;
1861 for(
unsigned i=1;
i<=17;++
i) cPhi[
i]=cPhi[0]-2*
i*pi/18;
1865 static double delta_cPhi=0.00638;
1870 if(eta<0) phi +=delta_cPhi;
1872 if (phi>=-pi && phi<=pi){
1875 if (phi<cPhi[17] || phi>=cPhi[0]){
1876 if (phi<0) phi+= 2*
pi;
1877 defi =
std::min(fabs(phi -cPhi[0]),fabs(phi-cPhi[17]-2*pi));
1886 defi=
std::min(fabs(phi-cPhi[i+1]),fabs(phi-cPhi[i]));
1895 std::cout<<
"Problem in dminphi"<<std::endl;
1899 static std::vector<double> cEta;
1900 if ( cEta.size() == 0 ) {
1901 cEta.push_back(0.0);
1902 cEta.push_back(4.44747
e-01) ; cEta.push_back(-4.44747
e-01) ;
1903 cEta.push_back(7.92824
e-01) ; cEta.push_back(-7.92824
e-01) ;
1904 cEta.push_back(1.14090
e+00) ; cEta.push_back(-1.14090
e+00) ;
1905 cEta.push_back(1.47464
e+00) ; cEta.push_back(-1.47464
e+00) ;
1909 for (
unsigned ieta=0; ieta<cEta.size(); ++ieta ) {
1910 deta =
std::min(deta,fabs(eta-cEta[ieta]));
1915 return std::pair<double,double>(defi,deta);
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
void cleanRBXAndHPD(const reco::PFRecHitCollection &rechits)
Clean HCAL readout box noise and HPD discharge.
void setLayer(PFLayer::Layer layer)
set layer
math::XYZPoint position_
cluster centroid position
std::multimap< double, unsigned >::iterator EH
int posCalcNCrystal_
number of crystals for position calculation
double threshEndcap_
endcap threshold
double threshDoubleSpikeBarrel_
Barrel double-spike cleaning.
double energy_
cluster energy
double pt2() const
rechit momentum transverse to the beam, squared.
pair< int, edm::FunctionWithDict > OK
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
void doClustering(const reco::PFRecHitCollection &rechits)
perform clustering
const CaloSubdetectorGeometry * eb_geom
std::vector< unsigned > color_
color, for all rechits
PFRecHitHandle rechitsHandle_
unsigned detId() const
rechit detId
std::vector< reco::PFRecHitFraction > rechits_
vector of rechit fractions (transient)
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< Double32_t > > REPPoint
std::pair< double, double > dCrack(double phi, double eta)
distance to a crack in the ECAL barrel in eta and phi direction
bool isSeed(unsigned rhi) const
const reco::PFRecHit & rechit(unsigned i, const reco::PFRecHitCollection &rechits)
double threshDoubleSpikeEndcap_
Endcap double-spike cleaning.
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
std::multimap< double, unsigned, std::greater< double > > eRecHits_
indices to rechits, sorted by decreasing E (not E_T)
std::vector< double > minS4S1Barrel_
double threshPtSeedEndcap_
double threshPtSeedBarrel_
std::ostream & operator<<(std::ostream &out, const ALILine &li)
std::vector< SeedState > seedStates_
seed state, for all rechits
std::vector< std::vector< unsigned > > topoClusters_
sets of cells having one common side, and energy over threshold
std::auto_ptr< std::vector< reco::PFRecHit > > pfRecHitsCleaned_
particle flow rechits cleaned
std::vector< bool > usedInTopo_
used in topo cluster? for all rechits
double energyUp() const
For HF hits: rechit energy (and neighbour's) in the other HF layer.
static int position[TOTALCHAMBERS][3]
void setSeed(const DetId &id)
double threshSeedBarrel_
barrel seed threshold
PFLayer::Layer layer() const
rechit layer
bool masked(unsigned rhi) const
std::vector< unsigned > seeds_
vector of indices for seeds.
void doClusteringWorker(const reco::PFRecHitCollection &rechits)
perform clustering
int posCalcNCrystal() const
get number of crystals for position calculation (-1 all,5, or 9)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
const T & max(const T &a, const T &b)
const std::vector< unsigned > & neighbours8() const
const CaloSubdetectorGeometry * preshower_geom
const math::XYZVector & getAxisXYZ() const
rechit cell axis x, y, z
std::vector< bool > mask_
static double depthCorAp_
bool cleanRBXandHPDs_
option to clean HCAL RBX's and HPD's
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
reco::Candidate::Vector normalize(const reco::Candidate::Vector &p)
void buildTopoClusters(const reco::PFRecHitCollection &rechits)
build topoclusters around seeds
std::auto_ptr< PositionCalc > eg_pos_calc
edm::Ref< PFRecHitCollection > PFRecHitRef
persistent reference to PFRecHit objects
std::vector< double > minS4S1Endcap_
static double depthCorBp_
double energy() const
cluster energy
void findSeeds(const reco::PFRecHitCollection &rechits)
look for seeds
PFClusterAlgo()
constructor
double threshCleanBarrel_
Barrel cleaning threshold and S4/S1 smallest fractiom.
int iphi() const
get the cell iphi
const math::XYZPoint & position() const
is seed ?
bool debug_
debugging on/off
int nNeighbours_
number of neighbours
reco::PFRecHitRef createRecHitRef(const reco::PFRecHitCollection &rechits, unsigned rhi)
REPPoint posrep_
cluster position: rho, eta, phi (transient)
void buildTopoCluster(std::vector< unsigned > &cluster, unsigned rhi, const reco::PFRecHitCollection &rechits)
build a topocluster (recursive)
double minS6S2DoubleSpikeEndcap_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
bool isNeighbour4(unsigned id) const
XYZPointD XYZPoint
point in space with cartesian internal representation
PositionCalcType which_pos_calc_
parameter for position calculation
double showerSigma_
sigma of shower (cm)
void paint(unsigned rhi, unsigned color=1)
paint a rechit with a color.
double parameter(Parameter paramtype, PFLayer::Layer layer, unsigned iCoeff=0, int iring0=0) const
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
std::vector< std::vector< double > > tmp
double energy() const
rechit energy
double threshBarrel_
barrel threshold
bool useCornerCells_
option to use cells with a common corner to build topo-clusters
static unsigned prodNum_
product number
bool isNeighbour8(unsigned id) const
void calculateClusterPosition(reco::PFCluster &cluster, reco::PFCluster &clusterwodepthcor, bool depcor=true, int posCalcNCrystal=0)
calculate position of a cluster
const CaloSubdetectorGeometry * ee_geom
std::auto_ptr< SortedPFRecHitCollection > sortedRecHits_
double threshSeedEndcap_
endcap seed threshold
std::auto_ptr< std::vector< reco::PFCluster > > pfClusters_
all clusters
volatile std::atomic< bool > shutdown_flag false
edm::SortedCollection< reco::PFRecHit > SortedPFRecHitCollection
void buildPFClusters(const std::vector< unsigned > &cluster, const reco::PFRecHitCollection &rechits)
build PFClusters from a topocluster
unsigned color(unsigned rhi) const
const std::vector< unsigned > & neighbours4() const
double minS6S2DoubleSpikeBarrel_
double threshCleanEndcap_
Endcap cleaning threshold and S4/S1 smallest fractiom.
const REPPoint & positionREP() const
rechit cell centre rho, eta, phi. call calculatePositionREP before !