CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEDataCertificationTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEDataCertificationTask.cc
3  *
4  * $Date: 2010/08/11 14:57:34 $
5  * $Revision: 1.25 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 #include <algorithm>
12 
17 
19 
22 
25 
27 
29 
30  // cloneME switch
31  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
32 
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 < 18; i++) {
45  }
46 
47  hDQM_ = 0;
48  hDAQ_ = 0;
50  hFrontendByLumi_ = 0;
52 
53 }
54 
56 
57 }
58 
60 
61  char histo[200];
62 
63  if ( dqmStore_ ) {
64 
65  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
66 
67  sprintf(histo, "CertificationSummary");
70 
71  sprintf(histo, "CertificationSummaryMap");
72  meEEDataCertificationSummaryMap_ = dqmStore_->book2D(histo,histo, 200, 0., 200., 100, 0., 100.);
75 
76  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
77 
78  for (int i = 0; i < 18; i++) {
79  sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
82  }
83 
84  }
85 
86 }
87 
89 
90  if ( enableCleanup_ ) this->cleanup();
91 
92 }
93 
95 
96 }
97 
99 
100  this->reset();
101 
102  char histo[200];
103 
104  MonitorElement* me;
105 
106  // evaluate the DQM quality of observables checked by lumi
107  float DQMVal[18];
108  for (int i = 0; i < 18; i++) {
109  DQMVal[i] = -1.;
110  }
111 
112  sprintf(histo, (prefixME_ + "/EEIntegrityTask/EEIT weighted integrity errors by lumi").c_str());
113  me = dqmStore_->get(histo);
114  hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );
115 
116  sprintf(histo, (prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT weighted frontend errors by lumi").c_str());
117  me = dqmStore_->get(histo);
118  hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );
119 
120  sprintf(histo, (prefixME_ + "/EERawDataTask/EERDT FE synchronization errors by lumi").c_str());
121  me = dqmStore_->get(histo);
122  hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );
123 
125 
126  float integrityErrSum = 0.;
127  float integrityQual = 1.0;
128  float frontendErrSum = 0.;
129  float frontendQual = 1.0;
130  float synchronizationErrSum = 0.;
131  float synchronizationQual = 1.0;
132 
133  for ( int i=0; i<18; i++) {
134  float ismIntegrityQual = 1.0;
135  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
136  float errors = hIntegrityByLumi_->GetBinContent(i+1);
137  ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
138  integrityErrSum += errors;
139  }
140  float ismFrontendQual = 1.0;
141  if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
142  float errors = hFrontendByLumi_->GetBinContent(i+1);
143  ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
144  frontendErrSum += errors;
145  }
146  float ismSynchronizationQual = 1.0;
147  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
148  float errors = hSynchronizationByLumi_->GetBinContent(i+1);
149  ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
150  synchronizationErrSum += errors;
151  }
152  float minVal= std::min(ismIntegrityQual,ismFrontendQual);
153  DQMVal[i] = std::min(minVal,ismSynchronizationQual);
154  }
155 
156  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/18.;
157  if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/18.;
158  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
159  float minVal = std::min(integrityQual,frontendQual);
160  float totDQMVal = std::min(minVal,synchronizationQual);
161 
162  sprintf(histo, (prefixME_ + "/EventInfo/reportSummary").c_str());
163  me = dqmStore_->get(histo);
164  if( me ) me->Fill(totDQMVal);
165 
166  for ( int i=0; i<18; i++) {
167  sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
168  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/" + histo);
169  if( me ) me->Fill(DQMVal[i]);
170 
171  sprintf(histo, "reportSummaryMap");
172  me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo );
173  if( me ) {
174  for ( int ix = 1; ix <= 100; ix++ ) {
175  for ( int iy = 1; iy <= 100; iy++ ) {
176  int jx = ( i < 9 ) ? ix : 100 + ix;
177  int jy = iy;
178  if ( Numbers::validEE(i+1, ix, iy) ) me->setBinContent(jx, jy, DQMVal[i]);
179  }
180  }
181  }
182  }
183 
184  }
185 
186  // now combine reduced DQM with DCS and DAQ
187  sprintf(histo, (prefixME_ + "/EventInfo/DAQSummaryMap").c_str());
188  me = dqmStore_->get(histo);
189  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
190 
191  sprintf(histo, (prefixME_ + "/EventInfo/DCSSummaryMap").c_str());
192  me = dqmStore_->get(histo);
193  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
194 
195  float sumCert = 0.;
196  float sumCertEE[18];
197  int nValidChannels = 0;
198  int nValidChannelsEE[18];
199 
200  for (int i = 0; i < 18; i++) {
201  sumCertEE[i] = 0;
202  nValidChannelsEE[i] = 0;
203  }
204 
205  for ( int iz = -1; iz < 2; iz+=2 ) {
206  for ( int ix = 1; ix <= 100; ix++ ) {
207  for ( int iy = 1; iy <= 100; iy++ ) {
208  int jx = (iz==1) ? 100 + ix : ix;
209  int jy = iy;
210  if( EEDetId::validDetId(ix, iy, iz) ) {
211 
212  // map the 1-18 index to the correct SM
213  int ism = 0;
214  int firstSec = ( iz < 0 ) ? 1 : 10;
215  int lastSec = ( iz < 0 ) ? 9 : 18;
216  for (int i = firstSec; i <= lastSec; i++) {
217  if ( Numbers::validEE(i, ix, iy) ) ism = i;
218  }
219 
220  float xvalDQM = DQMVal[ism-1];
221 
222  float xvalDAQ, xvalDCS;
223  xvalDAQ = xvalDCS = -1.;
224  float xcert = -1.;
225 
226  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
227  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );
228 
229  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
230  // problems: DQM empty or DAQ and DCS not available
231  xcert = 0.0;
232  } else {
233  // do not consider the white value of DAQ and DCS (problems with DB)
234  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
235  }
236 
238 
239  sumCertEE[ism-1] += xcert;
240  nValidChannelsEE[ism-1]++;
241 
242  sumCert += xcert;
243  nValidChannels++;
244 
245  } else {
247  }
248  }
249  }
250  }
251 
253  if( nValidChannels>0 ) meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
254  else meEEDataCertificationSummary_->Fill( 0.0 );
255  }
256 
257  for (int i = 0; i < 18; i++) {
258  if( meEEDataCertification_[i] ) {
259  if( nValidChannelsEE[i]>0 ) meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
260  else meEEDataCertification_[i]->Fill( 0.0 );
261  }
262  }
263 
264 }
265 
267 
268  if ( ! mergeRuns_ ) this->reset();
269 
270 }
271 
273 
274  this->reset();
275 
276  char histo[200];
277 
278  MonitorElement* me;
279 
280  sprintf(histo, (prefixME_ + "/EventInfo/reportSummaryMap").c_str());
281  me = dqmStore_->get(histo);
282  hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );
283 
284  sprintf(histo, (prefixME_ + "/EventInfo/DAQSummaryMap").c_str());
285  me = dqmStore_->get(histo);
286  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
287 
288  sprintf(histo, (prefixME_ + "/EventInfo/DCSSummaryMap").c_str());
289  me = dqmStore_->get(histo);
290  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
291 
292  float sumCert = 0.;
293  float sumCertEE[18];
294  int nValidChannels = 0;
295  int nValidChannelsEE[18];
296 
297  for (int i = 0; i < 18; i++) {
298  sumCertEE[i] = 0.;
299  nValidChannelsEE[i] = 0;
300  }
301 
302  for ( int iz = -1; iz < 2; iz+=2 ) {
303  for ( int ix = 1; ix <= 100; ix++ ) {
304  for ( int iy = 1; iy <= 100; iy++ ) {
305  int jx = (iz==1) ? 100 + ix : ix;
306  int jy = iy;
307  if( EEDetId::validDetId(ix, iy, iz) ) {
308 
309  float xvalDQM, xvalDAQ, xvalDCS;
310  xvalDQM = xvalDAQ = xvalDCS = -1.;
311  float xcert = -1.;
312 
313  if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( jx, jy );
314  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
315  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );
316 
317  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
318  // problems: DQM empty or DAQ and DCS not available
319  xcert = 0.0;
320  } else {
321  // do not consider the white value of DAQ and DCS (problems with DB)
322  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
323  }
324 
326 
327  // map the 1-18 index to the correct SM
328  int firstSec = ( iz < 0 ) ? 1 : 10;
329  int lastSec = ( iz < 0 ) ? 9 : 18;
330  for (int i = firstSec; i <= lastSec; i++) {
331  if ( Numbers::validEE(i, ix, iy) ) {
332  sumCertEE[i-1] += xcert;
333  nValidChannelsEE[i-1]++;
334  }
335  }
336 
337  sumCert += xcert;
338  nValidChannels++;
339 
340  } else {
342  }
343  }
344  }
345  }
346 
348  if( nValidChannels>0 ) {
349  meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
350  } else {
352  }
353  }
354 
355  for (int i = 0; i < 18; i++) {
356  if( meEEDataCertification_[i] ) {
357  if( nValidChannelsEE[i]>0 ) {
358  meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
359  } else {
360  meEEDataCertification_[i]->Fill( 0.0 );
361  }
362  }
363  }
364 
365 }
366 
368 
370 
371  for (int i = 0; i < 18; i++) {
373  }
374 
376 
378 
379 }
380 
381 
383 
384  if ( cloneME_ ) {
385  if( hDQM_ ) delete hDQM_;
386  if( hDAQ_ ) delete hDAQ_;
387  if( hDCS_ ) delete hDCS_;
389  if( hFrontendByLumi_ ) delete hFrontendByLumi_;
391  }
392  hDQM_ = 0;
393  hDAQ_ = 0;
394  hDCS_ = 0;
395  hIntegrityByLumi_ = 0;
396  hFrontendByLumi_ = 0;
398 
399  if ( dqmStore_ ) {
400  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
403 
404  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
405  for (int i = 0; i < 18; i++) {
407  }
408  }
409 
410 }
411 
413 
414 }
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 setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * meEEDataCertification_[18]
Some &quot;id&quot; conversions.
static std::string sEE(const int ism)
Definition: Numbers.cc:199
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
tuple histo
Definition: trackerHits.py:12
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:456
virtual ~EEDataCertificationTask()
Destructor.
void Fill(long long x)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2338
MonitorElement * meEEDataCertificationSummaryMap_
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
EndLuminosityBlock.
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
Ecal Monitor Utils for Client.
EEDataCertificationTask(const edm::ParameterSet &ps)
Constructor.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
static bool validEE(const int ism, const int ix, const int iy)
Definition: Numbers.cc:982
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:647
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:47
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)
MonitorElement * meEEDataCertificationSummary_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31