Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:07

0001 #ifndef EgammaReco_SuperCluster_h
0002 #define EgammaReco_SuperCluster_h
0003 /** \class reco::SuperCluster SuperCluster.h DataFormats/EgammaReco/interface/SuperCluster.h
0004  *  
0005  * A SuperCluster reconstructed in the Electromagnetic Calorimeter
0006  * contains references to seed and constituent BasicClusters
0007  *
0008  * \author Luca Lista, INFN
0009  *
0010  *
0011  */
0012 #include "DataFormats/Math/interface/Point3D.h"
0013 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0014 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0017 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0018 
0019 namespace reco {
0020   class SuperCluster : public CaloCluster {
0021   public:
0022     typedef math::XYZPoint Point;
0023 
0024     /// default constructor
0025     SuperCluster()
0026         : CaloCluster(0., Point(0., 0., 0.)),
0027           preshowerEnergy_(0),
0028           rawEnergy_(-1.),
0029           phiWidth_(0),
0030           etaWidth_(0),
0031           preshowerEnergy1_(0),
0032           preshowerEnergy2_(0) {}
0033 
0034     /// constructor defined by CaloCluster - will have to use setSeed and add() separately
0035     SuperCluster(double energy, const Point& position);
0036 
0037     SuperCluster(double energy,
0038                  const Point& position,
0039                  const CaloClusterPtr& seed,
0040                  const CaloClusterPtrVector& clusters,
0041                  double Epreshower = 0.,
0042                  double phiWidth = 0.,
0043                  double etaWidth = 0.,
0044                  double Epreshower1 = 0.,
0045                  double Epreshower2 = 0.);
0046 
0047     // to be merged in the previous one? -- FIXME
0048     SuperCluster(double energy,
0049                  const Point& position,
0050                  const CaloClusterPtr& seed,
0051                  const CaloClusterPtrVector& clusters,
0052                  const CaloClusterPtrVector& preshowerClusters,
0053                  double Epreshower = 0.,
0054                  double phiWidth = 0.,
0055                  double etaWidth = 0.,
0056                  double Epreshower1 = 0.,
0057                  double Epreshower2 = 0.);
0058 
0059     /// raw uncorrected energy (sum of energies of component BasicClusters)
0060     double rawEnergy() const { return rawEnergy_; }
0061 
0062     /// energy deposited in preshower
0063     double preshowerEnergy() const { return preshowerEnergy_; }
0064     double preshowerEnergyPlane1() const { return preshowerEnergy1_; }
0065     double preshowerEnergyPlane2() const { return preshowerEnergy2_; }
0066 
0067     /// obtain phi and eta width of the Super Cluster
0068     double phiWidth() const { return phiWidth_; }
0069     double etaWidth() const { return etaWidth_; }
0070 
0071     //Assign new variables to supercluster
0072     void setPreshowerEnergy(double preshowerEnergy) { preshowerEnergy_ = preshowerEnergy; };
0073     void setPreshowerEnergyPlane1(double preshowerEnergy1) { preshowerEnergy1_ = preshowerEnergy1; };
0074     void setPreshowerEnergyPlane2(double preshowerEnergy2) { preshowerEnergy2_ = preshowerEnergy2; };
0075     void setPhiWidth(double pw) { phiWidth_ = pw; }
0076     void setEtaWidth(double ew) { etaWidth_ = ew; }
0077 
0078     /// seed BasicCluster
0079     const CaloClusterPtr& seed() const { return seed_; }
0080 
0081     /// const access to the cluster list itself
0082     const CaloClusterPtrVector& clusters() const { return clusters_; }
0083 
0084     /// const access to the preshower cluster list itself
0085     const CaloClusterPtrVector& preshowerClusters() const { return preshowerClusters_; }
0086 
0087     /// fist iterator over BasicCluster constituents
0088     CaloCluster_iterator clustersBegin() const { return clusters_.begin(); }
0089 
0090     /// last iterator over BasicCluster constituents
0091     CaloCluster_iterator clustersEnd() const { return clusters_.end(); }
0092 
0093     /// fist iterator over PreshowerCluster constituents
0094     CaloCluster_iterator preshowerClustersBegin() const { return preshowerClusters_.begin(); }
0095 
0096     /// last iterator over PreshowerCluster constituents
0097     CaloCluster_iterator preshowerClustersEnd() const { return preshowerClusters_.end(); }
0098 
0099     /// number of BasicCluster constituents
0100     size_t clustersSize() const { return clusters_.size(); }
0101 
0102     /// number of BasicCluster PreShower constituents
0103     size_t preshowerClustersSize() const { return preshowerClusters_.size(); }
0104 
0105     /// list of used xtals by DetId // now inherited by CaloCluster
0106     //std::vector<DetId> getHitsByDetId() const { return usedHits_; }
0107 
0108     /// set reference to seed BasicCluster
0109     void setSeed(const CaloClusterPtr& r) { seed_ = r; }
0110 
0111     //(re)-set clusters
0112     void setClusters(const CaloClusterPtrVector& clusters) {
0113       clusters_ = clusters;
0114       computeRawEnergy();
0115     }
0116 
0117     //(re)-set preshower clusters
0118     void setPreshowerClusters(const CaloClusterPtrVector& clusters) { preshowerClusters_ = clusters; }
0119 
0120     //clear hits and fractions vector (for slimming)
0121     void clearHitsAndFractions() { hitsAndFractions_.clear(); }
0122 
0123     /// add reference to constituent BasicCluster
0124     void addCluster(const CaloClusterPtr& r) {
0125       clusters_.push_back(r);
0126       computeRawEnergy();
0127     }
0128 
0129     /// add reference to constituent BasicCluster
0130     void addPreshowerCluster(const CaloClusterPtr& r) { preshowerClusters_.push_back(r); }
0131 
0132     /** Set preshower planes status :
0133         0 : both planes working
0134         1 : only first plane working
0135         2 : only second plane working
0136         3 : both planes dead */
0137 
0138     void setPreshowerPlanesStatus(const uint32_t& status) {
0139       uint32_t flags = flags_ & flagsMask_;
0140       flags_ = flags | (status << flagsOffset_);
0141     }
0142 
0143     /** Get preshower planes status :
0144         0 : both planes working
0145         1 : only first plane working
0146         2 : only second plane working
0147         3 : both planes dead */
0148     const int getPreshowerPlanesStatus() const { return (flags_ >> flagsOffset_); }
0149 
0150     const int seedCrysIEtaOrIx() const {
0151       auto detid = seed_->seed();
0152       int ietaorix = 0;
0153       if (detid.subdetId() == EcalBarrel) {
0154         EBDetId ebdetid(detid);
0155         ietaorix = ebdetid.ieta();
0156       } else if (detid.subdetId() == EcalEndcap) {
0157         EEDetId eedetid(detid);
0158         ietaorix = eedetid.ix();
0159       }
0160       return ietaorix;
0161     }
0162 
0163     const int seedCrysIPhiOrIy() const {
0164       auto detid = seed_->seed();
0165       int iphioriy = 0;
0166       if (detid.subdetId() == EcalBarrel) {
0167         EBDetId ebdetid(detid);
0168         iphioriy = ebdetid.iphi();
0169       } else if (detid.subdetId() == EcalEndcap) {
0170         EEDetId eedetid(detid);
0171         iphioriy = eedetid.iy();
0172       }
0173       return iphioriy;
0174     }
0175 
0176   private:
0177     void computeRawEnergy();
0178 
0179     /// reference to BasicCluster seed
0180     CaloClusterPtr seed_;
0181 
0182     /// references to BasicCluster constitunets
0183     CaloClusterPtrVector clusters_;
0184 
0185     /// references to BasicCluster constitunets
0186     CaloClusterPtrVector preshowerClusters_;
0187 
0188     /// used hits by detId - retrieved from BC constituents -- now inherited from CaloCluster
0189     //std::vector<DetId> usedHits_;
0190 
0191     double preshowerEnergy_;
0192 
0193     double rawEnergy_;
0194 
0195     double phiWidth_;
0196     double etaWidth_;
0197 
0198     double preshowerEnergy1_;
0199     double preshowerEnergy2_;
0200   };
0201 
0202 }  // namespace reco
0203 #endif