CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
7 
20 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
21 #include <atomic>
22 #endif
23 
28 #include <cmath>
29 
30 // Define typedefs for convenience
31 namespace pat {
32  class MET;
33  typedef std::vector<MET> METCollection;
36 }
37 
38 
39 // Class definition
40 namespace pat {
41 
42 
43  class MET : public PATObject<reco::MET> {
44 
45  public:
46 
48  MET();
50  MET(const reco::MET & aMET);
52  MET(const edm::RefToBase<reco::MET> & aMETRef);
54  MET(const edm::Ptr<reco::MET> & aMETRef);
56  MET( MET const&);
58  MET(const reco::MET & corMET, const MET& srcMET );
60  virtual ~MET();
61 
62  MET& operator=(MET const&);
63 
65  virtual MET * clone() const { return new MET(*this); }
66 
67  // ---- methods for generated MET link ----
69  const reco::GenMET * genMET() const;
71  void setGenMET(const reco::GenMET & gm);
72 
73  // ----- MET significance functions ----
74  // set the MET Significance
75  void setMETSignificance(const double& metSig);
76  // get the MET significance
77  double metSignificance() const;
78 
79 
80  // ---- methods for uncorrected MET ----
81  // Methods not yet defined
82  //float uncorrectedPt() const;
83  //float uncorrectedPhi() const;
84  //float uncorrectedSumEt() const;
85 
86  // ---- methods to know what the pat::MET was constructed from ----
88  bool isCaloMET() const { return !caloMET_.empty(); }
90  bool isPFMET() const { return !pfMET_.empty(); }
92  bool isRecoMET() const { return ( caloMET_.empty() && pfMET_.empty() ); }
93 
94  // ---- methods for CaloMET specific stuff ----
96  double maxEtInEmTowers() const {return caloSpecific().MaxEtInEmTowers;}
98  double maxEtInHadTowers() const {return caloSpecific().MaxEtInHadTowers;}
102  double emEtFraction() const {return caloSpecific().EtFractionEm;}
104  double hadEtInHB() const {return caloSpecific().HadEtInHB;}
106  double hadEtInHO() const {return caloSpecific().HadEtInHO;}
108  double hadEtInHE() const {return caloSpecific().HadEtInHE;}
110  double hadEtInHF() const {return caloSpecific().HadEtInHF;}
112  double emEtInEB() const {return caloSpecific().EmEtInEB;}
114  double emEtInEE() const {return caloSpecific().EmEtInEE;}
116  double emEtInHF() const {return caloSpecific().EmEtInHF;}
120  double CaloSETInpHF() const {return caloSpecific().CaloSETInpHF;}
122  double CaloSETInmHF() const {return caloSpecific().CaloSETInmHF;}
124  double CaloMETInpHF() const {return caloSpecific().CaloMETInpHF;}
126  double CaloMETInmHF() const {return caloSpecific().CaloMETInmHF;}
128  double CaloMETPhiInpHF() const {return caloSpecific().CaloMETPhiInpHF;}
130  double CaloMETPhiInmHF() const {return caloSpecific().CaloMETPhiInmHF;}
133  if (!isCaloMET()) throw cms::Exception("pat::MET") << "This pat::MET has not been made from a reco::CaloMET\n";
134  return caloMET_[0];
135  }
136 
137  // ---- methods for PFMET specific stuff ----
138  double NeutralEMFraction() const { return pfSpecific().NeutralEMFraction; }
140  double ChargedEMEtFraction() const { return pfSpecific().ChargedEMFraction; }
142  double MuonEtFraction() const { return pfSpecific().MuonFraction; }
143  double Type6EtFraction() const { return pfSpecific().Type6Fraction; }
144  double Type7EtFraction() const { return pfSpecific().Type7Fraction; }
146  const SpecificPFMETData & pfSpecific() const {
147  if (!isPFMET()) 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 ----
158  };
160  Raw=0, Type1=1, Type01=2, TypeXY=3, Type1XY=4, Type01XY=5,
163  };
165  None=0, T1=1, T0=2, TXY=3, TXYForRaw=4,
168  };
169 
170  struct Vector2 {
171  double px, py;
172  double pt() const { return hypotf(px,py); }
173  double phi() const { return std::atan2(py,px); }
174  };
175 
184 
185  Vector2 corP2(METCorrectionLevel level=Type1) const ;
188  double corPx(METCorrectionLevel level=Type1) const { return corP2(level).px; };
189  double corPy(METCorrectionLevel level=Type1) const { return corP2(level).py; };
190  double corPt(METCorrectionLevel level=Type1) const { return corP2(level).pt(); };
191  double corPhi(METCorrectionLevel level=Type1) const { return corP2(level).phi(); };
192  double corSumEt(METCorrectionLevel level=Type1) const ;
193 
194  Vector2 uncorP2() const;
195  Vector uncorP3() const ;
196  LorentzVector uncorP4() const ;
197  double uncorPx() const { return uncorP2().px; };
198  double uncorPy() const { return uncorP2().py; };
199  double uncorPt() const { return uncorP2().pt(); };
200  double uncorPhi() const { return uncorP2().phi(); };
201  double uncorSumEt() const;
202 
203  void setUncShift(double px, double py, double sumEt, METUncertainty shift, bool isSmeared=false);
204  void setCorShift(double px, double py, double sumEt, METCorrectionType level);
205 
206  // specific method to fill and retrieve the caloMET quickly from miniAODs,
207  //should be used by JetMET experts only for the beginning
208  //of the runII, will be discarded later once we are sure
209  //everything is fine
210  Vector2 caloMETP2() const;
211  double caloMETPt() const;
212  double caloMETPhi() const;
213  double caloMETSumEt() const;
214 
215  //Functions for backward compatibility with 74X samples.
216  // allow access to 74X samples, transparent and not used in 75
221 
222 
225  // defined as C++ class so that I can change the packing without having to touch the code elsewhere
226  // the compiler should anyway inline everything whenever possible
227  public:
229  PackedMETUncertainty(float dpx, float dpy, float dsumEt) : dpx_(dpx), dpy_(dpy), dsumEt_(dsumEt) {pack();unpack();}
230  double dpx() const { if(!unpacked_) unpack(); return dpx_; }
231  double dpy() const { if(!unpacked_) unpack(); return dpy_; }
232  double dsumEt() const { if(!unpacked_) unpack(); return dsumEt_; }
233  void set(float dpx, float dpy, float dsumEt) { dpx_ = dpx; dpy_ = dpy; dsumEt_ = dsumEt; pack(); unpack();}
234  void add(float dpx, float dpy, float dsumEt) { dpx_ += dpx; dpy_ += dpy; dsumEt_ += dsumEt; }
235  void unpack() const ;
236  void pack();
237 
238  protected:
239  mutable float dpx_, dpy_, dsumEt_;
240  mutable bool unpacked_;
242  };
243  private:
244 
245  // ---- GenMET holder ----
246  std::vector<reco::GenMET> genMET_;
247  // ---- holder for CaloMET specific info ---
248  std::vector<SpecificCaloMETData> caloMET_;
249  // ---- holder for pfMET specific info ---
250  std::vector<SpecificPFMETData> pfMET_;
251 
252  // MET significance
253  double metSig_;
254 
256 
257  std::map<MET::METCorrectionLevel, std::vector<MET::METCorrectionType> > corMap_;
258  void initCorMap();
259 
260 
261 
262  protected:
263 
264  // ---- non-public correction utilities ----
265  //kept for 74X backward-compatibility, not initialized and used in 75X
266  std::vector<PackedMETUncertainty> uncertaintiesRaw_, uncertaintiesType1_, uncertaintiesType1p2_;
267 
268  std::vector<PackedMETUncertainty> uncertainties_;
269  std::vector<PackedMETUncertainty> corrections_;
270 
272 
273  };
274 
275 
276 }
277 
278 #endif
double px
Definition: MET.h:171
Analysis-level MET class.
Definition: MET.h:43
std::vector< PackedMETUncertainty > uncertaintiesRaw_
Definition: MET.h:266
double CaloMETInmHF() const
Returns the event MET in HF-.
Definition: MET.h:126
double shiftedPx(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:179
Vector2 shiftedP2_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:386
virtual MET * clone() const
required reimplementation of the Candidate&#39;s clone method
Definition: MET.h:65
const PackedMETUncertainty findMETTotalShift(MET::METCorrectionLevel cor, MET::METUncertainty shift) const
Definition: MET.cc:187
double emEtInHF() const
Returns the event electromagnetic energy extracted from HF.
Definition: MET.h:116
MET()
default constructor
Definition: MET.cc:11
double dpy() const
Definition: MET.h:231
double ChargedHadEtFraction() const
Definition: MET.h:141
double metSig_
Definition: MET.h:253
double uncorPy() const
Definition: MET.h:198
Vector2 caloMETP2() const
Definition: MET.cc:369
std::vector< PackedMETUncertainty > uncertaintiesType1p2_
Definition: MET.h:266
double MuonEtFraction() const
Definition: MET.h:142
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Vector2 corP2(METCorrectionLevel level=Type1) const
Definition: MET.cc:316
std::vector< MET > METCollection
Definition: MET.h:32
std::vector< PackedMETUncertainty > uncertainties_
Definition: MET.h:268
math::XYZTLorentzVector LorentzVector
double NeutralEMFraction() const
Definition: MET.h:138
LorentzVector shiftedP4(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:269
void setUncShift(double px, double py, double sumEt, METUncertainty shift, bool isSmeared=false)
Definition: MET.cc:343
double etFractionHadronic() const
Returns the event hadronic energy fraction.
Definition: MET.h:100
double dsumEt() const
Definition: MET.h:232
double ChargedEMEtFraction() const
Definition: MET.h:140
double Type6EtFraction() const
Definition: MET.h:143
double metSignificance() const
Definition: MET.cc:125
double uncorPt() const
Definition: MET.h:199
double Type7EtFraction() const
Definition: MET.h:144
double CaloMETPhiInpHF() const
Returns the event MET-phi in HF+.
Definition: MET.h:128
METUncertainty
Definition: MET.h:152
double CaloMETPhiInmHF() const
Returns the event MET-phi in HF-.
Definition: MET.h:130
double corPy(METCorrectionLevel level=Type1) const
Definition: MET.h:189
Vector2 uncorP2() const
Definition: MET.cc:329
Vector corP3(METCorrectionLevel level=Type1) const
Definition: MET.cc:319
double maxEtInHadTowers() const
Returns the maximum energy deposited in HCAL towers.
Definition: MET.h:98
double NeutralHadEtFraction() const
Definition: MET.h:139
double CaloSETInpHF() const
Returns the event SET in HF+.
Definition: MET.h:120
bool isPFMET() const
True if this pat::MET was made from a reco::pfMET.
Definition: MET.h:90
double emEtInEE() const
Returns the event electromagnetic energy in EE.
Definition: MET.h:114
double corPt(METCorrectionLevel level=Type1) const
Definition: MET.h:190
double caloMETSumEt() const
Definition: MET.cc:381
double corSumEt(METCorrectionLevel level=Type1) const
Definition: MET.cc:325
double hadEtInHE() const
Returns the event hadronic energy in HE.
Definition: MET.h:108
void add(float dpx, float dpy, float dsumEt)
Definition: MET.h:234
double shiftedPy(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:180
double corPhi(METCorrectionLevel level=Type1) const
Definition: MET.h:191
double uncorPx() const
Definition: MET.h:197
double sumEt() const
Definition: MET.h:56
double shiftedPhi(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:182
double emEtInEB() const
Returns the event electromagnetic energy in EB.
Definition: MET.h:112
PackedMETUncertainty(float dpx, float dpy, float dsumEt)
Definition: MET.h:229
bool isRecoMET() const
True if this pat::MET was NOT made from a reco::CaloMET nor a reco::pfMET.
Definition: MET.h:92
Definition: MET.h:42
PackedMETUncertainty caloPackedMet_
Definition: MET.h:271
LorentzVector corP4(METCorrectionLevel level=Type1) const
Definition: MET.cc:322
double dpx() const
Definition: MET.h:230
Vector2 shiftedP2(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:223
double caloMETPhi() const
Definition: MET.cc:377
double shiftedSumEt(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:294
double phi() const
Definition: MET.h:173
double CaloSETInmHF() const
Returns the event SET in HF-.
Definition: MET.h:122
std::vector< reco::GenMET > genMET_
Definition: MET.h:246
LorentzVector shiftedP4_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:409
MET made from Particle Flow Candidates.
double corPx(METCorrectionLevel level=Type1) const
Definition: MET.h:188
const SpecificPFMETData & pfSpecific() const
accessor for the pfMET-specific structure
Definition: MET.h:146
void initCorMap()
Definition: MET.cc:131
double shiftedPt(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.h:181
double py
Definition: MET.h:171
double shiftedSumEt_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:422
double uncorSumEt() const
Definition: MET.cc:338
double pt() const
Definition: MET.h:172
MET & operator=(MET const &)
Definition: MET.cc:92
double hadEtInHB() const
Returns the event hadronic energy in HB.
Definition: MET.h:104
std::map< MET::METCorrectionLevel, std::vector< MET::METCorrectionType > > corMap_
Definition: MET.h:257
const reco::GenMET * genMET() const
return the associated GenMET
Definition: MET.cc:109
double hadEtInHO() const
Returns the event hadronic energy in HO.
Definition: MET.h:106
virtual double px() const
x coordinate of momentum vector
double CaloMETInpHF() const
Returns the event MET in HF+.
Definition: MET.h:124
bool isCaloMET() const
True if this pat::MET was made from a reco::CaloMET.
Definition: MET.h:88
std::vector< SpecificCaloMETData > caloMET_
Definition: MET.h:248
edm::Ref< METCollection > METRef
Definition: MET.h:34
this below should be private but Reflex doesn&#39;t like it
Definition: MET.h:224
double caloMetSignificance() const
Returns the event MET Significance.
Definition: MET.h:118
double hadEtInHF() const
Returns the event hadronic energy in HF.
Definition: MET.h:110
double maxEtInEmTowers() const
Returns the maximum energy deposited in ECAL towers.
Definition: MET.h:96
double uncorPhi() const
Definition: MET.h:200
METCorrectionLevel
Definition: MET.h:159
std::vector< PackedMETUncertainty > uncertaintiesType1_
Definition: MET.h:266
METCorrectionType
Definition: MET.h:164
std::vector< PackedMETUncertainty > corrections_
Definition: MET.h:269
static unsigned int const shift
LorentzVector uncorP4() const
Definition: MET.cc:335
edm::RefVector< METCollection > METRefVector
Definition: MET.h:35
Templated PAT object container.
Definition: PATObject.h:49
void setCorShift(double px, double py, double sumEt, METCorrectionType level)
Definition: MET.cc:360
tuple level
Definition: testEve_cfg.py:34
void setGenMET(const reco::GenMET &gm)
set the associated GenMET
Definition: MET.cc:114
std::vector< SpecificPFMETData > pfMET_
Definition: MET.h:250
virtual ~MET()
destructor
Definition: MET.cc:88
double emEtFraction() const
Returns the event electromagnetic energy fraction.
Definition: MET.h:102
double caloMETPt() const
Definition: MET.cc:373
Vector uncorP3() const
Definition: MET.cc:332
virtual double py() const
y coordinate of momentum vector
void unpack() const
Definition: MET.cc:443
void setMETSignificance(const double &metSig)
Definition: MET.cc:121
Vector shiftedP3_74x(METUncertainty shift, METCorrectionLevel level) const
Definition: MET.cc:398
void set(float dpx, float dpy, float dsumEt)
Definition: MET.h:233
const SpecificCaloMETData & caloSpecific() const
accessor for the CaloMET-specific structure
Definition: MET.h:132
Vector shiftedP3(METUncertainty shift, METCorrectionLevel level=Type1) const
Definition: MET.cc:246