|
|
Go to the documentation of this file. 1 #ifndef PAT_SMEAREDJETPRODUCERT_H
2 #define PAT_SMEAREDJETPRODUCERT_H
51 desc.add<
double>(
"dRMax");
52 desc.add<
double>(
"dPtMaxFactor");
68 for (
const auto& genJet :
genJets) {
80 matched_genJet = &genJet;
84 return matched_genJet;
123 std::uint32_t
seed =
cfg.getParameter<std::uint32_t>(
"seed");
130 std::int32_t
variation =
cfg.getParameter<std::int32_t>(
"variation");
147 "Invalid value for 'variation' parameter. Only -1, 0, 1 or 101, -101 are supported.");
150 produces<JetCollection>();
157 desc.add<
bool>(
"enabled");
159 desc.add<std::int32_t>(
"variation", 0);
161 desc.add<std::uint32_t>(
"seed", 37428479);
162 desc.add<
bool>(
"skipGenMatching",
false);
163 desc.add<
bool>(
"useDeterministicSeed",
true);
164 desc.addUntracked<
bool>(
"debug",
false);
206 unsigned int runNum_uint = static_cast<unsigned int>(
event.id().run());
207 unsigned int lumiNum_uint = static_cast<unsigned int>(
event.id().luminosityBlock());
208 unsigned int evNum_uint = static_cast<unsigned int>(
event.id().event());
209 unsigned int jet0eta = uint32_t(
jets.empty() ? 0 :
jets[0].eta() / 0.01);
210 std::uint32_t
seed = jet0eta +
m_nomVar + (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
218 auto smearedJets = std::make_unique<JetCollection>();
223 smearedJets->push_back(
jet);
228 double jet_resolution =
resolution.getResolution(
235 std::cout <<
"jet: pt: " <<
jet.pt() <<
" eta: " <<
jet.eta() <<
" phi: " <<
jet.phi()
236 <<
" e: " <<
jet.energy() << std::endl;
237 std::cout <<
"resolution: " << jet_resolution << std::endl;
238 std::cout <<
"resolution scale factor: " << jer_sf << std::endl;
245 double smearFactor = 1.;
253 std::cout <<
"gen jet: pt: " << genJet->
pt() <<
" eta: " << genJet->
eta() <<
" phi: " << genJet->
phi()
254 <<
" e: " << genJet->
energy() << std::endl;
257 double dPt =
jet.pt() - genJet->
pt();
258 smearFactor = 1 +
m_nomVar * (jer_sf - 1.) * dPt /
jet.pt();
260 }
else if (jer_sf > 1) {
265 double sigma = jet_resolution *
std::sqrt(jer_sf * jer_sf - 1);
267 std::cout <<
"gaussian width: " << sigma << std::endl;
270 std::normal_distribution<>
d(0, sigma);
273 std::cout <<
"Impossible to smear this jet" << std::endl;
282 std::cout <<
"The smearing factor (" << smearFactor <<
") is either negative or too small. Fixing it to "
283 << newSmearFactor <<
" to avoid change of direction." << std::endl;
285 smearFactor = newSmearFactor;
289 smearedJet.scaleEnergy(smearFactor);
292 std::cout <<
"smeared jet (" << smearFactor <<
"): pt: " << smearedJet.pt() <<
" eta: " << smearedJet.eta()
293 <<
" phi: " << smearedJet.phi() <<
" e: " << smearedJet.energy() << std::endl;
296 smearedJets->push_back(smearedJet);
GreaterByPt< T > jetPtComparator
static void fillDescriptions(edm::ParameterSetDescription &desc)
float getScaleFactor(const JetParameters ¶meters, Variation variation=Variation::NOMINAL, std::string uncertaintySource="") const
Jets made from MC generator particles.
std::vector< GenJet > GenJetCollection
collection of GenJet objects
void produce(edm::Event &event, const edm::EventSetup &setup) override
GenJetMatcher(const edm::ParameterSet &cfg, edm::ConsumesCollector &&collector)
std::shared_ptr< pat::GenJetMatcher > m_genJetMatcher
std::vector< T > JetCollection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double pt() const final
transverse momentum
void getTokens(const edm::Event &event)
static constexpr const double MIN_JET_ENERGY
edm::EDGetTokenT< JetCollection > m_jets_token
std::string m_uncertaintySource
edm::EDGetTokenT< reco::GenJetCollection > m_genJetsToken
static const std::string source
std::unique_ptr< JME::JetResolution > m_resolution_from_file
Variation m_systematic_variation
edm::Handle< reco::GenJetCollection > m_genJets
bool m_useDeterministicSeed
double eta() const final
momentum pseudorapidity
std::string m_jets_algo_pt
static const JetResolutionScaleFactor get(const edm::EventSetup &, const std::string &)
std::mt19937 m_random_generator
double phi() const final
momentum azimuthal angle
const reco::GenJet * match(const T &jet, double resolution)
edm::EDGetTokenT< double > m_rho_token
double energy() const final
energy
static const JetResolution get(const edm::EventSetup &, const std::string &)
std::unique_ptr< JME::JetResolutionScaleFactor > m_scale_factor_from_file
Abs< T >::type abs(const T &t)
void addDefault(ParameterSetDescription const &psetDescription)
SmearedJetProducerT(const edm::ParameterSet &cfg)