CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions
EcalClusterTools Class Reference

#include <EcalClusterTools.h>

Classes

struct  EcalClusterEnergyDeposition
 

Public Member Functions

 EcalClusterTools ()
 
 ~EcalClusterTools ()
 

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 (std::vector< const EcalRecHit * > RH_ptrs, 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 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, int ixMin, int ixMax, int iyMin, int iyMax)
 
static float matrixEnergy (const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
 
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 (std::vector< const EcalRecHit * >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
< EcalClusterEnergyDeposition
getEnergyDepTopology (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 (std::vector< const EcalRecHit * >RH_ptrs)
 
static float getSumEnergy (std::vector< const EcalRecHit * >RH_ptrs)
 
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

various cluster tools (e.g. cluster shapes)

Author
Federico Ferri

editing author: M.B. Anderson

Version
$Id:

Definition at line 46 of file EcalClusterTools.h.

Constructor & Destructor Documentation

EcalClusterTools::EcalClusterTools ( )
inline

Definition at line 48 of file EcalClusterTools.h.

48 {};
EcalClusterTools::~EcalClusterTools ( )
inline

Definition at line 49 of file EcalClusterTools.h.

49 {};

Member Function Documentation

double EcalClusterTools::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 706 of file EcalClusterTools.cc.

References calc_AbsZernikeMoment(), and fast_AbsZernikeMoment().

Referenced by zernike20(), and zernike42().

707 {
708  // 1. Check if n,m are correctly
709  if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0)) return -1;
710 
711  // 2. Check if n,R0 are within validity Range :
712  // n>20 or R0<2.19cm just makes no sense !
713  if ((n>20) || (R0<=2.19)) return -1;
714  if (n<=5) return fast_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, w0 );
715  else return calc_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, w0 );
716 }
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 double calc_AbsZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
double EcalClusterTools::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 756 of file EcalClusterTools.cc.

References funct::cos(), factorial(), getEnergyDepTopology(), i, m, funct::pow(), csvReporter::r, asciidump::s, funct::sin(), and mathSSE::sqrt().

Referenced by absZernikeMoment().

