CMS 3D CMS Logo

MET.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_MET_h
5 #define DataFormats_PatCandidates_MET_h
6 
19 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
20 #include <atomic>
21 #endif
22 
27 #include <cmath>
28 
29 // Define typedefs for convenience
30 namespace pat {
31  class MET;
32  typedef std::vector<MET> METCollection;
35 } // namespace pat
36 
37 // Class definition
38 namespace pat {
39 
40  class MET : public PATObject<reco::MET> {
41  public:
43  MET();
45  MET(const reco::MET& aMET);
47  MET(const edm::RefToBase<reco::MET>& aMETRef);
49  MET(const edm::Ptr<reco::MET>& aMETRef);
51  MET(MET const&);
53  MET(const reco::MET& corMET, const MET& srcMET);
55  ~MET() override;
56 
57  MET& operator=(MET const&);
58 
60  MET* clone() const override { return new MET(*this); }
61 
62  // ---- methods for generated MET link ----
64  const reco::GenMET* genMET() const;
66  void setGenMET(const reco::GenMET& gm);
67 
68  // ----- MET significance functions ----
69  // set the MET Significance
70  void setMETSignificance(const double& metSig);
71  // get the MET significance
72  double metSignificance() const;
73  // set the MET sumPtUnclustered for MET Significance
74  void setMETSumPtUnclustered(const double& sumPtUnclustered);
75  // get the MET sumPtUnclustered
76  double metSumPtUnclustered() const;
77 
78  // ---- methods for uncorrected MET ----
79  // Methods not yet defined
80  //float uncorrectedPt() const;
81  //float uncorrectedPhi() const;
82  //float uncorrectedSumEt() const;
83 
84  // ---- methods to know what the pat::MET was constructed from ----
86  bool isCaloMET() const { return !caloMET_.empty(); }
88  bool isPFMET() const { return !pfMET_.empty(); }
90  bool isRecoMET() const { return (caloMET_.empty() && pfMET_.empty()); }
91 
92  // ---- methods for CaloMET specific stuff ----
94  double maxEtInEmTowers() const { return caloSpecific().MaxEtInEmTowers; }
96  double maxEtInHadTowers() const { return caloSpecific().MaxEtInHadTowers; }
98  double etFractionHadronic() const { return caloSpecific().EtFractionHadronic; }
100  double emEtFraction() const { return caloSpecific().EtFractionEm; }
102  double hadEtInHB() const { return caloSpecific().HadEtInHB; }
104  double hadEtInHO() const { return caloSpecific().HadEtInHO; }
106  double hadEtInHE() const { return caloSpecific().HadEtInHE; }
108  double hadEtInHF() const { return caloSpecific().HadEtInHF; }
110  double emEtInEB() const { return caloSpecific().EmEtInEB; }
112  double emEtInEE() const { return caloSpecific().EmEtInEE; }
114  double emEtInHF() const { return caloSpecific().EmEtInHF; }
116  double caloMetSignificance() const { return caloSpecific().METSignificance; }
118  double CaloSETInpHF() const { return caloSpecific().CaloSETInpHF; }
120  double CaloSETInmHF() const { return caloSpecific().CaloSETInmHF; }
122  double CaloMETInpHF() const { return caloSpecific().CaloMETInpHF; }
124  double CaloMETInmHF() const { return caloSpecific().CaloMETInmHF; }
126  double CaloMETPhiInpHF() const { return caloSpecific().CaloMETPhiInpHF; }
128  double CaloMETPhiInmHF() const { return caloSpecific().CaloMETPhiInmHF; }
131  if (!isCaloMET())
132  throw cms::Exception("pat::MET") << "This pat::MET has not been made from a reco::CaloMET\n";
133  return caloMET_[0];
134  }
135 
136  // ---- methods for PFMET specific stuff ----
137  double NeutralEMFraction() const { return pfSpecific().NeutralEMFraction; }
139  double ChargedEMEtFraction() const { return pfSpecific().ChargedEMFraction; }
141  double MuonEtFraction() const { return pfSpecific().MuonFraction; }
142  double Type6EtFraction() const { return pfSpecific().Type6Fraction; }
143  double Type7EtFraction() const { return pfSpecific().Type7Fraction; }
145  const SpecificPFMETData& pfSpecific() const {
146  if (!isPFMET())
147  throw cms::Exception("pat::MET") << "This pat::MET has not been made from a reco::PFMET\n";
148  return pfMET_[0];
149  }
150 
151  // ---- members for MET corrections ----
153  JetResUp = 0,
155  JetEnUp = 2,
157  MuonEnUp = 4,
161  TauEnUp = 8,
167  NoShift = 14,
172  };
174  Raw = 0,
175  Type1 = 1,
176  Type01 = 2,
177  TypeXY = 3,
178  Type1XY = 4,
179  Type01XY = 5,
184  RawCalo = 10,
185  RawChs = 11,
186  RawTrk = 12,
190  };
192  None = 0,
193  T1 = 1,
194  T0 = 2,
195  TXY = 3,
200  Smear = 8,
201  Calo = 9,
202  Chs = 10,
203  Trk = 11,
207  };
208 
209  struct Vector2 {
210  double px, py;
211  double pt() const { return hypotf(px, py); }
212  double phi() const { return std::atan2(py, px); }
213  };
214 
219  return shiftedP2(shift, level).px;
220  };
222  return shiftedP2(shift, level).py;
223  };
225  return shiftedP2(shift, level).pt();
226  };
228  return shiftedP2(shift, level).phi();
229  };
231 
235  double corPx(METCorrectionLevel level = Type1) const { return corP2(level).px; };
236  double corPy(METCorrectionLevel level = Type1) const { return corP2(level).py; };
237  double corPt(METCorrectionLevel level = Type1) const { return corP2(level).pt(); };
238  double corPhi(METCorrectionLevel level = Type1) const { return corP2(level).phi(); };
239  double corSumEt(METCorrectionLevel level = Type1) const;
240 
241  Vector2 uncorP2() const;
242  Vector uncorP3() const;
243  LorentzVector uncorP4() const;
244  double uncorPx() const { return uncorP2().px; };
245  double uncorPy() const { return uncorP2().py; };
246  double uncorPt() const { return uncorP2().pt(); };
247  double uncorPhi() const { return uncorP2().phi(); };
248  double uncorSumEt() const;
249 
250  void setUncShift(double px, double py, double sumEt, METUncertainty shift, bool isSmeared = false);
251  void setCorShift(double px, double py, double sumEt, METCorrectionType level);
252 
253  // specific method to fill and retrieve the caloMET quickly from miniAODs,
254  //should be used by JetMET experts only for the beginning
255  //of the runII, will be discarded later once we are sure
256  //everything is fine
257  Vector2 caloMETP2() const;
258  double caloMETPt() const;
259  double caloMETPhi() const;
260  double caloMETSumEt() const;
261 
262  //Functions for backward compatibility with 74X samples.
263  // allow access to 74X samples, transparent and not used in 75
267  double shiftedSumEt_74x(METUncertainty shift, METCorrectionLevel level) const;
268 
271  // defined as C++ class so that I can change the packing without having to touch the code elsewhere
272  // the compiler should anyway inline everything whenever possible
273  public:
274  PackedMETUncertainty() : dpx_(0), dpy_(0), dsumEt_(0) {
275  pack();
276  unpack();
277  }
278  PackedMETUncertainty(float dpx, float dpy, float dsumEt) : dpx_(dpx), dpy_(dpy), dsumEt_(dsumEt) {
279  pack();
280  unpack();
281  }
282  double dpx() const {
283  if (!unpacked_)
284  unpack();
285  return dpx_;
286  }
287  double dpy() const {
288  if (!unpacked_)
289  unpack();
290  return dpy_;
291  }
292  double dsumEt() const {
293  if (!unpacked_)
294  unpack();
295  return dsumEt_;
296  }
297  void set(float dpx, float dpy, float dsumEt) {
298  dpx_ = dpx;
299  dpy_ = dpy;
300  dsumEt_ = dsumEt;
301  pack();
302  unpack();
303  }
304  void add(float dpx, float dpy, float dsumEt) {
305  dpx_ += dpx;
306  dpy_ += dpy;
307  dsumEt_ += dsumEt;
308  }
309  void unpack() const;
310  void pack();
311 
312  protected:
313  mutable float dpx_, dpy_, dsumEt_;
314  mutable bool unpacked_;
315  uint16_t packedDpx_, packedDpy_, packedDSumEt_;
316  };
317 
318  private:
319  // ---- GenMET holder ----
320  std::vector<reco::GenMET> genMET_;
321  // ---- holder for CaloMET specific info ---
322  std::vector<SpecificCaloMETData> caloMET_;
323  // ---- holder for pfMET specific info ---
324  std::vector<SpecificPFMETData> pfMET_;
325 
326  // MET significance
327  double metSig_;
328  // MET sumPtUnclustered for MET Significance
330 
332 
333  std::map<MET::METCorrectionLevel, std::vector<MET::METCorrectionType> > corMap_;
334  void initCorMap();
335 
336  protected:
337  // ---- non-public correction utilities ----
338  //kept for 74X backward-compatibility, not initialized and used in 75X
339  std::vector<PackedMETUncertainty> uncertaintiesRaw_, uncertaintiesType1_, uncertaintiesType1p2_;
340 
341  std::vector<PackedMETUncertainty> uncertainties_;
342  std::vector<PackedMETUncertainty> corrections_;
343 
345  };
346 
347 } // namespace pat
348 
349 #endif
double px
Definition: MET.h:210
Analysis-level MET class.
Definition: MET.h:40
std::vector< double > dsumEt() const
Definition: MET.cc:126
def pack(high, low)
std::vector< PackedMETUncertainty > uncertaintiesRaw_
Definition: MET.h:339
double CaloMETInmHF() const
Returns the event MET in HF-.
Definition: MET.h:124
double shiftedPx(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:218
Vector2 shiftedP2_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:371
const PackedMETUncertainty findMETTotalShift(MET::METCorrectionLevel cor, MET::METUncertainty shift) const
Definition: MET.cc:208
double emEtInHF() const
Returns the event electromagnetic energy extracted from HF.
Definition: MET.h:114
MET()
default constructor
Definition: MET.cc:9
double dpy() const
Definition: MET.h:287
double ChargedHadEtFraction() const
Definition: MET.h:140
math::XYZVector Vector
point in the space
Definition: Candidate.h:43
double metSig_
Definition: MET.h:327
double uncorPy() const
Definition: MET.h:245
Vector2 caloMETP2() const
Definition: MET.cc:360
std::vector< PackedMETUncertainty > uncertaintiesType1p2_
Definition: MET.h:339
double MuonEtFraction() const
Definition: MET.h:141
Vector2 corP2(METCorrectionLevel level=Type1) const
Definition: MET.cc:326
std::vector< MET > METCollection
Definition: MET.h:31
std::vector< PackedMETUncertainty > uncertainties_
Definition: MET.h:341
double NeutralEMFraction() const
Definition: MET.h:137
LorentzVector shiftedP4(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:283
void setUncShift(double px, double py, double sumEt, METUncertainty shift, bool isSmeared=false)
Definition: MET.cc:336
double etFractionHadronic() const
Returns the event hadronic energy fraction.
Definition: MET.h:98
double dsumEt() const
Definition: MET.h:292
~MET() override
destructor
Definition: MET.cc:95
double ChargedEMEtFraction() const
Definition: MET.h:139
double Type6EtFraction() const
Definition: MET.h:142
double metSignificance() const
Definition: MET.cc:126
double uncorPt() const
Definition: MET.h:246
double Type7EtFraction() const
Definition: MET.h:143
double CaloMETPhiInpHF() const
Returns the event MET-phi in HF+.
Definition: MET.h:126
METUncertainty
Definition: MET.h:152
double CaloMETPhiInmHF() const
Returns the event MET-phi in HF-.
Definition: MET.h:128
double corPy(METCorrectionLevel level=Type1) const
Definition: MET.h:236
Vector2 uncorP2() const
Definition: MET.cc:331
Vector corP3(METCorrectionLevel level=Type1) const
Definition: MET.cc:327
double maxEtInHadTowers() const
Returns the maximum energy deposited in HCAL towers.
Definition: MET.h:96
double NeutralHadEtFraction() const
Definition: MET.h:138
double CaloSETInpHF() const
Returns the event SET in HF+.
Definition: MET.h:118
bool isPFMET() const
True if this pat::MET was made from a reco::pfMET.
Definition: MET.h:88
double emEtInEE() const
Returns the event electromagnetic energy in EE.
Definition: MET.h:112
double corPt(METCorrectionLevel level=Type1) const
Definition: MET.h:237
double caloMETSumEt() const
Definition: MET.cc:368
Definition: HeavyIon.h:7
double corSumEt(METCorrectionLevel level=Type1) const
Definition: MET.cc:329
double hadEtInHE() const
Returns the event hadronic energy in HE.
Definition: MET.h:106
void add(float dpx, float dpy, float dsumEt)
Definition: MET.h:304
double shiftedPy(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:221
double corPhi(METCorrectionLevel level=Type1) const
Definition: MET.h:238
double uncorPx() const
Definition: MET.h:244
double sumEt() const
Definition: MET.h:56
double shiftedPhi(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:227
double emEtInEB() const
Returns the event electromagnetic energy in EB.
Definition: MET.h:110
PackedMETUncertainty(float dpx, float dpy, float dsumEt)
Definition: MET.h:278
bool isRecoMET() const
True if this pat::MET was NOT made from a reco::CaloMET nor a reco::pfMET.
Definition: MET.h:90
Definition: MET.h:42
PackedMETUncertainty caloPackedMet_
Definition: MET.h:344
LorentzVector corP4(METCorrectionLevel level=Type1) const
Definition: MET.cc:328
double dpx() const
Definition: MET.h:282
Vector2 shiftedP2(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:241
double caloMETPhi() const
Definition: MET.cc:366
double shiftedSumEt(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:306
double phi() const
Definition: MET.h:212
double CaloSETInmHF() const
Returns the event SET in HF-.
Definition: MET.h:120
std::vector< reco::GenMET > genMET_
Definition: MET.h:320
LorentzVector shiftedP4_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:404
MET made from Particle Flow Candidates.
double corPx(METCorrectionLevel level=Type1) const
Definition: MET.h:235
const SpecificPFMETData & pfSpecific() const
accessor for the pfMET-specific structure
Definition: MET.h:145
MET * clone() const override
required reimplementation of the Candidate&#39;s clone method
Definition: MET.h:60
void initCorMap()
Definition: MET.cc:132
double shiftedPt(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:224
double py
Definition: MET.h:210
double shiftedSumEt_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:422
double uncorSumEt() const
Definition: MET.cc:334
double pt() const
Definition: MET.h:211
MET & operator=(MET const &)
Definition: MET.cc:97
double hadEtInHB() const
Returns the event hadronic energy in HB.
Definition: MET.h:102
void setMETSumPtUnclustered(const double &sumPtUnclustered)
Definition: MET.cc:128
std::map< MET::METCorrectionLevel, std::vector< MET::METCorrectionType > > corMap_
Definition: MET.h:333
const reco::GenMET * genMET() const
return the associated GenMET
Definition: MET.cc:115
double hadEtInHO() const
Returns the event hadronic energy in HO.
Definition: MET.h:104
double CaloMETInpHF() const
Returns the event MET in HF+.
Definition: MET.h:122
bool isCaloMET() const
True if this pat::MET was made from a reco::CaloMET.
Definition: MET.h:86
std::vector< SpecificCaloMETData > caloMET_
Definition: MET.h:322
edm::Ref< METCollection > METRef
Definition: MET.h:33
this below should be private but Reflex doesn&#39;t like it
Definition: MET.h:270
double caloMetSignificance() const
Returns the event MET Significance.
Definition: MET.h:116
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
double hadEtInHF() const
Returns the event hadronic energy in HF.
Definition: MET.h:108
double maxEtInEmTowers() const
Returns the maximum energy deposited in ECAL towers.
Definition: MET.h:94
double uncorPhi() const
Definition: MET.h:247
METCorrectionLevel
Definition: MET.h:173
std::vector< PackedMETUncertainty > uncertaintiesType1_
Definition: MET.h:339
METCorrectionType
Definition: MET.h:191
std::vector< PackedMETUncertainty > corrections_
Definition: MET.h:342
static unsigned int const shift
LorentzVector uncorP4() const
Definition: MET.cc:333
edm::RefVector< METCollection > METRefVector
Definition: MET.h:34
Templated PAT object container.
Definition: PATObject.h:49
void setCorShift(double px, double py, double sumEt, METCorrectionType level)
Definition: MET.cc:352
sumPtUnclustered
Definition: met_cff.py:20
void setGenMET(const reco::GenMET &gm)
set the associated GenMET
Definition: MET.cc:118
std::vector< SpecificPFMETData > pfMET_
Definition: MET.h:324
double emEtFraction() const
Returns the event electromagnetic energy fraction.
Definition: MET.h:100
double metSumPtUnclustered() const
Definition: MET.cc:130
double sumPtUnclustered_
Definition: MET.h:329
double caloMETPt() const
Definition: MET.cc:364
Vector uncorP3() const
Definition: MET.cc:332
void setMETSignificance(const double &metSig)
Definition: MET.cc:124
Vector shiftedP3_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:388
const SpecificCaloMETData & caloSpecific() const
accessor for the CaloMET-specific structure
Definition: MET.h:130
Vector shiftedP3(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:262