CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEHltTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEHltTask.cc
3  *
4  * $Date: 2012/04/27 13:46:15 $
5  * $Revision: 1.21 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <iostream>
11 #include <fstream>
12 
17 
19 
21 
24 
26 
29 
31 
33 
34  init_ = false;
35 
36  initGeometry_ = false;
37 
39 
40  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
41 
42  folderName_ = ps.getUntrackedParameter<std::string>("folderName", "FEDIntegrity");
43 
44  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
45 
46  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
47 
48  EEDetIdCollection0_ = ps.getParameter<edm::InputTag>("EEDetIdCollection0");
49  EEDetIdCollection1_ = ps.getParameter<edm::InputTag>("EEDetIdCollection1");
50  EEDetIdCollection2_ = ps.getParameter<edm::InputTag>("EEDetIdCollection2");
51  EEDetIdCollection3_ = ps.getParameter<edm::InputTag>("EEDetIdCollection3");
52  EcalElectronicsIdCollection1_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection1");
53  EcalElectronicsIdCollection2_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection2");
54  EcalElectronicsIdCollection3_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection3");
55  EcalElectronicsIdCollection4_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection4");
56  EcalElectronicsIdCollection5_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection5");
57  EcalElectronicsIdCollection6_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection6");
58  FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");
59 
63 
64  map = 0;
65 
66 }
67 
69 
70 }
71 
73 
74  ievt_ = 0;
75 
76  if ( dqmStore_ ) {
79  }
80 
81 }
82 
84 
85  initGeometry(c);
86 
87  if ( ! mergeRuns_ ) this->reset();
88 
89 }
90 
92 
93 }
94 
95 void EEHltTask::reset(void) {
96 
100 
101 }
102 
103 void EEHltTask::setup(void){
104 
105  init_ = true;
106 
107  std::string name;
108 
109  if ( dqmStore_ ) {
111 
112  name = "FEDEntries";
113  meEEFedsOccupancy_ = dqmStore_->book1D(name, name, 54, 601, 655);
114 
115  name = "FEDFatal";
116  meEEFedsSizeErrors_ = dqmStore_->book1D(name, name, 54, 601, 655);
117 
118  name = "FEDNonFatal";
119  meEEFedsIntegrityErrors_ = dqmStore_->book1D(name, name, 54, 601, 655);
120 
121  }
122 
123 }
124 
126 
127  if ( ! init_ ) return;
128 
129  if ( dqmStore_ ) {
131 
133  meEEFedsOccupancy_ = 0;
134 
137 
140 
141  }
142 
143  init_ = false;
144 
145 }
146 
147 void EEHltTask::endJob(void){
148 
149  edm::LogInfo("EEHltTask") << "analyzed " << ievt_ << " events";
150 
151  if ( enableCleanup_ ) this->cleanup();
152 
153 }
154 
156 
157  if ( ! init_ ) this->setup();
158 
159  ievt_++;
160 
161  // ECAL endcap FEDs
162  int EEFirstFED[2];
163  EEFirstFED[0] = 601; // EE-
164  EEFirstFED[1] = 646; // EE+
165 
166  int FedsSizeErrors[18];
167  for ( int i=0; i<18; i++ ) FedsSizeErrors[i]=0;
168 
170 
171  if ( e.getByLabel(EEDetIdCollection0_, ids0) ) {
172 
173  for ( EEDetIdCollection::const_iterator idItr = ids0->begin(); idItr != ids0->end(); ++idItr ) {
174 
175  int ism = iSM( *idItr );
176 
177  if ( ism > -1 ) FedsSizeErrors[ism-1]++;
178 
179  }
180 
181  } else {
182 
183 // edm::LogWarning("EEHltTask") << EEDetIdCollection0_ << " not available";
184 
185  }
186 
187  edm::Handle<FEDRawDataCollection> allFedRawData;
188 
189  if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
190 
191  for(int zside=0; zside<2; zside++) {
192 
193  int firstFedOnSide=EEFirstFED[zside];
194 
195  for ( int ism=1; ism<=9; ism++ ) {
196 
197  const FEDRawData& fedData = allFedRawData->FEDData( firstFedOnSide + ism - 1 );
198 
199  int length = fedData.size()/sizeof(uint64_t);
200 
201  if ( length > 0 ) {
202 
203  if ( meEEFedsOccupancy_ ) meEEFedsOccupancy_->Fill( firstFedOnSide + ism - 1 );
204 
205  uint64_t * pData = (uint64_t *)(fedData.data());
206  uint64_t * fedTrailer = pData + (length - 1);
207  bool crcError = (*fedTrailer >> 2 ) & 0x1;
208 
209  if (crcError) FedsSizeErrors[ism-1]++;
210 
211  }
212 
213  }
214 
215  }
216 
217  } else {
218  edm::LogWarning("EEHltTask") << FEDRawDataCollection_ << " not available";
219  }
220 
221 
222  for( int ism=1; ism<=18; ism++ ) {
223 
224  if ( FedsSizeErrors[ism-1] != 0 ) {
225 
226  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
227 
228  if ( meEEFedsSizeErrors_ ) meEEFedsSizeErrors_->Fill( fednumber );
229 
230  }
231 
232  }
233 
234 
235  // Integrity errors
237 
238  if ( e.getByLabel(EEDetIdCollection1_, ids1) ) {
239 
240  for ( EEDetIdCollection::const_iterator idItr = ids1->begin(); idItr != ids1->end(); ++idItr ) {
241 
242  int ism = iSM( *idItr );
243  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
244 
245  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
246 
247  }
248 
249  } else {
250 
251  edm::LogWarning("EEHltTask") << EEDetIdCollection1_ << " not available";
252 
253  }
254 
256 
257  if ( e.getByLabel(EEDetIdCollection2_, ids2) ) {
258 
259  for ( EEDetIdCollection::const_iterator idItr = ids2->begin(); idItr != ids2->end(); ++idItr ) {
260 
261  int ism = iSM( *idItr );
262  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
263 
264  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
265 
266  }
267 
268  } else {
269 
270  edm::LogWarning("EEHltTask") << EEDetIdCollection2_ << " not available";
271 
272  }
273 
275 
276  if ( e.getByLabel(EEDetIdCollection3_, ids3) ) {
277 
278  for ( EEDetIdCollection::const_iterator idItr = ids3->begin(); idItr != ids3->end(); ++idItr ) {
279 
280  int ism = iSM( *idItr );
281  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
282 
283  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
284 
285  }
286 
287  } else {
288 
289  edm::LogWarning("EEHltTask") << EEDetIdCollection3_ << " not available";
290 
291  }
292 
294 
295  if ( e.getByLabel(EcalElectronicsIdCollection1_, ids4) ) {
296 
297  for ( EcalElectronicsIdCollection::const_iterator idItr = ids4->begin(); idItr != ids4->end(); ++idItr ) {
298 
299  if ( subDet( *idItr ) != EcalEndcap ) continue;
300 
301  int ism = iSM( *idItr );
302  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
303 
304  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./34.);
305 
306  }
307 
308  } else {
309 
310  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection1_ << " not available";
311 
312  }
313 
315 
316  if ( e.getByLabel(EcalElectronicsIdCollection2_, ids5) ) {
317 
318  for ( EcalElectronicsIdCollection::const_iterator idItr = ids5->begin(); idItr != ids5->end(); ++idItr ) {
319 
320  if ( subDet( *idItr ) != EcalEndcap ) continue;
321 
322  int ism = iSM( *idItr );
323  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
324 
325  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
326 
327  }
328 
329  } else {
330 
331  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection2_ << " not available";
332 
333  }
334 
336 
337  if ( e.getByLabel(EcalElectronicsIdCollection3_, ids6) ) {
338 
339  for ( EcalElectronicsIdCollection::const_iterator idItr = ids6->begin(); idItr != ids6->end(); ++idItr ) {
340 
341  if ( subDet( *idItr ) != EcalEndcap ) continue;
342 
343  int ism = iSM( *idItr );
344  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
345 
346  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./34.);
347 
348  }
349 
350  } else {
351 
352  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection3_ << " not available";
353 
354  }
355 
357 
358  if ( e.getByLabel(EcalElectronicsIdCollection4_, ids7) ) {
359 
360  for ( EcalElectronicsIdCollection::const_iterator idItr = ids7->begin(); idItr != ids7->end(); ++idItr ) {
361 
362  if ( subDet( *idItr ) != EcalEndcap ) continue;
363 
364  int ism = iSM( *idItr );
365  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
366 
367  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
368 
369  }
370 
371  } else {
372 
373  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection4_ << " not available";
374 
375  }
376 
378 
379  if ( e.getByLabel(EcalElectronicsIdCollection5_, ids8) ) {
380 
381  for ( EcalElectronicsIdCollection::const_iterator idItr = ids8->begin(); idItr != ids8->end(); ++idItr ) {
382 
383  if ( subDet( *idItr ) != EcalEndcap ) continue;
384 
385  int ism = iSM( *idItr );
386  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
387 
388  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
389 
390  }
391 
392  } else {
393 
394  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection5_ << " not available";
395 
396  }
397 
399 
400  if ( e.getByLabel(EcalElectronicsIdCollection6_, ids9) ) {
401 
402  for ( EcalElectronicsIdCollection::const_iterator idItr = ids9->begin(); idItr != ids9->end(); ++idItr ) {
403 
404  if ( subDet( *idItr ) != EcalEndcap ) continue;
405 
406  int ism = iSM( *idItr );
407  int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
408 
409  if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
410 
411  }
412 
413  } else {
414 
415  edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection6_ << " not available";
416 
417  }
418 
419 }
420 
421 //-------------------------------------------------------------------------
422 
424 
425  if( initGeometry_ ) return;
426 
427  initGeometry_ = true;
428 
430  setup.get< EcalMappingRcd >().get(handle);
431  map = handle.product();
432 
433  if( ! map ) edm::LogWarning("EEHltTask") << "EcalElectronicsMapping not available";
434 
435 }
436 
437 int EEHltTask::iSM( const EEDetId& id ) {
438 
439  if( ! map ) return -1;
440 
442  int idcc = eid.dccId();
443 
444  // EE-
445  if( idcc >= 1 && idcc <= 9 ) return( idcc );
446 
447  // EE+
448  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
449 
450  edm::LogWarning("EEHltTask") << "Wrong DCC id: dcc = " << idcc;
451  return -1;
452 
453 }
454 
456 
457  int idcc = id.dccId();
458 
459  // EE-
460  if( idcc >= 1 && idcc <= 9 ) return( idcc );
461 
462  // EE+
463  if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
464 
465  edm::LogWarning("EEHltTask") << "Wrong DCC id: dcc = " << idcc;
466  return -1;
467 
468 }
469 
edm::InputTag EEDetIdCollection3_
Definition: EEHltTask.h:90
edm::InputTag EcalElectronicsIdCollection3_
Definition: EEHltTask.h:94
T getParameter(std::string const &) const
EEHltTask(const edm::ParameterSet &ps)
Constructor.
Definition: EEHltTask.cc:32
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
bool init_
Definition: EEHltTask.h:104
edm::InputTag EcalElectronicsIdCollection5_
Definition: EEHltTask.h:96
edm::InputTag EEDetIdCollection0_
Definition: EEHltTask.h:87
edm::InputTag EcalElectronicsIdCollection1_
Definition: EEHltTask.h:92
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
void beginJob(void)
BeginJob.
Definition: EEHltTask.cc:72
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
void reset(void)
Reset.
Definition: EEHltTask.cc:95
edm::InputTag FEDRawDataCollection_
Definition: EEHltTask.h:98
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
Definition: EEHltTask.cc:91
void Fill(long long x)
bool initGeometry_
Definition: EEHltTask.h:105
MonitorElement * meEEFedsSizeErrors_
Definition: EEHltTask.h:101
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
const EcalElectronicsMapping * map
Definition: EEHltTask.h:107
edm::InputTag EcalElectronicsIdCollection2_
Definition: EEHltTask.h:93
edm::InputTag EEDetIdCollection1_
Definition: EEHltTask.h:88
MonitorElement * meEEFedsOccupancy_
Definition: EEHltTask.h:100
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
tuple handle
Definition: patZpeak.py:22
DQMStore * dqmStore_
Definition: EEHltTask.h:78
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void cleanup(void)
Cleanup.
Definition: EEHltTask.cc:125
unsigned long long uint64_t
Definition: Time.h:15
MonitorElement * meEEFedsIntegrityErrors_
Definition: EEHltTask.h:102
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
Definition: EEHltTask.cc:155
void endJob(void)
EndJob.
Definition: EEHltTask.cc:147
edm::InputTag EcalElectronicsIdCollection4_
Definition: EEHltTask.h:95
bool enableCleanup_
Definition: EEHltTask.h:83
void initGeometry(const edm::EventSetup &setup)
Definition: EEHltTask.cc:423
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
Definition: EEHltTask.cc:83
int iSM(const EEDetId &id)
Definition: EEHltTask.cc:437
bool mergeRuns_
Definition: EEHltTask.h:85
edm::InputTag EcalElectronicsIdCollection6_
Definition: EEHltTask.h:97
std::string folderName_
Definition: EEHltTask.h:81
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
EcalSubdetector subDet(const EEDetId &id)
Definition: EEHltTask.h:66
edm::InputTag EEDetIdCollection2_
Definition: EEHltTask.h:89
virtual ~EEHltTask()
Destructor.
Definition: EEHltTask.cc:68
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void Reset(void)
reset ME (ie. contents, errors, etc)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
int ievt_
Definition: EEHltTask.h:76
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
std::string prefixME_
Definition: EEHltTask.h:80
Definition: Run.h:33
void setup(void)
Setup.
Definition: EEHltTask.cc:103
std::vector< T >::const_iterator const_iterator
Definition: EDCollection.h:20