CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
eHCALMatrix.cc
Go to the documentation of this file.
4 
5 #include<algorithm>
6 #include<iostream>
7 
8 namespace spr{
9  HcalDetId getHotCell(std::vector<HBHERecHitCollection::const_iterator>& hit, bool includeHO, bool useRaw, bool) {
10 
11  std::vector<HcalDetId> dets;
12  std::vector<double> energies;
13  for (unsigned int ihit=0; ihit<hit.size(); ihit++) {
14  double energy = getRawEnergy(hit.at(ihit), useRaw);
15  HcalDetId id0 = hit.at(ihit)->id();
16  if ((id0.subdet() != HcalOuter) || includeHO) {
17  HcalDetId id1(id0.subdet(),id0.ieta(),id0.iphi(),1);
18  bool found(false);
19  for (unsigned int idet=0; idet<dets.size(); ++idet) {
20  if (id1 == dets[idet]) {
21  energies[idet] += energy;
22  found = true;
23  break;
24  }
25  }
26  if (!found) {
27  dets.push_back(id1);
28  energies.push_back(energy);
29  }
30  }
31  }
32  double energyMax(-99.);
33  HcalDetId hotCell;
34  for (unsigned int ihit=0; ihit<dets.size(); ihit++) {
35  if (energies[ihit] > energyMax) {
36  energyMax = energies[ihit];
37  hotCell = dets[ihit];
38  }
39  }
40  return hotCell;
41  }
42 
43  HcalDetId getHotCell(std::vector<std::vector<PCaloHit>::const_iterator>& hit, bool includeHO, bool useRaw, bool) {
44 
45  std::vector<HcalDetId> dets;
46  std::vector<double> energies;
47  for (unsigned int ihit=0; ihit<hit.size(); ihit++) {
48  double energy = hit.at(ihit)->energy();
49  HcalDetId id0 = getRawEnergy(hit.at(ihit),useRaw);
50  if ((id0.subdet() != HcalOuter) || includeHO) {
51  HcalDetId id1(id0.subdet(),id0.ieta(),id0.iphi(),1);
52  bool found(false);
53  for (unsigned int idet=0; idet<dets.size(); ++idet) {
54  if (id1 == dets[idet]) {
55  energies[idet] += energy;
56  found = true;
57  break;
58  }
59  }
60  if (!found) {
61  dets.push_back(id1);
62  energies.push_back(energy);
63  }
64  }
65  }
66  double energyMax(-99.);
67  HcalDetId hotCell;
68  for (unsigned int ihit=0; ihit<dets.size(); ihit++) {
69  if (energies[ihit] > energyMax) {
70  energyMax = energies[ihit];
71  hotCell = dets[ihit];
72  }
73  }
74  return hotCell;
75  }
76 }
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
double getRawEnergy(HBHERecHitCollection::const_iterator hit, bool useRaw=false)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:103
HcalDetId getHotCell(std::vector< HBHERecHitCollection::const_iterator > &hit, bool includeHO, bool useRaw=false, bool debug=false)
Definition: eHCALMatrix.cc:9