CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions

CaloSpecificAlgo Class Reference

#include <RecoMET/METAlgorithms/interface/CaloSpecificAlgo.h>

List of all members.

Public Member Functions

reco::CaloMET addInfo (edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)

Private Types

typedef math::XYZTLorentzVector LorentzVector
typedef math::XYZPoint Point

Private Member Functions

void add_MET_in_HF (SpecificCaloMETData &specific, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
DetId find_DetId_of_ECAL_cell_in_constituent_of (const CaloTower *calotower)
DetId find_DetId_of_HCAL_cell_in_constituent_of (const CaloTower *calotower)
void initializeSpecificCaloMETData (SpecificCaloMETData &specific)
void remove_HF_from_MET (CommonMETData &met, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
void update_EmEtInEB_EmEtInEE (double &EmEtInEB, double &EmEtInEE, const CaloTower *calotower)
void update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF (double &HadEtInHB, double &HadEtInHE, double &HadEtInHO, double &HadEtInHF, double &EmEtInHF, const CaloTower *calotower, bool noHF)
void update_MaxTowerEm_MaxTowerHad (double &MaxTowerEm, double &MaxTowerHad, const CaloTower *calotower, bool noHF)
void update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF (double &sumEtInpHF, double &MExInpHF, double &MEyInpHF, double &sumEtInmHF, double &MExInmHF, double &MEyInmHF, const CaloTower *calotower)
void update_totalEt_totalEm (double &totalEt, double &totalEm, const CaloTower *calotower, bool noHF)

Detailed Description

Description: Adds Calorimeter specific information to MET base class

Implementation: [Notes on implementation]

Definition at line 38 of file CaloSpecificAlgo.h.


Member Typedef Documentation

Definition at line 45 of file CaloSpecificAlgo.h.

Definition at line 46 of file CaloSpecificAlgo.h.


Member Function Documentation

void CaloSpecificAlgo::add_MET_in_HF ( SpecificCaloMETData specific,
double  sumEtInpHF,
double  MExInpHF,
double  MEyInpHF,
double  sumEtInmHF,
double  MExInmHF,
double  MEyInmHF 
) [private]

Definition at line 207 of file CaloSpecificAlgo.cc.

References SpecificCaloMETData::CaloMETInmHF, SpecificCaloMETData::CaloMETInpHF, SpecificCaloMETData::CaloMETPhiInmHF, SpecificCaloMETData::CaloMETPhiInpHF, SpecificCaloMETData::CaloSETInmHF, SpecificCaloMETData::CaloSETInpHF, and mathSSE::sqrt().

{
  LorentzVector METpHF(MExInpHF, MEyInpHF, 0, sqrt(MExInpHF*MExInpHF + MEyInpHF*MEyInpHF));
  LorentzVector METmHF(MExInmHF, MEyInmHF, 0, sqrt(MExInmHF*MExInmHF + MEyInmHF*MEyInmHF));
  specific.CaloMETInpHF = METpHF.pt();
  specific.CaloMETInmHF = METmHF.pt();
  specific.CaloMETPhiInpHF = METpHF.Phi();
  specific.CaloMETPhiInmHF = METmHF.Phi();
  specific.CaloSETInpHF = sumEtInpHF;
  specific.CaloSETInmHF = sumEtInmHF;
}
reco::CaloMET CaloSpecificAlgo::addInfo ( edm::Handle< edm::View< reco::Candidate > >  towers,
CommonMETData  met,
bool  noHF,
double  globalThreshold 
)

Definition at line 27 of file CaloSpecificAlgo.cc.

References SpecificCaloMETData::EmEtInEB, SpecificCaloMETData::EmEtInEE, SpecificCaloMETData::EmEtInHF, CaloTower::et(), SpecificCaloMETData::EtFractionEm, SpecificCaloMETData::EtFractionHadronic, SpecificCaloMETData::HadEtInHB, SpecificCaloMETData::HadEtInHE, SpecificCaloMETData::HadEtInHF, SpecificCaloMETData::HadEtInHO, SpecificCaloMETData::MaxEtInEmTowers, SpecificCaloMETData::MaxEtInHadTowers, CommonMETData::met, CommonMETData::mex, CommonMETData::mey, p4, timingPdfMaker::specific, and CommonMETData::sumet.

Referenced by cms::METProducer::produce_CaloMET().

{ 
  SpecificCaloMETData specific;
  initializeSpecificCaloMETData(specific);

  double totalEt = 0.0; 
  double totalEm = 0.0;

  double sumEtInpHF = 0.0;
  double sumEtInmHF = 0.0;
  double MExInpHF = 0.0;
  double MEyInpHF = 0.0;
  double MExInmHF = 0.0;
  double MEyInmHF = 0.0;

  for(edm::View<Candidate>::const_iterator towerCand = towers->begin(); towerCand != towers->end(); ++towerCand ) 
    {
      const CaloTower* calotower = dynamic_cast<const CaloTower*> (&(*towerCand));
      if (!calotower) continue;
      if(calotower->et() < globalThreshold) continue;
      update_totalEt_totalEm(totalEt, totalEm, calotower, noHF);
      update_MaxTowerEm_MaxTowerHad(specific.MaxEtInEmTowers, specific.MaxEtInHadTowers, calotower, noHF);
      update_EmEtInEB_EmEtInEE(specific.EmEtInEB, specific.EmEtInEE, calotower);
      update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(specific.HadEtInHB, specific.HadEtInHE, specific.HadEtInHO, specific.HadEtInHF, specific.EmEtInHF, calotower, noHF);
      update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF, calotower);
    }
  
  double totalHad = totalEt - totalEm;
  
  if(noHF) remove_HF_from_MET(met, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);

  if(!noHF) add_MET_in_HF(specific, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);

  specific.EtFractionHadronic = (totalEt == 0.0)? 0.0 : totalHad/totalEt;
  specific.EtFractionEm = (totalEt == 0.0)? 0.0 : totalEm/totalEt;

  const LorentzVector p4( met.mex, met.mey, 0.0, met.met);
  const Point vtx(0.0, 0.0, 0.0);
  CaloMET caloMET(specific, met.sumet, p4, vtx);
  return caloMET;
}
DetId CaloSpecificAlgo::find_DetId_of_ECAL_cell_in_constituent_of ( const CaloTower calotower) [private]

Definition at line 236 of file CaloSpecificAlgo.cc.

References CaloTower::constituent(), CaloTower::constituentsSize(), DetId::Ecal, and run_regression::ret.

{
  DetId ret;
  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
    {
      DetId id = calotower->constituent( cell );
      if( id.det() == DetId::Ecal )
        {
          ret = id;
          break;
        }
    }
  return ret;
}
DetId CaloSpecificAlgo::find_DetId_of_HCAL_cell_in_constituent_of ( const CaloTower calotower) [private]

Definition at line 220 of file CaloSpecificAlgo.cc.

References CaloTower::constituent(), CaloTower::constituentsSize(), DetId::Hcal, and run_regression::ret.

{
  DetId ret;
  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
    {
      DetId id = calotower->constituent( cell );
      if( id.det() == DetId::Hcal )
        {
          ret = id;
          break;
        }
    }
  return ret;
}
void CaloSpecificAlgo::initializeSpecificCaloMETData ( SpecificCaloMETData specific) [private]

Definition at line 70 of file CaloSpecificAlgo.cc.

References SpecificCaloMETData::CaloMETInmHF, SpecificCaloMETData::CaloMETInpHF, SpecificCaloMETData::CaloMETPhiInmHF, SpecificCaloMETData::CaloMETPhiInpHF, SpecificCaloMETData::CaloSETInmHF, SpecificCaloMETData::CaloSETInpHF, SpecificCaloMETData::EmEtInEB, SpecificCaloMETData::EmEtInEE, SpecificCaloMETData::EmEtInHF, SpecificCaloMETData::EtFractionEm, SpecificCaloMETData::EtFractionHadronic, SpecificCaloMETData::HadEtInHB, SpecificCaloMETData::HadEtInHE, SpecificCaloMETData::HadEtInHF, SpecificCaloMETData::HadEtInHO, SpecificCaloMETData::MaxEtInEmTowers, SpecificCaloMETData::MaxEtInHadTowers, and SpecificCaloMETData::METSignificance.

{
  specific.MaxEtInEmTowers = 0.0;    // Maximum energy in EM towers
  specific.MaxEtInHadTowers = 0.0;   // Maximum energy in HCAL towers
  specific.HadEtInHO = 0.0;          // Hadronic energy fraction in HO
  specific.HadEtInHB = 0.0;          // Hadronic energy in HB
  specific.HadEtInHF = 0.0;          // Hadronic energy in HF
  specific.HadEtInHE = 0.0;          // Hadronic energy in HE
  specific.EmEtInEB = 0.0;           // Em energy in EB
  specific.EmEtInEE = 0.0;           // Em energy in EE
  specific.EmEtInHF = 0.0;           // Em energy in HF
  specific.EtFractionHadronic = 0.0; // Hadronic energy fraction
  specific.EtFractionEm = 0.0;       // Em energy fraction
  specific.METSignificance = 0.0;
  specific.CaloMETInpHF = 0.0;        // CaloMET in HF+ 
  specific.CaloMETInmHF = 0.0;        // CaloMET in HF- 
  specific.CaloSETInpHF = 0.0;        // CaloSET in HF+ 
  specific.CaloSETInmHF = 0.0;        // CaloSET in HF- 
  specific.CaloMETPhiInpHF = 0.0;     // CaloMET-phi in HF+ 
  specific.CaloMETPhiInmHF = 0.0;     // CaloMET-phi in HF- 
}
void CaloSpecificAlgo::remove_HF_from_MET ( CommonMETData met,
double  sumEtInpHF,
double  MExInpHF,
double  MEyInpHF,
double  sumEtInmHF,
double  MExInmHF,
double  MEyInmHF 
) [private]

Definition at line 198 of file CaloSpecificAlgo.cc.

References CommonMETData::met, CommonMETData::mex, CommonMETData::mey, mathSSE::sqrt(), and CommonMETData::sumet.

{
  met.mex -= (MExInmHF + MExInpHF);
  met.mey -= (MEyInmHF + MEyInpHF);
  met.sumet -= (sumEtInpHF + sumEtInmHF);
  met.met = sqrt(met.mex*met.mex + met.mey*met.mey);   
}
void CaloSpecificAlgo::update_EmEtInEB_EmEtInEE ( double &  EmEtInEB,
double &  EmEtInEE,
const CaloTower calotower 
) [private]

Definition at line 133 of file CaloSpecificAlgo.cc.

References EcalBarrel, EcalEndcap, CaloTower::emEt(), DetId::null(), and DetId::subdetId().

{
  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
  if(detIdEcal.null()) return;

  EcalSubdetector subdet = EcalSubdetector( detIdEcal.subdetId() );
  if( subdet == EcalBarrel )
    {
      EmEtInEB += calotower->emEt(); 
    }
  else if( subdet == EcalEndcap ) 
    {
      EmEtInEE += calotower->emEt();
    }
}
void CaloSpecificAlgo::update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF ( double &  HadEtInHB,
double &  HadEtInHE,
double &  HadEtInHO,
double &  HadEtInHF,
double &  EmEtInHF,
const CaloTower calotower,
bool  noHF 
) [private]

Definition at line 150 of file CaloSpecificAlgo.cc.

References CaloTower::emEt(), CaloTower::hadEt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, DetId::null(), CaloTower::outerEt(), and HcalDetId::subdet().

{
  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
  if(detIdHcal.null()) return;

  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
  if( subdet == HcalBarrel || subdet == HcalOuter )
    {
      HadEtInHB += calotower->hadEt();
      HadEtInHO += calotower->outerEt();
    }

  if( subdet == HcalEndcap )
    {
      HadEtInHE += calotower->hadEt();
    }

  if( subdet == HcalForward && !noHF)
    {
      HadEtInHF += calotower->hadEt();
      EmEtInHF += calotower->emEt();
    }
}
void CaloSpecificAlgo::update_MaxTowerEm_MaxTowerHad ( double &  MaxTowerEm,
double &  MaxTowerHad,
const CaloTower calotower,
bool  noHF 
) [private]

Definition at line 110 of file CaloSpecificAlgo.cc.

References CaloTower::emEt(), CaloTower::hadEt(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, DetId::null(), and HcalDetId::subdet().

{
  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);

  if( !detIdHcal.null() )
    {
      HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
      if( subdet == HcalBarrel || subdet == HcalOuter || subdet == HcalEndcap || (!noHF && subdet == HcalForward))
        {
          if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
          if( calotower->emEt() > MaxTowerEm  ) MaxTowerEm  = calotower->emEt();
        }

    }

  if( !detIdEcal.null() )
    {
      if( calotower->emEt() > MaxTowerEm ) MaxTowerEm = calotower->emEt();
    }
}
void CaloSpecificAlgo::update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF ( double &  sumEtInpHF,
double &  MExInpHF,
double &  MEyInpHF,
double &  sumEtInmHF,
double &  MExInmHF,
double &  MEyInmHF,
const CaloTower calotower 
) [private]

Definition at line 175 of file CaloSpecificAlgo.cc.

References funct::cos(), CaloTower::et(), reco::LeafCandidate::eta(), HcalForward, DetId::null(), reco::LeafCandidate::phi(), funct::sin(), and HcalDetId::subdet().

{
  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
  if(detIdHcal.null()) return;

  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
  if( !(subdet == HcalForward) ) return;

  if (calotower->eta() >= 0)
    {
      sumEtInpHF += calotower->et();
      MExInpHF -= (calotower->et() * cos(calotower->phi()));
      MEyInpHF -= (calotower->et() * sin(calotower->phi()));
    }
  else
    {
      sumEtInmHF += calotower->et();
      MExInmHF -= (calotower->et() * cos(calotower->phi()));
      MEyInmHF -= (calotower->et() * sin(calotower->phi()));
    }
}
void CaloSpecificAlgo::update_totalEt_totalEm ( double &  totalEt,
double &  totalEm,
const CaloTower calotower,
bool  noHF 
) [private]

Definition at line 93 of file CaloSpecificAlgo.cc.

References CaloTower::emEt(), CaloTower::et(), HcalForward, DetId::null(), and HcalDetId::subdet().

{
  if( noHF )
    {
      DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
      if(!detIdHcal.null()) 
        {
          HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
          if( subdet == HcalForward ) return;
        }
    }

  totalEt += calotower->et();
  totalEm += calotower->emEt();
}