CMS 3D CMS Logo

Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions

EcalClusterTools Class Reference

#include <EcalClusterTools.h>

List of all members.

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.

{};
EcalClusterTools::~EcalClusterTools ( ) [inline]

Definition at line 49 of file EcalClusterTools.h.

{};

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 
) [static, private]

Definition at line 706 of file EcalClusterTools.cc.

References calc_AbsZernikeMoment(), and fast_AbsZernikeMoment().

Referenced by zernike20(), and zernike42().

{
    // 1. Check if n,m are correctly
    if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0)) return -1;

    // 2. Check if n,R0 are within validity Range :
    // n>20 or R0<2.19cm  just makes no sense !
    if ((n>20) || (R0<=2.19)) return -1;
    if (n<=5) return fast_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, w0 );
    else return calc_AbsZernikeMoment(cluster, recHits, geometry, n, m, R0, logW, 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 
) [static, private]

Definition at line 756 of file EcalClusterTools.cc.

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

Referenced by absZernikeMoment().

{
    double r, ph, e, Re=0, Im=0, f_nm;
    double TotalEnergy = cluster.energy();
    std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
    int clusterSize=energyDistribution.size();
    if(clusterSize<3) return 0.0;

    for (int i = 0; i < clusterSize; ++i)
    { 
        r = energyDistribution[i].r / R0;
        if (r < 1) {
            ph = energyDistribution[i].phi;
            e = energyDistribution[i].deposited_energy;
            f_nm = 0;
            for (int s=0; s<=(n-m)/2; s++) {
                if (s%2==0) { 
                    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));
                } else {
                    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));
                }
            }
            Re = Re + e/TotalEnergy * f_nm * cos( (double) m*ph);
            Im = Im - e/TotalEnergy * f_nm * sin( (double) m*ph);
        }
    }
    return sqrt(Re*Re+Im*Im);
}
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 984 of file EcalClusterTools.cc.

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

Referenced by cluster2ndMoments(), and HLTDisplacedEgammaFilter::hltFilter().

                                                                                                                                                                                           {

  Cluster2ndMoments returnMoments;
  returnMoments.sMaj = -1.;
  returnMoments.sMin = -1.;
  returnMoments.alpha = 0.;

  // for now implemented only for EB:
  //  if( fabs( basicCluster.eta() ) < 1.479 ) { 

    std::vector<const EcalRecHit*> RH_ptrs;
    
    std::vector< std::pair<DetId, float> > myHitsPair = basicCluster.hitsAndFractions();
    std::vector<DetId> usedCrystals;
    for(unsigned int i=0; i< myHitsPair.size(); i++){
      usedCrystals.push_back(myHitsPair[i].first);
    }
    
    for(unsigned int i=0; i<usedCrystals.size(); i++){
      //get pointer to recHit object
      EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
      RH_ptrs.push_back(  &(*myRH)  );
    }

      returnMoments = EcalClusterTools::cluster2ndMoments(RH_ptrs, phiCorrectionFactor, w0, useLogWeights);

      //  }

  return returnMoments;

}
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 1017 of file EcalClusterTools.cc.

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

                                                                                                                                                                                           {

  // for now returns second moments of supercluster seed cluster:
  Cluster2ndMoments returnMoments;
  returnMoments.sMaj = -1.;
  returnMoments.sMin = -1.;
  returnMoments.alpha = 0.;

  // for now implemented only for EB:
  //  if( fabs( superCluster.eta() ) < 1.479 ) { 
    returnMoments = EcalClusterTools::cluster2ndMoments( *(superCluster.seed()), recHits, phiCorrectionFactor, w0, useLogWeights);
    //  }

  return returnMoments;

}
Cluster2ndMoments EcalClusterTools::cluster2ndMoments ( std::vector< const EcalRecHit * >  RH_ptrs,
double  phiCorrectionFactor = 0.8,
double  w0 = 4.7,
bool  useLogWeights = true 
) [static]

Definition at line 1035 of file EcalClusterTools.cc.

