test
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, hgcal_em = 6, hgcal_had = 7, hgcal_mixed = 8, 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 
44  algoID_( undefined ), flags_(0) {}
45 
49  algoID_( algoID ), flags_(0) {}
50 
52  const math::XYZPoint& position,
53  const CaloID& caloID) :
54  energy_ (energy), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-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), correctedEnergyUncertainty_(-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), correctedEnergyUncertainty_(-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), correctedEnergyUncertainty_(-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), correctedEnergyUncertainty_(-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  void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
111 
113 
114  void setCaloId(const CaloID& id) {caloID_= id;}
115 
116  void setAlgoId(const AlgoId& id) {algoID_=id;}
117 
118  void setSeed(const DetId& id) {seedId_=id;}
119 
121  double energy() const { return energy_; }
122  double correctedEnergy() const { return correctedEnergy_; }
124 
126  const math::XYZPoint & position() const { return position_; }
127 
129  bool operator >=(const CaloCluster& rhs) const {
130  return (energy_>=rhs.energy_);
131  }
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  double x() const { return position_.x(); }
155 
157  double y() const { return position_.y(); }
158 
160  double z() const { return position_.z(); }
161 
163  double eta() const { return position_.eta(); }
164 
166  double phi() const { return position_.phi(); }
167 
169  size_t size() const { return hitsAndFractions_.size(); }
170 
172  AlgoId algo() const { return algoID_; }
173  AlgoID algoID() const { return algo(); }
174 
175  uint32_t flags() const { return flags_&flagsMask_; }
176  void setFlags( uint32_t flags) {
177  uint32_t reserved = (flags_ & ~flagsMask_);
178  flags_ = (reserved ) | (flags & flagsMask_);
179  }
180  bool isInClean() const { return flags() < uncleanOnly; }
181  bool isInUnclean() const { return flags() >= common; }
182 
183  const CaloID& caloID() const {return caloID_;}
184 
185  void addHitAndFraction( DetId id, float fraction ) {
186  hitsAndFractions_.push_back( std::pair<DetId, float>(id, fraction) );
187  }
188 
192  const std::vector< std::pair<DetId, float> > & hitsAndFractions() const { return hitsAndFractions_; }
193 
195  std::string printHitAndFraction(unsigned i) const;
196 
198  friend std::ostream& operator<<(std::ostream& out,
199  const CaloCluster& cluster);
200 
202  DetId seed() const { return seedId_; }
203 
204  protected:
205 
207  double energy_;
210 
213 
216 
217  // used hits by detId
218  std::vector< std::pair<DetId, float> > hitsAndFractions_;
219 
220  // cluster algorithm Id
222 
225 
229  uint32_t flags_;
230 
231  static const uint32_t flagsMask_ =0x0FFFFFFF;
232  static const uint32_t flagsOffset_=28;
233  };
234 
235 }
236 
237 #endif
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
int i
Definition: DBlmapReader.cc:9
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:212
static const uint32_t flagsOffset_
Definition: CaloCluster.h:232
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:215
bool isInUnclean() const
Definition: CaloCluster.h:181
double correctedEnergy() const
Definition: CaloCluster.h:122
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:185
double energy_
cluster energy
Definition: CaloCluster.h:207
AlgoID algoID() const
Definition: CaloCluster.h:173
friend std::ostream & operator<<(std::ostream &out, const CaloCluster &cluster)
print me
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:112
double correctedEnergy_
Definition: CaloCluster.h:208
void setEnergy(double energy)
Definition: CaloCluster.h:108
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
float correctedEnergyUncertainty_
Definition: CaloCluster.h:209
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:218
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:160
bool operator>(const CaloCluster &rhs) const
comparison &gt; operator
Definition: CaloCluster.h:134
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
void setSeed(const DetId &id)
Definition: CaloCluster.h:118
bool operator<(const CaloCluster &rhs) const
comparison &lt; operator
Definition: CaloCluster.h:144
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:172
void setCaloId(const CaloID &id)
Definition: CaloCluster.h:114
void setFlags(uint32_t flags)
Definition: CaloCluster.h:176
const CaloID & caloID() const
Definition: CaloCluster.h:183
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:109
uint32_t flags() const
Definition: CaloCluster.h:175
DetId seedId_
DetId of seed.
Definition: CaloCluster.h:224
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:154
double energy() const
cluster energy
Definition: CaloCluster.h:121
bool operator>=(const CaloCluster &rhs) const
comparison &gt;= operator
Definition: CaloCluster.h:129
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:17
bool isInClean() const
Definition: CaloCluster.h:180
CaloCluster(double energy, const math::XYZPoint &position)
constructor from values
Definition: CaloCluster.h:61
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:202
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:116
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:139
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:169
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:231
float correctedEnergyUncertainty() const
Definition: CaloCluster.h:123
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:157
virtual ~CaloCluster()
destructor
Definition: CaloCluster.h:105
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:166
void setCorrectedEnergyUncertainty(float energyerr)
Definition: CaloCluster.h:110
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:149