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  // hcal cluster flags (used for pf)
40  enum HCalFlags { badHcalMarker = 1 };
41 
42  //FIXME:
43  //temporary fix... to be removed before 310 final
44  typedef AlgoId AlgoID ;
45 
49  algoID_( undefined ), flags_(0) {}
50 
52  CaloCluster(AlgoID algoID) :
54  algoID_( algoID ), flags_(0) {}
55 
57  const math::XYZPoint& position,
58  const CaloID& caloID) :
59  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), caloID_(caloID),algoID_( undefined ), flags_(0) {}
60 
61 
63  void reset();
64 
66  CaloCluster( double energy,
67  const math::XYZPoint& position ) :
68  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position),algoID_( undefined ), flags_(0) {}
69 
70 
72  const math::XYZPoint& position,
73  const CaloID& caloID,
74  const AlgoID& algoID,
75  uint32_t flags = 0) :
76  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position),
77  caloID_(caloID), algoID_(algoID) {
79  }
80 
82  const math::XYZPoint& position,
83  const CaloID& caloID,
84  const std::vector< std::pair< DetId, float > > &usedHitsAndFractions,
85  const AlgoId algoId,
86  const DetId seedId = DetId(0),
87  uint32_t flags = 0) :
88  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), caloID_(caloID),
89  hitsAndFractions_(usedHitsAndFractions), algoID_(algoId),seedId_(seedId){
91  }
92 
93  //FIXME:
95  CaloCluster( double energy,
96  const math::XYZPoint& position,
97  float chi2,
98  const std::vector<DetId > &usedHits,
99  const AlgoId algoId,
100  uint32_t flags = 0) :
101  energy_(energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), position_ (position), algoID_(algoId)
102  {
103  hitsAndFractions_.reserve(usedHits.size());
104  for(size_t i = 0; i < usedHits.size(); i++) hitsAndFractions_.push_back(std::pair< DetId, float > ( usedHits[i],1.));
106  }
107 
108 
110  virtual ~CaloCluster() {}
111 
112 
113  void setEnergy(double energy){energy_ = energy;}
114  void setCorrectedEnergy(double cenergy){correctedEnergy_ = cenergy;}
115  void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
116 
118 
119  void setCaloId(const CaloID& id) {caloID_= id;}
120 
121  void setAlgoId(const AlgoId& id) {algoID_=id;}
122 
123  void setSeed(const DetId& id) {seedId_=id;}
124 
126  double energy() const { return energy_; }
127  double correctedEnergy() const { return correctedEnergy_; }
129 
131  const math::XYZPoint & position() const { return position_; }
132 
134  bool operator >=(const CaloCluster& rhs) const {
135  return (energy_>=rhs.energy_);
136  }
137 
139  bool operator > (const CaloCluster& rhs) const {
140  return (energy_> rhs.energy_);
141  }
142 
144  bool operator <=(const CaloCluster& rhs) const {
145  return (energy_<=rhs.energy_);
146  }
147 
149  bool operator < (const CaloCluster& rhs) const {
150  return (energy_< rhs.energy_);
151  }
152 
154  bool operator==(const CaloCluster& rhs) const {
155  return (energy_ == rhs.energy_);
156  };
157 
159  double x() const { return position_.x(); }
160 
162  double y() const { return position_.y(); }
163 
165  double z() const { return position_.z(); }
166 
168  double eta() const { return position_.eta(); }
169 
171  double phi() const { return position_.phi(); }
172 
174  size_t size() const { return hitsAndFractions_.size(); }
175 
177  AlgoId algo() const { return algoID_; }
178  AlgoID algoID() const { return algo(); }
179 
180  uint32_t flags() const { return flags_&flagsMask_; }
181  void setFlags( uint32_t flags) {
182  uint32_t reserved = (flags_ & ~flagsMask_);
183  flags_ = (reserved ) | (flags & flagsMask_);
184  }
185  bool isInClean() const { return flags() < uncleanOnly; }
186  bool isInUnclean() const { return flags() >= common; }
187 
188  const CaloID& caloID() const {return caloID_;}
189 
190  void addHitAndFraction( DetId id, float fraction ) {
191  hitsAndFractions_.push_back( std::pair<DetId, float>(id, fraction) );
192  }
193 
197  const std::vector< std::pair<DetId, float> > & hitsAndFractions() const { return hitsAndFractions_; }
198 
200  std::string printHitAndFraction(unsigned i) const;
201 
203  friend std::ostream& operator<<(std::ostream& out,
204  const CaloCluster& cluster);
205 
207  DetId seed() const { return seedId_; }
208 
209  protected:
210 
212  double energy_;
215 
218 
221 
222  // used hits by detId
223  std::vector< std::pair<DetId, float> > hitsAndFractions_;
224 
225  // cluster algorithm Id
226  AlgoID algoID_;
227 
230 
234  uint32_t flags_;
235 
236  static const uint32_t flagsMask_ =0x0FFFFFFF;
237  static const uint32_t flagsOffset_=28;
238  };
239 
240 }
241 
242 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:217
static const uint32_t flagsOffset_
Definition: CaloCluster.h:237
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:220
bool isInUnclean() const
Definition: CaloCluster.h:186
double correctedEnergy() const
Definition: CaloCluster.h:127
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:190
double energy_
cluster energy
Definition: CaloCluster.h:212
AlgoID algoID() const
Definition: CaloCluster.h:178
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:117
double correctedEnergy_
Definition: CaloCluster.h:213
void setEnergy(double energy)
Definition: CaloCluster.h:113
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
float correctedEnergyUncertainty_
Definition: CaloCluster.h:214
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:223
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:165
bool operator>(const CaloCluster &rhs) const
comparison > operator
Definition: CaloCluster.h:139
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:168
void setSeed(const DetId &id)
Definition: CaloCluster.h:123
bool operator<(const CaloCluster &rhs) const
comparison < operator
Definition: CaloCluster.h:149
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:177
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:119
void setFlags(uint32_t flags)
Definition: CaloCluster.h:181
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
const CaloID & caloID() const
Definition: CaloCluster.h:188
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:114
uint32_t flags() const
Definition: CaloCluster.h:180
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:229
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:159
double energy() const
cluster energy
Definition: CaloCluster.h:126
bool operator>=(const CaloCluster &rhs) const
comparison >= operator
Definition: CaloCluster.h:134
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:17
bool isInClean() const
Definition: CaloCluster.h:185
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:66
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:71
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:207
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:121
CaloCluster()
default constructor. Sets energy and position to zero
Definition: CaloCluster.h:47
bool operator<=(const CaloCluster &rhs) const
comparison <= operator
Definition: CaloCluster.h:144
fixed size matrix
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:174
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:81
static const uint32_t flagsMask_
Definition: CaloCluster.h:236
float correctedEnergyUncertainty() const
Definition: CaloCluster.h:128
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:162
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:110
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:171
void setCorrectedEnergyUncertainty(float energyerr)
Definition: CaloCluster.h:115
CaloCluster(AlgoID algoID)
constructor with algoId, to be used in all child classes
Definition: CaloCluster.h:52
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:95
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:56
bool operator==(const CaloCluster &rhs) const
comparison == operator
Definition: CaloCluster.h:154