CMS 3D CMS Logo

CaloSpecificAlgo Class Reference

Adds Calorimeter specific information to MET base class Author: R. More...

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

List of all members.

Public Types

typedef math::XYZTLorentzVector LorentzVector
typedef math::XYZPoint Point
typedef std::vector< const
reco::Candidate * > 
TowerCollection

Public Member Functions

reco::CaloMET addInfo (edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)
 Make CaloMET. Assumes MET is made from CaloTowerCandidates.


Detailed Description

Adds Calorimeter specific information to MET base class Author: R.

Cavanaugh (taken from F.Ratnikov, UMd) 6 June, 2006

Definition at line 13 of file CaloSpecificAlgo.h.


Member Typedef Documentation

typedef math::XYZTLorentzVector CaloSpecificAlgo::LorentzVector

Definition at line 16 of file CaloSpecificAlgo.h.

typedef math::XYZPoint CaloSpecificAlgo::Point

Definition at line 17 of file CaloSpecificAlgo.h.

typedef std::vector<const reco::Candidate*> CaloSpecificAlgo::TowerCollection

Definition at line 18 of file CaloSpecificAlgo.h.


Member Function Documentation

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

Make CaloMET. Assumes MET is made from CaloTowerCandidates.

Definition at line 18 of file CaloSpecificAlgo.cc.

References reco::LeafCandidate::begin(), SpecificCaloMETData::CaloMETInmHF, SpecificCaloMETData::CaloMETInpHF, SpecificCaloMETData::CaloMETPhiInmHF, SpecificCaloMETData::CaloMETPhiInpHF, SpecificCaloMETData::CaloSETInmHF, SpecificCaloMETData::CaloSETInpHF, CaloTower::constituent(), CaloTower::constituentsSize(), funct::cos(), DetId::Ecal, EcalBarrel, EcalEndcap, CaloTower::emEt(), SpecificCaloMETData::EmEtInEB, SpecificCaloMETData::EmEtInEE, SpecificCaloMETData::EmEtInHF, edm::View< T >::end(), reco::Particle::et(), reco::Particle::eta(), SpecificCaloMETData::EtFractionEm, SpecificCaloMETData::EtFractionHadronic, CaloTower::hadEt(), SpecificCaloMETData::HadEtInHB, SpecificCaloMETData::HadEtInHE, SpecificCaloMETData::HadEtInHF, SpecificCaloMETData::HadEtInHO, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, SpecificCaloMETData::MaxEtInEmTowers, SpecificCaloMETData::MaxEtInHadTowers, CommonMETData::met, SpecificCaloMETData::METSignificance, CommonMETData::mex, CommonMETData::mey, CaloTower::outerEt(), p4, reco::Particle::phi(), funct::sin(), funct::sqrt(), and CommonMETData::sumet.

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

