CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalClusterLazyTools Class Reference

#include <EcalClusterLazyTools.h>

List of all members.

Public Member Functions

float BasicClusterSeedTime (const reco::BasicCluster &cluster)
float BasicClusterTime (const reco::BasicCluster &cluster, const edm::Event &ev)
std::vector< float > covariances (const reco::BasicCluster &cluster, float w0=4.7)
float e1x3 (const reco::BasicCluster &cluster)
float e1x5 (const reco::BasicCluster &cluster)
float e2nd (const reco::BasicCluster &cluster)
float e2x2 (const reco::BasicCluster &cluster)
float e2x5Bottom (const reco::BasicCluster &cluster)
float e2x5Left (const reco::BasicCluster &cluster)
float e2x5Max (const reco::BasicCluster &cluster)
float e2x5Right (const reco::BasicCluster &cluster)
float e2x5Top (const reco::BasicCluster &cluster)
float e3x1 (const reco::BasicCluster &cluster)
float e3x2 (const reco::BasicCluster &cluster)
float e3x3 (const reco::BasicCluster &cluster)
float e4x4 (const reco::BasicCluster &cluster)
float e5x5 (const reco::BasicCluster &cluster)
float eBottom (const reco::BasicCluster &cluster)
 EcalClusterLazyTools (const edm::Event &ev, const edm::EventSetup &es, edm::InputTag redEBRecHits, edm::InputTag redEERecHits)
