CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEBeamCaloTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEBeamCaloTask.cc
3  *
4  * $Date: 2010/08/08 08:46:09 $
5  * $Revision: 1.41 $
6  * \author A. Ghezzi
7  *
8  */
9 
10 #include <iostream>
11 #include <fstream>
12 
15 
17 
19 
26 
28 
30 
32 
34 
35  init_ = false;
36 
38 
39  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
40 
41  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
42 
43  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
44 
45  EcalTBEventHeader_ = ps.getParameter<edm::InputTag>("EcalTBEventHeader");
46  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
47  EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
48  EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
49 
50  for (int i = 0; i < cryInArray_ ; i++) {
53  meBBCaloGains_[i]=0;
54  meBBCaloEne_[i]=0;
55 
56  //meBBCaloPulseProfMoving_[i]=0;
57  //meBBCaloPulseProfG12Moving_[i]=0;
58  //meBBCaloGainsMoving_[i]=0;
59  //meBBCaloEneMoving_[i]=0;
60  }
61 
62  meBBCaloCryRead_ = 0;
63  //meBBCaloCryReadMoving_ = 0;
64 
67 
68  meBBCaloE3x3_ = 0;
70 
73  TableMoving_ = 0;
74 
75  CrystalsDone_ = 0;
82 
84 // for(int u=0;u<851;u++){
85 // meBBCaloE3x3Cry_[u]=0;
86 // meBBCaloE1Cry_[u]=0;
87 // }
88 
89  meEEBCaloDesync_ = 0;
90 
91 }
92 
94 
95 }
96 
98 
99  ievt_ = 0;
100 
101  profileArranged_ = false;
102 
103  if ( dqmStore_ ) {
104  dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
105  dqmStore_->rmdir(prefixME_ + "/EEBeamCaloTask");
106  }
107 
108 }
109 
111 
112  Numbers::initGeometry(c, false);
113 
114  if ( ! mergeRuns_ ) this->reset();
115 
116 }
117 
119 
120 }
121 
123 
124  for (int i = 0; i < cryInArray_ ; i++) {
127  if ( meBBCaloGains_[i] ) meBBCaloGains_[i]->Reset();
128  if ( meBBCaloEne_[i] ) meBBCaloEne_[i]->Reset();
129 
130 // if ( meBBCaloPulseProfMoving_[i] ) meBBCaloPulseProfMoving_[i]->Reset();
131 // if ( meBBCaloPulseProfG12Moving_[i] ) meBBCaloPulseProfG12Moving_[i]->Reset();
132 // if ( meBBCaloGainsMoving_[i] ) meBBCaloGainsMoving_[i]->Reset();
133 // if ( meBBCaloEneMoving_[i] ) meBBCaloEneMoving_[i]->Reset();
134  }
135 
136 // for(int u=0; u< 1701;u++){
137 // if ( meBBCaloE3x3Cry_[u] ) meBBCaloE3x3Cry_[u]->Reset();
138 // if ( meBBCaloE1Cry_[u] ) meBBCaloE1Cry_[u]->Reset();
139 // }
140 
142 // if ( meBBCaloCryReadMoving_ ) meBBCaloCryReadMoving_->Reset();
149  if ( TableMoving_ ) TableMoving_->Reset();
159 
160 }
161 
163 
164  init_ = true;
165  profileArranged_= false;
166  char histo[200];
167 
168  PreviousTableStatus_[0]=0;//let's start with stable...
169  PreviousTableStatus_[1]=0;//let's start with stable...
170 
171  PreviousCrystalinBeam_[0] = 0;
172  PreviousCrystalinBeam_[1] = 0;
173  PreviousCrystalinBeam_[2] = -1;
174  // PreviousCrystalinBeam_[2] = -1 is needed to have a correct step vs cry matching
176  for(int u=0;u<10;u++){cib_[u]=0;}
177  changed_tb_status_= false;
178  changed_cry_in_beam_ = false;
180  wasFakeChange_= false;
181  table_step_=1;
182  crystal_step_=1;
183  event_last_reset_ = 0;
184  last_cry_in_beam_ = 0;
186 
187  if ( dqmStore_ ) {
188  dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
189 
190  for (int i = 0; i < cryInArray_ ; i++) {
191  sprintf(histo, "EEBCT pulse profile cry %01d", i+1);
192  //considering the gain the range is 4096*12 ~ 50000
193  meBBCaloPulseProf_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,50000,0.,50000.,"s");
194 
195  sprintf(histo, "EEBCT pulse profile in G12 cry %01d", i+1);
196  meBBCaloPulseProfG12_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,4096,0.,4096.,"s");
197  meBBCaloPulseProfG12_[i]->setAxisTitle("#sample", 1);
199 
200  sprintf(histo, "EEBCT found gains cry %01d", i+1);
201  meBBCaloGains_[i] = dqmStore_->book1D(histo,histo,14,0.,14.);
202  meBBCaloGains_[i]->setAxisTitle("gain", 1);
203  // g1-> bin 2, g6-> bin 7, g12-> bin 13
204 
205  sprintf(histo, "EEBCT rec energy cry %01d", i+1);
206  meBBCaloEne_[i] = dqmStore_->book1D(histo,histo,500,0.,9000.);
207  meBBCaloEne_[i]->setAxisTitle("rec ene (ADC)", 1);
208  //9000 ADC in G12 equivalent is about 330 GeV
209 
211 
212 // sprintf(histo, "EEBCT pulse profile moving table cry %01d", i+1);
213 // //considering the gain the range is 4096*12 ~ 50000
214 // meBBCaloPulseProfMoving_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,50000,0.,50000.,"s");
215 
216 // sprintf(histo, "EEBCT pulse profile in G12 moving table cry %01d", i+1);
217 // meBBCaloPulseProfG12Moving_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,4096,0.,4096.,"s");
218 
219 // sprintf(histo, "EEBCT found gains moving table cry %01d", i+1);
220 // meBBCaloGainsMoving_[i] = dqmStore_->book1D(histo,histo,14,0.,14.);
221 // // g1-> bin 2, g6-> bin 7, g12-> bin 13
222 
223 // sprintf(histo, "EEBCT rec energy moving table cry %01d", i+1);
224 // meBBCaloEneMoving_[i] = dqmStore_->book1D(histo,histo,2000,0.,9000.);
225 // //9000 ADC in G12 equivalent is about 330 GeV
226 
227  }
228 
229 // dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask/EnergyHistos");
230 // for(int u=0; u< 851;u++){
231 // sprintf(histo, "EEBCT rec Ene sum 3x3 cry: %04d",u);
232 // meBBCaloE3x3Cry_[u] = dqmStore_->book1D(histo,histo,1000,0.,4500.);
233 
234 // sprintf(histo, "EEBCT rec Energy1 cry: %04d",u);
235 // meBBCaloE1Cry_[u] = dqmStore_->book1D(histo,histo,1000,0.,4500.);
236 // }
237 
238 // dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
239  sprintf(histo, "EEBCT readout crystals");
240  meBBCaloCryRead_ = dqmStore_->book2D(histo,histo,9,-4.,5.,9,-4.,5.);
241  //matrix of readout crystal around cry in beam
242 
243  //sprintf(histo, "EEBCT readout crystals table moving");
244  //meBBCaloCryReadMoving_ = dqmStore_->book2D(histo,histo,9,-4.,5.,9,-4.,5.);
245  //matrix of readout crystal around cry in beam
246 
247  sprintf(histo, "EEBCT all needed crystals readout");
248  meBBCaloAllNeededCry_ = dqmStore_->book1D(histo,histo,3,-1.,2.);
249  // not all needed cry are readout-> bin 1, all needed cry are readout-> bin 3
250 
251  sprintf(histo, "EEBCT readout crystals number");
252  meBBNumCaloCryRead_ = dqmStore_->book1D(histo,histo,851,0.,851.);
253  meBBNumCaloCryRead_->setAxisTitle("number of read crystals", 1);
254 
255  sprintf(histo, "EEBCT rec Ene sum 3x3");
256  meBBCaloE3x3_ = dqmStore_->book1D(histo,histo,500,0.,9000.);
257  meBBCaloE3x3_->setAxisTitle("rec ene (ADC)", 1);
258  //9000 ADC in G12 equivalent is about 330 GeV
259 
260  sprintf(histo, "EEBCT rec Ene sum 3x3 table moving");
261  meBBCaloE3x3Moving_ = dqmStore_->book1D(histo,histo,500,0.,9000.);
262  //9000 ADC in G12 equivalent is about 330 GeV
263 
264  sprintf(histo, "EEBCT crystal on beam");
265  meBBCaloCryOnBeam_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
266 
267  sprintf(histo, "EEBCT crystal with maximum rec energy");
268  meBBCaloMaxEneCry_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
269 
270  sprintf(histo, "EEBCT table is moving");
271  TableMoving_ = dqmStore_->book1D(histo,histo,2,0.,1.1);
272  TableMoving_->setAxisTitle("table status (0=stable, 1=moving)", 1);
273  //table is moving-> bin 2, table is not moving-> bin 1
274 
275  sprintf(histo, "EEBCT crystals done");
276  CrystalsDone_ = dqmStore_->book1D(histo,histo,850,1.,851.);
277  CrystalsDone_->setAxisTitle("crystal", 1);
278  CrystalsDone_->setAxisTitle("step in the scan", 2);
279  //for a crystal done the corresponing bin is filled with the step in the
280  //autoscan pertainig to the given crystales
281 
282  sprintf(histo, "EEBCT crystal in beam vs event");
283  CrystalInBeam_vs_Event_ = dqmStore_->bookProfile(histo, histo, 20000,0.,400000.,1802,-101.,851.,"s");
285  CrystalInBeam_vs_Event_->setAxisTitle("crystal in beam", 2);
286  // 1 bin each 20 events
287  // when table is moving for just one events fill with -100
288 
289  sprintf(histo, "EEBCT readout crystals errors");
290  meEEBCaloReadCryErrors_ = dqmStore_->book1D(histo, histo, 425,1.,86.);
291  meEEBCaloReadCryErrors_->setAxisTitle("step in the scan", 1);
292 
293  sprintf(histo, "EEBCT average rec energy in the single crystal");
294  //meEEBCaloE1vsCry_ = dqmStore_->book1D(histo, histo, 85,1.,86.);
295  meEEBCaloE1vsCry_ = dqmStore_->bookProfile(histo, histo, 850,1.,851.,500,0.,9000.,"s");
296  meEEBCaloE1vsCry_->setAxisTitle("crystal", 1);
297  meEEBCaloE1vsCry_->setAxisTitle("rec energy (ADC)", 2);
298 
299  sprintf(histo, "EEBCT average rec energy in the 3x3 array");
300  //meEEBCaloE3x3vsCry_= dqmStore_->book1D(histo, histo,85,1.,86.);
301  meEEBCaloE3x3vsCry_ = dqmStore_->bookProfile(histo, histo, 850,1.,851.,500,0.,9000.,"s");
302  meEEBCaloE3x3vsCry_->setAxisTitle("crystal", 1);
303  meEEBCaloE3x3vsCry_->setAxisTitle("rec energy (ADC)", 2);
304 
305  sprintf(histo, "EEBCT number of entries");
306  meEEBCaloEntriesVsCry_ = dqmStore_->book1D(histo, histo,850,1.,851.);
307  meEEBCaloEntriesVsCry_->setAxisTitle("crystal", 1);
308  meEEBCaloEntriesVsCry_->setAxisTitle("number of events (prescaled)", 2);
309 
310  sprintf(histo, "EEBCT energy deposition in the 3x3");
311  meEEBCaloBeamCentered_ = dqmStore_->book2D(histo, histo,3,-1.5,1.5,3,-1.5,1.5);
312  meEEBCaloBeamCentered_->setAxisTitle("\\Delta \\eta", 1);
313  meEEBCaloBeamCentered_->setAxisTitle("\\Delta \\phi", 2);
314 
315  sprintf(histo, "EEBCT E1 in the max cry");
316  meEEBCaloE1MaxCry_= dqmStore_->book1D(histo,histo,500,0.,9000.);
317  meEEBCaloE1MaxCry_->setAxisTitle("rec Ene (ADC)", 1);
318 
319  sprintf(histo, "EEBCT Desynchronization vs step");
320  meEEBCaloDesync_= dqmStore_->book1D(histo, histo, 85 ,1.,86.);
321  meEEBCaloDesync_->setAxisTitle("step", 1);
322  meEEBCaloDesync_->setAxisTitle("Desynchronized events", 2);
323 
324  }
325 
326 }
327 
329 
330  if ( ! init_ ) return;
331 
332  if ( dqmStore_ ) {
333  dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
334  for (int i = 0; i < cryInArray_ ; i++) {
336  meBBCaloPulseProf_[i] = 0;
340  meBBCaloGains_[i] = 0;
342  meBBCaloEne_[i] = 0;
343 
344 // if ( meBBCaloPulseProfMoving_[i] ) dqmStore_->removeElement( meBBCaloPulseProfMoving_[i]->getName() );
345 // meBBCaloPulseProfMoving_[i] = 0;
346 // if ( meBBCaloPulseProfG12Moving_[i] ) dqmStore_->removeElement( meBBCaloPulseProfG12Moving_[i]->getName() );
347 // meBBCaloPulseProfG12Moving_[i] = 0;
348 // if ( meBBCaloGainsMoving_[i] ) dqmStore_->removeElement( meBBCaloGainsMoving_[i]->getName() );
349 // meBBCaloGainsMoving_[i] = 0;
350 // if ( meBBCaloEneMoving_[i] ) dqmStore_->removeElement( meBBCaloEneMoving_[i]->getName() );
351 // meBBCaloEneMoving_[i] = 0;
352  }
353 
354 // dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask/EnergyHistos");
355 // for(int u=0; u< 851;u++){
356 // if ( meBBCaloE3x3Cry_[u] ) dqmStore_->removeElement( meBBCaloE3x3Cry_[u]->getName() );
357 // meBBCaloE3x3Cry_[u] = 0;
358 // if ( meBBCaloE1Cry_[u] ) dqmStore_->removeElement( meBBCaloE1Cry_[u]->getName() );
359 // meBBCaloE1Cry_[u] = 0;
360 // }
361 
362 // dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
364  meBBCaloCryRead_ = 0;
365 // if ( meBBCaloCryReadMoving_ ) dqmStore_->removeElement( meBBCaloCryReadMoving_->getName() );
366 // meBBCaloCryReadMoving_ = 0;
372  meBBCaloE3x3_ = 0;
376  meBBCaloCryOnBeam_ = 0;
378  meBBCaloMaxEneCry_ = 0;
380  TableMoving_ = 0;
382  CrystalsDone_ = 0;
388  meEEBCaloE1vsCry_ = 0;
396  meEEBCaloE1MaxCry_ = 0;
398  meEEBCaloDesync_ = 0;
399  }
400 
401  init_ = false;
402 
403 }
404 
406 
407  edm::LogInfo("EEBeamCaloTask") << "analyzed " << ievt_ << " events";
408 
409  if ( enableCleanup_ ) this->cleanup();
410 
411 }
412 
414 
415  bool enable = false;
416 
418 
419  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
420 
421  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
422 
423  if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
424 
425  if ( dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH4 ||
426  dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH2 ) enable = true;
427  }
428 
429  } else {
430  edm::LogWarning("EEBeamCaloTask") << EcalRawDataCollection_ << " not available";
431  }
432 
433  if ( ! enable ) return;
434  if ( ! init_ ) this->setup();
435  ievt_++;
436 
437  edm::Handle<EcalTBEventHeader> pEventHeader;
438  const EcalTBEventHeader* evtHeader=0;
439 
440  if ( e.getByLabel(EcalTBEventHeader_, pEventHeader) ) {
441  evtHeader = pEventHeader.product(); // get a ptr to the product
442  } else {
443  std::cerr << "Error! can't get the product for the event header" << std::endl;
444  }
445 
446  //FIX ME, in the task we should use LV1 instead of ievt_ (prescaling)
447  int cry_in_beam = 0;
448  bool tb_moving = false;//just for test, to be filled with info from the event
449  int event = 0;
450 
451  if(evtHeader){
452  //cry_in_beam = evtHeader->nominalCrystalInBeam();
453  cry_in_beam = evtHeader->crystalInBeam();
454  tb_moving = evtHeader->tableIsMoving();
455  event = evtHeader->eventNumber();
456  if( evtHeader->syncError() ) {meEEBCaloDesync_->Fill(crystal_step_);}
457  }
458  else {
459  cry_in_beam = previous_cry_in_beam_;
460  tb_moving = lastStableStatus_;
461  event = previous_ev_num_ +10;
462  }
463 
464  previous_cry_in_beam_ = cry_in_beam;
466 
467  //cry_in_beam = 702;//just for test, to be filled with info from the event
468 
469  bool reset_histos_stable = false;
470  bool reset_histos_moving = false;
471 
472  bool skip_this_event = false;
473 
474 // if(ievt_ > 500){tb_moving=true; }
475 // if(ievt_ > 1000){tb_moving=false; cry_in_beam = 703;}
476 // if(ievt_ > 2000){tb_moving=true; }
477 // if(ievt_ > 2500){tb_moving=false; cry_in_beam = 704;}
478 // if(ievt_ == 3000){cry_in_beam = 702;}
479 // if(ievt_ == 3001){cry_in_beam = 703;}
480 // if(ievt_ > 3500){tb_moving=true; }
481 
482 // if(ievt_ > 3300){tb_moving=true; }
483 // if(ievt_ > 6100){tb_moving=false; cry_in_beam = 705;}
484 // if(ievt_ == 6201){tb_moving=true; }
485 // if(ievt_ > 9000){tb_moving=true; }
486 // if(ievt_ == 11021){tb_moving=false; }
487 // if(ievt_ > 12100){tb_moving=false; cry_in_beam = 706;}
488 // if(ievt_ > 15320){tb_moving=true; }
489 // if(ievt_ > 15500){tb_moving=false; cry_in_beam = 707;}
490 
491 
492  // //if(ievt_ > 20){tb_moving=true; }
493 // // if(ievt_ == 23){tb_moving=true; }
494 // if(ievt_ > 50){tb_moving=false; cry_in_beam = 705;}
495 // //if(ievt_ > 90 ){tb_moving=true; }
496 // if(ievt_ == 65){tb_moving=false; }
497 // if(ievt_ > 110){tb_moving=false; cry_in_beam = 706;}
498 // if(ievt_ == 116){cry_in_beam = 709;}
499 // //if(ievt_ > 115){tb_moving=true; }
500 // if(ievt_ > 150){tb_moving=false; cry_in_beam = 707;}
501 
502  // #include "DQM/EcalEndcapMonitorTasks/interface/cry_in_beam_run_ecs73214.h"
503 
504  if(ievt_ < 3){last_cry_in_beam_ = cry_in_beam;}
505 
506  if(tb_moving){
507 
508  TableMoving_->Fill(1);
509  if( PreviousTableStatus_[0] == 0 && PreviousTableStatus_[1] == 1 && lastStableStatus_ == 0){
510  reset_histos_moving=true;
511  wasFakeChange_ = false;
512  // ! Warning! This works in the assumption that the crystal in beam stay the same
513  // while the tb is moving and is set to the new one only when the table
514  // reaches the new position
515  lastStableStatus_ = 1;
516 
517  }
518  else if( PreviousTableStatus_[1] == 0) {
519  skip_this_event=true;
520  changed_tb_status_ = true;
521  wasFakeChange_ = true;
522  }
523  // just skip the first event when the table change status
525  PreviousTableStatus_[1] = 1;
526  }//end of if(tb_moving)
527 
528  else {// table is not moving
529 
530  TableMoving_->Fill(0);
531  if( PreviousTableStatus_[0] == 1 && PreviousTableStatus_[1] == 0 && lastStableStatus_ == 1){
532  //reset_histos_stable = true;
533  wasFakeChange_ = false;
534  lastStableStatus_ = 0;
535  }
536  else if(PreviousTableStatus_[1] == 1) {
537  skip_this_event=true;
538  changed_tb_status_ = true;
539  wasFakeChange_ = true;
540  }
541  // just skip the first event when the table change status
544 
545  // check also whether cry in beam has changed
547  reset_histos_stable=true;
548  wasFakeChange_ = false;
549  }
550  else if (PreviousCrystalinBeam_[2] != cry_in_beam){
551  changed_cry_in_beam_ = true;
552  skip_this_event=true;
553  wasFakeChange_ = true;
554  }
555  // }
556 
559  PreviousCrystalinBeam_[2] = cry_in_beam;
560  }
561  //if (! changed_tb_status_ && ! changed_cry_in_beam_ ){// standard data taking
562 
563  if( !tb_moving ) {CrystalInBeam_vs_Event_->Fill(event,float(cry_in_beam));}
564  else{CrystalInBeam_vs_Event_->Fill(event,-100); }
565  if ( !profileArranged_ ){
566  float dd=0;
567  int mbin =0;
568  for( int bin=1; bin < 20001; bin++ ){
570  if(temp>0){ dd= temp+0.01; mbin=bin; break;}
571  }
572  if(mbin >0) { CrystalInBeam_vs_Event_->Fill(20*mbin-1,dd);}
573  profileArranged_ = true;
574  }
575 
576  // }
577 // else{ // here there is either a step or a daq error
578 // // keep 10 events in a buffer waiting to decide for the step or the error
579 // if(tb_moving){cib_[evt_after_change_]=-100;}
580 // else {cib_[evt_after_change_]=cry_in_beam;}
581 
582 // if(evt_after_change_ >= 9){
583 // evt_after_change_ =0;
584 // if(wasFakeChange_){// here is an error: put the 10 events in the profile
585 // for(int u=0; u<10; u++){
586 // CrystalInBeam_vs_Event_->Fill(ievt_-9+u , cib_[u]);
587 // }
588 // }
589 // //for a real change just skip the first 10 events after change
590 // changed_tb_status_=false;
591 // changed_cry_in_beam_ = false;
592 // }
593 // else{evt_after_change_ ++;}
594 // }
595 
596  if(reset_histos_moving){
597  edm::LogInfo("EEBeamCaloTask") << "event " << ievt_ << " resetting histos for moving table!! ";
598 
599  // meEEBCaloE1vsCry_->setBinContent(crystal_step_ , meBBCaloEne_[4]->getMean() );
600  // meEEBCaloE1vsCry_->setBinError(crystal_step_ , meBBCaloEne_[4]->getRMS() );
601  // meEEBCaloE3x3vsCry_->setBinContent(crystal_step_ , meBBCaloE3x3_->getMean() );
602  // meEEBCaloE3x3vsCry_->setBinError(crystal_step_ , meBBCaloE3x3_->getRMS() );
603 
604  // meEEBCaloEntriesVsCry_->setBinContent(crystal_step_ , meBBCaloE3x3_->getEntries() );
605 
606  table_step_++;
607 
608 
609  //here the follwowing histos should be reset
610  // for (int u=0;u<cryInArray_;u++){
611  // meBBCaloPulseProfMoving_[u]->Reset();
612  // meBBCaloPulseProfG12Moving_[u]->Reset();
613  // meBBCaloGainsMoving_[u]->Reset();
614  // meBBCaloEneMoving_[u]->Reset();
615  // }
616  // meBBCaloCryReadMoving_->Reset();
618 
619  }
620 
621 
622  if(reset_histos_stable){
623  if( event - event_last_reset_ > 30){//to be tuned, to avoid a double reset for the change in the table status and
624  //in the crystal in beam. This works ONLY if the crystal in beam stay the same
625  // while the table is moving.
626  //One can also think to remove the reset of the histograms when the table change
627  // status from moving to stable, and to leave the reset only if the cry_in_beam changes.
628 
629  edm::LogInfo("EEBeamCaloTask") << "event " << ievt_ << " resetting histos for stable table!! ";
630 
631  // meEEBCaloE1vsCry_->setBinContent(crystal_step_ , meBBCaloEne_[4]->getMean() );
632  // meEEBCaloE1vsCry_->setBinError(crystal_step_ , meBBCaloEne_[4]->getRMS() );
633  // meEEBCaloE3x3vsCry_->setBinContent(crystal_step_ , meBBCaloE3x3_->getMean() );
634  // meEEBCaloE3x3vsCry_->setBinError(crystal_step_ , meBBCaloE3x3_->getRMS() );
635  // //
636  // meEEBCaloEntriesVsCry_->setBinContent(crystal_step_ , meBBCaloE3x3_->getEntries() );
637 
639 
640  last_cry_in_beam_ = cry_in_beam;
641  crystal_step_++;
642 
643  //here the follwowing histos should be reset
644  for (int u=0;u<cryInArray_;u++){
647  meBBCaloGains_[u]->Reset();
648  meBBCaloEne_[u]->Reset();
649  }
651  meBBCaloE3x3_->Reset();
653  }
654  }
655 
656  if(skip_this_event){
657  edm::LogInfo("EEBeamCaloTask") << "event " << event <<" analyzed: "<<ievt_ << " : skipping this event!! ";
658  return;}
659 
660  // now CrystalsDone_ contains the crystal on beam at the beginning fo a new step, and not when it has finished !!
661  // <5 just to avoid that we skip the event just after the reset and we do not set CrystalsDone_ .
662  // if( ievt_ - event_last_reset_ < 5){ CrystalsDone_->setBinContent(cry_in_beam , crystal_step_ );}
663  CrystalsDone_->setBinContent(cry_in_beam , crystal_step_ );
664  int eta_c = ( cry_in_beam-1)/20 ;
665  int phi_c = ( cry_in_beam-1)%20 ;
666 
667  float xie = eta_c + 0.5;
668  float xip = phi_c + 0.5;
669  if (!tb_moving) {meBBCaloCryOnBeam_->Fill(xie,xip);}
670 
672  e.getByLabel(EBDigiCollection_, digis);
673  int nebd = digis->size();
674 
675  meBBNumCaloCryRead_->Fill(nebd);
676 
677  //matrix 7x7 around cry in beam
678  int cry_to_beRead[49]; //0 or -1 for non existing crystals (eg 852)
679  for(int u=0;u<49;u++){cry_to_beRead[u]=0;}
680  // chech that all the crystals in the 7x7 exist
681  for(int de=-3; de<4; de++){
682  for(int dp=-3; dp<4; dp++){
683  //int cry_num = (phi_c+dp) + 20*(eta_c+de) +1;
684  int u = de -7*dp + 24;
685  bool existing_cry = (phi_c+dp) >= 0 && (phi_c+dp) <= 19 && (eta_c+de) >=0 && (eta_c+de) <= 84;
686  if(!existing_cry){cry_to_beRead[u]=-1;}
687  }
688  }
689 
690 
691  meEEBCaloEntriesVsCry_->Fill(cry_in_beam);
692 
693  for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
694 
695  EBDetId id = digiItr->id();
696 
697  int ic = id.ic();
698  int ie = (ic-1)/20;
699  int ip = (ic-1)%20;
700 
701  int deta_c= ie - eta_c;
702  int dphi_c= ip - phi_c;
703  if (! tb_moving){meBBCaloCryRead_->Fill(deta_c, dphi_c);}
704  //else {meBBCaloCryReadMoving_->Fill(deta_c, dphi_c);}
705 
706  if(std::abs(deta_c) > 3 || std::abs(dphi_c) > 3){continue;}
707  int i_toBeRead = deta_c -7*dphi_c + 24;
708  if( i_toBeRead > -1 && i_toBeRead <49){
709  cry_to_beRead[i_toBeRead]++;
710  //if( (ievt_ == 4000 || ievt_ == 13000 || ievt_ == 13002 ) && i_toBeRead == 5){ cry_to_beRead[i_toBeRead] -=1;}
711  }
712 
713  if(std::abs(deta_c) > 1 || std::abs(dphi_c) > 1){continue;}
714  int i_in_array = deta_c -3*dphi_c + 4;
715 
716  if( i_in_array < 0 || i_in_array > 8 ){continue;}
717 
718  EBDataFrame dataframe = (*digiItr);
719 
720  for (int i = 0; i < 10; i++) {
721  int adc = dataframe.sample(i).adc();
722  int gainid = dataframe.sample(i).gainId();
723  //if( (ievt_ == 15400 || ievt_ == 15600 || ievt_ == 15700 ) && i_in_array == 4 && i == 4){ gainid =2;}
724  //if( (ievt_ == 15400 || ievt_ == 15600 || ievt_ == 15700 ) && i_in_array == 6 && i == 6){ gainid =3;}
725 
726  if ( gainid == 1 ){// gain 12
727  if(! tb_moving){
728  meBBCaloPulseProfG12_[i_in_array]->Fill(i,float(adc));
729  meBBCaloPulseProf_[i_in_array]->Fill(i,float(adc));
730  meBBCaloGains_[i_in_array]->Fill(12);
731  }
732  //else{
733  // meBBCaloPulseProfG12Moving_[i_in_array]->Fill(i,float(adc));
734  // meBBCaloPulseProfMoving_[i_in_array]->Fill(i,float(adc));
735  // meBBCaloGainsMoving_[i_in_array]->Fill(12);
736  //}
737  }
738  else if ( gainid == 2 ){// gain 6
739  float val = (float(adc)-defaultPede_)*2 + defaultPede_;
740  if(! tb_moving){
741  meBBCaloPulseProf_[i_in_array]->Fill(i,val);
742  meBBCaloGains_[i_in_array]->Fill(6);
743  }
744  //else{
745  // meBBCaloPulseProfMoving_[i_in_array]->Fill(i,val);
746  // meBBCaloGainsMoving_[i_in_array]->Fill(6);
747  //}
748  }
749  else if ( gainid == 3 ){// gain 1
750  float val = (float(adc)-defaultPede_)*12 + defaultPede_;
751  if(! tb_moving){
752  meBBCaloPulseProf_[i_in_array]->Fill(i,val);
753  meBBCaloGains_[i_in_array]->Fill(1);
754  }
755  //else{
756  //meBBCaloPulseProfMoving_[i_in_array]->Fill(i,val);
757  //meBBCaloGainsMoving_[i_in_array]->Fill(1);
758  //}
759  }
760  }// end of loop over samples
761  }// end of loop over digis
762 
763  //now if everything was correct cry_to_beRead should be filled with 1 or -1 but not 0
764  bool all_cry_readout = true;
765 
766  // if( ievt_ == 4000 || ievt_ == 13000 || ievt_ == 13002 ) {all_cry_readout = false;}
767  if(all_cry_readout){ meBBCaloAllNeededCry_->Fill(1.5);}//bin3
768  else {
769  meBBCaloAllNeededCry_->Fill(-0.5);//bin1
770  if( tb_moving ) {meEEBCaloReadCryErrors_->Fill( crystal_step_+0.5 );}
772  }
773 
774  //the part involving rechits
775 
778  int neh = hits->size();
779  LogDebug("EEBeamCaloTask") << "event " << event <<" analyzed: "<< ievt_ << " hits collection size " << neh;
780  float ene3x3=0;
781  float maxEne = 0;
782  int ieM =-1, ipM = -1;//for the crystal with maximum energy deposition
783  float cryInBeamEne =0;
784  for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
785 
786  EBDetId id = hitItr->id();
787 
788  int ic = id.ic();
789  int ie = (ic-1)/20;
790  int ip = (ic-1)%20;
791 
792  int deta_c= ie - eta_c;
793  int dphi_c= ip - phi_c;
794 
795  int i_in_array = deta_c -3*dphi_c + 4;
796 
797  float R_ene = hitItr->amplitude();
798  if ( R_ene <= 0. ) R_ene = 0.0;
799  if(R_ene > maxEne){
800  maxEne=R_ene;
801  ieM =ie; ipM = ip;
802  }
803  if(std::abs(deta_c) > 1 || std::abs(dphi_c) > 1){continue;}
804  meEEBCaloBeamCentered_->Fill(deta_c,dphi_c,R_ene);
805 
806  if( i_in_array < 0 || i_in_array > 8 ){continue;}
807 
808  if(i_in_array == 4){cryInBeamEne = R_ene;}
809  if(! tb_moving){meBBCaloEne_[i_in_array]->Fill(R_ene);}
810  //else{meBBCaloEneMoving_[i_in_array]->Fill(R_ene);}
811  ene3x3 += R_ene;
812 
813  }//end of loop over rechits
814 
815  if (!tb_moving){
816  meBBCaloE3x3_->Fill(ene3x3);
817  meEEBCaloE1vsCry_->Fill(cry_in_beam , cryInBeamEne );
818  meEEBCaloE3x3vsCry_->Fill(cry_in_beam, ene3x3 );
819  // if( cry_in_beam > 0 && cry_in_beam < 851){
820  // meBBCaloE3x3Cry_[cry_in_beam]->Fill(ene3x3);
821  // meBBCaloE1Cry_[cry_in_beam]->Fill(cryInBeamEne);
822  // }
823  meBBCaloMaxEneCry_->Fill(ieM,ipM);
824  meEEBCaloE1MaxCry_->Fill(maxEne);
825  }
826  else{meBBCaloE3x3Moving_->Fill(ene3x3);}
828 }
829 
#define LogDebug(id)
int adc(sample_type sample)
get the ADC sample (12 bits)
T getParameter(std::string const &) const
MonitorElement * meEEBCaloE1MaxCry_
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
MonitorElement * meBBCaloEne_[cryInArray_]
void setBinContent(int binx, double content)
set content of bin (1-D)
void cleanup(void)
Cleanup.
MonitorElement * meEEBCaloE1vsCry_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
bool tableIsMoving() const
Tell if the table is Moving.
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2296
MonitorElement * CrystalsDone_
static const int defaultPede_
Some &quot;id&quot; conversions.
void beginJob(void)
BeginJob.
edm::InputTag EcalTBEventHeader_
void reset(void)
Reset.
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:28
MonitorElement * meEEBCaloDesync_
MonitorElement * meBBCaloPulseProfG12_[cryInArray_]
tuple histo
Definition: trackerHits.py:12
EEBeamCaloTask(const edm::ParameterSet &ps)
Constructor.
int gainId() const
get the gainId (2 bits)
int crystalInBeam() const
Returns the crystal which is being hit by the beam (in the internal SM numbering scheme) ...
MonitorElement * meEEBCaloReadCryErrors_
MonitorElement * meBBCaloE3x3_
MonitorElement * meBBCaloGains_[cryInArray_]
edm::InputTag EBDigiCollection_
void Fill(long long x)
MonitorElement * meBBCaloE3x3Moving_
int PreviousTableStatus_[2]
void removeElement(const std::string &name)
Definition: DQMStore.cc:2338
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
edm::InputTag EcalRawDataCollection_
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
MonitorElement * TableMoving_
MonitorElement * meBBCaloCryRead_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:833
std::string prefixME_
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:94
int PreviousCrystalinBeam_[3]
MonitorElement * meBBCaloPulseProf_[cryInArray_]
DQMStore * dqmStore_
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:43
MonitorElement * meEEBCaloEntriesVsCry_
MonitorElement * meBBCaloCryOnBeam_
int eventNumber() const
Returns the event number.
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
T const * product() const
Definition: Handle.h:74
MonitorElement * CrystalInBeam_vs_Event_
edm::InputTag EcalUncalibratedRecHitCollection_
double getBinContent(int binx) const
get content of bin (1-D)
static const int cryInArray_
MonitorElement * meBBCaloMaxEneCry_
MonitorElement * meBBCaloAllNeededCry_
virtual ~EEBeamCaloTask()
Destructor.
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:130
MonitorElement * meBBNumCaloCryRead_
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
MonitorElement * meEEBCaloE3x3vsCry_
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 * meEEBCaloBeamCentered_
void setup(void)
Setup.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
void endJob(void)
EndJob.
bool syncError() const
is there any sync error
int adc() const
get the ADC sample (12 bits)