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