757 {
758  double r, ph, e, Re=0, Im=0, f_nm;
759  double TotalEnergy = cluster.energy();
760  std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
761  int clusterSize=energyDistribution.size();
762  if(clusterSize<3) return 0.0;
763 
764  for (int i = 0; i < clusterSize; ++i)
765  {
766  r = energyDistribution[i].r / R0;
767  if (r < 1) {
768  ph = energyDistribution[i].phi;
769  e = energyDistribution[i].deposited_energy;
770  f_nm = 0;
771  for (int s=0; s<=(n-m)/2; s++) {
772  if (s%2==0) {
773  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));
774  } else {
775  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));
776  }
777  }
778  Re = Re + e/TotalEnergy * f_nm * cos( (double) m*ph);
779  Im = Im - e/TotalEnergy * f_nm * sin( (double) m*ph);
780  }
781  }
782  return sqrt(Re*Re+Im*Im);
783 }
int i
Definition: DBlmapReader.cc:9
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:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static double factorial(int n)
string s
Definition: asciidump.py:422
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Cluster2ndMoments EcalClusterTools::cluster2ndMoments ( const reco::BasicCluster basicCluster,
const EcalRecHitCollection recHits,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 980 of file EcalClusterTools.cc.

References Cluster2ndMoments::alpha, edm::SortedCollection< T, SORT >::find(), first, i, Cluster2ndMoments::sMaj, and Cluster2ndMoments::sMin.

Referenced by cluster2ndMoments().

980  {
981 
982  Cluster2ndMoments returnMoments;
983  returnMoments.sMaj = -1.;
984  returnMoments.sMin = -1.;
985  returnMoments.alpha = 0.;
986 
987  // for now implemented only for EB:
988  if( fabs( basicCluster.eta() ) < 1.479 ) {
989 
990  std::vector<const EcalRecHit*> RH_ptrs;
991 
992  std::vector< std::pair<DetId, float> > myHitsPair = basicCluster.hitsAndFractions();
993  std::vector<DetId> usedCrystals;
994  for(unsigned int i=0; i< myHitsPair.size(); i++){
995  usedCrystals.push_back(myHitsPair[i].first);
996  }
997 
998  for(unsigned int i=0; i<usedCrystals.size(); i++){
999  //get pointer to recHit object
1000  EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
1001  RH_ptrs.push_back( &(*myRH) );
1002  }
1003 
1004  returnMoments = EcalClusterTools::cluster2ndMoments(RH_ptrs, phiCorrectionFactor, w0, useLogWeights);
1005 
1006  }
1007 
1008  return returnMoments;
1009 
1010 }
int i
Definition: DBlmapReader.cc:9
std::vector< T >::const_iterator const_iterator
static Cluster2ndMoments cluster2ndMoments(const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
bool first
Definition: L1TdeRCT.cc:79
iterator find(key_type k)
Cluster2ndMoments EcalClusterTools::cluster2ndMoments ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 1013 of file EcalClusterTools.cc.

References Cluster2ndMoments::alpha, cluster2ndMoments(), reco::CaloCluster::eta(), reco::SuperCluster::seed(), Cluster2ndMoments::sMaj, and Cluster2ndMoments::sMin.

1013  {
1014 
1015  // for now returns second moments of supercluster seed cluster:
1016  Cluster2ndMoments returnMoments;
1017  returnMoments.sMaj = -1.;
1018  returnMoments.sMin = -1.;
1019  returnMoments.alpha = 0.;
1020 
1021  // for now implemented only for EB:
1022  if( fabs( superCluster.eta() ) < 1.479 ) {
1023  returnMoments = EcalClusterTools::cluster2ndMoments( *(superCluster.seed()), recHits, phiCorrectionFactor, w0, useLogWeights);
1024  }
1025 
1026  return returnMoments;
1027 
1028 }
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:160
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:62
Cluster2ndMoments EcalClusterTools::cluster2ndMoments ( std::vector< const EcalRecHit * >  RH_ptrs,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
)
static

Definition at line 1031 of file EcalClusterTools.cc.

References Cluster2ndMoments::alpha, RecoTauValidation_cfi::denominator, getSumEnergy(), i, EBDetId::iphi(), funct::log(), max(), Cluster2ndMoments::sMaj, Cluster2ndMoments::sMin, and mathSSE::sqrt().

1031  {
1032 
1033  double mid_eta,mid_phi;
1034  mid_eta=mid_phi=0.;
1035 
1036  double Etot = EcalClusterTools::getSumEnergy( RH_ptrs );
1037 
1038  double max_phi=-10.;
1039  double min_phi=100.;
1040 
1041  std::vector<double> etaDetId;
1042  std::vector<double> phiDetId;
1043  std::vector<double> wiDetId;
1044 
1045  int nCry=0;
1046  double denominator=0.;
1047 
1048 
1049  // loop over rechits and compute weights:
1050  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1051 
1052  //get iEta, iPhi
1053  EBDetId temp_EBDetId( (*rh_ptr)->detid() );
1054  double temp_eta=(temp_EBDetId.ieta() > 0. ? temp_EBDetId.ieta() + 84.5 : temp_EBDetId.ieta() + 85.5);
1055  double temp_phi=temp_EBDetId.iphi() - 0.5;
1056  double temp_ene=(*rh_ptr)->energy();
1057 
1058  double temp_wi=((useLogWeights) ?
1059  std::max(0., w0 + log( fabs(temp_ene)/Etot ))
1060  : temp_ene);
1061 
1062  if(temp_phi>max_phi) max_phi=temp_phi;
1063  if(temp_phi<min_phi) min_phi=temp_phi;
1064  etaDetId.push_back(temp_eta);
1065  phiDetId.push_back(temp_phi);
1066  wiDetId.push_back(temp_wi);
1067  denominator+=temp_wi;
1068  nCry++;
1069  }
1070 
1071 
1072  // correct phi wrap-around:
1073  if(max_phi==359.5 && min_phi==0.5){
1074  for(int i=0; i<nCry; i++){
1075  if(phiDetId[i] - 179. > 0.) phiDetId[i]-=360.;
1076  mid_phi+=phiDetId[i]*wiDetId[i];
1077  mid_eta+=etaDetId[i]*wiDetId[i];
1078  }
1079  }
1080 
1081  else{
1082  for(int i=0; i<nCry; i++){
1083  mid_phi+=phiDetId[i]*wiDetId[i];
1084  mid_eta+=etaDetId[i]*wiDetId[i];
1085  }
1086  }
1087 
1088  mid_eta/=denominator;
1089  mid_phi/=denominator;
1090 
1091  // See = sigma eta eta
1092  // Spp = (B field corrected) sigma phi phi
1093  // See = (B field corrected) sigma eta phi
1094  double See=0.;
1095  double Spp=0.;
1096  double Sep=0.;
1097 
1098  // compute (phi-corrected) covariance matrix:
1099  for(int i=0; i<nCry; i++) {
1100  See += (wiDetId[i]*(etaDetId[i]-mid_eta)*(etaDetId[i]-mid_eta)) / denominator;
1101  Spp += phiCorrectionFactor*(wiDetId[i]*(phiDetId[i]-mid_phi)*(phiDetId[i]-mid_phi)) / denominator;
1102  Sep += sqrt(phiCorrectionFactor)*(wiDetId[i]*(etaDetId[i]-mid_eta)*(phiDetId[i]-mid_phi)) / denominator;
1103  }
1104 
1105  Cluster2ndMoments returnMoments;
1106 
1107  // compute matrix eigenvalues:
1108  returnMoments.sMaj = ((See + Spp) + sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1109  returnMoments.sMin = ((See + Spp) - sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1110 
1111  returnMoments.alpha = atan( (See - Spp + sqrt( (Spp - See)*(Spp - See) + 4.*Sep*Sep )) / (2.*Sep));
1112 
1113  return returnMoments;
1114 
1115 }
int i
Definition: DBlmapReader.cc:9
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
const T & max(const T &a, const T &b)
static float getSumEnergy(std::vector< const EcalRecHit * >RH_ptrs)
T sqrt(T t)
Definition: SSEVec.h:28
Log< T >::type log(const T &t)
Definition: Log.h:22
static float EcalClusterTools::computeWeight ( float  eRH,
float  energyTotal,
int  weightedPositionMethod 
)
staticprivate
std::vector< float > EcalClusterTools::covariances ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const CaloGeometry geometry,
float  w0 = 4.7 
)
static

Definition at line 534 of file EcalClusterTools.cc.

References RecoTauValidation_cfi::denominator, dPhi(), e5x5(), relval_parameters_module::energy, PV3DBase< T, PVType, FrameType >::eta(), CaloSubdetectorGeometry::getGeometry(), getMaximum(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), CaloTopology::getSubdetectorTopology(), CaloNavigator< T >::home(), i, j, funct::log(), max(), meanClusterPosition(), CaloNavigator< T >::offsetBy(), PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), position, recHitEnergy(), Geom::twoPi(), and v.

Referenced by GsfElectronAlgo::calculateShowerShape(), EcalClusterLazyTools::covariances(), PFPhotonTranslator::createPhotons(), egHLT::OffHelper::fillClusShapeData(), PhotonProducer::fillPhotonCollection(), and PiZeroDiscriminatorProducer::produce().

535 {
536  float e_5x5 = e5x5( cluster, recHits, topology );
537  float covEtaEta, covEtaPhi, covPhiPhi;
538  if (e_5x5 >= 0.) {
539  //double w0_ = parameterMap_.find("W0")->second;
540  std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
541  math::XYZVector meanPosition = meanClusterPosition( cluster, recHits, topology, geometry );
542 
543  // now we can calculate the covariances
544  double numeratorEtaEta = 0;
545  double numeratorEtaPhi = 0;
546  double numeratorPhiPhi = 0;
547  double denominator = 0;
548 
549  DetId id = getMaximum( v_id, recHits ).first;
550  CaloNavigator<DetId> cursor = CaloNavigator<DetId>( id, topology->getSubdetectorTopology( id ) );
551  for ( int i = -2; i <= 2; ++i ) {
552  for ( int j = -2; j <= 2; ++j ) {
553  cursor.home();
554  cursor.offsetBy( i, j );
555  float energy = recHitEnergy( *cursor, recHits );
556 
557  if ( energy <= 0 ) continue;
558 
559  GlobalPoint position = geometry->getSubdetectorGeometry(*cursor)->getGeometry(*cursor)->getPosition();
560 
561  double dPhi = position.phi() - meanPosition.phi();
562  if (dPhi > + Geom::pi()) { dPhi = Geom::twoPi() - dPhi; }
563  if (dPhi < - Geom::pi()) { dPhi = Geom::twoPi() + dPhi; }
564 
565  double dEta = position.eta() - meanPosition.eta();
566  double w = 0.;
567  w = std::max(0.0, w0 + log( energy / e_5x5 ));
568 
569  denominator += w;
570  numeratorEtaEta += w * dEta * dEta;
571  numeratorEtaPhi += w * dEta * dPhi;
572  numeratorPhiPhi += w * dPhi * dPhi;
573  }
574  }
575 
576  if (denominator != 0.0) {
577  covEtaEta = numeratorEtaEta / denominator;
578  covEtaPhi = numeratorEtaPhi / denominator;
579  covPhiPhi = numeratorPhiPhi / denominator;
580  } else {
581  covEtaEta = 999.9;
582  covEtaPhi = 999.9;
583  covPhiPhi = 999.9;
584  }
585 
586  } else {
587  // Warn the user if there was no energy in the cells and return zeroes.
588  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
589  covEtaEta = 0;
590  covEtaPhi = 0;
591  covPhiPhi = 0;
592  }
593  std::vector<float> v;
594  v.push_back( covEtaEta );
595  v.push_back( covEtaPhi );
596  v.push_back( covPhiPhi );
597  return v;
598 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
void home() const
move the navigator back to the starting point
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
const T & max(const T &a, const T &b)
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:20
Log< T >::type log(const T &t)
Definition: Log.h:22
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
T eta() const
Definition: PV3DBase.h:70
double pi()
Definition: Pi.h:31
double twoPi()
Definition: Pi.h:32
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const GlobalPoint & getPosition() const
mathSSE::Vec4< T > v
static math::XYZVector meanClusterPosition(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry)
int EcalClusterTools::deltaIEta ( int  seed_ieta,
int  rh_ieta 
)
staticprivate

Definition at line 1337 of file EcalClusterTools.cc.

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

1337  {
1338  // get rid of the fact that there is no ieta=0
1339  if(seed_ieta < 0) seed_ieta++;
1340  if(rh_ieta < 0) rh_ieta++;
1341  int rel_ieta = rh_ieta - seed_ieta;
1342  return rel_ieta;
1343 }
int EcalClusterTools::deltaIPhi ( int  seed_iphi,
int  rh_iphi 
)
staticprivate

Definition at line 1326 of file EcalClusterTools.cc.

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

1326  {
1327  int rel_iphi = rh_iphi - seed_iphi;
1328  // take care of cyclic variable iphi [1,360]
1329  if(rel_iphi > 180) rel_iphi = rel_iphi - 360;
1330  if(rel_iphi < -180) rel_iphi = rel_iphi + 360;
1331  return rel_iphi;
1332 }
float EcalClusterTools::e1x3 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 255 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e1x3().

256 {
257  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
258  return matrixEnergy( cluster, recHits, topology, id, 0, 0, -1, 1 );
259 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e1x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 239 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by GsfElectronAlgo::calculateShowerShape(), PFPhotonTranslator::createPhotons(), EcalClusterLazyTools::e1x5(), and PhotonProducer::fillPhotonCollection().

240 {
241  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
242  return matrixEnergy( cluster, recHits, topology, id, 0, 0, -2, 2 );
243 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2nd ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 175 of file EcalClusterTools.cc.

References first, i, recHitEnergy(), and edm::second().

Referenced by EcalClusterLazyTools::e2nd(), and PiZeroDiscriminatorProducer::produce().

176 {
177  std::list<float> energies;
178  std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
179  if ( v_id.size() < 2 ) return 0;
180  for ( size_t i = 0; i < v_id.size(); ++i ) {
181  energies.push_back( recHitEnergy( v_id[i].first, recHits ) * v_id[i].second );
182  }
183  energies.sort();
184  return *--(--energies.end());
185 
186 
187 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
U second(std::pair< T, U > const &p)
bool first
Definition: L1TdeRCT.cc:79
float EcalClusterTools::e2x2 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 110 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EBClusterTask::analyze(), EEClusterTask::analyze(), EcalClusterLazyTools::e2x2(), and PiZeroDiscriminatorProducer::produce().

111 {
112  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
113  std::list<float> energies;
114  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0, -1, 0 ) );
115  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0, 0, 1 ) );
116  energies.push_back( matrixEnergy( cluster, recHits, topology, id, 0, 1, 0, 1 ) );
117  energies.push_back( matrixEnergy( cluster, recHits, topology, id, 0, 1, -1, 0 ) );
118 
119 
120  return *std::max_element(energies.begin(),energies.end());
121 
122 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2x5Bottom ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 215 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e2x5Bottom(), and PiZeroDiscriminatorProducer::produce().

216 {
217  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
218  return matrixEnergy( cluster, recHits, topology, id, -2, 2, -2, -1 );
219 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2x5Left ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 199 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e2x5Left(), and PiZeroDiscriminatorProducer::produce().

200 {
201  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
202  return matrixEnergy( cluster, recHits, topology, id, -2, -1, -2, 2 );
203 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2x5Max ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 223 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by GsfElectronAlgo::calculateShowerShape(), PFPhotonTranslator::createPhotons(), EcalClusterLazyTools::e2x5Max(), and PhotonProducer::fillPhotonCollection().

224 {
225  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
226 
227  // 1x5 strip left of seed
228  float left = matrixEnergy( cluster, recHits, topology, id, -1, -1, -2, 2 );
229  // 1x5 strip right of seed
230  float right = matrixEnergy( cluster, recHits, topology, id, 1, 1, -2, 2 );
231  // 1x5 strip containing seed
232  float centre = matrixEnergy( cluster, recHits, topology, id, 0, 0, -2, 2 );
233 
234  // Return the maximum of (left+center) or (right+center) strip
235  return left > right ? left+centre : right+centre;
236 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2x5Right ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 191 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e2x5Right().

192 {
193  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
194  return matrixEnergy( cluster, recHits, topology, id, 1, 2, -2, 2 );
195 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e2x5Top ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 207 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e2x5Top(), and PiZeroDiscriminatorProducer::produce().

208 {
209  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
210  return matrixEnergy( cluster, recHits, topology, id, -2, 2, 1, 2 );
211 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e3x1 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 263 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e3x1().

264 {
265  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
266  return matrixEnergy( cluster, recHits, topology, id, -1, 1, 0, 0 );
267 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e3x2 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 126 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e3x2(), and PiZeroDiscriminatorProducer::produce().

127 {
128  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
129  std::list<float> energies;
130  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 1, -1, 0 ) );
131  energies.push_back( matrixEnergy( cluster, recHits, topology, id, 0, 1, -1, 1 ) );
132  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 1, 0, 1 ) );
133  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0, -1, 1 ) );
134  return *std::max_element(energies.begin(),energies.end());
135 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e3x3 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 139 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EBClusterTask::analyze(), EEClusterTask::analyze(), ContainmentCorrectionAnalyzer::analyze(), HiEgammaSCEnergyCorrectionAlgo::applyCorrection(), PFPhotonTranslator::createPhotons(), EcalClusterLazyTools::e3x3(), egHLT::OffHelper::fillClusShapeData(), PhotonProducer::fillPhotonCollection(), and PiZeroDiscriminatorProducer::produce().

140 {
141  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
142  return matrixEnergy( cluster, recHits, topology, id, -1, 1, -1, 1 );
143 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e4x4 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 147 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::e4x4().

148 {
149  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
150  std::list<float> energies;
151  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 2, -2, 1 ) );
152  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -2, 1, -2, 1 ) );
153  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -2, 1, -1, 2 ) );
154  energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 2, -1, 2 ) );
155  return *std::max_element(energies.begin(),energies.end());
156 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e5x1 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 247 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

