Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:05

0001 #ifndef PhysicsTools_PatAlgos_interface_SuperClusterHelper_h
0002 #define PhysicsTools_PatAlgos_interface_SuperClusterHelper_h
0003 
0004 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0005 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
0006 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0007 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0008 #include "DataFormats/PatCandidates/interface/Electron.h"
0009 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0010 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0011 
0012 class SuperClusterHelper {
0013 public:
0014   SuperClusterHelper(const reco::GsfElectron* electron,
0015                      const EcalRecHitCollection* rechits,
0016                      const CaloTopology*,
0017                      const CaloGeometry*);
0018   SuperClusterHelper(const pat::Electron* electron,
0019                      const EcalRecHitCollection* rechits,
0020                      const CaloTopology*,
0021                      const CaloGeometry*);
0022   ~SuperClusterHelper() {}
0023 
0024   float rawEnergy() const { return theSuperCluster_->rawEnergy(); }
0025   float eta() const { return theSuperCluster_->eta(); }
0026   float phi() const { return theSuperCluster_->phi(); }
0027   float etaWidth() const { return theSuperCluster_->etaWidth(); }
0028   float phiWidth() const { return theSuperCluster_->phiWidth(); }
0029   float clustersSize() const { return theSuperCluster_->clustersSize(); }
0030   float hadronicOverEm() const { return theElectron_->hadronicOverEm(); }
0031   float sigmaIetaIeta() const { return theElectron_->sigmaIetaIeta(); }
0032   float preshowerEnergy() const { return theSuperCluster_->preshowerEnergy(); }
0033   float preshowerEnergyOverRaw() const { return theSuperCluster_->preshowerEnergy() / theSuperCluster_->rawEnergy(); }
0034   float e3x3() const { return EcalClusterTools::e3x3(*seedCluster_, rechits_, topology_); }
0035   float e5x5() const { return EcalClusterTools::e5x5(*seedCluster_, rechits_, topology_); }
0036   float eMax() const { return EcalClusterTools::eMax(*seedCluster_, rechits_); }
0037   float e2nd() const { return EcalClusterTools::e2nd(*seedCluster_, rechits_); }
0038   float eTop() const { return EcalClusterTools::eTop(*seedCluster_, rechits_, topology_); }
0039   float eBottom() const { return EcalClusterTools::eBottom(*seedCluster_, rechits_, topology_); }
0040   float eLeft() const { return EcalClusterTools::eLeft(*seedCluster_, rechits_, topology_); }
0041   float eRight() const { return EcalClusterTools::eRight(*seedCluster_, rechits_, topology_); }
0042   float e2x5Max() const { return EcalClusterTools::e2x5Max(*seedCluster_, rechits_, topology_); }
0043   float e2x5Top() const { return EcalClusterTools::e2x5Top(*seedCluster_, rechits_, topology_); }
0044   float e2x5Bottom() const { return EcalClusterTools::e2x5Bottom(*seedCluster_, rechits_, topology_); }
0045   float e2x5Left() const { return EcalClusterTools::e2x5Left(*seedCluster_, rechits_, topology_); }
0046   float e2x5Right() const { return EcalClusterTools::e2x5Right(*seedCluster_, rechits_, topology_); }
0047   float r9() const {  //std::cout << " E3x3 " << e3x3() << " raw "  << theSuperCluster_->rawEnergy() << std::endl;
0048     return e3x3() / theSuperCluster_->rawEnergy();
0049   }
0050   float spp();
0051   float sep();
0052   float seedEta() const { return seedCluster_->eta(); }
0053   float seedPhi() const { return seedCluster_->phi(); }
0054   float seedEnergy() const { return seedCluster_->energy(); }
0055   int ietaSeed() {
0056     localCoordinates();
0057     return ietaSeed_;
0058   }
0059   int iphiSeed() {
0060     localCoordinates();
0061     return iphiSeed_;
0062   }
0063   float etaCrySeed() {
0064     localCoordinates();
0065     return etaCrySeed_;
0066   }
0067   float phiCrySeed() {
0068     localCoordinates();
0069     return phiCrySeed_;
0070   }
0071   float thetaTilt() {
0072     localCoordinates();
0073     return thetaTilt_;
0074   }
0075   float phiTilt() {
0076     localCoordinates();
0077     return phiTilt_;
0078   }
0079 
0080   // i=1,2,3 (0 would be the seed)
0081   float subClusterEnergy(unsigned i) const;
0082   float subClusterEta(unsigned i) const;
0083   float subClusterPhi(unsigned i) const;
0084   float subClusterEmax(unsigned i) const;
0085   float subClusterE3x3(unsigned i) const;
0086   // does not include the seed energy
0087   float eSubClusters() const { return eSubClusters_; }
0088 
0089   float esClusterEnergy(unsigned i) const;
0090   float esClusterEta(unsigned i) const;
0091   float esClusterPhi(unsigned i) const;
0092 
0093   float nPreshowerClusters() const { return nESClusters_; }
0094   float eESClusters() const { return eESClusters_; }
0095 
0096 private:
0097   const reco::GsfElectron* theElectron_;
0098   const reco::SuperCluster* theSuperCluster_;
0099   std::vector<const reco::CaloCluster*> theBasicClusters_;
0100   std::vector<const reco::CaloCluster*> theESClusters_;
0101   const reco::CaloCluster* seedCluster_;
0102   const EcalRecHitCollection* rechits_;
0103   const CaloTopology* topology_;
0104   const CaloGeometry* geometry_;
0105   bool barrel_;
0106 
0107   /// cached variables
0108   /// covariance matrix
0109   bool covComputed_;
0110   float spp_;
0111   float sep_;
0112   /// local coordinates
0113   bool localCoordinatesComputed_;
0114   int ietaSeed_;  // ix in the endcaps
0115   int iphiSeed_;  // iy in the endcaps
0116   float etaCrySeed_;
0117   float phiCrySeed_;
0118   float thetaTilt_;
0119   float phiTilt_;
0120   unsigned nBasicClusters_;
0121   unsigned nESClusters_;
0122   float eSubClusters_;
0123   float eESClusters_;
0124 
0125 private:
0126   void computeLocalCovariances();
0127   void localCoordinates();
0128 
0129   static bool sortClusters(const reco::CaloCluster* c1, const reco::CaloCluster* c2) {
0130     return (c1->energy() > c2->energy());
0131   }
0132 };
0133 
0134 #endif