float eLeft (const reco::BasicCluster &cluster)
float eMax (const reco::BasicCluster &cluster)
std::vector< float > energyBasketFractionEta (const reco::BasicCluster &cluster)
std::vector< float > energyBasketFractionPhi (const reco::BasicCluster &cluster)
float eRight (const reco::BasicCluster &cluster)
float eTop (const reco::BasicCluster &cluster)
std::pair< DetId, float > getMaximum (const reco::BasicCluster &cluster)
std::vector< float > lat (const reco::BasicCluster &cluster, bool logW=true, float w0=4.7)
std::vector< float > localCovariances (const reco::BasicCluster &cluster, float w0=4.7)
std::vector< DetIdmatrixDetId (DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
float matrixEnergy (const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
std::vector< float > scLocalCovariances (const reco::SuperCluster &cluster, float w0=4.7)
float SuperClusterSeedTime (const reco::SuperCluster &cluster)
float SuperClusterTime (const reco::SuperCluster &cluster, const edm::Event &ev)
double zernike20 (const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
double zernike42 (const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
 ~EcalClusterLazyTools ()

Private Member Functions

void getADCToGeV (const edm::EventSetup &es)
void getEBRecHits (const edm::Event &ev, edm::InputTag redEBRecHits)
const EcalRecHitCollectiongetEcalRecHitCollection (const reco::BasicCluster &cluster)
void getEERecHits (const edm::Event &ev, edm::InputTag redEERecHits)
void getGeometry (const edm::EventSetup &es)
void getIntercalibConstants (const edm::EventSetup &es)
void getLaserDbService (const edm::EventSetup &es)
void getTopology (const edm::EventSetup &es)

Private Attributes

edm::ESHandle
< EcalADCToGeVConstant
agc
const EcalRecHitCollectionebRecHits_
const EcalRecHitCollectioneeRecHits_
const CaloGeometrygeometry_
edm::ESHandle
< EcalIntercalibConstants
ical
EcalIntercalibConstantMap icalMap
edm::ESHandle< EcalLaserDbServicelaser
const CaloTopologytopology_

Detailed Description

various cluster tools (e.g. cluster shapes)

Author:
Federico Ferri
Version:
$Id:

Definition at line 28 of file EcalClusterLazyTools.h.


Constructor & Destructor Documentation

EcalClusterLazyTools::EcalClusterLazyTools ( const edm::Event ev,
const edm::EventSetup es,
edm::InputTag  redEBRecHits,
edm::InputTag  redEERecHits 
)
EcalClusterLazyTools::~EcalClusterLazyTools ( )

Definition at line 31 of file EcalClusterLazyTools.cc.

{
}

Member Function Documentation

float EcalClusterLazyTools::BasicClusterSeedTime ( const reco::BasicCluster cluster)

Definition at line 297 of file EcalClusterLazyTools.cc.

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

Referenced by SuperClusterSeedTime().

{
  
  const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
  
  DetId id = cluster.seed();
  EcalRecHitCollection::const_iterator theSeedHit = recHits->find (id);
  //  std::cout << "the seed of the BC has time: " 
  //<< (*theSeedHit).time() 
  //<< "and energy: " << (*theSeedHit).energy() << " collection size: " << recHits->size() 
  //<< "\n" <<std::endl; // GF debug
  
  return (*theSeedHit).time();
}
float EcalClusterLazyTools::BasicClusterTime ( const reco::BasicCluster cluster,
const edm::Event ev 
)

Definition at line 314 of file EcalClusterLazyTools.cc.

References ecalMGPA::adc(), agc, gather_cfg::cout, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::find(), EcalCondObjectContainer< T >::find(), first, getEcalRecHitCollection(), icalMap, laser, edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), and edm::EventBase::time().

Referenced by SuperClusterTime().

{
  
  std::vector<std::pair<DetId, float> > clusterComponents = (cluster).hitsAndFractions() ;
  std::cout << "BC has this many components: " << clusterComponents.size() << std::endl; // GF debug
  
  const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
  std::cout << "BasicClusterClusterTime - rechits are this many: " << recHits->size() << std::endl; // GF debug
  
  
  float weightedTsum   = 0;
  float sumOfWeights   = 0;
  
  for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterComponents.begin(); detitr != clusterComponents.end(); detitr++ )
    {
      //      EcalRecHitCollection::const_iterator theSeedHit = recHits->find (id); // trash this
      EcalRecHitCollection::const_iterator oneHit = recHits->find( (detitr -> first) ) ;
      
      // in order to get back the ADC counts from the recHit energy, three ingredients are necessary:
      // 1) get laser correction coefficient
      float lasercalib = 1.;
      lasercalib = laser->getLaserCorrection( detitr->first, ev.time());
      // 2) get intercalibration
      EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detitr->first);
      EcalIntercalibConstant icalconst = 1.;
      if( icalit!=icalMap.end() ) {
        icalconst = (*icalit);
        // std::cout << "icalconst set to: " << icalconst << std::endl;
      } else {
        edm::LogError("EcalClusterLazyTools") << "No intercalib const found for xtal "  << (detitr->first).rawId() << "bailing out";
        assert(0);
      }
      // 3) get adc2GeV
      float adcToGeV = 1.;
      if       ( (detitr -> first).subdetId() == EcalBarrel )  adcToGeV = float(agc->getEBValue());
      else if  ( (detitr -> first).subdetId() == EcalEndcap )  adcToGeV = float(agc->getEEValue());
            float adc = 2.;
      if (icalconst>0 && lasercalib>0 && adcToGeV>0)  adc= (*oneHit).energy()/(icalconst*lasercalib*adcToGeV);

      // don't consider recHits with too little amplitude; take sigma_noise_total into account
      if( (detitr -> first).subdetId() == EcalBarrel  &&  adc< (1.1*20) ) continue;
      if( (detitr -> first).subdetId() == EcalEndcap  &&  adc< (2.2*20) ) continue;

      // count only on rechits whose error is trusted by the method (ratio)
      if(! (*oneHit).isTimeErrorValid()) continue;

      float timeError    = (*oneHit).timeError();
      // the constant used to build timeError is largely over-estimated ; remove in quadrature 0.6 and add 0.15 back.
      // could be prettier if value of constant term was changed at recHit production level
      if (timeError>0.6) timeError = sqrt( timeError*timeError - 0.6*0.6 + 0.15*0.15);
      else               timeError = sqrt( timeError*timeError           + 0.15*0.15);

      // do the error weighting
      weightedTsum += (*oneHit).time() / (timeError*timeError);
      sumOfWeights += 1. / (timeError*timeError);

    }
  
  // what if no crytal is available for weighted average?
  if     ( sumOfWeights ==0 )  return -999;
  else   return ( weightedTsum / sumOfWeights);

}
std::vector< float > EcalClusterLazyTools::covariances ( const reco::BasicCluster cluster,
float  w0 = 4.7 
)
float EcalClusterLazyTools::e1x3 ( const reco::BasicCluster cluster)

Definition at line 115 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
        return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e1x5 ( const reco::BasicCluster cluster)

Definition at line 127 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
        return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e2nd ( const reco::BasicCluster cluster)

Definition at line 229 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection().

Referenced by EGEnergyCorrector::CorrectedEnergyWithError().

{
        return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster) );
}
float EcalClusterLazyTools::e2x2 ( const reco::BasicCluster cluster)

Definition at line 139 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

Referenced by SoftElectronProducer::produce().