248 {
249  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
250  return matrixEnergy( cluster, recHits, topology, id, -2, 2, 0, 0 );
251 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::e5x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 160 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EBClusterTask::analyze(), EEClusterTask::analyze(), ContainmentCorrectionAnalyzer::analyze(), HiEgammaSCEnergyCorrectionAlgo::applyCorrection(), GsfElectronAlgo::calculateShowerShape(), covariances(), PFPhotonTranslator::createPhotons(), EcalClusterLazyTools::e5x5(), PhotonProducer::fillPhotonCollection(), localCovariances(), meanClusterPosition(), PiZeroDiscriminatorProducer::produce(), and scLocalCovariances().

161 {
162  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
163  return matrixEnergy( cluster, recHits, topology, id, -2, 2, -2, 2 );
164 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::eBottom ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 295 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::eBottom(), and PiZeroDiscriminatorProducer::produce().

296 {
297  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
298  return matrixEnergy( cluster, recHits, topology, id, 0, 0, -1, -1 );
299 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::eLeft ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 271 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::eLeft(), and PiZeroDiscriminatorProducer::produce().

272 {
273  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
274  return matrixEnergy( cluster, recHits, topology, id, -1, -1, 0, 0 );
275 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::eMax ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 168 of file EcalClusterTools.cc.

References getMaximum(), and edm::second().

Referenced by ContainmentCorrectionAnalyzer::analyze(), PFPhotonTranslator::createPhotons(), EcalClusterLazyTools::eMax(), PhotonProducer::fillPhotonCollection(), and PiZeroDiscriminatorProducer::produce().

169 {
170  return getMaximum( cluster.hitsAndFractions(), recHits ).second;
171 }
U second(std::pair< T, U > const &p)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
std::vector< float > EcalClusterTools::energyBasketFractionEta ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 303 of file EcalClusterTools.cc.

References EcalBarrel, first, i, EBDetId::im(), EBDetId::kModulesPerSM, EBDetId::positiveZ(), recHitEnergy(), and python.multivaluedict::sort().

Referenced by EcalClusterLazyTools::energyBasketFractionEta().

304 {
305  std::vector<float> basketFraction( 2 * EBDetId::kModulesPerSM );
306  float clusterEnergy = cluster.energy();
307  std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
308  if ( v_id[0].first.subdetId() != EcalBarrel ) {
309  edm::LogWarning("EcalClusterTools::energyBasketFractionEta") << "Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
310  return basketFraction;
311  }
312  for ( size_t i = 0; i < v_id.size(); ++i ) {
313  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;
314  }
315  std::sort( basketFraction.rbegin(), basketFraction.rend() );
316  return basketFraction;
317 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.cc:85
static const int kModulesPerSM
Definition: EBDetId.h:126
bool first
Definition: L1TdeRCT.cc:79
bool positiveZ() const
Definition: EBDetId.h:65
std::vector< float > EcalClusterTools::energyBasketFractionPhi ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static

Definition at line 321 of file EcalClusterTools.cc.

References EcalBarrel, first, i, EBDetId::iphi(), EBDetId::kCrystalsInPhi, EBDetId::kTowersInPhi, EBDetId::MAX_IPHI, EBDetId::positiveZ(), recHitEnergy(), and python.multivaluedict::sort().

Referenced by EcalClusterLazyTools::energyBasketFractionPhi().

322 {
323  std::vector<float> basketFraction( 2 * (EBDetId::MAX_IPHI / EBDetId::kCrystalsInPhi) );
324  float clusterEnergy = cluster.energy();
325  std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
326  if ( v_id[0].first.subdetId() != EcalBarrel ) {
327  edm::LogWarning("EcalClusterTools::energyBasketFractionPhi") << "Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
328  return basketFraction;
329  }
330  for ( size_t i = 0; i < v_id.size(); ++i ) {
331  basketFraction[ (EBDetId(v_id[i].first).iphi()-1)/EBDetId::kCrystalsInPhi + EBDetId(v_id[i].first).positiveZ()*EBDetId::kTowersInPhi] += recHitEnergy( v_id[i].first, recHits ) * v_id[i].second / clusterEnergy;
332  }
333  std::sort( basketFraction.rbegin(), basketFraction.rend() );
334  return basketFraction;
335 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static const int kTowersInPhi
Definition: EBDetId.h:125
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
static const int kCrystalsInPhi
Definition: EBDetId.h:128
bool first
Definition: L1TdeRCT.cc:79
bool positiveZ() const
Definition: EBDetId.h:65
static const int MAX_IPHI
Definition: EBDetId.h:123
float EcalClusterTools::eRight ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 279 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::eRight(), and PiZeroDiscriminatorProducer::produce().

280 {
281  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
282  return matrixEnergy( cluster, recHits, topology, id, 1, 1, 0, 0 );
283 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float EcalClusterTools::eTop ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
static

Definition at line 287 of file EcalClusterTools.cc.

References first, getMaximum(), and matrixEnergy().

Referenced by EcalClusterLazyTools::eTop(), and PiZeroDiscriminatorProducer::produce().

288 {
289  DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
290  return matrixEnergy( cluster, recHits, topology, id, 0, 0, 1, 1 );
291 }
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static double EcalClusterTools::f00 ( double  r)
inlinestaticprivate

Definition at line 147 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

147 { return 1; }
static double EcalClusterTools::f11 ( double  r)
inlinestaticprivate

Definition at line 148 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

148 { return r; }
static double EcalClusterTools::f20 ( double  r)
inlinestaticprivate

Definition at line 149 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

149 { return 2.0*r*r-1.0; }
static double EcalClusterTools::f22 ( double  r)
inlinestaticprivate

Definition at line 150 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

150 { return r*r; }
static double EcalClusterTools::f31 ( double  r)
inlinestaticprivate

Definition at line 151 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

151 { return 3.0*r*r*r - 2.0*r; }
static double EcalClusterTools::f33 ( double  r)
inlinestaticprivate

Definition at line 152 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

152 { return r*r*r; }
static double EcalClusterTools::f40 ( double  r)
inlinestaticprivate

Definition at line 153 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

153 { return 6.0*r*r*r*r-6.0*r*r+1.0; }
static double EcalClusterTools::f42 ( double  r)
inlinestaticprivate

Definition at line 154 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

154 { return 4.0*r*r*r*r-3.0*r*r; }
static double EcalClusterTools::f44 ( double  r)
inlinestaticprivate

Definition at line 155 of file EcalClusterTools.h.

References csvReporter::r.

Referenced by fast_AbsZernikeMoment().

155 { return r*r*r*r; }
static double EcalClusterTools::f51 ( double  r)
inlinestaticprivate

Definition at line 156 of file EcalClusterTools.h.

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

Referenced by fast_AbsZernikeMoment().

156 { 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
static double EcalClusterTools::f53 ( double  r)
inlinestaticprivate

Definition at line 157 of file EcalClusterTools.h.

References funct::pow().

Referenced by fast_AbsZernikeMoment().

157 { 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
static double EcalClusterTools::f55 ( double  r)
inlinestaticprivate

Definition at line 158 of file EcalClusterTools.h.

References funct::pow().

Referenced by fast_AbsZernikeMoment().

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

Definition at line 164 of file EcalClusterTools.h.

References i, and n.

Referenced by calc_AbsZernikeMoment().

164  {
165  double res = 1.;
166  for (int i = 2; i <= n; ++i) res *= i;
167  return res;
168  }
int i
Definition: DBlmapReader.cc:9
double EcalClusterTools::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 719 of file EcalClusterTools.cc.

References funct::cos(), f00(), f11(), f20(), f22(), f31(), f33(), f40(), f42(), f44(), f51(), f53(), f55(), getEnergyDepTopology(), i, getHLTprescales::index, phi, csvReporter::r, funct::sin(), and mathSSE::sqrt().

Referenced by absZernikeMoment().

720 {
721  double r,ph,e,Re=0,Im=0;
722  double TotalEnergy = cluster.energy();
723  int index = (n/2)*(n/2)+(n/2)+m;
724  std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
725  int clusterSize = energyDistribution.size();
726  if(clusterSize < 3) return 0.0;
727 
728  for (int i=0; i<clusterSize; i++)
729  {
730  r = energyDistribution[i].r / R0;
731  if (r<1) {
732  std::vector<double> pol;
733  pol.push_back( f00(r) );
734  pol.push_back( f11(r) );
735  pol.push_back( f20(r) );
736  pol.push_back( f22(r) );
737  pol.push_back( f31(r) );
738  pol.push_back( f33(r) );
739  pol.push_back( f40(r) );
740  pol.push_back( f42(r) );
741  pol.push_back( f44(r) );
742  pol.push_back( f51(r) );
743  pol.push_back( f53(r) );
744  pol.push_back( f55(r) );
745  ph = (energyDistribution[i]).phi;
746  e = energyDistribution[i].deposited_energy;
747  Re = Re + e/TotalEnergy * pol[index] * cos( (double) m * ph);
748  Im = Im - e/TotalEnergy * pol[index] * sin( (double) m * ph);
749  }
750  }
751  return sqrt(Re*Re+Im*Im);
752 }
int i
Definition: DBlmapReader.cc:9
static double f42(double r)
static double f53(double r)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static double f51(double r)
static std::vector< EcalClusterEnergyDeposition > getEnergyDepTopology(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW, float w0)
static double f00(double r)
T sqrt(T t)
Definition: SSEVec.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static double f44(double r)
static double f55(double r)
static double f40(double r)
static double f31(double r)
static double f20(double r)
static double f33(double r)
static double f22(double r)
static double f11(double r)
Definition: DDAxes.h:10
float EcalClusterTools::getDPhiEndcap ( const DetId crysId,
float  meanX,
float  meanY 
)
staticprivate

Definition at line 882 of file EcalClusterTools.cc.

References dPhi(), getNormedIX(), getNormedIY(), phi, and mathSSE::sqrt().

Referenced by localCovariances(), and scLocalCovariances().

883 {
884  float iXNorm = getNormedIX(crysId);
885  float iYNorm = getNormedIY(crysId);
886 
887  float hitLocalR2 = (iXNorm-meanX)*(iXNorm-meanX)+(iYNorm-meanY)*(iYNorm-meanY);
888  float hitR2 = iXNorm*iXNorm+iYNorm*iYNorm;
889  float meanR2 = meanX*meanX+meanY*meanY;
890  float hitR = sqrt(hitR2);
891  float meanR = sqrt(meanR2);
892 
893  float phi = acos((hitR2+meanR2-hitLocalR2)/(2*hitR*meanR));
894  float dPhi = hitR*phi;
895 
896  return dPhi;
897 }
static float getNormedIX(const DetId &id)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
static float getNormedIY(const DetId &id)
T sqrt(T t)
Definition: SSEVec.h:28
Definition: DDAxes.h:10
std::vector< EcalClusterTools::EcalClusterEnergyDeposition > EcalClusterTools::getEnergyDepTopology ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
bool  logW,
float  w0 
)
staticprivate

Definition at line 339 of file EcalClusterTools.cc.

References EcalClusterTools::EcalClusterEnergyDeposition::deposited_energy, diffTreeTool::diff, edm::SortedCollection< T, SORT >::end(), CaloRecHit::energy(), edm::SortedCollection< T, SORT >::find(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), funct::log(), LogDebug, M_PI, max(), EcalClusterTools::EcalClusterEnergyDeposition::phi, EcalClusterTools::EcalClusterEnergyDeposition::r, CommonMethods::weight(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by calc_AbsZernikeMoment(), fast_AbsZernikeMoment(), and lat().

340 {
341  std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution;
342  // init a map of the energy deposition centered on the
343  // cluster centroid. This is for momenta calculation only.
344  CLHEP::Hep3Vector clVect(cluster.position().x(), cluster.position().y(), cluster.position().z());
345  CLHEP::Hep3Vector clDir(clVect);
346  clDir*=1.0/clDir.mag();
347  // in the transverse plane, axis perpendicular to clusterDir
348  CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
349  theta_axis *= 1.0/theta_axis.mag();
350  CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
351 
352  std::vector< std::pair<DetId, float> > clusterDetIds = cluster.hitsAndFractions();
353 
355  EcalRecHit testEcalRecHit;
356  std::vector< std::pair<DetId, float> >::iterator posCurrent;
357  // loop over crystals
358  for(posCurrent=clusterDetIds.begin(); posCurrent!=clusterDetIds.end(); ++posCurrent) {
359  EcalRecHitCollection::const_iterator itt = recHits->find( (*posCurrent).first );
360  testEcalRecHit=*itt;
361 
362  if(( (*posCurrent).first != DetId(0)) && (recHits->find( (*posCurrent).first ) != recHits->end())) {
363  clEdep.deposited_energy = testEcalRecHit.energy() * (*posCurrent).second;
364  // if logarithmic weight is requested, apply cut on minimum energy of the recHit
365  if(logW) {
366  //double w0 = parameterMap_.find("W0")->second;
367 
368  double weight = std::max(0.0, w0 + log(fabs(clEdep.deposited_energy)/cluster.energy()) );
369  if(weight==0) {
370  LogDebug("ClusterShapeAlgo") << "Crystal has insufficient energy: E = "
371  << clEdep.deposited_energy << " GeV; skipping... ";
372  continue;
373  }
374  else LogDebug("ClusterShapeAlgo") << "===> got crystal. Energy = " << clEdep.deposited_energy << " GeV. ";
375  }
376  DetId id_ = (*posCurrent).first;
377  const CaloCellGeometry *this_cell = geometry->getSubdetectorGeometry(id_)->getGeometry(id_);
378  GlobalPoint cellPos = this_cell->getPosition();
379  CLHEP::Hep3Vector gblPos (cellPos.x(),cellPos.y(),cellPos.z()); //surface position?
380  // Evaluate the distance from the cluster centroid
381  CLHEP::Hep3Vector diff = gblPos - clVect;
382  // Important: for the moment calculation, only the "lateral distance" is important
383  // "lateral distance" r_i = distance of the digi position from the axis Origin-Cluster Center
384  // ---> subtract the projection on clDir
385  CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
386  clEdep.r = DigiVect.mag();
387  LogDebug("ClusterShapeAlgo") << "E = " << clEdep.deposited_energy
388  << "\tdiff = " << diff.mag()
389  << "\tr = " << clEdep.r;
390  clEdep.phi = DigiVect.angle(theta_axis);
391  if(DigiVect.dot(phi_axis)<0) clEdep.phi = 2 * M_PI - clEdep.phi;
392  energyDistribution.push_back(clEdep);
393  }
394  }
395  return energyDistribution;
396 }
#define LogDebug(id)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
std::vector< T >::const_iterator const_iterator
T y() const
Definition: PV3DBase.h:57
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const T & max(const T &a, const T &b)
float energy() const
Definition: CaloRecHit.h:19
T z() const
Definition: PV3DBase.h:58
const_iterator end() const
Definition: DetId.h:20
#define M_PI
Definition: BFit3D.cc:3
Log< T >::type log(const T &t)
Definition: Log.h:22
iterator find(key_type k)
const GlobalPoint & getPosition() const
T x() const
Definition: PV3DBase.h:56
float EcalClusterTools::getIEta ( const DetId id)
staticprivate

Definition at line 789 of file EcalClusterTools.cc.

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

Referenced by getNrCrysDiffInEta().

790 {
791  if(id.det()==DetId::Ecal){
792  if(id.subdetId()==EcalBarrel){
793  EBDetId ebId(id);
794  return ebId.ieta();
795  }else if(id.subdetId()==EcalEndcap){
796  float iXNorm = getNormedIX(id);
797  float iYNorm = getNormedIY(id);
798 
799  return std::sqrt(iXNorm*iXNorm+iYNorm*iYNorm);
800  }
801  }
802  return 0.;
803 }
static float getNormedIX(const DetId &id)
static float getNormedIY(const DetId &id)
T sqrt(T t)
Definition: SSEVec.h:28
float EcalClusterTools::getIPhi ( const DetId id)
staticprivate

Definition at line 810 of file EcalClusterTools.cc.

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

Referenced by getNrCrysDiffInPhi().

811 {
812  if(id.det()==DetId::Ecal){
813  if(id.subdetId()==EcalBarrel){
814  EBDetId ebId(id);
815  return ebId.iphi();
816  }
817  }
818  return 0.;
819 }
std::pair< DetId, float > EcalClusterTools::getMaximum ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
)
static
std::pair< DetId, float > EcalClusterTools::getMaximum ( const std::vector< std::pair< DetId, float > > &  v_id,
const EcalRecHitCollection recHits 
)
static

Definition at line 18 of file EcalClusterTools.cc.

References relval_parameters_module::energy, first, i, max(), and recHitEnergy().

19 {
20  float max = 0;
21  DetId id(0);
22  for ( size_t i = 0; i < v_id.size(); ++i ) {
23  float energy = recHitEnergy( v_id[i].first, recHits ) * v_id[i].second;
24  if ( energy > max ) {
25  max = energy;
26  id = v_id[i].first;
27  }
28  }
29  return std::pair<DetId, float>(id, max);
30 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
const T & max(const T &a, const T &b)
bool first
Definition: L1TdeRCT.cc:79
Definition: DetId.h:20
float EcalClusterTools::getNormedIX ( const DetId id)
staticprivate

Definition at line 822 of file EcalClusterTools.cc.

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

Referenced by getDPhiEndcap(), getIEta(), and mean5x5PositionInXY().

823 {
824  if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
825  EEDetId eeId(id);
826  int iXNorm = eeId.ix()-50;
827  if(iXNorm<=0) iXNorm--;
828  return iXNorm;
829  }
830  return 0;
831 }
float EcalClusterTools::getNormedIY ( const DetId id)
staticprivate

Definition at line 834 of file EcalClusterTools.cc.

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

Referenced by getDPhiEndcap(), getIEta(), and mean5x5PositionInXY().

835 {
836  if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
837  EEDetId eeId(id);
838  int iYNorm = eeId.iy()-50;
839  if(iYNorm<=0) iYNorm--;
840  return iYNorm;
841  }
842  return 0;
843 }
float EcalClusterTools::getNrCrysDiffInEta ( const DetId crysId,
const DetId orginId 
)
staticprivate

Definition at line 846 of file EcalClusterTools.cc.

References EcalBarrel, getIEta(), and DetId::subdetId().

Referenced by localCovariances(), mean5x5PositionInLocalCrysCoord(), and scLocalCovariances().

847 {
848  float crysIEta = getIEta(crysId);
849  float orginIEta = getIEta(orginId);
850  bool isBarrel = orginId.subdetId()==EcalBarrel;
851 
852  float nrCrysDiff = crysIEta-orginIEta;
853 
854  //no iEta=0 in barrel, so if go from positive to negative
855  //need to reduce abs(detEta) by 1
856  if(isBarrel){
857  if(crysIEta*orginIEta<0){ // -1 to 1 transition
858  if(crysIEta>0) nrCrysDiff--;
859  else nrCrysDiff++;
860  }
861  }
862  return nrCrysDiff;
863 }
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
static float getIEta(const DetId &id)
float EcalClusterTools::getNrCrysDiffInPhi ( const DetId crysId,
const DetId orginId 
)
staticprivate

Definition at line 866 of file EcalClusterTools.cc.

References EcalBarrel, getIPhi(), and DetId::subdetId().

Referenced by localCovariances(), mean5x5PositionInLocalCrysCoord(), and scLocalCovariances().

867 {
868  float crysIPhi = getIPhi(crysId);
869  float orginIPhi = getIPhi(orginId);
870  bool isBarrel = orginId.subdetId()==EcalBarrel;
871 
872  float nrCrysDiff = crysIPhi-orginIPhi;
873 
874  if(isBarrel){ //if barrel, need to map into 0-180
875  if (nrCrysDiff > + 180) { nrCrysDiff = nrCrysDiff - 360; }
876  if (nrCrysDiff < - 180) { nrCrysDiff = nrCrysDiff + 360; }
877  }
878  return nrCrysDiff;
879 }
static float getIPhi(const DetId &id)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
std::vector< int > EcalClusterTools::getSeedPosition ( std::vector< const EcalRecHit * >  RH_ptrs)
staticprivate

Definition at line 1346 of file EcalClusterTools.cc.

References EBDetId::ieta().

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

1346  {
1347  std::vector<int> seedPosition;
1348  float eSeedRH = 0;
1349  int iEtaSeedRH = 0;
1350  int iPhiSeedRH = 0;
1351 
1352  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1353 
1354  //get iEta, iPhi
1355  EBDetId EBdetIdi( (*rh_ptr)->detid() );
1356 
1357  if(eSeedRH < (*rh_ptr)->energy()){
1358  eSeedRH = (*rh_ptr)->energy();
1359  iEtaSeedRH = EBdetIdi.ieta();
1360  iPhiSeedRH = EBdetIdi.iphi();
1361  }
1362 
1363  }// for loop
1364 
1365  seedPosition.push_back(iEtaSeedRH);
1366  seedPosition.push_back(iPhiSeedRH);
1367  return seedPosition;
1368 }
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
float EcalClusterTools::getSumEnergy ( std::vector< const EcalRecHit * >  RH_ptrs)
staticprivate

Definition at line 1371 of file EcalClusterTools.cc.

Referenced by cluster2ndMoments(), and roundnessSelectedBarrelRecHits().

1371  {
1372 
1373  float sumE = 0.;
1374 
1375  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1376  sumE += (*rh_ptr)->energy();
1377  }// for loop
1378 
1379  return sumE;
1380 }
std::vector< float > EcalClusterTools::lat ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
bool  logW = true,
float  w0 = 4.7 
)
static

Definition at line 400 of file EcalClusterTools.cc.

References funct::cos(), getEnergyDepTopology(), i, n, phi, csvReporter::r, funct::sin(), and tmp.

Referenced by EcalClusterLazyTools::lat().

401 {
402  std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
403 
404  std::vector<float> lat;
405  double r, redmoment=0;
406  double phiRedmoment = 0 ;
407  double etaRedmoment = 0 ;
408  int n,n1,n2,tmp;
409  int clusterSize=energyDistribution.size();
410  float etaLat_, phiLat_, lat_;
411  if (clusterSize<3) {
412  etaLat_ = 0.0 ;
413  lat_ = 0.0;
414  lat.push_back(0.);
415  lat.push_back(0.);
416  lat.push_back(0.);
417  return lat;
418  }
419 
420  n1=0; n2=1;
421  if (energyDistribution[1].deposited_energy >
422  energyDistribution[0].deposited_energy)
423  {
424  tmp=n2; n2=n1; n1=tmp;
425  }
426  for (int i=2; i<clusterSize; i++) {
427  n=i;
428  if (energyDistribution[i].deposited_energy >
429  energyDistribution[n1].deposited_energy)
430  {
431  tmp = n2;
432  n2 = n1; n1 = i; n=tmp;
433  } else {
434  if (energyDistribution[i].deposited_energy >
435  energyDistribution[n2].deposited_energy)
436  {
437  tmp=n2; n2=i; n=tmp;
438  }
439  }
440 
441  r = energyDistribution[n].r;
442  redmoment += r*r* energyDistribution[n].deposited_energy;
443  double rphi = r * cos (energyDistribution[n].phi) ;
444  phiRedmoment += rphi * rphi * energyDistribution[n].deposited_energy;
445  double reta = r * sin (energyDistribution[n].phi) ;
446  etaRedmoment += reta * reta * energyDistribution[n].deposited_energy;
447  }
448  double e1 = energyDistribution[n1].deposited_energy;
449  double e2 = energyDistribution[n2].deposited_energy;
450 
451  lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
452  phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
453  etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));
454 
455  lat.push_back(etaLat_);
456  lat.push_back(phiLat_);
457  lat.push_back(lat_);
458  return lat;
459 }
int i
Definition: DBlmapReader.cc:9
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
Definition: DDAxes.h:10
std::vector< float > EcalClusterTools::localCovariances ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
float  w0 = 4.7 
)
static

Definition at line 609 of file EcalClusterTools.cc.

References RecoTauValidation_cfi::denominator, dPhi(), e5x5(), EcalBarrel, relval_parameters_module::energy, getDPhiEndcap(), getMaximum(), getNrCrysDiffInEta(), getNrCrysDiffInPhi(), CaloTopology::getSubdetectorTopology(), CaloNavigator< T >::home(), funct::log(), max(), mean5x5PositionInLocalCrysCoord(), mean5x5PositionInXY(), CaloNavigator< T >::offsetBy(), recHitEnergy(), DetId::subdetId(), and v.

Referenced by GsfElectronAlgo::calculateShowerShape(), PFPhotonTranslator::createPhotons(), egHLT::OffHelper::fillClusShapeData(), PhotonProducer::fillPhotonCollection(), and EcalClusterLazyTools::localCovariances().

610 {
611 
612  float e_5x5 = e5x5( cluster, recHits, topology );
613  float covEtaEta, covEtaPhi, covPhiPhi;
614 
615  if (e_5x5 >= 0.) {
616  //double w0_ = parameterMap_.find("W0")->second;
617  std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
618  std::pair<float,float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord( cluster, recHits, topology );
619  std::pair<float,float> mean5x5XYPos = mean5x5PositionInXY(cluster,recHits,topology);
620 
621  // now we can calculate the covariances
622  double numeratorEtaEta = 0;
623  double numeratorEtaPhi = 0;
624  double numeratorPhiPhi = 0;
625  double denominator = 0;
626 
627  //these allow us to scale the localCov by the crystal size
628  //so that the localCovs have the same average value as the normal covs
629  const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
630  const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap
631 
632  DetId seedId = getMaximum( v_id, recHits ).first;
633 
634  bool isBarrel=seedId.subdetId()==EcalBarrel;
635  const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
636 
637  CaloNavigator<DetId> cursor = CaloNavigator<DetId>( seedId, topology->getSubdetectorTopology( seedId ) );
638 
639  for ( int eastNr = -2; eastNr <= 2; ++eastNr ) { //east is eta in barrel
640  for ( int northNr = -2; northNr <= 2; ++northNr ) { //north is phi in barrel
641  cursor.home();
642  cursor.offsetBy( eastNr, northNr);
643  float energy = recHitEnergy( *cursor, recHits );
644  if ( energy <= 0 ) continue;
645 
646  float dEta = getNrCrysDiffInEta(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.first;
647  float dPhi = 0;
648 
649  if(isBarrel) dPhi = getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
650  else dPhi = getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);
651 
652 
653  double w = std::max(0.0, w0 + log( energy / e_5x5 ));
654 
655  denominator += w;
656  numeratorEtaEta += w * dEta * dEta;
657  numeratorEtaPhi += w * dEta * dPhi;
658  numeratorPhiPhi += w * dPhi * dPhi;
659  } //end east loop
660  }//end north loop
661 
662 
663  //multiplying by crysSize to make the values compariable to normal covariances
664  if (denominator != 0.0) {
665  covEtaEta = crysSize*crysSize* numeratorEtaEta / denominator;
666  covEtaPhi = crysSize*crysSize* numeratorEtaPhi / denominator;
667  covPhiPhi = crysSize*crysSize* numeratorPhiPhi / denominator;
668  } else {
669  covEtaEta = 999.9;
670  covEtaPhi = 999.9;
671  covPhiPhi = 999.9;
672  }
673 
674 
675  } else {
676  // Warn the user if there was no energy in the cells and return zeroes.
677  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
678  covEtaEta = 0;
679  covEtaPhi = 0;
680  covPhiPhi = 0;
681  }
682  std::vector<float> v;
683  v.push_back( covEtaEta );
684  v.push_back( covEtaPhi );
685  v.push_back( covPhiPhi );
686  return v;
687 }
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
void home() const
move the navigator back to the starting point
static std::pair< float, float > mean5x5PositionInLocalCrysCoord(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
const T & max(const T &a, const T &b)
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
static std::pair< float, float > mean5x5PositionInXY(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
static float getDPhiEndcap(const DetId &crysId, float meanX, float meanY)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
Log< T >::type log(const T &t)
Definition: Log.h:22
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
mathSSE::Vec4< T > v
std::vector< DetId > EcalClusterTools::matrixDetId ( const CaloTopology topology,
DetId  id,
int  ixMin,
int  ixMax,
int  iyMin,
int  iyMax 
)
static

Definition at line 94 of file EcalClusterTools.cc.

References CaloTopology::getSubdetectorTopology(), CaloNavigator< T >::home(), i, j, CaloNavigator< T >::offsetBy(), and v.

Referenced by EcalClusterLazyTools::matrixDetId(), mean5x5PositionInLocalCrysCoord(), mean5x5PositionInXY(), and meanClusterPosition().

95 {
97  std::vector<DetId> v;
98  for ( int i = ixMin; i <= ixMax; ++i ) {
99  for ( int j = iyMin; j <= iyMax; ++j ) {
100  cursor.home();
101  cursor.offsetBy( i, j );
102  if ( *cursor != DetId(0) ) v.push_back( *cursor );
103  }
104  }
105  return v;
106 }
int i
Definition: DBlmapReader.cc:9
void home() const
move the navigator back to the starting point
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:20
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
mathSSE::Vec4< T > v
float EcalClusterTools::matrixEnergy ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
DetId  id,
int  ixMin,
int  ixMax,
int  iyMin,
int  iyMax 
)
static

Definition at line 71 of file EcalClusterTools.cc.

References relval_parameters_module::energy, CaloTopology::getSubdetectorTopology(), CaloNavigator< T >::home(), i, j, CaloNavigator< T >::offsetBy(), and recHitEnergy().

Referenced by e1x3(), e1x5(), e2x2(), e2x5Bottom(), e2x5Left(), e2x5Max(), e2x5Right(), e2x5Top(), e3x1(), e3x2(), e3x3(), e4x4(), e5x1(), e5x5(), eBottom(), eLeft(), eRight(), eTop(), and EcalClusterLazyTools::matrixEnergy().

72 {
73  // fast version
75  float energy = 0;
76  for ( int i = ixMin; i <= ixMax; ++i ) {
77  for ( int j = iyMin; j <= iyMax; ++j ) {
78  cursor.home();
79  cursor.offsetBy( i, j );
80  energy += recHitEnergy( *cursor, recHits );
81  }
82  }
83  // slow elegant version
84  //float energy = 0;
85  //std::vector<DetId> v_id = matrixDetId( topology, id, ixMin, ixMax, iyMin, iyMax );
86  //for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
87  // energy += recHitEnergy( *it, recHits );
88  //}
89  return energy;
90 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
void home() const
move the navigator back to the starting point
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
int j
Definition: DBlmapReader.cc:9
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
std::pair< float, float > EcalClusterTools::mean5x5PositionInLocalCrysCoord ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
staticprivate

Definition at line 485 of file EcalClusterTools.cc.

References relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), getMaximum(), getNrCrysDiffInEta(), getNrCrysDiffInPhi(), matrixDetId(), and recHitEnergy().

Referenced by localCovariances(), and scLocalCovariances().

486 {
487  DetId seedId = getMaximum( cluster, recHits ).first;
488  float meanDEta=0.;
489  float meanDPhi=0.;
490  float energySum=0.;
491 
492  std::vector<DetId> v_id = matrixDetId( topology,seedId, -2, 2, -2, 2 );
493  for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
494  float energy = recHitEnergy(*it,recHits);
495  if(energy<0.) continue;//skipping negative energy crystals
496  meanDEta += energy * getNrCrysDiffInEta(*it,seedId);
497  meanDPhi += energy * getNrCrysDiffInPhi(*it,seedId);
498  energySum +=energy;
499  }
500  meanDEta /=energySum;
501  meanDPhi /=energySum;
502  return std::pair<float,float>(meanDEta,meanDPhi);
503 }
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
Definition: DetId.h:20
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
double energySum(const DataFrame &df, int fs, int ls)
std::pair< float, float > EcalClusterTools::mean5x5PositionInXY ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
)
staticprivate

