CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBHltTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBHltTask.cc
3  *
4  * $Date: 2012/04/27 13:46:02 $
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  EBDetIdCollection0_ = ps.getParameter<edm::InputTag>("EBDetIdCollection0");
49  EBDetIdCollection1_ = ps.getParameter<edm::InputTag>("EBDetIdCollection1");
50  EBDetIdCollection2_ = ps.getParameter<edm::InputTag>("EBDetIdCollection2");
51  EBDetIdCollection3_ = ps.getParameter<edm::InputTag>("EBDetIdCollection3");
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 EBHltTask::reset(void) {
96 
100 
101 }
102 
103 void EBHltTask::setup(void){
104 
105  init_ = true;
106 
108 
109  if ( dqmStore_ ) {
111 
112  name = "FEDEntries";
113  meEBFedsOccupancy_ = dqmStore_->book1D(name, name, 36, 610, 646);
114 
115  name = "FEDFatal";
116  meEBFedsSizeErrors_ = dqmStore_->book1D(name, name, 36, 610, 646);
117 
118  name = "FEDNonFatal";
119  meEBFedsIntegrityErrors_ = dqmStore_->book1D(name, name, 36, 610, 646);
120 
121  }
122 
123 }
124 
126 
127  if ( ! init_ ) return;
128 
129  if ( dqmStore_ ) {
131 
133  meEBFedsOccupancy_ = 0;
134 
137 
140 
141  }
142 
143  init_ = false;
144 
145 }
146 
147 void EBHltTask::endJob(void){
148 
149  edm::LogInfo("EBHltTask") << "analyzed " << ievt_ << " events";
150 
151  if ( enableCleanup_ ) this->cleanup();
152 
153 }
154 
156 
157  if ( ! init_ ) this->setup();
158 
159  ievt_++;
160 
161  // ECAL barrel FEDs
162  int EBFirstFED=610;
163 
164  int FedsSizeErrors[36];
165  for ( int i=0; i<36; i++ ) FedsSizeErrors[i]=0;
166 
168 
169  if ( e.getByLabel(EBDetIdCollection0_, ids0) ) {
170 
171  for ( EBDetIdCollection::const_iterator idItr = ids0->begin(); idItr != ids0->end(); ++idItr ) {
172 
173  int ism = iSM( *idItr );
174 
175  if ( ism > -1 ) FedsSizeErrors[ism-1]++;
176 
177  }
178 
179  } else {
180 
181  }
182 
183  edm::Handle<FEDRawDataCollection> allFedRawData;
184 
185  if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
186 
187  for ( int ism=1; ism<=36; ism++ ) {
188 
189  const FEDRawData& fedData = allFedRawData->FEDData( EBFirstFED + ism - 1 );
190 
191  int length = fedData.size()/sizeof(uint64_t);
192 
193  if ( length > 0 ) {
194 
195  if ( meEBFedsOccupancy_ ) meEBFedsOccupancy_->Fill( EBFirstFED + ism - 1 );
196 
197  uint64_t * pData = (uint64_t *)(fedData.data());
198  uint64_t * fedTrailer = pData + (length - 1);
199  bool crcError = (*fedTrailer >> 2 ) & 0x1;
200 
201  if (crcError) FedsSizeErrors[ism-1]++;
202 
203  }
204 
205  }
206 
207  } else {
208  edm::LogWarning("EBHltTask") << FEDRawDataCollection_ << " not available";
209  }
210 
211 
212  for( int ism=1; ism<=36; ism++ ) {
213 
214  if ( FedsSizeErrors[ism-1] != 0 ) {
215 
216  if ( meEBFedsSizeErrors_ ) meEBFedsSizeErrors_->Fill( EBFirstFED + ism - 1 );
217 
218  }
219 
220  }
221 
222 
223  // Integrity errors
225 
226  if ( e.getByLabel(EBDetIdCollection1_, ids1) ) {
227 
228  for ( EBDetIdCollection::const_iterator idItr = ids1->begin(); idItr != ids1->end(); ++idItr ) {
229 
230  int ism = iSM( *idItr );
231 
232  if( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
233 
234  }
235 
236  } else {
237 
238  edm::LogWarning("EBHltTask") << EBDetIdCollection1_ << " not available";
239 
240  }
241 
243 
244  if ( e.getByLabel(EBDetIdCollection2_, ids2) ) {
245 
246  for ( EBDetIdCollection::const_iterator idItr = ids2->begin(); idItr != ids2->end(); ++idItr ) {
247 
248  int ism = iSM( *idItr );
249 
250  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
251 
252  }
253 
254  } else {
255 
256  edm::LogWarning("EBHltTask") << EBDetIdCollection2_ << " not available";
257 
258  }
259 
261 
262  if ( e.getByLabel(EBDetIdCollection3_, ids3) ) {
263 
264  for ( EBDetIdCollection::const_iterator idItr = ids3->begin(); idItr != ids3->end(); ++idItr ) {
265 
266  int ism = iSM( *idItr );
267 
268  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
269 
270  }
271 
272  } else {
273 
274  edm::LogWarning("EBHltTask") << EBDetIdCollection3_ << " not available";
275 
276  }
277 
279 
280  if ( e.getByLabel(EcalElectronicsIdCollection1_, ids4) ) {
281 
282  for ( EcalElectronicsIdCollection::const_iterator idItr = ids4->begin(); idItr != ids4->end(); ++idItr ) {
283 
284  if ( subDet( *idItr ) != EcalBarrel ) continue;
285 
286  int ism = iSM( *idItr );
287 
288  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./68.);
289 
290  }
291 
292  } else {
293 
294  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection1_ << " not available";
295 
296  }
297 
299 
300  if ( e.getByLabel(EcalElectronicsIdCollection2_, ids5) ) {
301 
302  for ( EcalElectronicsIdCollection::const_iterator idItr = ids5->begin(); idItr != ids5->end(); ++idItr ) {
303 
304  if ( subDet( *idItr ) != EcalBarrel ) continue;
305 
306  int ism = iSM( *idItr );
307 
308  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
309 
310  }
311 
312  } else {
313 
314  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection2_ << " not available";
315 
316  }
317 
319 
320  if ( e.getByLabel(EcalElectronicsIdCollection3_, ids6) ) {
321 
322  for ( EcalElectronicsIdCollection::const_iterator idItr = ids6->begin(); idItr != ids6->end(); ++idItr ) {
323 
324  if ( subDet( *idItr ) != EcalBarrel ) continue;
325 
326  int ism = iSM( *idItr );
327 
328  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./68.);
329 
330  }
331 
332  } else {
333 
334  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection3_ << " not available";
335 
336  }
337 
339 
340  if ( e.getByLabel(EcalElectronicsIdCollection4_, ids7) ) {
341 
342  for ( EcalElectronicsIdCollection::const_iterator idItr = ids7->begin(); idItr != ids7->end(); ++idItr ) {
343 
344  if ( subDet( *idItr ) != EcalBarrel ) continue;
345 
346  int ism = iSM( *idItr );
347 
348  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
349 
350  }
351 
352  } else {
353 
354  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection4_ << " not available";
355 
356  }
357 
359 
360  if ( e.getByLabel(EcalElectronicsIdCollection5_, ids8) ) {
361 
362  for ( EcalElectronicsIdCollection::const_iterator idItr = ids8->begin(); idItr != ids8->end(); ++idItr ) {
363 
364  if ( subDet( *idItr ) != EcalBarrel ) continue;
365 
366  int ism = iSM( *idItr );
367 
368  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
369 
370  }
371 
372  } else {
373 
374  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection5_ << " not available";
375 
376  }
377 
379 
380  if ( e.getByLabel(EcalElectronicsIdCollection6_, ids9) ) {
381 
382  for ( EcalElectronicsIdCollection::const_iterator idItr = ids9->begin(); idItr != ids9->end(); ++idItr ) {
383 
384  if ( subDet( *idItr ) != EcalBarrel ) continue;
385 
386  int ism = iSM( *idItr );
387 
388  if ( ism > -1 ) meEBFedsIntegrityErrors_->Fill( EBFirstFED + ism - 1, 1./1700.);
389 
390  }
391 
392  } else {
393 
394  edm::LogWarning("EBHltTask") << EcalElectronicsIdCollection6_ << " not available";
395 
396  }
397 
398 }
399 
400 //-------------------------------------------------------------------------
401 
403 
404  if( initGeometry_ ) return;
405 
406  initGeometry_ = true;
407 
409  setup.get< EcalMappingRcd >().get(handle);
410  map = handle.product();
411 
412  if( ! map ) edm::LogWarning("EBHltTask") << "EcalElectronicsMapping not available";
413 
414 }
415 
416 int EBHltTask::iSM( const EBDetId& id ) {
417 
418  if( ! map ) return -1;
419 
421  int idcc = eid.dccId();
422 
423  // EB-/EB+
424  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
425 
426  edm::LogWarning("EBHltTask") << "Wrong DCC id: dcc = " << idcc;
427  return -1;
428 
429 }
430 
432 
433  int idcc = id.dccId();
434 
435  // EB-/EB+
436  if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
437 
438  edm::LogWarning("EBHltTask") << "Wrong DCC id: dcc = " << idcc;
439  return -1;
440 
441 }
442 
T getParameter(std::string const &) const
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 beginJob(void)
BeginJob.
Definition: EBHltTask.cc:72
edm::InputTag EcalElectronicsIdCollection1_
Definition: EBHltTask.h:92
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
virtual ~EBHltTask()
Destructor.
Definition: EBHltTask.cc:68
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
bool init_
Definition: EBHltTask.h:104
edm::InputTag EBDetIdCollection1_
Definition: EBHltTask.h:88
edm::InputTag EcalElectronicsIdCollection2_
Definition: EBHltTask.h:93
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
Definition: EBHltTask.cc:91
edm::InputTag EcalElectronicsIdCollection5_
Definition: EBHltTask.h:96
bool initGeometry_
Definition: EBHltTask.h:105
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
edm::InputTag EcalElectronicsIdCollection3_
Definition: EBHltTask.h:94
EBHltTask(const edm::ParameterSet &ps)
Constructor.
Definition: EBHltTask.cc:32
std::string prefixME_
Definition: EBHltTask.h:80
EcalSubdetector subDet(const EBDetId &id)
Definition: EBHltTask.h:66
void Fill(long long x)
void endJob(void)
EndJob.
Definition: EBHltTask.cc:147
void reset(void)
Reset.
Definition: EBHltTask.cc:95
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
DQMStore * dqmStore_
Definition: EBHltTask.h:78
bool enableCleanup_
Definition: EBHltTask.h:83
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
std::string folderName_
Definition: EBHltTask.h:81
tuple handle
Definition: patZpeak.py:22
MonitorElement * meEBFedsOccupancy_
Definition: EBHltTask.h:100
bool mergeRuns_
Definition: EBHltTask.h:85
edm::InputTag EBDetIdCollection3_
Definition: EBHltTask.h:90
edm::InputTag EBDetIdCollection2_
Definition: EBHltTask.h:89
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
edm::InputTag EcalElectronicsIdCollection4_
Definition: EBHltTask.h:95
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int ievt_
Definition: EBHltTask.h:76
unsigned long long uint64_t
Definition: Time.h:15
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void cleanup(void)
Cleanup.
Definition: EBHltTask.cc:125
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
Definition: EBHltTask.cc:83
edm::InputTag FEDRawDataCollection_
Definition: EBHltTask.h:98
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
Definition: EBHltTask.cc:155
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void initGeometry(const edm::EventSetup &setup)
Definition: EBHltTask.cc:402
MonitorElement * meEBFedsSizeErrors_
Definition: EBHltTask.h:101
MonitorElement * meEBFedsIntegrityErrors_
Definition: EBHltTask.h:102
const EcalElectronicsMapping * map
Definition: EBHltTask.h:107
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="")
edm::InputTag EBDetIdCollection0_
Definition: EBHltTask.h:87
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
int iSM(const EBDetId &id)
Definition: EBHltTask.cc:416
void setup(void)
Setup.
Definition: EBHltTask.cc:103
Definition: Run.h:36
edm::InputTag EcalElectronicsIdCollection6_
Definition: EBHltTask.h:97
std::vector< T >::const_iterator const_iterator
Definition: EDCollection.h:20