00019 { 
00020   // Instantiate the container to hold the calorimeter specific information
00021   SpecificCaloMETData specific;
00022   // Initialise the container 
00023   specific.MaxEtInEmTowers = 0.0;         // Maximum energy in EM towers
00024   specific.MaxEtInHadTowers = 0.0;        // Maximum energy in HCAL towers
00025   specific.HadEtInHO = 0.0;          // Hadronic energy fraction in HO
00026   specific.HadEtInHB = 0.0;          // Hadronic energy in HB
00027   specific.HadEtInHF = 0.0;          // Hadronic energy in HF
00028   specific.HadEtInHE = 0.0;          // Hadronic energy in HE
00029   specific.EmEtInEB = 0.0;           // Em energy in EB
00030   specific.EmEtInEE = 0.0;           // Em energy in EE
00031   specific.EmEtInHF = 0.0;           // Em energy in HF
00032   specific.EtFractionHadronic = 0.0; // Hadronic energy fraction
00033   specific.EtFractionEm = 0.0;       // Em energy fraction
00034   specific.METSignificance = -1.0;    // MET Significance
00035   specific.CaloSETInpHF = 0.0;        // CaloSET in HF+ 
00036   specific.CaloSETInmHF = 0.0;        // CaloSET in HF- 
00037   specific.CaloMETInpHF = 0.0;        // CaloMET in HF+ 
00038   specific.CaloMETInmHF = 0.0;        // CaloMET in HF- 
00039   specific.CaloMETPhiInpHF = -999;     // CaloMET-phi in HF+ 
00040   specific.CaloMETPhiInmHF = -999;     // CaloMET-phi in HF- 
00041   
00042   double totalEt = 0.0; 
00043   double totalEm     = 0.0;
00044   double totalHad    = 0.0;
00045   double MaxTowerEm  = 0.0;
00046   double MaxTowerHad = 0.0;
00047   double sumEtInpHF = 0.0;
00048   double sumEtInmHF = 0.0;
00049   double MExInpHF = 0.0;
00050   double MEyInpHF = 0.0;
00051   double MExInmHF = 0.0;
00052   double MEyInmHF = 0.0;
00053 
00054   if( towers->size() == 0 )  // if there are no towers, return specific = 0
00055     {
00056    //   LogDebug("CaloMET") << "Number of Candidate CaloTowers is zero : Unable to calculate calo specific info. " ;
00057       const LorentzVector p4( met.mex, met.mey, 0.0, met.met );
00058       const Point vtx( 0.0, 0.0, 0.0 );
00059       CaloMET specificmet( specific, met.sumet, p4, vtx );
00060       return specificmet;
00061     }
00062   /*
00063   //retreive calo tower information from candidates
00064   //start with the first element of the candidate list
00065   CandidateCollection::const_iterator tower = towers->begin();
00066   //get the EDM references to the CaloTowers from the candidate list
00067   edm::Ref<CaloTowerCollection> towerRef = tower->get<CaloTowerRef>();
00068   */
00069   
00070   /*
00071   edm::Ref<CaloTowerCollection> towerRef = towers->begin()->get<CaloTowerRef>();
00072   //finally instantiate now, a list of pointers to the CaloTowers
00073   const CaloTowerCollection *towerCollection = towerRef.product();
00074   //iterate over all CaloTowers and record information
00075   CaloTowerCollection::const_iterator calotower = towerCollection->begin();
00076   */
00077 
00078   //edm::Ref<CaloTowerCollection> towerRef = towers->begin();
00079   //finally instantiate now, a list of pointers to the CaloTowers
00080   //const CaloTowerCollection *towerCollection = towerRef.product();
00081   //iterate over all CaloTowers and record information
00082   //CaloTowerCollection::const_iterator calotower = towerCollection->begin();
00083 
00084   edm::View<Candidate>::const_iterator towerCand = towers->begin();
00085 
00086 
00087   for( ; towerCand != towers->end(); towerCand++ ) 
00088        {
00089          const Candidate* candidate = &(*towerCand);
00090          if (candidate) {
00091            const CaloTower* calotower = dynamic_cast<const CaloTower*> (candidate);
00092            if (calotower)
00093              {
00094                if(calotower->et() < globalThreshold) continue;
00095                totalEt  += calotower->et();
00096                totalEm  += calotower->emEt();
00097                
00098                //totalHad += calotower->hadEt() + calotower->outerEt() ;
00099                
00100                bool hadIsDone = false;
00101                bool emIsDone = false;
00102                int cell = calotower->constituentsSize();
00103                while ( --cell >= 0 && (!hadIsDone || !emIsDone) ) 
00104                  {
00105                    DetId id = calotower->constituent( cell );
00106                    if( !hadIsDone && id.det() == DetId::Hcal ) 
00107                      {
00108                        HcalSubdetector subdet = HcalDetId(id).subdet();
00109                        if( subdet == HcalBarrel || subdet == HcalOuter )
00110                          {
00111                            if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
00112                            specific.HadEtInHB   += calotower->hadEt();
00113                            specific.HadEtInHO   += calotower->outerEt();
00114                          }
00115                        else if( subdet == HcalEndcap )
00116                          {
00117                            if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
00118                            specific.HadEtInHE   += calotower->hadEt();
00119                          }
00120                        else if( subdet == HcalForward )
00121                          {
00122                            if (!noHF)
00123                              {
00124                                if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
00125                                if( calotower->emEt()  > MaxTowerEm  ) MaxTowerEm  = calotower->emEt();
00126                                //These quantities should be nonzero only if HF is included, i.e., noHF == false
00127                                specific.HadEtInHF   += calotower->hadEt();
00128                                specific.EmEtInHF    += calotower->emEt();
00129                              }
00130                            else
00131                              {
00132                                //These quantities need to be corrected from above if HF is excluded
00133                                // totalHad             -= calotower->hadEt();  
00134                                totalEm              -= calotower->emEt();
00135                                totalEt              -= calotower->et();
00136                              }
00137                            // These get calculate regardless of NoHF == true or not.
00138                            // They are needed below for either case. 
00139                            if (calotower->eta()>=0)
00140                              {
00141                                sumEtInpHF  += calotower->et();
00142                                MExInpHF    -= (calotower->et() * cos(calotower->phi()));
00143                                MEyInpHF    -= (calotower->et() * sin(calotower->phi()));
00144                              }
00145                            else
00146                              {
00147                                sumEtInmHF  += calotower->et();
00148                                MExInmHF    -= (calotower->et() * cos(calotower->phi()));
00149                                MEyInmHF    -= (calotower->et() * sin(calotower->phi()));
00150                              }
00151                          }
00152                        hadIsDone = true;
00153                      }
00154                    else if( !emIsDone && id.det() == DetId::Ecal )
00155                      {
00156                        EcalSubdetector subdet = EcalSubdetector( id.subdetId() );
00157                        if( calotower->emEt()  > MaxTowerEm  ) MaxTowerEm  = calotower->emEt();
00158                        if( subdet == EcalBarrel )
00159                          {
00160                            specific.EmEtInEB    += calotower->emEt(); 
00161                          }
00162                        else if( subdet == EcalEndcap ) 
00163                          {
00164                            specific.EmEtInEE    += calotower->emEt();
00165                          }
00166                        emIsDone = true;
00167                      }
00168                  }
00169              }
00170          }
00171        }
00172   
00173   //Following Greg L's suggestion to calculate this quantity outside of the loop and to avoid confusion. 
00174   //This should work regardless of HO's inclusion / exclusion .
00175   totalHad += (totalEt - totalEm);
00176   
00177   if(!noHF)
00178     { // Form sub-det specific MET-vectors
00179       LorentzVector METpHF(MExInpHF, MEyInpHF, 0, sqrt(MExInpHF*MExInpHF + MEyInpHF*MEyInpHF));
00180       LorentzVector METmHF(MExInmHF, MEyInmHF, 0, sqrt(MExInmHF*MExInmHF + MEyInmHF*MEyInmHF));
00181       specific.CaloMETInpHF = METpHF.pt();
00182       specific.CaloMETInmHF = METmHF.pt();
00183       specific.CaloMETPhiInpHF = METpHF.Phi();
00184       specific.CaloMETPhiInmHF = METmHF.Phi();
00185       specific.CaloSETInpHF = sumEtInpHF;
00186       specific.CaloSETInmHF = sumEtInmHF;
00187     }
00188   else
00189     { // remove HF from MET calculation 
00190       met.mex   -= (MExInmHF + MExInpHF);
00191       met.mey   -= (MEyInmHF + MEyInpHF);
00192       met.sumet -= (sumEtInpHF + sumEtInmHF);
00193       met.met    = sqrt(met.mex*met.mex + met.mey*met.mey);   
00194     } 
00195 
00196   specific.MaxEtInEmTowers         = MaxTowerEm;  
00197   specific.MaxEtInHadTowers        = MaxTowerHad;         
00198   specific.EtFractionHadronic = totalHad / totalEt; 
00199   specific.EtFractionEm       =  totalEm / totalEt;       
00200 
00201   const LorentzVector p4( met.mex, met.mey, 0.0, met.met );
00202   const Point vtx( 0.0, 0.0, 0.0 );
00203   // Create and return an object of type CaloMET, which is a MET object with 
00204   // the extra calorimeter specfic information added
00205   CaloMET specificmet( specific, met.sumet, p4, vtx );
00206   return specificmet;
00207 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:15:58 2009 for CMSSW by  doxygen 1.5.4