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.
7 
8 using namespace reco;
9 using namespace std;
10 
11 //-------------------------------------------------------------------------
12 // This algorithm adds calorimeter specific global event information to
13 // the MET object which may be useful/needed for MET Data Quality Monitoring
14 // and MET cleaning. This list is not exhaustive and additional
15 // information will be added in the future.
16 //-------------------------------------
17 
19 {
20  // Instantiate the container to hold the calorimeter specific information
21  SpecificCaloMETData specific;
22  // Initialise the container
23  specific.MaxEtInEmTowers = 0.0; // Maximum energy in EM towers
24  specific.MaxEtInHadTowers = 0.0; // Maximum energy in HCAL towers
25  specific.HadEtInHO = 0.0; // Hadronic energy fraction in HO
26  specific.HadEtInHB = 0.0; // Hadronic energy in HB
27  specific.HadEtInHF = 0.0; // Hadronic energy in HF
28  specific.HadEtInHE = 0.0; // Hadronic energy in HE
29  specific.EmEtInEB = 0.0; // Em energy in EB
30  specific.EmEtInEE = 0.0; // Em energy in EE
31  specific.EmEtInHF = 0.0; // Em energy in HF
32  specific.EtFractionHadronic = 0.0; // Hadronic energy fraction
33  specific.EtFractionEm = 0.0; // Em energy fraction
34  specific.CaloSETInpHF = 0.0; // CaloSET in HF+
35  specific.CaloSETInmHF = 0.0; // CaloSET in HF-
36  specific.CaloMETInpHF = 0.0; // CaloMET in HF+
37  specific.CaloMETInmHF = 0.0; // CaloMET in HF-
38  specific.CaloMETPhiInpHF = 0.0; // CaloMET-phi in HF+
39  specific.CaloMETPhiInmHF = 0.0; // CaloMET-phi in HF-
40  specific.METSignificance = 0.0;
41 
42  double totalEt = 0.0;
43  double totalEm = 0.0;
44  double totalHad = 0.0;
45  double MaxTowerEm = 0.0;
46  double MaxTowerHad = 0.0;
47  double sumEtInpHF = 0.0;
48  double sumEtInmHF = 0.0;
49  double MExInpHF = 0.0;
50  double MEyInpHF = 0.0;
51  double MExInmHF = 0.0;
52  double MEyInmHF = 0.0;
53 
54  if( towers->size() == 0 ) // if there are no towers, return specific = 0
55  {
56  // LogDebug("CaloMET") << "Number of Candidate CaloTowers is zero : Unable to calculate calo specific info. " ;
57  const LorentzVector p4( met.mex, met.mey, 0.0, met.met );
58  const Point vtx( 0.0, 0.0, 0.0 );
59  CaloMET specificmet( specific, met.sumet, p4, vtx );
60  return specificmet;
61  }
62 
63  edm::View<Candidate>::const_iterator towerCand = towers->begin();
64  for( ; towerCand != towers->end(); towerCand++ )
65  {
66  const Candidate* candidate = &(*towerCand);
67  if (candidate) {
68  const CaloTower* calotower = dynamic_cast<const CaloTower*> (candidate);
69  if (calotower)
70  {
71  double caloTowerEt=calotower->et();
72  double caloTowerHadEt=calotower->hadEt();
73  double caloTowerEmEt=calotower->emEt();
74  if(caloTowerEt < globalThreshold) continue;
75  totalEt += caloTowerEt;
76  totalEm += caloTowerEmEt;
77 
78  //totalHad += caloTowerHadEt + calotower->outerEt() ;
79 
80  bool hadIsDone = false;
81  bool emIsDone = false;
82  int cell = calotower->constituentsSize();
83  while ( --cell >= 0 && (!hadIsDone || !emIsDone) )
84  {
85  DetId id = calotower->constituent( cell );
86  if( !hadIsDone && id.det() == DetId::Hcal )
87  {
88  HcalSubdetector subdet = HcalDetId(id).subdet();
89  if( subdet == HcalBarrel || subdet == HcalOuter )
90  {
91  if( caloTowerHadEt > MaxTowerHad ) MaxTowerHad = caloTowerHadEt;
92  specific.HadEtInHB += caloTowerHadEt;
93  specific.HadEtInHO += calotower->outerEt();
94  }
95  else if( subdet == HcalEndcap )
96  {
97  if( caloTowerHadEt > MaxTowerHad ) MaxTowerHad = caloTowerHadEt;
98  specific.HadEtInHE += caloTowerHadEt;
99  }
100  else if( subdet == HcalForward )
101  {
102  if (!noHF)
103  {
104  if( caloTowerHadEt > MaxTowerHad ) MaxTowerHad = caloTowerHadEt;
105  if( caloTowerEmEt > MaxTowerEm ) MaxTowerEm = caloTowerEmEt;
106  //These quantities should be nonzero only if HF is included, i.e., noHF == false
107  specific.HadEtInHF += caloTowerHadEt;
108  specific.EmEtInHF += caloTowerEmEt;
109  }
110  else
111  {
112  //These quantities need to be corrected from above if HF is excluded
113  // totalHad -= caloTowerHadEt;
114  totalEm -= caloTowerEmEt;
115  totalEt -= caloTowerEt;
116  }
117  // These get calculate regardless of NoHF == true or not.
118  // They are needed below for either case.
119  if (calotower->eta()>=0)
120  {
121  sumEtInpHF += caloTowerEt;
122  MExInpHF -= (caloTowerEt * cos(calotower->phi()));
123  MEyInpHF -= (caloTowerEt * sin(calotower->phi()));
124  }
125  else
126  {
127  sumEtInmHF += caloTowerEt;
128  MExInmHF -= (caloTowerEt * cos(calotower->phi()));
129  MEyInmHF -= (caloTowerEt * sin(calotower->phi()));
130  }
131  }
132  hadIsDone = true;
133  }
134  else if( !emIsDone && id.det() == DetId::Ecal )
135  {
136  EcalSubdetector subdet = EcalSubdetector( id.subdetId() );
137  if( caloTowerEmEt > MaxTowerEm ) MaxTowerEm = caloTowerEmEt;
138  if( subdet == EcalBarrel )
139  {
140  specific.EmEtInEB += caloTowerEmEt;
141  }
142  else if( subdet == EcalEndcap )
143  {
144  specific.EmEtInEE += caloTowerEmEt;
145  }
146  emIsDone = true;
147  }
148  }
149  }
150  }
151  }
152 
153  //Following Greg L's suggestion to calculate this quantity outside of the loop and to avoid confusion.
154  //This should work regardless of HO's inclusion / exclusion .
155  totalHad += (totalEt - totalEm);
156 
157  if(!noHF)
158  { // Form sub-det specific MET-vectors
159  LorentzVector METpHF(MExInpHF, MEyInpHF, 0, sqrt(MExInpHF*MExInpHF + MEyInpHF*MEyInpHF));
160  LorentzVector METmHF(MExInmHF, MEyInmHF, 0, sqrt(MExInmHF*MExInmHF + MEyInmHF*MEyInmHF));
161  specific.CaloMETInpHF = METpHF.pt();
162  specific.CaloMETInmHF = METmHF.pt();
163  specific.CaloMETPhiInpHF = METpHF.Phi();
164  specific.CaloMETPhiInmHF = METmHF.Phi();
165  specific.CaloSETInpHF = sumEtInpHF;
166  specific.CaloSETInmHF = sumEtInmHF;
167  }
168  else
169  { // remove HF from MET calculation
170  met.mex -= (MExInmHF + MExInpHF);
171  met.mey -= (MEyInmHF + MEyInpHF);
172  met.sumet -= (sumEtInpHF + sumEtInmHF);
173  met.met = sqrt(met.mex*met.mex + met.mey*met.mey);
174  }
175 
176  specific.MaxEtInEmTowers = MaxTowerEm;
177  specific.MaxEtInHadTowers = MaxTowerHad;
178  specific.EtFractionHadronic = totalHad / totalEt;
179  specific.EtFractionEm = totalEm / totalEt;
180 
181  const LorentzVector p4( met.mex, met.mey, 0.0, met.met );
182  const Point vtx( 0.0, 0.0, 0.0 );
183  // Create and return an object of type CaloMET, which is a MET object with
184  // the extra calorimeter specfic information added
185  CaloMET specificmet( specific, met.sumet, p4, vtx );
186  return specificmet;
187 }
188 //-------------------------------------------------------------------------
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
size_t constituentsSize() const
Definition: CaloTower.h:74
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
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
MET made from CaloTowers.
virtual double eta() const
momentum pseudorapidity
T sqrt(T t)
Definition: SSEVec.h:28
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
virtual const_iterator begin() const
first daughter const_iterator
Definition: LeafCandidate.cc:8
Definition: DetId.h:20
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)
Make CaloMET. Assumes MET is made from CaloTowerCandidates.
math::XYZTLorentzVector LorentzVector
math::XYZPoint Point
double et(double vtxZ) const
Definition: CaloTower.h:101
const_iterator end() const
EcalSubdetector
virtual double phi() const
momentum azimuthal angle
double emEt() const
Definition: CaloTower.h:84