CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBDataCertificationTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBDataCertificationTask.cc
3  *
4  * \author E. Di Marco
5  *
6 */
7 
8 #include <iostream>
9 #include <algorithm>
10 
15 
18 
20 
23 
25 
27 
29 
30  // cloneME switch
31  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
32 
33  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
34 
35  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
36 
37  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
38 
41  for (int i = 0; i < 36; i++) {
43  }
44 
45  hDQM_ = 0;
46  hDAQ_ = 0;
47  hDCS_ = 0;
49  hFrontendByLumi_ = 0;
51 
52 }
53 
55 
56 }
57 
59 
61 
62  if ( dqmStore_ ) {
63 
64  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
65 
66  name = "CertificationSummary";
69 
70  name = "CertificationSummaryMap";
71  meEBDataCertificationSummaryMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
74 
75  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
76 
77  for (int i = 0; i < 36; i++) {
78  name = "EcalBarrel_" + Numbers::sEB(i+1);
81  }
82 
83  }
84 
85 }
86 
88 
89  if ( enableCleanup_ ) this->cleanup();
90 
91 }
92 
94 
95 }
96 
98 
99  this->reset();
100 
101  MonitorElement* me;
102 
103  // evaluate the DQM quality of observables checked by lumi
104  float DQMVal[36];
105  for (int i = 0; i < 36; i++) {
106  DQMVal[i] = -1.;
107  }
108 
109  me = dqmStore_->get(prefixME_ + "/EBIntegrityTask/EBIT weighted integrity errors by lumi");
110  hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );
111 
112  me = dqmStore_->get(prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT weighted frontend errors by lumi");
113  hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );
114 
115  me = dqmStore_->get(prefixME_ + "/EBRawDataTask/EBRDT FE synchronization errors by lumi");
116  hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );
117 
119 
120  float integrityErrSum = 0.;
121  float integrityQual = 1.0;
122  float frontendErrSum = 0.;
123  float frontendQual = 1.0;
124  float synchronizationErrSum = 0.;
125  float synchronizationQual = 1.0;
126 
127  for ( int i=0; i<36; i++) {
128  float ismIntegrityQual = 1.0;
129  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
130  float errors = hIntegrityByLumi_->GetBinContent(i+1);
131  ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
132  integrityErrSum += errors;
133  }
134  float ismFrontendQual = 1.0;
135  if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
136  float errors = hFrontendByLumi_->GetBinContent(i+1);
137  ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
138  frontendErrSum += errors;
139  }
140  float ismSynchronizationQual = 1.0;
141  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
142  float errors = hSynchronizationByLumi_->GetBinContent(i+1);
143  ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
144  synchronizationErrSum += errors;
145  }
146  float minVal= std::min(ismIntegrityQual,ismFrontendQual);
147  DQMVal[i] = std::min(minVal,ismSynchronizationQual);
148  }
149 
150  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/36.;
151  if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/36.;
152  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
153  float minVal = std::min(integrityQual,frontendQual);
154  float totDQMVal = std::min(minVal,synchronizationQual);
155 
156  me = dqmStore_->get((prefixME_ + "/EventInfo/reportSummary"));
157  if( me ) me->Fill(totDQMVal);
158  for ( int i=0; i<36; i++) {
159  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/EcalBarrel_" + Numbers::sEB(i+1) ) ;
160  if( me ) me->Fill(DQMVal[i]);
161 
162  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
163  if( me ) {
164  for ( int iett = 0; iett < 34; iett++ ) {
165  for ( int iptt = 0; iptt < 72; iptt++ ) {
166  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
167  if( i == (ism-1) ) me->setBinContent(iptt+1, iett+1, DQMVal[ism-1]);
168  }
169  }
170  }
171  }
172 
173  }
174 
175  // now combine reduced DQM with DCS and DAQ
176  me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
177  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
178 
179  me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
180  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
181 
182  float sumCert = 0.;
183  float sumCertEB[36];
184  int nValidChannels = 0;
185  int nValidChannelsEB[36];
186 
187  for (int i = 0; i < 36; i++) {
188  sumCertEB[i] = 0.;
189  nValidChannelsEB[i] = 0;
190  }
191 
192  for ( int iett = 0; iett < 34; iett++ ) {
193  for ( int iptt = 0; iptt < 72; iptt++ ) {
194 
195  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
196 
197  float xvalDQM = DQMVal[ism-1];
198 
199  float xvalDAQ, xvalDCS;
200  xvalDAQ = xvalDCS = -1.;
201  float xcert = -1.;
202 
203  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
204  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
205 
206  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
207  // problems: DQM empty or DAQ and DCS not available
208  xcert = 0.0;
209  } else {
210  // do not consider the white value of DAQ and DCS (problems with DB)
211  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
212  }
213 
215 
216  sumCertEB[ism-1] += xcert;
217  nValidChannelsEB[ism-1]++;
218 
219  sumCert += xcert;
220  nValidChannels++;
221 
222  }
223  }
224 
226  if( nValidChannels>0 ) meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
227  else meEBDataCertificationSummary_->Fill( 0.0 );
228  }
229 
230  for (int i = 0; i < 36; i++) {
231  if( meEBDataCertification_[i] ) {
232  if( nValidChannelsEB[i]>0 ) meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
233  else meEBDataCertification_[i]->Fill( 0.0 );
234  }
235  }
236 
237 }
238 
240 
241  if ( ! mergeRuns_ ) this->reset();
242 
243 }
244 
246 
247  this->reset();
248 
249  MonitorElement* me;
250 
251  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
252  hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );
253 
254  me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
255  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
256 
257  me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
258  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
259 
260  float sumCert = 0.;
261  float sumCertEB[36];
262  int nValidChannels = 0;
263  int nValidChannelsEB[36];
264 
265  for (int i = 0; i < 36; i++) {
266  sumCertEB[i] = 0.;
267  nValidChannelsEB[i] = 0;
268  }
269 
270  for ( int iett = 0; iett < 34; iett++ ) {
271  for ( int iptt = 0; iptt < 72; iptt++ ) {
272 
273  float xvalDQM, xvalDAQ, xvalDCS;
274  xvalDQM = xvalDAQ = xvalDCS = -1.;
275  float xcert = -1;
276 
277  if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( iptt+1, iett+1 );
278  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
279  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
280 
281  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
282  // problems: DQM empty or DAQ and DCS not available
283  xcert = 0.0;
284  } else {
285  // do not consider the white value of DAQ and DCS (problems with DB)
286  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
287  }
288 
290 
291  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
292 
293  sumCertEB[ism-1] += xcert;
294  nValidChannelsEB[ism-1]++;
295 
296  sumCert += xcert;
297  nValidChannels++;
298 
299  }
300  }
301 
303  if( nValidChannels>0 ) {
304  meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
305  } else {
307  }
308  }
309 
310  for (int i = 0; i < 36; i++) {
311  if( meEBDataCertification_[i] ) {
312  if( nValidChannelsEB[i]>0 ) {
313  meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
314  } else {
315  meEBDataCertification_[i]->Fill( 0.0 );
316  }
317  }
318  }
319 
320 }
321 
323 
325 
326  for (int i = 0; i < 36; i++) {
328  }
329 
331 
332 }
333 
334 
336 
337  if ( cloneME_ ) {
338  if( hDQM_ ) delete hDQM_;
339  if( hDAQ_ ) delete hDAQ_;
340  if( hDCS_ ) delete hDCS_;
342  if( hFrontendByLumi_ ) delete hFrontendByLumi_;
344  }
345  hDQM_ = 0;
346  hDAQ_ = 0;
347  hDCS_ = 0;
348  hIntegrityByLumi_ = 0;
349  hFrontendByLumi_ = 0;
351 
352  if ( dqmStore_ ) {
353  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
356 
357  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
358  for (int i = 0; i < 36; i++) {
360  }
361  }
362 
363 }
364 
366 
367 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
void setBinContent(int binx, double content)
set content of bin (1-D)
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
MonitorElement * meEBDataCertificationSummary_
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:810
void Fill(long long x)
MonitorElement * meEBDataCertificationSummaryMap_
void removeElement(const std::string &name)
Definition: DQMStore.cc:2773
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
Ecal Monitor Utils for Client.
MonitorElement * meEBDataCertification_[36]
virtual ~EBDataCertificationTask()
Destructor.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1001
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
Definition: Run.h:41
EBDataCertificationTask(const edm::ParameterSet &ps)
Constructor.