1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
#ifndef DataFormats_CaloRecHit_CaloCluster_h
#define DataFormats_CaloRecHit_CaloCluster_h
/** \class reco::CaloCluster
*
* Base class for all types calorimeter clusters
*
* \author Shahram Rahatlou, INFN
*
* Comments:
* modified AlgoId enumeration to include cleaning status flags
* In summary:
* algoID_ < 200 object is in clean collection
* algoID_ >=100 object is in unclean collection
*
*/
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/CaloRecHit/interface/CaloID.h"
#include "DataFormats/DetId/interface/DetId.h"
#include <vector>
#include <string>
#include <iostream>
namespace reco {
class CaloCluster;
std::ostream& operator<<(std::ostream& out, const CaloCluster& cluster);
class CaloCluster {
public:
enum AlgoId {
island = 0,
hybrid = 1,
fixedMatrix = 2,
dynamicHybrid = 3,
multi5x5 = 4,
particleFlow = 5,
hgcal_em = 6,
hgcal_had = 7,
hgcal_scintillator = 8,
hfnose = 9,
undefined = 1000
};
// super-cluster flags
enum SCFlags { cleanOnly = 0, common = 100, uncleanOnly = 200 };
// hcal cluster flags (used for pf)
enum HCalFlags { badHcalMarker = 1 };
//FIXME:
//temporary fix... to be removed before 310 final
typedef AlgoId AlgoID;
/// default constructor. Sets energy and position to zero
CaloCluster()
: energy_(0), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), algoID_(undefined), flags_(0) {}
/// constructor with algoId, to be used in all child classes
CaloCluster(AlgoID algoID)
: energy_(0), correctedEnergy_(-1.0), correctedEnergyUncertainty_(-1.0), algoID_(algoID), flags_(0) {}
CaloCluster(double energy, const math::XYZPoint& position, const CaloID& caloID)
: energy_(energy),
correctedEnergy_(-1.0),
correctedEnergyUncertainty_(-1.0),
position_(position),
caloID_(caloID),
algoID_(undefined),
flags_(0) {}
/// resets the CaloCluster (position, energy, hitsAndFractions)
void reset();
/// constructor from values
CaloCluster(double energy, const math::XYZPoint& position)
: energy_(energy),
correctedEnergy_(-1.0),
correctedEnergyUncertainty_(-1.0),
position_(position),
algoID_(undefined),
flags_(0) {}
CaloCluster(
double energy, const math::XYZPoint& position, const CaloID& caloID, const AlgoID& algoID, uint32_t flags = 0)
: energy_(energy),
correctedEnergy_(-1.0),
correctedEnergyUncertainty_(-1.0),
position_(position),
caloID_(caloID),
algoID_(algoID) {
flags_ = flags & flagsMask_;
}
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)
: energy_(energy),
correctedEnergy_(-1.0),
correctedEnergyUncertainty_(-1.0),
position_(position),
caloID_(caloID),
hitsAndFractions_(usedHitsAndFractions),
algoID_(algoId),
seedId_(seedId) {
flags_ = flags & flagsMask_;
}
//FIXME:
/// temporary compatibility constructor
CaloCluster(double energy,
const math::XYZPoint& position,
float chi2,
const std::vector<DetId>& usedHits,
const AlgoId algoId,
uint32_t flags = 0)
: energy_(energy),
correctedEnergy_(-1.0),
correctedEnergyUncertainty_(-1.0),
position_(position),
algoID_(algoId) {
hitsAndFractions_.reserve(usedHits.size());
for (size_t i = 0; i < usedHits.size(); i++)
hitsAndFractions_.push_back(std::pair<DetId, float>(usedHits[i], 1.));
flags_ = flags & flagsMask_;
}
/// destructor
virtual ~CaloCluster() {}
void setEnergy(double energy) { energy_ = energy; }
void setCorrectedEnergy(double cenergy) { correctedEnergy_ = cenergy; }
void setCorrectedEnergyUncertainty(float energyerr) { correctedEnergyUncertainty_ = energyerr; }
void setPosition(const math::XYZPoint& p) { position_ = p; }
void setCaloId(const CaloID& id) { caloID_ = id; }
void setAlgoId(const AlgoId& id) { algoID_ = id; }
void setSeed(const DetId& id) { seedId_ = id; }
/// cluster energy
double energy() const { return energy_; }
double correctedEnergy() const { return correctedEnergy_; }
float correctedEnergyUncertainty() const { return correctedEnergyUncertainty_; }
/// cluster centroid position
const math::XYZPoint& position() const { return position_; }
/// comparison >= operator
bool operator>=(const CaloCluster& rhs) const { return (energy_ >= rhs.energy_); }
/// comparison > operator
bool operator>(const CaloCluster& rhs) const { return (energy_ > rhs.energy_); }
/// comparison <= operator
bool operator<=(const CaloCluster& rhs) const { return (energy_ <= rhs.energy_); }
/// comparison < operator
bool operator<(const CaloCluster& rhs) const { return (energy_ < rhs.energy_); }
/// comparison == operator
bool operator==(const CaloCluster& rhs) const { return (energy_ == rhs.energy_); };
/// x coordinate of cluster centroid
double x() const { return position_.x(); }
/// y coordinate of cluster centroid
double y() const { return position_.y(); }
/// z coordinate of cluster centroid
double z() const { return position_.z(); }
/// pseudorapidity of cluster centroid
double eta() const { return position_.eta(); }
/// azimuthal angle of cluster centroid
double phi() const { return position_.phi(); }
/// size in number of hits (e.g. in crystals for ECAL)
size_t size() const { return hitsAndFractions_.size(); }
/// algorithm identifier
AlgoId algo() const { return algoID_; }
AlgoID algoID() const { return algo(); }
uint32_t flags() const { return flags_ & flagsMask_; }
void setFlags(uint32_t flags) {
uint32_t reserved = (flags_ & ~flagsMask_);
flags_ = (reserved) | (flags & flagsMask_);
}
bool isInClean() const { return flags() < uncleanOnly; }
bool isInUnclean() const { return flags() >= common; }
const CaloID& caloID() const { return caloID_; }
void addHitAndFraction(DetId id, float fraction) {
hitsAndFractions_.push_back(std::pair<DetId, float>(id, fraction));
}
/// replace getHitsByDetId() : return hits by DetId
/// and their corresponding fraction of energy considered
/// to compute the total cluster energy
const std::vector<std::pair<DetId, float> >& hitsAndFractions() const { return hitsAndFractions_; }
/// print hitAndFraction
std::string printHitAndFraction(unsigned i) const;
/// print me
friend std::ostream& operator<<(std::ostream& out, const CaloCluster& cluster);
/// return DetId of seed
DetId seed() const { return seedId_; }
protected:
/// cluster energy
double energy_;
double correctedEnergy_;
float correctedEnergyUncertainty_;
/// cluster centroid position
math::XYZPoint position_;
/// bitmask for detector information
CaloID caloID_;
// used hits by detId
std::vector<std::pair<DetId, float> > hitsAndFractions_;
// cluster algorithm Id
AlgoID algoID_;
/// DetId of seed
DetId seedId_;
/// flags (e.g. for handling of cleaned/uncleaned SC)
/// 4 most significant bits reserved
/// 28 bits for handling of cleaned/uncleaned
uint32_t flags_;
static const uint32_t flagsMask_ = 0x0FFFFFFF;
static const uint32_t flagsOffset_ = 28;
};
} // namespace reco
#endif
|