155 int nPfCand = pfcandidates->size();
158 copy->reserve(nPfCand);
159 std::vector<int> oldToNew(nPfCand), newToOld, badToOld;
160 newToOld.reserve(nPfCand);
162 LogDebug(
"PFCandidateRecalibrator") <<
"NEW EV:";
171 if (pf.particleId() == reco::PFCandidate::ParticleType::h0 &&
173 absEta > 1.4 && absEta < 3.) {
176 if (
reco::deltaR2(pf.eta(), pf.phi(), badIt.eta, badIt.phi) < 0.07)
180 discarded->push_back(pf);
181 oldToNew[
i] = (-discarded->size());
182 badToOld.push_back(i);
186 oldToNew[
i] = (
copy->size());
187 newToOld.push_back(i);
191 else if ((pf.particleId() == reco::PFCandidate::ParticleType::h_HF ||
192 pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF) &&
196 GlobalPoint ecalGPoint(ecalPoint.X(), ecalPoint.Y(), ecalPoint.Z());
200 HcalDetId hDetId(closestDetId.subdet(), closestDetId.ieta(), closestDetId.iphi(), 1);
203 float longE = pf.rawEcalEnergy() + pf.rawHcalEnergy() / 2.;
204 float shortE = pf.rawHcalEnergy() / 2.;
206 float ecalEnergy = pf.rawEcalEnergy();
207 float hcalEnergy = pf.rawHcalEnergy();
208 float totEnergy = ecalEnergy + hcalEnergy;
209 float totEnergyOrig = totEnergy;
213 for (
auto const& badIt :
badChHF_) {
214 if (hDetId.ieta() == badIt.ieta && hDetId.iphi() == badIt.iphi) {
216 <<
"==> orig en (tot,H,E): " << pf.energy() <<
" " << pf.rawHcalEnergy() <<
" " << pf.rawEcalEnergy();
217 if (badIt.depth == 1)
219 longE *= badIt.ratio;
220 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
221 totEnergy = ecalEnergy + hcalEnergy;
224 shortE *= badIt.ratio;
225 hcalEnergy = 2 * shortE;
226 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
227 totEnergy = ecalEnergy + hcalEnergy;
230 if ((pf.particleId() == reco::PFCandidate::ParticleType::h_HF && shortE <
shortFibreThr_) ||
231 (pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF && longE <
longFibreThr_))
234 LogDebug(
"PFCandidateRecalibrator") <<
"====> ieta,iphi,depth: " << badIt.ieta <<
" " << badIt.iphi <<
" "
235 << badIt.depth <<
" corr: " << badIt.ratio;
237 <<
"====> recal en (tot,H,E): " << totEnergy <<
" " << hcalEnergy <<
" " << ecalEnergy;
242 discarded->push_back(pf);
243 oldToNew[
i] = (-discarded->size());
244 badToOld.push_back(i);
246 LogDebug(
"PFCandidateRecalibrator") <<
"==> KILLED ";
249 oldToNew[
i] = (
copy->size());
250 newToOld.push_back(i);
252 copy->back().setHcalEnergy(hcalEnergy, hcalEnergy);
253 copy->back().setEcalEnergy(ecalEnergy, ecalEnergy);
255 float scalingFactor = totEnergy / totEnergyOrig;
257 copy->back().setP4(recalibP4);
259 LogDebug(
"PFCandidateRecalibrator") <<
"====> stored en (tot,H,E): " <<
copy->back().energy() <<
" "
260 <<
copy->back().hcalEnergy() <<
" " <<
copy->back().ecalEnergy();
264 oldToNew[
i] = (
copy->size());
265 newToOld.push_back(i);
269 oldToNew[
i] = (
copy->size());
270 newToOld.push_back(i);
280 std::vector<reco::PFCandidateRef> refs;
281 refs.reserve(nPfCand);
284 for (
auto iOldToNew : oldToNew) {
291 filler.insert(pfcandidates, refs.begin(), refs.end());
294 for (
int i : newToOld) {
297 filler.insert(newpf, refs.begin(), refs.end());
300 for (
int i : badToOld) {
303 filler.insert(badpf, refs.begin(), refs.end());
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
T const * product() const
std::vector< HFChannel > badChHF_
edm::EDGetTokenT< reco::PFCandidateCollection > pfcandidates_
Particle reconstructed by the particle flow algorithm.