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,
30  const CaloCluster& cluster);
31 
32  class CaloCluster {
33  public:
34 
35  enum AlgoId { island = 0, hybrid = 1, fixedMatrix = 2, dynamicHybrid = 3, multi5x5 = 4, particleFlow = 5, hgcal_em = 6, hgcal_had = 7, hgcal_mixed = 8, undefined = 1000};
36 
37  // super-cluster flags
38  enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
39 
40  //FIXME:
41  //temporary fix... to be removed before 310 final
42  typedef AlgoId AlgoID ;
43 
47  algoID_( undefined ), flags_(0) {}
48 
50  CaloCluster(AlgoID algoID) :
52  algoID_( algoID ), flags_(0) {}
53 
55  const math::XYZPoint& position,
56  const CaloID& caloID) :
57  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), caloID_(caloID),algoID_( undefined ), flags_(0) {}
58 
59 
61  void reset();
62 
64  CaloCluster( double energy,
65  const math::XYZPoint& position ) :
66  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position),algoID_( undefined ), flags_(0) {}
67 
68 
70  const math::XYZPoint& position,
71  const CaloID& caloID,
72  const AlgoID& algoID,
73  uint32_t flags = 0) :
74  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position),
75  caloID_(caloID), algoID_(algoID) {
77  }
78 
80  const math::XYZPoint& position,
81  const CaloID& caloID,
82  const std::vector< std::pair< DetId, float > > &usedHitsAndFractions,
83  const AlgoId algoId,
84  const DetId seedId = DetId(0),
85  uint32_t flags = 0) :
86  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), caloID_(caloID),
87  hitsAndFractions_(usedHitsAndFractions), algoID_(algoId),seedId_(seedId){
89  }
90 
91  //FIXME:
93  CaloCluster( double energy,
94  const math::XYZPoint& position,
95  float chi2,
96  const std::vector<DetId > &usedHits,
97  const AlgoId algoId,
98  uint32_t flags = 0) :
99  energy_(energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), algoID_(algoId)
100  {
101  hitsAndFractions_.reserve(usedHits.size());
102  for(size_t i = 0; i < usedHits.size(); i++) hitsAndFractions_.push_back(std::pair< DetId, float > ( usedHits[i],1.));
104  }
105 
106 
108  virtual ~CaloCluster() {}
109 
110 
111  void setEnergy(double energy){energy_ = energy;}
112  void setCorrectedEnergy(double cenergy){correctedEnergy_ = cenergy;}
113  void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
114 
116 
117  void setCaloId(const CaloID& id) {caloID_= id;}
118 
119  void setAlgoId(const AlgoId& id) {algoID_=id;}
120 
121  void setSeed(const DetId& id) {seedId_=id;}
122 
124  double energy() const { return energy_; }
125  double correctedEnergy() const { return correctedEnergy_; }
127 
129  const math::XYZPoint & position() const { return position_; }
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  bool operator==(const CaloCluster& rhs) const {
153  return (energy_ == rhs.energy_);
154  };
155 
157  double x() const { return position_.x(); }
158 
160  double y() const { return position_.y(); }
161 
163  double z() const { return position_.z(); }
164 
166  double eta() const { return position_.eta(); }
167 
169  double phi() const { return position_.phi(); }
170 
172  size_t size() const { return hitsAndFractions_.size(); }
173 
175  AlgoId algo() const { return algoID_; }
176  AlgoID algoID() const { return algo(); }
177 
178  uint32_t flags() const { return flags_&flagsMask_; }
179  void setFlags( uint32_t flags) {
180  uint32_t reserved = (flags_ & ~flagsMask_);
181  flags_ = (reserved ) | (flags & flagsMask_);
182  }
183  bool isInClean() const { return flags() < uncleanOnly; }
184  bool isInUnclean() const { return flags() >= common; }
185 
186  const CaloID& caloID() const {return caloID_;}
187 
188  void addHitAndFraction( DetId id, float fraction ) {
189  hitsAndFractions_.push_back( std::pair<DetId, float>(id, fraction) );
190  }
191 
195  const std::vector< std::pair<DetId, float> > & hitsAndFractions() const { return hitsAndFractions_; }
196 
198  std::string printHitAndFraction(unsigned i) const;
199 
201  friend std::ostream& operator<<(std::ostream& out,
202  const CaloCluster& cluster);
203 
205  DetId seed() const { return seedId_; }
206 
207  protected:
208 
210  double energy_;
213 
216 
219 
220  // used hits by detId
221  std::vector< std::pair<DetId, float> > hitsAndFractions_;
222 
223  // cluster algorithm Id
224  AlgoID algoID_;
225 
228 
232  uint32_t flags_;
233 
234  static const uint32_t flagsMask_ =0x0FFFFFFF;
235  static const uint32_t flagsOffset_=28;
236  };
237 
238 }
239 
240 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:215
static const uint32_t flagsOffset_
Definition: CaloCluster.h:235
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:218
bool isInUnclean() const
Definition: CaloCluster.h:184
double correctedEnergy() const
Definition: CaloCluster.h:125
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:188
double energy_
cluster energy
Definition: CaloCluster.h:210
AlgoID algoID() const
Definition: CaloCluster.h:176
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:115
double correctedEnergy_
Definition: CaloCluster.h:211
void setEnergy(double energy)
Definition: CaloCluster.h:111
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:195
float correctedEnergyUncertainty_
Definition: CaloCluster.h:212
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:221
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:163
bool operator>(const CaloCluster &rhs) const
comparison > operator
Definition: CaloCluster.h:137
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:166
void setSeed(const DetId &id)
Definition: CaloCluster.h:121
bool operator<(const CaloCluster &rhs) const
comparison < operator
Definition: CaloCluster.h:147
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:175
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:117
void setFlags(uint32_t flags)
Definition: CaloCluster.h:179
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
const CaloID & caloID() const
Definition: CaloCluster.h:186
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:112
uint32_t flags() const
Definition: CaloCluster.h:178
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:227
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:157
double energy() const
cluster energy
Definition: CaloCluster.h:124
bool operator>=(const CaloCluster &rhs) const
comparison >= operator
Definition: CaloCluster.h:132
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:17
bool isInClean() const
Definition: CaloCluster.h:183
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:64
Definition: DetId.h:18
Definition: common.py:1
CaloCluster(double energy, const math::XYZPoint &position, const CaloID &caloID, const AlgoID &algoID, uint32_t flags=0)
Definition: CaloCluster.h:69
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:205
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:119
CaloCluster()
default constructor. Sets energy and position to zero
Definition: CaloCluster.h:45
bool operator<=(const CaloCluster &rhs) const
comparison <= operator
Definition: CaloCluster.h:142
fixed size matrix
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:172
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:79
static const uint32_t flagsMask_
Definition: CaloCluster.h:234
float correctedEnergyUncertainty() const
Definition: CaloCluster.h:126
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:160
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:108
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:169
void setCorrectedEnergyUncertainty(float energyerr)
Definition: CaloCluster.h:113
CaloCluster(AlgoID algoID)
constructor with algoId, to be used in all child classes
Definition: CaloCluster.h:50
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:93
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:54
bool operator==(const CaloCluster &rhs) const
comparison == operator
Definition: CaloCluster.h:152