CMS 3D CMS Logo

Public Member Functions | Private Attributes

calib::CalibElectron Class Reference

#include <CalibElectron.h>

List of all members.

Public Member Functions

 CalibElectron ()
 CalibElectron (const reco::GsfElectron *ele, const EcalRecHitCollection *theHits, const EcalRecHitCollection *theEEHits)
std::vector< std::pair< int,
float > > 
getCalibModulesWeights (TString calibtype)
const EcalRecHitCollectiongetEERecHits ()
const EcalRecHitCollectiongetRecHits ()
const reco::GsfElectrongetRecoElectron ()
 ~CalibElectron ()

Private Attributes

const EcalRecHitCollectiontheEEHits_
const reco::GsfElectrontheElectron_
const EcalRecHitCollectiontheHits_

Detailed Description

Definition at line 16 of file CalibElectron.h.


Constructor & Destructor Documentation

CalibElectron::CalibElectron ( )

Definition at line 15 of file CalibElectron.cc.

                             : theElectron_(0), theHits_(0), theEEHits_(0)
{
}
calib::CalibElectron::CalibElectron ( const reco::GsfElectron ele,
const EcalRecHitCollection theHits,
const EcalRecHitCollection theEEHits 
) [inline]

Definition at line 21 of file CalibElectron.h.

                                                                                                                          : 
      theElectron_(ele),
      theHits_(theHits), 
      theEEHits_(theEEHits) 
      {
      };
calib::CalibElectron::~CalibElectron ( ) [inline]

Definition at line 28 of file CalibElectron.h.

{};

Member Function Documentation

std::vector< std::pair< int, float > > CalibElectron::getCalibModulesWeights ( TString  calibtype)

Definition at line 20 of file CalibElectron.cc.

References gather_cfg::cout, EcalBarrel, EcalEndcap, CaloRecHit::energy(), eta(), reco::LeafCandidate::eta(), funct::exp(), edm::SortedCollection< T, SORT >::find(), EcalIndexingTools::getInstance(), EcalRingCalibrationTools::getModuleIndex(), EcalIndexingTools::getNumberOfChannels(), EcalIndexingTools::getProgressiveIndex(), EcalRingCalibrationTools::getRingIndex(), i, recoMuon::in, EcalRingCalibrationTools::N_MODULES_BARREL, EcalRingCalibrationTools::N_RING_TOTAL, funct::sin(), reco::GsfElectron::superCluster(), theEEHits_, theElectron_, theHits_, and theta().