Definition at line 511 of file EcalClusterTools.cc.

References EcalBarrel, relval_parameters_module::energy, CastorDataFrameFilter_impl::energySum(), getMaximum(), getNormedIX(), getNormedIY(), matrixDetId(), recHitEnergy(), and DetId::subdetId().

Referenced by localCovariances(), and scLocalCovariances().

512 {
513  DetId seedId = getMaximum( cluster, recHits ).first;
514 
515  std::pair<float,float> meanXY(0.,0.);
516  if(seedId.subdetId()==EcalBarrel) return meanXY;
517 
518  float energySum=0.;
519 
520  std::vector<DetId> v_id = matrixDetId( topology,seedId, -2, 2, -2, 2 );
521  for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
522  float energy = recHitEnergy(*it,recHits);
523  if(energy<0.) continue;//skipping negative energy crystals
524  meanXY.first += energy * getNormedIX(*it);
525  meanXY.second += energy * getNormedIY(*it);
526  energySum +=energy;
527  }
528  meanXY.first/=energySum;
529  meanXY.second/=energySum;
530  return meanXY;
531 }
static float getNormedIX(const DetId &id)
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
static float getNormedIY(const DetId &id)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
double energySum(const DataFrame &df, int fs, int ls)
math::XYZVector EcalClusterTools::meanClusterPosition ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const CaloGeometry geometry 
)
staticprivate