References Cluster2ndMoments::alpha, RecoTauValidation_cfi::denominator, EcalBarrel, getIEta(), getIPhi(), getNormedIX(), getNormedIY(), getSumEnergy(), i, funct::log(), max(), phi, Cluster2ndMoments::sMaj, Cluster2ndMoments::sMin, and mathSSE::sqrt().

                                                                                                                                                      {

  double mid_eta(0),mid_phi(0),mid_x(0),mid_y(0);
  
  double Etot = EcalClusterTools::getSumEnergy(  RH_ptrs  );
 
  double max_phi=-10.;
  double min_phi=100.;
  
  
  std::vector<double> etaDetId;
  std::vector<double> phiDetId;
  std::vector<double> xDetId;
  std::vector<double> yDetId;
  std::vector<double> wiDetId;
 
  unsigned int nCry=0;
  double denominator=0.;
  bool isBarrel(1);

  // loop over rechits and compute weights:
  for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){

    //get iEta, iPhi
    double temp_eta(0),temp_phi(0),temp_x(0),temp_y(0);
    isBarrel = (*rh_ptr)->detid().subdetId()==EcalBarrel;
    
    if(isBarrel) {
      temp_eta = (getIEta((*rh_ptr)->detid()) > 0. ? getIEta((*rh_ptr)->detid()) + 84.5 : getIEta((*rh_ptr)->detid()) + 85.5);
      temp_phi= getIPhi((*rh_ptr)->detid()) - 0.5;
    }
    else {
      temp_eta = getIEta((*rh_ptr)->detid());  
      temp_x =  getNormedIX((*rh_ptr)->detid());
      temp_y =  getNormedIY((*rh_ptr)->detid());
    }     

    double temp_ene=(*rh_ptr)->energy();
    
    double temp_wi=((useLogWeights) ?
                    std::max(0., w0 + log( fabs(temp_ene)/Etot ))
                    :  temp_ene);


    if(temp_phi>max_phi) max_phi=temp_phi;
    if(temp_phi<min_phi) min_phi=temp_phi;
    etaDetId.push_back(temp_eta);
    phiDetId.push_back(temp_phi);
    xDetId.push_back(temp_x);
    yDetId.push_back(temp_y);
    wiDetId.push_back(temp_wi);
    denominator+=temp_wi;
    nCry++;
  }

  if(isBarrel){
    // correct phi wrap-around:
    if(max_phi==359.5 && min_phi==0.5){ 
      for(unsigned int i=0; i<nCry; i++){
        if(phiDetId[i] - 179. > 0.) phiDetId[i]-=360.; 
        mid_phi+=phiDetId[i]*wiDetId[i];
        mid_eta+=etaDetId[i]*wiDetId[i];
      }
    } else{
      for(unsigned int i=0; i<nCry; i++){
        mid_phi+=phiDetId[i]*wiDetId[i];
        mid_eta+=etaDetId[i]*wiDetId[i];
      }
    }
  }else{
    for(unsigned int i=0; i<nCry; i++){
      mid_eta+=etaDetId[i]*wiDetId[i];      
      mid_x+=xDetId[i]*wiDetId[i];
      mid_y+=yDetId[i]*wiDetId[i];
    }
  }
  
  mid_eta/=denominator;
  mid_phi/=denominator;
  mid_x/=denominator;
  mid_y/=denominator;


  // See = sigma eta eta
  // Spp = (B field corrected) sigma phi phi
  // See = (B field corrected) sigma eta phi
  double See=0.;
  double Spp=0.;
  double Sep=0.;
  double deta(0),dphi(0);
  // compute (phi-corrected) covariance matrix:
  for(unsigned int i=0; i<nCry; i++) {
    if(isBarrel) {
      deta = etaDetId[i]-mid_eta;
      dphi = phiDetId[i]-mid_phi;
    } else {
      deta = etaDetId[i]-mid_eta;
      float hitLocalR2 = (xDetId[i]-mid_x)*(xDetId[i]-mid_x)+(yDetId[i]-mid_y)*(yDetId[i]-mid_y);
      float hitR2 = xDetId[i]*xDetId[i]+yDetId[i]*yDetId[i];
      float meanR2 = mid_x*mid_x+mid_y*mid_y;
      float hitR = sqrt(hitR2);
      float meanR = sqrt(meanR2);
      float phi = acos((hitR2+meanR2-hitLocalR2)/(2*hitR*meanR));
      dphi = hitR*phi;

    }
    See += (wiDetId[i]* deta * deta) / denominator;
    Spp += phiCorrectionFactor*(wiDetId[i]* dphi * dphi) / denominator;
    Sep += sqrt(phiCorrectionFactor)*(wiDetId[i]*deta*dphi) / denominator;
  }

  Cluster2ndMoments returnMoments;

  // compute matrix eigenvalues:
  returnMoments.sMaj = ((See + Spp) + sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
  returnMoments.sMin = ((See + Spp) - sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;

  returnMoments.alpha = atan( (See - Spp + sqrt( (Spp - See)*(Spp - See) + 4.*Sep*Sep )) / (2.*Sep));

  return returnMoments;

}
static float EcalClusterTools::computeWeight ( float  eRH,
float  energyTotal,
int  weightedPositionMethod 
) [static, private]
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(), v, and w().

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

{
    float e_5x5 = e5x5( cluster, recHits, topology );
    float covEtaEta, covEtaPhi, covPhiPhi;
    if (e_5x5 >= 0.) {
        //double w0_ = parameterMap_.find("W0")->second;
        std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
        math::XYZVector meanPosition = meanClusterPosition( cluster, recHits, topology, geometry );

        // now we can calculate the covariances
        double numeratorEtaEta = 0;
        double numeratorEtaPhi = 0;
        double numeratorPhiPhi = 0;
        double denominator     = 0;

        DetId id = getMaximum( v_id, recHits ).first;
        CaloNavigator<DetId> cursor = CaloNavigator<DetId>( id, topology->getSubdetectorTopology( id ) );
        for ( int i = -2; i <= 2; ++i ) {
            for ( int j = -2; j <= 2; ++j ) {
                cursor.home();
                cursor.offsetBy( i, j );
                float energy = recHitEnergy( *cursor, recHits );

                if ( energy <= 0 ) continue;

                GlobalPoint position = geometry->getSubdetectorGeometry(*cursor)->getGeometry(*cursor)->getPosition();

                double dPhi = position.phi() - meanPosition.phi();
                if (dPhi > + Geom::pi()) { dPhi = Geom::twoPi() - dPhi; }
                if (dPhi < - Geom::pi()) { dPhi = Geom::twoPi() + dPhi; }

                double dEta = position.eta() - meanPosition.eta();
                double w = 0.;
                w = std::max(0.0, w0 + log( energy / e_5x5 ));

                denominator += w;
                numeratorEtaEta += w * dEta * dEta;
                numeratorEtaPhi += w * dEta * dPhi;
                numeratorPhiPhi += w * dPhi * dPhi;
            }
        }

        if (denominator != 0.0) {
            covEtaEta =  numeratorEtaEta / denominator;
            covEtaPhi =  numeratorEtaPhi / denominator;
            covPhiPhi =  numeratorPhiPhi / denominator;
        } else {
            covEtaEta = 999.9;
            covEtaPhi = 999.9;
            covPhiPhi = 999.9;
        }

    } else {
        // Warn the user if there was no energy in the cells and return zeroes.
        //       std::cout << "\ClusterShapeAlgo::Calculate_Covariances:  no energy in supplied cells.\n";
        covEtaEta = 0;
        covEtaPhi = 0;
        covPhiPhi = 0;
    }
    std::vector<float> v;
    v.push_back( covEtaEta );
    v.push_back( covEtaPhi );
    v.push_back( covPhiPhi );
    return v;
}
int EcalClusterTools::deltaIEta ( int  seed_ieta,
int  rh_ieta 
) [static, private]

Definition at line 1379 of file EcalClusterTools.cc.

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

                                                         {
    // get rid of the fact that there is no ieta=0
    if(seed_ieta < 0) seed_ieta++;
    if(rh_ieta   < 0) rh_ieta++;
    int rel_ieta = rh_ieta - seed_ieta;
    return rel_ieta;
}
int EcalClusterTools::deltaIPhi ( int  seed_iphi,
int  rh_iphi 
) [static, private]

Definition at line 1368 of file EcalClusterTools.cc.

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

                                                         {
    int rel_iphi = rh_iphi - seed_iphi;
    // take care of cyclic variable iphi [1,360]
    if(rel_iphi >  180) rel_iphi = rel_iphi - 360;
    if(rel_iphi < -180) rel_iphi = rel_iphi + 360;
    return rel_iphi;
}
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().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 0, 0, -1, 1 );
}
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(), and PhotonProducer::fillPhotonCollection().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 0, 0, -2, 2 );
}
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 PiZeroDiscriminatorProducer::produce().

