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