CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DataFormats/CaloRecHit/interface/CaloCluster.h

Go to the documentation of this file.
00001 #ifndef DataFormats_CaloRecHit_CaloCluster_h
00002 #define DataFormats_CaloRecHit_CaloCluster_h
00003 
00018 #include "DataFormats/Math/interface/Point3D.h"
00019 #include "DataFormats/CaloRecHit/interface/CaloID.h"
00020 
00021 #include "DataFormats/DetId/interface/DetId.h"
00022 
00023 #include <vector>
00024 #include <string>
00025 #include <iostream>
00026 
00027 namespace reco {
00028 
00029 
00030   class CaloCluster {
00031   public:
00032     
00033     enum AlgoId { island = 0, hybrid = 1, fixedMatrix = 2, dynamicHybrid = 3, multi5x5 = 4, particleFlow = 5,  undefined = 1000};
00034 
00035     // super-cluster flags
00036     enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
00037 
00038    //FIXME:  
00039    //temporary fix... to be removed before 310 final
00040    typedef AlgoId AlgoID ;
00041  
00043     CaloCluster() : 
00044       energy_(0), 
00045       algoID_( undefined ), flags_(0) {}
00046 
00048     CaloCluster(AlgoID algoID) : 
00049       energy_(0), 
00050       algoID_( algoID ), flags_(0) {}
00051 
00052     CaloCluster( double energy,
00053                  const math::XYZPoint& position,
00054                  const CaloID& caloID) :
00055       energy_ (energy), position_ (position), caloID_(caloID),algoID_( undefined ), flags_(0) {}
00056 
00057 
00059     void reset();
00060     
00062      CaloCluster( double energy,  
00063                  const math::XYZPoint& position ) : 
00064        energy_ (energy), position_ (position),algoID_( undefined ), flags_(0) {} 
00065 
00066 
00067     CaloCluster( double energy,
00068                  const math::XYZPoint& position,
00069                  const CaloID& caloID,
00070                  const AlgoID& algoID,
00071                  uint32_t flags = 0) :
00072       energy_ (energy), position_ (position), 
00073       caloID_(caloID), algoID_(algoID) {
00074       flags_=flags&flagsMask_;
00075     }
00076 
00077     CaloCluster( double energy,
00078                  const math::XYZPoint& position,
00079                  const CaloID& caloID,
00080                  const std::vector< std::pair< DetId, float > > &usedHitsAndFractions,
00081                  const AlgoId algoId,
00082                  const DetId seedId = DetId(0),
00083                  uint32_t flags = 0) :
00084       energy_ (energy), position_ (position), caloID_(caloID), 
00085       hitsAndFractions_(usedHitsAndFractions), algoID_(algoId),seedId_(seedId){
00086       flags_=flags&flagsMask_;
00087     }
00088 
00089    //FIXME:
00091     CaloCluster( double energy,
00092                  const math::XYZPoint& position,
00093                  float chi2,
00094                  const std::vector<DetId > &usedHits,
00095                  const AlgoId algoId,
00096                  uint32_t flags = 0) :
00097       energy_ (energy), position_ (position),  algoID_(algoId)
00098        {
00099           hitsAndFractions_.reserve(usedHits.size());
00100           for(size_t i = 0; i < usedHits.size(); i++) hitsAndFractions_.push_back(std::pair< DetId, float > ( usedHits[i],1.));
00101           flags_=flags&flagsMask_;
00102       }
00103 
00104 
00106     virtual ~CaloCluster() {}
00107 
00109     double energy() const { return energy_; }
00110 
00112     const math::XYZPoint & position() const { return position_; }
00113     
00115     bool operator >=(const CaloCluster& rhs) const { 
00116       return (energy_>=rhs.energy_); 
00117     }
00118 
00120     bool operator > (const CaloCluster& rhs) const { 
00121       return (energy_> rhs.energy_); 
00122     }
00123 
00125     bool operator <=(const CaloCluster& rhs) const { 
00126       return (energy_<=rhs.energy_); 
00127     }
00128 
00130     bool operator < (const CaloCluster& rhs) const { 
00131       return (energy_< rhs.energy_); 
00132     }
00133 
00135      bool operator==(const CaloCluster& rhs) const { 
00136              return (energy_ == rhs.energy_); 
00137      }; 
00138 
00140     double x() const { return position_.x(); }
00141 
00143     double y() const { return position_.y(); }
00144 
00146     double z() const { return position_.z(); }
00147 
00149     double eta() const { return position_.eta(); }
00150 
00152     double phi() const { return position_.phi(); }
00153 
00155     size_t size() const { return hitsAndFractions_.size(); }
00156 
00158     AlgoId algo() const { return algoID_; }
00159     AlgoID algoID() const { return algo(); }
00160 
00161     uint32_t flags() const { return flags_&flagsMask_; }
00162     void setFlags( uint32_t flags) { 
00163       uint32_t reserved = (flags_ & ~flagsMask_);
00164       flags_ = (reserved ) | (flags & flagsMask_); 
00165     }
00166     bool isInClean()   const { return flags() < uncleanOnly; }
00167     bool isInUnclean() const { return flags() >= common; }
00168 
00169     const CaloID& caloID() const {return caloID_;}
00170 
00171     void addHitAndFraction( DetId id, float fraction ) { 
00172             hitsAndFractions_.push_back( std::pair<DetId, float>(id, fraction) );
00173     }
00174 
00178     const std::vector< std::pair<DetId, float> > & hitsAndFractions() const { return hitsAndFractions_; }
00179     
00181     std::string printHitAndFraction(unsigned i) const;
00182 
00184     friend std::ostream& operator<<(std::ostream& out, 
00185                                     const CaloCluster& cluster);
00186 
00188     DetId seed() const { return seedId_; }
00189 
00190   protected:
00191 
00193     double              energy_;
00194 
00196     math::XYZPoint      position_;
00197 
00199     CaloID              caloID_;
00200     
00201     // used hits by detId
00202     std::vector< std::pair<DetId, float> > hitsAndFractions_;
00203 
00204     // cluster algorithm Id
00205     AlgoID              algoID_;
00206 
00208     DetId               seedId_;
00209 
00213     uint32_t            flags_;
00214 
00215     static const uint32_t flagsMask_  =0x0FFFFFFF;
00216     static const uint32_t flagsOffset_=28;
00217   };
00218 
00219 }
00220 
00221 #endif