4 #include "Math/GenVector/VectorUtil.h"
23 pfClusters_( new vector<
reco::PFCluster> ),
24 pfRecHitsCleaned_( new vector<
reco::PFRecHit> ),
27 threshSeedBarrel_(0.2),
28 threshPtSeedBarrel_(0.),
31 threshSeedEndcap_(0.6),
32 threshPtSeedEndcap_(0.),
33 threshCleanBarrel_(1E5),
35 threshDoubleSpikeBarrel_(1E9),
36 minS6S2DoubleSpikeBarrel_(-1.),
37 threshCleanEndcap_(1E5),
39 threshDoubleSpikeEndcap_(1E9),
40 minS6S2DoubleSpikeEndcap_(-1.),
45 useCornerCells_(
false),
46 cleanRBXandHPDs_(
false),
59 cout <<
"Benchmark output written to file " <<
file_->GetName() << endl;
89 if (mask.size() == rechits.size()) {
90 mask_.insert(
mask_.end(), mask.begin(), mask.end() );
92 edm::LogError(
"PClusterAlgo::doClustering") <<
"map size should be " << rechits.size() <<
". Will be reinitialized.";
124 if (mask.size() == rechits.size()) {
125 mask_.insert(
mask_.end(), mask.begin(), mask.end() );
127 edm::LogError(
"PClusterAlgo::doClustering") <<
"map size should be " << rechits.size() <<
". Will be reinitialized.";
143 pfClusters_.reset(
new std::vector<reco::PFCluster> );
154 for (
unsigned i = 0;
i < rechits.size();
i++ ){
160 color_.resize( rechits.size(), 0 );
199 unsigned iCoeff,
int iring )
const {
236 cerr<<
"PFClusterAlgo::parameter : unknown parameter type "
274 cerr<<
"PFClusterAlgo::parameter : unknown parameter type "
280 cerr<<
"PFClusterAlgo::parameter : unknown layer "<<layer<<endl;
292 std::map< int, std::vector<unsigned> > hpds;
293 std::map< int, std::vector<unsigned> > rbxs;
297 unsigned rhi = ih->second;
299 if(!
masked(rhi) )
continue;
303 int layer = rhit.
layer();
308 int ieta = theHcalDetId.
ieta();
309 int iphi = theHcalDetId.
iphi();
310 int ihpd = ieta < 0 ?
313 hpds[ihpd].push_back(rhi);
314 int irbx = ieta < 0 ?
317 if ( irbx == 19 ) irbx = 1;
318 else if ( irbx == -19 ) irbx = -1;
319 else if ( irbx == 39 ) irbx = 21;
320 else if ( irbx == -39 ) irbx = -21;
321 rbxs[irbx].push_back(rhi);
325 for (
std::map<
int, std::vector<unsigned> >::iterator itrbx = rbxs.begin();
326 itrbx != rbxs.end(); ++itrbx ) {
327 if ( (
abs(itrbx->first)<20 && itrbx->second.size() > 30 ) ||
328 (
abs(itrbx->first)>20 && itrbx->second.size() > 30 ) ) {
329 const std::vector<unsigned>& rhits = itrbx->second;
330 double totalEta = 0.;
331 double totalEtaW = 0.;
332 double totalPhi = 0.;
333 double totalPhiW = 0.;
334 double totalEta2 = 1E-9;
335 double totalEta2W = 1E-9;
336 double totalPhi2 = 1E-9;
337 double totalPhi2W = 1E-9;
338 double totalEnergy = 0.;
339 double totalEnergy2 = 1E-9;
340 unsigned nSeeds = rhits.size();
341 unsigned nSeeds0 = rhits.size();
342 std::map< int,std::vector<unsigned> > theHPDs;
343 std::multimap< double,unsigned > theEnergies;
344 for (
unsigned jh=0; jh < rhits.size(); ++jh ) {
349 const vector<unsigned>& neighbours4 = *(& hit.
neighbours4());
350 for(
unsigned in=0;
in<neighbours4.size();
in++) {
359 if ( neighbour.
energy() > 0.4 ) ++nN;
362 if ( isASeed && !nN ) --nSeeds0;
366 int iphi = theHcalDetId.
iphi();
369 theHPDs[iphi].push_back(rhits[jh]);
371 theHPDs[(iphi-1)/2].push_back(rhits[jh]);
372 theEnergies.insert(std::pair<double,unsigned>(hit.
energy(),rhits[jh]));
373 totalEnergy += hit.
energy();
374 totalPhi += fabs(hit.
position().phi());
385 totalPhi /= rhits.size();
386 totalEta /= rhits.size();
387 totalPhiW /= totalEnergy;
388 totalEtaW /= totalEnergy;
389 totalPhi2 /= rhits.size();
390 totalEta2 /= rhits.size();
391 totalPhi2W /= totalEnergy;
392 totalEta2W /= totalEnergy;
393 totalPhi2 =
std::sqrt(totalPhi2 - totalPhi*totalPhi);
394 totalEta2 =
std::sqrt(totalEta2 - totalEta*totalEta);
395 totalPhi2W =
std::sqrt(totalPhi2W - totalPhiW*totalPhiW);
396 totalEta2W =
std::sqrt(totalEta2W - totalEtaW*totalEtaW);
397 totalEnergy /= rhits.size();
398 totalEnergy2 /= rhits.size();
399 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
403 for (
std::map<
int, std::vector<unsigned> >::iterator itHPD = theHPDs.begin();
404 itHPD != theHPDs.end(); ++itHPD ) {
405 int hpdN = itHPD->first;
406 const std::vector<unsigned>& hpdHits = itHPD->second;
407 if ( (
abs(hpdN) < 100 && hpdHits.size() > 14 ) ||
408 (
abs(hpdN) > 100 && hpdHits.size() > 14 ) ) ++nHPD15;
426 std::multimap<double, unsigned >::iterator ntEn = theEnergies.end();
430 for ( std::multimap<double, unsigned >::iterator itEn = theEnergies.begin();
431 itEn != theEnergies.end(); ++itEn ) {
434 mask_[itEn->second] =
false;
435 }
else if ( nn == 5 ) {
436 threshold = itEn->first * 5.;
437 mask_[itEn->second] =
false;
439 if ( itEn->first < threshold )
mask_[itEn->second] =
false;
441 if ( !
masked(itEn->second) ) {
461 std::map<int, std::vector<unsigned> >::iterator neighbour1;
462 std::map<int, std::vector<unsigned> >::iterator neighbour2;
463 std::map<int, std::vector<unsigned> >::iterator neighbour0;
464 std::map<int, std::vector<unsigned> >::iterator neighbour3;
467 for (
std::map<
int, std::vector<unsigned> >::iterator ithpd = hpds.begin();
468 ithpd != hpds.end(); ++ithpd ) {
470 const std::vector<unsigned>& rhits = ithpd->second;
471 std::multimap< double,unsigned > theEnergies;
472 double totalEnergy = 0.;
473 double totalEnergy2 = 1E-9;
474 for (
unsigned jh=0; jh < rhits.size(); ++jh ) {
476 totalEnergy += hit.
energy();
478 theEnergies.insert(std::pair<double,unsigned>(hit.
energy(),rhits[jh]));
480 totalEnergy /= rhits.size();
481 totalEnergy2 /= rhits.size();
482 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
484 if ( ithpd->first == 1 ) neighbour1 = hpds.find(72);
485 else if ( ithpd->first == -1 ) neighbour1 = hpds.find(-72);
486 else if ( ithpd->first == 101 ) neighbour1 = hpds.find(136);
487 else if ( ithpd->first == -101 ) neighbour1 = hpds.find(-136);
488 else neighbour1 = ithpd->first > 0 ? hpds.find(ithpd->first-1) : hpds.find(ithpd->first+1) ;
490 if ( ithpd->first == 72 ) neighbour2 = hpds.find(1);
491 else if ( ithpd->first == -72 ) neighbour2 = hpds.find(-1);
492 else if ( ithpd->first == 136 ) neighbour2 = hpds.find(101);
493 else if ( ithpd->first == -136 ) neighbour2 = hpds.find(-101);
494 else neighbour2 = ithpd->first > 0 ? hpds.find(ithpd->first+1) : hpds.find(ithpd->first-1) ;
496 if ( neighbour1 != hpds.end() ) {
497 if ( neighbour1->first == 1 ) neighbour0 = hpds.find(72);
498 else if ( neighbour1->first == -1 ) neighbour0 = hpds.find(-72);
499 else if ( neighbour1->first == 101 ) neighbour0 = hpds.find(136);
500 else if ( neighbour1->first == -101 ) neighbour0 = hpds.find(-136);
501 else neighbour0 = neighbour1->first > 0 ? hpds.find(neighbour1->first-1) : hpds.find(neighbour1->first+1) ;
504 if ( neighbour2 != hpds.end() ) {
505 if ( neighbour2->first == 72 ) neighbour3 = hpds.find(1);
506 else if ( neighbour2->first == -72 ) neighbour3 = hpds.find(-1);
507 else if ( neighbour2->first == 136 ) neighbour3 = hpds.find(101);
508 else if ( neighbour2->first == -136 ) neighbour3 = hpds.find(-101);
509 else neighbour3 = neighbour2->first > 0 ? hpds.find(neighbour2->first+1) : hpds.find(neighbour2->first-1) ;
512 size1 = neighbour1 != hpds.end() ? neighbour1->second.size() : 0;
513 size2 = neighbour2 != hpds.end() ? neighbour2->second.size() : 0;
517 if ( (
abs(neighbour1->first) > 100 && neighbour1->second.size() > 15 ) ||
518 (
abs(neighbour1->first) < 100 && neighbour1->second.size() > 12 ) )
519 size1 = neighbour0 != hpds.end() ? neighbour0->second.size() : 0;
522 if ( (
abs(neighbour2->first) > 100 && neighbour2->second.size() > 15 ) ||
523 (
abs(neighbour2->first) < 100 && neighbour2->second.size() > 12 ) )
524 size2 = neighbour3 != hpds.end() ? neighbour3->second.size() : 0;
527 if ( (
abs(ithpd->first) > 100 && ithpd->second.size() > 15 ) ||
528 (
abs(ithpd->first) < 100 && ithpd->second.size() > 12 ) )
529 if ( (
float)(size1 + size2)/(
float)ithpd->second.size() < 1.0 ) {
536 std::multimap<double, unsigned >::iterator ntEn = theEnergies.end();
540 for ( std::multimap<double, unsigned >::iterator itEn = theEnergies.begin();
541 itEn != theEnergies.end(); ++itEn ) {
544 mask_[itEn->second] =
false;
545 }
else if ( nn == 5 ) {
546 threshold = itEn->first * 2.5;
547 mask_[itEn->second] =
false;
549 if ( itEn->first < threshold )
mask_[itEn->second] =
false;
551 if ( !
masked(itEn->second) ) {
578 cout<<
"PFClusterAlgo::findSeeds : start"<<endl;
583 const vector<unsigned> noNeighbours(0, static_cast<unsigned>(0));
589 unsigned rhi = ih->second;
591 if(!
masked(rhi) )
continue;
594 double rhenergy = ih->first;
601 int layer = wannaBeSeed.
layer();
608 static_cast<PFLayer::Layer>(layer), 0, iring );
611 static_cast<PFLayer::Layer>(layer), 0., iring );
614 static_cast<PFLayer::Layer>(layer), 0, iring );
617 static_cast<PFLayer::Layer>(layer), 0, iring );
620 static_cast<PFLayer::Layer>(layer), 1, iring );
623 static_cast<PFLayer::Layer>(layer), 0, iring );
626 static_cast<PFLayer::Layer>(layer), 0, iring );
630 cout<<
"layer:"<<layer<<
" seedThresh:"<<seedThresh<<endl;
634 if( rhenergy < seedThresh || (seedPtThresh>0. && wannaBeSeed.
pt2() < seedPtThresh*seedPtThresh )) {
640 const vector<unsigned>* nbp;
641 double tighterE = 1.0;
642 double tighterF = 1.0;
661 nbp = & noNeighbours;
666 cerr<<
"you're not allowed to set n neighbours to "
677 cerr<<
"CellsEF::PhotonSeeds : unknown layer "<<layer<<endl;
681 const vector<unsigned>& neighbours = *nbp;
687 for(
unsigned in=0;
in<neighbours.size();
in++) {
689 unsigned rhj = neighbours[
in];
691 if ( !
masked(rhj) )
continue;
702 if (
file_ || wannaBeSeed.
energy() > cleanThresh ) {
704 const vector<unsigned>& neighbours4 = *(& wannaBeSeed.
neighbours4());
706 double surroundingEnergy = wannaBeSeed.
energyUp();
707 double neighbourEnergy = 0.;
708 double layerEnergy = 0.;
709 for(
unsigned in4=0; in4<neighbours4.size(); in4++) {
710 unsigned rhj = neighbours4[in4];
712 if ( !
masked(rhj) )
continue;
716 layerEnergy += neighbour.
energy();
722 double fraction1 = surroundingEnergy/wannaBeSeed.
energy();
741 }
else if ( fabs(wannaBeSeed.
position().eta()) < 5.0 ) {
743 if ( wannaBeSeed.
energy() > 1000 ) {
744 if ( fabs(wannaBeSeed.
position().eta()) < 2.8 )
753 if ( wannaBeSeed.
energy() > cleanThresh ) {
754 double f1Cut = minS4S1_a * log10(wannaBeSeed.
energy()) + minS4S1_b;
755 if ( fraction1 < f1Cut ) {
759 std::pair<double,double> dcr =
dCrack(phi,eta);
763 ( ( eta < 2.85 && dcrmin > 1. ) ||
764 ( rhenergy > tighterE*cleanThresh &&
765 fraction1 < f1Cut/tighterF ) )
788 if (
mask_[rhi] && wannaBeSeed.
energy() > doubleSpikeThresh ) {
790 double surroundingEnergyi = 0.;
791 double enmax = -999.;
792 unsigned mostEnergeticNeighbour = 0;
793 const vector<unsigned>& neighbours4i = *(& wannaBeSeed.
neighbours4());
794 for(
unsigned in4=0; in4<neighbours4i.size(); in4++) {
795 unsigned rhj = neighbours4i[in4];
796 if ( !
masked(rhj) )
continue;
798 surroundingEnergyi += neighbouri.
energy();
799 if ( neighbouri.
energy() > enmax ) {
800 enmax = neighbouri.
energy();
801 mostEnergeticNeighbour = rhj;
806 unsigned rhj = mostEnergeticNeighbour;
808 double surroundingEnergyj = 0.;
811 const vector<unsigned>& neighbours4j = *(& neighbouri.
neighbours4());
812 for(
unsigned jn4=0; jn4<neighbours4j.size(); jn4++) {
813 unsigned rhk = neighbours4j[jn4];
815 surroundingEnergyj += neighbourj.
energy();
818 double surroundingEnergyFraction =
819 (surroundingEnergyi+surroundingEnergyj) / (wannaBeSeed.
energy()+neighbouri.
energy()) - 1.;
820 if ( surroundingEnergyFraction < doubleSpikeS6S2 ) {
823 std::pair<double,double> dcr =
dCrack(phi,eta);
826 if ( ( eta < 5.0 && dcrmin > 1. ) ||
827 ( wannaBeSeed.
energy() > tighterE*doubleSpikeThresh &&
828 surroundingEnergyFraction < doubleSpikeS6S2/tighterF ) ) {
866 for(
unsigned in=0;
in<neighbours.size();
in++) {
875 cout<<
"PFClusterAlgo::findSeeds : done"<<endl;
888 cout<<
"PFClusterAlgo::buildTopoClusters start"<<endl;
891 for(
unsigned is = 0; is<
seeds_.size(); is++) {
893 unsigned rhi =
seeds_[is];
895 if( !
masked(rhi) )
continue;
902 cout<<rhi<<
" used"<<endl;
907 vector< unsigned > topocluster;
910 if(topocluster.empty() )
continue;
918 cout<<
"PFClusterAlgo::buildTopoClusters done"<<endl;
933 cout<<
"PFClusterAlgo::buildTopoCluster in"<<endl;
939 int layer = rh.
layer();
946 static_cast<PFLayer::Layer>(layer), 0, iring );
948 static_cast<PFLayer::Layer>(layer), 0, iring );
951 if( e < thresh || (ptThresh > 0. && rh.
pt2() < ptThresh*ptThresh) ) {
954 cout<<
"return : "<<e<<
"<"<<thresh<<endl;
961 cluster.push_back( rhi );
970 const std::vector< unsigned >& nbs
973 for(
unsigned i=0;
i<nbs.size();
i++) {
985 cout<<rhi<<
" used"<<endl;
990 if( !
masked(nbs[i]) )
continue;
995 cout<<
"PFClusterAlgo::buildTopoCluster out"<<endl;
1012 vector<reco::PFCluster> curpfclusters;
1013 vector<reco::PFCluster> curpfclusterswodepthcor;
1014 vector< unsigned > seedsintopocluster;
1017 for(
unsigned i=0;
i<topocluster.size();
i++ ) {
1019 unsigned rhi = topocluster[
i];
1026 double fraction = 1.0;
1041 curpfclusters.push_back( cluster );
1042 curpfclusterswodepthcor.push_back( clusterwodepthcor );
1045 cout <<
"PFClusterAlgo::buildPFClusters: seed "
1046 <<
rechit( rhi, rechits) <<endl;
1047 cout <<
"PFClusterAlgo::buildPFClusters: pfcluster initialized : "
1053 seedsintopocluster.push_back( rhi );
1061 double ns2 =
std::max(1.,(
double)(seedsintopocluster.size())-1.);
1067 unsigned niter = 50;
1071 vector<double> ener;
1072 vector<double> dist;
1073 vector<double>
frac;
1074 vector<math::XYZVector>
tmp;
1076 while ( iter++ < niter && diff > 1E-8*ns2 ) {
1082 for (
unsigned ic=0; ic<curpfclusters.size(); ic++ ) {
1083 ener.push_back( curpfclusters[ic].
energy() );
1086 v = curpfclusters[ic].position();
1092 cout<<
"saving photon pos "<<ic<<
" "<<curpfclusters[ic]<<endl;
1093 cout<<tmp[ic].X()<<
" "<<tmp[ic].Y()<<
" "<<tmp[ic].Z()<<endl;
1097 curpfclusters[ic].reset();
1101 for(
unsigned irh=0; irh<topocluster.size(); irh++ ) {
1102 unsigned rhindex = topocluster[irh];
1110 double fractot = 0.;
1112 bool isaseed =
isSeed(rhindex);
1120 cout<<
"start loop on curpfclusters"<<endl;
1125 for (
unsigned ic=0; ic<tmp.size(); ic++) {
1132 bool seedexclusion=
true;
1138 cposxyzclust = curpfclusterswodepthcor[ic].position();
1143 cout<<
"CLUSTER "<<cposxyzclust.X()<<
","
1144 <<cposxyzclust.Y()<<
","
1145 <<cposxyzclust.Z()<<
"\t\t"
1146 <<
"CELL "<<cposxyzcell.X()<<
","
1147 <<cposxyzcell.Y()<<
","
1148 <<cposxyzcell.Z()<<endl;
1156 deltav -= cposxyzcell;
1164 if( d > 10. &&
debug_ ) {
1166 cout<<
"PFClusterAlgo Warning: distance too large"<<d<<endl;
1169 dist.push_back( d );
1172 if( rhindex == seedsintopocluster[ic] && seedexclusion ) {
1175 if(
debug_)
cout<<
"this cell is a seed for the current photon"<<endl;
1178 else if( isaseed && seedexclusion ) {
1181 if(
debug_)
cout<<
"this cell is a seed for another photon"<<endl;
1187 frc = ener[ic] *
exp ( - dist[ic]*dist[ic] / 2. );
1191 cout<<
"dist["<<ic<<
"] "<<dist[ic]
1193 <<
", frc="<<frc<<endl;
1199 frac.push_back(frc);
1206 for (
unsigned ic=0; ic<tmp.size(); ++ic ) {
1209 cout<<
" frac["<<ic<<
"] "<<frac[ic]<<
" "<<fractot<<
" "<<rh<<endl;
1213 frac[ic] /= fractot;
1217 int layer = rh.
layer();
1218 cerr<<
"fractot = 0 ! "<<layer<<endl;
1220 for(
unsigned trh=0; trh<topocluster.size(); trh++ ) {
1221 unsigned tindex = topocluster[trh];
1244 if ( dist[ic] < 10. || frac[ic] > 0.99999 ) {
1248 curpfclusters[ic].addRecHitFraction( rhf );
1257 for (
unsigned ic=0; ic<tmp.size(); ++ic ) {
1260 true, posCalcNCrystal );
1266 double delta = ROOT::Math::VectorUtil::DeltaR(curpfclusters[ic].
position(),tmp[ic]);
1267 if ( delta > diff ) diff =
delta;
1274 if ( iter >= 50 &&
debug_ )
1275 cout <<
"PFClusterAlgo Warning: "
1276 <<
"more than "<<niter<<
" iterations in pfcluster finding: "
1277 << setprecision(10) << diff << endl;
1282 for(
unsigned ic=0; ic<curpfclusters.size(); ic++) {
1285 true, posCalcNCrystal);
1297 int posCalcNCrystal) {
1302 throw "PFCluster::calculatePosition : posCalcNCrystal_ must be -1, 5, or 9.";
1312 double normalize = 0;
1318 map <PFLayer::Layer, double> layers;
1320 unsigned seedIndex = 0;
1321 bool seedIndexFound =
false;
1326 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1328 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1332 double fraction = cluster.
rechits_[ic].fraction();
1336 if(
isSeed(rhi) && fraction > 1
e-9 ) {
1338 seedIndexFound =
true;
1341 double recHitEnergy = rh.
energy() * fraction;
1344 if( recHitEnergy!=recHitEnergy ) {
1346 edm::LogError(
"PFClusterAlgo")<<
"rechit "<<rh.
detId()<<
" has a NaN energy... The input of the particle flow clustering seems to be corrupted.";
1349 cluster.
energy_ += recHitEnergy;
1354 map <PFLayer::Layer, double>:: iterator it = layers.find(layer);
1356 if (it != layers.end()) {
1357 it->second += recHitEnergy;
1360 layers.insert(make_pair(layer, recHitEnergy));
1366 assert(seedIndexFound);
1371 for (map<PFLayer::Layer, double>::iterator it = layers.begin();
1372 it != layers.end(); ++it) {
1373 double e = it->second;
1396 switch(cluster.
layer() ) {
1430 cerr<<
"Clusters weight_p1 -1 not yet allowed for layer "<<layer
1431 <<
". Chose a better value in the opt file"<<endl;
1436 else if( p1< 1
e-9 ) {
1445 double maxe = -9999;
1450 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1452 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1457 if(rhi != seedIndex) {
1458 if( posCalcNCrystal == 5 ) {
1463 if( posCalcNCrystal == 9 ) {
1469 double fraction = cluster.
rechits_[ic].fraction();
1470 double recHitEnergy = rh.
energy() * fraction;
1472 double norm = fraction < 1E-9 ? 0. :
max(0.,
log(recHitEnergy/p1 ));
1476 if( recHitEnergy > maxe ) {
1477 firstrechitposxyz = rechitposxyz;
1478 maxe = recHitEnergy;
1481 x += rechitposxyz.X() * norm;
1482 y += rechitposxyz.Y() * norm;
1483 z += rechitposxyz.Z() * norm;
1491 if( normalize < 1
e-9 ) {
1494 cout <<
"Watch out : cluster too far from its seeding cell, set to 0,0,0" << endl;
1495 clusterposxyz.SetXYZ(0,0,0);
1496 clusterpos.SetCoordinates(0,0,0);
1504 clusterposxyz.SetCoordinates( x, y, z);
1506 clusterpos.SetCoordinates( clusterposxyz.Rho(), clusterposxyz.Eta(), clusterposxyz.Phi() );
1514 clusterwodepthcor = cluster;
1528 if(
abs(clusterpos.Eta() ) < 2.6 &&
1529 abs(clusterpos.Eta() ) > 1.65 ) {
1540 depth = corra * ( corrb +
log(cluster.
energy_) );
1546 cerr<<
"PFClusterAlgo::calculateClusterPosition : unknown function for depth correction! "<<endl;
1569 clusterposxyz.Z() );
1570 depthv /=
sqrt(depthv.Mag2() );
1581 cluster.
posrep_.SetXYZ(0,0,0);
1583 for (
unsigned ic=0; ic<cluster.
rechits_.size(); ic++ ) {
1585 unsigned rhi = cluster.
rechits_[ic].recHitRef().index();
1590 if(rhi != seedIndex) {
1591 if( posCalcNCrystal == 5 ) {
1596 if( posCalcNCrystal == 9 ) {
1603 double fraction = cluster.
rechits_[ic].fraction();
1604 double recHitEnergy = rh.
energy() * fraction;
1613 rechitaxisu /=
sqrt( rechitaxis.Mag2() );
1617 displacement *= rechitaxisu.Dot( depthv );
1620 rechitposxyzcor += displacement;
1622 if( recHitEnergy > maxe ) {
1623 firstrechitposxyz = rechitposxyzcor;
1624 maxe = recHitEnergy;
1627 double norm = fraction < 1E-9 ? 0. :
max(0.,
log(recHitEnergy/p1 ));
1629 x += rechitposxyzcor.X() * norm;
1630 y += rechitposxyzcor.Y() * norm;
1631 z += rechitposxyzcor.Z() * norm;
1638 if(normalize < 1
e-9) {
1639 cerr<<
"--------------------"<<endl;
1640 cerr<< cluster <<endl;
1649 clusterposxyzcor.SetCoordinates(x,y,z);
1650 cluster.
posrep_.SetCoordinates( clusterposxyzcor.Rho(),
1651 clusterposxyzcor.Eta(),
1652 clusterposxyzcor.Phi() );
1654 clusterposxyz = clusterposxyzcor;
1666 if(i >= rechits.size() ) {
1667 string err =
"PFClusterAlgo::rechit : out of range";
1668 throw std::out_of_range(err);
1678 if(rhi>=
mask_.size() ) {
1679 string err =
"PFClusterAlgo::masked : out of range";
1680 throw std::out_of_range(err);
1689 if(rhi>=
color_.size() ) {
1690 string err =
"PFClusterAlgo::color : out of range";
1691 throw std::out_of_range(err);
1702 string err =
"PFClusterAlgo::isSeed : out of range";
1703 throw std::out_of_range(err);
1712 if(rhi>=
color_.size() ) {
1713 string err =
"PFClusterAlgo::color : out of range";
1714 throw std::out_of_range(err);
1735 if(!out)
return out;
1736 out<<
"PFClusterAlgo parameters : "<<endl;
1737 out<<
"-----------------------------------------------------"<<endl;
1758 out<<algo.
pfClusters_->size()<<
" clusters:"<<endl;
1763 if(!out)
return out;
1771 std::pair<double,double>
1777 static std::vector<double> cPhi;
1782 for(
unsigned i=1;
i<=17;++
i) cPhi[
i]=cPhi[0]-2*
i*pi/18;
1786 static double delta_cPhi=0.00638;
1791 if(eta<0) phi +=delta_cPhi;
1793 if (phi>=-pi && phi<=pi){
1796 if (phi<cPhi[17] || phi>=cPhi[0]){
1797 if (phi<0) phi+= 2*
pi;
1798 defi =
std::min(fabs(phi -cPhi[0]),fabs(phi-cPhi[17]-2*pi));
1807 defi=
std::min(fabs(phi-cPhi[i+1]),fabs(phi-cPhi[i]));
1816 std::cout<<
"Problem in dminphi"<<std::endl;
1820 static std::vector<double> cEta;
1821 if ( cEta.size() == 0 ) {
1822 cEta.push_back(0.0);
1823 cEta.push_back(4.44747
e-01) ; cEta.push_back(-4.44747
e-01) ;
1824 cEta.push_back(7.92824
e-01) ; cEta.push_back(-7.92824
e-01) ;
1825 cEta.push_back(1.14090
e+00) ; cEta.push_back(-1.14090
e+00) ;
1826 cEta.push_back(1.47464
e+00) ; cEta.push_back(-1.47464
e+00) ;
1830 for (
unsigned ieta=0; ieta<cEta.size(); ++ieta ) {
1831 deta =
std::min(deta,fabs(eta-cEta[ieta]));
1836 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
tuple nN
people filling error matrix uses the naive 1/sqrt(N) errors
double threshDoubleSpikeBarrel_
Barrel double-spike cleaning.
double energy_
cluster energy
double pt2() const
rechit momentum transverse to the beam, squared.
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
void doClustering(const reco::PFRecHitCollection &rechits)
perform clustering
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]
double threshSeedBarrel_
barrel seed threshold
PFLayer::Layer layer() const
rechit layer
Algorithm for particle flow clustering.
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 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
void buildTopoClusters(const reco::PFRecHitCollection &rechits)
build topoclusters around seeds
edm::Ref< PFRecHitCollection > PFRecHitRef
persistent reference to PFRecHit objects
std::vector< double > minS4S1Endcap_
static double depthCorBp_
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
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
double threshSeedEndcap_
endcap seed threshold
std::auto_ptr< std::vector< reco::PFCluster > > pfClusters_
all clusters
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.
double posCalcP1_
parameter for position calculation
const REPPoint & positionREP() const
rechit cell centre rho, eta, phi. call calculatePositionREP before !