CMS 3D CMS Logo

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