test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OccupancyClient.cc
Go to the documentation of this file.
1 #include "../interface/OccupancyClient.h"
2 
4 
6 
8 
10 
11 namespace ecaldqm
12 {
15  minHits_(0),
16  deviationThreshold_(0.)
17  {
18  qualitySummaries_.insert("QualitySummary");
19  }
20 
21  void
23  {
24  minHits_ = _params.getUntrackedParameter<int>("minHits");
25  deviationThreshold_ = _params.getUntrackedParameter<double>("deviationThreshold");
26  }
27 
28  void
30  {
31  using namespace std;
32 
33  // number of allowed ieta indices
34  // EE-: -28 to -1 with -27, -25 empty
35  // EE+: 1 to 28 with 26, 28 empty
36  unsigned const nPhiRings(56);
37 
38  MESet& meQualitySummary(MEs_.at("QualitySummary"));
39 // MESet& meHotDigi(MEs_.at("HotDigi"));
40 // MESet& meHotRecHitThr(MEs_.at("HotRecHitThr"));
41 // MESet& meHotTPDigiThr(MEs_.at("HotTPDigiThr"));
42 
43  MESet const& sDigi(sources_.at("DigiAll"));
44  MESet const& sRecHitThr(sources_.at("RecHitThrAll"));
45  MESet const& sTPDigiThr(sources_.at("TPDigiThrAll"));
46 
50 
51  double digiPhiRingMean[nPhiRings];
52  std::fill_n(digiPhiRingMean, nPhiRings, 0.);
53  double rechitPhiRingMean[nPhiRings];
54  std::fill_n(rechitPhiRingMean, nPhiRings, 0.);
55  int numCrystals[nPhiRings]; // this is static, but is easier to count now
56  std::fill_n(numCrystals, nPhiRings, 0);
57 
58  MESet::const_iterator dEnd(sDigi.end());
59  MESet::const_iterator rItr(sRecHitThr);
60  for(MESet::const_iterator dItr(sDigi.beginChannel()); dItr != dEnd; dItr.toNextChannel()){
61  rItr = dItr;
62 
63  float entries(dItr->getBinContent());
64  float rhentries(rItr->getBinContent());
65 
66  DetId id(dItr->getId());
67  int ieta(0);
68  if(id.subdetId() == EcalTriggerTower) // barrel
69  ieta = EcalTrigTowerDetId(id).ieta();
70  else{
71  std::vector<DetId> ids(scConstituents(EcalScDetId(id)));
72  if(ids.size() == 0) continue;
73  ieta = getTrigTowerMap()->towerOf(ids[0]).ieta();
74  }
75 
76  unsigned index(ieta < 0 ? ieta + 28 : ieta + 27);
77 
78  digiPhiRingMean[index] += entries;
79  rechitPhiRingMean[index] += rhentries;
80  numCrystals[index] += 1;
81  }
82 
83  for(unsigned ie(0); ie < nPhiRings; ie++){
84  digiPhiRingMean[ie] /= numCrystals[ie];
85  rechitPhiRingMean[ie] /= numCrystals[ie];
86  }
87 
88  // second round to find hot towers
89  for(MESet::const_iterator dItr(sDigi.beginChannel()); dItr != dEnd; dItr.toNextChannel()){
90  DetId id(dItr->getId());
91 
92  bool doMask(meQualitySummary.maskMatches(id, mask, statusManager_));
93 
94  rItr = dItr;
95 
96  float entries(dItr->getBinContent());
97  float rhentries(rItr->getBinContent());
98 
99  int ieta(0);
100  if(id.subdetId() == EcalTriggerTower) // barrel
101  ieta = EcalTrigTowerDetId(id).ieta();
102  else{
103  std::vector<DetId> ids(scConstituents(EcalScDetId(id)));
104  if(ids.size() == 0) continue;
105  ieta = getTrigTowerMap()->towerOf(ids[0]).ieta();
106  }
107 
108  unsigned index(ieta < 0 ? ieta + 28 : ieta + 27);
109 
110  int quality(doMask ? kMGood : kGood);
111 
112  if(entries > minHits_ && entries > digiPhiRingMean[index] * deviationThreshold_){
113  // meHotDigi->fill(id);
114  quality = doMask ? kMBad : kBad;
115  }
116  if(rhentries > minHits_ && rhentries > rechitPhiRingMean[index] * deviationThreshold_){
117  // meHotRecHitThr->fill(id);
118  quality = doMask ? kMBad : kBad;
119  }
120 
121  meQualitySummary.setBinContent(id, double(quality));
122  }
123 
124  double tpdigiPhiRingMean[nPhiRings];
125  std::fill_n(tpdigiPhiRingMean, nPhiRings, 0.);
126 
127  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; ++iTT){
129  float entries(sTPDigiThr.getBinContent(ttid));
130 
131  unsigned index(ttid.ieta() < 0 ? ttid.ieta() + 28 : ttid.ieta() + 27);
132 
133  tpdigiPhiRingMean[index] += entries;
134  }
135 
136  for(int ie(0); ie < 28; ie++){
137  float denom(-1.);
138  if(ie < 27) denom = 72.;
139  else denom = 36.;
140  tpdigiPhiRingMean[ie] /= denom;
141  tpdigiPhiRingMean[55 - ie] /= denom;
142  }
143 
144  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; ++iTT){
146 
147  float entries(sTPDigiThr.getBinContent(ttid));
148 
149  unsigned index(ttid.ieta() < 0 ? ttid.ieta() + 28 : ttid.ieta() + 27);
150 
151  int quality(kGood);
152 
153  if(entries > minHits_ && entries > tpdigiPhiRingMean[index] * deviationThreshold_){
154  // meHotTPDigiThr.fill(ttid);
155  quality = kBad;
156  }
157 
158  if(quality != kBad) continue;
159 
160  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
161  for(unsigned iD(0); iD < ids.size(); ++iD){
162  DetId& id(ids[iD]);
163 
164  int quality(meQualitySummary.getBinContent(id));
165  if(quality == kMBad || quality == kBad) continue;
166 
167  meQualitySummary.setBinContent(id, meQualitySummary.maskMatches(id, mask, statusManager_) ? kMBad : kBad);
168  }
169  }
170  }
171 
173 }
T getUntrackedParameter(std::string const &, T const &) const
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
static const int PHYSICS_BAD_CHANNEL_WARNING
static const int PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR
static const int PHYSICS_BAD_CHANNEL_ERROR
void setParams(edm::ParameterSet const &) override
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
int ieta() const
get the tower ieta
std::set< std::string > qualitySummaries_
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
StatusManager const * statusManager_
MESetCollection sources_
Definition: DetId.h:18
void producePlots(ProcessType) override
MESetCollection MEs_
Definition: DQWorker.h:75
const_iterator & toNextChannel()
Definition: MESet.cc:446
std::vector< DetId > scConstituents(EcalScDetId const &)