{
        return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e2x5Bottom ( const reco::BasicCluster cluster)

Definition at line 187 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::e2x5Left ( const reco::BasicCluster cluster)

Definition at line 175 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::e2x5Max ( const reco::BasicCluster cluster)

Definition at line 193 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::e2x5Right ( const reco::BasicCluster cluster)

Definition at line 169 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::e2x5Top ( const reco::BasicCluster cluster)

Definition at line 181 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::e3x1 ( const reco::BasicCluster cluster)

Definition at line 121 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
        return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e3x2 ( const reco::BasicCluster cluster)

Definition at line 145 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
        return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e3x3 ( const reco::BasicCluster cluster)
float EcalClusterLazyTools::e4x4 ( const reco::BasicCluster cluster)

Definition at line 157 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
        return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
}
float EcalClusterLazyTools::e5x5 ( const reco::BasicCluster cluster)
float EcalClusterLazyTools::eBottom ( const reco::BasicCluster cluster)
float EcalClusterLazyTools::eLeft ( const reco::BasicCluster cluster)
float EcalClusterLazyTools::eMax ( const reco::BasicCluster cluster)
std::vector< float > EcalClusterLazyTools::energyBasketFractionEta ( const reco::BasicCluster cluster)

Definition at line 241 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection().

std::vector< float > EcalClusterLazyTools::energyBasketFractionPhi ( const reco::BasicCluster cluster)

Definition at line 247 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection().

float EcalClusterLazyTools::eRight ( const reco::BasicCluster cluster)
float EcalClusterLazyTools::eTop ( const reco::BasicCluster cluster)
void EcalClusterLazyTools::getADCToGeV ( const edm::EventSetup es) [private]

Definition at line 82 of file EcalClusterLazyTools.cc.

References agc, and edm::EventSetup::get().

Referenced by EcalClusterLazyTools().

{
  // get ADCtoGeV
  es.get<EcalADCToGeVConstantRcd>().get(agc);
}
void EcalClusterLazyTools::getEBRecHits ( const edm::Event ev,
edm::InputTag  redEBRecHits 
) [private]

Definition at line 55 of file EcalClusterLazyTools.cc.

References ebRecHits_, edm::Event::getByLabel(), and edm::Handle< T >::product().

Referenced by EcalClusterLazyTools().

{
        edm::Handle< EcalRecHitCollection > pEBRecHits;
        ev.getByLabel( redEBRecHits, pEBRecHits );
        ebRecHits_ = pEBRecHits.product();
}
const EcalRecHitCollection * EcalClusterLazyTools::getEcalRecHitCollection ( const reco::BasicCluster cluster) [private]

Definition at line 96 of file EcalClusterLazyTools.cc.

References ebRecHits_, EcalBarrel, EcalEndcap, eeRecHits_, Exception, and first.

Referenced by BasicClusterSeedTime(), BasicClusterTime(), covariances(), e1x3(), e1x5(), e2nd(), e2x2(), e2x5Bottom(), e2x5Left(), e2x5Max(), e2x5Right(), e2x5Top(), e3x1(), e3x2(), e3x3(), e4x4(), e5x5(), eBottom(), eLeft(), eMax(), energyBasketFractionEta(), energyBasketFractionPhi(), eRight(), eTop(), getMaximum(), lat(), localCovariances(), matrixEnergy(), scLocalCovariances(), zernike20(), and zernike42().

{
        if ( cluster.size() == 0 ) {
                throw cms::Exception("InvalidCluster") << "The cluster has no crystals!";
        }
        DetId id = (cluster.hitsAndFractions()[0]).first; // size is by definition > 0 -- FIXME??
        const EcalRecHitCollection *recHits = 0;
        if ( id.subdetId() == EcalBarrel ) {
                recHits = ebRecHits_;
        } else if ( id.subdetId() == EcalEndcap ) {
                recHits = eeRecHits_;
        } else {
                throw cms::Exception("InvalidSubdetector") << "The subdetId() " << id.subdetId() << " does not correspond to EcalBarrel neither EcalEndcap";
        }
        return recHits;
}
void EcalClusterLazyTools::getEERecHits ( const edm::Event ev,
edm::InputTag  redEERecHits 
) [private]

Definition at line 64 of file EcalClusterLazyTools.cc.

References eeRecHits_, edm::Event::getByLabel(), and edm::Handle< T >::product().

Referenced by EcalClusterLazyTools().

{
        edm::Handle< EcalRecHitCollection > pEERecHits;
        ev.getByLabel( redEERecHits, pEERecHits );
        eeRecHits_ = pEERecHits.product();
}
void EcalClusterLazyTools::getGeometry ( const edm::EventSetup es) [private]

Definition at line 37 of file EcalClusterLazyTools.cc.

References geometry_, edm::EventSetup::get(), and edm::ESHandle< T >::product().

Referenced by EcalClusterLazyTools().

{
        edm::ESHandle<CaloGeometry> pGeometry;
        es.get<CaloGeometryRecord>().get(pGeometry);
        geometry_ = pGeometry.product();
}
void EcalClusterLazyTools::getIntercalibConstants ( const edm::EventSetup es) [private]

Definition at line 73 of file EcalClusterLazyTools.cc.

