CMS 3D CMS Logo

EcalTools.cc
Go to the documentation of this file.
1 
10 
11 float EcalTools::swissCross(const DetId& id,
13  float recHitThreshold,
14  bool avoidIeta85) {
15  // compute swissCross
16  if (id.subdetId() == EcalBarrel) {
17  EBDetId ebId(id);
18  // avoid recHits at |eta|=85 where one side of the neighbours is missing
19  // (may improve considering also eta module borders, but no
20  // evidence for the time being that there the performance is
21  // different)
22  if (abs(ebId.ieta()) == 85 && avoidIeta85)
23  return 0;
24  // select recHits with Et above recHitThreshold
26  return 0;
27  float s4 = 0;
28  float e1 = recHitE(id, recHits);
29  // protect against nan (if 0 threshold is given above)
30  if (e1 == 0)
31  return 0;
32  s4 += recHitE(id, recHits, 1, 0);
33  s4 += recHitE(id, recHits, -1, 0);
34  s4 += recHitE(id, recHits, 0, 1);
35  s4 += recHitE(id, recHits, 0, -1);
36  return 1 - s4 / e1;
37  } else if (id.subdetId() == EcalEndcap) {
38  EEDetId eeId(id);
39  // select recHits with E above recHitThreshold
40  float e1 = recHitE(id, recHits);
41  if (e1 < recHitThreshold)
42  return 0;
43  float s4 = 0;
44  // protect against nan (if 0 threshold is given above)
45  if (e1 == 0)
46  return 0;
47  s4 += recHitE(id, recHits, 1, 0);
48  s4 += recHitE(id, recHits, -1, 0);
49  s4 += recHitE(id, recHits, 0, 1);
50  s4 += recHitE(id, recHits, 0, -1);
51  return 1 - s4 / e1;
52  }
53  return 0;
54 }
55 
56 bool EcalTools::isNextToDead(const DetId& id, const edm::EventSetup& es) {
58  es.get<EcalNextToDeadChannelRcd>().get(dch);
59 
61 
62  if (chIt != dch->end()) {
63  return *chIt;
64  } else {
65  edm::LogError("EcalDBError") << "No NextToDead status found for xtal " << id.rawId();
66  }
67 
68  return false;
69 }
70 
71 bool EcalTools::isNextToDeadFromNeighbours(const DetId& id, const EcalChannelStatus& chs, int chStatusThreshold) {
72  if (deadNeighbour(id, chs, chStatusThreshold, 1, 0))
73  return true;
74  if (deadNeighbour(id, chs, chStatusThreshold, -1, 0))
75  return true;
76  if (deadNeighbour(id, chs, chStatusThreshold, 0, 1))
77  return true;
78  if (deadNeighbour(id, chs, chStatusThreshold, 0, -1))
79  return true;
80  if (deadNeighbour(id, chs, chStatusThreshold, 1, -1))
81  return true;
82  if (deadNeighbour(id, chs, chStatusThreshold, 1, 1))
83  return true;
84  if (deadNeighbour(id, chs, chStatusThreshold, -1, 1))
85  return true;
86  if (deadNeighbour(id, chs, chStatusThreshold, -1, -1))
87  return true;
88 
89  return false;
90 }
91 
92 bool EcalTools::deadNeighbour(const DetId& id, const EcalChannelStatus& chs, int chStatusThreshold, int dx, int dy) {
93  DetId nid;
94  if (id.subdetId() == EcalBarrel)
95  nid = EBDetId::offsetBy(id, dx, dy);
96  else if (id.subdetId() == EcalEndcap)
97  nid = EEDetId::offsetBy(id, dx, dy);
98 
99  if (!nid)
100  return false;
101 
102  EcalChannelStatus::const_iterator chIt = chs.find(nid);
103  uint16_t dbStatus = 0;
104  if (chIt != chs.end()) {
105  // note that
106  dbStatus = chIt->getStatusCode();
107  } else {
108  edm::LogError("EcalDBError") << "No channel status found for xtal " << id.rawId()
109  << "! something wrong with EcalChannelStatus in your DB? ";
110  }
111 
112  return (dbStatus >= chStatusThreshold);
113 }
114 
115 float EcalTools::recHitE(const DetId id, const EcalRecHitCollection& recHits, int di, int dj) {
116  // in the barrel: di = dEta dj = dPhi
117  // in the endcap: di = dX dj = dY
118 
119  DetId nid;
120  if (id.subdetId() == EcalBarrel)
121  nid = EBDetId::offsetBy(id, di, dj);
122  else if (id.subdetId() == EcalEndcap)
123  nid = EEDetId::offsetBy(id, di, dj);
124 
125  return (nid == DetId(0) ? 0 : recHitE(nid, recHits));
126 }
127 
129  if (id == DetId(0)) {
130  return 0;
131  } else {
133  if (it != recHits.end())
134  return (*it).energy();
135  }
136  return 0;
137 }
138 
140  // for the time being works only for the barrel
141  if (id.subdetId() == EcalBarrel) {
142  return recHitE(id, recHits) / cosh(EBDetId::approxEta(id));
143  }
144  return 0;
145 }
146 
147 bool isNextToBoundary(const DetId& id) {
148  if (id.subdetId() == EcalBarrel)
150  else if (id.subdetId() == EcalEndcap)
152 
153  return false;
154 }
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
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
EcalNextToDeadChannel.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:71
EBDetId
Definition: EBDetId.h:17
EBDetId.h
EEDetId.h
edm::SortedCollection< EcalRecHit >
EcalCondObjectContainer< EcalChannelStatusCode >
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:11
EcalBarrel
Definition: EcalSubdetector.h:10
EcalTools::recHitApproxEt
static float recHitApproxEt(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:139
DetId
Definition: DetId.h:17
EEDetId::offsetBy
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:391
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
OccupancyTask_cfi.recHitThreshold
recHitThreshold
Definition: OccupancyTask_cfi.py:4
edm::ESHandle
Definition: DTSurvey.h:22
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:92
EcalTools::recHitE
static float recHitE(const DetId id, const EcalRecHitCollection &recHits)
Definition: EcalTools.cc:128
EEDetId
Definition: EEDetId.h:14
EcalEndcap
Definition: EcalSubdetector.h:10
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::LogError
Definition: MessageLogger.h:183
EcalNextToDeadChannelRcd.h
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
PVValHelper::dy
Definition: PVValidationHelpers.h:49
edm::EventSetup
Definition: EventSetup.h:57
EBDetId::offsetBy
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:50
get
#define get
EcalTools.h
isNextToBoundary
bool isNextToBoundary(const DetId &id)
Definition: EcalTools.cc:147
EventSetup.h
EcalTools::isNextToDead
static bool isNextToDead(const DetId &id, const edm::EventSetup &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:56
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:48
EcalNextToDeadChannelRcd
Definition: EcalNextToDeadChannelRcd.h:12