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