{
    std::list<float> energies;
    std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
    if ( v_id.size() < 2 ) return 0;
    for ( size_t i = 0; i < v_id.size(); ++i ) {
        energies.push_back( recHitEnergy( v_id[i].first, recHits ) * v_id[i].second );
    }
    energies.sort();             
    return *--(--energies.end());


}
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 EEClusterTask::analyze(), EBClusterTask::analyze(), and PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    std::list<float> energies;
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0, -1, 0 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0,  0, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id,  0, 1,  0, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id,  0, 1, -1, 0 ) );


    return *std::max_element(energies.begin(),energies.end());

}
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 PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -2, 2, -2, -1 );
}
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 PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -2, -1, -2, 2 );
}
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(), and PhotonProducer::fillPhotonCollection().

{
    DetId id =      getMaximum( cluster.hitsAndFractions(), recHits ).first;

    // 1x5 strip left of seed
    float left   = matrixEnergy( cluster, recHits, topology, id, -1, -1, -2, 2 );
    // 1x5 strip right of seed
    float right  = matrixEnergy( cluster, recHits, topology, id,  1,  1, -2, 2 );
    // 1x5 strip containing seed
    float centre = matrixEnergy( cluster, recHits, topology, id,  0,  0, -2, 2 );

    // Return the maximum of (left+center) or (right+center) strip
    return left > right ? left+centre : right+centre;
}
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().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 1, 2, -2, 2 );
}
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 PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -2, 2, 1, 2 );
}
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().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -1, 1, 0, 0 );
}
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 PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    std::list<float> energies;
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 1, -1, 0 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id,  0, 1, -1, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 1,  0, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 0, -1, 1 ) );
    return *std::max_element(energies.begin(),energies.end());
}
float EcalClusterTools::e3x3 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
) [static]
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().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    std::list<float> energies;
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 2, -2, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -2, 1, -2, 1 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -2, 1, -1, 2 ) );
    energies.push_back( matrixEnergy( cluster, recHits, topology, id, -1, 2, -1, 2 ) );
    return *std::max_element(energies.begin(),energies.end());
}
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().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -2, 2, 0, 0 );
}
float EcalClusterTools::e5x5 ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
) [static]
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 EBRecoSummary::analyze(), and PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 0, 0, -1, -1 );
}
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 EBRecoSummary::analyze(), and PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, -1, -1, 0, 0 );
}
float EcalClusterTools::eMax ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits 
) [static]

Definition at line 168 of file EcalClusterTools.cc.

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

{
    return getMaximum( cluster.hitsAndFractions(), recHits ).second;
}
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().

{
    std::vector<float> basketFraction( 2 * EBDetId::kModulesPerSM );
    float clusterEnergy = cluster.energy();
    std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
    if ( v_id[0].first.subdetId() != EcalBarrel ) {
        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.";
        return basketFraction;
    }
    for ( size_t i = 0; i < v_id.size(); ++i ) {
        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;
    }
    std::sort( basketFraction.rbegin(), basketFraction.rend() );
    return basketFraction;
}
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().

{
    std::vector<float> basketFraction( 2 * (EBDetId::MAX_IPHI / EBDetId::kCrystalsInPhi) );
    float clusterEnergy = cluster.energy();
    std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
    if ( v_id[0].first.subdetId() != EcalBarrel ) {
        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.";
        return basketFraction;
    }
    for ( size_t i = 0; i < v_id.size(); ++i ) {
        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;
    }
    std::sort( basketFraction.rbegin(), basketFraction.rend() );
    return basketFraction;
}
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 EBRecoSummary::analyze(), and PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 1, 1, 0, 0 );
}
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 EBRecoSummary::analyze(), and PiZeroDiscriminatorProducer::produce().

{
    DetId id = getMaximum( cluster.hitsAndFractions(), recHits ).first;
    return matrixEnergy( cluster, recHits, topology, id, 0, 0, 1, 1 );
}
static double EcalClusterTools::f00 ( double  r) [inline, static, private]

Definition at line 147 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

{ return 1; }
static double EcalClusterTools::f11 ( double  r) [inline, static, private]

Definition at line 148 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return r; }
static double EcalClusterTools::f20 ( double  r) [inline, static, private]

Definition at line 149 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

{ return 2.0*r*r-1.0; }
static double EcalClusterTools::f22 ( double  r) [inline, static, private]

Definition at line 150 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return r*r; }
static double EcalClusterTools::f31 ( double  r) [inline, static, private]

Definition at line 151 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return 3.0*r*r*r - 2.0*r; }
static double EcalClusterTools::f33 ( double  r) [inline, static, private]

Definition at line 152 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return r*r*r; }
static double EcalClusterTools::f40 ( double  r) [inline, static, private]

Definition at line 153 of file EcalClusterTools.h.

Referenced by fast_AbsZernikeMoment().

{ return 6.0*r*r*r*r-6.0*r*r+1.0; }
static double EcalClusterTools::f42 ( double  r) [inline, static, private]

Definition at line 154 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return 4.0*r*r*r*r-3.0*r*r; }
static double EcalClusterTools::f44 ( double  r) [inline, static, private]

Definition at line 155 of file EcalClusterTools.h.

References alignCSCRings::r.

Referenced by fast_AbsZernikeMoment().

{ return r*r*r*r; }
static double EcalClusterTools::f51 ( double  r) [inline, static, private]

Definition at line 156 of file EcalClusterTools.h.

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

Referenced by fast_AbsZernikeMoment().

{ return 10.0*pow(r,5)-12.0*pow(r,3)+3.0*r; }
static double EcalClusterTools::f53 ( double  r) [inline, static, private]

Definition at line 157 of file EcalClusterTools.h.

References funct::pow().

Referenced by fast_AbsZernikeMoment().

{ return 5.0*pow(r,5) - 4.0*pow(r,3); }
static double EcalClusterTools::f55 ( double  r) [inline, static, private]

Definition at line 158 of file EcalClusterTools.h.

References funct::pow().

Referenced by fast_AbsZernikeMoment().

{ return pow(r,5); }
static double EcalClusterTools::factorial ( int  n) [inline, static, private]

Definition at line 164 of file EcalClusterTools.h.

References i, and n.

Referenced by calc_AbsZernikeMoment().

                                               {
                        double res = 1.;
                        for (int i = 2; i <= n; ++i) res *= i;
                        return res;
                }
