CMS 3D CMS Logo

PresampleClient.cc
Go to the documentation of this file.
2 
4 
7 
9 
10 #include <cmath>
11 
12 namespace ecaldqm {
14  : DQWorkerClient(),
15  minChannelEntries_(0),
16  expectedMean_(0.),
17  toleranceLow_(0.),
18  toleranceHigh_(0.),
19  toleranceRMS_(0.),
20  toleranceRMSFwd_(0.) {
21  qualitySummaries_.insert("Quality");
22  qualitySummaries_.insert("QualitySummary");
23  }
24 
26  minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
27  expectedMean_ = _params.getUntrackedParameter<double>("expectedMean");
28  toleranceLow_ = _params.getUntrackedParameter<double>("toleranceLow");
29  toleranceHigh_ = _params.getUntrackedParameter<double>("toleranceHigh");
30  toleranceRMS_ = _params.getUntrackedParameter<double>("toleranceRMS");
31  toleranceRMSFwd_ = _params.getUntrackedParameter<double>("toleranceRMSFwd");
32  }
33 
35  MESet& meQualitySummary(MEs_.at("QualitySummary"));
36  MESet& meQuality(MEs_.at("Quality"));
37  MESet& meErrorsSummary(MEs_.at("ErrorsSummary"));
38  MESet& meMean(MEs_.at("Mean"));
39  MESet& meRMS(MEs_.at("RMS"));
40  MESet& meRMSMap(MEs_.at("RMSMap"));
41  MESet& meRMSMapAll(MEs_.at("RMSMapAll"));
42  MESet& meRMSMapAllByLumi(MEs_.at("RMSMapAllByLumi"));
43  MESet& meMeanMapAll(MEs_.at("MeanMapAll"));
44 
45  MESet const& sPedestal(sources_.at("Pedestal"));
46  MESet const& sPedestalByLS(sources_.at("PedestalByLS"));
47  MESet const& sChStatus(sources_.at("ChStatus"));
48 
51 
52  MESet::iterator qEnd(meQuality.end(GetElectronicsMap()));
53 
54  MESet::const_iterator pItr(GetElectronicsMap(), sPedestal);
55  MESet::const_iterator pLSItr(GetElectronicsMap(), sPedestalByLS);
56  double maxEB(0.), minEB(0.), maxEE(0.), minEE(0.);
57  double rmsMaxEB(0.), rmsMaxEE(0.);
58  for (MESet::iterator qItr(meQuality.beginChannel(GetElectronicsMap())); qItr != qEnd;
60  pItr = qItr;
61  pLSItr = qItr;
62 
63  DetId id(qItr->getId());
64 
65  bool doMask(meQuality.maskMatches(id, mask, statusManager_, GetTrigTowerMap()));
66 
67  double rmsThresh(toleranceRMS_);
68 
69  if (isForward(id))
70  rmsThresh = toleranceRMSFwd_;
71 
72  double entries(pItr->getBinEntries());
73  double entriesLS(pLSItr->getBinEntries());
74 
75  if (entries < minChannelEntries_) {
76  qItr->setBinContent(doMask ? kMUnknown : kUnknown);
77  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMUnknown : kUnknown);
78  meRMSMap.setBinContent(getEcalDQMSetupObjects(), id, -1.);
79  continue;
80  }
81 
82  double mean(pItr->getBinContent());
83  double meanLS(pLSItr->getBinContent());
84  double rms(pItr->getBinError() * std::sqrt(entries));
85  double rmsLS(pLSItr->getBinError() * std::sqrt(entriesLS));
86 
87  int dccid(dccId(id, GetElectronicsMap()));
88 
89  meMean.fill(getEcalDQMSetupObjects(), dccid, mean);
90  meRMS.fill(getEcalDQMSetupObjects(), dccid, rms);
91  meRMSMap.setBinContent(getEcalDQMSetupObjects(), id, rms);
92  meRMSMapAllByLumi.setBinContent(getEcalDQMSetupObjects(), id, rmsLS);
93 
94  if (((mean > expectedMean_ + toleranceHigh_) || (mean < expectedMean_ - toleranceLow_)) || rms > rmsThresh) {
95  qItr->setBinContent(doMask ? kMBad : kBad);
96  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMBad : kBad);
97  if (!doMask)
98  meErrorsSummary.fill(getEcalDQMSetupObjects(), id);
99  } else {
100  qItr->setBinContent(doMask ? kMGood : kGood);
101  meQualitySummary.setBinContent(getEcalDQMSetupObjects(), id, doMask ? kMGood : kGood);
102  }
103 
104  // Fill Presample Trend plots:
105  // Use PedestalByLS which only contains digis from "current" LS
106  float chStatus(sChStatus.getBinContent(getEcalDQMSetupObjects(), id));
107  if (entriesLS < minChannelEntries_)
108  continue;
109  if (chStatus != EcalChannelStatusCode::kOk)
110  continue; // exclude problematic channels
111 
112  // Get max/min
113  // Min is effectively just 0
114  if (id.subdetId() == EcalBarrel) {
115  if (meanLS > maxEB)
116  maxEB = meanLS;
117  if (meanLS < minEB)
118  minEB = meanLS;
119  if (rmsLS > rmsMaxEB)
120  rmsMaxEB = rmsLS;
121  } else {
122  if (meanLS > maxEE)
123  maxEE = meanLS;
124  if (meanLS < minEE)
125  minEE = meanLS;
126  if (rmsLS > rmsMaxEE)
127  rmsMaxEE = rmsLS;
128  }
129 
130  } // qItr
131 
132  towerAverage_(meRMSMapAll, meRMSMap, -1.);
133  towerAverage_(meMeanMapAll, sPedestal, -1.);
134 
135  MESet& meTrendMean(MEs_.at("TrendMean"));
136  MESet& meTrendRMS(MEs_.at("TrendRMS"));
137  meTrendMean.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), maxEB - minEB);
138  meTrendMean.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), maxEE - minEE);
139  meTrendRMS.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), rmsMaxEB);
140  meTrendRMS.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), rmsMaxEE);
141  }
142 
144 } // namespace ecaldqm
double getBinContent() const
Definition: MESet.h:192
void towerAverage_(MESet &, MESet const &, float)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
MESet & at(const std::string &key)
Definition: MESet.h:399
const_iterator & toNextChannel(EcalElectronicsMapping const *electronicsMap)
Definition: MESet.h:320
bool isForward(DetId const &)
static const int PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR
constexpr uint32_t mask
Definition: gpuClustering.h:24
void setParams(edm::ParameterSet const &) override
std::set< std::string > qualitySummaries_
T sqrt(T t)
Definition: SSEVec.h:19
double getBinEntries() const
Definition: MESet.h:204
StatusManager const * statusManager_
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
virtual void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:74
MESetCollection sources_
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
Timestamp timestamp_
Definition: DQWorker.h:134
static const int PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR
MESetCollection MEs_
Definition: DQWorker.h:131
EcalTrigTowerConstituentsMap const * GetTrigTowerMap()
Definition: DQWorker.cc:155
void producePlots(ProcessType) override
double getBinError() const
Definition: MESet.h:198