Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:24

0001 #include "RecoEgamma/EgammaTools/interface/HGCalClusterTools.h"
0002 
0003 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0004 #include "DataFormats/Math/interface/deltaR.h"
0005 #include "DataFormats/Math/interface/deltaPhi.h"
0006 
0007 float HGCalClusterTools::energyInCone(const float eta,
0008                                       const float phi,
0009                                       const std::vector<reco::CaloCluster>& layerClusters,
0010                                       const float minDR,
0011                                       const float maxDR,
0012                                       const float minEt,
0013                                       const float minEnergy,
0014                                       const std::vector<DetId::Detector>& subDets,
0015                                       const HGCalClusterTools::EType& eType) {
0016   float hadValue = 0.;
0017 
0018   const float minDR2 = minDR * minDR;
0019   const float maxDR2 = maxDR * maxDR;
0020 
0021   for (auto& clus : layerClusters) {
0022     if (clus.energy() < minEnergy) {
0023       continue;
0024     }
0025 
0026     if (std::find(subDets.begin(), subDets.end(), clus.seed().det()) == subDets.end()) {
0027       continue;
0028     }
0029 
0030     float clusEt = clus.energy() * std::sin(clus.position().theta());
0031     if (clusEt < minEt) {
0032       continue;
0033     }
0034 
0035     //this is a prefilter on the clusters before we calculuate
0036     //the expensive eta() of the cluster
0037     float dPhi = reco::deltaPhi(phi, clus.phi());
0038     if (dPhi > maxDR) {
0039       continue;
0040     }
0041 
0042     float dR2 = reco::deltaR2(eta, phi, clus.eta(), clus.phi());
0043     if (dR2 < minDR2 || dR2 > maxDR2) {
0044       continue;
0045     }
0046     switch (eType) {
0047       case EType::ET:
0048         hadValue += clusEt;
0049         break;
0050       case EType::ENERGY:
0051         hadValue += clus.energy();
0052         break;
0053     }
0054   }
0055   return hadValue;
0056 }