CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SummaryClient.cc
Go to the documentation of this file.
1 #include "../interface/SummaryClient.h"
2 
4 
6 
7 #include <algorithm>
8 
9 namespace ecaldqm
10 {
13  towerBadFraction_(0.),
14  fedBadFraction_(0.)
15  {
16  qualitySummaries_.insert("QualitySummary");
17  qualitySummaries_.insert("ReportSummaryMap");
18  qualitySummaries_.insert("ReportSummaryContents");
19  qualitySummaries_.insert("ReportSummary");
20  }
21 
22  void
24  {
25  towerBadFraction_ = _params.getUntrackedParameter<double>("towerBadFraction");
26  fedBadFraction_ = _params.getUntrackedParameter<double>("fedBadFraction");
27 
28  std::vector<std::string> sourceList(_params.getUntrackedParameter<std::vector<std::string> >("activeSources"));
29  if(std::find(sourceList.begin(), sourceList.end(), "Presample") == sourceList.end()) sources_.erase(std::string("Presample"));
30  if(std::find(sourceList.begin(), sourceList.end(), "Timing") == sourceList.end()) sources_.erase(std::string("Timing"));
31  if(std::find(sourceList.begin(), sourceList.end(), "TriggerPrimitives") == sourceList.end()) sources_.erase(std::string("TriggerPrimitives"));
32  if(std::find(sourceList.begin(), sourceList.end(), "HotCell") == sourceList.end()) sources_.erase(std::string("HotCell"));
33  }
34 
35  void
37  {
39 
40  MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
41  MESet& meReportSummary(MEs_.at("ReportSummary"));
42  MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
43 
44  for(unsigned iDCC(0); iDCC < nDCC; ++iDCC){
45  int dccid(iDCC + 1);
46  meReportSummaryContents.fill(dccid, -1.);
47  }
48 
49  meReportSummary.fill(-1.);
50 
51  meReportSummaryMap.reset(-1.);
52  }
53 
54  void
56  {
57 
58  MESet& meReportSummaryContents(MEs_.at("ReportSummaryContents"));
59  MESet& meReportSummary(MEs_.at("ReportSummary"));
60 
61  for(unsigned iDCC(0); iDCC < nDCC; ++iDCC){
62  int dccid(iDCC + 1);
63  meReportSummaryContents.fill(dccid, -1.);
64  }
65  meReportSummary.fill(-1.);
66 
67  MESet const& sIntegrityByLumi(sources_.at("IntegrityByLumi"));
68  MESet const& sDesyncByLumi(sources_.at("DesyncByLumi"));
69  MESet const& sFEByLumi(sources_.at("FEByLumi"));
70 
71  double integrityByLumi[nDCC];
72  double rawDataByLumi[nDCC];
73  for(unsigned iDCC(0); iDCC < nDCC; ++iDCC){
74  integrityByLumi[iDCC] = sIntegrityByLumi.getBinContent(iDCC + 1);
75  rawDataByLumi[iDCC] = sDesyncByLumi.getBinContent(iDCC + 1) + sFEByLumi.getBinContent(iDCC + 1);
76  }
77 
78  MESet& meQualitySummary(MEs_.at("QualitySummary"));
79  MESet& meReportSummaryMap(MEs_.at("ReportSummaryMap"));
80 
81  MESet const* sIntegrity(using_("Integrity") ? &sources_.at("Integrity") : 0);
82  MESet const& sRawData(sources_.at("RawData"));
83  MESet const* sPresample(using_("Presample") ? &sources_.at("Presample") : 0);
84  MESet const* sTiming(using_("Timing") ? &sources_.at("Timing") : 0);
85  MESet const* sTriggerPrimitives(using_("TriggerPrimitives") ? &sources_.at("TriggerPrimitives") : 0);
86  MESet const* sHotCell(using_("HotCell") ? &sources_.at("HotCell") : 0);
87 
88  float totalChannels(0.);
89  float totalGood(0.);
90 
91  double dccChannels[nDCC];
92  std::fill_n(dccChannels, nDCC, 0.);
93  double dccGood[nDCC];
94  std::fill_n(dccGood, nDCC, 0.);
95 
96  std::map<uint32_t, int> badChannelsCount;
97 
98  MESet::iterator qEnd(meQualitySummary.end());
99  for(MESet::iterator qItr(meQualitySummary.beginChannel()); qItr != qEnd; qItr.toNextChannel()){
100 
101  DetId id(qItr->getId());
102  unsigned iDCC(dccId(id) - 1);
103 
104  int integrity(sIntegrity ? sIntegrity->getBinContent(id) : kUnknown);
105 
106  if(integrity == kUnknown || integrity == kMUnknown){
107  qItr->setBinContent(integrity);
108  if ( onlineMode_ ) continue;
109  }
110 
111  int presample(sPresample ? sPresample->getBinContent(id) : kUnknown);
112  int hotcell(sHotCell ? sHotCell->getBinContent(id) : kUnknown);
113  int timing(sTiming ? sTiming->getBinContent(id) : kUnknown);
114  int trigprim(sTriggerPrimitives ? sTriggerPrimitives->getBinContent(id) : kUnknown);
115 
116  int rawdata(sRawData.getBinContent(id));
117 
118  if(integrity == kBad && integrityByLumi[iDCC] == 0.) integrity = kGood;
119  if(rawdata == kBad && rawDataByLumi[iDCC] == 0.) rawdata = kGood;
120 
121  int status(kGood);
122  //if(integrity == kBad || presample == kBad || timing == kBad || rawdata == kBad || trigprim == kBad || hotcell == kBad)
123  if(integrity == kBad || timing == kBad || rawdata == kBad || trigprim == kBad || hotcell == kBad)
124  status = kBad;
125  else if(integrity == kUnknown && presample == kUnknown && timing == kUnknown && rawdata == kUnknown && trigprim == kUnknown)
126  status = kUnknown;
127 
128  qItr->setBinContent(status);
129 
130  if(status == kBad){
131  if(id.subdetId() == EcalBarrel) badChannelsCount[EBDetId(id).tower().rawId()] += 1;
132  if(id.subdetId() == EcalEndcap) badChannelsCount[EEDetId(id).sc().rawId()] += 1;
133  }
134  else{
135  dccGood[iDCC] += 1.;
136  totalGood += 1.;
137  }
138  dccChannels[iDCC] += 1.;
139  totalChannels += 1.;
140  }
141 
142  // search clusters of bad towers
143  if(onlineMode_){
144  for(int iz(-1); iz < 2; iz += 2){
145  for(int ieta(0); ieta < 17; ++ieta){
146  if(iz == 1 && ieta == 0) continue;
147  for(int iphi(1); iphi <= 72; ++iphi){
148  EcalTrigTowerDetId ttids[4];
149  unsigned badTowers(0);
150  for(int deta(0); deta < 2; ++deta){
151  int ttz(ieta == 0 && deta == 0 ? -1 : iz);
152  int tteta(ieta == 0 && deta == 0 ? 1 : ieta + deta);
153  for(int dphi(0); dphi < 2; ++dphi){
154  int ttphi(iphi != 72 ? iphi + dphi : 1);
155  EcalTrigTowerDetId ttid(ttz, EcalBarrel, tteta, ttphi);
156  ttids[deta * 2 + dphi] = ttid;
157 
158  if(badChannelsCount[ttid.rawId()] > towerBadFraction_ * 25.)
159  badTowers += 1;
160  }
161  }
162 
163  if(badTowers > 2){
164  for(unsigned iD(0); iD < 4; ++iD)
165  dccGood[dccId(ttids[iD]) - 1] = 0.;
166  }
167  }
168  }
169  }
170  for(int iz(-1); iz <= 1; iz += 2){
171  for(int ix(1); ix < 20; ++ix){
172  for(int iy(1); iy < 20; ++iy){
173  EcalScDetId scids[4];
174  unsigned badTowers(0);
175  for(int dx(0); dx < 2; ++dx){
176  for(int dy(0); dy < 2; ++dy){
177  if(!EcalScDetId::validDetId(ix + dx, iy + dy, iz)){
178  scids[dx * 2 + dy] = EcalScDetId(0);
179  continue;
180  }
181  EcalScDetId scid(ix + dx, iy + dy, iz);
182  scids[dx * 2 + dy] = scid;
183 
184  if(badChannelsCount[scid.rawId()] > towerBadFraction_ * scConstituents(scid).size())
185  badTowers += 1;
186  }
187  }
188 
189  // contiguous towers bad -> [(00)(11)] [(11)(00)] [(01)(01)] [(10)(10)] []=>x ()=>y
190  if(badTowers > 2){
191  for(unsigned iD(0); iD < 4; ++iD){
192  EcalScDetId& scid(scids[iD]);
193  if(scid.null()) continue;
194  dccGood[dccId(scid) - 1] = 0.;
195  }
196  }
197  }
198  }
199  }
200  }
201 
202  double nBad(0.);
203  for(unsigned iDCC(0); iDCC < nDCC; ++iDCC){
204  if(dccChannels[iDCC] < 1.) continue;
205 
206  int dccid(iDCC + 1);
207  float frac(dccGood[iDCC] / dccChannels[iDCC]);
208  meReportSummaryMap.setBinContent(dccid, frac);
209  meReportSummaryContents.fill(dccid, frac);
210 
211  if(1. - frac > fedBadFraction_) nBad += 1.;
212  }
213 
214  if(totalChannels > 0.) meReportSummary.fill(totalGood / totalChannels);
215 
216  if(onlineMode_){
217  if(totalChannels > 0.) MEs_.at("GlobalSummary").setBinContent(1, totalGood / totalChannels);
218  MEs_.at("NBadFEDs").setBinContent(1, nBad);
219  }
220  }
221 
223 }
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:64
void setParams(edm::ParameterSet const &) override
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
bool using_(std::string const &_name, ProcessType _type=kJob) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator & toNextChannel()
Definition: MESet.h:271
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void resetMEs() override
void producePlots(ProcessType) override
std::set< std::string > qualitySummaries_
virtual double getBinContent(DetId const &, int=0) const
Definition: MESet.h:72
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:59
MESetCollection sources_
Definition: DetId.h:18
bool null() const
is this a null id ?
Definition: DetId.h:45
MESetCollection MEs_
Definition: DQWorker.h:75
EcalScDetId sc() const
Definition: EEDetId.h:88
std::vector< DetId > scConstituents(EcalScDetId const &)
dictionary rawdata
Definition: lumiPlot.py:393
unsigned dccId(DetId const &)
tuple status
Definition: mps_update.py:57