double EcalClusterTools::fast_AbsZernikeMoment ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
int  n,
int  m,
double  R0,
bool  logW,
float  w0 
) [static, private]

Definition at line 719 of file EcalClusterTools.cc.

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

Referenced by absZernikeMoment().

{
    double r,ph,e,Re=0,Im=0;
    double TotalEnergy = cluster.energy();
    int index = (n/2)*(n/2)+(n/2)+m;
    std::vector<EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
    int clusterSize = energyDistribution.size();
    if(clusterSize < 3) return 0.0;

    for (int i=0; i<clusterSize; i++)
    { 
        r = energyDistribution[i].r / R0;
        if (r<1) {
            std::vector<double> pol;
            pol.push_back( f00(r) );
            pol.push_back( f11(r) );
            pol.push_back( f20(r) );
            pol.push_back( f22(r) );
            pol.push_back( f31(r) );
            pol.push_back( f33(r) );
            pol.push_back( f40(r) );
            pol.push_back( f42(r) );
            pol.push_back( f44(r) );
            pol.push_back( f51(r) );
            pol.push_back( f53(r) );
            pol.push_back( f55(r) );
            ph = (energyDistribution[i]).phi;
            e = energyDistribution[i].deposited_energy;
            Re = Re + e/TotalEnergy * pol[index] * cos( (double) m * ph);
            Im = Im - e/TotalEnergy * pol[index] * sin( (double) m * ph);
        }
    }
    return sqrt(Re*Re+Im*Im);
}
float EcalClusterTools::getDPhiEndcap ( const DetId crysId,
float  meanX,
float  meanY 
) [static, private]

Definition at line 882 of file EcalClusterTools.cc.

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

Referenced by localCovariances(), and scLocalCovariances().

{
    float iXNorm  = getNormedIX(crysId);
    float iYNorm  = getNormedIY(crysId);

    float hitLocalR2 = (iXNorm-meanX)*(iXNorm-meanX)+(iYNorm-meanY)*(iYNorm-meanY);
    float hitR2 = iXNorm*iXNorm+iYNorm*iYNorm;
    float meanR2 = meanX*meanX+meanY*meanY;
    float hitR = sqrt(hitR2);
    float meanR = sqrt(meanR2);

    float tmp = (hitR2+meanR2-hitLocalR2)/(2*hitR*meanR);
    if (tmp<-1) tmp =-1;
    if (tmp>1)  tmp=1;
    float phi = acos(tmp);
    float dPhi = hitR*phi;

    return dPhi;
}
std::vector< EcalClusterTools::EcalClusterEnergyDeposition > EcalClusterTools::getEnergyDepTopology ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloGeometry geometry,
bool  logW,
float  w0 
) [static, private]

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().

{
    std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution;
    // init a map of the energy deposition centered on the
    // cluster centroid. This is for momenta calculation only.
    CLHEP::Hep3Vector clVect(cluster.position().x(), cluster.position().y(), cluster.position().z());
    CLHEP::Hep3Vector clDir(clVect);
    clDir*=1.0/clDir.mag();
    // in the transverse plane, axis perpendicular to clusterDir
    CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
    theta_axis *= 1.0/theta_axis.mag();
    CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);

    std::vector< std::pair<DetId, float> > clusterDetIds = cluster.hitsAndFractions();

    EcalClusterEnergyDeposition clEdep;
    EcalRecHit testEcalRecHit;
    std::vector< std::pair<DetId, float> >::iterator posCurrent;
    // loop over crystals
    for(posCurrent=clusterDetIds.begin(); posCurrent!=clusterDetIds.end(); ++posCurrent) {
        EcalRecHitCollection::const_iterator itt = recHits->find( (*posCurrent).first );
        testEcalRecHit=*itt;

        if(( (*posCurrent).first != DetId(0)) && (recHits->find( (*posCurrent).first ) != recHits->end())) {
            clEdep.deposited_energy = testEcalRecHit.energy() * (*posCurrent).second;
            // if logarithmic weight is requested, apply cut on minimum energy of the recHit
            if(logW) {
                //double w0 = parameterMap_.find("W0")->second;

                double weight = std::max(0.0, w0 + log(fabs(clEdep.deposited_energy)/cluster.energy()) );
                if(weight==0) {
                    LogDebug("ClusterShapeAlgo") << "Crystal has insufficient energy: E = " 
                        << clEdep.deposited_energy << " GeV; skipping... ";
                    continue;
                }
                else LogDebug("ClusterShapeAlgo") << "===> got crystal. Energy = " << clEdep.deposited_energy << " GeV. ";
            }
            DetId id_ = (*posCurrent).first;
            const CaloCellGeometry *this_cell = geometry->getSubdetectorGeometry(id_)->getGeometry(id_);
            GlobalPoint cellPos = this_cell->getPosition();
            CLHEP::Hep3Vector gblPos (cellPos.x(),cellPos.y(),cellPos.z()); //surface position?
            // Evaluate the distance from the cluster centroid
            CLHEP::Hep3Vector diff = gblPos - clVect;
            // Important: for the moment calculation, only the "lateral distance" is important
            // "lateral distance" r_i = distance of the digi position from the axis Origin-Cluster Center
            // ---> subtract the projection on clDir
            CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
            clEdep.r = DigiVect.mag();
            LogDebug("ClusterShapeAlgo") << "E = " << clEdep.deposited_energy
                << "\tdiff = " << diff.mag()
                << "\tr = " << clEdep.r;
            clEdep.phi = DigiVect.angle(theta_axis);
            if(DigiVect.dot(phi_axis)<0) clEdep.phi = 2 * M_PI - clEdep.phi;
            energyDistribution.push_back(clEdep);
        }
    } 
    return energyDistribution;
}
float EcalClusterTools::getIEta ( const DetId id) [static, private]

Definition at line 789 of file EcalClusterTools.cc.

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

Referenced by cluster2ndMoments(), and getNrCrysDiffInEta().

{
    if(id.det()==DetId::Ecal){
        if(id.subdetId()==EcalBarrel){
            EBDetId ebId(id);
            return ebId.ieta();
        }else if(id.subdetId()==EcalEndcap){
            float iXNorm = getNormedIX(id);
            float iYNorm = getNormedIY(id);

            return std::sqrt(iXNorm*iXNorm+iYNorm*iYNorm);
        }
    }
    return 0.;    
}
float EcalClusterTools::getIPhi ( const DetId id) [static, private]

