Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef EgammaElectronAlgos_EcalRegressionData_h
0002 #define EgammaElectronAlgos_EcalRegressionData_h
0003 
0004 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0005 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0006 #include "DataFormats/VertexReco/interface/Vertex.h"
0007 #include <vector>
0008 #include <cmath>
0009 
0010 class CaloGeometry;
0011 class CaloTopology;
0012 
0013 namespace reco {
0014   class SuperCluster;
0015 }
0016 
0017 class EcalRegressionData {
0018 public:
0019   EcalRegressionData() { clear(); }
0020 
0021   //this exists due to concerns that sub-cluster 1 is actually accessed
0022   //by subClusRawE_[0] and could potentially cause bugs
0023   //this although slightly wordy, makes it absolutely clear
0024   enum class SubClusNr { C1 = 0, C2 = 1, C3 = 2 };
0025 
0026   //direct accessors
0027   bool isEB() const { return isEB_; }
0028   float scRawEnergy() const { return scRawEnergy_; }
0029   float scCalibEnergy() const { return scCalibEnergy_; }
0030   float scPreShowerEnergy() const { return scPreShowerEnergy_; }
0031   float scEta() const { return scEta_; }
0032   float scPhi() const { return scPhi_; }
0033   float scEtaWidth() const { return scEtaWidth_; }
0034   float scPhiWidth() const { return scPhiWidth_; }
0035   int scNrAdditionalClusters() const { return scNrAdditionalClusters_; }
0036   float seedClusEnergy() const { return seedClusEnergy_; }
0037   float eMax() const { return eMax_; }
0038   float e2nd() const { return e2nd_; }
0039   float e3x3() const { return e3x3_; }
0040   float eTop() const { return eTop_; }
0041   float eBottom() const { return eBottom_; }
0042   float eLeft() const { return eLeft_; }
0043   float eRight() const { return eRight_; }
0044   float sigmaIEtaIEta() const { return sigmaIEtaIEta_; }
0045   float sigmaIEtaIPhi() const { return sigmaIEtaIPhi_; }
0046   float sigmaIPhiIPhi() const { return sigmaIPhiIPhi_; }
0047 
0048   float seedCrysPhiOrY() const { return seedCrysPhiOrY_; }
0049   float seedCrysEtaOrX() const { return seedCrysEtaOrX_; }
0050   float seedCrysIEtaOrIX() const { return seedCrysIEtaOrIX_; }
0051   float seedCrysIPhiOrIY() const { return seedCrysIPhiOrIY_; }
0052   float maxSubClusDR() const { return std::sqrt(maxSubClusDR2_); }
0053   float maxSubClusDRDPhi() const { return maxSubClusDRDPhi_; }
0054   float maxSubClusDRDEta() const { return maxSubClusDRDEta_; }
0055   float maxSubClusDRRawEnergy() const { return maxSubClusDRRawEnergy_; }
0056   const std::vector<float>& subClusRawEnergy() const { return subClusRawEnergy_; }
0057   const std::vector<float>& subClusDPhi() const { return subClusDPhi_; }
0058   const std::vector<float>& subClusDEta() const { return subClusDEta_; }
0059   int nrVtx() const { return nrVtx_; }
0060 
0061   //indirect accessors
0062   float scPreShowerEnergyOverSCRawEnergy() const { return divideBySCRawEnergy_(scPreShowerEnergy()); }
0063   float scSeedR9() const { return divideBySCRawEnergy_(e3x3()); }
0064   float seedClusEnergyOverSCRawEnergy() const { return divideBySCRawEnergy_(seedClusEnergy()); }
0065   float eMaxOverSCRawEnergy() const { return divideBySCRawEnergy_(eMax()); }
0066   float e2ndOverSCRawEnergy() const { return divideBySCRawEnergy_(e2nd()); }
0067   float seedLeftRightAsym() const;
0068   float seedTopBottomAsym() const;
0069   float maxSubClusDRRawEnergyOverSCRawEnergy() const { return divideBySCRawEnergy_(maxSubClusDRRawEnergy()); }
0070   float subClusRawEnergyOverSCRawEnergy(size_t clusNr) const { return divideBySCRawEnergy_(subClusRawEnergy(clusNr)); }
0071   float subClusRawEnergy(size_t clusNr) const;
0072   float subClusDPhi(size_t clusNr) const;
0073   float subClusDEta(size_t clusNr) const;
0074   float subClusRawEnergyOverSCRawEnergy(SubClusNr clusNr) const {
0075     return subClusRawEnergyOverSCRawEnergy(static_cast<int>(clusNr));
0076   }
0077   float subClusRawEnergy(SubClusNr clusNr) const { return subClusRawEnergy(static_cast<int>(clusNr)); }
0078   float subClusDPhi(SubClusNr clusNr) const { return subClusDPhi(static_cast<int>(clusNr)); }
0079   float subClusDEta(SubClusNr clusNr) const { return subClusDEta(static_cast<int>(clusNr)); }
0080 
0081   //modifiers
0082   void fill(const reco::SuperCluster& superClus,
0083             const EcalRecHitCollection* ebRecHits,
0084             const EcalRecHitCollection* eeRecHits,
0085             const CaloGeometry* geom,
0086             const CaloTopology* topology,
0087             const reco::VertexCollection* vertices) {
0088     fill(superClus, ebRecHits, eeRecHits, geom, topology, vertices->size());
0089   }
0090   void fill(const reco::SuperCluster& superClus,
0091             const EcalRecHitCollection* ebRecHits,
0092             const EcalRecHitCollection* eeRecHits,
0093             const CaloGeometry* geom,
0094             const CaloTopology* topology,
0095             int nrVertices);
0096   void clear();
0097 
0098   //converts output to single vector for use in training
0099   void fillVec(std::vector<float>& inputVec) const;
0100 
0101 private:
0102   //0 is obviously not a sensible energy for a supercluster so just return zero if this is the case
0103   float divideBySCRawEnergy_(float numer) const { return scRawEnergy() != 0 ? numer / scRawEnergy() : 0.; }
0104   void fillVecEB_(std::vector<float>& inputVec) const;
0105   void fillVecEE_(std::vector<float>& inputVec) const;
0106 
0107 private:
0108   bool isEB_;
0109 
0110   //supercluster quantities
0111   float scRawEnergy_;
0112   float scCalibEnergy_;
0113   float scPreShowerEnergy_;
0114   float scEta_;
0115   float scPhi_;
0116   float scEtaWidth_;
0117   float scPhiWidth_;
0118   int scNrAdditionalClusters_;  //excludes seed cluster
0119 
0120   //seed cluster quantities
0121   float seedClusEnergy_;
0122   float eMax_;
0123   float e2nd_;
0124   float e3x3_;
0125   float eTop_;
0126   float eBottom_;
0127   float eLeft_;
0128   float eRight_;
0129   float sigmaIEtaIEta_;
0130   float sigmaIEtaIPhi_;
0131   float sigmaIPhiIPhi_;
0132 
0133   //seed crystal quantities
0134   float seedCrysPhiOrY_;
0135   float seedCrysEtaOrX_;
0136   int seedCrysIEtaOrIX_;
0137   int seedCrysIPhiOrIY_;
0138 
0139   //sub cluster (non-seed) quantities
0140   float maxSubClusDR2_;
0141   float maxSubClusDRDPhi_;
0142   float maxSubClusDRDEta_;
0143   float maxSubClusDRRawEnergy_;
0144   std::vector<float> subClusRawEnergy_;
0145   std::vector<float> subClusDPhi_;
0146   std::vector<float> subClusDEta_;
0147 
0148   //event quantities
0149   int nrVtx_;
0150 };
0151 
0152 #endif