CMS 3D CMS Logo

GenSpecificAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METAlgorithms
4 // Class: GenSpecificAlgo
5 //
6 // Original Authors: R. Cavanaugh (taken from F.Ratnikov, UMd)
7 // Created: June 6, 2006
8 //
9 //
10 //____________________________________________________________________________||
12 #include "TMath.h"
13 
14 #include <set>
15 
16 //____________________________________________________________________________||
19  double globalThreshold,
20  bool onlyFiducial,
22  bool usePt) {
24 
27 
28  const LorentzVector p4(met->mex, met->mey, met->mez, met->met);
29  const Point vtx(0.0, 0.0, 0.0);
30 
31  reco::GenMET genMet(specific, met->sumet, p4, vtx);
32  return genMet;
33 }
34 
35 //____________________________________________________________________________||
38  double globalThreshold,
39  bool onlyFiducial,
40  bool usePt) {
41  double sum_et = 0.0;
42  double sum_ex = 0.0;
43  double sum_ey = 0.0;
44  double sum_ez = 0.0;
45 
46  for (edm::View<reco::Candidate>::const_iterator iParticle = (particles.product())->begin();
47  iParticle != (particles.product())->end();
48  ++iParticle) {
49  if ((onlyFiducial && TMath::Abs(iParticle->eta()) >= 5.0))
50  continue;
51 
52  if (iParticle->et() <= globalThreshold)
53  continue;
54 
55  if (usePt) {
56  double phi = iParticle->phi();
57  double et = iParticle->pt();
58  sum_ez += iParticle->pz();
59  sum_et += et;
60  sum_ex += et * cos(phi);
61  sum_ey += et * sin(phi);
62  } else {
63  double phi = iParticle->phi();
64  double theta = iParticle->theta();
65  double e = iParticle->energy();
66  double et = e * sin(theta);
67  sum_ez += e * cos(theta);
68  sum_et += et;
69  sum_ex += et * cos(phi);
70  sum_ey += et * sin(phi);
71  }
72  }
73 
74  met->mex = -sum_ex;
75  met->mey = -sum_ey;
76  met->mez = -sum_ez;
77  met->met = sqrt(sum_ex * sum_ex + sum_ey * sum_ey);
78  met->sumet = sum_et;
79 }
80 
81 //____________________________________________________________________________||
83  double globalThreshold,
84  bool onlyFiducial,
86  bool usePt) {
87  const static int neutralEMpdgId[] = {22 /* photon */};
88  const static std::set<int> neutralEMpdgIdSet(neutralEMpdgId, neutralEMpdgId + sizeof(neutralEMpdgId) / sizeof(int));
89 
90  const static int chargedEMpdgId[] = {11 /* e */};
91  const static std::set<int> chargedEMpdgIdSet(chargedEMpdgId, chargedEMpdgId + sizeof(chargedEMpdgId) / sizeof(int));
92 
93  const static int muonpdgId[] = {13 /* muon */};
94  const static std::set<int> muonpdgIdSet(muonpdgId, muonpdgId + sizeof(muonpdgId) / sizeof(int));
95 
96  const static int neutralHADpdgId[] = {
97  130 /* K_long */,
98  310 /* K_short */,
99  3122 /* Lambda */,
100  2112 /* n */,
101  3222 /* Neutral Cascade */
102  };
103  const static std::set<int> neutralHADpdgIdSet(neutralHADpdgId,
104  neutralHADpdgId + sizeof(neutralHADpdgId) / sizeof(int));
105 
106  const static int chargedHADpdgId[] = {
107  211 /* pi */,
108  321 /* K+/K- */,
109  2212 /* p */,
110  3312 /* Cascade - */,
111  3112 /* Sigma - */,
112  3322 /* Sigma + */,
113  3334 /* Omega - */
114  };
115  const static std::set<int> chargedHADpdgIdSet(chargedHADpdgId,
116  chargedHADpdgId + sizeof(chargedHADpdgId) / sizeof(int));
117 
118  const static int invisiblepdgId[] = {
119  12 /* e_nu */, 14 /* mu_nu */, 16 /* tau_nu */,
120  1000022 /* Neutral ~Chi_0 */, 1000012 /* LH ~e_nu */, 1000014 /* LH ~mu_nu */,
121  1000016 /* LH ~tau_nu */, 2000012 /* RH ~e_nu */, 2000014 /* RH ~mu_nu */,
122  2000016 /* RH ~tau_nu */, 39 /* G */, 1000039 /* ~G */,
123  5100039 /* KK G */, 4000012 /* excited e_nu */, 4000014 /* excited mu_nu */,
124  4000016 /* excited tau_nu */, 9900012 /* Maj e_nu */, 9900014 /* Maj mu_nu */,
125  9900016 /* Maj tau_nu */,
126  };
127  const static std::set<int> invisiblepdgIdSet(invisiblepdgId, invisiblepdgId + sizeof(invisiblepdgId) / sizeof(int));
128 
130  double Et_unclassified = 0.0;
131 
132  for (edm::View<reco::Candidate>::const_iterator iParticle = (particles.product())->begin();
133  iParticle != (particles.product())->end();
134  ++iParticle) {
136  if (onlyFiducial && (TMath::Abs(iParticle->eta()) >= 5.0))
137  continue;
139  if (iParticle->et() <= globalThreshold)
140  continue;
141 
142  int pdgId = TMath::Abs(iParticle->pdgId());
143  double pt = (usePt) ? iParticle->pt() : iParticle->et();
144  if (neutralEMpdgIdSet.count(pdgId))
145  specific.NeutralEMEtFraction += pt;
146  else if (chargedEMpdgIdSet.count(pdgId))
147  specific.ChargedEMEtFraction += pt;
148  else if (muonpdgIdSet.count(pdgId))
149  specific.MuonEtFraction += pt;
150  else if (neutralHADpdgIdSet.count(pdgId))
151  specific.NeutralHadEtFraction += pt;
152  else if (chargedHADpdgIdSet.count(pdgId))
153  specific.ChargedHadEtFraction += pt;
154  else if (invisiblepdgIdSet.count(pdgId))
155  specific.InvisibleEtFraction += pt;
156  else
157  Et_unclassified += pt;
158  }
159 
160  double Et_Total = specific.NeutralEMEtFraction + specific.NeutralHadEtFraction + specific.ChargedEMEtFraction +
161  specific.ChargedHadEtFraction + specific.MuonEtFraction + specific.InvisibleEtFraction +
162  Et_unclassified;
163 
164  if (Et_Total) {
165  specific.NeutralEMEtFraction /= Et_Total;
166  specific.NeutralHadEtFraction /= Et_Total;
167  specific.ChargedEMEtFraction /= Et_Total;
168  specific.ChargedHadEtFraction /= Et_Total;
169  specific.MuonEtFraction /= Et_Total;
170  specific.InvisibleEtFraction /= Et_Total;
171  }
172 
173  return specific;
174 }
175 
176 //____________________________________________________________________________||
reco::GenMET addInfo(edm::Handle< edm::View< reco::Candidate > > particles, CommonMETData *met, double globalThreshold=0, bool onlyFiducial=false, bool applyFiducialThresholdForFractions=false, bool usePt=false)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:23
void fillCommonMETData(CommonMETData *met, edm::Handle< edm::View< reco::Candidate > > &particles, double globalThreshold, bool onlyFiducial, bool usePt)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
applyFiducialThresholdForFractions
using Pt instead Et
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
SpecificGenMETData mkSpecificGenMETData(edm::Handle< edm::View< reco::Candidate > > &particles, double globalThreshold, bool onlyFiducial, bool applyFiducialThresholdForFractions, bool usePt)
Structure Point Contains parameters of Gaussian fits to DMRs.
math::XYZTLorentzVector LorentzVector
Geom::Theta< T > theta() const
if(threadIdxLocalY==0 &&threadIdxLocalX==0)