Definition at line 463 of file EcalClusterTools.cc.

References e5x5(), first, CaloSubdetectorGeometry::getGeometry(), getMaximum(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), matrixDetId(), position, recHitEnergy(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by covariances().

464 {
465  // find mean energy position of a 5x5 cluster around the maximum
466  math::XYZVector meanPosition(0.0, 0.0, 0.0);
467  std::vector<DetId> v_id = matrixDetId( topology, getMaximum( cluster, recHits ).first, -2, 2, -2, 2 );
468  for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
469  GlobalPoint positionGP = geometry->getSubdetectorGeometry( *it )->getGeometry( *it )->getPosition();
470  math::XYZVector position(positionGP.x(),positionGP.y(),positionGP.z());
471  meanPosition = meanPosition + recHitEnergy( *it, recHits ) * position;
472  }
473  return meanPosition / e5x5( cluster, recHits, topology );
474 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
T y() const
Definition: PV3DBase.h:57
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T z() const
Definition: PV3DBase.h:58
bool first
Definition: L1TdeRCT.cc:79
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const GlobalPoint & getPosition() const
T x() const
Definition: PV3DBase.h:56
float EcalClusterTools::recHitEnergy ( DetId  id,
const EcalRecHitCollection recHits 
)
static

Definition at line 41 of file EcalClusterTools.cc.

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

Referenced by covariances(), e2nd(), energyBasketFractionEta(), energyBasketFractionPhi(), getMaximum(), localCovariances(), matrixEnergy(), mean5x5PositionInLocalCrysCoord(), mean5x5PositionInXY(), meanClusterPosition(), and scLocalCovariances().

42 {
43  if ( id == DetId(0) ) {
44  return 0;
45  } else {
46  EcalRecHitCollection::const_iterator it = recHits->find( id );
47  if ( it != recHits->end() ) {
48  return (*it).energy();
49  } else {
50  //throw cms::Exception("EcalRecHitNotFound") << "The recHit corresponding to the DetId" << id.rawId() << " not found in the EcalRecHitCollection";
51  // the recHit is not in the collection (hopefully zero suppressed)
52  return 0;
53  }
54  }
55  return 0;
56 }
std::vector< T >::const_iterator const_iterator
const_iterator end() const
Definition: DetId.h:20
iterator find(key_type k)
std::vector< float > EcalClusterTools::roundnessBarrelSuperClusters ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
int  weightedPositionMethod = 0,
float  energyThreshold = 0.0 
)
static