References edm::EventSetup::get(), ical, and icalMap.

Referenced by EcalClusterLazyTools().

{
  // get IC's
  es.get<EcalIntercalibConstantsRcd>().get(ical);
  icalMap = ical->getMap();
}
void EcalClusterLazyTools::getLaserDbService ( const edm::EventSetup es) [private]

Definition at line 90 of file EcalClusterLazyTools.cc.

References edm::EventSetup::get(), and laser.

Referenced by EcalClusterLazyTools().

                                                                          {
  // transp corrections
  es.get<EcalLaserDbRecord>().get(laser);
}
std::pair< DetId, float > EcalClusterLazyTools::getMaximum ( const reco::BasicCluster cluster)
void EcalClusterLazyTools::getTopology ( const edm::EventSetup es) [private]

Definition at line 46 of file EcalClusterLazyTools.cc.

References edm::EventSetup::get(), edm::ESHandle< T >::product(), and topology_.

Referenced by EcalClusterLazyTools().

{
        edm::ESHandle<CaloTopology> pTopology;
        es.get<CaloTopologyRecord>().get(pTopology);
        topology_ = pTopology.product();
}
std::vector< float > EcalClusterLazyTools::lat ( const reco::BasicCluster cluster,
bool  logW = true,
float  w0 = 4.7 
)

Definition at line 253 of file EcalClusterLazyTools.cc.

References geometry_, and getEcalRecHitCollection().

{
        return EcalClusterTools::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
}
std::vector< float > EcalClusterLazyTools::localCovariances ( const reco::BasicCluster cluster,
float  w0 = 4.7 
)
std::vector< DetId > EcalClusterLazyTools::matrixDetId ( DetId  id,
int  ixMin,
int  ixMax,
int  iyMin,
int  iyMax 
)

Definition at line 285 of file EcalClusterLazyTools.cc.

References topology_.

Referenced by EcalDigiSelector::produce().

{
        return EcalClusterTools::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
}
float EcalClusterLazyTools::matrixEnergy ( const reco::BasicCluster cluster,
DetId  id,
int  ixMin,
int  ixMax,
int  iyMin,
int  iyMax 
)

Definition at line 290 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

{
  return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
}
std::vector< float > EcalClusterLazyTools::scLocalCovariances ( const reco::SuperCluster cluster,
float  w0 = 4.7 
)

Definition at line 269 of file EcalClusterLazyTools.cc.

References getEcalRecHitCollection(), and topology_.

float EcalClusterLazyTools::SuperClusterSeedTime ( const reco::SuperCluster cluster)

Definition at line 380 of file EcalClusterLazyTools.cc.

References BasicClusterSeedTime(), and reco::SuperCluster::seed().

                                                                               {

  return BasicClusterSeedTime ( (*cluster.seed()) );

}
float EcalClusterLazyTools::SuperClusterTime ( const reco::SuperCluster cluster,
const edm::Event ev 
)

Definition at line 388 of file EcalClusterLazyTools.cc.

References BasicClusterTime(), and reco::SuperCluster::seed().

                                                                                               {
  
  return BasicClusterTime ( (*cluster.seed()) , ev);

}
double EcalClusterLazyTools::zernike20 ( const reco::BasicCluster cluster,
double  R0 = 6.6,
bool  logW = true,
float  w0 = 4.7 
)

Definition at line 274 of file EcalClusterLazyTools.cc.

References geometry_, and getEcalRecHitCollection().

{
        return EcalClusterTools::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
}
double EcalClusterLazyTools::zernike42 ( const reco::BasicCluster cluster,
double  R0 = 6.6,
bool  logW = true,
float  w0 = 4.7 
)

Definition at line 280 of file EcalClusterLazyTools.cc.

References geometry_, and getEcalRecHitCollection().

{
        return EcalClusterTools::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
}

Member Data Documentation

Definition at line 126 of file EcalClusterLazyTools.h.

Referenced by BasicClusterTime(), and getADCToGeV().

Definition at line 120 of file EcalClusterLazyTools.h.

Referenced by getEBRecHits(), and getEcalRecHitCollection().

Definition at line 121 of file EcalClusterLazyTools.h.

Referenced by getEcalRecHitCollection(), and getEERecHits().

Definition at line 118 of file EcalClusterLazyTools.h.

Referenced by covariances(), getGeometry(), lat(), zernike20(), and zernike42().

Definition at line 124 of file EcalClusterLazyTools.h.

Referenced by getIntercalibConstants().

Definition at line 125 of file EcalClusterLazyTools.h.

Referenced by BasicClusterTime(), and getIntercalibConstants().

Definition at line 127 of file EcalClusterLazyTools.h.

Referenced by BasicClusterTime(), and getLaserDbService().