45 HFChannel(
int ieta,
int iphi,
int depth,
float ratio):
80 shortFibreThr_(iConfig.getParameter<double>(
"shortFibreThr")),
81 longFibreThr_(iConfig.getParameter<double>(
"longFibreThr"))
83 produces<reco::PFCandidateCollection>();
84 produces<reco::PFCandidateCollection>(
"discarded");
85 produces<edm::ValueMap<reco::PFCandidateRef>>();
104 buggedRespCorrs.
setTopo(theHBHETopology);
118 for(
auto id : cellsHE)
121 float buggedRespCorr = buggedRespCorrs.getValues(
id)->getValue();
122 if (buggedRespCorr == 0.)
125 float ratio = currentRespCorr/buggedRespCorr;
135 for(
auto id : cellsHF)
138 float buggedRespCorr = buggedRespCorrs.getValues(
id)->getValue();
139 if (buggedRespCorr == 0.)
142 float ratio = currentRespCorr/buggedRespCorr;
168 int nPfCand = pfcandidates->size();
171 copy->reserve(nPfCand);
173 newToOld.reserve(nPfCand);
175 LogDebug(
"PFCandidateRecalibrator") <<
"NEW EV:";
185 if(
pf.particleId() == reco::PFCandidate::ParticleType::h0 &&
187 absEta > 1.4 && absEta < 3.)
197 discarded->push_back(
pf);
199 badToOld.push_back(i);
206 newToOld.push_back(i);
210 else if( (
pf.particleId() == reco::PFCandidate::ParticleType::h_HF ||
pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF) &&
215 GlobalPoint ecalGPoint(ecalPoint.X(),ecalPoint.Y(),ecalPoint.Z());
220 HcalDetId hDetId(closestDetId.subdet(),closestDetId.ieta(),closestDetId.iphi(),1);
223 float longE =
pf.rawEcalEnergy() +
pf.rawHcalEnergy()/2.;
224 float shortE =
pf.rawHcalEnergy()/2.;
226 float ecalEnergy =
pf.rawEcalEnergy();
227 float hcalEnergy =
pf.rawHcalEnergy();
228 float totEnergy = ecalEnergy + hcalEnergy;
229 float totEnergyOrig = totEnergy;
235 if ( hDetId.ieta() == badIt.ieta &&
236 hDetId.iphi() == badIt.iphi )
238 LogDebug(
"PFCandidateRecalibrator") <<
"==> orig en (tot,H,E): " 239 <<
pf.energy() <<
" " <<
pf.rawHcalEnergy() <<
" " <<
pf.rawEcalEnergy();
242 longE *= badIt.ratio;
243 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
244 totEnergy = ecalEnergy + hcalEnergy;
248 shortE *= badIt.ratio;
249 hcalEnergy = 2*shortE;
250 ecalEnergy = ((longE - shortE) > 0.) ? (longE - shortE) : 0.;
251 totEnergy = ecalEnergy + hcalEnergy;
254 if((
pf.particleId() == reco::PFCandidate::ParticleType::h_HF && shortE <
shortFibreThr_) ||
255 (
pf.particleId() == reco::PFCandidate::ParticleType::egamma_HF && longE <
longFibreThr_))
258 LogDebug(
"PFCandidateRecalibrator") <<
"====> ieta,iphi,depth: " 259 << badIt.ieta <<
" " << badIt.iphi <<
" " << badIt.depth <<
" corr: " << badIt.ratio;
260 LogDebug(
"PFCandidateRecalibrator") <<
"====> recal en (tot,H,E): " 261 << totEnergy <<
" " << hcalEnergy <<
" " << ecalEnergy;
268 discarded->push_back(
pf);
270 badToOld.push_back(i);
272 LogDebug(
"PFCandidateRecalibrator") <<
"==> KILLED ";
278 newToOld.push_back(i);
280 copy->back().setHcalEnergy(hcalEnergy, hcalEnergy);
281 copy->back().setEcalEnergy(ecalEnergy, ecalEnergy);
283 float scalingFactor = totEnergy/totEnergyOrig;
285 copy->back().setP4( recalibP4 );
287 LogDebug(
"PFCandidateRecalibrator") <<
"====> stored en (tot,H,E): " 288 << copy->back().energy() <<
" " << copy->back().hcalEnergy() <<
" " << copy->back().ecalEnergy();
295 newToOld.push_back(i);
302 newToOld.push_back(i);
312 std::vector<reco::PFCandidateRef> refs; refs.reserve(nPfCand);
322 filler.
insert(pfcandidates, refs.begin(), refs.end());
325 for (
int i : newToOld) {
328 filler.
insert(newpf, refs.begin(), refs.end());
331 for (
int i : badToOld) {
334 filler.
insert(badpf, refs.begin(), refs.end());
346 desc.
add<
double>(
"shortFibreThr", 1.4);
347 desc.
add<
double>(
"longFibreThr", 1.4);
349 descriptions.
add(
"pfCandidateRecalibrator", desc);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::ESWatcher< HcalRecNumberingRecord > hcalDbWatcher_
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
Geom::Phi< T > phi() const
void insert(const H &h, I begin, I end)
void endRun(const edm::Run &iRun, edm::EventSetup const &iSetup) override
std::vector< HEChannel > badChHE_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
PFCandidateRecalibrator(const edm::ParameterSet &)
HEChannel(float eta, float phi, float ratio)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const HcalRespCorr * getHcalRespCorr(const HcalGenericDetId &fId) const
int depth() const
get the tower depth
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
GlobalPoint getPosition(const DetId &id) const
~PFCandidateRecalibrator() override
edm::ESWatcher< HcalRespCorrsRcd > hcalRCWatcher_
int iphi() const
get the cell iphi
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< HFChannel > badChHF_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HFChannel(int ieta, int iphi, int depth, float ratio)
bool check(const edm::EventSetup &iSetup)
edm::EDGetTokenT< reco::PFCandidateCollection > pfcandidates_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
void beginRun(const edm::Run &iRun, edm::EventSetup const &iSetup) override
Particle reconstructed by the particle flow algorithm.
T const * product() const
void setTopo(const HcalTopology *topo)
DetId getClosestCell(const GlobalPoint &r) const override