CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalTools.cc
Go to the documentation of this file.
1 
8 
9 float EcalTools::swissCross(const DetId& id,
11  float recHitThreshold,
12  bool avoidIeta85) {
13  // compute swissCross
14  if (id.subdetId() == EcalBarrel) {
15  EBDetId ebId(id);
16  // avoid recHits at |eta|=85 where one side of the neighbours is missing
17  // (may improve considering also eta module borders, but no
18  // evidence for the time being that there the performance is
19  // different)
20  if (abs(ebId.ieta()) == 85 && avoidIeta85)
21  return 0;
22  // select recHits with Et above recHitThreshold
23  if (recHitApproxEt(id, recHits) < recHitThreshold)
24  return 0;
25  float s4 = 0;
26  float e1 = recHitE(id, recHits);
27  // protect against nan (if 0 threshold is given above)
28  if (e1 == 0)
29  return 0;
30  s4 += recHitE(id, recHits, 1, 0);
31  s4 += recHitE(id, recHits, -1, 0);
32  s4 += recHitE(id, recHits, 0, 1);
33  s4 += recHitE(id, recHits, 0, -1);
34  return 1 - s4 / e1;
35  } else if (id.subdetId() == EcalEndcap) {
36  EEDetId eeId(id);
37  // select recHits with E above recHitThreshold
38  float e1 = recHitE(id, recHits);
39  if (e1 < recHitThreshold)
40  return 0;
41  float s4 = 0;
42  // protect against nan (if 0 threshold is given above)
43  if (e1 == 0)
44  return 0;
45  s4 += recHitE(id, recHits, 1, 0);
46  s4 += recHitE(id, recHits, -1, 0);
47  s4 += recHitE(id, recHits, 0, 1);
48  s4 += recHitE(id, recHits, 0, -1);
49  return 1 - s4 / e1;
50  }
51  return 0;
52 }
53 
56 
57  if (chIt != dch.end()) {
58  return *chIt;
59  } else {
60  edm::LogError("EcalDBError") << "No NextToDead status found for xtal " << id.rawId();
61  }
62 
63  return false;
64 }
65 
66 bool EcalTools::isNextToDeadFromNeighbours(const DetId& id, const EcalChannelStatus& chs, int chStatusThreshold) {
67  if (deadNeighbour(id, chs, chStatusThreshold, 1, 0))
68  return true;
69  if (deadNeighbour(id, chs, chStatusThreshold, -1, 0))
70  return true;
71  if (deadNeighbour(id, chs, chStatusThreshold, 0, 1))
72  return true;
73  if (deadNeighbour(id, chs, chStatusThreshold, 0, -1))
74  return true;
75  if (deadNeighbour(id, chs, chStatusThreshold, 1, -1))
76  return true;
77  if (deadNeighbour(id, chs, chStatusThreshold, 1, 1))
78  return true;
79  if (deadNeighbour(id, chs, chStatusThreshold, -1, 1))
80  return true;
81  if (deadNeighbour(id, chs, chStatusThreshold, -1, -1))
82  return true;
83 
84  return false;
85 }
86 
87 bool EcalTools::deadNeighbour(const DetId& id, const EcalChannelStatus& chs, int chStatusThreshold, int dx, int dy) {
88  DetId nid;
89  if (id.subdetId() == EcalBarrel)
90  nid = EBDetId::offsetBy(id, dx, dy);
91  else if (id.subdetId() == EcalEndcap)
92  nid = EEDetId::offsetBy(id, dx, dy);
93 
94  if (!nid)
95  return false;
96 
98  uint16_t dbStatus = 0;
99  if (chIt != chs.end()) {
100  // note that
101  dbStatus = chIt->getStatusCode();
102  } else {
103  edm::LogError("EcalDBError") << "No channel status found for xtal " << id.rawId()
104  << "! something wrong with EcalChannelStatus in your DB? ";
105  }
106 
107  return (dbStatus >= chStatusThreshold);
108 }
109 
110 float EcalTools::recHitE(const DetId id, const EcalRecHitCollection& recHits, int di, int dj) {
111  // in the barrel: di = dEta dj = dPhi
112  // in the endcap: di = dX dj = dY
113 
114  DetId nid;
115  if (id.subdetId() == EcalBarrel)
116  nid = EBDetId::offsetBy(id, di, dj);
117  else if (id.subdetId() == EcalEndcap)
118  nid = EEDetId::offsetBy(id, di, dj);
119 
120  return (nid == DetId(0) ? 0 : recHitE(nid, recHits));
121 }
122 
124  if (id == DetId(0)) {
125  return 0;
126  } else {
128  if (it != recHits.end())
129  return (*it).energy();
130  }
131  return 0;
132 }
133 
135  // for the time being works only for the barrel
136  if (id.subdetId() == EcalBarrel) {
137  return recHitE(id, recHits) / cosh(EBDetId::approxEta(id));
138  }
139  return 0;
140 }
141 
142 bool isNextToBoundary(const DetId& id) {
143  if (id.subdetId() == EcalBarrel)
145  else if (id.subdetId() == EcalEndcap)
147 
148  return false;
149 }
float approxEta() const
Definition: EBDetId.h:102
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:277
std::vector< EcalRecHit >::const_iterator const_iterator
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:391
Log< level::Error, false > LogError
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:106
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:50
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
bool isNextToBoundary(const DetId &id)
Definition: EcalTools.cc:142
const_iterator end() const
static bool isNextToDeadFromNeighbours(const DetId &id, const EcalChannelStatus &chs, int chStatusThreshold)
same as isNextToDead, but will use information from the neighbour
Definition: EcalTools.cc:66
static bool isNextToDead(const DetId &id, const EcalNextToDeadChannel &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:54
Definition: DetId.h:17
std::vector< Item >::const_iterator const_iterator
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:123
static float swissCross(const DetId &id, const EcalRecHitCollection &recHits, float recHitThreshold, bool avoidIeta85=true)
the good old 1-e4/e1. Ignore hits below recHitThreshold
Definition: EcalTools.cc:9
static bool deadNeighbour(const DetId &id, const EcalChannelStatus &chs, int chStatusThreshold, int dx, int dy)
return true if the channel at offsets dx,dy is dead
Definition: EcalTools.cc:87
iterator find(key_type k)
static float recHitApproxEt(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:134
const_iterator find(uint32_t rawId) const
const_iterator end() const