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