{
  std::vector< std::pair<int,float> > theWeights;

  if (calibtype == "RING")
    {
      float w_ring[EcalRingCalibrationTools::N_RING_TOTAL];

      for (int i=0;i<EcalRingCalibrationTools::N_RING_TOTAL;++i)
        w_ring[i]=0.;
      
      std::vector<std::pair<DetId,float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();

      
      for(std::vector<std::pair<DetId,float> >::const_iterator idIt=scDetIds.begin(); idIt!=scDetIds.end(); ++idIt){
    
        const EcalRecHit* rh=0;
        if ( (*idIt).first.subdetId() == EcalBarrel) 
          rh = &*(theHits_->find((*idIt).first));
        else if ( (*idIt).first.subdetId() == EcalEndcap) 
          rh = &*(theEEHits_->find((*idIt).first));
        if (!rh)
          std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;  
        w_ring[EcalRingCalibrationTools::getRingIndex((*idIt).first)]+=rh->energy();
        
      }

      for (int i=0;i<EcalRingCalibrationTools::N_RING_TOTAL;++i)
        if (w_ring[i]!=0.) 
          theWeights.push_back(std::pair<int,float>(i,w_ring[i]));
          // std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;
    }

  else if(calibtype == "MODULE")
    {

      float w_ring[EcalRingCalibrationTools::N_MODULES_BARREL];

      for (int i=0;i<EcalRingCalibrationTools::N_MODULES_BARREL;++i)
        w_ring[i]=0.;

      std::vector<std::pair<DetId,float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();


      for(std::vector<std::pair<DetId,float> >::const_iterator idIt=scDetIds.begin(); idIt!=scDetIds.end(); ++idIt){

        const EcalRecHit* rh=0;
        if ( (*idIt).first.subdetId() == EcalBarrel)
          rh = &*(theHits_->find((*idIt).first));
        else if ( (*idIt).first.subdetId() == EcalEndcap)
          rh = &*(theEEHits_->find((*idIt).first));
        if (!rh)
          std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
        w_ring[EcalRingCalibrationTools::getModuleIndex((*idIt).first)]+=rh->energy();

      }

      for (int i=0;i<EcalRingCalibrationTools::N_MODULES_BARREL;++i)
        if (w_ring[i]!=0.)
          theWeights.push_back(std::pair<int,float>(i,w_ring[i]));
      // std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;                            

    }

  else if(calibtype == "ABS_SCALE")
    {
      std::cout<< "ENTERING CalibElectron, ABS SCALE mode"<<std::endl;

      float w_ring(0.);
      
      std::vector<std::pair<DetId,float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();


      for(std::vector<std::pair<DetId,float> >::const_iterator idIt=scDetIds.begin(); idIt!=scDetIds.end(); ++idIt){
        
        const EcalRecHit* rh=0;
        if ( (*idIt).first.subdetId() == EcalBarrel)
          rh = &*(theHits_->find((*idIt).first));
        else if ( (*idIt).first.subdetId() == EcalEndcap)
          rh = &*(theEEHits_->find((*idIt).first));
        if (!rh)
          std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
        
        w_ring += rh->energy();
        
      }
      
      if(w_ring != 0.)
        theWeights.push_back(std::pair<int,float>(0,w_ring));
      std::cout << " ABS SCALE  - energy sum " << w_ring << std::endl;                            
      
    }
  
  else if(calibtype == "ETA_ET_MODE")
    {

      float w_ring[ 200 ];
      
      for (int i=0; i< EcalIndexingTools::getInstance()->getNumberOfChannels(); ++i)
        w_ring[i]=0.;

      std::vector<std::pair<DetId,float> > scDetIds = theElectron_->superCluster()->hitsAndFractions();


      for(std::vector<std::pair<DetId,float> >::const_iterator idIt=scDetIds.begin(); idIt!=scDetIds.end(); ++idIt){
        const EcalRecHit* rh=0;
        if ( (*idIt).first.subdetId() == EcalBarrel)
          rh = &*(theHits_->find((*idIt).first));
        else if ( (*idIt).first.subdetId() == EcalEndcap)
          rh = &*(theEEHits_->find((*idIt).first));
        if (!rh)
          std::cout << "CalibElectron::BIG ERROR::RecHit NOT FOUND" << std::endl;
        
        float eta = fabs( theElectron_->eta() );
        float theta = 2. * atan( exp(- eta) );
        float et = theElectron_->superCluster()->energy() * sin(theta);
        
        int in = EcalIndexingTools::getInstance()->getProgressiveIndex(eta, et);
        
        w_ring[in]+=rh->energy();
        //w_ring[in]+=theElectron_->superCluster()->energy();

        std::cout << "CalibElectron::filling channel " << in << " with value " << theElectron_->superCluster()->energy() << std::endl;
      }
      
      for (int i=0; i< EcalIndexingTools::getInstance()->getNumberOfChannels(); ++i){
        if (w_ring[i]!=0.){
          theWeights.push_back(std::pair<int,float>(i,w_ring[i]));
          std::cout << " ring " << i << " - energy sum " << w_ring[i] << std::endl;                            
        }
        
      }
      
    }
  
  else 
    {
      std::cout << "CalibType not yet implemented" << std::endl;
      
    }
  
  return theWeights;

}
const EcalRecHitCollection* calib::CalibElectron::getEERecHits ( ) [inline]

Definition at line 34 of file CalibElectron.h.

References theEEHits_.

{ return theEEHits_; }
const EcalRecHitCollection* calib::CalibElectron::getRecHits ( ) [inline]

Definition at line 33 of file CalibElectron.h.

References theHits_.

{ return theHits_; }
const reco::GsfElectron* calib::CalibElectron::getRecoElectron ( ) [inline]

Member Data Documentation

Definition at line 41 of file CalibElectron.h.

Referenced by getCalibModulesWeights(), and getEERecHits().

Definition at line 38 of file CalibElectron.h.

Referenced by getCalibModulesWeights(), and getRecoElectron().

Definition at line 40 of file CalibElectron.h.

Referenced by getCalibModulesWeights(), and getRecHits().