-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathGsfElectron.cc
274 lines (245 loc) · 10.5 KB
/
GsfElectron.cc
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/EgammaReco/interface/BasicCluster.h"
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
using namespace reco;
GsfElectronCoreRef GsfElectron::core() const { return core_; }
void GsfElectron::init() {
passCutBasedPreselection_ = false;
passPflowPreselection_ = false;
passMvaPreslection_ = false;
ambiguous_ = true;
class_ = UNKNOWN;
}
GsfElectron::GsfElectron() { init(); }
GsfElectron::GsfElectron(const GsfElectronCoreRef& core) : core_(core) { init(); }
GsfElectron::GsfElectron(int charge,
const ChargeInfo& chargeInfo,
const GsfElectronCoreRef& core,
const TrackClusterMatching& tcm,
const TrackExtrapolations& te,
const ClosestCtfTrack& ctfInfo,
const FiducialFlags& ff,
const ShowerShape& ss,
const ConversionRejection& crv)
: chargeInfo_(chargeInfo),
core_(core),
trackClusterMatching_(tcm),
trackExtrapolations_(te),
//closestCtfTrack_(ctfInfo),
fiducialFlags_(ff),
showerShape_(ss),
conversionRejection_(crv) {
init();
setCharge(charge);
setVertex(math::XYZPoint(te.positionAtVtx.x(), te.positionAtVtx.y(), te.positionAtVtx.z()));
setPdgId(-11 * charge);
/*if (ecalDrivenSeed())*/ corrections_.correctedEcalEnergy = superCluster()->energy();
// assert(ctfInfo.ctfTrack==(GsfElectron::core()->ctfTrack())) ;
// assert(ctfInfo.shFracInnerHits==(GsfElectron::core()->ctfGsfOverlap())) ;
}
GsfElectron::GsfElectron(int charge,
const ChargeInfo& chargeInfo,
const GsfElectronCoreRef& core,
const TrackClusterMatching& tcm,
const TrackExtrapolations& te,
const ClosestCtfTrack& ctfInfo,
const FiducialFlags& ff,
const ShowerShape& ss,
const ShowerShape& full5x5_ss,
const ConversionRejection& crv,
const SaturationInfo& si)
: chargeInfo_(chargeInfo),
core_(core),
trackClusterMatching_(tcm),
trackExtrapolations_(te),
fiducialFlags_(ff),
showerShape_(ss),
full5x5_showerShape_(full5x5_ss),
saturationInfo_(si),
conversionRejection_(crv) {
init();
setCharge(charge);
setVertex(math::XYZPoint(te.positionAtVtx.x(), te.positionAtVtx.y(), te.positionAtVtx.z()));
setPdgId(-11 * charge);
corrections_.correctedEcalEnergy = superCluster()->energy();
}
GsfElectron::GsfElectron(const GsfElectron& electron, const GsfElectronCoreRef& core)
: RecoCandidate(electron),
chargeInfo_(electron.chargeInfo_),
core_(core),
trackClusterMatching_(electron.trackClusterMatching_),
trackExtrapolations_(electron.trackExtrapolations_),
//closestCtfTrack_(electron.closestCtfTrack_),
fiducialFlags_(electron.fiducialFlags_),
showerShape_(electron.showerShape_),
full5x5_showerShape_(electron.full5x5_showerShape_),
saturationInfo_(electron.saturationInfo_),
dr03_(electron.dr03_),
dr04_(electron.dr04_),
conversionRejection_(electron.conversionRejection_),
pfIso_(electron.pfIso_),
mvaInput_(electron.mvaInput_),
mvaOutput_(electron.mvaOutput_),
passCutBasedPreselection_(electron.passCutBasedPreselection_),
passPflowPreselection_(electron.passPflowPreselection_),
passMvaPreslection_(electron.passMvaPreslection_),
ambiguous_(electron.ambiguous_),
ambiguousGsfTracks_(electron.ambiguousGsfTracks_),
classVariables_(electron.classVariables_),
class_(electron.class_),
corrections_(electron.corrections_),
pixelMatchVariables_(electron.pixelMatchVariables_) {
//assert(electron.core()->ctfTrack()==core->ctfTrack()) ;
//assert(electron.core()->ctfGsfOverlap()==core->ctfGsfOverlap()) ;
}
GsfElectron::GsfElectron(const GsfElectron& electron,
const GsfElectronCoreRef& core,
const CaloClusterPtr& electronCluster,
const TrackRef& closestCtfTrack,
const TrackBaseRef& conversionPartner,
const GsfTrackRefVector& ambiguousTracks)
: RecoCandidate(electron),
chargeInfo_(electron.chargeInfo_),
core_(core),
trackClusterMatching_(electron.trackClusterMatching_),
trackExtrapolations_(electron.trackExtrapolations_),
//closestCtfTrack_(electron.closestCtfTrack_),
fiducialFlags_(electron.fiducialFlags_),
showerShape_(electron.showerShape_),
full5x5_showerShape_(electron.full5x5_showerShape_),
saturationInfo_(electron.saturationInfo_),
dr03_(electron.dr03_),
dr04_(electron.dr04_),
conversionRejection_(electron.conversionRejection_),
pfIso_(electron.pfIso_),
mvaInput_(electron.mvaInput_),
mvaOutput_(electron.mvaOutput_),
passCutBasedPreselection_(electron.passCutBasedPreselection_),
passPflowPreselection_(electron.passPflowPreselection_),
passMvaPreslection_(electron.passMvaPreslection_),
ambiguous_(electron.ambiguous_),
ambiguousGsfTracks_(ambiguousTracks),
//mva_(electron.mva_),
classVariables_(electron.classVariables_),
class_(electron.class_),
corrections_(electron.corrections_),
pixelMatchVariables_(electron.pixelMatchVariables_) {
trackClusterMatching_.electronCluster = electronCluster;
//closestCtfTrack_.ctfTrack = closestCtfTrack ;
conversionRejection_.partner = conversionPartner;
//assert(closestCtfTrack==core->ctfTrack()) ;
//assert(electron.core()->ctfGsfOverlap()==core->ctfGsfOverlap()) ;
// TO BE DONE
// Check that the new edm references are really
// the clones of the former references, and therefore other attributes
// stay valid :
// * electron.core_ ~ core ?
// * electron.trackClusterMatching_.electronCluster ~ electronCluster ?
// * electron.closestCtfTrack_.ctfTrack ~ closestCtfTrack ?
// * electron.ambiguousGsfTracks_ ~ ambiguousTracks ?
}
bool GsfElectron::overlap(const Candidate& c) const {
const RecoCandidate* o = dynamic_cast<const RecoCandidate*>(&c);
return (o != nullptr && (checkOverlap(gsfTrack(), o->gsfTrack()) || checkOverlap(superCluster(), o->superCluster())));
//?? return false;
}
GsfElectron* GsfElectron::clone() const { return new GsfElectron(*this); }
GsfElectron* GsfElectron::clone(const GsfElectronCoreRef& core,
const CaloClusterPtr& electronCluster,
const TrackRef& closestCtfTrack,
const TrackBaseRef& conversionPartner,
const GsfTrackRefVector& ambiguousTracks) const {
return new GsfElectron(*this, core, electronCluster, closestCtfTrack, conversionPartner, ambiguousTracks);
}
bool GsfElectron::ecalDriven() const { return (ecalDrivenSeed() && passingCutBasedPreselection()); }
void GsfElectron::setCorrectedEcalEnergyError(float energyError) {
corrections_.correctedEcalEnergyError = energyError;
}
void GsfElectron::setCorrectedEcalEnergy(float newEnergy) { setCorrectedEcalEnergy(newEnergy, true); }
void GsfElectron::setCorrectedEcalEnergy(float newEnergy, bool rescaleDependentValues) {
math::XYZTLorentzVectorD momentum = p4();
momentum *= newEnergy / momentum.e();
setP4(momentum);
if (corrections_.correctedEcalEnergy > 0. && rescaleDependentValues) {
for (size_t id = 0; id < showerShape_.hcalOverEcal.size(); ++id) {
showerShape_.hcalOverEcal[id] *= corrections_.correctedEcalEnergy / newEnergy;
showerShape_.hcalOverEcalBc[id] *= corrections_.correctedEcalEnergy / newEnergy;
}
trackClusterMatching_.eSuperClusterOverP *= newEnergy / corrections_.correctedEcalEnergy;
corrections_.correctedEcalEnergyError *= newEnergy / corrections_.correctedEcalEnergy;
}
corrections_.correctedEcalEnergy = newEnergy;
corrections_.isEcalEnergyCorrected = true;
}
void GsfElectron::setTrackMomentumError(float trackErr) { corrections_.trackMomentumError = trackErr; }
void GsfElectron::setP4(P4Kind kind, const reco::Candidate::LorentzVector& p4, float error, bool setCandidate) {
switch (kind) {
case P4_FROM_SUPER_CLUSTER:
corrections_.fromSuperClusterP4 = p4;
corrections_.fromSuperClusterP4Error = error;
break;
case P4_COMBINATION:
corrections_.combinedP4 = p4;
corrections_.combinedP4Error = error;
break;
case P4_PFLOW_COMBINATION:
corrections_.pflowP4 = p4;
corrections_.pflowP4Error = error;
break;
default:
throw cms::Exception("GsfElectron") << "unexpected p4 kind: " << kind;
}
if (setCandidate) {
setP4(p4);
corrections_.candidateP4Kind = kind;
}
}
const Candidate::LorentzVector& GsfElectron::p4(P4Kind kind) const {
switch (kind) {
case P4_FROM_SUPER_CLUSTER:
return corrections_.fromSuperClusterP4;
case P4_COMBINATION:
return corrections_.combinedP4;
case P4_PFLOW_COMBINATION:
return corrections_.pflowP4;
default:
throw cms::Exception("GsfElectron") << "unexpected p4 kind: " << kind;
}
}
float GsfElectron::p4Error(P4Kind kind) const {
switch (kind) {
case P4_FROM_SUPER_CLUSTER:
return corrections_.fromSuperClusterP4Error;
case P4_COMBINATION:
return corrections_.combinedP4Error;
case P4_PFLOW_COMBINATION:
return corrections_.pflowP4Error;
default:
throw cms::Exception("GsfElectron") << "unexpected p4 kind: " << kind;
}
}
void GsfElectron::hcalToRun2EffDepth() {
auto& ss1 = showerShape_;
auto& ss2 = full5x5_showerShape_;
auto& iv1 = dr03_;
auto& iv2 = dr04_;
for (uint id = 2u; id < ss1.hcalOverEcal.size(); ++id) {
ss1.hcalOverEcal[1] += ss1.hcalOverEcal[id];
ss1.hcalOverEcalBc[1] += ss1.hcalOverEcalBc[id];
ss1.hcalOverEcal[id] = 0.f;
ss1.hcalOverEcalBc[id] = 0.f;
ss2.hcalOverEcal[1] += ss2.hcalOverEcal[id];
ss2.hcalOverEcalBc[1] += ss2.hcalOverEcalBc[id];
ss2.hcalOverEcal[id] = 0.f;
ss2.hcalOverEcalBc[id] = 0.f;
iv1.hcalRecHitSumEt[1] += iv1.hcalRecHitSumEt[id];
iv1.hcalRecHitSumEtBc[1] += iv1.hcalRecHitSumEtBc[id];
iv1.hcalRecHitSumEt[id] = 0.f;
iv1.hcalRecHitSumEtBc[id] = 0.f;
iv2.hcalRecHitSumEt[1] += iv2.hcalRecHitSumEt[id];
iv2.hcalRecHitSumEtBc[1] += iv2.hcalRecHitSumEtBc[id];
iv2.hcalRecHitSumEt[id] = 0.f;
iv2.hcalRecHitSumEtBc[id] = 0.f;
}
}