23 emf_(cfg.getParameter<bool>(
"emf" )),
25 type_ (cfg.getParameter<std::
string>(
"flavorType")),
26 label_(cfg.getParameter<std::
string>(
"@module_label" )),
27 payload_( cfg.getParameter<std::
string>(
"payload") ),
28 useNPV_(cfg.getParameter<bool>(
"useNPV")),
29 useRho_(cfg.getParameter<bool>(
"useRho")),
32 std::vector<std::string> levels = cfg.
getParameter<std::vector<std::string> >(
"levels");
41 if(
std::find(levels.begin(), levels.end(),
"L5Flavor")!=levels.end() ||
std::find(levels.begin(), levels.end(),
"L7Parton")!=levels.end()){
54 if(
std::find(levels.begin(), levels.end(),
"L1JPTOffset")!=levels.end()){
60 <<
"The configured correction levels contain a L1JPTOffset correction, which re- \n"
61 <<
"quires the additional parameter extraJPTOffset or type std::string. This \n"
62 <<
"string should correspond to the L1Offset corrections that should be applied \n"
63 <<
"together with the JPTL1Offset corrections. These corrections can be of type \n"
64 <<
"L1Offset or L1FastJet. \n";
78 <<
"The configured correction levels contain an L1Offset or L1FastJet correction, \n"
79 <<
"which requires the number of offlinePrimaryVertices. Please specify this col- \n"
80 <<
"lection as additional optional parameter primaryVertices of type edm::InputTag\n"
81 <<
"in the jetCorrFactors module. \n";
95 <<
"The configured correction levels contain a L1FastJet correction, which re- \n"
96 <<
"quires the energy density parameter rho. Please specify this collection as \n"
97 <<
"additional optional parameter rho of type edm::InputTag in the jetCorrFac- \n"
103 message <<
"Module is configured to use the parameter rho, but rho is only used \n"
104 <<
"for L1FastJet corrections. The configuration of levels does not contain \n"
105 <<
"L1FastJet corrections though, so rho will not be used by this module. \n";
108 produces<JetCorrFactorsMap>();
111 std::vector<std::string>
114 std::vector<std::string>
expand;
115 for(std::vector<std::string>::const_iterator
level=levels.begin();
level!=levels.end(); ++
level){
116 if((*
level)==
"L5Flavor" || (*level)==
"L7Parton"){
120 message <<
"Jet energy corrections requested for level: L7Parton and type: 'T'. \n"
121 <<
"For this combination there is no GLUON correction available. The \n"
122 <<
"correction for this flavor type will be taken from 'J'.";
124 expand.push_back(
std::string(*level).append(
"_").append(
"g").append(
"J"));
131 expand.push_back(*
level);
137 std::vector<JetCorrectorParameters>
140 std::vector<JetCorrectorParameters>
params;
141 for(std::vector<std::string>::const_iterator
level=levels.begin();
level!=levels.end(); ++
level){
160 corrector->setJPTrawP4(p4);
163 const Jet* patjet =
dynamic_cast<Jet const *
>( &*
jet );
167 corrector->setJetEta(jet->eta()); corrector->setJetPt(jet->pt()); corrector->setJetE(jet->energy());
169 if(
emf_ && dynamic_cast<const reco::CaloJet*>(&*jet)){
170 corrector->setJetEMF(dynamic_cast<const reco::CaloJet*>(&*jet)->emEnergyFraction());
172 return corrector->getSubCorrections()[
level];
197 if (
cacheId_ != rec.cacheIdentifier()) {
202 for(FlavorCorrLevelMap::const_iterator flavor=
levels_.begin(); flavor!=
levels_.end(); ++flavor){
213 std::vector<JetCorrFactors> jcfs;
221 std::vector<JetCorrFactors::CorrectionFactor>
jec;
222 jec.push_back(std::make_pair<
std::string, std::vector<float> >(
std::string(
"Uncorrected"), std::vector<float>(1, 1)));
228 FlavorCorrLevelMap::const_iterator corrLevel=
levels_.begin();
230 throw cms::Exception(
"No JECFactors") <<
"You request to create a jetCorrFactors object with no JEC Levels indicated. \n"
231 <<
"This makes no sense, either you should correct this or drop the module from \n"
234 for(
unsigned int idx=0;
idx<corrLevel->second.size(); ++
idx){
236 std::vector<float> factors;
237 if(flavorDependent ||
238 corrLevel->second[
idx].find(
"L5Flavor")!=std::string::npos ||
239 corrLevel->second[
idx].find(
"L7Parton")!=std::string::npos){
240 flavorDependent=
true;
242 for(FlavorCorrLevelMap::const_iterator flavor=corrLevel; flavor!=
levels_.end(); ++flavor){
251 correctors_.find(flavor->first)->second->setRho(*rho);
266 correctors_.find(corrLevel->first)->second->setRho(*rho);
267 correctors_.find(corrLevel->first)->second->setJetA(
jet->jetArea());
279 jec.push_back(std::make_pair((corrLevel->second[
idx]).substr(0, (corrLevel->second[
idx]).find(
"_")), factors));
284 jcfs.push_back(corrFactors);
290 filler.
insert(jets, jcfs.begin(), jcfs.end());
293 event.put(jetCorrsMap);
300 iDesc.
add<
bool>(
"emf",
false);
304 iDesc.
add<
bool>(
"useNPV",
true);
306 iDesc.
add<
bool>(
"useRho",
true);
310 std::vector<std::string> levels;
317 iDesc.
add<std::vector<std::string> >(
"levels", levels);
318 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
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="")
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
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...
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::string payload_
label of payload
JetCorrFactorsProducer(const edm::ParameterSet &cfg)
default constructor
FlavorCorrLevelMap levels_
virtual double energy() const
energy
bool flavorDependent() const
return true if the jec levels contain at least one flavor dependent correction level ...
virtual 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.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Produces a ValueMap between JetCorrFactors and the to the originating reco jets.
edm::ValueMap< pat::JetCorrFactors > JetCorrFactorsMap
value map for JetCorrFactors (to be written into the event)
std::vector< std::string > expand(const std::vector< std::string > &levels, const JetCorrFactors::Flavor &flavor)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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 ...
Analysis-level calorimeter jet class.
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
virtual double phi() const
momentum azimuthal angle
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
unsigned long long cacheId_
cache identifier for JetCorrectionsRecord