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: 2012/04/27 13:46:14 $
5  * $Revision: 1.31 $
6  * \author E. Di Marco
7  *
8 */
9 
10 #include <iostream>
11 #include <algorithm>
12 
17 
19 
22 
25 
28 
30 
32 
33  // cloneME switch
34  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
35 
37 
38  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
39 
40  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
41 
42  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
43 
46  for (int i = 0; i < 18; i++) {
48  }
49 
50  hDQM_ = 0;
51  hDAQ_ = 0;
53  hFrontendByLumi_ = 0;
55 
56 }
57 
59 
60 }
61 
63 
64  if ( dqmStore_ ) {
65 
66  std::string name;
67 
68  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
69 
70  meEEDataCertificationSummary_ = dqmStore_->bookFloat( "CertificationSummary" );
72 
73  name = "CertificationSummaryMap";
74  meEEDataCertificationSummaryMap_ = dqmStore_->book2D(name, name, 40, 0., 200., 20, 0., 100.);
77 
78  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
79 
80  for (int i = 0; i < 18; i++) {
81  meEEDataCertification_[i] = dqmStore_->bookFloat( "EcalEndcap_" + Numbers::sEE(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[18];
107  for (int i = 0; i < 18; i++) {
108  DQMVal[i] = -1.;
109  }
110 
112  iSetup.get< EcalMappingRcd >().get(handle);
113  const EcalElectronicsMapping *map = handle.product();
114  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
115 
116  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/EEIT weighted integrity errors by lumi" );
117  hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );
118 
119  me = dqmStore_->get( prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT weighted frontend errors by lumi" );
120  hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );
121 
122  me = dqmStore_->get( prefixME_ + "/EERawDataTask/EERDT FE synchronization errors by lumi" );
123  hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );
124 
126 
127  float integrityErrSum = 0.;
128  float integrityQual = 1.0;
129  float frontendErrSum = 0.;
130  float frontendQual = 1.0;
131  float synchronizationErrSum = 0.;
132  float synchronizationQual = 1.0;
133 
134  for ( int i=0; i<18; i++) {
135  float ismIntegrityQual = 1.0;
136  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
137  float errors = hIntegrityByLumi_->GetBinContent(i+1);
138  ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
139  integrityErrSum += errors;
140  }
141  float ismFrontendQual = 1.0;
142  if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
143  float errors = hFrontendByLumi_->GetBinContent(i+1);
144  ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
145  frontendErrSum += errors;
146  }
147  float ismSynchronizationQual = 1.0;
148  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
149  float errors = hSynchronizationByLumi_->GetBinContent(i+1);
150  ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
151  synchronizationErrSum += errors;
152  }
153  float minVal= std::min(ismIntegrityQual,ismFrontendQual);
154  DQMVal[i] = std::min(minVal,ismSynchronizationQual);
155  }
156 
157  if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/18.;
158  if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/18.;
159  if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
160  float minVal = std::min(integrityQual,frontendQual);
161  float totDQMVal = std::min(minVal,synchronizationQual);
162 
163  me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummary" );
164  if( me ) me->Fill(totDQMVal);
165 
166  for ( int i=0; i<18; i++) {
167  me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryContents/EcalEndcap_" + Numbers::sEE(i+1) );
168  if( me ) me->Fill(DQMVal[i]);
169 
170  me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryMap" );
171  if( me ) {
172  for(int t=1 ; t<=nTowerMax_ ; t++){
173  if(! map->dccTowerConstituents(DccId_[i], t).size() ) continue;
174  std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
175  for(unsigned u=0 ; u<scs.size() ; u++){
176  int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
177  int jy = scs[u].iy();
178  me->setBinContent(jx,jy, DQMVal[i]);
179  }
180  }
181  }
182  }
183 
184  }
185 
186  // now combine reduced DQM with DCS and DAQ
187  me = dqmStore_->get( prefixME_ + "/EventInfo/DAQSummaryMap" );
188  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
189 
190  me = dqmStore_->get( prefixME_ + "/EventInfo/DCSSummaryMap" );
191  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
192 
193  float sumCert = 0.;
194  float sumCertEE[18];
195  int nValidChannels = 0;
196  int nValidChannelsEE[18];
197 
199  for(int ix=1 ; ix<=meEEDataCertificationSummaryMap_->getNbinsX() ; ix++){
200  for(int iy=1 ; iy<=meEEDataCertificationSummaryMap_->getNbinsY() ; iy++){
202  }
203  }
204  }
205 
206  for (int i = 0; i < 18; i++) {
207  sumCertEE[i] = 0;
208  nValidChannelsEE[i] = 0;
209 
210  for(int t=1 ; t<=nTowerMax_ ; t++){
211 
212  std::vector<DetId> crystals = map->dccTowerConstituents(DccId_[i], t);
213  if(!crystals.size()) continue; // getEcalScDetId throws an exception when no crystal is found
214 
215  std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
216  for(unsigned u=0 ; u<scs.size() ; u++){
217 
218  int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
219  int jy = scs[u].iy();
220 
221  float xvalDQM = DQMVal[i];
222 
223  float xvalDAQ, xvalDCS;
224  xvalDAQ = xvalDCS = -1.;
225  float xcert = -1.;
226 
227  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
228  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );
229 
230  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
231  // problems: DQM empty or DAQ and DCS not available
232  xcert = 0.0;
233  } else {
234  // do not consider the white value of DAQ and DCS (problems with DB)
235  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
236  }
237 
239 
240  int ncrystals = 0;
241 
242  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
243  EEDetId id(*it);
244  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
245  }
246 
247  sumCertEE[i] += xcert * ncrystals;
248  nValidChannelsEE[i] += ncrystals;
249 
250  sumCert += xcert * ncrystals;
251  nValidChannels += ncrystals;
252 
253  }
254  }
255 
256  if( meEEDataCertification_[i] ) {
257  if( nValidChannelsEE[i]>0 ) meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
258  else meEEDataCertification_[i]->Fill( 0.0 );
259  }
260  }
261 
263  if( nValidChannels>0 ) meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
264  else meEEDataCertificationSummary_->Fill( 0.0 );
265  }
266 
267 }
268 
270 
271  if ( ! mergeRuns_ ) this->reset();
272 
273 }
274 
276 
277  this->reset();
278 
280  c.get< EcalMappingRcd >().get(handle);
281  const EcalElectronicsMapping *map = handle.product();
282  if( ! map ){
283  edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
284  return;
285  }
286 
287  MonitorElement* me;
288 
289  me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryMap" );
290  hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );
291 
292  me = dqmStore_->get( prefixME_ + "/EventInfo/DAQSummaryMap" );
293  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
294 
295  me = dqmStore_->get( prefixME_ + "/EventInfo/DCSSummaryMap" );
296  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
297 
298  float sumCert = 0.;
299  float sumCertEE[18];
300  int nValidChannels = 0;
301  int nValidChannelsEE[18];
302 
304  for(int ix=1 ; ix<=meEEDataCertificationSummaryMap_->getNbinsX() ; ix++){
305  for(int iy=1 ; iy<=meEEDataCertificationSummaryMap_->getNbinsY() ; iy++){
307  }
308  }
309  }
310 
311  for (int i = 0; i < 18; i++) {
312  sumCertEE[i] = 0;
313  nValidChannelsEE[i] = 0;
314 
315  for(int t=1 ; t<=nTowerMax_ ; t++){
316 
317  std::vector<DetId> crystals = map->dccTowerConstituents(DccId_[i], t);
318  if(!crystals.size()) continue;
319 
320  std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
321  for(unsigned u=0 ; u<scs.size() ; u++){
322 
323  int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
324  int jy = scs[u].iy();
325 
326  float xvalDQM, xvalDAQ, xvalDCS;
327  xvalDQM = xvalDAQ = xvalDCS = -1.;
328  float xcert = -1.;
329 
330  if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( jx, jy );
331  if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
332  if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );
333 
334  if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
335  // problems: DQM empty or DAQ and DCS not available
336  xcert = 0.0;
337  } else {
338  // do not consider the white value of DAQ and DCS (problems with DB)
339  xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
340  }
341 
343 
344  int ncrystals = 0;
345 
346  for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
347  EEDetId id(*it);
348  if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
349  }
350 
351  sumCertEE[i] += xcert * ncrystals;
352  nValidChannelsEE[i] += ncrystals;
353 
354  sumCert += xcert * ncrystals;
355  nValidChannels += ncrystals;
356 
357  }
358  }
359 
360  if( meEEDataCertification_[i] ) {
361  if( nValidChannelsEE[i]>0 ) meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
362  else meEEDataCertification_[i]->Fill( 0.0 );
363  }
364  }
365 
367  if( nValidChannels>0 ) meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
368  else meEEDataCertificationSummary_->Fill( 0.0 );
369  }
370 
371 }
372 
374 
376 
377  for (int i = 0; i < 18; i++) {
379  }
380 
382 
384 
385 }
386 
387 
389 
390  if ( cloneME_ ) {
391  if( hDQM_ ) delete hDQM_;
392  if( hDAQ_ ) delete hDAQ_;
393  if( hDCS_ ) delete hDCS_;
395  if( hFrontendByLumi_ ) delete hFrontendByLumi_;
397  }
398  hDQM_ = 0;
399  hDAQ_ = 0;
400  hDCS_ = 0;
401  hIntegrityByLumi_ = 0;
402  hFrontendByLumi_ = 0;
404 
405  if ( dqmStore_ ) {
406  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
409 
410  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
411  for (int i = 0; i < 18; i++) {
413  }
414  }
415 
416 }
417 
419 
420 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:226
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.
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
virtual ~EEDataCertificationTask()
Destructor.
dictionary map
Definition: Association.py:205
int getNbinsY(void) const
get # of bins in Y-axis
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:2572
MonitorElement * meEEDataCertificationSummaryMap_
tuple handle
Definition: patZpeak.py:22
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:1468
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
Ecal Monitor Utils for Client.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
EEDataCertificationTask(const edm::ParameterSet &ps)
Constructor.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
BeginLuminosityBlock.
int getNbinsX(void) const
get # of bins in X-axis
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
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:845
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:429
Definition: Run.h:33
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.