CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: CaloSpecificAlgo.cc,v 1.32 2012/06/09 21:19:30 sakuma Exp $
9 //
10 //
15 
16 #include <iostream>
17 
18 using namespace reco;
19 
20 //____________________________________________________________________________||
21 // This algorithm adds calorimeter specific global event information to
22 // the MET object which may be useful/needed for MET Data Quality Monitoring
23 // and MET cleaning.
24 //____________________________________________________________________________||
25 
26 //____________________________________________________________________________||
28 {
30  initializeSpecificCaloMETData(specific);
31 
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  {
44  const CaloTower* calotower = dynamic_cast<const CaloTower*> (&(*towerCand));
45  if (!calotower) continue;
46  if(calotower->et() < globalThreshold) continue;
47  update_totalEt_totalEm(totalEt, totalEm, calotower, noHF);
48  update_MaxTowerEm_MaxTowerHad(specific.MaxEtInEmTowers, specific.MaxEtInHadTowers, calotower, noHF);
49  update_EmEtInEB_EmEtInEE(specific.EmEtInEB, specific.EmEtInEE, calotower);
50  update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(specific.HadEtInHB, specific.HadEtInHE, specific.HadEtInHO, specific.HadEtInHF, specific.EmEtInHF, calotower, noHF);
51  update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF, calotower);
52  }
53 
54  double totalHad = totalEt - totalEm;
55 
56  if(noHF) remove_HF_from_MET(met, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
57 
58  if(!noHF) add_MET_in_HF(specific, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
59 
60  specific.EtFractionHadronic = (totalEt == 0.0)? 0.0 : totalHad/totalEt;
61  specific.EtFractionEm = (totalEt == 0.0)? 0.0 : totalEm/totalEt;
62 
63  const LorentzVector p4( met.mex, met.mey, 0.0, met.met);
64  const Point vtx(0.0, 0.0, 0.0);
65  CaloMET caloMET(specific, met.sumet, p4, vtx);
66  return caloMET;
67 }
68 
69 //____________________________________________________________________________||
71 {
72  specific.MaxEtInEmTowers = 0.0; // Maximum energy in EM towers
73  specific.MaxEtInHadTowers = 0.0; // Maximum energy in HCAL towers
74  specific.HadEtInHO = 0.0; // Hadronic energy fraction in HO
75  specific.HadEtInHB = 0.0; // Hadronic energy in HB
76  specific.HadEtInHF = 0.0; // Hadronic energy in HF
77  specific.HadEtInHE = 0.0; // Hadronic energy in HE
78  specific.EmEtInEB = 0.0; // Em energy in EB
79  specific.EmEtInEE = 0.0; // Em energy in EE
80  specific.EmEtInHF = 0.0; // Em energy in HF
81  specific.EtFractionHadronic = 0.0; // Hadronic energy fraction
82  specific.EtFractionEm = 0.0; // Em energy fraction
83  specific.METSignificance = 0.0;
84  specific.CaloMETInpHF = 0.0; // CaloMET in HF+
85  specific.CaloMETInmHF = 0.0; // CaloMET in HF-
86  specific.CaloSETInpHF = 0.0; // CaloSET in HF+
87  specific.CaloSETInmHF = 0.0; // CaloSET in HF-
88  specific.CaloMETPhiInpHF = 0.0; // CaloMET-phi in HF+
89  specific.CaloMETPhiInmHF = 0.0; // CaloMET-phi in HF-
90 }
91 
92 //____________________________________________________________________________||
93 void CaloSpecificAlgo::update_totalEt_totalEm(double &totalEt, double& totalEm, const CaloTower* calotower, bool noHF)
94 {
95  if( noHF )
96  {
97  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
98  if(!detIdHcal.null())
99  {
100  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
101  if( subdet == HcalForward ) return;
102  }
103  }
104 
105  totalEt += calotower->et();
106  totalEm += calotower->emEt();
107 }
108 
109 //____________________________________________________________________________||
110 void CaloSpecificAlgo::update_MaxTowerEm_MaxTowerHad(double &MaxTowerEm, double &MaxTowerHad, const CaloTower* calotower, bool noHF)
111 {
112  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
113  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
114 
115  if( !detIdHcal.null() )
116  {
117  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
118  if( subdet == HcalBarrel || subdet == HcalOuter || subdet == HcalEndcap || (!noHF && subdet == HcalForward))
119  {
120  if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
121  if( calotower->emEt() > MaxTowerEm ) MaxTowerEm = calotower->emEt();
122  }
123 
124  }
125 
126  if( !detIdEcal.null() )
127  {
128  if( calotower->emEt() > MaxTowerEm ) MaxTowerEm = calotower->emEt();
129  }
130 }
131 
132 //____________________________________________________________________________||
133 void CaloSpecificAlgo::update_EmEtInEB_EmEtInEE(double &EmEtInEB, double &EmEtInEE, const CaloTower* calotower)
134 {
135  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
136  if(detIdEcal.null()) return;
137 
138  EcalSubdetector subdet = EcalSubdetector( detIdEcal.subdetId() );
139  if( subdet == EcalBarrel )
140  {
141  EmEtInEB += calotower->emEt();
142  }
143  else if( subdet == EcalEndcap )
144  {
145  EmEtInEE += calotower->emEt();
146  }
147 }
148 
149 //____________________________________________________________________________||
150 void CaloSpecificAlgo::update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(double &HadEtInHB, double &HadEtInHE, double &HadEtInHO, double &HadEtInHF, double &EmEtInHF, const CaloTower* calotower, bool noHF)
151 {
152  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
153  if(detIdHcal.null()) return;
154 
155  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
156  if( subdet == HcalBarrel || subdet == HcalOuter )
157  {
158  HadEtInHB += calotower->hadEt();
159  HadEtInHO += calotower->outerEt();
160  }
161 
162  if( subdet == HcalEndcap )
163  {
164  HadEtInHE += calotower->hadEt();
165  }
166 
167  if( subdet == HcalForward && !noHF)
168  {
169  HadEtInHF += calotower->hadEt();
170  EmEtInHF += calotower->emEt();
171  }
172 }
173 
174 //____________________________________________________________________________||
175 void CaloSpecificAlgo::update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(double &sumEtInpHF, double &MExInpHF, double &MEyInpHF, double &sumEtInmHF, double &MExInmHF, double &MEyInmHF, const CaloTower* calotower)
176 {
177  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
178  if(detIdHcal.null()) return;
179 
180  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
181  if( !(subdet == HcalForward) ) return;
182 
183  if (calotower->eta() >= 0)
184  {
185  sumEtInpHF += calotower->et();
186  MExInpHF -= (calotower->et() * cos(calotower->phi()));
187  MEyInpHF -= (calotower->et() * sin(calotower->phi()));
188  }
189  else
190  {
191  sumEtInmHF += calotower->et();
192  MExInmHF -= (calotower->et() * cos(calotower->phi()));
193  MEyInmHF -= (calotower->et() * sin(calotower->phi()));
194  }
195 }
196 
197 //____________________________________________________________________________||
198 void CaloSpecificAlgo::remove_HF_from_MET(CommonMETData &met, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
199 {
200  met.mex -= (MExInmHF + MExInpHF);
201  met.mey -= (MEyInmHF + MEyInpHF);
202  met.sumet -= (sumEtInpHF + sumEtInmHF);
203  met.met = sqrt(met.mex*met.mex + met.mey*met.mey);
204 }
205 
206 //____________________________________________________________________________||
207 void CaloSpecificAlgo::add_MET_in_HF(SpecificCaloMETData &specific, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
208 {
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 {
222  DetId ret;
223  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
224  {
225  DetId id = calotower->constituent( cell );
226  if( id.det() == DetId::Hcal )
227  {
228  ret = id;
229  break;
230  }
231  }
232  return ret;
233 }
234 
235 //____________________________________________________________________________||
237 {
238  DetId ret;
239  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
240  {
241  DetId id = calotower->constituent( cell );
242  if( id.det() == DetId::Ecal )
243  {
244  ret = id;
245  break;
246  }
247  }
248  return ret;
249 }
250 
251 //____________________________________________________________________________||
DetId find_DetId_of_HCAL_cell_in_constituent_of(const CaloTower *calotower)
void initializeSpecificCaloMETData(SpecificCaloMETData &specific)
dictionary specific
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
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:74
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
void update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(double &HadEtInHB, double &HadEtInHE, double &HadEtInHO, double &HadEtInHF, double &EmEtInHF, const CaloTower *calotower, bool noHF)
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:75
double hadEt() const
Definition: CaloTower.h:85
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double outerEt() const
Definition: CaloTower.h:86
void update_EmEtInEB_EmEtInEE(double &EmEtInEB, double &EmEtInEE, const CaloTower *calotower)
void update_MaxTowerEm_MaxTowerHad(double &MaxTowerEm, double &MaxTowerHad, const CaloTower *calotower, bool noHF)
MET made from CaloTowers.
void update_totalEt_totalEm(double &totalEt, double &totalEm, const CaloTower *calotower, bool noHF)
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
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:48
double p4[4]
Definition: TauolaWrapper.h:92
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
HcalSubdetector
Definition: HcalAssistant.h:32
Structure containing data common to all types of MET.
Definition: CommonMETData.h:22
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
Definition: DetId.h:20
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)
bool null() const
is this a null id ?
Definition: DetId.h:47
math::XYZTLorentzVector LorentzVector
math::XYZPoint Point
double et(double vtxZ) const
Definition: CaloTower.h:101
EcalSubdetector
double emEt() const
Definition: CaloTower.h:84
DetId find_DetId_of_ECAL_cell_in_constituent_of(const CaloTower *calotower)