CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CaloSpecificAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METAlgorithms
4 // Class: CaloSpecificAlgo
5 //
6 // Original Author: R. Cavanaugh (taken from F.Ratnikov, UMd)
7 // Created: June 6, 2006
8 //
9 //
14 
15 #include <iostream>
16 
17 using namespace reco;
18 
19 //____________________________________________________________________________||
20 // This algorithm adds calorimeter specific global event information to
21 // the MET object which may be useful/needed for MET Data Quality Monitoring
22 // and MET cleaning.
23 //____________________________________________________________________________||
24 
25 //____________________________________________________________________________||
27  const CommonMETData &umet,
28  bool noHF,
29  double globalThreshold) {
31  CommonMETData met = umet;
32  double totalEt = 0.0;
33  double totalEm = 0.0;
34 
35  double sumEtInpHF = 0.0;
36  double sumEtInmHF = 0.0;
37  double MExInpHF = 0.0;
38  double MEyInpHF = 0.0;
39  double MExInmHF = 0.0;
40  double MEyInmHF = 0.0;
41 
42  for (edm::View<Candidate>::const_iterator towerCand = towers->begin(); towerCand != towers->end(); ++towerCand) {
43  const CaloTower *calotower = dynamic_cast<const CaloTower *>(&(*towerCand));
44  if (!calotower)
45  continue;
46  if (calotower->et() < globalThreshold)
47  continue;
48  update_totalEt_totalEm(totalEt, totalEm, calotower, noHF);
49  update_MaxTowerEm_MaxTowerHad(specific.MaxEtInEmTowers, specific.MaxEtInHadTowers, calotower, noHF);
50  update_EmEtInEB_EmEtInEE(specific.EmEtInEB, specific.EmEtInEE, calotower);
51  update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(specific.HadEtInHB,
52  specific.HadEtInHE,
53  specific.HadEtInHO,
54  specific.HadEtInHF,
55  specific.EmEtInHF,
56  calotower,
57  noHF);
58  update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(
59  sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF, calotower);
60  }
61 
62  double totalHad = totalEt - totalEm;
63 
64  if (noHF)
65  remove_HF_from_MET(met, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
66 
67  if (!noHF)
68  add_MET_in_HF(specific, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
69 
70  specific.EtFractionHadronic = (totalEt == 0.0) ? 0.0 : totalHad / totalEt;
71  specific.EtFractionEm = (totalEt == 0.0) ? 0.0 : totalEm / totalEt;
72 
73  const LorentzVector p4(met.mex, met.mey, 0.0, met.met);
74  const Point vtx(0.0, 0.0, 0.0);
75  CaloMET caloMET(specific, met.sumet, p4, vtx);
76  return caloMET;
77 }
78 
79 //____________________________________________________________________________||
80 void CaloSpecificAlgo::update_totalEt_totalEm(double &totalEt, double &totalEm, const CaloTower *calotower, bool noHF) {
81  if (noHF) {
82  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
83  if (!detIdHcal.null()) {
84  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
85  if (subdet == HcalForward)
86  return;
87  }
88  }
89 
90  totalEt += calotower->et();
91  totalEm += calotower->emEt();
92 }
93 
94 //____________________________________________________________________________||
96  float &MaxTowerHad,
97  const CaloTower *calotower,
98  bool noHF) {
99  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
100  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
101 
102  if (!detIdHcal.null()) {
103  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
104  if (subdet == HcalBarrel || subdet == HcalOuter || subdet == HcalEndcap || (!noHF && subdet == HcalForward)) {
105  if (calotower->hadEt() > MaxTowerHad)
106  MaxTowerHad = calotower->hadEt();
107  if (calotower->emEt() > MaxTowerEm)
108  MaxTowerEm = calotower->emEt();
109  }
110  }
111 
112  if (!detIdEcal.null()) {
113  if (calotower->emEt() > MaxTowerEm)
114  MaxTowerEm = calotower->emEt();
115  }
116 }
117 
118 //____________________________________________________________________________||
119 void CaloSpecificAlgo::update_EmEtInEB_EmEtInEE(float &EmEtInEB, float &EmEtInEE, const CaloTower *calotower) {
120  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
121  if (detIdEcal.null())
122  return;
123 
124  EcalSubdetector subdet = EcalSubdetector(detIdEcal.subdetId());
125  if (subdet == EcalBarrel) {
126  EmEtInEB += calotower->emEt();
127  } else if (subdet == EcalEndcap) {
128  EmEtInEE += calotower->emEt();
129  }
130 }
131 
132 //____________________________________________________________________________||
134  float &HadEtInHE,
135  float &HadEtInHO,
136  float &HadEtInHF,
137  float &EmEtInHF,
138  const CaloTower *calotower,
139  bool noHF) {
140  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
141  if (detIdHcal.null())
142  return;
143 
144  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
145  if (subdet == HcalBarrel || subdet == HcalOuter) {
146  HadEtInHB += calotower->hadEt();
147  HadEtInHO += calotower->outerEt();
148  }
149 
150  if (subdet == HcalEndcap) {
151  HadEtInHE += calotower->hadEt();
152  }
153 
154  if (subdet == HcalForward && !noHF) {
155  HadEtInHF += calotower->hadEt();
156  EmEtInHF += calotower->emEt();
157  }
158 }
159 
160 //____________________________________________________________________________||
162  double &MExInpHF,
163  double &MEyInpHF,
164  double &sumEtInmHF,
165  double &MExInmHF,
166  double &MEyInmHF,
167  const CaloTower *calotower) {
168  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
169  if (detIdHcal.null())
170  return;
171 
172  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
173  if (!(subdet == HcalForward))
174  return;
175 
176  if (calotower->eta() >= 0) {
177  sumEtInpHF += calotower->et();
178  MExInpHF -= (calotower->et() * cos(calotower->phi()));
179  MEyInpHF -= (calotower->et() * sin(calotower->phi()));
180  } else {
181  sumEtInmHF += calotower->et();
182  MExInmHF -= (calotower->et() * cos(calotower->phi()));
183  MEyInmHF -= (calotower->et() * sin(calotower->phi()));
184  }
185 }
186 
187 //____________________________________________________________________________||
189  double sumEtInpHF,
190  double MExInpHF,
191  double MEyInpHF,
192  double sumEtInmHF,
193  double MExInmHF,
194  double MEyInmHF) {
195  met.mex -= (MExInmHF + MExInpHF);
196  met.mey -= (MEyInmHF + MEyInpHF);
197  met.sumet -= (sumEtInpHF + sumEtInmHF);
198  met.met = sqrt(met.mex * met.mex + met.mey * met.mey);
199 }
200 
201 //____________________________________________________________________________||
203  double sumEtInpHF,
204  double MExInpHF,
205  double MEyInpHF,
206  double sumEtInmHF,
207  double MExInmHF,
208  double MEyInmHF) {
209  LorentzVector METpHF(MExInpHF, MEyInpHF, 0, sqrt(MExInpHF * MExInpHF + MEyInpHF * MEyInpHF));
210  LorentzVector METmHF(MExInmHF, MEyInmHF, 0, sqrt(MExInmHF * MExInmHF + MEyInmHF * MEyInmHF));
211  specific.CaloMETInpHF = METpHF.pt();
212  specific.CaloMETInmHF = METmHF.pt();
213  specific.CaloMETPhiInpHF = METpHF.Phi();
214  specific.CaloMETPhiInmHF = METmHF.Phi();
215  specific.CaloSETInpHF = sumEtInpHF;
216  specific.CaloSETInmHF = sumEtInmHF;
217 }
218 
219 //____________________________________________________________________________||
221  DetId ret;
222  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell) {
223  DetId id = calotower->constituent(cell);
224  if (id.det() == DetId::Hcal) {
225  ret = id;
226  break;
227  }
228  }
229  return ret;
230 }
231 
232 //____________________________________________________________________________||
234  DetId ret;
235  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell) {
236  DetId id = calotower->constituent(cell);
237  if (id.det() == DetId::Ecal) {
238  ret = id;
239  break;
240  }
241  }
242  return ret;
243 }
244 
245 //____________________________________________________________________________||
DetId find_DetId_of_HCAL_cell_in_constituent_of(const CaloTower *calotower)
tuple ret
prodAgent to be discontinued
dictionary specific
void update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(float &HadEtInHB, float &HadEtInHE, float &HadEtInHO, float &HadEtInHF, float &EmEtInHF, const CaloTower *calotower, bool noHF)
void remove_HF_from_MET(CommonMETData &met, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
size_t constituentsSize() const
Definition: CaloTower.h:125
uint16_t *__restrict__ id
void add_MET_in_HF(SpecificCaloMETData &specific, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
DetId constituent(size_t i) const
Definition: CaloTower.h:126
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
double hadEt() const
Definition: CaloTower.h:136
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double outerEt() const
Definition: CaloTower.h:137
void update_EmEtInEB_EmEtInEE(float &EmEtInEB, float &EmEtInEE, const CaloTower *calotower)
void update_totalEt_totalEm(double &totalEt, double &totalEm, const CaloTower *calotower, bool noHF)
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
void update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(double &sumEtInpHF, double &MExInpHF, double &MEyInpHF, double &sumEtInmHF, double &MExInmHF, double &MEyInmHF, const CaloTower *calotower)
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
HcalSubdetector
Definition: HcalAssistant.h:31
tuple globalThreshold
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
Definition: DetId.h:17
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, const CommonMETData &met, bool noHF, double globalThreshold)
void update_MaxTowerEm_MaxTowerHad(float &MaxTowerEm, float &MaxTowerHad, const CaloTower *calotower, bool noHF)
math::XYZTLorentzVector LorentzVector
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
double et(double vtxZ) const
Definition: CaloTower.h:150
EcalSubdetector
double phi() const final
momentum azimuthal angle
double emEt() const
Definition: CaloTower.h:135
DetId find_DetId_of_ECAL_cell_in_constituent_of(const CaloTower *calotower)
double eta() const final
momentum pseudorapidity