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 //
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 {
29  CommonMETData met = umet;
30  double totalEt = 0.0;
31  double totalEm = 0.0;
32 
33  double sumEtInpHF = 0.0;
34  double sumEtInmHF = 0.0;
35  double MExInpHF = 0.0;
36  double MEyInpHF = 0.0;
37  double MExInmHF = 0.0;
38  double MEyInmHF = 0.0;
39 
40  for(edm::View<Candidate>::const_iterator towerCand = towers->begin(); towerCand != towers->end(); ++towerCand )
41  {
42  const CaloTower* calotower = dynamic_cast<const CaloTower*> (&(*towerCand));
43  if (!calotower) continue;
44  if(calotower->et() < globalThreshold) continue;
45  update_totalEt_totalEm(totalEt, totalEm, calotower, noHF);
46  update_MaxTowerEm_MaxTowerHad(specific.MaxEtInEmTowers, specific.MaxEtInHadTowers, calotower, noHF);
47  update_EmEtInEB_EmEtInEE(specific.EmEtInEB, specific.EmEtInEE, calotower);
48  update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(specific.HadEtInHB, specific.HadEtInHE, specific.HadEtInHO, specific.HadEtInHF, specific.EmEtInHF, calotower, noHF);
49  update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF, calotower);
50  }
51 
52  double totalHad = totalEt - totalEm;
53 
54  if(noHF) remove_HF_from_MET(met, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
55 
56  if(!noHF) add_MET_in_HF(specific, sumEtInpHF, MExInpHF, MEyInpHF, sumEtInmHF, MExInmHF, MEyInmHF);
57 
58  specific.EtFractionHadronic = (totalEt == 0.0)? 0.0 : totalHad/totalEt;
59  specific.EtFractionEm = (totalEt == 0.0)? 0.0 : totalEm/totalEt;
60 
61  const LorentzVector p4( met.mex, met.mey, 0.0, met.met);
62  const Point vtx(0.0, 0.0, 0.0);
63  CaloMET caloMET(specific, met.sumet, p4, vtx);
64  return caloMET;
65 }
66 
67 //____________________________________________________________________________||
68 void CaloSpecificAlgo::update_totalEt_totalEm(double &totalEt, double& totalEm, const CaloTower* calotower, bool noHF)
69 {
70  if( noHF )
71  {
72  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
73  if(!detIdHcal.null())
74  {
75  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
76  if( subdet == HcalForward ) return;
77  }
78  }
79 
80  totalEt += calotower->et();
81  totalEm += calotower->emEt();
82 }
83 
84 //____________________________________________________________________________||
85 void CaloSpecificAlgo::update_MaxTowerEm_MaxTowerHad(float &MaxTowerEm, float &MaxTowerHad, const CaloTower* calotower, bool noHF)
86 {
87  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
88  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
89 
90  if( !detIdHcal.null() )
91  {
92  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
93  if( subdet == HcalBarrel || subdet == HcalOuter || subdet == HcalEndcap || (!noHF && subdet == HcalForward))
94  {
95  if( calotower->hadEt() > MaxTowerHad ) MaxTowerHad = calotower->hadEt();
96  if( calotower->emEt() > MaxTowerEm ) MaxTowerEm = calotower->emEt();
97  }
98 
99  }
100 
101  if( !detIdEcal.null() )
102  {
103  if( calotower->emEt() > MaxTowerEm ) MaxTowerEm = calotower->emEt();
104  }
105 }
106 
107 //____________________________________________________________________________||
108 void CaloSpecificAlgo::update_EmEtInEB_EmEtInEE(float &EmEtInEB, float &EmEtInEE, const CaloTower* calotower)
109 {
110  DetId detIdEcal = find_DetId_of_ECAL_cell_in_constituent_of(calotower);
111  if(detIdEcal.null()) return;
112 
113  EcalSubdetector subdet = EcalSubdetector( detIdEcal.subdetId() );
114  if( subdet == EcalBarrel )
115  {
116  EmEtInEB += calotower->emEt();
117  }
118  else if( subdet == EcalEndcap )
119  {
120  EmEtInEE += calotower->emEt();
121  }
122 }
123 
124 //____________________________________________________________________________||
125 void CaloSpecificAlgo::update_HadEtInHB_HadEtInHE_HadEtInHO_HadEtInHF_EmEtInHF(float &HadEtInHB, float &HadEtInHE, float &HadEtInHO, float &HadEtInHF, float &EmEtInHF, const CaloTower* calotower, bool noHF)
126 {
127  DetId detIdHcal = find_DetId_of_HCAL_cell_in_constituent_of(calotower);
128  if(detIdHcal.null()) return;
129 
130  HcalSubdetector subdet = HcalDetId(detIdHcal).subdet();
131  if( subdet == HcalBarrel || subdet == HcalOuter )
132  {
133  HadEtInHB += calotower->hadEt();
134  HadEtInHO += calotower->outerEt();
135  }
136 
137  if( subdet == HcalEndcap )
138  {
139  HadEtInHE += calotower->hadEt();
140  }
141 
142  if( subdet == HcalForward && !noHF)
143  {
144  HadEtInHF += calotower->hadEt();
145  EmEtInHF += calotower->emEt();
146  }
147 }
148 
149 //____________________________________________________________________________||
150 void CaloSpecificAlgo::update_sumEtInpHF_MExInpHF_MEyInpHF_sumEtInmHF_MExInmHF_MEyInmHF(double &sumEtInpHF, double &MExInpHF, double &MEyInpHF, double &sumEtInmHF, double &MExInmHF, double &MEyInmHF, const CaloTower* calotower)
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 == HcalForward) ) return;
157 
158  if (calotower->eta() >= 0)
159  {
160  sumEtInpHF += calotower->et();
161  MExInpHF -= (calotower->et() * cos(calotower->phi()));
162  MEyInpHF -= (calotower->et() * sin(calotower->phi()));
163  }
164  else
165  {
166  sumEtInmHF += calotower->et();
167  MExInmHF -= (calotower->et() * cos(calotower->phi()));
168  MEyInmHF -= (calotower->et() * sin(calotower->phi()));
169  }
170 }
171 
172 //____________________________________________________________________________||
173 void CaloSpecificAlgo::remove_HF_from_MET(CommonMETData &met, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
174 {
175  met.mex -= (MExInmHF + MExInpHF);
176  met.mey -= (MEyInmHF + MEyInpHF);
177  met.sumet -= (sumEtInpHF + sumEtInmHF);
178  met.met = sqrt(met.mex*met.mex + met.mey*met.mey);
179 }
180 
181 //____________________________________________________________________________||
182 void CaloSpecificAlgo::add_MET_in_HF(SpecificCaloMETData &specific, double sumEtInpHF, double MExInpHF, double MEyInpHF, double sumEtInmHF, double MExInmHF, double MEyInmHF)
183 {
184  LorentzVector METpHF(MExInpHF, MEyInpHF, 0, sqrt(MExInpHF*MExInpHF + MEyInpHF*MEyInpHF));
185  LorentzVector METmHF(MExInmHF, MEyInmHF, 0, sqrt(MExInmHF*MExInmHF + MEyInmHF*MEyInmHF));
186  specific.CaloMETInpHF = METpHF.pt();
187  specific.CaloMETInmHF = METmHF.pt();
188  specific.CaloMETPhiInpHF = METpHF.Phi();
189  specific.CaloMETPhiInmHF = METmHF.Phi();
190  specific.CaloSETInpHF = sumEtInpHF;
191  specific.CaloSETInmHF = sumEtInmHF;
192 }
193 
194 //____________________________________________________________________________||
196 {
197  DetId ret;
198  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
199  {
200  DetId id = calotower->constituent( cell );
201  if( id.det() == DetId::Hcal )
202  {
203  ret = id;
204  break;
205  }
206  }
207  return ret;
208 }
209 
210 //____________________________________________________________________________||
212 {
213  DetId ret;
214  for (int cell = calotower->constituentsSize() - 1; cell >= 0; --cell)
215  {
216  DetId id = calotower->constituent( cell );
217  if( id.det() == DetId::Ecal )
218  {
219  ret = id;
220  break;
221  }
222  }
223  return ret;
224 }
225 
226 //____________________________________________________________________________||
DetId find_DetId_of_HCAL_cell_in_constituent_of(const CaloTower *calotower)
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:89
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
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:90
double hadEt() const
Definition: CaloTower.h:100
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double outerEt() const
Definition: CaloTower.h:101
void update_EmEtInEB_EmEtInEE(float &EmEtInEB, float &EmEtInEE, const CaloTower *calotower)
virtual double eta() const
momentum pseudorapidity
void update_totalEt_totalEm(double &totalEt, double &totalEm, const CaloTower *calotower, bool noHF)
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:31
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, const CommonMETData &met, bool noHF, double globalThreshold)
bool null() const
is this a null id ?
Definition: DetId.h:45
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:81
math::XYZPoint Point
double et(double vtxZ) const
Definition: CaloTower.h:116
EcalSubdetector
virtual double phi() const
momentum azimuthal angle
double emEt() const
Definition: CaloTower.h:99
DetId find_DetId_of_ECAL_cell_in_constituent_of(const CaloTower *calotower)