59 if (cfg.
exists(
"energyDependency")) {
64 std::unique_ptr<StringCutObjectSelector<reco::Candidate>>
binSelection_;
80 if (!srcWeights.label().empty())
83 if (cfg.
exists(
"binning")) {
84 typedef std::vector<edm::ParameterSet> vParameterSet;
85 vParameterSet cfgBinning = cfg.
getParameter<vParameterSet>(
"binning");
86 for (vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin(); cfgBinningEntry != cfgBinning.end();
95 produces<reco::CandidateCollection>();
99 for (std::vector<binningEntryType*>::const_iterator it =
binning_.begin(); it !=
binning_.end(); ++it) {
112 auto shiftedParticles = std::make_unique<reco::CandidateCollection>();
114 for (
unsigned i = 0;
i < originalParticles->size(); ++
i) {
118 while (!weights->contains(particlePtr.
id()) && (particlePtr->numberOfSourceCandidatePtrs() > 0))
119 particlePtr = particlePtr->sourceCandidatePtr(0);
120 weight = (*weights)[particlePtr];
125 double uncertainty =
getUncShift(weightedParticle);
130 if ((weight > 0) && (!(
edm::isNotFinite(shift) && shiftedParticleP4.mag2() == 0)))
131 shiftedParticleP4 *= (1. + shift);
133 std::unique_ptr<reco::Candidate> shiftedParticle = std::make_unique<reco::LeafCandidate>(originalParticle);
134 shiftedParticle->setP4(shiftedParticleP4);
136 shiftedParticles->push_back(shiftedParticle.release());
145 for (std::vector<binningEntryType*>::iterator binningEntry =
binning_.begin(); binningEntry !=
binning_.end();
147 if ((!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(originalParticle)) {
148 if ((*binningEntry)->energyDep_)
149 valx = originalParticle.
energy();
151 valx = originalParticle.
pt();
153 valy = originalParticle.
eta();
154 return (*binningEntry)->binUncFormula_->Eval(valx, valy);
~ShiftedParticleProducer() override
edm::View< reco::Candidate > CandidateView
virtual double energy() const =0
energy
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::string binUncertainty_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr bool isNotFinite(T x)
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< CandidateView > srcToken_
constexpr bool isUninitialized() const noexcept
bool exists(std::string const ¶meterName) const
checks if a parameter exists
binningEntryType(std::string uncertainty, std::string moduleLabel)
void produce(edm::Event &evt, const edm::EventSetup &es) override
ShiftedParticleProducer(const edm::ParameterSet &cfg)
double getUncShift(const reco::Candidate &originalParticle)
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
binningEntryType(const edm::ParameterSet &cfg, std::string moduleLabel)
std::unique_ptr< TF2 > binUncFormula_
T getParameter(std::string const &) const
ProductID id() const
Accessor for product ID.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::unique_ptr< StringCutObjectSelector< reco::Candidate > > binSelection_
static unsigned int const shift
void setP4(const LorentzVector &p4) final
set 4-momentum
std::vector< binningEntryType * > binning_
virtual double eta() const =0
momentum pseudorapidity
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector