CMS 3D CMS Logo

TrigPrimClient.cc
Go to the documentation of this file.
2 
5 
7 
9 
10 #include <cmath>
11 
12 namespace ecaldqm {
14  : DQWorkerClient(), minEntries_(0), errorFractionThreshold_(0.), TTF4MaskingAlarmThreshold_(0.) {
15  qualitySummaries_.insert("EmulQualitySummary");
16  }
17 
19  minEntries_ = _params.getUntrackedParameter<int>("minEntries");
20  errorFractionThreshold_ = _params.getUntrackedParameter<double>("errorFractionThreshold");
21  TTF4MaskingAlarmThreshold_ = _params.getUntrackedParameter<double>("TTF4MaskingAlarmThreshold");
22  sourceFromEmul_ = _params.getUntrackedParameter<bool>("sourceFromEmul");
23  if (!sourceFromEmul_) {
24  MEs_.erase(std::string("NonSingleSummary"));
25  MEs_.erase(std::string("TimingSummary"));
26  sources_.erase(std::string("EtEmulError"));
27  sources_.erase(std::string("MatchedIndex"));
28  }
29  }
30 
32  MESet* meNonSingleSummary = nullptr;
33  MESet* meTimingSummary = nullptr;
34  MESet* sEtEmulError = nullptr;
35  MESet* sMatchedIndex = nullptr;
36 
37  MESet& meEmulQualitySummary(MEs_.at("EmulQualitySummary"));
38  MESet& meTrendTTF4Flags(MEs_.at("TrendTTF4Flags"));
39 
40  MESet const& sTPDigiThrAll(sources_.at("TPDigiThrAll"));
41  MESetNonObject const& sLHCStatusByLumi(static_cast<MESetNonObject&>(sources_.at("LHCStatusByLumi")));
42 
44 
45  // Store # of entries for Occupancy analysis
46  std::vector<float> Nentries(nDCC, 0.);
47 
48  double currentLHCStatus = sLHCStatusByLumi.getFloatValue();
49  bool statsCheckEnabled =
50  ((currentLHCStatus > 10.5 && currentLHCStatus < 11.5) ||
51  currentLHCStatus < 0); // currentLHCStatus = -1 is the default when no beam info is available
52 
53  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
55 
56  bool doMask(meEmulQualitySummary.maskMatches(ttid, mask, statusManager_, GetTrigTowerMap()));
57 
58  if (sourceFromEmul_) {
59  sEtEmulError = &sources_.at("EtEmulError");
60  sMatchedIndex = &sources_.at("MatchedIndex");
61  meNonSingleSummary = &MEs_.at("NonSingleSummary");
62  meTimingSummary = &MEs_.at("TimingSummary");
63  float towerEntries(0.);
64  float tMax(0.5);
65  float nMax(0.);
66  for (int iBin(0); iBin < 6; iBin++) {
67  float entries(sMatchedIndex->getBinContent(getEcalDQMSetupObjects(), ttid, iBin + 1));
68  towerEntries += entries;
69 
70  if (entries > nMax) {
71  nMax = entries;
72  tMax = iBin == 0 ? -0.5 : iBin + 0.5; // historical reasons.. much clearer to say "no entry = -0.5"
73  }
74  }
75  meTimingSummary->setBinContent(getEcalDQMSetupObjects(), ttid, tMax);
76  if (towerEntries < minEntries_) {
77  meEmulQualitySummary.setBinContent(getEcalDQMSetupObjects(), ttid, doMask ? kMUnknown : kUnknown);
78  continue;
79  }
80 
81  float nonsingleFraction(1. - nMax / towerEntries);
82 
83  if (nonsingleFraction > 0.) {
84  meNonSingleSummary->setBinContent(getEcalDQMSetupObjects(), ttid, nonsingleFraction);
85  }
86 
87  if (sEtEmulError->getBinContent(getEcalDQMSetupObjects(), ttid) / towerEntries > errorFractionThreshold_) {
88  meEmulQualitySummary.setBinContent(getEcalDQMSetupObjects(), ttid, doMask ? kMBad : kBad);
89  } else {
90  meEmulQualitySummary.setBinContent(getEcalDQMSetupObjects(), ttid, doMask ? kMGood : kGood);
91  }
92  }
93 
94  // Keep count for Occupancy analysis
95  unsigned iDCC(dccId(ttid, GetElectronicsMap()) - 1);
96  Nentries[iDCC] += sTPDigiThrAll.getBinContent(getEcalDQMSetupObjects(), ttid);
97  }
98 
99  // Fill TTF4 v Masking ME
100  // NOT an occupancy plot: only tells you if non-zero TTF4 occupancy was seen
101  // without giving info about how many were seen
102  MESet& meTTF4vMask(MEs_.at("TTF4vMask"));
103  MESet& meTTF4vMaskByLumi(MEs_.at("TTF4vMaskByLumi"));
104  MESet const& sTTFlags4(sources_.at("TTFlags4"));
105  MESet const& sTTFlags4ByLumi(sources_.at("TTFlags4ByLumi"));
106  MESet const& sTTMaskMapAll(sources_.at("TTMaskMapAll"));
107 
108  std::vector<float> nWithTTF4(nDCC,
109  0.); // counters to keep track of number of towers in a DCC that have TTF4 flag set
110  int nWithTTF4_EE = 0; // total number of towers in EE with TTF4
111  int nWithTTF4_EB = 0; // total number of towers in EB with TTF4
112  // Loop over all TTs
113  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
115  unsigned iDCC(dccId(ttid, GetElectronicsMap()) - 1);
116  bool isMasked(sTTMaskMapAll.getBinContent(getEcalDQMSetupObjects(), ttid) > 0.);
117  bool hasTTF4(sTTFlags4.getBinContent(getEcalDQMSetupObjects(), ttid) > 0.);
118  bool hasTTF4InThisLumiSection(sTTFlags4ByLumi.getBinContent(getEcalDQMSetupObjects(), ttid) > 0.);
119  if (hasTTF4InThisLumiSection) {
120  nWithTTF4[iDCC]++;
121  if (ttid.subDet() == EcalBarrel)
122  nWithTTF4_EB++;
123  else if (ttid.subDet() == EcalEndcap)
124  nWithTTF4_EE++;
125  }
126  if (isMasked) {
127  if (hasTTF4) {
128  meTTF4vMask.setBinContent(getEcalDQMSetupObjects(), ttid, 12); // Masked, has TTF4
129  } else {
130  meTTF4vMask.setBinContent(getEcalDQMSetupObjects(), ttid, 11); // Masked, no TTF4
131  }
132  if (hasTTF4InThisLumiSection) {
133  meTTF4vMaskByLumi.setBinContent(getEcalDQMSetupObjects(), ttid, 12); // Masked, has TTF4
134  } else {
135  meTTF4vMaskByLumi.setBinContent(getEcalDQMSetupObjects(), ttid, 11); // Masked, no TTF4
136  }
137  } else {
138  if (hasTTF4)
139  meTTF4vMask.setBinContent(getEcalDQMSetupObjects(), ttid, 13); // not Masked, has TTF4
140  if (hasTTF4InThisLumiSection)
141  meTTF4vMaskByLumi.setBinContent(getEcalDQMSetupObjects(), ttid, 13); // not Masked, has TTF4
142  }
143  } // TT loop
144 
145  // Fill trend plots for number of TTs with TTF4 flag set
146  meTrendTTF4Flags.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), nWithTTF4_EB);
147  meTrendTTF4Flags.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), nWithTTF4_EE);
148 
149  // Quality check: set an entire FED to BAD if a more than 80% of the TTs in that FED show any DCC-SRP flag mismatch errors
150  // Fill flag mismatch statistics
151  std::vector<float> nTTs(nDCC, 0.);
152  std::vector<float> nTTFMismath(nDCC, 0.);
153  MESet const& sTTFMismatch(sources_.at("TTFMismatch"));
154  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
156  unsigned iDCC(dccId(ttid, GetElectronicsMap()) - 1);
157  if (sTTFMismatch.getBinContent(getEcalDQMSetupObjects(), ttid) > 0.)
158  nTTFMismath[iDCC]++;
159  nTTs[iDCC]++;
160  }
161  // Analyze flag mismatch statistics and TTF4 fraction statistics
162  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
164  unsigned iDCC(dccId(ttid, GetElectronicsMap()) - 1);
165  if (nTTFMismath[iDCC] > 0.8 * nTTs[iDCC] || nWithTTF4[iDCC] > TTF4MaskingAlarmThreshold_ * nTTs[iDCC]) {
166  meEmulQualitySummary.setBinContent(
168  ttid,
169  meEmulQualitySummary.maskMatches(ttid, mask, statusManager_, GetTrigTowerMap()) ? kMBad : kBad);
170  }
171  }
172 
173  // Quality check: set entire FED to BAD if its occupancy begins to vanish
174  // Fill FED statistics from TP digi occupancy
175  float meanFEDEB(0.), meanFEDEE(0.), rmsFEDEB(0.), rmsFEDEE(0.);
176  unsigned int nFEDEB(0), nFEDEE(0);
177  for (unsigned iDCC(0); iDCC < nDCC; iDCC++) {
178  if (iDCC >= kEBmLow && iDCC <= kEBpHigh) {
179  meanFEDEB += Nentries[iDCC];
180  rmsFEDEB += Nentries[iDCC] * Nentries[iDCC];
181  nFEDEB++;
182  } else {
183  meanFEDEE += Nentries[iDCC];
184  rmsFEDEE += Nentries[iDCC] * Nentries[iDCC];
185  nFEDEE++;
186  }
187  }
188  meanFEDEB /= float(nFEDEB);
189  rmsFEDEB /= float(nFEDEB);
190  meanFEDEE /= float(nFEDEE);
191  rmsFEDEE /= float(nFEDEE);
192  rmsFEDEB = sqrt(std::abs(rmsFEDEB - meanFEDEB * meanFEDEB));
193  rmsFEDEE = sqrt(std::abs(rmsFEDEE - meanFEDEE * meanFEDEE));
194  // Analyze FED statistics
195  float meanFED(0.), rmsFED(0.), nRMS(5.);
196  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
198  unsigned iDCC(dccId(ttid, GetElectronicsMap()) - 1);
199  if (iDCC >= kEBmLow && iDCC <= kEBpHigh) {
200  meanFED = meanFEDEB;
201  rmsFED = rmsFEDEB;
202  } else {
203  meanFED = meanFEDEE;
204  rmsFED = rmsFEDEE;
205  }
206  float threshold(meanFED < nRMS * rmsFED ? minEntries_ : meanFED - nRMS * rmsFED);
207  if ((meanFED > 100. && Nentries[iDCC] < threshold) && statsCheckEnabled)
208  meEmulQualitySummary.setBinContent(
210  ttid,
211  meEmulQualitySummary.maskMatches(ttid, mask, statusManager_, GetTrigTowerMap()) ? kMBad : kBad);
212  }
213 
214  } // producePlots()
215 
217 } // namespace ecaldqm
virtual void setBinContent(EcalDQMSetupObjects const, DetId const &, double)
Definition: MESet.h:79
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
static const int PHYSICS_BAD_CHANNEL_WARNING
MESet & at(const std::string &key)
Definition: MESet.h:399
void producePlots(ProcessType) override
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
void setParams(edm::ParameterSet const &) override
virtual double getBinContent(EcalDQMSetupObjects const, DetId const &, int=0) const
Definition: MESet.h:100
std::set< std::string > qualitySummaries_
T sqrt(T t)
Definition: SSEVec.h:19
StatusManager const * statusManager_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
MESetCollection sources_
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Timestamp timestamp_
Definition: DQWorker.h:134
MESetCollection MEs_
Definition: DQWorker.h:131
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:155
void erase(const std::string &key)
Definition: MESet.h:390