159 copy->reserve(nPfCand);
160 std::vector<int> oldToNew(nPfCand), newToOld, badToOld;
161 newToOld.reserve(nPfCand);
163 LogDebug(
"PFCandidateRecalibrator") <<
"NEW EV:";
172 if (
pf.particleId() == reco::PFCandidate::ParticleType::h0 &&
174 absEta > 1.4 && absEta < 3.) {
181 discarded->push_back(
pf);
182 oldToNew[
i] = (-discarded->size());
183 badToOld.push_back(
i);
187 oldToNew[
i] = (
copy->size());
188 newToOld.push_back(
i);
192 else if ((
pf.particleId() == reco::PFCandidate::ParticleType::h_HF ||
193 pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF) &&
197 GlobalPoint ecalGPoint(ecalPoint.X(), ecalPoint.Y(), ecalPoint.Z());
201 HcalDetId hDetId(closestDetId.subdet(), closestDetId.ieta(), closestDetId.iphi(), 1);
204 float longE =
pf.rawEcalEnergy() +
pf.rawHcalEnergy() / 2.;
205 float shortE =
pf.rawHcalEnergy() / 2.;
207 float ecalEnergy =
pf.rawEcalEnergy();
208 float hcalEnergy =
pf.rawHcalEnergy();
209 float totEnergy = ecalEnergy + hcalEnergy;
210 float totEnergyOrig = totEnergy;
214 for (
auto const& badIt :
badChHF_) {
215 if (hDetId.ieta() == badIt.ieta && hDetId.iphi() == badIt.iphi) {
217 <<
"==> orig en (tot,H,E): " <<
pf.energy() <<
" " <<
pf.rawHcalEnergy() <<
" " <<
pf.rawEcalEnergy();
218 if (badIt.depth == 1)
220 longE *= badIt.ratio;
221 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
222 totEnergy = ecalEnergy + hcalEnergy;
225 shortE *= badIt.ratio;
226 hcalEnergy = 2 * shortE;
227 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
228 totEnergy = ecalEnergy + hcalEnergy;
231 if ((
pf.particleId() == reco::PFCandidate::ParticleType::h_HF && shortE <
shortFibreThr_) ||
232 (
pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF && longE <
longFibreThr_))
235 LogDebug(
"PFCandidateRecalibrator") <<
"====> ieta,iphi,depth: " << badIt.ieta <<
" " << badIt.iphi <<
" " 236 << badIt.depth <<
" corr: " << badIt.ratio;
238 <<
"====> recal en (tot,H,E): " << totEnergy <<
" " << hcalEnergy <<
" " << ecalEnergy;
243 discarded->push_back(
pf);
244 oldToNew[
i] = (-discarded->size());
245 badToOld.push_back(
i);
247 LogDebug(
"PFCandidateRecalibrator") <<
"==> KILLED ";
250 oldToNew[
i] = (
copy->size());
251 newToOld.push_back(
i);
253 copy->back().setHcalEnergy(hcalEnergy, hcalEnergy);
254 copy->back().setEcalEnergy(ecalEnergy, ecalEnergy);
256 float scalingFactor = totEnergy / totEnergyOrig;
258 copy->back().setP4(recalibP4);
260 LogDebug(
"PFCandidateRecalibrator") <<
"====> stored en (tot,H,E): " <<
copy->back().energy() <<
" " 261 <<
copy->back().hcalEnergy() <<
" " <<
copy->back().ecalEnergy();
265 oldToNew[
i] = (
copy->size());
266 newToOld.push_back(
i);
270 oldToNew[
i] = (
copy->size());
271 newToOld.push_back(
i);
281 std::vector<reco::PFCandidateRef> refs;
282 refs.reserve(nPfCand);
285 for (
auto iOldToNew : oldToNew) {
295 for (
int i : newToOld) {
298 filler.insert(newpf, refs.begin(), refs.end());
301 for (
int i : badToOld) {
304 filler.insert(badpf, refs.begin(), refs.end());
DetId getClosestCell(const GlobalPoint &r) const override
std::vector< HEChannel > badChHE_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Abs< T >::type abs(const T &t)
bool getData(T &iHolder) const
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > calogeomTokenEvent_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
std::vector< HFChannel > badChHF_
edm::EDGetTokenT< reco::PFCandidateCollection > pfcandidates_
Particle reconstructed by the particle flow algorithm.
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly