CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATMETSlimmer::OneMETShift Class Reference

Public Member Functions

 OneMETShift ()
 
 OneMETShift (pat::MET::METUncertainty shift_, pat::MET::METCorrectionType level_, const edm::InputTag &baseTag, edm::ConsumesCollector &&cc, bool t0FromMiniAOD_, bool corShift_, bool uncShift_, bool isSmeared_=false)
 
void readAndSet (const edm::Event &ev, pat::MET &met) const
 

Private Attributes

const bool corShift
 
const bool isSmeared
 
const pat::MET::METCorrectionType level
 
const pat::MET::METUncertainty shift
 
const bool t0FromMiniAOD
 
edm::EDGetTokenT< pat::METCollectiontoken
 
const bool uncShift
 

Detailed Description

Definition at line 27 of file PATMETSlimmer.cc.

Constructor & Destructor Documentation

pat::PATMETSlimmer::OneMETShift::OneMETShift ( )
inline

Definition at line 29 of file PATMETSlimmer.cc.

References ev, RazorAnalyzer::met, and readAndSet().

pat::PATMETSlimmer::OneMETShift::OneMETShift ( pat::MET::METUncertainty  shift_,
pat::MET::METCorrectionType  level_,
const edm::InputTag baseTag,
edm::ConsumesCollector &&  cc,
bool  t0FromMiniAOD_,
bool  corShift_,
bool  uncShift_,
bool  isSmeared_ = false 
)

Definition at line 109 of file PATMETSlimmer.cc.

References pat::MET::ElectronEnDown, pat::MET::ElectronEnUp, edm::InputTag::encode(), Exception, pat::MET::JetEnDown, pat::MET::JetEnUp, pat::MET::JetResDown, pat::MET::JetResUp, pat::MET::MuonEnDown, pat::MET::MuonEnUp, pat::MET::NoShift, pat::MET::PhotonEnDown, pat::MET::PhotonEnUp, shift, AlCaHLTBitMon_QueryRunRegistry::string, pat::MET::TauEnDown, pat::MET::TauEnUp, token, pat::MET::UnclusteredEnDown, and pat::MET::UnclusteredEnUp.

110  :
111  shift(shift_), level(level_), t0FromMiniAOD(t0FromMiniAOD_), corShift(corShift_), uncShift(uncShift_), isSmeared(isSmeared)
112 {
113 
114  std::string baseTagStr = baseTag.encode();
115  char buff[1024];
116  switch (shift) {
117  case pat::MET::NoShift : snprintf(buff, 1023, baseTagStr.c_str(), ""); break;
118  case pat::MET::JetEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "JetEnUp"); break;
119  case pat::MET::JetEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "JetEnDown"); break;
120  case pat::MET::JetResUp : snprintf(buff, 1023, baseTagStr.c_str(), "JetResUp"); break;
121  case pat::MET::JetResDown: snprintf(buff, 1023, baseTagStr.c_str(), "JetResDown"); break;
122  case pat::MET::MuonEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "MuonEnUp"); break;
123  case pat::MET::MuonEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "MuonEnDown"); break;
124  case pat::MET::ElectronEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "ElectronEnUp"); break;
125  case pat::MET::ElectronEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "ElectronEnDown"); break;
126  case pat::MET::PhotonEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "PhotonEnUp"); break;
127  case pat::MET::PhotonEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "PhotonEnDown"); break;
128  case pat::MET::TauEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "TauEnUp"); break;
129  case pat::MET::TauEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "TauEnDown"); break;
130  case pat::MET::UnclusteredEnUp : snprintf(buff, 1023, baseTagStr.c_str(), "UnclusteredEnUp"); break;
131  case pat::MET::UnclusteredEnDown: snprintf(buff, 1023, baseTagStr.c_str(), "UnclusteredEnDown"); break;
132  default: throw cms::Exception("LogicError", "OneMETShift constructor called with bogus shift");
133  }
135 
136 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const pat::MET::METCorrectionType level
std::vector< MET > METCollection
Definition: MET.h:32
std::string encode() const
Definition: InputTag.cc:165
edm::EDGetTokenT< pat::METCollection > token
const pat::MET::METUncertainty shift

Member Function Documentation

void pat::PATMETSlimmer::OneMETShift::readAndSet ( const edm::Event ev,
pat::MET met 
) const

Definition at line 160 of file PATMETSlimmer.cc.

References pat::MET::corPx(), pat::MET::corPy(), corShift, pat::MET::corSumEt(), DEFINE_FWK_MODULE, edm::Event::getByToken(), isSmeared, level, reco::LeafCandidate::px(), reco::LeafCandidate::py(), pat::MET::setCorShift(), pat::MET::setUncShift(), shift, pat::MET::shiftedPx(), pat::MET::shiftedPy(), pat::MET::shiftedSumEt(), TrackRefitter_38T_cff::src, reco::MET::sumEt(), t0FromMiniAOD, token, pat::MET::Type01, and uncShift.

Referenced by OneMETShift().

160  {
162  ev.getByToken(token, src);
163 
164  if (src->size() != 1) throw cms::Exception("CorruptData", "More than one MET in the shifted collection");
165  const pat::MET &met2 = src->front();
166 
167 
168  if(t0FromMiniAOD) {
173  }
174  else {
175  if(uncShift) met.setUncShift(met2.px(), met2.py(), met2.sumEt(), shift, isSmeared);
176  if(corShift) met.setCorShift(met2.px(), met2.py(), met2.sumEt(), level);
177  }
178 
179 }
Analysis-level MET class.
Definition: MET.h:43
double shiftedPx(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:179
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const pat::MET::METCorrectionType level
void setUncShift(double px, double py, double sumEt, METUncertainty shift, bool isSmeared=false)
Definition: MET.cc:346
double corPy(METCorrectionLevel level=Type1) const
Definition: MET.h:189
double corSumEt(METCorrectionLevel level=Type1) const
Definition: MET.cc:328
double shiftedPy(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:180
edm::EDGetTokenT< pat::METCollection > token
double sumEt() const
Definition: MET.h:56
const pat::MET::METUncertainty shift
virtual double px() const final
x coordinate of momentum vector
double shiftedSumEt(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:297
double corPx(METCorrectionLevel level=Type1) const
Definition: MET.h:188
void setCorShift(double px, double py, double sumEt, METCorrectionType level)
Definition: MET.cc:363
virtual double py() const final
y coordinate of momentum vector

Member Data Documentation

const bool pat::PATMETSlimmer::OneMETShift::corShift
private

Definition at line 38 of file PATMETSlimmer.cc.

Referenced by readAndSet().

const bool pat::PATMETSlimmer::OneMETShift::isSmeared
private

Definition at line 40 of file PATMETSlimmer.cc.

Referenced by readAndSet().

const pat::MET::METCorrectionType pat::PATMETSlimmer::OneMETShift::level
private

Definition at line 35 of file PATMETSlimmer.cc.

Referenced by readAndSet().

const pat::MET::METUncertainty pat::PATMETSlimmer::OneMETShift::shift
private

Definition at line 34 of file PATMETSlimmer.cc.

Referenced by OneMETShift(), pat::PATMETSlimmer::produce(), and readAndSet().

const bool pat::PATMETSlimmer::OneMETShift::t0FromMiniAOD
private

Definition at line 37 of file PATMETSlimmer.cc.

Referenced by readAndSet().

edm::EDGetTokenT<pat::METCollection> pat::PATMETSlimmer::OneMETShift::token
private

Definition at line 36 of file PATMETSlimmer.cc.

Referenced by OneMETShift(), and readAndSet().

const bool pat::PATMETSlimmer::OneMETShift::uncShift
private

Definition at line 39 of file PATMETSlimmer.cc.

Referenced by readAndSet().