Definition at line 1126 of file EcalClusterTools.cc.

References edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), first, reco::CaloCluster::hitsAndFractions(), i, roundnessSelectedBarrelRecHits(), and cond::rpcobtemp::temp.

Referenced by EcalHaloAlgo::Calculate().

1126  {//int positionWeightingMethod=0){
1127  std::vector<const EcalRecHit*>RH_ptrs;
1128  std::vector< std::pair<DetId, float> > myHitsPair = superCluster.hitsAndFractions();
1129  std::vector<DetId> usedCrystals;
1130  for(unsigned int i=0; i< myHitsPair.size(); i++){
1131  usedCrystals.push_back(myHitsPair[i].first);
1132  }
1133  for(unsigned int i=0; i<usedCrystals.size(); i++){
1134  //get pointer to recHit object
1135  EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
1136  if( myRH != recHits.end() && myRH->energy() > energyThreshold){ //require rec hit to have positive energy
1137  RH_ptrs.push_back( &(*myRH) );
1138  }
1139  }
1140  std::vector<float> temp = EcalClusterTools::roundnessSelectedBarrelRecHits(RH_ptrs,weightedPositionMethod);
1141  return temp;
1142 }
int i
Definition: DBlmapReader.cc:9
std::vector< T >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:189
static std::vector< float > roundnessSelectedBarrelRecHits(std::vector< const EcalRecHit * >rhVector, int weightedPositionMethod=0)
bool first
Definition: L1TdeRCT.cc:79
const_iterator end() const
iterator find(key_type k)
std::vector< float > EcalClusterTools::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 1149 of file EcalClusterTools.cc.

