00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <fstream>
00012 #include <vector>
00013
00014 #include "FWCore/ServiceRegistry/interface/Service.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020
00021 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00022 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00023 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00024 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00025 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
00026 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00027
00028 #include "TBDataFormats/EcalTBObjects/interface/EcalTBCollections.h"
00029
00030 #include <DQM/EcalCommon/interface/Numbers.h>
00031
00032 #include <DQM/EcalEndcapMonitorTasks/interface/EEBeamCaloTask.h>
00033
00034 using namespace cms;
00035 using namespace edm;
00036 using namespace std;
00037
00038 EEBeamCaloTask::EEBeamCaloTask(const ParameterSet& ps){
00039
00040 init_ = false;
00041
00042 dqmStore_ = Service<DQMStore>().operator->();
00043
00044 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00045
00046 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00047
00048 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00049
00050 EcalTBEventHeader_ = ps.getParameter<edm::InputTag>("EcalTBEventHeader");
00051 EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00052 EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
00053 EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
00054
00055 for (int i = 0; i < cryInArray_ ; i++) {
00056 meBBCaloPulseProf_[i]=0;
00057 meBBCaloPulseProfG12_[i]=0;
00058 meBBCaloGains_[i]=0;
00059 meBBCaloEne_[i]=0;
00060
00061
00062
00063
00064
00065 }
00066
00067 meBBCaloCryRead_ = 0;
00068
00069
00070 meBBNumCaloCryRead_ = 0;
00071 meBBCaloAllNeededCry_ = 0;
00072
00073 meBBCaloE3x3_ = 0;
00074 meBBCaloE3x3Moving_ = 0;
00075
00076 meBBCaloCryOnBeam_ = 0;
00077 meBBCaloMaxEneCry_ = 0;
00078 TableMoving_ = 0;
00079
00080 CrystalsDone_ = 0;
00081 CrystalInBeam_vs_Event_ = 0;
00082 meEEBCaloReadCryErrors_ = 0;
00083 meEEBCaloE1vsCry_ = 0;
00084 meEEBCaloE3x3vsCry_ = 0;
00085 meEEBCaloEntriesVsCry_ = 0;
00086 meEEBCaloBeamCentered_ = 0;
00087
00088 meEEBCaloE1MaxCry_ = 0;
00089
00090
00091
00092
00093
00094 meEEBCaloDesync_ = 0;
00095
00096 }
00097
00098 EEBeamCaloTask::~EEBeamCaloTask(){
00099
00100 }
00101
00102 void EEBeamCaloTask::beginJob(const EventSetup& c){
00103
00104 ievt_ = 0;
00105
00106 profileArranged_ = false;
00107
00108 if ( dqmStore_ ) {
00109 dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
00110 dqmStore_->rmdir(prefixME_ + "/EEBeamCaloTask");
00111 }
00112
00113 Numbers::initGeometry(c, false);
00114
00115 }
00116
00117 void EEBeamCaloTask::beginRun(const Run& r, const EventSetup& c) {
00118
00119 if ( ! mergeRuns_ ) this->reset();
00120
00121 }
00122
00123 void EEBeamCaloTask::endRun(const Run& r, const EventSetup& c) {
00124
00125 }
00126
00127 void EEBeamCaloTask::reset(void) {
00128
00129 for (int i = 0; i < cryInArray_ ; i++) {
00130 if ( meBBCaloPulseProf_[i] ) meBBCaloPulseProf_[i]->Reset();
00131 if ( meBBCaloPulseProfG12_[i] ) meBBCaloPulseProfG12_[i]->Reset();
00132 if ( meBBCaloGains_[i] ) meBBCaloGains_[i]->Reset();
00133 if ( meBBCaloEne_[i] ) meBBCaloEne_[i]->Reset();
00134
00135
00136
00137
00138
00139 }
00140
00141
00142
00143
00144
00145
00146 if ( meBBCaloCryRead_ ) meBBCaloCryRead_->Reset();
00147
00148 if ( meBBCaloAllNeededCry_ ) meBBCaloAllNeededCry_->Reset();
00149 if ( meBBNumCaloCryRead_ ) meBBNumCaloCryRead_->Reset();
00150 if ( meBBCaloE3x3_ ) meBBCaloE3x3_->Reset();
00151 if ( meBBCaloE3x3Moving_ ) meBBCaloE3x3Moving_->Reset();
00152 if ( meBBCaloCryOnBeam_ ) meBBCaloCryOnBeam_->Reset();
00153 if ( meBBCaloMaxEneCry_ ) meBBCaloMaxEneCry_->Reset();
00154 if ( TableMoving_ ) TableMoving_->Reset();
00155 if ( CrystalsDone_ ) CrystalsDone_->Reset();
00156 if ( CrystalInBeam_vs_Event_ ) CrystalInBeam_vs_Event_->Reset();
00157 if( meEEBCaloReadCryErrors_ ) meEEBCaloReadCryErrors_->Reset();
00158 if( meEEBCaloE1vsCry_ ) meEEBCaloE1vsCry_->Reset();
00159 if( meEEBCaloE3x3vsCry_ ) meEEBCaloE3x3vsCry_->Reset();
00160 if( meEEBCaloEntriesVsCry_ ) meEEBCaloEntriesVsCry_->Reset();
00161 if( meEEBCaloBeamCentered_ ) meEEBCaloBeamCentered_->Reset();
00162 if( meEEBCaloE1MaxCry_ ) meEEBCaloE1MaxCry_->Reset();
00163 if( meEEBCaloDesync_ ) meEEBCaloDesync_->Reset();
00164
00165 }
00166
00167 void EEBeamCaloTask::setup(void){
00168
00169 init_ = true;
00170 profileArranged_= false;
00171 char histo[200];
00172
00173 PreviousTableStatus_[0]=0;
00174 PreviousTableStatus_[1]=0;
00175
00176 PreviousCrystalinBeam_[0] = 0;
00177 PreviousCrystalinBeam_[1] = 0;
00178 PreviousCrystalinBeam_[2] = -1;
00179
00180 lastStableStatus_=0;
00181 for(int u=0;u<10;u++){cib_[u]=0;}
00182 changed_tb_status_= false;
00183 changed_cry_in_beam_ = false;
00184 evt_after_change_ =0;
00185 wasFakeChange_= false;
00186 table_step_=1;
00187 crystal_step_=1;
00188 event_last_reset_ = 0;
00189 last_cry_in_beam_ = 0;
00190 previous_cry_in_beam_ = 1;
00191
00192 if ( dqmStore_ ) {
00193 dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
00194
00195 for (int i = 0; i < cryInArray_ ; i++) {
00196 sprintf(histo, "EEBCT pulse profile cry %01d", i+1);
00197
00198 meBBCaloPulseProf_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,50000,0.,50000.,"s");
00199
00200 sprintf(histo, "EEBCT pulse profile in G12 cry %01d", i+1);
00201 meBBCaloPulseProfG12_[i] = dqmStore_->bookProfile(histo, histo, 10,0.,10.,4096,0.,4096.,"s");
00202 meBBCaloPulseProfG12_[i]->setAxisTitle("#sample", 1);
00203 meBBCaloPulseProfG12_[i]->setAxisTitle("ADC", 2);
00204
00205 sprintf(histo, "EEBCT found gains cry %01d", i+1);
00206 meBBCaloGains_[i] = dqmStore_->book1D(histo,histo,14,0.,14.);
00207 meBBCaloGains_[i]->setAxisTitle("gain", 1);
00208
00209
00210 sprintf(histo, "EEBCT rec energy cry %01d", i+1);
00211 meBBCaloEne_[i] = dqmStore_->book1D(histo,histo,500,0.,9000.);
00212 meBBCaloEne_[i]->setAxisTitle("rec ene (ADC)", 1);
00213
00214
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 sprintf(histo, "EEBCT readout crystals");
00245 meBBCaloCryRead_ = dqmStore_->book2D(histo,histo,9,-4.,5.,9,-4.,5.);
00246
00247
00248
00249
00250
00251
00252 sprintf(histo, "EEBCT all needed crystals readout");
00253 meBBCaloAllNeededCry_ = dqmStore_->book1D(histo,histo,3,-1.,2.);
00254
00255
00256 sprintf(histo, "EEBCT readout crystals number");
00257 meBBNumCaloCryRead_ = dqmStore_->book1D(histo,histo,851,0.,851.);
00258 meBBNumCaloCryRead_->setAxisTitle("number of read crystals", 1);
00259
00260 sprintf(histo, "EEBCT rec Ene sum 3x3");
00261 meBBCaloE3x3_ = dqmStore_->book1D(histo,histo,500,0.,9000.);
00262 meBBCaloE3x3_->setAxisTitle("rec ene (ADC)", 1);
00263
00264
00265 sprintf(histo, "EEBCT rec Ene sum 3x3 table moving");
00266 meBBCaloE3x3Moving_ = dqmStore_->book1D(histo,histo,500,0.,9000.);
00267
00268
00269 sprintf(histo, "EEBCT crystal on beam");
00270 meBBCaloCryOnBeam_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00271
00272 sprintf(histo, "EEBCT crystal with maximum rec energy");
00273 meBBCaloMaxEneCry_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00274
00275 sprintf(histo, "EEBCT table is moving");
00276 TableMoving_ = dqmStore_->book1D(histo,histo,2,0.,1.1);
00277 TableMoving_->setAxisTitle("table status (0=stable, 1=moving)", 1);
00278
00279
00280 sprintf(histo, "EEBCT crystals done");
00281 CrystalsDone_ = dqmStore_->book1D(histo,histo,850,1.,851.);
00282 CrystalsDone_->setAxisTitle("crystal", 1);
00283 CrystalsDone_->setAxisTitle("step in the scan", 2);
00284
00285
00286
00287 sprintf(histo, "EEBCT crystal in beam vs event");
00288 CrystalInBeam_vs_Event_ = dqmStore_->bookProfile(histo, histo, 20000,0.,400000.,1802,-101.,851.,"s");
00289 CrystalInBeam_vs_Event_->setAxisTitle("event", 1);
00290 CrystalInBeam_vs_Event_->setAxisTitle("crystal in beam", 2);
00291
00292
00293
00294
00295 sprintf(histo, "EEBCT readout crystals errors");
00296 meEEBCaloReadCryErrors_ = dqmStore_->book1D(histo, histo, 425,1.,86.);
00297 meEEBCaloReadCryErrors_->setAxisTitle("step in the scan", 1);
00298
00299 sprintf(histo, "EEBCT average rec energy in the single crystal");
00300
00301 meEEBCaloE1vsCry_ = dqmStore_->bookProfile(histo, histo, 850,1.,851.,500,0.,9000.,"s");
00302 meEEBCaloE1vsCry_->setAxisTitle("crystal", 1);
00303 meEEBCaloE1vsCry_->setAxisTitle("rec energy (ADC)", 2);
00304
00305 sprintf(histo, "EEBCT average rec energy in the 3x3 array");
00306
00307 meEEBCaloE3x3vsCry_ = dqmStore_->bookProfile(histo, histo, 850,1.,851.,500,0.,9000.,"s");
00308 meEEBCaloE3x3vsCry_->setAxisTitle("crystal", 1);
00309 meEEBCaloE3x3vsCry_->setAxisTitle("rec energy (ADC)", 2);
00310
00311 sprintf(histo, "EEBCT number of entries");
00312 meEEBCaloEntriesVsCry_ = dqmStore_->book1D(histo, histo,850,1.,851.);
00313 meEEBCaloEntriesVsCry_->setAxisTitle("crystal", 1);
00314 meEEBCaloEntriesVsCry_->setAxisTitle("number of events (prescaled)", 2);
00315
00316 sprintf(histo, "EEBCT energy deposition in the 3x3");
00317 meEEBCaloBeamCentered_ = dqmStore_->book2D(histo, histo,3,-1.5,1.5,3,-1.5,1.5);
00318 meEEBCaloBeamCentered_->setAxisTitle("\\Delta \\eta", 1);
00319 meEEBCaloBeamCentered_->setAxisTitle("\\Delta \\phi", 2);
00320
00321 sprintf(histo, "EEBCT E1 in the max cry");
00322 meEEBCaloE1MaxCry_= dqmStore_->book1D(histo,histo,500,0.,9000.);
00323 meEEBCaloE1MaxCry_->setAxisTitle("rec Ene (ADC)", 1);
00324
00325 sprintf(histo, "EEBCT Desynchronization vs step");
00326 meEEBCaloDesync_= dqmStore_->book1D(histo, histo, 85 ,1.,86.);
00327 meEEBCaloDesync_->setAxisTitle("step", 1);
00328 meEEBCaloDesync_->setAxisTitle("Desynchronized events", 2);
00329
00330 }
00331
00332 }
00333
00334 void EEBeamCaloTask::cleanup(void){
00335
00336 if ( ! init_ ) return;
00337
00338 if ( dqmStore_ ) {
00339 dqmStore_->setCurrentFolder(prefixME_ + "/EEBeamCaloTask");
00340 for (int i = 0; i < cryInArray_ ; i++) {
00341 if ( meBBCaloPulseProf_[i] ) dqmStore_->removeElement( meBBCaloPulseProf_[i]->getName() );
00342 meBBCaloPulseProf_[i] = 0;
00343 if ( meBBCaloPulseProfG12_[i] ) dqmStore_->removeElement( meBBCaloPulseProfG12_[i]->getName() );
00344 meBBCaloPulseProfG12_[i] = 0;
00345 if ( meBBCaloGains_[i] ) dqmStore_->removeElement( meBBCaloGains_[i]->getName() );
00346 meBBCaloGains_[i] = 0;
00347 if ( meBBCaloEne_[i] ) dqmStore_->removeElement( meBBCaloEne_[i]->getName() );
00348 meBBCaloEne_[i] = 0;
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 if ( meBBCaloCryRead_ ) dqmStore_->removeElement( meBBCaloCryRead_->getName() );
00370 meBBCaloCryRead_ = 0;
00371
00372
00373 if ( meBBCaloAllNeededCry_ ) dqmStore_->removeElement( meBBCaloAllNeededCry_->getName() );
00374 meBBCaloAllNeededCry_ = 0;
00375 if ( meBBNumCaloCryRead_ ) dqmStore_->removeElement( meBBNumCaloCryRead_->getName() );
00376 meBBNumCaloCryRead_ = 0;
00377 if ( meBBCaloE3x3_ ) dqmStore_->removeElement( meBBCaloE3x3_->getName() );
00378 meBBCaloE3x3_ = 0;
00379 if ( meBBCaloE3x3Moving_ ) dqmStore_->removeElement( meBBCaloE3x3Moving_->getName() );
00380 meBBCaloE3x3Moving_ = 0;
00381 if ( meBBCaloCryOnBeam_ ) dqmStore_->removeElement( meBBCaloCryOnBeam_->getName() );
00382 meBBCaloCryOnBeam_ = 0;
00383 if ( meBBCaloMaxEneCry_ ) dqmStore_->removeElement( meBBCaloMaxEneCry_->getName() );
00384 meBBCaloMaxEneCry_ = 0;
00385 if ( TableMoving_ ) dqmStore_->removeElement( TableMoving_->getName() );
00386 TableMoving_ = 0;
00387 if ( CrystalsDone_ ) dqmStore_->removeElement( CrystalsDone_->getName() );
00388 CrystalsDone_ = 0;
00389 if ( CrystalInBeam_vs_Event_ ) dqmStore_->removeElement( CrystalInBeam_vs_Event_->getName() );
00390 CrystalInBeam_vs_Event_ = 0;
00391 if( meEEBCaloReadCryErrors_ ) dqmStore_->removeElement( meEEBCaloReadCryErrors_->getName() );
00392 meEEBCaloReadCryErrors_ = 0;
00393 if( meEEBCaloE1vsCry_ ) dqmStore_->removeElement( meEEBCaloE1vsCry_->getName() );
00394 meEEBCaloE1vsCry_ = 0;
00395 if( meEEBCaloE3x3vsCry_ ) dqmStore_->removeElement( meEEBCaloE3x3vsCry_->getName() );
00396 meEEBCaloE3x3vsCry_ = 0;
00397 if( meEEBCaloEntriesVsCry_ ) dqmStore_->removeElement( meEEBCaloEntriesVsCry_->getName() );
00398 meEEBCaloEntriesVsCry_ = 0;
00399 if( meEEBCaloBeamCentered_ ) dqmStore_->removeElement( meEEBCaloBeamCentered_->getName() );
00400 meEEBCaloBeamCentered_ = 0;
00401 if( meEEBCaloE1MaxCry_ ) dqmStore_->removeElement(meEEBCaloE1MaxCry_->getName() );
00402 meEEBCaloE1MaxCry_ = 0;
00403 if( meEEBCaloDesync_ ) dqmStore_->removeElement(meEEBCaloDesync_->getName() );
00404 meEEBCaloDesync_ = 0;
00405 }
00406
00407 init_ = false;
00408
00409 }
00410
00411 void EEBeamCaloTask::endJob(void){
00412
00413 LogInfo("EEBeamCaloTask") << "analyzed " << ievt_ << " events";
00414
00415 if ( enableCleanup_ ) this->cleanup();
00416
00417 }
00418
00419 void EEBeamCaloTask::analyze(const Event& e, const EventSetup& c){
00420
00421 bool enable = false;
00422
00423 Handle<EcalRawDataCollection> dcchs;
00424
00425 if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00426
00427 for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00428
00429 if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00430
00431 if ( dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH4 ||
00432 dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH2 ) enable = true;
00433 }
00434
00435 } else {
00436 LogWarning("EEBeamCaloTask") << EcalRawDataCollection_ << " not available";
00437 }
00438
00439 if ( ! enable ) return;
00440 if ( ! init_ ) this->setup();
00441 ievt_++;
00442
00443 Handle<EcalTBEventHeader> pEventHeader;
00444 const EcalTBEventHeader* evtHeader=0;
00445
00446 if ( e.getByLabel(EcalTBEventHeader_, pEventHeader) ) {
00447 evtHeader = pEventHeader.product();
00448 } else {
00449 std::cerr << "Error! can't get the product for the event header" << std::endl;
00450 }
00451
00452
00453 int cry_in_beam = 0;
00454 bool tb_moving = false;
00455 int event = 0;
00456
00457 if(evtHeader){
00458
00459 cry_in_beam = evtHeader->crystalInBeam();
00460 tb_moving = evtHeader->tableIsMoving();
00461 event = evtHeader->eventNumber();
00462 if( evtHeader->syncError() ) {meEEBCaloDesync_->Fill(crystal_step_);}
00463 }
00464 else {
00465 cry_in_beam = previous_cry_in_beam_;
00466 tb_moving = lastStableStatus_;
00467 event = previous_ev_num_ +10;
00468 }
00469
00470 previous_cry_in_beam_ = cry_in_beam;
00471 previous_ev_num_ = event;
00472
00473
00474
00475 bool reset_histos_stable = false;
00476 bool reset_histos_moving = false;
00477
00478 bool skip_this_event = false;
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510 if(ievt_ < 3){last_cry_in_beam_ = cry_in_beam;}
00511
00512 if(tb_moving){
00513
00514 TableMoving_->Fill(1);
00515 if( PreviousTableStatus_[0] == 0 && PreviousTableStatus_[1] == 1 && lastStableStatus_ == 0){
00516 reset_histos_moving=true;
00517 wasFakeChange_ = false;
00518
00519
00520
00521 lastStableStatus_ = 1;
00522
00523 }
00524 else if( PreviousTableStatus_[1] == 0) {
00525 skip_this_event=true;
00526 changed_tb_status_ = true;
00527 wasFakeChange_ = true;
00528 }
00529
00530 PreviousTableStatus_[0] = PreviousTableStatus_[1];
00531 PreviousTableStatus_[1] = 1;
00532 }
00533
00534 else {
00535
00536 TableMoving_->Fill(0);
00537 if( PreviousTableStatus_[0] == 1 && PreviousTableStatus_[1] == 0 && lastStableStatus_ == 1){
00538
00539 wasFakeChange_ = false;
00540 lastStableStatus_ = 0;
00541 }
00542 else if(PreviousTableStatus_[1] == 1) {
00543 skip_this_event=true;
00544 changed_tb_status_ = true;
00545 wasFakeChange_ = true;
00546 }
00547
00548 PreviousTableStatus_[0]=PreviousTableStatus_[1];
00549 PreviousTableStatus_[1]=0;
00550
00551
00552 if( PreviousCrystalinBeam_[0] == PreviousCrystalinBeam_[1] && PreviousCrystalinBeam_[1] != PreviousCrystalinBeam_[2] && PreviousCrystalinBeam_[2] == cry_in_beam ){
00553 reset_histos_stable=true;
00554 wasFakeChange_ = false;
00555 }
00556 else if (PreviousCrystalinBeam_[2] != cry_in_beam){
00557 changed_cry_in_beam_ = true;
00558 skip_this_event=true;
00559 wasFakeChange_ = true;
00560 }
00561
00562
00563 PreviousCrystalinBeam_[0] = PreviousCrystalinBeam_[1];
00564 PreviousCrystalinBeam_[1] = PreviousCrystalinBeam_[2];
00565 PreviousCrystalinBeam_[2] = cry_in_beam;
00566 }
00567
00568
00569 if( !tb_moving ) {CrystalInBeam_vs_Event_->Fill(event,float(cry_in_beam));}
00570 else{CrystalInBeam_vs_Event_->Fill(event,-100); }
00571 if ( !profileArranged_ ){
00572 float dd=0;
00573 int mbin =0;
00574 for( int bin=1; bin < 20001; bin++ ){
00575 float temp = CrystalInBeam_vs_Event_->getBinContent(bin);
00576 if(temp>0){ dd= temp+0.01; mbin=bin; break;}
00577 }
00578 if(mbin >0) { CrystalInBeam_vs_Event_->Fill(20*mbin-1,dd);}
00579 profileArranged_ = true;
00580 }
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602 if(reset_histos_moving){
00603 LogInfo("EEBeamCaloTask") << "event " << ievt_ << " resetting histos for moving table!! ";
00604
00605
00606
00607
00608
00609
00610
00611
00612 table_step_++;
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623 meBBCaloE3x3Moving_->Reset();
00624
00625 }
00626
00627
00628 if(reset_histos_stable){
00629 if( event - event_last_reset_ > 30){
00630
00631
00632
00633
00634
00635 LogInfo("EEBeamCaloTask") << "event " << ievt_ << " resetting histos for stable table!! ";
00636
00637
00638
00639
00640
00641
00642
00643
00644 event_last_reset_ = event;
00645
00646 last_cry_in_beam_ = cry_in_beam;
00647 crystal_step_++;
00648
00649
00650 for (int u=0;u<cryInArray_;u++){
00651 meBBCaloPulseProf_[u]->Reset();
00652 meBBCaloPulseProfG12_[u]->Reset();
00653 meBBCaloGains_[u]->Reset();
00654 meBBCaloEne_[u]->Reset();
00655 }
00656 meBBCaloCryRead_->Reset();
00657 meBBCaloE3x3_->Reset();
00658 meEEBCaloBeamCentered_->Reset();
00659 }
00660 }
00661
00662 if(skip_this_event){
00663 LogInfo("EEBeamCaloTask") << "event " << event <<" analyzed: "<<ievt_ << " : skipping this event!! ";
00664 return;}
00665
00666
00667
00668
00669 CrystalsDone_->setBinContent(cry_in_beam , crystal_step_ );
00670 int eta_c = ( cry_in_beam-1)/20 ;
00671 int phi_c = ( cry_in_beam-1)%20 ;
00672
00673 float xie = eta_c + 0.5;
00674 float xip = phi_c + 0.5;
00675 if (!tb_moving) {meBBCaloCryOnBeam_->Fill(xie,xip);}
00676
00677 Handle<EBDigiCollection> digis;
00678 e.getByLabel(EBDigiCollection_, digis);
00679 int nebd = digis->size();
00680
00681
00682 meBBNumCaloCryRead_->Fill(nebd);
00683
00684
00685 int cry_to_beRead[49];
00686 for(int u=0;u<49;u++){cry_to_beRead[u]=0;}
00687
00688 for(int de=-3; de<4; de++){
00689 for(int dp=-3; dp<4; dp++){
00690
00691 int u = de -7*dp + 24;
00692 bool existing_cry = (phi_c+dp) >= 0 && (phi_c+dp) <= 19 && (eta_c+de) >=0 && (eta_c+de) <= 84;
00693 if(!existing_cry){cry_to_beRead[u]=-1;}
00694 }
00695 }
00696
00697
00698 meEEBCaloEntriesVsCry_->Fill(cry_in_beam);
00699
00700 for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00701
00702 EBDetId id = digiItr->id();
00703
00704 int ic = id.ic();
00705 int ie = (ic-1)/20;
00706 int ip = (ic-1)%20;
00707
00708 int deta_c= ie - eta_c;
00709 int dphi_c= ip - phi_c;
00710 if (! tb_moving){meBBCaloCryRead_->Fill(deta_c, dphi_c);}
00711
00712
00713 if(abs(deta_c) >3 || abs(dphi_c) >3){continue;}
00714 int i_toBeRead = deta_c -7*dphi_c + 24;
00715 if( i_toBeRead > -1 && i_toBeRead <49){
00716 cry_to_beRead[i_toBeRead]++;
00717
00718 }
00719
00720 if(abs(deta_c) >1 || abs(dphi_c) >1){continue;}
00721 int i_in_array = deta_c -3*dphi_c + 4;
00722
00723
00724
00725
00726
00727
00728 if( i_in_array < 0 || i_in_array > 8 ){continue;}
00729
00730 EBDataFrame dataframe = (*digiItr);
00731
00732 for (int i = 0; i < 10; i++) {
00733 int adc = dataframe.sample(i).adc();
00734 int gainid = dataframe.sample(i).gainId();
00735
00736
00737
00738 if ( gainid == 1 ){
00739 if(! tb_moving){
00740 meBBCaloPulseProfG12_[i_in_array]->Fill(i,float(adc));
00741 meBBCaloPulseProf_[i_in_array]->Fill(i,float(adc));
00742 meBBCaloGains_[i_in_array]->Fill(12);
00743 }
00744
00745
00746
00747
00748
00749 }
00750 else if ( gainid == 2 ){
00751 float val = (float(adc)-defaultPede_)*2 + defaultPede_;
00752 if(! tb_moving){
00753 meBBCaloPulseProf_[i_in_array]->Fill(i,val);
00754 meBBCaloGains_[i_in_array]->Fill(6);
00755 }
00756
00757
00758
00759
00760 }
00761 else if ( gainid == 3 ){
00762 float val = (float(adc)-defaultPede_)*12 + defaultPede_;
00763 if(! tb_moving){
00764 meBBCaloPulseProf_[i_in_array]->Fill(i,val);
00765 meBBCaloGains_[i_in_array]->Fill(1);
00766 }
00767
00768
00769
00770
00771 }
00772 }
00773 }
00774
00775
00776 bool all_cry_readout = true;
00777
00778
00779 if(all_cry_readout){ meBBCaloAllNeededCry_->Fill(1.5);}
00780 else {
00781 meBBCaloAllNeededCry_->Fill(-0.5);
00782 if( tb_moving ) {meEEBCaloReadCryErrors_->Fill( crystal_step_+0.5 );}
00783 else {meEEBCaloReadCryErrors_->Fill( crystal_step_ );}
00784 }
00785
00786
00787
00788 Handle<EcalUncalibratedRecHitCollection> hits;
00789 e.getByLabel(EcalUncalibratedRecHitCollection_, hits);
00790 int neh = hits->size();
00791 LogDebug("EEBeamCaloTask") << "event " << event <<" analyzed: "<< ievt_ << " hits collection size " << neh;
00792 float ene3x3=0;
00793 float maxEne = 0;
00794 int ieM =-1, ipM = -1;
00795 float cryInBeamEne =0;
00796 for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00797
00798 EBDetId id = hitItr->id();
00799
00800 int ic = id.ic();
00801 int ie = (ic-1)/20;
00802 int ip = (ic-1)%20;
00803
00804 int deta_c= ie - eta_c;
00805 int dphi_c= ip - phi_c;
00806
00807
00808 int i_in_array = deta_c -3*dphi_c + 4;
00809
00810
00811
00812
00813 float R_ene = hitItr->amplitude();
00814 if ( R_ene <= 0. ) R_ene = 0.0;
00815 if(R_ene > maxEne){
00816 maxEne=R_ene;
00817 ieM =ie; ipM = ip;
00818 }
00819 if(abs(deta_c) >1 || abs(dphi_c) >1){continue;}
00820 meEEBCaloBeamCentered_->Fill(deta_c,dphi_c,R_ene);
00821
00822 if( i_in_array < 0 || i_in_array > 8 ){continue;}
00823
00824
00825
00826 if(i_in_array == 4){cryInBeamEne = R_ene;}
00827 if(! tb_moving){meBBCaloEne_[i_in_array]->Fill(R_ene);}
00828
00829 ene3x3 += R_ene;
00830
00831 }
00832
00833 if (!tb_moving){
00834 meBBCaloE3x3_->Fill(ene3x3);
00835 meEEBCaloE1vsCry_->Fill(cry_in_beam , cryInBeamEne );
00836 meEEBCaloE3x3vsCry_->Fill(cry_in_beam, ene3x3 );
00837
00838
00839
00840
00841 meBBCaloMaxEneCry_->Fill(ieM,ipM);
00842 meEEBCaloE1MaxCry_->Fill(maxEne);
00843 }
00844 else{meBBCaloE3x3Moving_->Fill(ene3x3);}
00846 }
00847