Definition at line 810 of file EcalClusterTools.cc.

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

Referenced by cluster2ndMoments(), and getNrCrysDiffInPhi().

{
    if(id.det()==DetId::Ecal){
        if(id.subdetId()==EcalBarrel){
            EBDetId ebId(id);
            return ebId.iphi();
        }
    }
    return 0.;    
}
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().

{
    float max = 0;
    DetId id(0);
    for ( size_t i = 0; i < v_id.size(); ++i ) {
        float energy = recHitEnergy( v_id[i].first, recHits ) * v_id[i].second;
        if ( energy > max ) {
            max = energy;
            id = v_id[i].first;
        }
    }
    return std::pair<DetId, float>(id, max);
}
float EcalClusterTools::getNormedIX ( const DetId id) [static, private]

Definition at line 822 of file EcalClusterTools.cc.

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

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

{
    if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
        EEDetId eeId(id);      
        int iXNorm  = eeId.ix()-50;
        if(iXNorm<=0) iXNorm--;
        return iXNorm;
    }
    return 0;
}
float EcalClusterTools::getNormedIY ( const DetId id) [static, private]

Definition at line 834 of file EcalClusterTools.cc.

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

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

{
    if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap){
        EEDetId eeId(id);      
        int iYNorm  = eeId.iy()-50;
        if(iYNorm<=0) iYNorm--;
        return iYNorm;
    }
    return 0;
}
float EcalClusterTools::getNrCrysDiffInEta ( const DetId crysId,
const DetId orginId 
) [static, private]

Definition at line 846 of file EcalClusterTools.cc.

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

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

{
    float crysIEta = getIEta(crysId);
    float orginIEta = getIEta(orginId);
    bool isBarrel = orginId.subdetId()==EcalBarrel;

    float nrCrysDiff = crysIEta-orginIEta;

    //no iEta=0 in barrel, so if go from positive to negative
    //need to reduce abs(detEta) by 1
    if(isBarrel){ 
        if(crysIEta*orginIEta<0){ // -1 to 1 transition
            if(crysIEta>0) nrCrysDiff--;
            else nrCrysDiff++;
        }
    }
    return nrCrysDiff;
}
float EcalClusterTools::getNrCrysDiffInPhi ( const DetId crysId,
const DetId orginId 
) [static, private]

Definition at line 866 of file EcalClusterTools.cc.

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

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

{
    float crysIPhi = getIPhi(crysId);
    float orginIPhi = getIPhi(orginId);
    bool isBarrel = orginId.subdetId()==EcalBarrel;

    float nrCrysDiff = crysIPhi-orginIPhi;

    if(isBarrel){ //if barrel, need to map into 0-180 
        if (nrCrysDiff > + 180) { nrCrysDiff = nrCrysDiff - 360; }
        if (nrCrysDiff < - 180) { nrCrysDiff = nrCrysDiff + 360; }
    }
    return nrCrysDiff;
}
std::vector< int > EcalClusterTools::getSeedPosition ( std::vector< const EcalRecHit * >  RH_ptrs) [static, private]

Definition at line 1388 of file EcalClusterTools.cc.

References EBDetId::ieta().

Referenced by roundnessBarrelSuperClustersUserExtended(), and roundnessSelectedBarrelRecHits().

                                                                                    {
    std::vector<int> seedPosition;
    float eSeedRH = 0;
    int iEtaSeedRH = 0;
    int iPhiSeedRH = 0;

    for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){

        //get iEta, iPhi
        EBDetId EBdetIdi( (*rh_ptr)->detid() );

        if(eSeedRH < (*rh_ptr)->energy()){
            eSeedRH = (*rh_ptr)->energy();
            iEtaSeedRH = EBdetIdi.ieta();
            iPhiSeedRH = EBdetIdi.iphi();
        }

    }// for loop

    seedPosition.push_back(iEtaSeedRH);
    seedPosition.push_back(iPhiSeedRH);
    return seedPosition;
}
float EcalClusterTools::getSumEnergy ( std::vector< const EcalRecHit * >  RH_ptrs) [static, private]

Definition at line 1413 of file EcalClusterTools.cc.

Referenced by cluster2ndMoments(), and roundnessSelectedBarrelRecHits().

                                                                        {

    float sumE = 0.;

    for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
        sumE += (*rh_ptr)->energy();
    }// for loop

    return sumE;
}
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, alignCSCRings::r, funct::sin(), and tmp.

{
    std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution = getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );

    std::vector<float> lat;
    double r, redmoment=0;
    double phiRedmoment = 0 ;
    double etaRedmoment = 0 ;
    int n,n1,n2,tmp;
    int clusterSize=energyDistribution.size();
    float etaLat_, phiLat_, lat_;
    if (clusterSize<3) {
        etaLat_ = 0.0 ; 
        lat_ = 0.0;
        lat.push_back(0.);
        lat.push_back(0.);
        lat.push_back(0.);
        return lat; 
    }

    n1=0; n2=1;
    if (energyDistribution[1].deposited_energy > 
            energyDistribution[0].deposited_energy) 
    {
        tmp=n2; n2=n1; n1=tmp;
    }
    for (int i=2; i<clusterSize; i++) {
        n=i;
        if (energyDistribution[i].deposited_energy > 
                energyDistribution[n1].deposited_energy) 
        {
            tmp = n2;
            n2 = n1; n1 = i; n=tmp;
        } else {
            if (energyDistribution[i].deposited_energy > 
                    energyDistribution[n2].deposited_energy) 
            {
                tmp=n2; n2=i; n=tmp;
            }
        }

        r = energyDistribution[n].r;
        redmoment += r*r* energyDistribution[n].deposited_energy;
        double rphi = r * cos (energyDistribution[n].phi) ;
        phiRedmoment += rphi * rphi * energyDistribution[n].deposited_energy;
        double reta = r * sin (energyDistribution[n].phi) ;
        etaRedmoment += reta * reta * energyDistribution[n].deposited_energy;
    } 
    double e1 = energyDistribution[n1].deposited_energy;
    double e2 = energyDistribution[n2].deposited_energy;

    lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
    phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
    etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));

    lat.push_back(etaLat_);
    lat.push_back(phiLat_);
    lat.push_back(lat_);
    return lat;
}
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(), v, and w().

Referenced by GsfElectronAlgo::calculateShowerShape(), egHLT::OffHelper::fillClusShapeData(), and PhotonProducer::fillPhotonCollection().

