22 : emf_(cfg.getParameter<
bool>(
"emf")),
23 srcToken_(consumes<
edm::
View<
reco::
Jet> >(cfg.getParameter<
edm::InputTag>(
"src"))),
24 type_(cfg.getParameter<
std::
string>(
"flavorType")),
25 label_(cfg.getParameter<
std::
string>(
"@module_label")),
26 payload_(cfg.getParameter<
std::
string>(
"payload")),
27 useNPV_(cfg.getParameter<
bool>(
"useNPV")),
28 useRho_(cfg.getParameter<
bool>(
"useRho")),
30 std::vector<std::string>
levels = cfg.
getParameter<std::vector<std::string> >(
"levels");
39 if (
std::find(levels.begin(), levels.end(),
"L5Flavor") != levels.end() ||
40 std::find(levels.begin(), levels.end(),
"L7Parton") != levels.end()) {
52 if (
std::find(levels.begin(), levels.end(),
"L1JPTOffset") != levels.end()) {
57 <<
"The configured correction levels contain a L1JPTOffset correction, which re- \n" 58 <<
"quires the additional parameter extraJPTOffset or type std::string. This \n" 59 <<
"string should correspond to the L1Offset corrections that should be applied \n" 60 <<
"together with the JPTL1Offset corrections. These corrections can be of type \n" 61 <<
"L1Offset or L1FastJet. \n";
74 <<
"The configured correction levels contain an L1Offset or L1FastJet correction, \n" 75 <<
"which requires the number of offlinePrimaryVertices. Please specify this col- \n" 76 <<
"lection as additional optional parameter primaryVertices of type edm::InputTag\n" 77 <<
"in the jetCorrFactors module. \n";
85 std::find(levels.begin(), levels.end(),
"L1FastJet") != levels.end()) {
91 <<
"The configured correction levels contain a L1FastJet correction, which re- \n" 92 <<
"quires the energy density parameter rho. Please specify this collection as \n" 93 <<
"additional optional parameter rho of type edm::InputTag in the jetCorrFac- \n" 98 message <<
"Module is configured to use the parameter rho, but rho is only used \n" 99 <<
"for L1FastJet corrections. The configuration of levels does not contain \n" 100 <<
"L1FastJet corrections though, so rho will not be used by this module. \n";
103 produces<JetCorrFactorsMap>();
108 std::vector<std::string>
expand;
109 for (std::vector<std::string>::const_iterator
level = levels.begin();
level != levels.end(); ++
level) {
110 if ((*
level) ==
"L5Flavor" || (*level) ==
"L7Parton") {
114 message <<
"Jet energy corrections requested for level: L7Parton and type: 'T'. \n" 115 <<
"For this combination there is no GLUON correction available. The \n" 116 <<
"correction for this flavor type will be taken from 'J'.";
118 expand.push_back(
std::string(*level).append(
"_").append(
"g").append(
"J"));
121 expand.push_back(
std::string(*level).append(
"_").append(
"q").append(
type_));
123 expand.push_back(
std::string(*level).append(
"_").append(
"c").append(
type_));
125 expand.push_back(
std::string(*level).append(
"_").append(
"b").append(
type_));
127 expand.push_back(*
level);
134 const std::vector<std::string>&
levels)
const {
135 std::vector<JetCorrectorParameters>
params;
136 for (std::vector<std::string>::const_iterator
level = levels.begin();
level != levels.end(); ++
level) {
159 corrector->setJPTrawP4(p4);
162 const Jet* patjet =
dynamic_cast<Jet const*
>(&*
jet);
164 corrector->setJetEta(patjet->
correctedP4(0).eta());
166 corrector->setJetPhi(patjet->
correctedP4(0).phi());
167 corrector->setJetE(patjet->
correctedP4(0).energy());
169 corrector->setJetEta(jet->eta());
170 corrector->setJetPt(jet->pt());
171 corrector->setJetPhi(jet->phi());
172 corrector->setJetE(jet->energy());
174 if (
emf_ && dynamic_cast<const reco::CaloJet*>(&*jet)) {
175 corrector->setJetEMF(dynamic_cast<const reco::CaloJet*>(&*jet)->emEnergyFraction());
177 return corrector->getSubCorrections()[
level];
198 if (
cacheId_ != rec.cacheIdentifier()) {
203 for (FlavorCorrLevelMap::const_iterator flavor =
levels_.begin(); flavor !=
levels_.end(); ++flavor) {
214 std::vector<JetCorrFactors> jcfs;
222 std::vector<JetCorrFactors::CorrectionFactor>
jec;
231 if (corrLevel ==
levels_.end()) {
233 <<
"You request to create a jetCorrFactors object with no JEC Levels indicated. \n" 234 <<
"This makes no sense, either you should correct this or drop the module from \n" 237 for (
unsigned int idx = 0;
idx < corrLevel->second.size(); ++
idx) {
238 std::vector<float> factors;
239 if (corrLevel->second[
idx].find(
"L5Flavor") != std::string::npos ||
240 corrLevel->second[
idx].find(
"L7Parton") != std::string::npos) {
241 for (FlavorCorrLevelMap::const_iterator flavor = corrLevel; flavor !=
levels_.end(); ++flavor) {
250 correctors_.find(flavor->first)->second->setRho(*rho);
264 correctors_.find(corrLevel->first)->second->setRho(*rho);
265 correctors_.find(corrLevel->first)->second->setJetA(
jet->jetArea());
277 jec.push_back(std::make_pair((corrLevel->second[
idx]).substr(0, (corrLevel->second[
idx]).find(
"_")), factors));
282 jcfs.push_back(corrFactors);
285 auto jetCorrsMap = std::make_unique<JetCorrFactorsMap>();
288 filler.insert(jets, jcfs.begin(), jcfs.end());
296 iDesc.
add<
bool>(
"emf",
false);
300 iDesc.
add<
bool>(
"useNPV",
true);
302 iDesc.
add<
bool>(
"useRho",
true);
306 std::vector<std::string>
levels;
313 iDesc.
add<std::vector<std::string> >(
"levels",
levels);
314 descriptions.
add(
"JetCorrFactorsProducer", iDesc);
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
T getParameter(std::string const &) const
edm::EDGetTokenT< double > rhoToken_
std::string payload()
map jet algorithm to payload in DB
double eta() const final
momentum pseudorapidity
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::string label_
label of jec factors
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void push_back(key_type i, value_type const &j, label_type const &flav="")
def setup(process, global_tag, zero_tesla=False)
double pt() const final
transverse momentum
edm::EDGetTokenT< std::vector< reco::Vertex > > primaryVerticesToken_
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
std::vector< std::string > extraJPTOffset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool emf_
use electromagnetic fraction for jet energy corrections or not (will only have an effect for jets Cal...
std::string payload_
label of payload
JetCorrFactorsProducer(const edm::ParameterSet &cfg)
default constructor
FlavorCorrLevelMap levels_
#define DEFINE_FWK_MODULE(type)
void produce(edm::Event &event, const edm::EventSetup &setup) override
everything that needs to be done per event
Jets made from CaloJets corrected for ZSP and tracks.
int numberOf(const edm::Handle< std::vector< reco::Vertex > > &primaryVertices)
determines the number of valid primary vertices for the standard L1Offset correction of JetMET ...
Class for the storage of jet correction factors.
double energy() const final
energy
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Produces a ValueMap between JetCorrFactors and the to the originating reco jets.
std::vector< std::string > expand(const std::vector< std::string > &levels, const JetCorrFactors::Flavor &flavor)
edm::EDGetTokenT< edm::View< reco::Jet > > srcToken_
input jet collection
std::vector< JetCorrectorParameters > params(const JetCorrectorParametersCollection ¶meters, const std::vector< std::string > &levels) const
return the jec parameters as input to the FactorizedJetCorrector for different flavors ...
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::unique_ptr< FactorizedJetCorrector > extraJPTOffsetCorrector_
cache container for JPTOffset jet corrections
std::map< JetCorrFactors::Flavor, std::unique_ptr< FactorizedJetCorrector > > correctors_
cache container for jet corrections
edm::InputTag primaryVertices_
label for L1Offset primaryVertex collection
edm::InputTag rho_
label for L1FastJet energy density parameter rho
bool useNPV_
use the NPV and rho with the JEC? (used for L1Offset/L1FastJet and L1FastJet, resp.)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of configuration file parameters
std::string type_
type of flavor dependent JEC factors (only 'J' and 'T' are allowed)
float evaluate(edm::View< reco::Jet >::const_iterator &jet, const JetCorrFactors::Flavor &flavor, int level)
evaluate jet correction factor up to a given level
double phi() const final
momentum azimuthal angle
unsigned long long cacheId_
cache identifier for JetCorrectionsRecord