CMS 3D CMS Logo

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  class CaloCluster;
29  std::ostream& operator<<(std::ostream& out, const CaloCluster& cluster);
30 
31  class CaloCluster {
32  public:
33  enum AlgoId {
34  island = 0,
35  hybrid = 1,
38  multi5x5 = 4,
40  hgcal_em = 6,
41  hgcal_had = 7,
43  hfnose = 9,
44  undefined = 1000
45  };
46 
47  // super-cluster flags
48  enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
49  // hcal cluster flags (used for pf)
50  enum HCalFlags { badHcalMarker = 1 };
51 
52  //FIXME:
53  //temporary fix... to be removed before 310 final
54  typedef AlgoId AlgoID;
55 
59 
63 
65  : energy_(energy),
66  correctedEnergy_(-1.0),
69  caloID_(caloID),
71  flags_(0) {}
72 
74  void reset();
75 
78  : energy_(energy),
79  correctedEnergy_(-1.0),
83  flags_(0) {}
84 
86  double energy, const math::XYZPoint& position, const CaloID& caloID, const AlgoID& algoID, uint32_t flags = 0)
87  : energy_(energy),
88  correctedEnergy_(-1.0),
91  caloID_(caloID),
92  algoID_(algoID) {
94  }
95 
97  const math::XYZPoint& position,
98  const CaloID& caloID,
99  const std::vector<std::pair<DetId, float> >& usedHitsAndFractions,
100  const AlgoId algoId,
101  const DetId seedId = DetId(0),
102  uint32_t flags = 0)
103  : energy_(energy),
104  correctedEnergy_(-1.0),
107  caloID_(caloID),
108  hitsAndFractions_(usedHitsAndFractions),
109  algoID_(algoId),
110  seedId_(seedId) {
111  flags_ = flags & flagsMask_;
112  }
113 
114  //FIXME:
117  const math::XYZPoint& position,
118  float chi2,
119  const std::vector<DetId>& usedHits,
120  const AlgoId algoId,
121  uint32_t flags = 0)
122  : energy_(energy),
123  correctedEnergy_(-1.0),
126  algoID_(algoId) {
127  hitsAndFractions_.reserve(usedHits.size());
128  for (size_t i = 0; i < usedHits.size(); i++)
129  hitsAndFractions_.push_back(std::pair<DetId, float>(usedHits[i], 1.));
130  flags_ = flags & flagsMask_;
131  }
132 
134  virtual ~CaloCluster() {}
135 
136  void setEnergy(double energy) { energy_ = energy; }
137  void setCorrectedEnergy(double cenergy) { correctedEnergy_ = cenergy; }
138  void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
139 
140  void setPosition(const math::XYZPoint& p) { position_ = p; }
141 
142  void setCaloId(const CaloID& id) { caloID_ = id; }
143 
144  void setAlgoId(const AlgoId& id) { algoID_ = id; }
145 
146  void setSeed(const DetId& id) { seedId_ = id; }
147 
149  double energy() const { return energy_; }
150  double correctedEnergy() const { return correctedEnergy_; }
152 
154  const math::XYZPoint& position() const { return position_; }
155 
157  bool operator>=(const CaloCluster& rhs) const { return (energy_ >= rhs.energy_); }
158 
160  bool operator>(const CaloCluster& rhs) const { return (energy_ > rhs.energy_); }
161 
163  bool operator<=(const CaloCluster& rhs) const { return (energy_ <= rhs.energy_); }
164 
166  bool operator<(const CaloCluster& rhs) const { return (energy_ < rhs.energy_); }
167 
169  bool operator==(const CaloCluster& rhs) const { return (energy_ == rhs.energy_); };
170 
172  double x() const { return position_.x(); }
173 
175  double y() const { return position_.y(); }
176 
178  double z() const { return position_.z(); }
179 
181  double eta() const { return position_.eta(); }
182 
184  double phi() const { return position_.phi(); }
185 
187  size_t size() const { return hitsAndFractions_.size(); }
188 
190  AlgoId algo() const { return algoID_; }
191  AlgoID algoID() const { return algo(); }
192 
193  uint32_t flags() const { return flags_ & flagsMask_; }
194  void setFlags(uint32_t flags) {
195  uint32_t reserved = (flags_ & ~flagsMask_);
196  flags_ = (reserved) | (flags & flagsMask_);
197  }
198  bool isInClean() const { return flags() < uncleanOnly; }
199  bool isInUnclean() const { return flags() >= common; }
200 
201  const CaloID& caloID() const { return caloID_; }
202 
203  void addHitAndFraction(DetId id, float fraction) {
204  hitsAndFractions_.push_back(std::pair<DetId, float>(id, fraction));
205  }
206 
210  const std::vector<std::pair<DetId, float> >& hitsAndFractions() const { return hitsAndFractions_; }
211 
213  std::string printHitAndFraction(unsigned i) const;
214 
216  friend std::ostream& operator<<(std::ostream& out, const CaloCluster& cluster);
217 
219  DetId seed() const { return seedId_; }
220 
221  protected:
223  double energy_;
226 
229 
232 
233  // used hits by detId
234  std::vector<std::pair<DetId, float> > hitsAndFractions_;
235 
236  // cluster algorithm Id
238 
241 
245  uint32_t flags_;
246 
247  static const uint32_t flagsMask_ = 0x0FFFFFFF;
248  static const uint32_t flagsOffset_ = 28;
249  };
250 
251 } // namespace reco
252 
253 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
bool operator==(const CaloCluster &rhs) const
comparison == operator
Definition: CaloCluster.h:169
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:228
uint32_t flags() const
Definition: CaloCluster.h:193
static const uint32_t flagsOffset_
Definition: CaloCluster.h:248
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:231
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:15
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
float correctedEnergyUncertainty() const
Definition: CaloCluster.h:151
bool operator<=(const CaloCluster &rhs) const
comparison <= operator
Definition: CaloCluster.h:163
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:203
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:190
double energy_
cluster energy
Definition: CaloCluster.h:223
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:140
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
double correctedEnergy_
Definition: CaloCluster.h:224
void setEnergy(double energy)
Definition: CaloCluster.h:136
float correctedEnergyUncertainty_
Definition: CaloCluster.h:225
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:172
const CaloID & caloID() const
Definition: CaloCluster.h:201
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
void setSeed(const DetId &id)
Definition: CaloCluster.h:146
double correctedEnergy() const
Definition: CaloCluster.h:150
bool operator<(const CaloCluster &rhs) const
comparison < operator
Definition: CaloCluster.h:166
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:142
void setFlags(uint32_t flags)
Definition: CaloCluster.h:194
bool isInUnclean() const
Definition: CaloCluster.h:199
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
bool operator>(const CaloCluster &rhs) const
comparison > operator
Definition: CaloCluster.h:160
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:240
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:178
bool isInClean() const
Definition: CaloCluster.h:198
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:175
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:187
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:234
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:77
double energy() const
cluster energy
Definition: CaloCluster.h:149
Definition: DetId.h:17
Definition: common.py:1
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID, const AlgoID &algoID, uint32_t flags=0)
Definition: CaloCluster.h:85
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:144
CaloCluster()
default constructor. Sets energy and position to zero
Definition: CaloCluster.h:57
bool operator>=(const CaloCluster &rhs) const
comparison >= operator
Definition: CaloCluster.h:157
fixed size matrix
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:96
static const uint32_t flagsMask_
Definition: CaloCluster.h:247
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:134
void setCorrectedEnergyUncertainty(float energyerr)
Definition: CaloCluster.h:138
CaloCluster(AlgoID algoID)
constructor with algoId, to be used in all child classes
Definition: CaloCluster.h:61
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:116
void reset()
resets the CaloCluster (position, energy, hitsAndFractions)
Definition: CaloCluster.cc:9
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID)
Definition: CaloCluster.h:64
AlgoID algoID() const
Definition: CaloCluster.h:191