CMS 3D CMS Logo

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
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 }
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:74
EEDetId::isNextToBoundary
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:277
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
EBDetId::isNextToBoundary
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:106
MessageLogger.h
EBDetId::approxEta
float approxEta() const
Definition: EBDetId.h:102
ESHandle.h
EcalTools::isNextToDeadFromNeighbours
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
EBDetId
Definition: EBDetId.h:17
EBDetId.h
EEDetId.h
edm::SortedCollection< EcalRecHit >
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
EcalTools::swissCross
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
EcalBarrel
Definition: EcalSubdetector.h:10
EcalTools::recHitApproxEt
static float recHitApproxEt(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:134
DetId
Definition: DetId.h:17
EEDetId::offsetBy
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:391
EcalTools::isNextToDead
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
OccupancyTask_cfi.recHitThreshold
recHitThreshold
Definition: OccupancyTask_cfi.py:4
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EcalTools::deadNeighbour
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
EcalTools::recHitE
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:123
EEDetId
Definition: EEDetId.h:14
EcalEndcap
Definition: EcalSubdetector.h:10
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
PVValHelper::dy
Definition: PVValidationHelpers.h:50
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EBDetId::offsetBy
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:50
EcalTools.h
isNextToBoundary
bool isNextToBoundary(const DetId &id)
Definition: EcalTools.cc:142
EventSetup.h
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PVValHelper::dx
Definition: PVValidationHelpers.h:49