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_));
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(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(ttid, tMax);
76  if (towerEntries < minEntries_) {
77  meEmulQualitySummary.setBinContent(ttid, doMask ? kMUnknown : kUnknown);
78  continue;
79  }
80 
81  float nonsingleFraction(1. - nMax / towerEntries);
82 
83  if (nonsingleFraction > 0.) {
84  meNonSingleSummary->setBinContent(ttid, nonsingleFraction);
85  }
86 
87  if (sEtEmulError->getBinContent(ttid) / towerEntries > errorFractionThreshold_) {
88  meEmulQualitySummary.setBinContent(ttid, doMask ? kMBad : kBad);
89  } else {
90  meEmulQualitySummary.setBinContent(ttid, doMask ? kMGood : kGood);
91  }
92  }
93 
94  // Keep count for Occupancy analysis
95  unsigned iDCC(dccId(ttid) - 1);
96  Nentries[iDCC] += sTPDigiThrAll.getBinContent(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) - 1);
116  bool isMasked(sTTMaskMapAll.getBinContent(ttid) > 0.);
117  bool hasTTF4(sTTFlags4.getBinContent(ttid) > 0.);
118  bool hasTTF4InThisLumiSection(sTTFlags4ByLumi.getBinContent(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(ttid, 12); // Masked, has TTF4
129  } else {
130  meTTF4vMask.setBinContent(ttid, 11); // Masked, no TTF4
131  }
132  if (hasTTF4InThisLumiSection) {
133  meTTF4vMaskByLumi.setBinContent(ttid, 12); // Masked, has TTF4
134  } else {
135  meTTF4vMaskByLumi.setBinContent(ttid, 11); // Masked, no TTF4
136  }
137  } else {
138  if (hasTTF4)
139  meTTF4vMask.setBinContent(ttid, 13); // not Masked, has TTF4
140  if (hasTTF4InThisLumiSection)
141  meTTF4vMaskByLumi.setBinContent(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(EcalBarrel, double(timestamp_.iLumi), nWithTTF4_EB);
147  meTrendTTF4Flags.fill(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) - 1);
157  if (sTTFMismatch.getBinContent(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) - 1);
165  if (nTTFMismath[iDCC] > 0.8 * nTTs[iDCC] || nWithTTF4[iDCC] > TTF4MaskingAlarmThreshold_ * nTTs[iDCC]) {
166  meEmulQualitySummary.setBinContent(ttid,
167  meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad);
168  }
169  }
170 
171  // Quality check: set entire FED to BAD if its occupancy begins to vanish
172  // Fill FED statistics from TP digi occupancy
173  float meanFEDEB(0.), meanFEDEE(0.), rmsFEDEB(0.), rmsFEDEE(0.);
174  unsigned int nFEDEB(0), nFEDEE(0);
175  for (unsigned iDCC(0); iDCC < nDCC; iDCC++) {
176  if (iDCC >= kEBmLow && iDCC <= kEBpHigh) {
177  meanFEDEB += Nentries[iDCC];
178  rmsFEDEB += Nentries[iDCC] * Nentries[iDCC];
179  nFEDEB++;
180  } else {
181  meanFEDEE += Nentries[iDCC];
182  rmsFEDEE += Nentries[iDCC] * Nentries[iDCC];
183  nFEDEE++;
184  }
185  }
186  meanFEDEB /= float(nFEDEB);
187  rmsFEDEB /= float(nFEDEB);
188  meanFEDEE /= float(nFEDEE);
189  rmsFEDEE /= float(nFEDEE);
190  rmsFEDEB = sqrt(std::abs(rmsFEDEB - meanFEDEB * meanFEDEB));
191  rmsFEDEE = sqrt(std::abs(rmsFEDEE - meanFEDEE * meanFEDEE));
192  // Analyze FED statistics
193  float meanFED(0.), rmsFED(0.), nRMS(5.);
194  for (unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
196  unsigned iDCC(dccId(ttid) - 1);
197  if (iDCC >= kEBmLow && iDCC <= kEBpHigh) {
198  meanFED = meanFEDEB;
199  rmsFED = rmsFEDEB;
200  } else {
201  meanFED = meanFEDEE;
202  rmsFED = rmsFEDEE;
203  }
204  float threshold(meanFED < nRMS * rmsFED ? minEntries_ : meanFED - nRMS * rmsFED);
205  if ((meanFED > 100. && Nentries[iDCC] < threshold) && statsCheckEnabled)
206  meEmulQualitySummary.setBinContent(ttid,
207  meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad);
208  }
209 
210  } // producePlots()
211 
213 } // namespace ecaldqm
ecaldqm::TrigPrimClient
Definition: TrigPrimClient.h:7
ecaldqm::TrigPrimClient::setParams
void setParams(edm::ParameterSet const &) override
Definition: TrigPrimClient.cc:18
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ecaldqm
Definition: DQWorker.h:24
ecaldqm::TrigPrimClient::TrigPrimClient
TrigPrimClient()
Definition: TrigPrimClient.cc:13
ecaldqm::MESetNonObject
Definition: MESetNonObject.h:7
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
ecaldqm::TrigPrimClient::errorFractionThreshold_
float errorFractionThreshold_
Definition: TrigPrimClient.h:18
ecaldqm::DQWorkerClient::statusManager_
StatusManager const * statusManager_
Definition: DQWorkerClient.h:60
TrigPrimClient.h
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
ecaldqm::TrigPrimClient::sourceFromEmul_
bool sourceFromEmul_
Definition: TrigPrimClient.h:21
EcalBarrel
Definition: EcalSubdetector.h:10
EcalDQMStatusHelper.h
ecaldqm::MESet::getBinContent
virtual double getBinContent(DetId const &, int=0) const
Definition: MESet.h:72
ecaldqm::DQWorkerClient::qualitySummaries_
std::set< std::string > qualitySummaries_
Definition: DQWorkerClient.h:56
EcalTrigTowerDetId::kSizeForDenseIndexing
Definition: EcalTrigTowerDetId.h:119
ecaldqm::TrigPrimClient::minEntries_
int minEntries_
Definition: TrigPrimClient.h:17
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ecaldqm::DQWorkerClient::ProcessType
ProcessType
Definition: DQWorkerClient.h:15
ecaldqm::TrigPrimClient::producePlots
void producePlots(ProcessType) override
Definition: TrigPrimClient.cc:31
ecaldqm::kEBpHigh
Definition: EcalDQMCommonUtils.h:88
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
ecaldqm::DQWorkerClient::kMBad
Definition: DQWorkerClient.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::DQWorkerClient::kUnknown
Definition: DQWorkerClient.h:37
ecaldqm::DQWorkerClient::kBad
Definition: DQWorkerClient.h:37
ecaldqm::DQWorkerClient::sources_
MESetCollection sources_
Definition: DQWorkerClient.h:55
ecaldqm::DQWorkerClient::kMGood
Definition: DQWorkerClient.h:37
edm::ParameterSet
Definition: ParameterSet.h:47
ecaldqm::MESetCollection::at
MESet & at(const std::string &key)
Definition: MESet.h:362
ecaldqm::TrigPrimClient::TTF4MaskingAlarmThreshold_
float TTF4MaskingAlarmThreshold_
Definition: TrigPrimClient.h:19
ecaldqm::DQWorkerClient::kMUnknown
Definition: DQWorkerClient.h:37
ecaldqm::MESetCollection::erase
void erase(const std::string &key)
Definition: MESet.h:353
ecaldqm::kEBmLow
Definition: EcalDQMCommonUtils.h:85
ecaldqm::DQWorkerClient
Definition: DQWorkerClient.h:13
EcalTrigTowerDetId::subDet
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
Definition: EcalTrigTowerDetId.h:33
EcalDQMStatusHelper::PHYSICS_BAD_CHANNEL_WARNING
static const int PHYSICS_BAD_CHANNEL_WARNING
Definition: EcalDQMStatusHelper.h:46
ecaldqm::DQWorker::Timestamp::iLumi
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
ecaldqm::MESet::setBinContent
virtual void setBinContent(DetId const &, double)
Definition: MESet.h:51
ecaldqm::DQWorkerClient::kGood
Definition: DQWorkerClient.h:37
ecaldqm::DQWorker::timestamp_
Timestamp timestamp_
Definition: DQWorker.h:81
EcalTrigTowerDetId::detIdFromDenseIndex
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
Definition: EcalTrigTowerDetId.cc:104
MESetNonObject.h
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
metDiagnosticParameterSet_cfi.nMax
nMax
Definition: metDiagnosticParameterSet_cfi.py:11
EcalDQMCommonUtils.h
ecaldqm::MESet
Definition: MESet.h:27
ecaldqm::dccId
unsigned dccId(DetId const &)
Definition: EcalDQMCommonUtils.cc:16