References abs, edm::SortedCollection< T, SORT >::begin(), deltaIEta(), deltaIPhi(), edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), first, getSeedPosition(), reco::CaloCluster::hitsAndFractions(), i, and roundnessSelectedBarrelRecHits().

1149  {
1150 
1151  std::vector<const EcalRecHit*>RH_ptrs;
1152  std::vector< std::pair<DetId, float> > myHitsPair = superCluster.hitsAndFractions();
1153  std::vector<DetId> usedCrystals;
1154  for(unsigned int i=0; i< myHitsPair.size(); i++){
1155  usedCrystals.push_back(myHitsPair[i].first);
1156  }
1157 
1158  for(unsigned int i=0; i<usedCrystals.size(); i++){
1159  //get pointer to recHit object
1160  EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
1161  if(myRH != recHits.end() && myRH->energy() > energyRHThresh)
1162  RH_ptrs.push_back( &(*myRH) );
1163  }
1164 
1165 
1166  std::vector<int> seedPosition = EcalClusterTools::getSeedPosition( RH_ptrs );
1167 
1168  for(EcalRecHitCollection::const_iterator rh = recHits.begin(); rh != recHits.end(); rh++){
1169  EBDetId EBdetIdi( rh->detid() );
1170  //if(rh != recHits.end())
1171  bool inEtaWindow = ( abs( deltaIEta(seedPosition[0],EBdetIdi.ieta()) ) <= ieta_delta );
1172  bool inPhiWindow = ( abs( deltaIPhi(seedPosition[1],EBdetIdi.iphi()) ) <= iphi_delta );
1173  bool passEThresh = ( rh->energy() > energyRHThresh );
1174  bool alreadyCounted = false;
1175 
1176  // figure out if the rechit considered now is already inside the SC
1177  bool is_SCrh_inside_recHits = false;
1178  for(unsigned int i=0; i<usedCrystals.size(); i++){
1179  EcalRecHitCollection::const_iterator SCrh = recHits.find(usedCrystals[i]);
1180  if(SCrh != recHits.end()){
1181  is_SCrh_inside_recHits = true;
1182  if( rh->detid() == SCrh->detid() ) alreadyCounted = true;
1183  }
1184  }//for loop over SC's recHits
1185 
1186  if( is_SCrh_inside_recHits && !alreadyCounted && passEThresh && inEtaWindow && inPhiWindow){
1187  RH_ptrs.push_back( &(*rh) );
1188  }
1189 
1190  }//for loop over rh
1191  return EcalClusterTools::roundnessSelectedBarrelRecHits(RH_ptrs,weightedPositionMethod);
1192 }
int i
Definition: DBlmapReader.cc:9
static std::vector< int > getSeedPosition(std::vector< const EcalRecHit * >RH_ptrs)
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:189
static int deltaIEta(int seed_ieta, int rh_ieta)
static int deltaIPhi(int seed_iphi, int rh_iphi)
static std::vector< float > roundnessSelectedBarrelRecHits(std::vector< const EcalRecHit * >rhVector, int weightedPositionMethod=0)
bool first
Definition: L1TdeRCT.cc:79
const_iterator end() const
iterator find(key_type k)
const_iterator begin() const
std::vector< float > EcalClusterTools::roundnessSelectedBarrelRecHits ( std::vector< const EcalRecHit * >  rhVector,
int  weightedPositionMethod = 0 
)
static

Definition at line 1197 of file EcalClusterTools.cc.

References deltaIEta(), deltaIPhi(), RecoTauValidation_cfi::denominator, getSeedPosition(), getSumEnergy(), i, funct::log(), max(), cond::rpcobtemp::temp, and CommonMethods::weight().

Referenced by roundnessBarrelSuperClusters(), and roundnessBarrelSuperClustersUserExtended().

