CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetEnergyShift.cc
Go to the documentation of this file.
4 
7 
35 
36  public:
38  explicit JetEnergyShift(const edm::ParameterSet&);
41 
42  private:
44  virtual void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  private:
56  double scaleFactor_;
61 };
62 
63 
65  inputJetsToken_ (consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("inputJets"))),
66  inputMETsToken_ (consumes<std::vector<pat::MET> >(cfg.getParameter<edm::InputTag>("inputMETs"))),
67  scaleFactor_ (cfg.getParameter<double> ("scaleFactor" )),
68  jetPTThresholdForMET_(cfg.getParameter<double> ("jetPTThresholdForMET")),
69  jetEMLimitForMET_ (cfg.getParameter<double> ("jetEMLimitForMET" ))
70 {
71  // use label of input to create label for output
72  outputJets_ = cfg.getParameter<edm::InputTag>("inputJets").label();
73  outputMETs_ = cfg.getParameter<edm::InputTag>("inputMETs").label();
74  // register products
75  produces<std::vector<pat::Jet> >(outputJets_);
76  produces<std::vector<pat::MET> >(outputMETs_);
77 }
78 
79 void
81 {
83  event.getByToken(inputJetsToken_, jets);
84 
86  event.getByToken(inputMETsToken_, mets);
87 
88  std::auto_ptr<std::vector<pat::Jet> > pJets(new std::vector<pat::Jet>);
89  std::auto_ptr<std::vector<pat::MET> > pMETs(new std::vector<pat::MET>);
90 
91  double dPx = 0.;
92  double dPy = 0.;
93  double dSumEt = 0.;
94 
95  for(std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
96  pat::Jet scaledJet = *jet;
97  scaledJet.scaleEnergy( scaleFactor_ );
98  pJets->push_back( scaledJet );
99  // consider jet scale shift only if the raw jet pt and emf
100  // is above the thresholds given in the module definition
101  if(jet->correctedJet("raw").pt() > jetPTThresholdForMET_
102  && jet->emEnergyFraction() < jetEMLimitForMET_) {
103  dPx += scaledJet.px() - jet->px();
104  dPy += scaledJet.py() - jet->py();
105  dSumEt += scaledJet.et() - jet->et();
106  }
107  }
108 
109  // scale MET accordingly
110  pat::MET met = *(mets->begin());
111  double scaledMETPx = met.px() - dPx;
112  double scaledMETPy = met.py() - dPy;
113  pat::MET scaledMET(reco::MET(met.sumEt()+dSumEt, reco::MET::LorentzVector(scaledMETPx, scaledMETPy, 0, sqrt(scaledMETPx*scaledMETPx+scaledMETPy*scaledMETPy)), reco::MET::Point(0,0,0)));
114  pMETs->push_back( scaledMET );
115  event.put(pJets, outputJets_);
116  event.put(pMETs, outputMETs_);
117 }
118 
Analysis-level MET class.
Definition: MET.h:42
T getParameter(std::string const &) const
virtual double et() const GCC11_FINAL
transverse energy
~JetEnergyShift()
default destructor
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:7
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:444
double jetEMLimitForMET_
limit on the emf of the jet for Type1 MET corrections
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
std::string outputJets_
jet output collection
double sumEt() const
Definition: MET.h:48
Definition: MET.h:32
T sqrt(T t)
Definition: SSEVec.h:48
vector< PseudoJet > jets
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
virtual void produce(edm::Event &, const edm::EventSetup &) override
rescale jet energy and recalculated MET
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
edm::EDGetTokenT< std::vector< pat::MET > > inputMETsToken_
met input collection
JetEnergyShift(const edm::ParameterSet &)
default constructor
Analysis-level calorimeter jet class.
Definition: Jet.h:70
double scaleFactor_
scale factor for the rescaling
Plugin to shift the jet energy scale and recalculate the MET accordingly.
double jetPTThresholdForMET_
threshold on (raw!) jet pt for Type1 MET corrections
edm::EDGetTokenT< std::vector< pat::Jet > > inputJetsToken_
jet input collection
std::string outputMETs_
MET output collection.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:26
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:30