{

    float e_5x5 = e5x5( cluster, recHits, topology );
    float covEtaEta, covEtaPhi, covPhiPhi;

    if (e_5x5 >= 0.) {
        //double w0_ = parameterMap_.find("W0")->second;
        std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
        std::pair<float,float> mean5x5PosInNrCrysFromSeed =  mean5x5PositionInLocalCrysCoord( cluster, recHits, topology );
        std::pair<float,float> mean5x5XYPos =  mean5x5PositionInXY(cluster,recHits,topology);

        // now we can calculate the covariances
        double numeratorEtaEta = 0;
        double numeratorEtaPhi = 0;
        double numeratorPhiPhi = 0;
        double denominator     = 0;

        //these allow us to scale the localCov by the crystal size 
        //so that the localCovs have the same average value as the normal covs
        const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
        const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap

        DetId seedId = getMaximum( v_id, recHits ).first;

        bool isBarrel=seedId.subdetId()==EcalBarrel;
        const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;

        CaloNavigator<DetId> cursor = CaloNavigator<DetId>( seedId, topology->getSubdetectorTopology( seedId ) );

        for ( int eastNr = -2; eastNr <= 2; ++eastNr ) { //east is eta in barrel
            for ( int northNr = -2; northNr <= 2; ++northNr ) { //north is phi in barrel
                cursor.home();
                cursor.offsetBy( eastNr, northNr);
                float energy = recHitEnergy( *cursor, recHits );
                if ( energy <= 0 ) continue;

                float dEta = getNrCrysDiffInEta(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.first;
                float dPhi = 0;

                if(isBarrel)  dPhi = getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
                else dPhi = getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);


                double w = std::max(0.0, w0 + log( energy / e_5x5 ));

                denominator += w;
                numeratorEtaEta += w * dEta * dEta;
                numeratorEtaPhi += w * dEta * dPhi;
                numeratorPhiPhi += w * dPhi * dPhi;
            } //end east loop
        }//end north loop


        //multiplying by crysSize to make the values compariable to normal covariances
        if (denominator != 0.0) {
            covEtaEta =  crysSize*crysSize* numeratorEtaEta / denominator;
            covEtaPhi =  crysSize*crysSize* numeratorEtaPhi / denominator;
            covPhiPhi =  crysSize*crysSize* numeratorPhiPhi / denominator;
        } else {
            covEtaEta = 999.9;
            covEtaPhi = 999.9;
            covPhiPhi = 999.9;
        }


    } else {
        // Warn the user if there was no energy in the cells and return zeroes.
        //       std::cout << "\ClusterShapeAlgo::Calculate_Covariances:  no energy in supplied cells.\n";
        covEtaEta = 0;
        covEtaPhi = 0;
        covPhiPhi = 0;
    }
    std::vector<float> v;
    v.push_back( covEtaEta );
    v.push_back( covEtaPhi );
    v.push_back( covPhiPhi );
    return 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 mean5x5PositionInLocalCrysCoord(), mean5x5PositionInXY(), and meanClusterPosition().

{
    CaloNavigator<DetId> cursor = CaloNavigator<DetId>( id, topology->getSubdetectorTopology( id ) );
    std::vector<DetId> v;
    for ( int i = ixMin; i <= ixMax; ++i ) {
        for ( int j = iyMin; j <= iyMax; ++j ) {
            cursor.home();
            cursor.offsetBy( i, j );
            if ( *cursor != DetId(0) ) v.push_back( *cursor );
        }
    }
    return 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(), and eTop().

{
    // fast version
    CaloNavigator<DetId> cursor = CaloNavigator<DetId>( id, topology->getSubdetectorTopology( id ) );
    float energy = 0;
    for ( int i = ixMin; i <= ixMax; ++i ) {
        for ( int j = iyMin; j <= iyMax; ++j ) {
            cursor.home();
            cursor.offsetBy( i, j );
            energy += recHitEnergy( *cursor, recHits );
        }
    }
    // slow elegant version
    //float energy = 0;
    //std::vector<DetId> v_id = matrixDetId( topology, id, ixMin, ixMax, iyMin, iyMax );
    //for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
    //        energy += recHitEnergy( *it, recHits );
    //}
    return energy;
}
std::pair< float, float > EcalClusterTools::mean5x5PositionInLocalCrysCoord ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
) [static, private]

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().

{
    DetId seedId =  getMaximum( cluster, recHits ).first;
    float meanDEta=0.;
    float meanDPhi=0.;
    float energySum=0.;

    std::vector<DetId> v_id = matrixDetId( topology,seedId, -2, 2, -2, 2 );
    for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {  
        float energy = recHitEnergy(*it,recHits);
        if(energy<0.) continue;//skipping negative energy crystals
        meanDEta += energy * getNrCrysDiffInEta(*it,seedId);
        meanDPhi += energy * getNrCrysDiffInPhi(*it,seedId);    
        energySum +=energy;
    }
    meanDEta /=energySum;
    meanDPhi /=energySum;
    return std::pair<float,float>(meanDEta,meanDPhi);
}
std::pair< float, float > EcalClusterTools::mean5x5PositionInXY ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology 
) [static, private]

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().

{
    DetId seedId =  getMaximum( cluster, recHits ).first;

    std::pair<float,float> meanXY(0.,0.);
    if(seedId.subdetId()==EcalBarrel) return meanXY;

    float energySum=0.;

    std::vector<DetId> v_id = matrixDetId( topology,seedId, -2, 2, -2, 2 );
    for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {  
        float energy = recHitEnergy(*it,recHits);
        if(energy<0.) continue;//skipping negative energy crystals
        meanXY.first += energy * getNormedIX(*it);
        meanXY.second += energy * getNormedIY(*it);
        energySum +=energy;
    }
    meanXY.first/=energySum;
    meanXY.second/=energySum;
    return meanXY;
}
math::XYZVector EcalClusterTools::meanClusterPosition ( const reco::BasicCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const CaloGeometry geometry 
) [static, private]

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().

{
    // find mean energy position of a 5x5 cluster around the maximum
    math::XYZVector meanPosition(0.0, 0.0, 0.0);
    std::vector<DetId> v_id = matrixDetId( topology, getMaximum( cluster, recHits ).first, -2, 2, -2, 2 );
    for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
        GlobalPoint positionGP = geometry->getSubdetectorGeometry( *it )->getGeometry( *it )->getPosition();
        math::XYZVector position(positionGP.x(),positionGP.y(),positionGP.z());
        meanPosition = meanPosition + recHitEnergy( *it, recHits ) * position;
    }
    return meanPosition / e5x5( cluster, recHits, topology );
}
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().

