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