1197  {//int weightedPositionMethod = 0){
1198  //positionWeightingMethod = 0 linear weighting, 1 log energy weighting
1199 
1200  std::vector<float> shapes; // this is the returning vector
1201 
1202  //make sure photon has more than one crystal; else roundness and angle suck
1203  if(RH_ptrs.size()<2){
1204  shapes.push_back( -3 );
1205  shapes.push_back( -3 );
1206  return shapes;
1207  }
1208 
1209  //Find highest E RH (Seed) and save info, compute sum total energy used
1210  std::vector<int> seedPosition = EcalClusterTools::getSeedPosition( RH_ptrs );// *recHits);
1211  int tempInt = seedPosition[0];
1212  if(tempInt <0) tempInt++;
1213  float energyTotal = EcalClusterTools::getSumEnergy( RH_ptrs );
1214 
1215  //1st loop over rechits: compute new weighted center position in coordinates centered on seed
1216  float centerIEta = 0.;
1217  float centerIPhi = 0.;
1218  float denominator = 0.;
1219 
1220  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1221  //get iEta, iPhi
1222  EBDetId EBdetIdi( (*rh_ptr)->detid() );
1223  if(fabs(energyTotal) < 0.0001){
1224  // don't /0, bad!
1225  shapes.push_back( -2 );
1226  shapes.push_back( -2 );
1227  return shapes;
1228  }
1229  float weight = 0;
1230  if(fabs(weightedPositionMethod)<0.0001){ //linear
1231  weight = (*rh_ptr)->energy()/energyTotal;
1232  }else{ //logrithmic
1233  weight = std::max(0.0, 4.2 + log((*rh_ptr)->energy()/energyTotal));
1234  }
1235  denominator += weight;
1236  centerIEta += weight*deltaIEta(seedPosition[0],EBdetIdi.ieta());
1237  centerIPhi += weight*deltaIPhi(seedPosition[1],EBdetIdi.iphi());
1238  }
1239  if(fabs(denominator) < 0.0001){
1240  // don't /0, bad!
1241  shapes.push_back( -2 );
1242  shapes.push_back( -2 );
1243  return shapes;
1244  }
1245  centerIEta = centerIEta / denominator;
1246  centerIPhi = centerIPhi / denominator;
1247 
1248 
1249  //2nd loop over rechits: compute inertia tensor
1250  TMatrixDSym inertia(2); //initialize 2d inertia tensor
1251  double inertia00 = 0.;
1252  double inertia01 = 0.;// = inertia10 b/c matrix should be symmetric
1253  double inertia11 = 0.;
1254  int i = 0;
1255  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1256  //get iEta, iPhi
1257  EBDetId EBdetIdi( (*rh_ptr)->detid() );
1258 
1259  if(fabs(energyTotal) < 0.0001){
1260  // don't /0, bad!
1261  shapes.push_back( -2 );
1262  shapes.push_back( -2 );
1263  return shapes;
1264  }
1265  float weight = 0;
1266  if(fabs(weightedPositionMethod) < 0.0001){ //linear
1267  weight = (*rh_ptr)->energy()/energyTotal;
1268  }else{ //logrithmic
1269  weight = std::max(0.0, 4.2 + log((*rh_ptr)->energy()/energyTotal));
1270  }
1271 
1272  float ieta_rh_to_center = deltaIEta(seedPosition[0],EBdetIdi.ieta()) - centerIEta;
1273  float iphi_rh_to_center = deltaIPhi(seedPosition[1],EBdetIdi.iphi()) - centerIPhi;
1274 
1275  inertia00 += weight*iphi_rh_to_center*iphi_rh_to_center;
1276  inertia01 -= weight*iphi_rh_to_center*ieta_rh_to_center;
1277  inertia11 += weight*ieta_rh_to_center*ieta_rh_to_center;
1278  i++;
1279  }
1280 
1281  inertia[0][0] = inertia00;
1282  inertia[0][1] = inertia01; // use same number here
1283  inertia[1][0] = inertia01; // and here to insure symmetry
1284  inertia[1][1] = inertia11;
1285 
1286 
1287  //step 1 find principal axes of inertia
1288  TMatrixD eVectors(2,2);
1289  TVectorD eValues(2);
1290  //std::cout<<"EcalClusterTools::showerRoundness- about to compute eVectors"<<std::endl;
1291  eVectors=inertia.EigenVectors(eValues); //ordered highest eV to lowest eV (I checked!)
1292  //and eVectors are in columns of matrix! I checked!
1293  //and they are normalized to 1
1294 
1295 
1296 
1297  //step 2 select eta component of smaller eVal's eVector
1298  TVectorD smallerAxis(2);//easiest to spin SC on this axis (smallest eVal)
1299  smallerAxis[0]=eVectors[0][1];//row,col //eta component
1300  smallerAxis[1]=eVectors[1][1]; //phi component
1301 
1302  //step 3 compute interesting quatities
1303  Double_t temp = fabs(smallerAxis[0]);// closer to 1 ->beamhalo, closer to 0 something else
1304  if(fabs(eValues[0]) < 0.0001){
1305  // don't /0, bad!
1306  shapes.push_back( -2 );
1307  shapes.push_back( -2 );
1308  return shapes;
1309  }
1310 
1311  float Roundness = eValues[1]/eValues[0];
1312  float Angle=acos(temp);
1313 
1314  if( -0.00001 < Roundness && Roundness < 0) Roundness = 0.;
1315  if( -0.00001 < Angle && Angle < 0 ) Angle = 0.;
1316 
1317  shapes.push_back( Roundness );
1318  shapes.push_back( Angle );
1319  return shapes;
1320 
1321 }
int i
Definition: DBlmapReader.cc:9
static std::vector< int > getSeedPosition(std::vector< const EcalRecHit * >RH_ptrs)
static int deltaIEta(int seed_ieta, int rh_ieta)
const T & max(const T &a, const T &b)
static float getSumEnergy(std::vector< const EcalRecHit * >RH_ptrs)
static int deltaIPhi(int seed_iphi, int rh_iphi)
Log< T >::type log(const T &t)
Definition: Log.h:22
Definition: Angle.h:17
std::vector< float > EcalClusterTools::scLocalCovariances ( const reco::SuperCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
float  w0 = 4.7 
)
static

Definition at line 899 of file EcalClusterTools.cc.

References RecoTauValidation_cfi::denominator, dPhi(), e5x5(), EcalBarrel, relval_parameters_module::energy, first, getDPhiEndcap(), getMaximum(), getNrCrysDiffInEta(), getNrCrysDiffInPhi(), CaloTopology::getSubdetectorTopology(), reco::CaloCluster::hitsAndFractions(), i, funct::log(), max(), mean5x5PositionInLocalCrysCoord(), mean5x5PositionInXY(), recHitEnergy(), reco::SuperCluster::seed(), DetId::subdetId(), and v.

Referenced by EcalClusterLazyTools::scLocalCovariances().

900 {
901  const reco::BasicCluster bcluster = *(cluster.seed());
902 
903  float e_5x5 = e5x5(bcluster, recHits, topology);
904  float covEtaEta, covEtaPhi, covPhiPhi;
905 
906  if (e_5x5 >= 0.) {
907  std::vector<std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
908  std::pair<float,float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord(bcluster, recHits, topology);
909  std::pair<float,float> mean5x5XYPos = mean5x5PositionInXY(cluster,recHits,topology);
910  // now we can calculate the covariances
911  double numeratorEtaEta = 0;
912  double numeratorEtaPhi = 0;
913  double numeratorPhiPhi = 0;
914  double denominator = 0;
915 
916  const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
917  const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap
918 
919  DetId seedId = getMaximum(v_id, recHits).first;
920  bool isBarrel=seedId.subdetId()==EcalBarrel;
921 
922  const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
923 
924  for (size_t i = 0; i < v_id.size(); ++i) {
925  CaloNavigator<DetId> cursor = CaloNavigator<DetId>(v_id[i].first, topology->getSubdetectorTopology(v_id[i].first));
926  float energy = recHitEnergy(*cursor, recHits);
927 
928  if (energy <= 0) continue;
929 
930  float dEta = getNrCrysDiffInEta(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.first;
931  float dPhi = 0;
932  if(isBarrel) dPhi = getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
933  else dPhi = getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);
934 
935 
936 
937  double w = 0.;
938  w = std::max(0.0, w0 + log( energy / e_5x5 ));
939 
940  denominator += w;
941  numeratorEtaEta += w * dEta * dEta;
942  numeratorEtaPhi += w * dEta * dPhi;
943  numeratorPhiPhi += w * dPhi * dPhi;
944  }
945 
946  //multiplying by crysSize to make the values compariable to normal covariances
947  if (denominator != 0.0) {
948  covEtaEta = crysSize*crysSize* numeratorEtaEta / denominator;
949  covEtaPhi = crysSize*crysSize* numeratorEtaPhi / denominator;
950  covPhiPhi = crysSize*crysSize* numeratorPhiPhi / denominator;
951  } else {
952  covEtaEta = 999.9;
953  covEtaPhi = 999.9;
954  covPhiPhi = 999.9;
955  }
956 
957  } else {
958  // Warn the user if there was no energy in the cells and return zeroes.
959  // std::cout << "\ClusterShapeAlgo::Calculate_Covariances: no energy in supplied cells.\n";
960  covEtaEta = 0;
961  covEtaPhi = 0;
962  covPhiPhi = 0;
963  }
964 
965  std::vector<float> v;
966  v.push_back( covEtaEta );
967  v.push_back( covEtaPhi );
968  v.push_back( covPhiPhi );
969 
970  return v;
971 }
int i
Definition: DBlmapReader.cc:9
static float recHitEnergy(DetId id, const EcalRecHitCollection *recHits)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:189
static std::pair< float, float > mean5x5PositionInLocalCrysCoord(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
const T & max(const T &a, const T &b)
static std::pair< float, float > mean5x5PositionInXY(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float getNrCrysDiffInPhi(const DetId &crysId, const DetId &orginId)
static float getDPhiEndcap(const DetId &crysId, float meanX, float meanY)
bool first
Definition: L1TdeRCT.cc:79
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
Log< T >::type log(const T &t)
Definition: Log.h:22
static float getNrCrysDiffInEta(const DetId &crysId, const DetId &orginId)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:62
mathSSE::Vec4< T > v
double EcalClusterTools::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 692 of file EcalClusterTools.cc.

References absZernikeMoment().

Referenced by EcalClusterLazyTools::zernike20().

693 {
694  return absZernikeMoment( cluster, recHits, geometry, 2, 0, R0, logW, w0 );
695 }
static double absZernikeMoment(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, int n, int m, double R0, bool logW, float w0)
double EcalClusterTools::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 699 of file EcalClusterTools.cc.

References absZernikeMoment().

Referenced by EcalClusterLazyTools::zernike42().

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