161 copy->reserve(nPfCand);
162 std::vector<int> oldToNew(nPfCand), newToOld, badToOld;
163 newToOld.reserve(nPfCand);
165 LogDebug(
"PFCandidateRecalibrator") <<
"NEW EV:";
174 if (
pf.particleId() == reco::PFCandidate::ParticleType::h0 &&
176 absEta > 1.4 && absEta < 3.) {
183 discarded->push_back(
pf);
184 oldToNew[
i] = (-discarded->size());
185 badToOld.push_back(
i);
189 oldToNew[
i] = (
copy->size());
190 newToOld.push_back(
i);
194 else if ((
pf.particleId() == reco::PFCandidate::ParticleType::h_HF ||
195 pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF) &&
199 GlobalPoint ecalGPoint(ecalPoint.X(), ecalPoint.Y(), ecalPoint.Z());
203 HcalDetId hDetId(closestDetId.subdet(), closestDetId.ieta(), closestDetId.iphi(), 1);
206 float longE =
pf.rawEcalEnergy() +
pf.rawHcalEnergy() / 2.;
207 float shortE =
pf.rawHcalEnergy() / 2.;
209 float ecalEnergy =
pf.rawEcalEnergy();
210 float hcalEnergy =
pf.rawHcalEnergy();
211 float totEnergy = ecalEnergy + hcalEnergy;
212 float totEnergyOrig = totEnergy;
216 for (
auto const& badIt :
badChHF_) {
217 if (hDetId.ieta() == badIt.ieta && hDetId.iphi() == badIt.iphi) {
219 <<
"==> orig en (tot,H,E): " <<
pf.energy() <<
" " <<
pf.rawHcalEnergy() <<
" " <<
pf.rawEcalEnergy();
220 if (badIt.depth == 1)
222 longE *= badIt.ratio;
223 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
224 totEnergy = ecalEnergy + hcalEnergy;
227 shortE *= badIt.ratio;
228 hcalEnergy = 2 * shortE;
229 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
230 totEnergy = ecalEnergy + hcalEnergy;
233 if ((
pf.particleId() == reco::PFCandidate::ParticleType::h_HF && shortE <
shortFibreThr_) ||
234 (
pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF && longE <
longFibreThr_))
237 LogDebug(
"PFCandidateRecalibrator") <<
"====> ieta,iphi,depth: " << badIt.ieta <<
" " << badIt.iphi <<
" " 238 << badIt.depth <<
" corr: " << badIt.ratio;
240 <<
"====> recal en (tot,H,E): " << totEnergy <<
" " << hcalEnergy <<
" " << ecalEnergy;
245 discarded->push_back(
pf);
246 oldToNew[
i] = (-discarded->size());
247 badToOld.push_back(
i);
249 LogDebug(
"PFCandidateRecalibrator") <<
"==> KILLED ";
252 oldToNew[
i] = (
copy->size());
253 newToOld.push_back(
i);
255 copy->back().setHcalEnergy(hcalEnergy, hcalEnergy);
256 copy->back().setEcalEnergy(ecalEnergy, ecalEnergy);
258 float scalingFactor = totEnergy / totEnergyOrig;
260 copy->back().setP4(recalibP4);
262 LogDebug(
"PFCandidateRecalibrator") <<
"====> stored en (tot,H,E): " <<
copy->back().energy() <<
" " 263 <<
copy->back().hcalEnergy() <<
" " <<
copy->back().ecalEnergy();
267 oldToNew[
i] = (
copy->size());
268 newToOld.push_back(
i);
272 oldToNew[
i] = (
copy->size());
273 newToOld.push_back(
i);
283 std::vector<reco::PFCandidateRef> refs;
284 refs.reserve(nPfCand);
287 for (
auto iOldToNew : oldToNew) {
297 for (
int i : newToOld) {
300 filler.insert(newpf, refs.begin(), refs.end());
303 for (
int i : badToOld) {
306 filler.insert(badpf, refs.begin(), refs.end());
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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)
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