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,
42  hfnose = 9,
43  undefined = 1000
44  };
45 
46  // super-cluster flags
47  enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
48  // hcal cluster flags (used for pf)
49  enum HCalFlags { badHcalMarker = 1 };
50 
51  //FIXME:
52  //temporary fix... to be removed before 310 final
53  typedef AlgoId AlgoID;
54 
58 
62 
64  : energy_(energy),
65  correctedEnergy_(-1.0),
68  caloID_(caloID),
70  flags_(0) {}
71 
73  void reset();
74 
77  : energy_(energy),
78  correctedEnergy_(-1.0),
82  flags_(0) {}
83 
85  double energy, const math::XYZPoint& position, const CaloID& caloID, const AlgoID& algoID, uint32_t flags = 0)
86  : energy_(energy),
87  correctedEnergy_(-1.0),
90  caloID_(caloID),
91  algoID_(algoID) {
93  }
94 
96  const math::XYZPoint& position,
97  const CaloID& caloID,
98  const std::vector<std::pair<DetId, float> >& usedHitsAndFractions,
99  const AlgoId algoId,
100  const DetId seedId = DetId(0),
101  uint32_t flags = 0)
102  : energy_(energy),
103  correctedEnergy_(-1.0),
106  caloID_(caloID),
107  hitsAndFractions_(usedHitsAndFractions),
108  algoID_(algoId),
109  seedId_(seedId) {
110  flags_ = flags & flagsMask_;
111  }
112 
113  //FIXME:
116  const math::XYZPoint& position,
117  float chi2,
118  const std::vector<DetId>& usedHits,
119  const AlgoId algoId,
120  uint32_t flags = 0)
121  : energy_(energy),
122  correctedEnergy_(-1.0),
125  algoID_(algoId) {
126  hitsAndFractions_.reserve(usedHits.size());
127  for (size_t i = 0; i < usedHits.size(); i++)
128  hitsAndFractions_.push_back(std::pair<DetId, float>(usedHits[i], 1.));
129  flags_ = flags & flagsMask_;
130  }
131 
133  virtual ~CaloCluster() {}
134 
135  void setEnergy(double energy) { energy_ = energy; }
136  void setCorrectedEnergy(double cenergy) { correctedEnergy_ = cenergy; }
137  void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
138 
139  void setPosition(const math::XYZPoint& p) { position_ = p; }
140 
141  void setCaloId(const CaloID& id) { caloID_ = id; }
142 
143  void setAlgoId(const AlgoId& id) { algoID_ = id; }
144 
145  void setSeed(const DetId& id) { seedId_ = id; }
146 
148  double energy() const { return energy_; }
149  double correctedEnergy() const { return correctedEnergy_; }
151 
153  const math::XYZPoint& position() const { return position_; }
154 
156  bool operator>=(const CaloCluster& rhs) const { return (energy_ >= rhs.energy_); }
157 
159  bool operator>(const CaloCluster& rhs) const { return (energy_ > rhs.energy_); }
160 
162  bool operator<=(const CaloCluster& rhs) const { return (energy_ <= rhs.energy_); }
163 
165  bool operator<(const CaloCluster& rhs) const { return (energy_ < rhs.energy_); }
166 
168  bool operator==(const CaloCluster& rhs) const { return (energy_ == rhs.energy_); };
169 
171  double x() const { return position_.x(); }
172 
174  double y() const { return position_.y(); }
175 
177  double z() const { return position_.z(); }
178 
180  double eta() const { return position_.eta(); }
181 
183  double phi() const { return position_.phi(); }
184 
186  size_t size() const { return hitsAndFractions_.size(); }
187 
189  AlgoId algo() const { return algoID_; }
190  AlgoID algoID() const { return algo(); }
191 
192  uint32_t flags() const { return flags_ & flagsMask_; }
193  void setFlags(uint32_t flags) {
194  uint32_t reserved = (flags_ & ~flagsMask_);
195  flags_ = (reserved) | (flags & flagsMask_);
196  }
197  bool isInClean() const { return flags() < uncleanOnly; }
198  bool isInUnclean() const { return flags() >= common; }
199 
200  const CaloID& caloID() const { return caloID_; }
201 
202  void addHitAndFraction(DetId id, float fraction) {
203  hitsAndFractions_.push_back(std::pair<DetId, float>(id, fraction));
204  }
205 
209  const std::vector<std::pair<DetId, float> >& hitsAndFractions() const { return hitsAndFractions_; }
210 
212  std::string printHitAndFraction(unsigned i) const;
213 
215  friend std::ostream& operator<<(std::ostream& out, const CaloCluster& cluster);
216 
218  DetId seed() const { return seedId_; }
219 
220  protected:
222  double energy_;
225 
228 
231 
232  // used hits by detId
233  std::vector<std::pair<DetId, float> > hitsAndFractions_;
234 
235  // cluster algorithm Id
237 
240 
244  uint32_t flags_;
245 
246  static const uint32_t flagsMask_ = 0x0FFFFFFF;
247  static const uint32_t flagsOffset_ = 28;
248  };
249 
250 } // namespace reco
251 
252 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:153
bool operator==(const CaloCluster &rhs) const
comparison == operator
Definition: CaloCluster.h:168
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:227
uint32_t flags() const
Definition: CaloCluster.h:192
static const uint32_t flagsOffset_
Definition: CaloCluster.h:247
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:230
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:15
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:209
float correctedEnergyUncertainty() const
Definition: CaloCluster.h:150
bool operator<=(const CaloCluster &rhs) const
comparison <= operator
Definition: CaloCluster.h:162
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:202
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:189
double energy_
cluster energy
Definition: CaloCluster.h:222
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:139
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:218
double correctedEnergy_
Definition: CaloCluster.h:223
void setEnergy(double energy)
Definition: CaloCluster.h:135
float correctedEnergyUncertainty_
Definition: CaloCluster.h:224
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:171
const CaloID & caloID() const
Definition: CaloCluster.h:200
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:183
void setSeed(const DetId &id)
Definition: CaloCluster.h:145
double correctedEnergy() const
Definition: CaloCluster.h:149
bool operator<(const CaloCluster &rhs) const
comparison < operator
Definition: CaloCluster.h:165
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:141
void setFlags(uint32_t flags)
Definition: CaloCluster.h:193
bool isInUnclean() const
Definition: CaloCluster.h:198
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:136
bool operator>(const CaloCluster &rhs) const
comparison > operator
Definition: CaloCluster.h:159
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:239
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:177
bool isInClean() const
Definition: CaloCluster.h:197
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:174
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:186
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:233
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:76
double energy() const
cluster energy
Definition: CaloCluster.h:148
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:84
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:143
CaloCluster()
default constructor. Sets energy and position to zero
Definition: CaloCluster.h:56
bool operator>=(const CaloCluster &rhs) const
comparison >= operator
Definition: CaloCluster.h:156
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:95
static const uint32_t flagsMask_
Definition: CaloCluster.h:246
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:180
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:133
void setCorrectedEnergyUncertainty(float energyerr)
Definition: CaloCluster.h:137
CaloCluster(AlgoID algoID)
constructor with algoId, to be used in all child classes
Definition: CaloCluster.h:60
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:115
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:63
AlgoID algoID() const
Definition: CaloCluster.h:190