{
    if ( id == DetId(0) ) {
        return 0;
    } else {
        EcalRecHitCollection::const_iterator it = recHits->find( id );
        if ( it != recHits->end() ) {
            return (*it).energy();
        } else {
            //throw cms::Exception("EcalRecHitNotFound") << "The recHit corresponding to the DetId" << id.rawId() << " not found in the EcalRecHitCollection";
            // the recHit is not in the collection (hopefully zero suppressed)
            return 0;
        }
    }
    return 0;
}
std::vector< float > EcalClusterTools::roundnessBarrelSuperClusters ( const reco::SuperCluster superCluster,
const EcalRecHitCollection recHits,
int  weightedPositionMethod = 0,
float  energyThreshold = 0.0 
) [static]

Definition at line 1168 of file EcalClusterTools.cc.

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

Referenced by EcalHaloAlgo::Calculate(), and PhotonMIPHaloTagger::GetMipTrailFit().

                                                                                                                                                                                            {//int positionWeightingMethod=0){
    std::vector<const EcalRecHit*>RH_ptrs;
    std::vector< std::pair<DetId, float> > myHitsPair = superCluster.hitsAndFractions();
    std::vector<DetId> usedCrystals;
    for(unsigned int i=0; i< myHitsPair.size(); i++){
        usedCrystals.push_back(myHitsPair[i].first);
    }
    for(unsigned int i=0; i<usedCrystals.size(); i++){
        //get pointer to recHit object
        EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
        if( myRH != recHits.end() && myRH->energy() > energyThreshold){ //require rec hit to have positive energy
            RH_ptrs.push_back(  &(*myRH)  );
        }
    }
    std::vector<float> temp = EcalClusterTools::roundnessSelectedBarrelRecHits(RH_ptrs,weightedPositionMethod); 
    return temp;
}
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 1191 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().

                                                                                                                                                                                                                                       {

    std::vector<const EcalRecHit*>RH_ptrs;
    std::vector< std::pair<DetId, float> > myHitsPair = superCluster.hitsAndFractions();
    std::vector<DetId> usedCrystals;
    for(unsigned int i=0; i< myHitsPair.size(); i++){
        usedCrystals.push_back(myHitsPair[i].first);
    }

    for(unsigned int i=0; i<usedCrystals.size(); i++){
        //get pointer to recHit object
        EcalRecHitCollection::const_iterator myRH = recHits.find(usedCrystals[i]);
        if(myRH != recHits.end() && myRH->energy() > energyRHThresh)
            RH_ptrs.push_back(  &(*myRH)  );
    }


    std::vector<int> seedPosition = EcalClusterTools::getSeedPosition(  RH_ptrs  );

    for(EcalRecHitCollection::const_iterator rh = recHits.begin(); rh != recHits.end(); rh++){
        EBDetId EBdetIdi( rh->detid() );
        //if(rh != recHits.end())
        bool inEtaWindow = (   abs(  deltaIEta(seedPosition[0],EBdetIdi.ieta())  ) <= ieta_delta   );
        bool inPhiWindow = (   abs(  deltaIPhi(seedPosition[1],EBdetIdi.iphi())  ) <= iphi_delta   );
        bool passEThresh = (  rh->energy() > energyRHThresh  );
        bool alreadyCounted = false;

        // figure out if the rechit considered now is already inside the SC
        bool is_SCrh_inside_recHits = false;
        for(unsigned int i=0; i<usedCrystals.size(); i++){
            EcalRecHitCollection::const_iterator SCrh = recHits.find(usedCrystals[i]);
            if(SCrh != recHits.end()){
                is_SCrh_inside_recHits = true;
                if( rh->detid() == SCrh->detid()  ) alreadyCounted = true;
            }
        }//for loop over SC's recHits

        if( is_SCrh_inside_recHits && !alreadyCounted && passEThresh && inEtaWindow && inPhiWindow){
            RH_ptrs.push_back( &(*rh) );
        }

    }//for loop over rh
    return EcalClusterTools::roundnessSelectedBarrelRecHits(RH_ptrs,weightedPositionMethod);
}
std::vector< float > EcalClusterTools::roundnessSelectedBarrelRecHits ( std::vector< const EcalRecHit * >  rhVector,
int  weightedPositionMethod = 0 
) [static]

Definition at line 1239 of file EcalClusterTools.cc.

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

