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/EcalBarrelMonitorTasks/interface/EBBeamCaloTask.h"
00032
00033 EBBeamCaloTask::EBBeamCaloTask(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 meEBBCaloReadCryErrors_ = 0;
00078 meEBBCaloE1vsCry_ = 0;
00079 meEBBCaloE3x3vsCry_ = 0;
00080 meEBBCaloEntriesVsCry_ = 0;
00081 meEBBCaloBeamCentered_ = 0;
00082
00083 meEBBCaloE1MaxCry_ = 0;
00084
00085
00086
00087
00088
00089 meEBBCaloDesync_ = 0;
00090
00091 }
00092
00093 EBBeamCaloTask::~EBBeamCaloTask(){
00094
00095 }
00096
00097 void EBBeamCaloTask::beginJob(void){
00098
00099 ievt_ = 0;
00100
00101 profileArranged_ = false;
00102
00103 if ( dqmStore_ ) {
00104 dqmStore_->setCurrentFolder(prefixME_ + "/EBBeamCaloTask");
00105 dqmStore_->rmdir(prefixME_ + "/EBBeamCaloTask");
00106 }
00107
00108 }
00109
00110 void EBBeamCaloTask::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 EBBeamCaloTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00119
00120 }
00121
00122 void EBBeamCaloTask::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( meEBBCaloReadCryErrors_ ) meEBBCaloReadCryErrors_->Reset();
00153 if( meEBBCaloE1vsCry_ ) meEBBCaloE1vsCry_->Reset();
00154 if( meEBBCaloE3x3vsCry_ ) meEBBCaloE3x3vsCry_->Reset();
00155 if( meEBBCaloEntriesVsCry_ ) meEBBCaloEntriesVsCry_->Reset();
00156 if( meEBBCaloBeamCentered_ ) meEBBCaloBeamCentered_->Reset();
00157 if( meEBBCaloE1MaxCry_ ) meEBBCaloE1MaxCry_->Reset();
00158 if( meEBBCaloDesync_ ) meEBBCaloDesync_->Reset();
00159
00160 }
00161
00162 void EBBeamCaloTask::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_ + "/EBBeamCaloTask");
00189
00190 for (int i = 0; i < cryInArray_ ; i++) {
00191 sprintf(histo, "EBBCT 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, "EBBCT 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, "EBBCT 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, "EBBCT 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, "EBBCT readout crystals");
00240 meBBCaloCryRead_ = dqmStore_->book2D(histo,histo,9,-4.,5.,9,-4.,5.);
00241
00242
00243
00244
00245
00246
00247 sprintf(histo, "EBBCT all needed crystals readout");
00248 meBBCaloAllNeededCry_ = dqmStore_->book1D(histo,histo,3,-1.,2.);
00249
00250
00251 sprintf(histo, "EBBCT readout crystals number");
00252 meBBNumCaloCryRead_ = dqmStore_->book1D(histo,histo,1701,0.,1701.);
00253 meBBNumCaloCryRead_->setAxisTitle("number of read crystals", 1);
00254
00255 sprintf(histo, "EBBCT 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, "EBBCT rec Ene sum 3x3 table moving");
00261 meBBCaloE3x3Moving_ = dqmStore_->book1D(histo,histo,500,0.,9000.);
00262
00263
00264 sprintf(histo, "EBBCT crystal on beam");
00265 meBBCaloCryOnBeam_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00266
00267 sprintf(histo, "EBBCT crystal with maximum rec energy");
00268 meBBCaloMaxEneCry_ = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00269
00270 sprintf(histo, "EBBCT 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, "EBBCT crystals done");
00276 CrystalsDone_ = dqmStore_->book1D(histo,histo,1700,1.,1701.);
00277 CrystalsDone_->setAxisTitle("crystal", 1);
00278 CrystalsDone_->setAxisTitle("step in the scan", 2);
00279
00280
00281
00282 sprintf(histo, "EBBCT crystal in beam vs event");
00283 CrystalInBeam_vs_Event_ = dqmStore_->bookProfile(histo, histo, 20000,0.,400000.,1802,-101.,1701.,"s");
00284 CrystalInBeam_vs_Event_->setAxisTitle("event", 1);
00285 CrystalInBeam_vs_Event_->setAxisTitle("crystal in beam", 2);
00286
00287
00288
00289 sprintf(histo, "EBBCT readout crystals errors");
00290 meEBBCaloReadCryErrors_ = dqmStore_->book1D(histo, histo, 425,1.,86.);
00291 meEBBCaloReadCryErrors_->setAxisTitle("step in the scan", 1);
00292
00293 sprintf(histo, "EBBCT average rec energy in the single crystal");
00294
00295 meEBBCaloE1vsCry_ = dqmStore_->bookProfile(histo, histo, 1700,1.,1701.,500,0.,9000.,"s");
00296 meEBBCaloE1vsCry_->setAxisTitle("crystal", 1);
00297 meEBBCaloE1vsCry_->setAxisTitle("rec energy (ADC)", 2);
00298
00299 sprintf(histo, "EBBCT average rec energy in the 3x3 array");
00300
00301 meEBBCaloE3x3vsCry_ = dqmStore_->bookProfile(histo, histo, 1700,1.,1701.,500,0.,9000.,"s");
00302 meEBBCaloE3x3vsCry_->setAxisTitle("crystal", 1);
00303 meEBBCaloE3x3vsCry_->setAxisTitle("rec energy (ADC)", 2);
00304
00305 sprintf(histo, "EBBCT number of entries");
00306 meEBBCaloEntriesVsCry_ = dqmStore_->book1D(histo, histo,1700,1.,1701.);
00307 meEBBCaloEntriesVsCry_->setAxisTitle("crystal", 1);
00308 meEBBCaloEntriesVsCry_->setAxisTitle("number of events (prescaled)", 2);
00309
00310 sprintf(histo, "EBBCT energy deposition in the 3x3");
00311 meEBBCaloBeamCentered_ = dqmStore_->book2D(histo, histo,3,-1.5,1.5,3,-1.5,1.5);
00312 meEBBCaloBeamCentered_->setAxisTitle("\\Delta \\eta", 1);
00313 meEBBCaloBeamCentered_->setAxisTitle("\\Delta \\phi", 2);
00314
00315 sprintf(histo, "EBBCT E1 in the max cry");
00316 meEBBCaloE1MaxCry_= dqmStore_->book1D(histo,histo,500,0.,9000.);
00317 meEBBCaloE1MaxCry_->setAxisTitle("rec Ene (ADC)", 1);
00318
00319 sprintf(histo, "EBBCT Desynchronization vs step");
00320 meEBBCaloDesync_= dqmStore_->book1D(histo, histo, 85 ,1.,86.);
00321 meEBBCaloDesync_->setAxisTitle("step", 1);
00322 meEBBCaloDesync_->setAxisTitle("Desynchronized events", 2);
00323
00324 }
00325
00326 }
00327
00328 void EBBeamCaloTask::cleanup(void){
00329
00330 if ( ! init_ ) return;
00331
00332 if ( dqmStore_ ) {
00333 dqmStore_->setCurrentFolder(prefixME_ + "/EBBeamCaloTask");
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( meEBBCaloReadCryErrors_ ) dqmStore_->removeElement( meEBBCaloReadCryErrors_->getName() );
00386 meEBBCaloReadCryErrors_ = 0;
00387 if( meEBBCaloE1vsCry_ ) dqmStore_->removeElement( meEBBCaloE1vsCry_->getName() );
00388 meEBBCaloE1vsCry_ = 0;
00389 if( meEBBCaloE3x3vsCry_ ) dqmStore_->removeElement( meEBBCaloE3x3vsCry_->getName() );
00390 meEBBCaloE3x3vsCry_ = 0;
00391 if( meEBBCaloEntriesVsCry_ ) dqmStore_->removeElement( meEBBCaloEntriesVsCry_->getName() );
00392 meEBBCaloEntriesVsCry_ = 0;
00393 if( meEBBCaloBeamCentered_ ) dqmStore_->removeElement( meEBBCaloBeamCentered_->getName() );
00394 meEBBCaloBeamCentered_ = 0;
00395 if( meEBBCaloE1MaxCry_ ) dqmStore_->removeElement(meEBBCaloE1MaxCry_->getName() );
00396 meEBBCaloE1MaxCry_ = 0;
00397 if( meEBBCaloDesync_ ) dqmStore_->removeElement(meEBBCaloDesync_->getName() );
00398 meEBBCaloDesync_ = 0;
00399 }
00400
00401 init_ = false;
00402
00403 }
00404
00405 void EBBeamCaloTask::endJob(void){
00406
00407 edm::LogInfo("EBBeamCaloTask") << "analyzed " << ievt_ << " events";
00408
00409 if ( enableCleanup_ ) this->cleanup();
00410
00411 }
00412
00413 void EBBeamCaloTask::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 ) != EcalBarrel ) continue;
00424
00425 if ( dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH4 ||
00426 dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH2 ) enable = true;
00427
00428 }
00429
00430 } else {
00431 edm::LogWarning("EBBeamCaloTask") << EcalRawDataCollection_ << " not available";
00432 }
00433
00434 if ( ! enable ) return;
00435 if ( ! init_ ) this->setup();
00436 ievt_++;
00437
00438 edm::Handle<EcalTBEventHeader> pEventHeader;
00439 const EcalTBEventHeader* evtHeader=0;
00440
00441 if ( e.getByLabel(EcalTBEventHeader_, pEventHeader) ) {
00442 evtHeader = pEventHeader.product();
00443 } else {
00444 std::cerr << "Error! can't get the product for the event header" << std::endl;
00445 }
00446
00447
00448 int cry_in_beam = 0;
00449 bool tb_moving = false;
00450 int event = 0;
00451
00452 if(evtHeader){
00453
00454 cry_in_beam = evtHeader->crystalInBeam();
00455 tb_moving = evtHeader->tableIsMoving();
00456 event = evtHeader->eventNumber();
00457 if( evtHeader->syncError() ) {meEBBCaloDesync_->Fill(crystal_step_);}
00458 }
00459 else {
00460 cry_in_beam = previous_cry_in_beam_;
00461 tb_moving = lastStableStatus_;
00462 event = previous_ev_num_ +10;
00463 }
00464
00465 previous_cry_in_beam_ = cry_in_beam;
00466 previous_ev_num_ = event;
00467
00468
00469
00470 bool reset_histos_stable = false;
00471 bool reset_histos_moving = false;
00472
00473 bool skip_this_event = false;
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
00505 if(ievt_ < 3){last_cry_in_beam_ = cry_in_beam;}
00506
00507 if(tb_moving){
00508
00509 TableMoving_->Fill(1);
00510 if( PreviousTableStatus_[0] == 0 && PreviousTableStatus_[1] == 1 && lastStableStatus_ == 0){
00511 reset_histos_moving=true;
00512 wasFakeChange_ = false;
00513
00514
00515
00516 lastStableStatus_ = 1;
00517
00518 }
00519 else if( PreviousTableStatus_[1] == 0) {
00520 skip_this_event=true;
00521 changed_tb_status_ = true;
00522 wasFakeChange_ = true;
00523 }
00524
00525 PreviousTableStatus_[0] = PreviousTableStatus_[1];
00526 PreviousTableStatus_[1] = 1;
00527 }
00528
00529 else {
00530
00531 TableMoving_->Fill(0);
00532 if( PreviousTableStatus_[0] == 1 && PreviousTableStatus_[1] == 0 && lastStableStatus_ == 1){
00533
00534 wasFakeChange_ = false;
00535 lastStableStatus_ = 0;
00536 }
00537 else if(PreviousTableStatus_[1] == 1) {
00538 skip_this_event=true;
00539 changed_tb_status_ = true;
00540 wasFakeChange_ = true;
00541 }
00542
00543 PreviousTableStatus_[0]=PreviousTableStatus_[1];
00544 PreviousTableStatus_[1]=0;
00545
00546
00547 if( PreviousCrystalinBeam_[0] == PreviousCrystalinBeam_[1] && PreviousCrystalinBeam_[1] != PreviousCrystalinBeam_[2] && PreviousCrystalinBeam_[2] == cry_in_beam ){
00548 reset_histos_stable=true;
00549 wasFakeChange_ = false;
00550 }
00551 else if (PreviousCrystalinBeam_[2] != cry_in_beam){
00552 changed_cry_in_beam_ = true;
00553 skip_this_event=true;
00554 wasFakeChange_ = true;
00555 }
00556
00557
00558 PreviousCrystalinBeam_[0] = PreviousCrystalinBeam_[1];
00559 PreviousCrystalinBeam_[1] = PreviousCrystalinBeam_[2];
00560 PreviousCrystalinBeam_[2] = cry_in_beam;
00561 }
00562
00563
00564 if( !tb_moving ) {CrystalInBeam_vs_Event_->Fill(event,float(cry_in_beam));}
00565 else{CrystalInBeam_vs_Event_->Fill(event,-100); }
00566 if ( !profileArranged_ ){
00567 float dd=0;
00568 int mbin =0;
00569 for( int bin=1; bin < 20001; bin++ ){
00570 float temp = CrystalInBeam_vs_Event_->getBinContent(bin);
00571 if(temp>0){ dd= temp+0.01; mbin=bin; break;}
00572 }
00573 if(mbin >0) { CrystalInBeam_vs_Event_->Fill(20*mbin-1,dd);}
00574 profileArranged_ = true;
00575 }
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 if(reset_histos_moving){
00598 edm::LogInfo("EBBeamCaloTask") << "event " << ievt_ << " resetting histos for moving table!! ";
00599
00600
00601
00602
00603
00604
00605
00606
00607 table_step_++;
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618 meBBCaloE3x3Moving_->Reset();
00619
00620 }
00621
00622
00623 if(reset_histos_stable){
00624 if( event - event_last_reset_ > 30){
00625
00626
00627
00628
00629
00630 edm::LogInfo("EBBeamCaloTask") << "event " << ievt_ << " resetting histos for stable table!! ";
00631
00632
00633
00634
00635
00636
00637
00638
00639 event_last_reset_ = event;
00640
00641 last_cry_in_beam_ = cry_in_beam;
00642 crystal_step_++;
00643
00644
00645 for (int u=0;u<cryInArray_;u++){
00646 meBBCaloPulseProf_[u]->Reset();
00647 meBBCaloPulseProfG12_[u]->Reset();
00648 meBBCaloGains_[u]->Reset();
00649 meBBCaloEne_[u]->Reset();
00650 }
00651 meBBCaloCryRead_->Reset();
00652 meBBCaloE3x3_->Reset();
00653 meEBBCaloBeamCentered_->Reset();
00654 }
00655 }
00656
00657 if(skip_this_event){
00658 edm::LogInfo("EBBeamCaloTask") << "event " << event <<" analyzed: "<<ievt_ << " : skipping this event!! ";
00659 return;}
00660
00661
00662
00663
00664 CrystalsDone_->setBinContent(cry_in_beam , crystal_step_ );
00665 int eta_c = ( cry_in_beam-1)/20 ;
00666 int phi_c = ( cry_in_beam-1)%20 ;
00667
00668 float xie = eta_c + 0.5;
00669 float xip = phi_c + 0.5;
00670 if (!tb_moving) {meBBCaloCryOnBeam_->Fill(xie,xip);}
00671
00672 edm::Handle<EBDigiCollection> digis;
00673 e.getByLabel(EBDigiCollection_, digis);
00674 int nebd = digis->size();
00675
00676 meBBNumCaloCryRead_->Fill(nebd);
00677
00678
00679 int cry_to_beRead[49];
00680 for(int u=0;u<49;u++){cry_to_beRead[u]=0;}
00681
00682 for(int de=-3; de<4; de++){
00683 for(int dp=-3; dp<4; dp++){
00684
00685 int u = de -7*dp + 24;
00686 bool existing_cry = (phi_c+dp) >= 0 && (phi_c+dp) <= 19 && (eta_c+de) >=0 && (eta_c+de) <= 84;
00687 if(!existing_cry){cry_to_beRead[u]=-1;}
00688 }
00689 }
00690
00691
00692 meEBBCaloEntriesVsCry_->Fill(cry_in_beam);
00693
00694 for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00695
00696 EBDetId id = digiItr->id();
00697
00698 int ic = id.ic();
00699 int ie = (ic-1)/20;
00700 int ip = (ic-1)%20;
00701
00702 int deta_c= ie - eta_c;
00703 int dphi_c= ip - phi_c;
00704 if (! tb_moving){meBBCaloCryRead_->Fill(deta_c, dphi_c);}
00705
00706
00707 if(std::abs(deta_c) > 3 || std::abs(dphi_c) > 3){continue;}
00708 int i_toBeRead = deta_c -7*dphi_c + 24;
00709 if( i_toBeRead > -1 && i_toBeRead <49){
00710 cry_to_beRead[i_toBeRead]++;
00711
00712 }
00713
00714 if(std::abs(deta_c) > 1 || std::abs(dphi_c) > 1){continue;}
00715 int i_in_array = deta_c -3*dphi_c + 4;
00716
00717 if( i_in_array < 0 || i_in_array > 8 ){continue;}
00718
00719 EBDataFrame dataframe = (*digiItr);
00720
00721 for (int i = 0; i < 10; i++) {
00722 int adc = dataframe.sample(i).adc();
00723 int gainid = dataframe.sample(i).gainId();
00724
00725
00726
00727 if ( gainid == 1 ){
00728 if(! tb_moving){
00729 meBBCaloPulseProfG12_[i_in_array]->Fill(i,float(adc));
00730 meBBCaloPulseProf_[i_in_array]->Fill(i,float(adc));
00731 meBBCaloGains_[i_in_array]->Fill(12);
00732 }
00733
00734
00735
00736
00737
00738 }
00739 else if ( gainid == 2 ){
00740 float val = (float(adc)-defaultPede_)*2 + defaultPede_;
00741 if(! tb_moving){
00742 meBBCaloPulseProf_[i_in_array]->Fill(i,val);
00743 meBBCaloGains_[i_in_array]->Fill(6);
00744 }
00745
00746
00747
00748
00749 }
00750 else if ( gainid == 3 ){
00751 float val = (float(adc)-defaultPede_)*12 + defaultPede_;
00752 if(! tb_moving){
00753 meBBCaloPulseProf_[i_in_array]->Fill(i,val);
00754 meBBCaloGains_[i_in_array]->Fill(1);
00755 }
00756
00757
00758
00759
00760 }
00761 }
00762 }
00763
00764
00765 bool all_cry_readout = true;
00766
00767
00768 if(all_cry_readout){ meBBCaloAllNeededCry_->Fill(1.5);}
00769 else {
00770 meBBCaloAllNeededCry_->Fill(-0.5);
00771 if( tb_moving ) {meEBBCaloReadCryErrors_->Fill( crystal_step_+0.5 );}
00772 else {meEBBCaloReadCryErrors_->Fill( crystal_step_ );}
00773 }
00774
00775
00776
00777 edm::Handle<EcalUncalibratedRecHitCollection> hits;
00778 e.getByLabel(EcalUncalibratedRecHitCollection_, hits);
00779 int neh = hits->size();
00780 LogDebug("EBBeamCaloTask") << "event " << event <<" analyzed: "<< ievt_ << " hits collection size " << neh;
00781 float ene3x3=0;
00782 float maxEne = 0;
00783 int ieM =-1, ipM = -1;
00784 float cryInBeamEne =0;
00785 for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00786
00787 EBDetId id = hitItr->id();
00788
00789 int ic = id.ic();
00790 int ie = (ic-1)/20;
00791 int ip = (ic-1)%20;
00792
00793 int deta_c= ie - eta_c;
00794 int dphi_c= ip - phi_c;
00795
00796 int i_in_array = deta_c -3*dphi_c + 4;
00797
00798 float R_ene = hitItr->amplitude();
00799 if ( R_ene <= 0. ) R_ene = 0.0;
00800 if(R_ene > maxEne){
00801 maxEne=R_ene;
00802 ieM =ie; ipM = ip;
00803 }
00804 if(std::abs(deta_c) > 1 || std::abs(dphi_c) > 1){continue;}
00805 meEBBCaloBeamCentered_->Fill(deta_c,dphi_c,R_ene);
00806
00807 if( i_in_array < 0 || i_in_array > 8 ){continue;}
00808
00809 if(i_in_array == 4){cryInBeamEne = R_ene;}
00810 if(! tb_moving){meBBCaloEne_[i_in_array]->Fill(R_ene);}
00811
00812 ene3x3 += R_ene;
00813
00814 }
00815
00816 if (!tb_moving){
00817 meBBCaloE3x3_->Fill(ene3x3);
00818 meEBBCaloE1vsCry_->Fill(cry_in_beam , cryInBeamEne );
00819 meEBBCaloE3x3vsCry_->Fill(cry_in_beam, ene3x3 );
00820
00821
00822
00823
00824 meBBCaloMaxEneCry_->Fill(ieM,ipM);
00825 meEBBCaloE1MaxCry_->Fill(maxEne);
00826 }
00827 else{meBBCaloE3x3Moving_->Fill(ene3x3);}
00829 }
00830