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