CMS 3D CMS Logo

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.empty()) 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  // Store # of entries for Occupancy analysis
89  std::vector<float> Nentries(nDCC,0.); // digis
90  std::vector<float> Nrhentries(nDCC,0.); // (filtered) rechits
91 
92  // second round to find hot towers
93  for(MESet::const_iterator dItr(sDigi.beginChannel()); dItr != dEnd; dItr.toNextChannel()){
94  DetId id(dItr->getId());
95 
96  bool doMask(meQualitySummary.maskMatches(id, mask, statusManager_));
97 
98  rItr = dItr;
99 
100  float entries(dItr->getBinContent());
101  float rhentries(rItr->getBinContent());
102 
103  int ieta(0);
104  if(id.subdetId() == EcalTriggerTower) // barrel
105  ieta = EcalTrigTowerDetId(id).ieta();
106  else{
107  std::vector<DetId> ids(scConstituents(EcalScDetId(id)));
108  if(ids.empty()) continue;
109  ieta = getTrigTowerMap()->towerOf(ids[0]).ieta();
110  }
111 
112  unsigned index(ieta < 0 ? ieta + 28 : ieta + 27);
113 
114  int quality(doMask ? kMGood : kGood);
115 
116  if(entries > minHits_ && entries > digiPhiRingMean[index] * deviationThreshold_){
117  // meHotDigi->fill(id);
118  quality = doMask ? kMBad : kBad;
119  }
120  if(rhentries > minHits_ && rhentries > rechitPhiRingMean[index] * deviationThreshold_){
121  // meHotRecHitThr->fill(id);
122  quality = doMask ? kMBad : kBad;
123  }
124 
125  meQualitySummary.setBinContent(id, double(quality));
126 
127  // Keep count of digis & rechits for Occupancy analysis
128  unsigned iDCC( dccId(id)-1 );
129  if ( entries > minHits_ ) Nentries[iDCC] += entries;
130  if ( rhentries > minHits_ ) Nrhentries[iDCC] += rhentries;
131 
132  }
133 
134  double tpdigiPhiRingMean[nPhiRings];
135  std::fill_n(tpdigiPhiRingMean, nPhiRings, 0.);
136 
137  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; ++iTT){
139  float entries(sTPDigiThr.getBinContent(ttid));
140 
141  unsigned index(ttid.ieta() < 0 ? ttid.ieta() + 28 : ttid.ieta() + 27);
142 
143  tpdigiPhiRingMean[index] += entries;
144  }
145 
146  for(int ie(0); ie < 28; ie++){
147  float denom(-1.);
148  if(ie < 27) denom = 72.;
149  else denom = 36.;
150  tpdigiPhiRingMean[ie] /= denom;
151  tpdigiPhiRingMean[55 - ie] /= denom;
152  }
153 
154  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; ++iTT){
156 
157  float entries(sTPDigiThr.getBinContent(ttid));
158 
159  unsigned index(ttid.ieta() < 0 ? ttid.ieta() + 28 : ttid.ieta() + 27);
160 
161  int quality(kGood);
162 
163  if(entries > minHits_ && entries > tpdigiPhiRingMean[index] * deviationThreshold_){
164  // meHotTPDigiThr.fill(ttid);
165  quality = kBad;
166  }
167 
168  if(quality != kBad) continue;
169 
170  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
171  for(unsigned iD(0); iD < ids.size(); ++iD){
172  DetId& id(ids[iD]);
173 
174  int quality(meQualitySummary.getBinContent(id));
175  if(quality == kMBad || quality == kBad) continue;
176 
177  meQualitySummary.setBinContent(id, meQualitySummary.maskMatches(id, mask, statusManager_) ? kMBad : kBad);
178  }
179  }
180 
181  // Quality check: set entire FED to BAD if its occupancy begins to vanish
182  // Fill FED statistics from (filtered) RecHit Occupancy
183  float meanFEDEB(0), meanFEDEE(0), rmsFEDEB(0), rmsFEDEE(0);
184  unsigned int nFEDEB(0), nFEDEE(0);
185  for ( unsigned iDCC(0); iDCC < nDCC; iDCC++ ) {
186  if ( iDCC >=kEBmLow && iDCC <= kEBpHigh) {
187  meanFEDEB += Nrhentries[iDCC];
188  rmsFEDEB += Nrhentries[iDCC]*Nrhentries[iDCC];
189  nFEDEB++;
190  }
191  else {
192  meanFEDEE += Nrhentries[iDCC];
193  rmsFEDEE += Nrhentries[iDCC]*Nrhentries[iDCC];
194  nFEDEE++;
195  }
196  }
197  meanFEDEB /= float( nFEDEB ); rmsFEDEB /= float( nFEDEB );
198  meanFEDEE /= float( nFEDEE ); rmsFEDEE /= float( nFEDEE );
199  rmsFEDEB = sqrt( abs(rmsFEDEB - meanFEDEB*meanFEDEB) );
200  rmsFEDEE = sqrt( abs(rmsFEDEE - meanFEDEE*meanFEDEE) );
201  // Analyze FED statistics
202  float meanFED(0.), rmsFED(0.), nRMS(5.);
203  for ( MESet::iterator qsItr(meQualitySummary.beginChannel()); qsItr != meQualitySummary.end(); qsItr.toNextChannel() ) {
204  DetId id( qsItr->getId() );
205  unsigned iDCC( dccId(id)-1 );
206  if ( iDCC >= kEBmLow && iDCC <= kEBpHigh ) {
207  meanFED = meanFEDEB;
208  rmsFED = rmsFEDEB;
209  }
210  else {
211  meanFED = meanFEDEE;
212  rmsFED = rmsFEDEE;
213  }
214  float threshold( meanFED < nRMS*rmsFED ? minHits_ : meanFED - nRMS*rmsFED );
215  if ( meanFED > 1000. && Nrhentries[iDCC] < threshold )
216  meQualitySummary.setBinContent( id, meQualitySummary.maskMatches(id, mask, statusManager_) ? kMBad : kBad );
217  }
218 
219  } // producePlots()
220 
222 }
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
const_iterator & toNextChannel()
Definition: MESet.h:271
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_
T sqrt(T t)
Definition: SSEVec.h:18
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
StatusManager const * statusManager_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 &)
unsigned dccId(DetId const &)