CMS 3D CMS Logo

List of all members | Classes | Static Public Member Functions | Static Private Member Functions
EcalClusterToolsT< noZS > Class Template Reference

#include <EcalClusterTools.h>

Classes

struct  EcalClusterEnergyDeposition
 

Static Public Member Functions

static Cluster2ndMoments cluster2ndMoments (const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
 
static Cluster2ndMoments cluster2ndMoments (const reco::SuperCluster &superCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
 
static Cluster2ndMoments cluster2ndMoments (const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs_fracs, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
 
static std::vector< float > covariances (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
 
static float e1x3 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e1x5 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2nd (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
 
static float e2x2 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2x5Bottom (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2x5Left (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2x5Max (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2x5Right (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e2x5Top (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e3x1 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e3x2 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e3x3 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e4x4 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e5x1 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float e5x5 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float eBottom (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float eLeft (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float eMax (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
 
static std::vector< float > energyBasketFractionEta (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
 
static std::vector< float > energyBasketFractionPhi (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
 
static float eRight (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float eTop (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float getFraction (const std::vector< std::pair< DetId, float > > &v_id, DetId id)
 
static std::pair< DetId, float > getMaximum (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
 
static std::pair< DetId, float > getMaximum (const std::vector< std::pair< DetId, float > > &v_id, const EcalRecHitCollection *recHits)
 
static std::vector< float > lat (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW=true, float w0=4.7)
 
static std::vector< float > localCovariances (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
 
static std::vector< DetIdmatrixDetId (const CaloTopology *topology, DetId id, CaloRectangle rectangle)
 
static std::vector< DetIdmatrixDetId (const CaloTopology *topology, DetId id, int size)
 
static float matrixEnergy (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
 
static int matrixSize (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
 
static int n5x5 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static int nrSaturatedCrysIn5x5 (const DetId &id, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static float recHitEnergy (DetId id, const EcalRecHitCollection *recHits)
 
static std::vector< float > roundnessBarrelSuperClusters (const reco::SuperCluster &superCluster, const EcalRecHitCollection &recHits, int weightedPositionMethod=0, float energyThreshold=0.0)
 
static std::vector< float > roundnessBarrelSuperClustersUserExtended (const reco::SuperCluster &superCluster, const EcalRecHitCollection &recHits, int ieta_delta=0, int iphi_delta=0, float energyRHThresh=0.00000, int weightedPositionMethod=0)
 
static std::vector< float > roundnessSelectedBarrelRecHits (const std::vector< std::pair< const EcalRecHit *, float > > &rhVector, int weightedPositionMethod=0)
 
static std::vector< float > scLocalCovariances (const reco::SuperCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
 
static double zernike20 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, double R0=6.6, bool logW=true, float w0=4.7)
 
static double zernike42 (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, double R0=6.6, bool logW=true, float w0=4.7)
 

Static Private Member Functions

static double absZernikeMoment (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
 
static double calc_AbsZernikeMoment (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
 
static float computeWeight (float eRH, float energyTotal, int weightedPositionMethod)
 
static int deltaIEta (int seed_ieta, int rh_ieta)
 
static int deltaIPhi (int seed_iphi, int rh_iphi)
 
static double f00 (double r)
 
static double f11 (double r)
 
static double f20 (double r)
 
static double f22 (double r)
 
static double f31 (double r)
 
static double f33 (double r)
 
static double f40 (double r)
 
static double f42 (double r)
 
static double f44 (double r)
 
static double f51 (double r)
 
static double f53 (double r)
 
static double f55 (double r)
 
static double factorial (int n)
 
static double fast_AbsZernikeMoment (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
 
static float getDPhiEndcap (const DetId &crysId, float meanX, float meanY)
 
static std::vector< EcalClusterEnergyDepositiongetEnergyDepTopology (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW, float w0)
 
static float getIEta (const DetId &id)
 
static float getIPhi (const DetId &id)
 
static float getNormedIX (const DetId &id)
 
static float getNormedIY (const DetId &id)
 
static float getNrCrysDiffInEta (const DetId &crysId, const DetId &orginId)
 
static float getNrCrysDiffInPhi (const DetId &crysId, const DetId &orginId)
 
static std::vector< int > getSeedPosition (const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs)
 
static float getSumEnergy (const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs_fracs)
 
static std::pair< float, float > mean5x5PositionInLocalCrysCoord (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static std::pair< float, float > mean5x5PositionInXY (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
 
static math::XYZVector meanClusterPosition (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry)
 

Detailed Description

template<bool noZS>
class EcalClusterToolsT< noZS >

Definition at line 77 of file EcalClusterTools.h.

Member Function Documentation

template<bool noZS>
double EcalClusterToolsT< noZS >::absZernikeMoment ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
int  n,
int  m,
double  R0,
bool  logW,
float  w0 
)
staticprivate

Definition at line 947 of file EcalClusterTools.h.

948 {
949  // 1. Check if n,m are correctly
950  if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0)) return -1;
951 
952  // 2. Check if n,R0 are within validity Range :
953  // n>20 or R0<2.19cm just makes no sense !
954  if ((n>20) || (R0<=2.19)) return -1;
955  if (n<=5) return fast_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, w0 );
956  else return calc_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, w0 );
957 }
static double calc_AbsZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
static double fast_AbsZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
template<bool noZS>
double EcalClusterToolsT< noZS >::calc_AbsZernikeMoment ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
int  n,
int  m,
double  R0,
bool  logW,
float  w0 
)
staticprivate

Definition at line 996 of file EcalClusterTools.h.

References funct::cos(), MillePedeFileConverter_cfg::e, factorial(), mps_fire::i, funct::m, funct::pow(), alignCSCRings::r, pfBoostedDoubleSVAK8TagInfos_cfi::R0, alignCSCRings::s, funct::sin(), and mathSSE::sqrt().

997 {
998  double r, ph, e, Re=0, Im=0, f_nm;
999  double TotalEnergy = cluster.energy();
1000  std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
1001  int clusterSize=energyDistribution.size();
1002  if(clusterSize<3) return 0.0;
1003 
1004  for (int i = 0; i < clusterSize; ++i)
1005  {
1006  r = energyDistribution[i].r / R0;
1007  if (r < 1) {
1008  ph = energyDistribution[i].phi;
1009  e = energyDistribution[i].deposited_energy;
1010  f_nm = 0;
1011  for (int s=0; s<=(n-m)/2; s++) {
1012  if (s%2==0) {
1013  f_nm = f_nm + factorial(n-s)*pow(r,(double) (n-2*s))/(factorial(s)*factorial((n+m)/2-s)*factorial((n-m)/2-s));
1014  } else {
1015  f_nm = f_nm - factorial(n-s)*pow(r,(double) (n-2*s))/(factorial(s)*factorial((n+m)/2-s)*factorial((n-m)/2-s));
1016  }
1017  }
1018  Re = Re + e/TotalEnergy * f_nm * cos( (double) m*ph);
1019  Im = Im - e/TotalEnergy * f_nm * sin( (double) m*ph);
1020  }
1021  }
1022  return sqrt(Re*Re+Im*Im);
1023 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static std::vector< EcalClusterEnergyDeposition > getEnergyDepTopology(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW, float w0)
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static double factorial(int n)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<bool noZS>
Cluster2ndMoments EcalClusterToolsT< noZS >::cluster2ndMoments ( const reco::BasicCluster basicCluster,
const EcalRecHitCollection recHits,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 1231 of file EcalClusterTools.h.

References Cluster2ndMoments::Cluster2ndMoments(), edm::SortedCollection< T, SORT >::empty(), edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), plotBeamSpotDB::first, mps_fire::i, and edm::second().

Referenced by EcalClusterToolsT< noZS >::cluster2ndMoments(), GEDPhotonProducer::fillPhotonCollection(), and EG9X105XObjectUpdateModifier::modifyObject().

1231  {
1232 
1233  if(recHits.empty()) return Cluster2ndMoments();
1234 
1235  std::vector<std::pair<const EcalRecHit*, float> > RH_ptrs_fracs;
1236 
1237  const std::vector< std::pair<DetId, float> >& myHitsPair = basicCluster.hitsAndFractions();
1238 
1239  for(unsigned int i=0; i<myHitsPair.size(); i++){
1240  //get pointer to recHit object
1241  EcalRecHitCollection::const_iterator myRH = recHits.find(myHitsPair[i].first);
1242  if(myRH != recHits.end()){
1243  RH_ptrs_fracs.push_back( std::make_pair(&(*myRH) , myHitsPair[i].second) );
1244  }
1245  }
1246 
1247  return EcalClusterToolsT<noZS>::cluster2ndMoments(RH_ptrs_fracs, phiCorrectionFactor, w0, useLogWeights);
1248 }
std::vector< EcalRecHit >::const_iterator const_iterator
U second(std::pair< T, U > const &p)
const_iterator end() const
static Cluster2ndMoments cluster2ndMoments(const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
iterator find(key_type k)
template<bool noZS>
Cluster2ndMoments EcalClusterToolsT< noZS >::cluster2ndMoments ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 1251 of file EcalClusterTools.h.

References EcalClusterToolsT< noZS >::cluster2ndMoments(), and reco::SuperCluster::seed().

1251  {
1252 
1253  return EcalClusterToolsT<noZS>::cluster2ndMoments( *(superCluster.seed()), recHits, phiCorrectionFactor, w0, useLogWeights);
1254 
1255 }
static Cluster2ndMoments cluster2ndMoments(const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
template<bool noZS>
Cluster2ndMoments EcalClusterToolsT< noZS >::cluster2ndMoments ( const std::vector< std::pair< const EcalRecHit *, float > > &  RH_ptrs_fracs,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 1258 of file EcalClusterTools.h.

References funct::abs(), Cluster2ndMoments::alpha, Cluster2ndMoments::Cluster2ndMoments(), pfDeepCMVADiscriminatorsJetTags_cfi::denominator, EcalRecHit::detid(), EcalBarrel, EcalRecHit::energy(), EcalClusterToolsT< noZS >::getSumEnergy(), mps_fire::i, GeomDetEnumerators::isBarrel(), cmsBatch::log, SiStripPI::max, phi, Cluster2ndMoments::sMaj, Cluster2ndMoments::sMin, mathSSE::sqrt(), and DetId::subdetId().

1258  {
1259 
1260  if(RH_ptrs_fracs.empty()) return Cluster2ndMoments();
1261 
1262  double mid_eta(0),mid_phi(0),mid_x(0),mid_y(0);
1263 
1264  double Etot = EcalClusterToolsT<noZS>::getSumEnergy( RH_ptrs_fracs );
1265 
1266  double max_phi=-10.;
1267  double min_phi=100.;
1268 
1269 
1270  std::vector<double> etaDetId;
1271  std::vector<double> phiDetId;
1272  std::vector<double> xDetId;
1273  std::vector<double> yDetId;
1274  std::vector<double> wiDetId;
1275 
1276  unsigned int nCry=0;
1277  double denominator=0.;
1278  bool isBarrel(true);
1279 
1280  // loop over rechits and compute weights:
1281  for(std::vector<std::pair<const EcalRecHit*, float> >::const_iterator rhf_ptr = RH_ptrs_fracs.begin(); rhf_ptr != RH_ptrs_fracs.end(); rhf_ptr++){
1282  const EcalRecHit* rh_ptr = rhf_ptr->first;
1283 
1284 
1285  //get iEta, iPhi
1286  double temp_eta(0),temp_phi(0),temp_x(0),temp_y(0);
1287  isBarrel = rh_ptr->detid().subdetId()==EcalBarrel;
1288 
1289  if(isBarrel) {
1290  temp_eta = (getIEta(rh_ptr->detid()) > 0. ? getIEta(rh_ptr->detid()) + 84.5 : getIEta(rh_ptr->detid()) + 85.5);
1291  temp_phi= getIPhi(rh_ptr->detid()) - 0.5;
1292  }
1293  else {
1294  temp_eta = getIEta(rh_ptr->detid());
1295  temp_x = getNormedIX(rh_ptr->detid());
1296  temp_y = getNormedIY(rh_ptr->detid());
1297  }
1298 
1299  double temp_ene=rh_ptr->energy() * (noZS ? 1.0 : rhf_ptr->second);
1300 
1301  double temp_wi=((useLogWeights) ?
1302  std::max(0.0, w0 + std::log( std::abs(temp_ene)/Etot ))
1303  : temp_ene);
1304 
1305 
1306  if(temp_phi>max_phi) max_phi=temp_phi;
1307  if(temp_phi<min_phi) min_phi=temp_phi;
1308  etaDetId.push_back(temp_eta);
1309  phiDetId.push_back(temp_phi);
1310  xDetId.push_back(temp_x);
1311  yDetId.push_back(temp_y);
1312  wiDetId.push_back(temp_wi);
1313  denominator+=temp_wi;
1314  nCry++;
1315  }
1316 
1317  if(isBarrel){
1318  // correct phi wrap-around:
1319  if(max_phi==359.5 && min_phi==0.5){
1320  for(unsigned int i=0; i<nCry; i++){
1321  if(phiDetId[i] - 179. > 0.) phiDetId[i]-=360.;
1322  mid_phi+=phiDetId[i]*wiDetId[i];
1323  mid_eta+=etaDetId[i]*wiDetId[i];
1324  }
1325  } else{
1326  for(unsigned int i=0; i<nCry; i++){
1327  mid_phi+=phiDetId[i]*wiDetId[i];
1328  mid_eta+=etaDetId[i]*wiDetId[i];
1329  }
1330  }
1331  }else{
1332  for(unsigned int i=0; i<nCry; i++){
1333  mid_eta+=etaDetId[i]*wiDetId[i];
1334  mid_x+=xDetId[i]*wiDetId[i];
1335  mid_y+=yDetId[i]*wiDetId[i];
1336  }
1337  }
1338 
1339  mid_eta/=denominator;
1340  mid_phi/=denominator;
1341  mid_x/=denominator;
1342  mid_y/=denominator;
1343 
1344 
1345  // See = sigma eta eta
1346  // Spp = (B field corrected) sigma phi phi
1347  // See = (B field corrected) sigma eta phi
1348  double See=0.;
1349  double Spp=0.;
1350  double Sep=0.;
1351  double deta(0),dphi(0);
1352  // compute (phi-corrected) covariance matrix:
1353  for(unsigned int i=0; i<nCry; i++) {
1354  if(isBarrel) {
1355  deta = etaDetId[i]-mid_eta;
1356  dphi = phiDetId[i]-mid_phi;
1357  } else {
1358  deta = etaDetId[i]-mid_eta;
1359  float hitLocalR2 = (xDetId[i]-mid_x)*(xDetId[i]-mid_x)+(yDetId[i]-mid_y)*(yDetId[i]-mid_y);
1360  float hitR2 = xDetId[i]*xDetId[i]+yDetId[i]*yDetId[i];
1361  float meanR2 = mid_x*mid_x+mid_y*mid_y;
1362  float hitR = sqrt(hitR2);
1363  float meanR = sqrt(meanR2);
1364  float phi = acos((hitR2+meanR2-hitLocalR2)/(2*hitR*meanR));
1365  dphi = hitR*phi;
1366 
1367  }
1368  See += (wiDetId[i]* deta * deta) / denominator;
1369  Spp += phiCorrectionFactor*(wiDetId[i]* dphi * dphi) / denominator;
1370  Sep += sqrt(phiCorrectionFactor)*(wiDetId[i]*deta*dphi) / denominator;
1371  }
1372 
1373  Cluster2ndMoments returnMoments;
1374 
1375  // compute matrix eigenvalues:
1376  returnMoments.sMaj = ((See + Spp) + sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1377  returnMoments.sMin = ((See + Spp) - sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1378 
1379  returnMoments.alpha = atan( (See - Spp + sqrt( (Spp - See)*(Spp - See) + 4.*Sep*Sep )) / (2.*Sep));
1380 
1381  return returnMoments;
1382 
1383 }
bool isBarrel(GeomDetEnumerators::SubDetector m)
const DetId & detid() const
Definition: EcalRecHit.h:72
static float getIEta(const DetId &id)
static float getIPhi(const DetId &id)
T sqrt(T t)
Definition: SSEVec.h:18
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
static float getNormedIY(const DetId &id)
static float getSumEnergy(const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs_fracs)
static float getNormedIX(const DetId &id)
template<bool noZS>
static float EcalClusterToolsT< noZS >::computeWeight ( float  eRH,
float  energyTotal,
int  weightedPositionMethod 
)
staticprivate
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::covariances ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const CaloGeometry geometry,
float  w0 = 4.7 
)
static

Definition at line 789 of file EcalClusterTools.h.

References pfDeepCMVADiscriminatorsJetTags_cfi::denominator, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, PV3DBase< T, PVType, FrameType >::eta(), f, DivergingColor::frac, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), cmsBatch::log, SiStripPI::max, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), position, Geom::twoPi(), findQualityFiles::v, and w.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

790 {
791  float e_5x5 = e5x5( cluster, recHits, topology );
792  float covEtaEta, covEtaPhi, covPhiPhi;
793  if (e_5x5 >= 0.) {
794  //double w0_ = parameterMap_.find("W0")->second;
795  const std::vector< std::pair<DetId, float>>& v_id =cluster.hitsAndFractions();
796  math::XYZVector meanPosition = meanClusterPosition( cluster, recHits, topology, geometry );
797 
798  // now we can calculate the covariances
799  double numeratorEtaEta = 0;
800  double numeratorEtaPhi = 0;
801  double numeratorPhiPhi = 0;
802  double denominator = 0;
803 
804  DetId id = getMaximum( v_id, recHits ).first;
805  CaloRectangle rectangle{-2, 2, -2, 2};
806  for (auto const& detId : rectangle(id, *topology)) {
807  float frac=getFraction(v_id,detId);
808  float energy = recHitEnergy( detId, recHits )*frac;
809 
810  if ( energy <= 0 ) continue;
811 
812  const CaloSubdetectorGeometry* geo = geometry->getSubdetectorGeometry(detId);
813  GlobalPoint position = geo->getGeometry(detId)->getPosition();
814 
815  double dPhi = position.phi() - meanPosition.phi();
816  if (dPhi > + Geom::pi()) { dPhi = Geom::twoPi() - dPhi; }
817  if (dPhi < - Geom::pi()) { dPhi = Geom::twoPi() + dPhi; }
818 
819  double dEta = position.eta() - meanPosition.eta();
820  double w = 0.;
821  w = std::max(0.0f, w0 + std::log( energy / e_5x5 ));
822 
823  denominator += w;
824  numeratorEtaEta += w * dEta * dEta;
825  numeratorEtaPhi += w * dEta * dPhi;
826  numeratorPhiPhi += w * dPhi * dPhi;
827  }
828 
829  if (denominator != 0.0) {
830  covEtaEta = numeratorEtaEta / denominator;
831  covEtaPhi = numeratorEtaPhi / denominator;
832  covPhiPhi = numeratorPhiPhi / denominator;
833  } else {
834  covEtaEta = 999.9;
835  covEtaPhi = 999.9;
836  covPhiPhi = 999.9;
837  }
838 
839  } else {
840  // Warn the user if there was no energy in the cells and return zeroes.
841  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
842  covEtaEta = 0;
843  covEtaPhi = 0;
844  covPhiPhi = 0;
845  }
846  std::vector<float> v;
847  v.push_back( covEtaEta );
848  v.push_back( covEtaPhi );
849  v.push_back( covPhiPhi );
850  return v;
851 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
static math::XYZVector meanClusterPosition(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry)
const double w
Definition: UKUtility.cc:23
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
double f[11][100]
static float getFraction(const std::vector< std::pair< DetId, float > > &v_id, DetId id)
Definition: DetId.h:18
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
T eta() const
Definition: PV3DBase.h:76
static int position[264][3]
Definition: ReadPGInfo.cc:509
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
template<bool noZS>
int EcalClusterToolsT< noZS >::deltaIEta ( int  seed_ieta,
int  rh_ieta 
)
staticprivate

Definition at line 1622 of file EcalClusterTools.h.

1622  {
1623  // get rid of the fact that there is no ieta=0
1624  if(seed_ieta < 0) seed_ieta++;
1625  if(rh_ieta < 0) rh_ieta++;
1626  int rel_ieta = rh_ieta - seed_ieta;
1627  return rel_ieta;
1628 }
template<bool noZS>
int EcalClusterToolsT< noZS >::deltaIPhi ( int  seed_iphi,
int  rh_iphi 
)
staticprivate

Definition at line 1610 of file EcalClusterTools.h.

1610  {
1611  int rel_iphi = rh_iphi - seed_iphi;
1612  // take care of cyclic variable iphi [1,360]
1613  if(rel_iphi > 180) rel_iphi = rel_iphi - 360;
1614  if(rel_iphi < -180) rel_iphi = rel_iphi + 360;
1615  return rel_iphi;
1616 }
template<bool noZS>
float EcalClusterToolsT< noZS >::e1x3 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 503 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection().

504 {
505  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
506  return matrixEnergy( cluster, recHits, topology, id, {0, 0, -1, 1} );
507 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e1x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 489 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

490 {
491  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
492  return matrixEnergy( cluster, recHits, topology, id, {0, 0, -2, 2} );
493 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2nd ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 429 of file EcalClusterTools.h.

References plotBeamSpotDB::first, mps_fire::i, and edm::second().

Referenced by GEDPhotonProducer::fillPhotonCollection().

430 {
431  std::vector<float> energies;
432  const std::vector< std::pair<DetId, float> >& v_id = cluster.hitsAndFractions();
433  energies.reserve( v_id.size() );
434  if ( v_id.size() < 2 ) return 0;
435  for ( size_t i = 0; i < v_id.size(); ++i ) {
436  energies.push_back( recHitEnergy( v_id[i].first, recHits ) * (noZS ? 1.0 : v_id[i].second) );
437  }
438  std::partial_sort( energies.begin(), energies.begin()+2, energies.end(), std::greater<float>() );
439  return energies[1];
440 }
U second(std::pair< T, U > const &p)
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x2 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 368 of file EcalClusterTools.h.

References plotBeamSpotDB::first, and SiStripPI::max.

Referenced by GEDPhotonProducer::fillPhotonCollection().

369 {
370  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
371  std::list<float> energies;
372  float max_E = matrixEnergy( cluster, recHits, topology, id, {-1, 0, -1, 0} );
373  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-1, 0, 0, 1} ) );
374  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, { 0, 1, 0, 1} ) );
375  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, { 0, 1, -1, 0} ) );
376  return max_E;
377 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x5Bottom ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 464 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection(), and EG8XObjectUpdateModifier::modifyObject().

465 {
466  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
467  return matrixEnergy( cluster, recHits, topology, id, {-2, 2, -2, -1} );
468 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x5Left ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 450 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection(), and EG8XObjectUpdateModifier::modifyObject().

451 {
452  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
453  return matrixEnergy( cluster, recHits, topology, id, {-2, -1, -2, 2} );
454 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x5Max ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 473 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

474 {
475  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
476 
477  // 1x5 strip left of seed
478  float left = matrixEnergy( cluster, recHits, topology, id, {-1, -1, -2, 2} );
479  // 1x5 strip right of seed
480  float right = matrixEnergy( cluster, recHits, topology, id, {1, 1, -2, 2} );
481  // 1x5 strip containing seed
482  float centre = matrixEnergy( cluster, recHits, topology, id, {0, 0, -2, 2} );
483 
484  // Return the maximum of (left+center) or (right+center) strip
485  return left > right ? left+centre : right+centre;
486 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x5Right ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 443 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection(), and EG8XObjectUpdateModifier::modifyObject().

444 {
445  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
446  return matrixEnergy( cluster, recHits, topology, id, {1, 2, -2, 2} );
447 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e2x5Top ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 457 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection(), and EG8XObjectUpdateModifier::modifyObject().

458 {
459  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
460  return matrixEnergy( cluster, recHits, topology, id, {-2, 2, 1, 2} );
461 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e3x1 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 510 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

511 {
512  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
513  return matrixEnergy( cluster, recHits, topology, id, {-1, 1, 0, 0} );
514 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e3x2 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 380 of file EcalClusterTools.h.

References plotBeamSpotDB::first, and SiStripPI::max.

381 {
382  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
383  float max_E = matrixEnergy( cluster, recHits, topology, id, {-1, 1, -1, 0} );
384  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {0, 1, -1, 1} ) );
385  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-1, 1, 0, 1} ) );
386  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-1, 0, -1, 1} ) );
387  return max_E;
388 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e3x3 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 391 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

392 {
393  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
394  return matrixEnergy( cluster, recHits, topology, id, {-1, 1, -1, 1} );
395 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e4x4 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 398 of file EcalClusterTools.h.

References plotBeamSpotDB::first, and SiStripPI::max.

399 {
400  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
401  float max_E = matrixEnergy( cluster, recHits, topology, id, {-1, 2, -2, 1} );
402  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-2, 1, -2, 1} ) );
403  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-2, 1, -1, 2} ) );
404  max_E = std::max( max_E, matrixEnergy( cluster, recHits, topology, id, {-1, 2, -1, 2} ) );
405  return max_E;
406 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e5x1 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 496 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

497 {
498  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
499  return matrixEnergy( cluster, recHits, topology, id, {-2, 2, 0, 0} );
500 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::e5x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 409 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

410 {
411  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
412  return matrixEnergy( cluster, recHits, topology, id, {-2, 2, -2, 2} );
413 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::eBottom ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 538 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection().

539 {
540  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
541  return matrixEnergy( cluster, recHits, topology, id, {0, 0, -1, -1} );
542 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::eLeft ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 517 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection().

518 {
519  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
520  return matrixEnergy( cluster, recHits, topology, id, {-1, -1, 0, 0} );
521 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::eMax ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 423 of file EcalClusterTools.h.

References edm::second().

Referenced by PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

424 {
425  return getMaximum( cluster.hitsAndFractions(), recHits ).second;
426 }
U second(std::pair< T, U > const &p)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::energyBasketFractionEta ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 545 of file EcalClusterTools.h.

References EcalBarrel, plotBeamSpotDB::first, mps_fire::i, EBDetId::im(), EBDetId::kModulesPerSM, EBDetId::positiveZ(), and jetUpdater_cfi::sort.

546 {
547  std::vector<float> basketFraction( 2 * EBDetId::kModulesPerSM );
548  float clusterEnergy = cluster.energy();
549  const std::vector< std::pair<DetId, float> >& v_id = cluster.hitsAndFractions();
550  if ( v_id[0].first.subdetId() != EcalBarrel ) {
551  edm::LogWarning("EcalClusterToolsT<noZS>::energyBasketFractionEta") << "Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
552  return basketFraction;
553  }
554  for ( size_t i = 0; i < v_id.size(); ++i ) {
555  basketFraction[ EBDetId(v_id[i].first).im()-1 + EBDetId(v_id[i].first).positiveZ()*EBDetId::kModulesPerSM ] += recHitEnergy( v_id[i].first, recHits ) * v_id[i].second / clusterEnergy;
556  }
557  std::sort( basketFraction.rbegin(), basketFraction.rend() );
558  return basketFraction;
559 }
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.h:64
static const int kModulesPerSM
Definition: EBDetId.h:140
bool positiveZ() const
Definition: EBDetId.h:76
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::energyBasketFractionPhi ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 562 of file EcalClusterTools.h.

References EcalBarrel, plotBeamSpotDB::first, mps_fire::i, EBDetId::iphi(), EBDetId::kCrystalsInPhi, EBDetId::kTowersInPhi, EBDetId::MAX_IPHI, EBDetId::positiveZ(), and jetUpdater_cfi::sort.

563 {
564  std::vector<float> basketFraction( 2 * (EBDetId::MAX_IPHI / EBDetId::kCrystalsInPhi) );
565  float clusterEnergy = cluster.energy();
566  const std::vector< std::pair<DetId, float> >& v_id = cluster.hitsAndFractions();
567  if ( v_id[0].first.subdetId() != EcalBarrel ) {
568  edm::LogWarning("EcalClusterToolsT<noZS>::energyBasketFractionPhi") << "Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
569  return basketFraction;
570  }
571  for ( size_t i = 0; i < v_id.size(); ++i ) {
572  basketFraction[ (EBDetId(v_id[i].first).iphi()-1)/EBDetId::kCrystalsInPhi + EBDetId(v_id[i].first).positiveZ()*EBDetId::kTowersInPhi] += recHitEnergy( v_id[i].first, recHits ) * (noZS ? 1.0 : v_id[i].second) / clusterEnergy;
573  }
574  std::sort( basketFraction.rbegin(), basketFraction.rend() );
575  return basketFraction;
576 }
static const int kTowersInPhi
Definition: EBDetId.h:139
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
static const int kCrystalsInPhi
Definition: EBDetId.h:142
bool positiveZ() const
Definition: EBDetId.h:76
static const int MAX_IPHI
Definition: EBDetId.h:137
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
float EcalClusterToolsT< noZS >::eRight ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 524 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection().

525 {
526  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
527  return matrixEnergy( cluster, recHits, topology, id, {1, 1, 0, 0} );
528 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
float EcalClusterToolsT< noZS >::eTop ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 531 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

Referenced by GEDPhotonProducer::fillPhotonCollection().

532 {
533  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
534  return matrixEnergy( cluster, recHits, topology, id, {0, 0, 1, 1} );
535 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
Definition: DetId.h:18
template<bool noZS>
static double EcalClusterToolsT< noZS >::f00 ( double  r)
inlinestaticprivate

Definition at line 215 of file EcalClusterTools.h.

215 { return 1; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f11 ( double  r)
inlinestaticprivate

Definition at line 216 of file EcalClusterTools.h.

References alignCSCRings::r.

216 { return r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f20 ( double  r)
inlinestaticprivate

Definition at line 217 of file EcalClusterTools.h.

217 { return 2.0*r*r-1.0; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f22 ( double  r)
inlinestaticprivate

Definition at line 218 of file EcalClusterTools.h.

References alignCSCRings::r.

218 { return r*r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f31 ( double  r)
inlinestaticprivate

Definition at line 219 of file EcalClusterTools.h.

References alignCSCRings::r.

219 { return 3.0*r*r*r - 2.0*r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f33 ( double  r)
inlinestaticprivate

Definition at line 220 of file EcalClusterTools.h.

References alignCSCRings::r.

220 { return r*r*r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f40 ( double  r)
inlinestaticprivate

Definition at line 221 of file EcalClusterTools.h.

221 { return 6.0*r*r*r*r-6.0*r*r+1.0; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f42 ( double  r)
inlinestaticprivate

Definition at line 222 of file EcalClusterTools.h.

References alignCSCRings::r.

222 { return 4.0*r*r*r*r-3.0*r*r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f44 ( double  r)
inlinestaticprivate

Definition at line 223 of file EcalClusterTools.h.

References alignCSCRings::r.

223 { return r*r*r*r; }
template<bool noZS>
static double EcalClusterToolsT< noZS >::f51 ( double  r)
inlinestaticprivate

Definition at line 224 of file EcalClusterTools.h.

References funct::pow(), and alignCSCRings::r.

224 { return 10.0*pow(r,5)-12.0*pow(r,3)+3.0*r; }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<bool noZS>
static double EcalClusterToolsT< noZS >::f53 ( double  r)
inlinestaticprivate

Definition at line 225 of file EcalClusterTools.h.

References funct::pow().

225 { return 5.0*pow(r,5) - 4.0*pow(r,3); }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<bool noZS>
static double EcalClusterToolsT< noZS >::f55 ( double  r)
inlinestaticprivate

Definition at line 226 of file EcalClusterTools.h.

References funct::m, gen::n, funct::pow(), and pfBoostedDoubleSVAK8TagInfos_cfi::R0.

226 { return pow(r,5); }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<bool noZS>
static double EcalClusterToolsT< noZS >::factorial ( int  n)
inlinestaticprivate

Definition at line 232 of file EcalClusterTools.h.

References mps_fire::i, and gen::n.

232  {
233  double res = 1.;
234  for (int i = 2; i <= n; ++i) res *= i;
235  return res;
236  }
Definition: Electron.h:6
template<bool noZS>
double EcalClusterToolsT< noZS >::fast_AbsZernikeMoment ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
int  n,
int  m,
double  R0,
bool  logW,
float  w0 
)
staticprivate

Definition at line 960 of file EcalClusterTools.h.

References funct::cos(), MillePedeFileConverter_cfg::e, mps_fire::i, phi, alignCSCRings::r, pfBoostedDoubleSVAK8TagInfos_cfi::R0, funct::sin(), and mathSSE::sqrt().

961 {
962  double r,ph,e,Re=0,Im=0;
963  double TotalEnergy = cluster.energy();
964  int index = (n/2)*(n/2)+(n/2)+m;
965  std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
966  int clusterSize = energyDistribution.size();
967  if(clusterSize < 3) return 0.0;
968 
969  for (int i=0; i<clusterSize; i++)
970  {
971  r = energyDistribution[i].r / R0;
972  if (r<1) {
973  std::vector<double> pol;
974  pol.push_back( f00(r) );
975  pol.push_back( f11(r) );
976  pol.push_back( f20(r) );
977  pol.push_back( f22(r) );
978  pol.push_back( f31(r) );
979  pol.push_back( f33(r) );
980  pol.push_back( f40(r) );
981  pol.push_back( f42(r) );
982  pol.push_back( f44(r) );
983  pol.push_back( f51(r) );
984  pol.push_back( f53(r) );
985  pol.push_back( f55(r) );
986  ph = (energyDistribution[i]).phi;
987  e = energyDistribution[i].deposited_energy;
988  Re = Re + e/TotalEnergy * pol[index] * cos( (double) m * ph);
989  Im = Im - e/TotalEnergy * pol[index] * sin( (double) m * ph);
990  }
991  }
992  return sqrt(Re*Re+Im*Im);
993 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static double f33(double r)
static double f11(double r)
static std::vector< EcalClusterEnergyDeposition > getEnergyDepTopology(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW, float w0)
static double f55(double r)
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static double f40(double r)
static double f31(double r)
static double f44(double r)
static double f00(double r)
static double f53(double r)
static double f42(double r)
static double f51(double r)
static double f20(double r)
static double f22(double r)
template<bool noZS>
float EcalClusterToolsT< noZS >::getDPhiEndcap ( const DetId crysId,
float  meanX,
float  meanY 
)
staticprivate

Definition at line 1129 of file EcalClusterTools.h.

References particleFlow_cfi::dPhi, phi, mathSSE::sqrt(), and tmp.

1130 {
1131  float iXNorm = getNormedIX(crysId);
1132  float iYNorm = getNormedIY(crysId);
1133 
1134  float hitLocalR2 = (iXNorm-meanX)*(iXNorm-meanX)+(iYNorm-meanY)*(iYNorm-meanY);
1135  float hitR2 = iXNorm*iXNorm+iYNorm*iYNorm;
1136  float meanR2 = meanX*meanX+meanY*meanY;
1137  float hitR = sqrt(hitR2);
1138  float meanR = sqrt(meanR2);
1139 
1140  float tmp = (hitR2+meanR2-hitLocalR2)/(2*hitR*meanR);
1141  if (tmp<-1) tmp =-1;
1142  if (tmp>1) tmp=1;
1143  float phi = acos(tmp);
1144  float dPhi = hitR*phi;
1145 
1146  return dPhi;
1147 }
T sqrt(T t)
Definition: SSEVec.h:18
static float getNormedIY(const DetId &id)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static float getNormedIX(const DetId &id)
template<bool noZS>
std::vector< typename EcalClusterToolsT< noZS >::EcalClusterEnergyDeposition > EcalClusterToolsT< noZS >::getEnergyDepTopology ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
bool  logW,
float  w0 
)
staticprivate

Definition at line 579 of file EcalClusterTools.h.

References funct::abs(), EcalClusterToolsT< noZS >::EcalClusterEnergyDeposition::deposited_energy, diffTreeTool::diff, edm::SortedCollection< T, SORT >::end(), EcalRecHit::energy(), edm::SortedCollection< T, SORT >::find(), CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), cmsBatch::log, LogDebug, M_PI, SiStripPI::max, EcalClusterToolsT< noZS >::EcalClusterEnergyDeposition::phi, EcalClusterToolsT< noZS >::EcalClusterEnergyDeposition::r, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

580 {
581  std::vector<typename EcalClusterToolsT<noZS>::EcalClusterEnergyDeposition> energyDistribution;
582  // init a map of the energy deposition centered on the
583  // cluster centroid. This is for momenta calculation only.
584  CLHEP::Hep3Vector clVect(cluster.position().x(), cluster.position().y(), cluster.position().z());
585  CLHEP::Hep3Vector clDir(clVect);
586  clDir*=1.0/clDir.mag();
587  // in the transverse plane, axis perpendicular to clusterDir
588  CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
589  theta_axis *= 1.0/theta_axis.mag();
590  CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
591 
592  const std::vector< std::pair<DetId, float> >& clusterDetIds = cluster.hitsAndFractions();
593 
595  EcalRecHit testEcalRecHit;
596  std::vector< std::pair<DetId, float> >::const_iterator posCurrent;
597  // loop over crystals
598  for(posCurrent=clusterDetIds.begin(); posCurrent!=clusterDetIds.end(); ++posCurrent) {
599  EcalRecHitCollection::const_iterator itt = recHits->find( (*posCurrent).first );
600  testEcalRecHit=*itt;
601 
602  if(( (*posCurrent).first != DetId(0)) && (recHits->find( (*posCurrent).first ) != recHits->end())) {
603  clEdep.deposited_energy = testEcalRecHit.energy() * (noZS ? 1.0 : (*posCurrent).second);
604  // if logarithmic weight is requested, apply cut on minimum energy of the recHit
605  if(logW) {
606  //double w0 = parameterMap_.find("W0")->second;
607 
608  double weight = std::max(0.0, w0 + log(std::abs(clEdep.deposited_energy)/cluster.energy()) );
609  if(weight==0) {
610  LogDebug("ClusterShapeAlgo") << "Crystal has insufficient energy: E = "
611  << clEdep.deposited_energy << " GeV; skipping... ";
612  continue;
613  }
614  else LogDebug("ClusterShapeAlgo") << "===> got crystal. Energy = " << clEdep.deposited_energy << " GeV. ";
615  }
616  DetId id_ = (*posCurrent).first;
617  const CaloSubdetectorGeometry* geo = geometry->getSubdetectorGeometry(id_);
618  auto this_cell = geo->getGeometry(id_);
619  const GlobalPoint& cellPos = this_cell->getPosition();
620  CLHEP::Hep3Vector gblPos (cellPos.x(),cellPos.y(),cellPos.z()); //surface position?
621  // Evaluate the distance from the cluster centroid
622  CLHEP::Hep3Vector diff = gblPos - clVect;
623  // Important: for the moment calculation, only the "lateral distance" is important
624  // "lateral distance" r_i = distance of the digi position from the axis Origin-Cluster Center
625  // ---> subtract the projection on clDir
626  CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
627  clEdep.r = DigiVect.mag();
628  LogDebug("ClusterShapeAlgo") << "E = " << clEdep.deposited_energy
629  << "\tdiff = " << diff.mag()
630  << "\tr = " << clEdep.r;
631  clEdep.phi = DigiVect.angle(theta_axis);
632  if(DigiVect.dot(phi_axis)<0) clEdep.phi = 2 * M_PI - clEdep.phi;
633  energyDistribution.push_back(clEdep);
634  }
635  }
636  return energyDistribution;
637 }
#define LogDebug(id)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
std::vector< EcalRecHit >::const_iterator const_iterator
T y() const
Definition: PV3DBase.h:63
Definition: weight.py:1
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
#define M_PI
const_iterator end() const
Definition: DetId.h:18
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
iterator find(key_type k)
T x() const
Definition: PV3DBase.h:62
template<bool noZS>
float EcalClusterToolsT< noZS >::getFraction ( const std::vector< std::pair< DetId, float > > &  v_id,
DetId  id 
)
static

Definition at line 259 of file EcalClusterTools.h.

References plotBeamSpotDB::first, DivergingColor::frac, and mps_fire::i.

260 {
261  if(noZS) return 1.0;
262  float frac = 0.0;
263  for ( size_t i = 0; i < v_id.size(); ++i ) {
264  if(v_id[i].first.rawId()==id.rawId()){
265  frac= v_id[i].second;
266  break;
267  }
268  }
269  return frac;
270 }
template<bool noZS>
float EcalClusterToolsT< noZS >::getIEta ( const DetId id)
staticprivate

Definition at line 1030 of file EcalClusterTools.h.

References DetId::Ecal, EcalBarrel, EcalEndcap, EBDetId::ieta(), and mathSSE::sqrt().

1031 {
1032  if(id.det()==DetId::Ecal){
1033  if(id.subdetId()==EcalBarrel){
1034  EBDetId ebId(id);
1035  return ebId.ieta();
1036  }else if(id.subdetId()==EcalEndcap){
1037  float iXNorm = getNormedIX(id);
1038  float iYNorm = getNormedIY(id);
1039 
1040  return std::sqrt(iXNorm*iXNorm+iYNorm*iYNorm);
1041  }
1042  }
1043  return 0.;
1044 }
T sqrt(T t)
Definition: SSEVec.h:18
static float getNormedIY(const DetId &id)
static float getNormedIX(const DetId &id)
template<bool noZS>
float EcalClusterToolsT< noZS >::getIPhi ( const DetId id)
staticprivate

Definition at line 1052 of file EcalClusterTools.h.

References DetId::Ecal, EcalBarrel, and EBDetId::iphi().

1053 {
1054  if(id.det()==DetId::Ecal){
1055  if(id.subdetId()==EcalBarrel){
1056  EBDetId ebId(id);
1057  return ebId.iphi();
1058  }
1059  }
1060  return 0.;
1061 }
template<bool noZS>
std::pair< DetId, float > EcalClusterToolsT< noZS >::getMaximum ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 288 of file EcalClusterTools.h.

289 {
290  return getMaximum( cluster.hitsAndFractions(), recHits );
291 }
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
template<bool noZS>
std::pair< DetId, float > EcalClusterToolsT< noZS >::getMaximum ( const std::vector< std::pair< DetId, float > > &  v_id,
const EcalRecHitCollection recHits 
)
static

Definition at line 273 of file EcalClusterTools.h.

References plotBeamSpotDB::first, mps_fire::i, triggerObjects_cff::id, and SiStripPI::max.

274 {
275  float max = 0;
276  DetId id(0);
277  for ( size_t i = 0; i < v_id.size(); ++i ) {
278  float energy = recHitEnergy( v_id[i].first, recHits ) * (noZS ? 1.0 : v_id[i].second);
279  if ( energy > max ) {
280  max = energy;
281  id = v_id[i].first;
282  }
283  }
284  return std::pair<DetId, float>(id, max);
285 }
Definition: DetId.h:18
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
float EcalClusterToolsT< noZS >::getNormedIX ( const DetId id)
staticprivate

Definition at line 1065 of file EcalClusterTools.h.

References DetId::Ecal, EcalEndcap, and EEDetId::ix().

1066 {
1067  if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
1068  EEDetId eeId(id);
1069  int iXNorm = eeId.ix()-50;
1070  if(iXNorm<=0) iXNorm--;
1071  return iXNorm;
1072  }
1073  return 0;
1074 }
template<bool noZS>
float EcalClusterToolsT< noZS >::getNormedIY ( const DetId id)
staticprivate

Definition at line 1078 of file EcalClusterTools.h.

References DetId::Ecal, EcalEndcap, and EEDetId::iy().

1079 {
1080  if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
1081  EEDetId eeId(id);
1082  int iYNorm = eeId.iy()-50;
1083  if(iYNorm<=0) iYNorm--;
1084  return iYNorm;
1085  }
1086  return 0;
1087 }
template<bool noZS>
float EcalClusterToolsT< noZS >::getNrCrysDiffInEta ( const DetId crysId,
const DetId orginId 
)
staticprivate

Definition at line 1091 of file EcalClusterTools.h.

References EcalBarrel, GeomDetEnumerators::isBarrel(), and DetId::subdetId().

1092 {
1093  float crysIEta = getIEta(crysId);
1094  float orginIEta = getIEta(orginId);
1095  bool isBarrel = orginId.subdetId()==EcalBarrel;
1096 
1097  float nrCrysDiff = crysIEta-orginIEta;
1098 
1099  //no iEta=0 in barrel, so if go from positive to negative
1100  //need to reduce abs(detEta) by 1
1101  if(isBarrel){
1102  if(crysIEta*orginIEta<0){ // -1 to 1 transition
1103  if(crysIEta>0) nrCrysDiff--;
1104  else nrCrysDiff++;
1105  }
1106  }
1107  return nrCrysDiff;
1108 }
bool isBarrel(GeomDetEnumerators::SubDetector m)
static float getIEta(const DetId &id)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
template<bool noZS>
float EcalClusterToolsT< noZS >::getNrCrysDiffInPhi ( const DetId crysId,
const DetId orginId 
)
staticprivate

Definition at line 1112 of file EcalClusterTools.h.

References EcalBarrel, GeomDetEnumerators::isBarrel(), and DetId::subdetId().

1113 {
1114  float crysIPhi = getIPhi(crysId);
1115  float orginIPhi = getIPhi(orginId);
1116  bool isBarrel = orginId.subdetId()==EcalBarrel;
1117 
1118  float nrCrysDiff = crysIPhi-orginIPhi;
1119 
1120  if(isBarrel){ //if barrel, need to map into 0-180
1121  if (nrCrysDiff > + 180) { nrCrysDiff = nrCrysDiff - 360; }
1122  if (nrCrysDiff < - 180) { nrCrysDiff = nrCrysDiff + 360; }
1123  }
1124  return nrCrysDiff;
1125 }
bool isBarrel(GeomDetEnumerators::SubDetector m)
static float getIPhi(const DetId &id)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
template<bool noZS>
std::vector< int > EcalClusterToolsT< noZS >::getSeedPosition ( const std::vector< std::pair< const EcalRecHit *, float > > &  RH_ptrs)
staticprivate

Definition at line 1632 of file EcalClusterTools.h.

References EcalRecHit::detid(), and EcalRecHit::energy().

Referenced by EcalClusterToolsT< noZS >::roundnessBarrelSuperClustersUserExtended(), and EcalClusterToolsT< noZS >::roundnessSelectedBarrelRecHits().

1632  {
1633  std::vector<int> seedPosition;
1634  float eSeedRH = 0;
1635  int iEtaSeedRH = 0;
1636  int iPhiSeedRH = 0;
1637 
1638  for(auto const& rhf : RH_ptrs_fracs) {
1639  const EcalRecHit* rh_ptr = rhf.first;
1640  //get iEta, iPhi
1641  EBDetId EBdetIdi( rh_ptr->detid() );
1642  float rh_energy = rh_ptr->energy() * (noZS ? 1.0 : rhf.second);
1643 
1644  if(eSeedRH < rh_energy){
1645  eSeedRH = rh_energy;
1646  iEtaSeedRH = EBdetIdi.ieta();
1647  iPhiSeedRH = EBdetIdi.iphi();
1648  }
1649 
1650  }// for loop
1651 
1652  seedPosition.push_back(iEtaSeedRH);
1653  seedPosition.push_back(iPhiSeedRH);
1654  return seedPosition;
1655 }
const DetId & detid() const
Definition: EcalRecHit.h:72
float energy() const
Definition: EcalRecHit.h:68
template<bool noZS>
float EcalClusterToolsT< noZS >::getSumEnergy ( const std::vector< std::pair< const EcalRecHit *, float > > &  RH_ptrs_fracs)
staticprivate

Definition at line 1659 of file EcalClusterTools.h.

Referenced by EcalClusterToolsT< noZS >::cluster2ndMoments(), and EcalClusterToolsT< noZS >::roundnessSelectedBarrelRecHits().

1659  {
1660  float sumE = 0.;
1661  for( const auto& hAndF : RH_ptrs_fracs ) {
1662  sumE += hAndF.first->energy() * (noZS ? 1.0 : hAndF.second);
1663  }
1664  return sumE;
1665 }
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::lat ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
bool  logW = true,
float  w0 = 4.7 
)
static

Definition at line 640 of file EcalClusterTools.h.

References funct::cos(), mps_fire::i, gen::n, phi, alignCSCRings::r, funct::sin(), and tmp.

641 {
642  std::vector<EcalClusterToolsT::EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
643 
644  std::vector<float> lat;
645  double r, redmoment=0;
646  double phiRedmoment = 0 ;
647  double etaRedmoment = 0 ;
648  int n,n1,n2,tmp;
649  int clusterSize=energyDistribution.size();
650  float etaLat_, phiLat_, lat_;
651  if (clusterSize<3) {
652  etaLat_ = 0.0 ;
653  lat_ = 0.0;
654  lat.push_back(0.);
655  lat.push_back(0.);
656  lat.push_back(0.);
657  return lat;
658  }
659 
660  n1=0; n2=1;
661  if (energyDistribution[1].deposited_energy >
662  energyDistribution[0].deposited_energy)
663  {
664  tmp=n2; n2=n1; n1=tmp;
665  }
666  for (int i=2; i<clusterSize; i++) {
667  n=i;
668  if (energyDistribution[i].deposited_energy >
669  energyDistribution[n1].deposited_energy)
670  {
671  tmp = n2;
672  n2 = n1; n1 = i; n=tmp;
673  } else {
674  if (energyDistribution[i].deposited_energy >
675  energyDistribution[n2].deposited_energy)
676  {
677  tmp=n2; n2=i; n=tmp;
678  }
679  }
680 
681  r = energyDistribution[n].r;
682  redmoment += r*r* energyDistribution[n].deposited_energy;
683  double rphi = r * cos (energyDistribution[n].phi) ;
684  phiRedmoment += rphi * rphi * energyDistribution[n].deposited_energy;
685  double reta = r * sin (energyDistribution[n].phi) ;
686  etaRedmoment += reta * reta * energyDistribution[n].deposited_energy;
687  }
688  double e1 = energyDistribution[n1].deposited_energy;
689  double e2 = energyDistribution[n2].deposited_energy;
690 
691  lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
692  phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
693  etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));
694 
695  lat.push_back(etaLat_);
696  lat.push_back(phiLat_);
697  lat.push_back(lat_);
698  return lat;
699 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static std::vector< EcalClusterEnergyDeposition > getEnergyDepTopology(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW, float w0)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static std::vector< float > lat(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW=true, float w0=4.7)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::localCovariances ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
float  w0 = 4.7 
)
static

Definition at line 858 of file EcalClusterTools.h.

References pfDeepCMVADiscriminatorsJetTags_cfi::denominator, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, EcalBarrel, f, DivergingColor::frac, GeomDetEnumerators::isBarrel(), cmsBatch::log, SiStripPI::max, DetId::subdetId(), findQualityFiles::v, and w.

Referenced by GsfElectronFull5x5Filler::calculateShowerShape_full5x5(), PhotonProducer::fillPhotonCollection(), and GEDPhotonProducer::fillPhotonCollection().

859 {
860 
861  float e_5x5 = e5x5( cluster, recHits, topology );
862  float covEtaEta, covEtaPhi, covPhiPhi;
863 
864  if (e_5x5 >= 0.) {
865  //double w0_ = parameterMap_.find("W0")->second;
866  const std::vector< std::pair<DetId, float> >& v_id = cluster.hitsAndFractions();
867  std::pair<float,float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord( cluster, recHits, topology );
868  std::pair<float,float> mean5x5XYPos = mean5x5PositionInXY(cluster,recHits,topology);
869 
870  // now we can calculate the covariances
871  double numeratorEtaEta = 0;
872  double numeratorEtaPhi = 0;
873  double numeratorPhiPhi = 0;
874  double denominator = 0;
875 
876  //these allow us to scale the localCov by the crystal size
877  //so that the localCovs have the same average value as the normal covs
878  const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
879  const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap
880 
881  DetId seedId = getMaximum( v_id, recHits ).first;
882 
883  bool isBarrel=seedId.subdetId()==EcalBarrel;
884  const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
885 
886  CaloRectangle rectangle{-2, 2, -2, 2};
887  for (auto const& detId : rectangle(seedId, *topology)) {
888  float frac = getFraction(v_id,detId);
889  float energy = recHitEnergy( detId, recHits )*frac;
890  if ( energy <= 0 ) continue;
891 
892  float dEta = getNrCrysDiffInEta(detId,seedId) - mean5x5PosInNrCrysFromSeed.first;
893  float dPhi = 0;
894 
895  if(isBarrel) dPhi = getNrCrysDiffInPhi(detId,seedId) - mean5x5PosInNrCrysFromSeed.second;
896  else dPhi = getDPhiEndcap(detId,mean5x5XYPos.first,mean5x5XYPos.second);
897 
898 
899  double w = std::max(0.0f,w0 + std::log( energy / e_5x5 ));
900 
901  denominator += w;
902  numeratorEtaEta += w * dEta * dEta;
903  numeratorEtaPhi += w * dEta * dPhi;
904  numeratorPhiPhi += w * dPhi * dPhi;
905  }
906 
907 
908  //multiplying by crysSize to make the values compariable to normal covariances
909  if (denominator != 0.0) {
910  covEtaEta = crysSize*crysSize* numeratorEtaEta / denominator;
911  covEtaPhi = crysSize*crysSize* numeratorEtaPhi / denominator;
912  covPhiPhi = crysSize*crysSize* numeratorPhiPhi / denominator;
913  } else {
914  covEtaEta = 999.9;
915  covEtaPhi = 999.9;
916  covPhiPhi = 999.9;
917  }
918 
919 
920  } else {
921  // Warn the user if there was no energy in the cells and return zeroes.
922  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
923  covEtaEta = 0;
924  covEtaPhi = 0;
925  covPhiPhi = 0;
926  }
927  std::vector<float> v;
928  v.push_back( covEtaEta );
929  v.push_back( covEtaPhi );
930  v.push_back( covPhiPhi );
931  return v;
932 }
const double w
Definition: UKUtility.cc:23
bool isBarrel(GeomDetEnumerators::SubDetector m)
static float getDPhiEndcap(const DetId &crysId, float meanX, float meanY)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
double f[11][100]
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
static float getFraction(const std::vector< std::pair< DetId, float > > &v_id, DetId id)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
static std::pair< float, float > mean5x5PositionInXY(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:18
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static std::pair< float, float > mean5x5PositionInLocalCrysCoord(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
template<bool noZS>
std::vector< DetId > EcalClusterToolsT< noZS >::matrixDetId ( const CaloTopology topology,
DetId  id,
CaloRectangle  rectangle 
)
static

Definition at line 357 of file EcalClusterTools.h.

References findQualityFiles::v.

358 {
359  std::vector<DetId> v;
360  for (auto const& detId : rectangle(id, *topology)) {
361  if ( detId != DetId(0) ) v.push_back(detId);
362  }
363  return v;
364 }
Definition: DetId.h:18
template<bool noZS>
static std::vector<DetId> EcalClusterToolsT< noZS >::matrixDetId ( const CaloTopology topology,
DetId  id,
int  size 
)
inlinestatic

Definition at line 175 of file EcalClusterTools.h.

References findQualityFiles::size.

176  { return matrixDetId(topology, id, CaloRectangle{-size, size, -size, size}); }
size
Write out results.
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, CaloRectangle rectangle)
template<bool noZS>
float EcalClusterToolsT< noZS >::matrixEnergy ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
DetId  id,
CaloRectangle  rectangle 
)
static

Definition at line 330 of file EcalClusterTools.h.

331 {
332  float energy = 0;
333  auto const& vId = cluster.hitsAndFractions();
334 
335  for (auto const& detId : rectangle(id, *topology)) {
336  energy += recHitEnergy( detId, recHits ) * getFraction(vId, detId);
337  }
338 
339  return energy;
340 }
static float getFraction(const std::vector< std::pair< DetId, float > > &v_id, DetId id)
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
int EcalClusterToolsT< noZS >::matrixSize ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
DetId  id,
CaloRectangle  rectangle 
)
static

Definition at line 343 of file EcalClusterTools.h.

References DivergingColor::frac, and mps_fire::result.

344 {
345  int result = 0;
346 
347  for (auto const& detId : rectangle(id, *topology)) {
348  const float energy = recHitEnergy(detId, recHits);
349  const float frac = getFraction(cluster.hitsAndFractions(), detId);
350  if(energy * frac > 0) result++;
351  }
352  return result;
353 }
static float getFraction(const std::vector< std::pair< DetId, float > > &v_id, DetId id)
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
template<bool noZS>
std::pair< float, float > EcalClusterToolsT< noZS >::mean5x5PositionInLocalCrysCoord ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
staticprivate

Definition at line 729 of file EcalClusterTools.h.

References CastorDataFrameFilter_impl::energySum().

730 {
731  DetId seedId = getMaximum( cluster, recHits ).first;
732  float meanDEta=0.;
733  float meanDPhi=0.;
734  float energySum=0.;
735 
736  const std::vector<std::pair<DetId,float> >& hsAndFs = cluster.hitsAndFractions();
737  std::vector<DetId> v_id = matrixDetId( topology,seedId, 2 );
738  for( const std::pair<DetId,float>& hAndF : hsAndFs ) {
739  for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
740  if( hAndF.first != *it && !noZS ) continue;
741  float energy = recHitEnergy(*it,recHits) * hAndF.second;
742  if(energy<0.) continue;//skipping negative energy crystals
743  meanDEta += energy * getNrCrysDiffInEta(*it,seedId);
744  meanDPhi += energy * getNrCrysDiffInPhi(*it,seedId);
745  energySum +=energy;
746  }
747  if(noZS) break;
748  }
749  meanDEta /=energySum;
750  meanDPhi /=energySum;
751  return std::pair<float,float>(meanDEta,meanDPhi);
752 }
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
Definition: DetId.h:18
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
double energySum(const DataFrame &df, int fs, int ls)
template<bool noZS>
std::pair< float, float > EcalClusterToolsT< noZS >::mean5x5PositionInXY ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
staticprivate

Definition at line 761 of file EcalClusterTools.h.

References EcalBarrel, CastorDataFrameFilter_impl::energySum(), and DetId::subdetId().

762 {
763  DetId seedId = getMaximum( cluster, recHits ).first;
764 
765  std::pair<float,float> meanXY(0.,0.);
766  if(seedId.subdetId()==EcalBarrel) return meanXY;
767 
768  float energySum=0.;
769 
770  const std::vector<std::pair<DetId,float> >& hsAndFs = cluster.hitsAndFractions();
771  std::vector<DetId> v_id = matrixDetId( topology,seedId, 2);
772  for( const std::pair<DetId,float>& hAndF : hsAndFs ) {
773  for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
774  if( hAndF.first != *it && !noZS) continue;
775  float energy = recHitEnergy(*it,recHits) * hAndF.second;
776  if(energy<0.) continue;//skipping negative energy crystals
777  meanXY.first += energy * getNormedIX(*it);
778  meanXY.second += energy * getNormedIY(*it);
779  energySum +=energy;
780  }
781  if(noZS) break;
782  }
783  meanXY.first/=energySum;
784  meanXY.second/=energySum;
785  return meanXY;
786 }
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, CaloRectangle rectangle)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
static float getNormedIY(const DetId &id)
Definition: DetId.h:18
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
double energySum(const DataFrame &df, int fs, int ls)
static float getNormedIX(const DetId &id)
template<bool noZS>
math::XYZVector EcalClusterToolsT< noZS >::meanClusterPosition ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const CaloGeometry geometry 
)
staticprivate

Definition at line 702 of file EcalClusterTools.h.

References plotBeamSpotDB::first, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), position, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

703 {
704  // find mean energy position of a 5x5 cluster around the maximum
705  math::XYZVector meanPosition(0.0, 0.0, 0.0);
706  const std::vector<std::pair<DetId,float> >& hsAndFs = cluster.hitsAndFractions();
707  std::vector<DetId> v_id = matrixDetId( topology, getMaximum( cluster, recHits ).first, 2 );
708  for( const std::pair<DetId,float>& hitAndFrac : hsAndFs ) {
709  for( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
710  if( hitAndFrac.first != *it && !noZS) continue;
711  const CaloSubdetectorGeometry* geo = geometry->getSubdetectorGeometry(*it);
712  GlobalPoint positionGP = geo->getGeometry( *it )->getPosition();
713  math::XYZVector position(positionGP.x(),positionGP.y(),positionGP.z());
714  meanPosition = meanPosition + recHitEnergy( *it, recHits ) * position * hitAndFrac.second;
715  }
716  if(noZS) break;
717  }
718  return meanPosition / e5x5( cluster, recHits, topology );
719 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
T y() const
Definition: PV3DBase.h:63
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, CaloRectangle rectangle)
T z() const
Definition: PV3DBase.h:64
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static int position[264][3]
Definition: ReadPGInfo.cc:509
T x() const
Definition: PV3DBase.h:62
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
template<bool noZS>
int EcalClusterToolsT< noZS >::n5x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 416 of file EcalClusterTools.h.

References plotBeamSpotDB::first.

417 {
418  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
419  return matrixSize( cluster, recHits, topology, id, {-2, 2, -2, 2} );
420 }
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static int matrixSize(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, CaloRectangle rectangle)
Definition: DetId.h:18
template<bool noZS>
int EcalClusterToolsT< noZS >::nrSaturatedCrysIn5x5 ( const DetId id,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 1591 of file EcalClusterTools.h.

References edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), and EcalRecHit::kSaturated.

Referenced by ElectronHEEPIDValueMapProducer::nrSaturatedCrysIn5x5().

1592 {
1593  int nrSat=0;
1594  CaloRectangle rectangle{-2, 2, -2, 2};
1595  for (auto const& detId : rectangle(id, *topology)) {
1596  auto recHitIt = recHits->find(detId);
1597  if(recHitIt!=recHits->end() && recHitIt->checkFlag(EcalRecHit::kSaturated)) {
1598  nrSat++;
1599  }
1600  }
1601  return nrSat;
1602 }
const_iterator end() const
iterator find(key_type k)
template<bool noZS>
float EcalClusterToolsT< noZS >::recHitEnergy ( DetId  id,
const EcalRecHitCollection recHits 
)
static

Definition at line 295 of file EcalClusterTools.h.

References EcalBarrel, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), EcalRecHit::kDiWeird, EcalRecHit::kTowerRecovered, and EcalRecHit::kWeird.

296 {
297  if ( id == DetId(0) ) {
298  return 0;
299  } else {
300  EcalRecHitCollection::const_iterator it = recHits->find( id );
301  if ( it != recHits->end() ) {
302  if( noZS && ( it->checkFlag(EcalRecHit::kTowerRecovered) ||
303  it->checkFlag(EcalRecHit::kWeird) ||
304  (it->detid().subdetId() == EcalBarrel &&
305  it->checkFlag(EcalRecHit::kDiWeird) ))) return 0.0;
306  else return it->energy();
307  } else {
308  //throw cms::Exception("EcalRecHitNotFound") << "The recHit corresponding to the DetId" << id.rawId() << " not found in the EcalRecHitCollection";
309  // the recHit is not in the collection (hopefully zero suppressed)
310  return 0;
311  }
312  }
313  return 0;
314 }
std::vector< EcalRecHit >::const_iterator const_iterator
const_iterator end() const
Definition: DetId.h:18
iterator find(key_type k)
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::roundnessBarrelSuperClusters ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
int  weightedPositionMethod = 0,
float  energyThreshold = 0.0 
)
static

Definition at line 1393 of file EcalClusterTools.h.

References edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), plotBeamSpotDB::first, reco::CaloCluster::hitsAndFractions(), mps_fire::i, EcalClusterToolsT< noZS >::roundnessSelectedBarrelRecHits(), edm::second(), and groupFilesInBlocks::temp.

1393  {//int positionWeightingMethod=0){
1394  std::vector<std::pair<const EcalRecHit*, float> > RH_ptrs_fracs;
1395  const std::vector< std::pair<DetId, float> >& myHitsPair = superCluster.hitsAndFractions();
1396  for(unsigned int i=0; i< myHitsPair.size(); ++i){
1397  //get pointer to recHit object
1398  EcalRecHitCollection::const_iterator myRH = recHits.find(myHitsPair[i].first);
1399  if( myRH != recHits.end() && myRH->energy()*(noZS ? 1.0 : myHitsPair[i].second) > energyThreshold){
1400  //require rec hit to have positive energy
1401  RH_ptrs_fracs.push_back( std::make_pair(&(*myRH) , myHitsPair[i].second) );
1402  }
1403  }
1404  std::vector<float> temp = EcalClusterToolsT<noZS>::roundnessSelectedBarrelRecHits(RH_ptrs_fracs,weightedPositionMethod);
1405  return temp;
1406 }
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
U second(std::pair< T, U > const &p)
const_iterator end() const
static std::vector< float > roundnessSelectedBarrelRecHits(const std::vector< std::pair< const EcalRecHit *, float > > &rhVector, int weightedPositionMethod=0)
iterator find(key_type k)
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::roundnessBarrelSuperClustersUserExtended ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
int  ieta_delta = 0,
int  iphi_delta = 0,
float  energyRHThresh = 0.00000,
int  weightedPositionMethod = 0 
)
static

Definition at line 1413 of file EcalClusterTools.h.

References funct::abs(), edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), plotBeamSpotDB::first, EcalClusterToolsT< noZS >::getSeedPosition(), reco::CaloCluster::hitsAndFractions(), mps_fire::i, EcalClusterToolsT< noZS >::roundnessSelectedBarrelRecHits(), and edm::second().

1413  {
1414 
1415  std::vector<std::pair<const EcalRecHit*, float> > RH_ptrs_fracs;
1416  const std::vector< std::pair<DetId, float> >& myHitsPair = superCluster.hitsAndFractions();
1417  for(unsigned int i=0; i<myHitsPair.size(); ++i){
1418  //get pointer to recHit object
1419  EcalRecHitCollection::const_iterator myRH = recHits.find(myHitsPair[i].first);
1420  if(myRH != recHits.end() && myRH->energy()*(noZS ? 1.0 : myHitsPair[i].second) > energyRHThresh)
1421  RH_ptrs_fracs.push_back( std::make_pair(&(*myRH) , myHitsPair[i].second) );
1422  }
1423 
1424 
1425  std::vector<int> seedPosition = EcalClusterToolsT<noZS>::getSeedPosition( RH_ptrs_fracs );
1426 
1427  for(EcalRecHitCollection::const_iterator rh = recHits.begin(); rh != recHits.end(); rh++){
1428  EBDetId EBdetIdi( rh->detid() );
1429  float the_fraction = 0;
1430  //if(rh != recHits.end())
1431  bool inEtaWindow = ( abs( deltaIEta(seedPosition[0],EBdetIdi.ieta()) ) <= ieta_delta );
1432  bool inPhiWindow = ( abs( deltaIPhi(seedPosition[1],EBdetIdi.iphi()) ) <= iphi_delta );
1433  bool passEThresh = ( rh->energy() > energyRHThresh );
1434  bool alreadyCounted = false;
1435 
1436  // figure out if the rechit considered now is already inside the SC
1437  bool is_SCrh_inside_recHits = false;
1438  for(unsigned int i=0; i<myHitsPair.size(); i++){
1439  EcalRecHitCollection::const_iterator SCrh = recHits.find(myHitsPair[i].first);
1440  if(SCrh != recHits.end()){
1441  the_fraction = myHitsPair[i].second;
1442  is_SCrh_inside_recHits = true;
1443  if( rh->detid() == SCrh->detid() ) alreadyCounted = true;
1444  }
1445  }//for loop over SC's recHits
1446 
1447  if( is_SCrh_inside_recHits && !alreadyCounted && passEThresh && inEtaWindow && inPhiWindow){
1448  RH_ptrs_fracs.push_back( std::make_pair(&(*rh),the_fraction) );
1449  }
1450 
1451  }//for loop over rh
1452  return EcalClusterToolsT<noZS>::roundnessSelectedBarrelRecHits(RH_ptrs_fracs,weightedPositionMethod);
1453 }
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
static int deltaIEta(int seed_ieta, int rh_ieta)
static std::vector< int > getSeedPosition(const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs)
static int deltaIPhi(int seed_iphi, int rh_iphi)
U second(std::pair< T, U > const &p)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const_iterator end() const
static std::vector< float > roundnessSelectedBarrelRecHits(const std::vector< std::pair< const EcalRecHit *, float > > &rhVector, int weightedPositionMethod=0)
iterator find(key_type k)
const_iterator begin() const
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::roundnessSelectedBarrelRecHits ( const std::vector< std::pair< const EcalRecHit *, float > > &  rhVector,
int  weightedPositionMethod = 0 
)
static

Definition at line 1459 of file EcalClusterTools.h.

References funct::abs(), pfDeepCMVADiscriminatorsJetTags_cfi::denominator, EcalRecHit::detid(), EcalRecHit::energy(), EcalClusterToolsT< noZS >::getSeedPosition(), EcalClusterToolsT< noZS >::getSumEnergy(), mps_fire::i, cmsBatch::log, SiStripPI::max, groupFilesInBlocks::temp, and mps_merge::weight.

Referenced by EcalClusterToolsT< noZS >::roundnessBarrelSuperClusters(), and EcalClusterToolsT< noZS >::roundnessBarrelSuperClustersUserExtended().

1459  {//int weightedPositionMethod = 0){
1460  //positionWeightingMethod = 0 linear weighting, 1 log energy weighting
1461 
1462  std::vector<float> shapes; // this is the returning vector
1463 
1464  //make sure photon has more than one crystal; else roundness and angle suck
1465  if(RH_ptrs_fracs.size()<2){
1466  shapes.push_back( -3 );
1467  shapes.push_back( -3 );
1468  return shapes;
1469  }
1470 
1471  //Find highest E RH (Seed) and save info, compute sum total energy used
1472  std::vector<int> seedPosition = EcalClusterToolsT<noZS>::getSeedPosition( RH_ptrs_fracs );// *recHits);
1473  int tempInt = seedPosition[0];
1474  if(tempInt <0) tempInt++;
1475  float energyTotal = EcalClusterToolsT<noZS>::getSumEnergy( RH_ptrs_fracs );
1476 
1477  //1st loop over rechits: compute new weighted center position in coordinates centered on seed
1478  float centerIEta = 0.;
1479  float centerIPhi = 0.;
1480  float denominator = 0.;
1481 
1482  for(std::vector<std::pair<const EcalRecHit*,float> >::const_iterator rhf_ptr = RH_ptrs_fracs.begin(); rhf_ptr != RH_ptrs_fracs.end(); rhf_ptr++){
1483  const EcalRecHit* rh_ptr = rhf_ptr->first;
1484  //get iEta, iPhi
1485  EBDetId EBdetIdi( rh_ptr->detid() );
1486  if(fabs(energyTotal) < 0.0001){
1487  // don't /0, bad!
1488  shapes.push_back( -2 );
1489  shapes.push_back( -2 );
1490  return shapes;
1491  }
1492  float rh_energy = rh_ptr->energy() * (noZS ? 1.0 : rhf_ptr->second);
1493  float weight = 0;
1494  if(std::abs(weightedPositionMethod)<0.0001){ //linear
1495  weight = rh_energy/energyTotal;
1496  }else{ //logrithmic
1497  weight = std::max(0.0, 4.2 + log(rh_energy/energyTotal));
1498  }
1499  denominator += weight;
1500  centerIEta += weight*deltaIEta(seedPosition[0],EBdetIdi.ieta());
1501  centerIPhi += weight*deltaIPhi(seedPosition[1],EBdetIdi.iphi());
1502  }
1503  if(fabs(denominator) < 0.0001){
1504  // don't /0, bad!
1505  shapes.push_back( -2 );
1506  shapes.push_back( -2 );
1507  return shapes;
1508  }
1509  centerIEta = centerIEta / denominator;
1510  centerIPhi = centerIPhi / denominator;
1511 
1512 
1513  //2nd loop over rechits: compute inertia tensor
1514  TMatrixDSym inertia(2); //initialize 2d inertia tensor
1515  double inertia00 = 0.;
1516  double inertia01 = 0.;// = inertia10 b/c matrix should be symmetric
1517  double inertia11 = 0.;
1518  int i = 0;
1519  for(std::vector<std::pair<const EcalRecHit*,float> >::const_iterator rhf_ptr = RH_ptrs_fracs.begin(); rhf_ptr != RH_ptrs_fracs.end(); rhf_ptr++){
1520  const EcalRecHit* rh_ptr = rhf_ptr->first;
1521  //get iEta, iPhi
1522  EBDetId EBdetIdi( rh_ptr->detid() );
1523 
1524  if(fabs(energyTotal) < 0.0001){
1525  // don't /0, bad!
1526  shapes.push_back( -2 );
1527  shapes.push_back( -2 );
1528  return shapes;
1529  }
1530  float rh_energy = rh_ptr->energy() * (noZS ? 1.0 : rhf_ptr->second);
1531  float weight = 0;
1532  if(std::abs(weightedPositionMethod) < 0.0001){ //linear
1533  weight = rh_energy/energyTotal;
1534  }else{ //logrithmic
1535  weight = std::max(0.0, 4.2 + log(rh_energy/energyTotal));
1536  }
1537 
1538  float ieta_rh_to_center = deltaIEta(seedPosition[0],EBdetIdi.ieta()) - centerIEta;
1539  float iphi_rh_to_center = deltaIPhi(seedPosition[1],EBdetIdi.iphi()) - centerIPhi;
1540 
1541  inertia00 += weight*iphi_rh_to_center*iphi_rh_to_center;
1542  inertia01 -= weight*iphi_rh_to_center*ieta_rh_to_center;
1543  inertia11 += weight*ieta_rh_to_center*ieta_rh_to_center;
1544  i++;
1545  }
1546 
1547  inertia[0][0] = inertia00;
1548  inertia[0][1] = inertia01; // use same number here
1549  inertia[1][0] = inertia01; // and here to insure symmetry
1550  inertia[1][1] = inertia11;
1551 
1552 
1553  //step 1 find principal axes of inertia
1554  TMatrixD eVectors(2,2);
1555  TVectorD eValues(2);
1556  //std::cout<<"EcalClusterToolsT<noZS>::showerRoundness- about to compute eVectors"<<std::endl;
1557  eVectors=inertia.EigenVectors(eValues); //ordered highest eV to lowest eV (I checked!)
1558  //and eVectors are in columns of matrix! I checked!
1559  //and they are normalized to 1
1560 
1561 
1562 
1563  //step 2 select eta component of smaller eVal's eVector
1564  TVectorD smallerAxis(2);//easiest to spin SC on this axis (smallest eVal)
1565  smallerAxis[0]=eVectors[0][1];//row,col //eta component
1566  smallerAxis[1]=eVectors[1][1]; //phi component
1567 
1568  //step 3 compute interesting quatities
1569  Double_t temp = fabs(smallerAxis[0]);// closer to 1 ->beamhalo, closer to 0 something else
1570  if(fabs(eValues[0]) < 0.0001){
1571  // don't /0, bad!
1572  shapes.push_back( -2 );
1573  shapes.push_back( -2 );
1574  return shapes;
1575  }
1576 
1577  float Roundness = eValues[1]/eValues[0];
1578  float Angle=acos(temp);
1579 
1580  if( -0.00001 < Roundness && Roundness < 0) Roundness = 0.;
1581  if( -0.00001 < Angle && Angle < 0 ) Angle = 0.;
1582 
1583  shapes.push_back( Roundness );
1584  shapes.push_back( Angle );
1585  return shapes;
1586 
1587 }
const DetId & detid() const
Definition: EcalRecHit.h:72
Definition: weight.py:1
static int deltaIEta(int seed_ieta, int rh_ieta)
static std::vector< int > getSeedPosition(const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs)
static int deltaIPhi(int seed_iphi, int rh_iphi)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
Definition: EcalRecHit.h:68
static float getSumEnergy(const std::vector< std::pair< const EcalRecHit *, float > > &RH_ptrs_fracs)
Definition: Angle.h:17
template<bool noZS>
std::vector< float > EcalClusterToolsT< noZS >::scLocalCovariances ( const reco::SuperCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
float  w0 = 4.7 
)
static

Definition at line 1150 of file EcalClusterTools.h.

References pfDeepCMVADiscriminatorsJetTags_cfi::denominator, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, EcalBarrel, f, plotBeamSpotDB::first, DivergingColor::frac, reco::CaloCluster::hitsAndFractions(), mps_fire::i, GeomDetEnumerators::isBarrel(), cmsBatch::log, SiStripPI::max, reco::SuperCluster::seed(), DetId::subdetId(), findQualityFiles::v, and w.

1151 {
1152  const reco::BasicCluster bcluster = *(cluster.seed());
1153 
1154  float e_5x5 = e5x5(bcluster, recHits, topology);
1155  float covEtaEta, covEtaPhi, covPhiPhi;
1156 
1157  if (e_5x5 >= 0.) {
1158  const std::vector<std::pair<DetId, float> >& v_id = cluster.hitsAndFractions();
1159  std::pair<float,float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord(bcluster, recHits, topology);
1160  std::pair<float,float> mean5x5XYPos = mean5x5PositionInXY(cluster,recHits,topology);
1161  // now we can calculate the covariances
1162  double numeratorEtaEta = 0;
1163  double numeratorEtaPhi = 0;
1164  double numeratorPhiPhi = 0;
1165  double denominator = 0;
1166 
1167  const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
1168  const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap
1169 
1170  DetId seedId = getMaximum(v_id, recHits).first;
1171  bool isBarrel=seedId.subdetId()==EcalBarrel;
1172 
1173  const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
1174 
1175  for (size_t i = 0; i < v_id.size(); ++i) {
1176  float frac = getFraction(v_id, v_id[i].first);
1177  float energy = recHitEnergy(v_id[i].first, recHits)*frac;
1178 
1179  if (energy <= 0) continue;
1180 
1181  float dEta = getNrCrysDiffInEta(v_id[i].first,seedId) - mean5x5PosInNrCrysFromSeed.first;
1182  float dPhi = 0;
1183  if(isBarrel) dPhi = getNrCrysDiffInPhi(v_id[i].first,seedId) - mean5x5PosInNrCrysFromSeed.second;
1184  else dPhi = getDPhiEndcap(v_id[i].first,mean5x5XYPos.first,mean5x5XYPos.second);
1185 
1186 
1187 
1188  double w = 0.;
1189  w = std::max(0.0f, w0 + std::log( energy / e_5x5 ));
1190 
1191  denominator += w;
1192  numeratorEtaEta += w * dEta * dEta;
1193  numeratorEtaPhi += w * dEta * dPhi;
1194  numeratorPhiPhi += w * dPhi * dPhi;
1195  }
1196 
1197  //multiplying by crysSize to make the values compariable to normal covariances
1198  if (denominator != 0.0) {
1199  covEtaEta = crysSize*crysSize* numeratorEtaEta / denominator;
1200  covEtaPhi = crysSize*crysSize* numeratorEtaPhi / denominator;
1201  covPhiPhi = crysSize*crysSize* numeratorPhiPhi / denominator;
1202  } else {
1203  covEtaEta = 999.9;
1204  covEtaPhi = 999.9;
1205  covPhiPhi = 999.9;
1206  }
1207 
1208  } else {
1209  // Warn the user if there was no energy in the cells and return zeroes.
1210  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
1211  covEtaEta = 0;
1212  covEtaPhi = 0;
1213  covPhiPhi = 0;
1214  }
1215 
1216  std::vector<float> v;
1217  v.push_back( covEtaEta );
1218  v.push_back( covEtaPhi );
1219  v.push_back( covPhiPhi );
1220 
1221  return v;
1222 }
const double w
Definition: UKUtility.cc:23
bool isBarrel(GeomDetEnumerators::SubDetector m)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
static float getDPhiEndcap(const DetId &crysId, float meanX, float meanY)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
double f[11][100]
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
static float getFraction(const std::vector< std::pair< DetId, float > > &v_id, DetId id)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
static std::pair< float, float > mean5x5PositionInXY(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:18
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static std::pair< float, float > mean5x5PositionInLocalCrysCoord(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
template<bool noZS>
double EcalClusterToolsT< noZS >::zernike20 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
double  R0 = 6.6,
bool  logW = true,
float  w0 = 4.7 
)
static

Definition at line 935 of file EcalClusterTools.h.

936 {
937  return absZernikeMoment( cluster, recHits, geometry, 2, 0, R0, logW, w0 );
938 }
static double absZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
template<bool noZS>
double EcalClusterToolsT< noZS >::zernike42 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
double  R0 = 6.6,
bool  logW = true,
float  w0 = 4.7 
)
static

Definition at line 941 of file EcalClusterTools.h.

942 {
943  return absZernikeMoment( cluster, recHits, geometry, 4, 2, R0, logW, w0 );
944 }
static double absZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)