CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloCluster.h
Go to the documentation of this file.
1 #ifndef DataFormats_CaloRecHit_CaloCluster_h
2 #define DataFormats_CaloRecHit_CaloCluster_h
3 
19 
21 
22 #include <vector>
23 #include <string>
24 #include <iostream>
25 
26 namespace reco {
27 
28 
29  class CaloCluster {
30  public:
31 
32  enum AlgoId { island = 0, hybrid = 1, fixedMatrix = 2, dynamicHybrid = 3, multi5x5 = 4, particleFlow = 5, undefined = 1000};
33 
34  // super-cluster flags
35  enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
36 
37  //FIXME:
38  //temporary fix... to be removed before 310 final
39  typedef AlgoId AlgoID ;
40 
43  energy_(0), correctedEnergy_(-1.0),
44  algoID_( undefined ), flags_(0) {}
45 
48  energy_(0), correctedEnergy_(-1.0),
49  algoID_( algoID ), flags_(0) {}
50 
52  const math::XYZPoint& position,
53  const CaloID& caloID) :
54  energy_ (energy), correctedEnergy_(-1.0), position_ (position), caloID_(caloID),algoID_( undefined ), flags_(0) {}
55 
56 
58  void reset();
59 
61  CaloCluster( double energy,
62  const math::XYZPoint& position ) :
63  energy_ (energy), correctedEnergy_(-1.0), position_ (position),algoID_( undefined ), flags_(0) {}
64 
65 
67  const math::XYZPoint& position,
68  const CaloID& caloID,
69  const AlgoID& algoID,
70  uint32_t flags = 0) :
71  energy_ (energy), correctedEnergy_(-1.0), position_ (position),
72  caloID_(caloID), algoID_(algoID) {
74  }
75 
77  const math::XYZPoint& position,
78  const CaloID& caloID,
79  const std::vector< std::pair< DetId, float > > &usedHitsAndFractions,
80  const AlgoId algoId,
81  const DetId seedId = DetId(0),
82  uint32_t flags = 0) :
83  energy_ (energy), correctedEnergy_(-1.0), position_ (position), caloID_(caloID),
84  hitsAndFractions_(usedHitsAndFractions), algoID_(algoId),seedId_(seedId){
86  }
87 
88  //FIXME:
90  CaloCluster( double energy,
91  const math::XYZPoint& position,
92  float chi2,
93  const std::vector<DetId > &usedHits,
94  const AlgoId algoId,
95  uint32_t flags = 0) :
96  energy_(energy), correctedEnergy_(-1.0), position_ (position), algoID_(algoId)
97  {
98  hitsAndFractions_.reserve(usedHits.size());
99  for(size_t i = 0; i < usedHits.size(); i++) hitsAndFractions_.push_back(std::pair< DetId, float > ( usedHits[i],1.));
101  }
102 
103 
105  virtual ~CaloCluster() {}
106 
107 
108  void setEnergy(double energy){energy_ = energy;}
109  void setCorrectedEnergy(double cenergy){correctedEnergy_ = cenergy;}
110 
112 
113  void setCaloId(const CaloID& id) {caloID_= id;}
114 
115  void setAlgoId(const AlgoId& id) {algoID_=id;}
116 
117  void setSeed(const DetId& id) {seedId_=id;}
118 
120  double energy() const { return energy_; }
121  double correctedEnergy() const { return correctedEnergy_; }
122 
124  const math::XYZPoint & position() const { return position_; }
125 
127  bool operator >=(const CaloCluster& rhs) const {
128  return (energy_>=rhs.energy_);
129  }
130 
132  bool operator > (const CaloCluster& rhs) const {
133  return (energy_> rhs.energy_);
134  }
135 
137  bool operator <=(const CaloCluster& rhs) const {
138  return (energy_<=rhs.energy_);
139  }
140 
142  bool operator < (const CaloCluster& rhs) const {
143  return (energy_< rhs.energy_);
144  }
145 
147  bool operator==(const CaloCluster& rhs) const {
148  return (energy_ == rhs.energy_);
149  };
150 
152  double x() const { return position_.x(); }
153 
155  double y() const { return position_.y(); }
156 
158  double z() const { return position_.z(); }
159 
161  double eta() const { return position_.eta(); }
162 
164  double phi() const { return position_.phi(); }
165 
167  size_t size() const { return hitsAndFractions_.size(); }
168 
170  AlgoId algo() const { return algoID_; }
171  AlgoID algoID() const { return algo(); }
172 
173  uint32_t flags() const { return flags_&flagsMask_; }
174  void setFlags( uint32_t flags) {
175  uint32_t reserved = (flags_ & ~flagsMask_);
176  flags_ = (reserved ) | (flags & flagsMask_);
177  }
178  bool isInClean() const { return flags() < uncleanOnly; }
179  bool isInUnclean() const { return flags() >= common; }
180 
181  const CaloID& caloID() const {return caloID_;}
182 
183  void addHitAndFraction( DetId id, float fraction ) {
184  hitsAndFractions_.push_back( std::pair<DetId, float>(id, fraction) );
185  }
186 
190  const std::vector< std::pair<DetId, float> > & hitsAndFractions() const { return hitsAndFractions_; }
191 
193  std::string printHitAndFraction(unsigned i) const;
194 
196  friend std::ostream& operator<<(std::ostream& out,
197  const CaloCluster& cluster);
198 
200  DetId seed() const { return seedId_; }
201 
202  protected:
203 
205  double energy_;
207 
210 
213 
214  // used hits by detId
215  std::vector< std::pair<DetId, float> > hitsAndFractions_;
216 
217  // cluster algorithm Id
219 
222 
226  uint32_t flags_;
227 
228  static const uint32_t flagsMask_ =0x0FFFFFFF;
229  static const uint32_t flagsOffset_=28;
230  };
231 
232 }
233 
234 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
int i
Definition: DBlmapReader.cc:9
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:209
static const uint32_t flagsOffset_
Definition: CaloCluster.h:229
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:212
bool isInUnclean() const
Definition: CaloCluster.h:179
double correctedEnergy() const
Definition: CaloCluster.h:121
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:183
double energy_
cluster energy
Definition: CaloCluster.h:205
AlgoID algoID() const
Definition: CaloCluster.h:171
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:111
double correctedEnergy_
Definition: CaloCluster.h:206
void setEnergy(double energy)
Definition: CaloCluster.h:108
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:190
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:215
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:158
bool operator>(const CaloCluster &rhs) const
comparison &gt; operator
Definition: CaloCluster.h:132
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:161
void setSeed(const DetId &id)
Definition: CaloCluster.h:117
bool operator<(const CaloCluster &rhs) const
comparison &lt; operator
Definition: CaloCluster.h:142
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:170
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:113
void setFlags(uint32_t flags)
Definition: CaloCluster.h:174
const CaloID & caloID() const
Definition: CaloCluster.h:181
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:109
uint32_t flags() const
Definition: CaloCluster.h:173
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:221
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:152
double energy() const
cluster energy
Definition: CaloCluster.h:120
bool operator>=(const CaloCluster &rhs) const
comparison &gt;= operator
Definition: CaloCluster.h:127
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:17
bool isInClean() const
Definition: CaloCluster.h:178
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:61
tuple out
Definition: dbtoconf.py:99
Definition: DetId.h:18
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID, const AlgoID &algoID, uint32_t flags=0)
Definition: CaloCluster.h:66
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:200
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:115
CaloCluster()
default constructor. Sets energy and position to zero
Definition: CaloCluster.h:42
bool operator<=(const CaloCluster &rhs) const
comparison &lt;= operator
Definition: CaloCluster.h:137
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:167
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID, const std::vector< std::pair< DetId, float > > &usedHitsAndFractions, const AlgoId algoId, const DetId seedId=DetId(0), uint32_t flags=0)
Definition: CaloCluster.h:76
static const uint32_t flagsMask_
Definition: CaloCluster.h:228
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:155
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:105
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:164
CaloCluster(AlgoID algoID)
constructor with algoId, to be used in all child classes
Definition: CaloCluster.h:47
CaloCluster(double energy, const math::XYZPoint &position, float chi2, const std::vector< DetId > &usedHits, const AlgoId algoId, uint32_t flags=0)
temporary compatibility constructor
Definition: CaloCluster.h:90
void reset()
resets the CaloCluster (position, energy, hitsAndFractions)
Definition: CaloCluster.cc:11
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID)
Definition: CaloCluster.h:51
bool operator==(const CaloCluster &rhs) const
comparison == operator
Definition: CaloCluster.h:147