Referenced by roundnessBarrelSuperClusters(), and roundnessBarrelSuperClustersUserExtended().

                                                                                                                                  {//int weightedPositionMethod = 0){
    //positionWeightingMethod = 0 linear weighting, 1 log energy weighting

    std::vector<float> shapes; // this is the returning vector

    //make sure photon has more than one crystal; else roundness and angle suck
    if(RH_ptrs.size()<2){
        shapes.push_back( -3 );
        shapes.push_back( -3 );
        return shapes;
    }

    //Find highest E RH (Seed) and save info, compute sum total energy used
    std::vector<int> seedPosition = EcalClusterTools::getSeedPosition(  RH_ptrs  );// *recHits);
    int tempInt = seedPosition[0];
    if(tempInt <0) tempInt++;
    float energyTotal = EcalClusterTools::getSumEnergy(  RH_ptrs  );

    //1st loop over rechits: compute new weighted center position in coordinates centered on seed
    float centerIEta = 0.;
    float centerIPhi = 0.;
    float denominator = 0.;

    for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
        //get iEta, iPhi
        EBDetId EBdetIdi( (*rh_ptr)->detid() );
        if(fabs(energyTotal) < 0.0001){
            // don't /0, bad!
            shapes.push_back( -2 );
            shapes.push_back( -2 );
            return shapes;
        }
        float weight = 0;
        if(fabs(weightedPositionMethod)<0.0001){ //linear
            weight = (*rh_ptr)->energy()/energyTotal;
        }else{ //logrithmic
            weight = std::max(0.0, 4.2 + log((*rh_ptr)->energy()/energyTotal));
        }
        denominator += weight;
        centerIEta += weight*deltaIEta(seedPosition[0],EBdetIdi.ieta()); 
        centerIPhi += weight*deltaIPhi(seedPosition[1],EBdetIdi.iphi());
    }
    if(fabs(denominator) < 0.0001){
        // don't /0, bad!
        shapes.push_back( -2 );
        shapes.push_back( -2 );
        return shapes;
    }
    centerIEta = centerIEta / denominator;
    centerIPhi = centerIPhi / denominator;


    //2nd loop over rechits: compute inertia tensor
    TMatrixDSym inertia(2); //initialize 2d inertia tensor
    double inertia00 = 0.;
    double inertia01 = 0.;// = inertia10 b/c matrix should be symmetric
    double inertia11 = 0.;
    int i = 0;
    for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
        //get iEta, iPhi
        EBDetId EBdetIdi( (*rh_ptr)->detid() );

        if(fabs(energyTotal) < 0.0001){
            // don't /0, bad!
            shapes.push_back( -2 );
            shapes.push_back( -2 );
            return shapes;
        }
        float weight = 0;
        if(fabs(weightedPositionMethod) < 0.0001){ //linear
            weight = (*rh_ptr)->energy()/energyTotal;
        }else{ //logrithmic
            weight = std::max(0.0, 4.2 + log((*rh_ptr)->energy()/energyTotal));
        }

        float ieta_rh_to_center = deltaIEta(seedPosition[0],EBdetIdi.ieta()) - centerIEta;
        float iphi_rh_to_center = deltaIPhi(seedPosition[1],EBdetIdi.iphi()) - centerIPhi;

        inertia00 += weight*iphi_rh_to_center*iphi_rh_to_center;
        inertia01 -= weight*iphi_rh_to_center*ieta_rh_to_center;
        inertia11 += weight*ieta_rh_to_center*ieta_rh_to_center;
        i++;
    }

    inertia[0][0] = inertia00;
    inertia[0][1] = inertia01; // use same number here
    inertia[1][0] = inertia01; // and here to insure symmetry
    inertia[1][1] = inertia11;


    //step 1 find principal axes of inertia
    TMatrixD eVectors(2,2);
    TVectorD eValues(2);
    //std::cout<<"EcalClusterTools::showerRoundness- about to compute eVectors"<<std::endl;
    eVectors=inertia.EigenVectors(eValues); //ordered highest eV to lowest eV (I checked!)
    //and eVectors are in columns of matrix! I checked!
    //and they are normalized to 1



    //step 2 select eta component of smaller eVal's eVector
    TVectorD smallerAxis(2);//easiest to spin SC on this axis (smallest eVal)
    smallerAxis[0]=eVectors[0][1];//row,col  //eta component
    smallerAxis[1]=eVectors[1][1];           //phi component

    //step 3 compute interesting quatities
    Double_t temp = fabs(smallerAxis[0]);// closer to 1 ->beamhalo, closer to 0 something else
    if(fabs(eValues[0]) < 0.0001){
        // don't /0, bad!
        shapes.push_back( -2 );
        shapes.push_back( -2 );
        return shapes;
    }

    float Roundness = eValues[1]/eValues[0];
    float Angle=acos(temp);

    if( -0.00001 < Roundness && Roundness < 0) Roundness = 0.;
    if( -0.00001 < Angle && Angle < 0 ) Angle = 0.;

    shapes.push_back( Roundness );
    shapes.push_back( Angle );
    return shapes;

}
std::vector< float > EcalClusterTools::scLocalCovariances ( const reco::SuperCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
float  w0 = 4.7 
) [static]

Definition at line 902 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(), v, and w().

{
    const reco::BasicCluster bcluster = *(cluster.seed());

    float e_5x5 = e5x5(bcluster, recHits, topology);
    float covEtaEta, covEtaPhi, covPhiPhi;

    if (e_5x5 >= 0.) {
        std::vector<std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
        std::pair<float,float> mean5x5PosInNrCrysFromSeed =  mean5x5PositionInLocalCrysCoord(bcluster, recHits, topology);
        std::pair<float,float> mean5x5XYPos =  mean5x5PositionInXY(cluster,recHits,topology);
        // now we can calculate the covariances
        double numeratorEtaEta = 0;
        double numeratorEtaPhi = 0;
        double numeratorPhiPhi = 0;
        double denominator     = 0;

        const double barrelCrysSize = 0.01745; //approximate size of crystal in eta,phi in barrel
        const double endcapCrysSize = 0.0447; //the approximate crystal size sigmaEtaEta was corrected to in the endcap

        DetId seedId = getMaximum(v_id, recHits).first;  
        bool isBarrel=seedId.subdetId()==EcalBarrel;

        const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;

        for (size_t i = 0; i < v_id.size(); ++i) {
            CaloNavigator<DetId> cursor = CaloNavigator<DetId>(v_id[i].first, topology->getSubdetectorTopology(v_id[i].first));
            float energy = recHitEnergy(*cursor, recHits);

            if (energy <= 0) continue;

            float dEta = getNrCrysDiffInEta(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.first;
            float dPhi = 0;
            if(isBarrel)  dPhi = getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
            else dPhi = getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);



            double w = 0.;
            w = std::max(0.0, w0 + log( energy / e_5x5 ));

            denominator += w;
            numeratorEtaEta += w * dEta * dEta;
            numeratorEtaPhi += w * dEta * dPhi;
            numeratorPhiPhi += w * dPhi * dPhi;
        }

        //multiplying by crysSize to make the values compariable to normal covariances
        if (denominator != 0.0) {
            covEtaEta =  crysSize*crysSize* numeratorEtaEta / denominator;
            covEtaPhi =  crysSize*crysSize* numeratorEtaPhi / denominator;
            covPhiPhi =  crysSize*crysSize* numeratorPhiPhi / denominator;
        } else {
            covEtaEta = 999.9;
            covEtaPhi = 999.9;
            covPhiPhi = 999.9;
        }

    } else {
        // Warn the user if there was no energy in the cells and return zeroes.
        // std::cout << "\ClusterShapeAlgo::Calculate_Covariances:  no energy in supplied cells.\n";
        covEtaEta = 0;
        covEtaPhi = 0;
        covPhiPhi = 0;
    }

    std::vector<float> v;
    v.push_back( covEtaEta );
    v.push_back( covEtaPhi );
    v.push_back( covPhiPhi );

    return 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().

{
    return absZernikeMoment( cluster, recHits, geometry, 2, 0, R0, logW, 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().

{
    return absZernikeMoment( cluster, recHits, geometry, 4, 2, R0, logW, w0 );
}