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  * $Date: 2012/04/27 13:46:02 $
5  * $Revision: 1.33 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 #include <algorithm>
12 
17 
20 
22 
25 
27 
29 
31 
32  // cloneME switch
33  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
34 
35  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
36 
37  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
38 
39  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
40 
43  for (int i = 0; i < 36; i++) {
45  }
46 
47  hDQM_ = 0;
48  hDAQ_ = 0;
49  hDCS_ = 0;
51  hFrontendByLumi_ = 0;
53 
54 }
55 
57 
58 }
59 
61 
63 
64  if ( dqmStore_ ) {
65 
66  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
67 
68  name = "CertificationSummary";
71 
72  name = "CertificationSummaryMap";
73  meEBDataCertificationSummaryMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
76 
77  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
78 
79  for (int i = 0; i < 36; i++) {
80  name = "EcalBarrel_" + Numbers::sEB(i+1);
83  }
84 
85  }
86 
87 }
88 
90 
91  if ( enableCleanup_ ) this->cleanup();
92 
93 }
94 
96 
97 }
98 
100 
101  this->reset();
102 
103  MonitorElement* me;
104 
105  // evaluate the DQM quality of observables checked by lumi
106  float DQMVal[36];
107  for (int i = 0; i < 36; i++) {
108  DQMVal[i] = -1.;
109  }
110 
111  me = dqmStore_->get(prefixME_ + "/EBIntegrityTask/EBIT weighted integrity errors by lumi");
112  hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );
113 
114  me = dqmStore_->get(prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT weighted frontend errors by lumi");
115  hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );
116 
117  me = dqmStore_->get(prefixME_ + "/EBRawDataTask/EBRDT FE synchronization errors by lumi");
118  hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );
119 
121 
122  float integrityErrSum = 0.;
123  float integrityQual = 1.0;
124  float frontendErrSum = 0.;
125  float frontendQual = 1.0;
126  float synchronizationErrSum = 0.;
127  float synchronizationQual = 1.0;
128 
129  for ( int i=0; i<36; i++) {
130  float ismIntegrityQual = 1.0;
131  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
132  float errors = hIntegrityByLumi_->GetBinContent(i+1);
133  ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
134  integrityErrSum += errors;
135  }
136  float ismFrontendQual = 1.0;
137  if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
138  float errors = hFrontendByLumi_->GetBinContent(i+1);
139  ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
140  frontendErrSum += errors;
141  }
142  float ismSynchronizationQual = 1.0;
143  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
144  float errors = hSynchronizationByLumi_->GetBinContent(i+1);
145  ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
146  synchronizationErrSum += errors;
147  }
148  float minVal= std::min(ismIntegrityQual,ismFrontendQual);
149  DQMVal[i] = std::min(minVal,ismSynchronizationQual);
150  }
151 
152  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/36.;
153  if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/36.;
154  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
155  float minVal = std::min(integrityQual,frontendQual);
156  float totDQMVal = std::min(minVal,synchronizationQual);
157 
158  me = dqmStore_->get((prefixME_ + "/EventInfo/reportSummary"));
159  if( me ) me->Fill(totDQMVal);
160  for ( int i=0; i<36; i++) {
161  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/EcalBarrel_" + Numbers::sEB(i+1) ) ;
162  if( me ) me->Fill(DQMVal[i]);
163 
164  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
165  if( me ) {
166  for ( int iett = 0; iett < 34; iett++ ) {
167  for ( int iptt = 0; iptt < 72; iptt++ ) {
168  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
169  if( i == (ism-1) ) me->setBinContent(iptt+1, iett+1, DQMVal[ism-1]);
170  }
171  }
172  }
173  }
174 
175  }
176 
177  // now combine reduced DQM with DCS and DAQ
178  me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
179  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
180 
181  me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
182  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
183 
184  float sumCert = 0.;
185  float sumCertEB[36];
186  int nValidChannels = 0;
187  int nValidChannelsEB[36];
188 
189  for (int i = 0; i < 36; i++) {
190  sumCertEB[i] = 0.;
191  nValidChannelsEB[i] = 0;
192  }
193 
194  for ( int iett = 0; iett < 34; iett++ ) {
195  for ( int iptt = 0; iptt < 72; iptt++ ) {
196 
197  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
198 
199  float xvalDQM = DQMVal[ism-1];
200 
201  float xvalDAQ, xvalDCS;
202  xvalDAQ = xvalDCS = -1.;
203  float xcert = -1.;
204 
205  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
206  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
207 
208  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
209  // problems: DQM empty or DAQ and DCS not available
210  xcert = 0.0;
211  } else {
212  // do not consider the white value of DAQ and DCS (problems with DB)
213  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
214  }
215 
217 
218  sumCertEB[ism-1] += xcert;
219  nValidChannelsEB[ism-1]++;
220 
221  sumCert += xcert;
222  nValidChannels++;
223 
224  }
225  }
226 
228  if( nValidChannels>0 ) meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
229  else meEBDataCertificationSummary_->Fill( 0.0 );
230  }
231 
232  for (int i = 0; i < 36; i++) {
233  if( meEBDataCertification_[i] ) {
234  if( nValidChannelsEB[i]>0 ) meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
235  else meEBDataCertification_[i]->Fill( 0.0 );
236  }
237  }
238 
239 }
240 
242 
243  if ( ! mergeRuns_ ) this->reset();
244 
245 }
246 
248 
249  this->reset();
250 
251  MonitorElement* me;
252 
253  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
254  hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );
255 
256  me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
257  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
258 
259  me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
260  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
261 
262  float sumCert = 0.;
263  float sumCertEB[36];
264  int nValidChannels = 0;
265  int nValidChannelsEB[36];
266 
267  for (int i = 0; i < 36; i++) {
268  sumCertEB[i] = 0.;
269  nValidChannelsEB[i] = 0;
270  }
271 
272  for ( int iett = 0; iett < 34; iett++ ) {
273  for ( int iptt = 0; iptt < 72; iptt++ ) {
274 
275  float xvalDQM, xvalDAQ, xvalDCS;
276  xvalDQM = xvalDAQ = xvalDCS = -1.;
277  float xcert = -1;
278 
279  if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( iptt+1, iett+1 );
280  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
281  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
282 
283  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
284  // problems: DQM empty or DAQ and DCS not available
285  xcert = 0.0;
286  } else {
287  // do not consider the white value of DAQ and DCS (problems with DB)
288  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
289  }
290 
292 
293  int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
294 
295  sumCertEB[ism-1] += xcert;
296  nValidChannelsEB[ism-1]++;
297 
298  sumCert += xcert;
299  nValidChannels++;
300 
301  }
302  }
303 
305  if( nValidChannels>0 ) {
306  meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
307  } else {
309  }
310  }
311 
312  for (int i = 0; i < 36; i++) {
313  if( meEBDataCertification_[i] ) {
314  if( nValidChannelsEB[i]>0 ) {
315  meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
316  } else {
317  meEBDataCertification_[i]->Fill( 0.0 );
318  }
319  }
320  }
321 
322 }
323 
325 
327 
328  for (int i = 0; i < 36; i++) {
330  }
331 
333 
334 }
335 
336 
338 
339  if ( cloneME_ ) {
340  if( hDQM_ ) delete hDQM_;
341  if( hDAQ_ ) delete hDAQ_;
342  if( hDCS_ ) delete hDCS_;
344  if( hFrontendByLumi_ ) delete hFrontendByLumi_;
346  }
347  hDQM_ = 0;
348  hDAQ_ = 0;
349  hDCS_ = 0;
350  hIntegrityByLumi_ = 0;
351  hFrontendByLumi_ = 0;
353 
354  if ( dqmStore_ ) {
355  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
358 
359  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
360  for (int i = 0; i < 36; i++) {
362  }
363  }
364 
365 }
366 
368 
369 }
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:94
MonitorElement * meEBDataCertificationSummary_
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
void Fill(long long x)
MonitorElement * meEBDataCertificationSummaryMap_
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
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:1473
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:850
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:434
Definition: Run.h:36
EBDataCertificationTask(const edm::ParameterSet &ps)
Constructor.