00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
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/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/EBBeamHodoTask.h"
00032
00033 EBBeamHodoTask::EBBeamHodoTask(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 EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
00048 EcalTBTDCRawInfo_ = ps.getParameter<edm::InputTag>("EcalTBTDCRawInfo");
00049 EcalTBHodoscopeRawInfo_ = ps.getParameter<edm::InputTag>("EcalTBHodoscopeRawInfo");
00050 EcalTBTDCRecInfo_ = ps.getParameter<edm::InputTag>("EcalTBTDCRecInfo");
00051 EcalTBHodoscopeRecInfo_ = ps.getParameter<edm::InputTag>("EcalTBHodoscopeRecInfo");
00052
00053 tableIsMoving_ = false;
00054 cryInBeam_ =0;
00055 previousCryInBeam_ = -99999;
00056
00057
00058 for (int i=0; i<4; i++) {
00059 meHodoOcc_[i] =0;
00060 meHodoRaw_[i] =0;
00061 }
00062 meTDCRec_ =0;
00063
00064
00065 meHodoPosRecX_ =0;
00066 meHodoPosRecY_ =0;
00067 meHodoPosRecXY_ =0;
00068 meHodoSloXRec_ =0;
00069 meHodoSloYRec_ =0;
00070 meHodoQuaXRec_ =0;
00071 meHodoQuaYRec_ =0;
00072 meHodoPosXMinusCaloPosXVsCry_ =0;
00073 meHodoPosYMinusCaloPosYVsCry_ =0;
00074 meTDCTimeMinusCaloTimeVsCry_ =0;
00075 meMissingCollections_ =0;
00076
00077 meEvsXRecProf_ =0;
00078 meEvsYRecProf_ =0;
00079 meEvsXRecHis_ =0;
00080 meEvsYRecHis_ =0;
00081
00082
00083 meCaloVsHodoXPos_ =0;
00084 meCaloVsHodoYPos_ =0;
00085 meCaloVsTDCTime_ =0;
00086
00087 }
00088
00089 EBBeamHodoTask::~EBBeamHodoTask(){
00090
00091 }
00092
00093 void EBBeamHodoTask::beginJob(void){
00094
00095 ievt_ = 0;
00096
00097 LV1_ = 0;
00098 cryInBeamCounter_ =0;
00099 resetNow_ =false;
00100
00101 if ( dqmStore_ ) {
00102 dqmStore_->setCurrentFolder(prefixME_ + "/EBBeamHodoTask");
00103 dqmStore_->rmdir(prefixME_ + "/EBBeamHodoTask");
00104 }
00105
00106 }
00107
00108 void EBBeamHodoTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00109
00110 Numbers::initGeometry(c, false);
00111
00112 if ( ! mergeRuns_ ) this->reset();
00113
00114 }
00115
00116 void EBBeamHodoTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00117
00118 }
00119
00120 void EBBeamHodoTask::reset(void) {
00121
00122 for (int i=0; i<4; i++) {
00123 if ( meHodoOcc_[i] ) meHodoOcc_[i]->Reset();
00124 if ( meHodoRaw_[i] ) meHodoRaw_[i]->Reset();
00125 }
00126
00127 if ( meHodoPosRecX_ ) meHodoPosRecX_->Reset();
00128 if ( meHodoPosRecY_ ) meHodoPosRecY_->Reset();
00129 if ( meHodoPosRecXY_ ) meHodoPosRecXY_->Reset();
00130 if ( meHodoSloXRec_ ) meHodoSloXRec_->Reset();
00131 if ( meHodoSloYRec_ ) meHodoSloYRec_->Reset();
00132 if ( meHodoQuaXRec_ ) meHodoQuaXRec_->Reset();
00133 if ( meHodoQuaYRec_ ) meHodoQuaYRec_->Reset();
00134 if ( meTDCRec_ ) meTDCRec_->Reset();
00135 if ( meEvsXRecProf_ ) meEvsXRecProf_->Reset();
00136 if ( meEvsYRecProf_ ) meEvsYRecProf_->Reset();
00137 if ( meEvsXRecHis_ ) meEvsXRecHis_->Reset();
00138 if ( meEvsYRecHis_ ) meEvsYRecHis_->Reset();
00139 if ( meCaloVsHodoXPos_ ) meCaloVsHodoXPos_->Reset();
00140 if ( meCaloVsHodoYPos_ ) meCaloVsHodoYPos_->Reset();
00141 if ( meCaloVsTDCTime_ ) meCaloVsTDCTime_->Reset();
00142 if ( meHodoPosXMinusCaloPosXVsCry_ ) meHodoPosXMinusCaloPosXVsCry_->Reset();
00143 if ( meHodoPosYMinusCaloPosYVsCry_ ) meHodoPosYMinusCaloPosYVsCry_->Reset();
00144 if ( meTDCTimeMinusCaloTimeVsCry_ ) meTDCTimeMinusCaloTimeVsCry_->Reset();
00145 if ( meMissingCollections_ ) meMissingCollections_->Reset();
00146
00147 }
00148
00149 void EBBeamHodoTask::setup(void){
00150
00151 init_ = true;
00152
00153 smId =1;
00154
00155 if ( dqmStore_ ) {
00156 dqmStore_->setCurrentFolder(prefixME_ + "/EBBeamHodoTask");
00157
00158 std::stringstream ss;
00159 std::string name;
00160
00161
00162
00163
00164
00165 for (int i=0; i<4; i++) {
00166 ss << std::setw(2) << std::setfill('0') << i+1;
00167 name = "EBBHT occup " + Numbers::sEB(smId) + " " + ss.str();
00168 meHodoOcc_[i] = dqmStore_->book1D(name, name, 30, 0., 30.);
00169 meHodoOcc_[i]->setAxisTitle("hits per event", 1);
00170 name = "EBBHT raw " + Numbers::sEB(smId) + " " + ss.str();
00171 meHodoRaw_[i] = dqmStore_->book1D(name, name, 64, 0., 64.);
00172 meHodoRaw_[i]->setAxisTitle("hodo fiber number", 1);
00173 }
00174
00175 name = "EBBHT PosX rec " + Numbers::sEB(smId);
00176 meHodoPosRecX_ = dqmStore_->book1D(name, name, 100, -20, 20);
00177 meHodoPosRecX_->setAxisTitle("reconstructed position (mm)", 1);
00178
00179 name = "EBBHT PosY rec " + Numbers::sEB(smId);
00180 meHodoPosRecY_ = dqmStore_->book1D(name, name, 100, -20, 20);
00181 meHodoPosRecY_->setAxisTitle("reconstructed position (mm)", 1);
00182
00183 name = "EBBHT PosYX rec " + Numbers::sEB(smId);
00184 meHodoPosRecXY_ = dqmStore_->book2D(name, name, 100, -20, 20,100, -20, 20);
00185 meHodoPosRecXY_->setAxisTitle("reconstructed X position (mm)", 1);
00186 meHodoPosRecXY_->setAxisTitle("reconstructed Y position (mm)", 2);
00187
00188 name = "EBBHT SloX " + Numbers::sEB(smId);
00189 meHodoSloXRec_ = dqmStore_->book1D(name, name, 50, -0.005, 0.005);
00190 meHodoSloXRec_->setAxisTitle("reconstructed track slope", 1);
00191
00192 name = "EBBHT SloY " + Numbers::sEB(smId);
00193 meHodoSloYRec_ = dqmStore_->book1D(name, name, 50, -0.005, 0.005);
00194 meHodoSloYRec_->setAxisTitle("reconstructed track slope", 1);
00195
00196 name = "EBBHT QualX " + Numbers::sEB(smId);
00197 meHodoQuaXRec_ = dqmStore_->book1D(name, name, 50, 0, 5);
00198 meHodoQuaXRec_->setAxisTitle("track fit quality", 1);
00199
00200 name = "EBBHT QualY " + Numbers::sEB(smId);
00201 meHodoQuaYRec_ = dqmStore_->book1D(name, name, 50, 0, 5);
00202 meHodoQuaYRec_->setAxisTitle("track fit quality", 1);
00203
00204 name = "EBBHT TDC rec " + Numbers::sEB(smId);
00205 meTDCRec_ = dqmStore_->book1D(name, name, 25, 0, 1);
00206 meTDCRec_->setAxisTitle("offset", 1);
00207
00208 name = "EBBHT Hodo-Calo X vs Cry " + Numbers::sEB(smId);
00209 meHodoPosXMinusCaloPosXVsCry_ = dqmStore_->book1D(name, name, 50, 0, 50);
00210 meHodoPosXMinusCaloPosXVsCry_->setAxisTitle("scan step number", 1);
00211 meHodoPosXMinusCaloPosXVsCry_->setAxisTitle("PosX_{hodo} - PosX_{calo} (mm)", 2);
00212
00213 name = "EBBHT Hodo-Calo Y vs Cry " + Numbers::sEB(smId);
00214 meHodoPosYMinusCaloPosYVsCry_ = dqmStore_->book1D(name, name, 50, 0, 50);
00215 meHodoPosYMinusCaloPosYVsCry_->setAxisTitle("scan step number", 1);
00216 meHodoPosYMinusCaloPosYVsCry_->setAxisTitle("PosY_{hodo} - PosY_{calo} (mm)", 2);
00217
00218 name = "EBBHT TDC-Calo vs Cry " + Numbers::sEB(smId);
00219 meTDCTimeMinusCaloTimeVsCry_ = dqmStore_->book1D(name, name, 50, 0, 50);
00220 meTDCTimeMinusCaloTimeVsCry_->setAxisTitle("scan step number", 1);
00221 meTDCTimeMinusCaloTimeVsCry_->setAxisTitle("Time_{TDC} - Time_{calo} (sample)", 2);
00222
00223 name = "EBBHT Missing Collections " + Numbers::sEB(smId);
00224 meMissingCollections_ = dqmStore_->book1D(name, name, 7, 0, 7);
00225 meMissingCollections_->setAxisTitle("missing collection", 1);
00226
00227
00228
00229
00230
00231 name = "EBBHT prof E1 vs X " + Numbers::sEB(smId);
00232 meEvsXRecProf_ = dqmStore_-> bookProfile(name, name, 100, -20, 20, 500, 0, 5000, "s");
00233 meEvsXRecProf_->setAxisTitle("PosX (mm)", 1);
00234 meEvsXRecProf_->setAxisTitle("E1 (ADC)", 2);
00235
00236 name = "EBBHT prof E1 vs Y " + Numbers::sEB(smId);
00237 meEvsYRecProf_ = dqmStore_-> bookProfile(name, name, 100, -20, 20, 500, 0, 5000, "s");
00238 meEvsYRecProf_->setAxisTitle("PosY (mm)", 1);
00239 meEvsYRecProf_->setAxisTitle("E1 (ADC)", 2);
00240
00241 name = "EBBHT his E1 vs X " + Numbers::sEB(smId);
00242 meEvsXRecHis_ = dqmStore_-> book2D(name, name, 100, -20, 20, 500, 0, 5000);
00243 meEvsXRecHis_->setAxisTitle("PosX (mm)", 1);
00244 meEvsXRecHis_->setAxisTitle("E1 (ADC)", 2);
00245
00246 name = "EBBHT his E1 vs Y " + Numbers::sEB(smId);
00247 meEvsYRecHis_ = dqmStore_-> book2D(name, name, 100, -20, 20, 500, 0, 5000);
00248 meEvsYRecHis_->setAxisTitle("PosY (mm)", 1);
00249 meEvsYRecHis_->setAxisTitle("E1 (ADC)", 2);
00250
00251 name = "EBBHT PosX Hodo-Calo " + Numbers::sEB(smId);
00252 meCaloVsHodoXPos_ = dqmStore_->book1D(name, name, 40, -20, 20);
00253 meCaloVsHodoXPos_->setAxisTitle("PosX_{hodo} - PosX_{calo} (mm)", 1);
00254
00255 name = "EBBHT PosY Hodo-Calo " + Numbers::sEB(smId);
00256 meCaloVsHodoYPos_ = dqmStore_->book1D(name, name, 40, -20, 20);
00257 meCaloVsHodoYPos_->setAxisTitle("PosY_{hodo} - PosY_{calo} (mm)", 1);
00258
00259 name = "EBBHT TimeMax TDC-Calo " + Numbers::sEB(smId);
00260 meCaloVsTDCTime_ = dqmStore_->book1D(name, name, 100, -1, 1);
00261 meCaloVsTDCTime_->setAxisTitle("Time_{TDC} - Time_{calo} (samples)", 1);
00262
00263 }
00264
00265 }
00266
00267 void EBBeamHodoTask::cleanup(void){
00268
00269 if ( ! init_ ) return;
00270
00271 if ( dqmStore_ ) {
00272 dqmStore_->setCurrentFolder(prefixME_ + "/EBBeamHodoTask");
00273
00274 for (int i=0; i<4; i++) {
00275 if ( meHodoOcc_[i] ) dqmStore_->removeElement( meHodoOcc_[i]->getName() );
00276 meHodoOcc_[i] = 0;
00277 if ( meHodoRaw_[i] ) dqmStore_->removeElement( meHodoRaw_[i]->getName() );
00278 meHodoRaw_[i] = 0;
00279 }
00280
00281 if ( meHodoPosRecX_ ) dqmStore_->removeElement( meHodoPosRecX_->getName() );
00282 meHodoPosRecX_ = 0;
00283 if ( meHodoPosRecY_ ) dqmStore_->removeElement( meHodoPosRecY_->getName() );
00284 meHodoPosRecY_ = 0;
00285 if ( meHodoPosRecXY_ ) dqmStore_->removeElement( meHodoPosRecXY_->getName() );
00286 meHodoPosRecXY_ = 0;
00287 if ( meHodoSloXRec_ ) dqmStore_->removeElement( meHodoSloXRec_->getName() );
00288 meHodoSloXRec_ = 0;
00289 if ( meHodoSloYRec_ ) dqmStore_->removeElement( meHodoSloYRec_->getName() );
00290 meHodoSloYRec_ = 0;
00291 if ( meHodoQuaXRec_ ) dqmStore_->removeElement( meHodoQuaXRec_->getName() );
00292 meHodoQuaXRec_ = 0;
00293 if ( meHodoQuaYRec_ ) dqmStore_->removeElement( meHodoQuaYRec_->getName() );
00294 meHodoQuaYRec_ = 0;
00295 if ( meTDCRec_ ) dqmStore_->removeElement( meTDCRec_->getName() );
00296 meTDCRec_ = 0;
00297 if ( meEvsXRecProf_ ) dqmStore_->removeElement( meEvsXRecProf_->getName() );
00298 meEvsXRecProf_ = 0;
00299 if ( meEvsYRecProf_ ) dqmStore_->removeElement( meEvsYRecProf_->getName() );
00300 meEvsYRecProf_ = 0;
00301 if ( meEvsXRecHis_ ) dqmStore_->removeElement( meEvsXRecHis_->getName() );
00302 meEvsXRecHis_ = 0;
00303 if ( meEvsYRecHis_ ) dqmStore_->removeElement( meEvsYRecHis_->getName() );
00304 meEvsYRecHis_ = 0;
00305 if ( meCaloVsHodoXPos_ ) dqmStore_->removeElement( meCaloVsHodoXPos_->getName() );
00306 meCaloVsHodoXPos_ = 0;
00307 if ( meCaloVsHodoYPos_ ) dqmStore_->removeElement( meCaloVsHodoYPos_->getName() );
00308 meCaloVsHodoYPos_ = 0;
00309 if ( meCaloVsTDCTime_ ) dqmStore_->removeElement( meCaloVsTDCTime_->getName() );
00310 meCaloVsTDCTime_ = 0;
00311 if ( meHodoPosXMinusCaloPosXVsCry_ ) dqmStore_->removeElement( meHodoPosXMinusCaloPosXVsCry_->getName() );
00312 meHodoPosXMinusCaloPosXVsCry_ = 0;
00313 if ( meHodoPosYMinusCaloPosYVsCry_ ) dqmStore_->removeElement( meHodoPosYMinusCaloPosYVsCry_->getName() );
00314 meHodoPosYMinusCaloPosYVsCry_ = 0;
00315 if ( meTDCTimeMinusCaloTimeVsCry_ ) dqmStore_->removeElement( meTDCTimeMinusCaloTimeVsCry_->getName() );
00316 meTDCTimeMinusCaloTimeVsCry_ = 0;
00317 if ( meMissingCollections_ ) dqmStore_->removeElement( meMissingCollections_->getName() );
00318 meMissingCollections_ = 0;
00319
00320 }
00321
00322 init_ = false;
00323
00324 }
00325
00326 void EBBeamHodoTask::endJob(void){
00327
00328 edm::LogInfo("EBBeamHodoTask") << "analyzed " << ievt_ << " events";
00329
00330 if ( enableCleanup_ ) this->cleanup();
00331
00332 }
00333
00334 void EBBeamHodoTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00335
00336 bool enable = false;
00337 edm::Handle<EcalTBEventHeader> pHeader;
00338 const EcalTBEventHeader* Header =0;
00339
00340 if ( e.getByLabel(EcalTBEventHeader_, pHeader) ) {
00341 Header = pHeader.product();
00342 if (!Header) {
00343 edm::LogWarning("EBBeamHodoTask") << "Event header not found. Returning. ";
00344 meMissingCollections_-> Fill(0);
00345 return;
00346 }
00347 tableIsMoving_ = Header->tableIsMoving();
00348 cryInBeam_ = Header->crystalInBeam();
00349 if (previousCryInBeam_ == -99999 )
00350 { previousCryInBeam_ = cryInBeam_ ; }
00351
00352 LogDebug("EBBeamHodoTask") << "event: " << ievt_ << " event header found ";
00353 if (tableIsMoving_){
00354 LogDebug("EBBeamHodoTask") << "Table is moving. "; }
00355 else
00356 { LogDebug("EBBeamHodoTask") << "Table is not moving. "; }
00357 } else {
00358 edm::LogWarning("EBBeamHodoTask") << "Event header not found (exception caught). Returning. ";
00359 return;
00360 }
00361
00362 edm::Handle<EcalRawDataCollection> dcchs;
00363
00364 if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00365
00366 for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00367
00368 if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00369
00370 if ( dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH4 ||
00371 dcchItr->getRunType() == EcalDCCHeaderBlock::BEAMH2 ) enable = true;
00372 }
00373
00374 } else {
00375 edm::LogWarning("EcalBeamTask") << EcalRawDataCollection_ << " not available";
00376 meMissingCollections_-> Fill(1);
00377 return;
00378
00379 }
00380
00381 if ( ! enable ) return;
00382 if ( ! init_ ) this->setup();
00383 ievt_++;
00384
00385 LV1_ = Header->eventNumber();
00386
00387 edm::Handle<EcalUncalibratedRecHitCollection> pUncalRH;
00388 const EcalUncalibratedRecHitCollection* uncalRecH =0;
00389
00390 if ( e.getByLabel(EcalUncalibratedRecHitCollection_, pUncalRH) ) {
00391 uncalRecH = pUncalRH.product();
00392 int neh = pUncalRH->size();
00393 LogDebug("EBBeamHodoTask") << EcalUncalibratedRecHitCollection_ << " found in event " << ievt_ << "; hits collection size " << neh;
00394 } else {
00395 edm::LogWarning("EBBeamHodoTask") << EcalUncalibratedRecHitCollection_ << " not available";
00396 meMissingCollections_-> Fill(2);
00397 return;
00398 }
00399
00400 edm::Handle<EcalTBTDCRawInfo> pTDCRaw;
00401 const EcalTBTDCRawInfo* rawTDC=0;
00402
00403 if ( e.getByLabel(EcalTBTDCRawInfo_, pTDCRaw) ) {
00404 rawTDC = pTDCRaw.product();
00405 } else {
00406 edm::LogError("EcalBeamTask") << "Error! Can't get the product EcalTBTDCRawInfo. Returning.";
00407 meMissingCollections_-> Fill(4);
00408 return;
00409 }
00410
00411 edm::Handle<EcalTBHodoscopeRawInfo> pHodoRaw;
00412 const EcalTBHodoscopeRawInfo* rawHodo=0;
00413
00414 if ( e.getByLabel(EcalTBHodoscopeRawInfo_, pHodoRaw) ) {
00415 rawHodo = pHodoRaw.product();
00416 if(rawHodo->planes() ){
00417 LogDebug("EcalBeamTask") << "hodoscopeRaw: num planes: " << rawHodo->planes()
00418 << " channels in plane 1: " << rawHodo->channels(0);
00419 }
00420 } else {
00421 edm::LogError("EcalBeamTask") << "Error! Can't get the product EcalTBHodoscopeRawInfo. Returning";
00422 meMissingCollections_-> Fill(3);
00423 return;
00424 }
00425
00426 if ( !rawTDC ||!rawHodo || !uncalRecH || !( rawHodo->planes() )) {
00427 edm::LogWarning("EcalBeamTask") << "analyze: missing a needed collection or hodo collection empty. Returning.";
00428 return;
00429 }
00430 LogDebug("EBBeamHodoTask") << " TDC raw, Hodo raw, uncalRecH and DCCheader found.";
00431
00432
00433
00434
00435
00436
00437 if (cryInBeam_ != previousCryInBeam_ ) {
00438 previousCryInBeam_ = cryInBeam_ ;
00439 cryInBeamCounter_++;
00440 resetNow_ = true;
00441
00442
00443
00444
00445
00446 LogDebug("EcalBeamTask") << "At event number : " << LV1_ << " switching table status: from moving to still. "
00447 << " cry in beam is: " << cryInBeam_ << ", step being: " << cryInBeamCounter_ ;
00448
00449
00450 float HodoPosXMinusCaloPosXVsCry_mean =0;
00451 float HodoPosXMinusCaloPosXVsCry_rms =0;
00452 float HodoPosYMinusCaloPosYVsCry_mean =0;
00453 float HodoPosYMinusCaloPosYVsCry_rms =0;
00454 float TDCTimeMinusCaloTimeVsCry_mean =0;
00455 float TDCTimeMinusCaloTimeVsCry_rms =0;
00456
00457
00458
00459
00460
00461 if (meCaloVsHodoXPos_-> getEntries() > 10){
00462 HodoPosXMinusCaloPosXVsCry_mean = meCaloVsHodoXPos_-> getMean(1);
00463 HodoPosXMinusCaloPosXVsCry_rms = meCaloVsHodoXPos_-> getRMS(1);
00464 meHodoPosXMinusCaloPosXVsCry_-> setBinContent( cryInBeamCounter_, HodoPosXMinusCaloPosXVsCry_mean);
00465 meHodoPosXMinusCaloPosXVsCry_-> setBinError( cryInBeamCounter_, HodoPosXMinusCaloPosXVsCry_rms);
00466 LogDebug("EcalBeamTask") << "At event number: " << LV1_ << " step: " << cryInBeamCounter_
00467 << " DeltaPosX is: " << (meCaloVsHodoXPos_-> getMean(1))
00468 << " +-" << ( meCaloVsHodoXPos_-> getRMS(1));
00469 }
00470 if (meCaloVsHodoYPos_-> getEntries() > 10){
00471 HodoPosYMinusCaloPosYVsCry_mean = meCaloVsHodoYPos_-> getMean(1);
00472 HodoPosYMinusCaloPosYVsCry_rms = meCaloVsHodoYPos_-> getRMS(1);
00473 meHodoPosYMinusCaloPosYVsCry_-> setBinContent( cryInBeamCounter_, HodoPosYMinusCaloPosYVsCry_mean);
00474 meHodoPosYMinusCaloPosYVsCry_-> setBinError( cryInBeamCounter_, HodoPosYMinusCaloPosYVsCry_rms);
00475 LogDebug("EcalBeamTask") << "At event number: " << LV1_ << " step: " << cryInBeamCounter_
00476 << " DeltaPosY is: " << (meCaloVsHodoYPos_-> getMean(1))
00477 << " +-" << ( meCaloVsHodoYPos_-> getRMS(1));
00478 }
00479 if (meCaloVsTDCTime_-> getEntries() > 10){
00480 TDCTimeMinusCaloTimeVsCry_mean = meCaloVsTDCTime_-> getMean(1);
00481 TDCTimeMinusCaloTimeVsCry_rms = meCaloVsTDCTime_-> getRMS(1);
00482 meTDCTimeMinusCaloTimeVsCry_-> setBinContent(cryInBeamCounter_, TDCTimeMinusCaloTimeVsCry_mean);
00483 meTDCTimeMinusCaloTimeVsCry_-> setBinError(cryInBeamCounter_, TDCTimeMinusCaloTimeVsCry_rms);
00484 LogDebug("EcalBeamTask") << "At event number: " << LV1_ << " step: " << cryInBeamCounter_
00485 << " DeltaT is: " << (meCaloVsTDCTime_-> getMean(1))
00486 << " +-" << ( meCaloVsTDCTime_-> getRMS(1));
00487 }
00488
00489 LogDebug("EcalBeamTask") << "At event number: " << LV1_ << " trace histos filled ( cryInBeamCounter_="
00490 << cryInBeamCounter_ << ")";
00491
00492 }
00493
00494
00495
00496
00497
00498 if (resetNow_)
00499 {
00500 meEvsXRecProf_->Reset();
00501 meEvsYRecProf_->Reset();
00502 meEvsXRecHis_->Reset();
00503 meEvsYRecHis_->Reset();
00504 meCaloVsHodoXPos_->Reset();
00505 meCaloVsHodoYPos_->Reset();
00506 meCaloVsTDCTime_->Reset();
00507
00508 resetNow_ = false;
00509 }
00510
00511
00512
00513
00514
00515
00516
00517 for (unsigned int planeId=0; planeId <4; planeId++){
00518
00519 const EcalTBHodoscopePlaneRawHits& planeRaw = rawHodo->getPlaneRawHits(planeId);
00520 LogDebug("EcalBeamTask") << "\t plane: " << (planeId+1)
00521 << "\t number of fibers: " << planeRaw.channels()
00522 << "\t number of hits: " << planeRaw.numberOfFiredHits();
00523 meHodoOcc_[planeId]-> Fill( planeRaw.numberOfFiredHits() );
00524
00525 for (unsigned int i=0;i<planeRaw.channels();i++)
00526 {
00527 if (planeRaw.isChannelFired(i))
00528 {
00529 edm::LogInfo("EcalBeamTask")<< " channel " << (i+1) << " has fired";
00530 meHodoRaw_[planeId]-> Fill(i+0.5);
00531 }
00532 }
00533 }
00534
00535
00536
00537 edm::Handle<EcalTBTDCRecInfo> pTDC;
00538 const EcalTBTDCRecInfo* recTDC=0;
00539
00540 if ( e.getByLabel(EcalTBTDCRecInfo_, pTDC) ) {
00541 recTDC = pTDC.product();
00542 LogDebug("EBBeamHodoTask") << " TDC offset is: " << recTDC->offset();
00543 } else {
00544 edm::LogError("EcalBeamTask") << "Error! Can't get the product EcalTBTDCRecInfo. Returning";
00545 meMissingCollections_-> Fill(5);
00546 return;
00547 }
00548
00549 edm::Handle<EcalTBHodoscopeRecInfo> pHodo;
00550 const EcalTBHodoscopeRecInfo* recHodo=0;
00551
00552 if ( e.getByLabel(EcalTBHodoscopeRecInfo_, pHodo) ) {
00553 recHodo = pHodo.product();
00554 LogDebug("EcalBeamTask") << "hodoscopeReco: x: " << recHodo->posX()
00555 << "\ty: " << recHodo->posY()
00556 << "\t sx: " << recHodo->slopeX() << "\t qualx: " << recHodo->qualX()
00557 << "\t sy: " << recHodo->slopeY() << "\t qualy: " << recHodo->qualY();
00558 } else {
00559 edm::LogError("EcalBeamTask") << "Error! Can't get the product EcalTBHodoscopeRecInfo";
00560 meMissingCollections_-> Fill(6);
00561 return;
00562 }
00563
00564 if ( (!recHodo) || (!recTDC) ) {
00565 edm::LogWarning("EcalBeamTask") << "analyze: missing a needed collection, recHodo or recTDC. Returning.";
00566 return;
00567 }
00568 LogDebug("EBBeamHodoTask") << " Hodo reco and TDC reco found.";
00569
00570 meTDCRec_->Fill( recTDC->offset());
00571
00572 meHodoPosRecXY_->Fill( recHodo->posX(), recHodo->posY() );
00573 meHodoPosRecX_->Fill( recHodo->posX());
00574 meHodoPosRecY_->Fill( recHodo->posY() );
00575 meHodoSloXRec_->Fill( recHodo->slopeX());
00576 meHodoSloYRec_->Fill( recHodo->slopeY());
00577 meHodoQuaXRec_->Fill( recHodo->qualX());
00578 meHodoQuaYRec_->Fill( recHodo->qualY());
00579
00580
00581
00582
00583
00584 if (tableIsMoving_) {
00585 LogDebug("EcalBeamTask")<< "At event number:" << LV1_ << " table is moving. Not filling concerned monitoring elements. ";
00586 return;
00587 } else {
00588 LogDebug("EcalBeamTask")<< "At event number:" << LV1_ << " table is not moving - thus filling alos monitoring elements requiring so.";
00589 }
00590
00591 float maxE =0;
00592 EBDetId maxHitId(0);
00593 for ( EBUncalibratedRecHitCollection::const_iterator uncalHitItr = pUncalRH->begin(); uncalHitItr!= pUncalRH->end(); uncalHitItr++ ) {
00594 double e = (*uncalHitItr).amplitude();
00595 if ( e <= 0. ) e = 0.0;
00596 if ( e > maxE ) {
00597 maxE = e;
00598 maxHitId = (*uncalHitItr).id();
00599 }
00600 }
00601 if ( maxHitId == EBDetId(0) ) {
00602 edm::LogError("EBBeamHodoTask") << "No positive UncalRecHit found in ECAL in event " << ievt_ << " - returning.";
00603 return;
00604 }
00605
00606 meEvsXRecProf_-> Fill(recHodo->posX(), maxE);
00607 meEvsYRecProf_-> Fill(recHodo->posY(), maxE);
00608 meEvsXRecHis_-> Fill(recHodo->posX(), maxE);
00609 meEvsYRecHis_-> Fill(recHodo->posY(), maxE);
00610
00611 edm::LogInfo("EcalBeamTask")<< " channel with max is " << maxHitId;
00612
00613 bool mat5x5 =true;
00614 int ietaMax = maxHitId.ieta();
00615 int iphiMax = (maxHitId.iphi() % 20);
00616 if (ietaMax ==1 || ietaMax ==2 || ietaMax ==84 || ietaMax == 85 ||
00617 iphiMax ==1 || iphiMax ==2 || iphiMax ==19 || iphiMax == 20 )
00618 {mat5x5 =false;}
00619
00620 if (!mat5x5) return;
00621
00622 EBDetId Xtals5x5[25];
00623 double ene5x5[25];
00624 double e25 =0;
00625 for (unsigned int icry=0;icry<25;icry++)
00626 {
00627 unsigned int row = icry / 5;
00628 unsigned int column= icry %5;
00629 if ( EBDetId::validDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2) ) {
00630 Xtals5x5[icry]=EBDetId(maxHitId.ieta()+column-2,maxHitId.iphi()+row-2,EBDetId::ETAPHIMODE);
00631 double e = ( *pUncalRH->find( Xtals5x5[icry] ) ).amplitude();
00632 if ( e <= 0. ) e = 0.0;
00633 ene5x5[icry] =e;
00634 e25 +=e;
00635 } else {
00636 LogDebug("EcalBeamTask")<< "Cannot construct 5x5 matrix around EBDetId " << maxHitId;
00637 mat5x5 =false;
00638 }
00639 }
00640
00641 if (!mat5x5) return;
00642 LogDebug("EcalBeamTask")<< "Could construct 5x5 matrix around EBDetId " << maxHitId;
00643
00644
00645 float sideX =24.06;
00646 float sideY =22.02;
00647 float caloX =0;
00648 float caloY =0;
00649 float weight=0;
00650 float sumWeight=0;
00651
00652 for (unsigned int icry=0;icry<25;icry++)
00653 {
00654 weight = log( ene5x5[icry] / e25) + 3.8;
00655 if (weight>0)
00656 {
00657 unsigned int row = icry / 5;
00658 unsigned int column = icry %5;
00659 caloX += (column-2) * sideX * weight;
00660 caloY -= (row-2) * sideY * weight;
00661 sumWeight += weight;
00662 }
00663 }
00664 caloX /=sumWeight;
00665 caloY /=sumWeight;
00666
00667 meCaloVsHodoXPos_->Fill( recHodo->posX()-caloX );
00668 meCaloVsHodoYPos_->Fill( recHodo->posY()-caloY );
00669 meCaloVsTDCTime_->Fill( (*pUncalRH->find( maxHitId ) ).jitter() - recTDC->offset() - 3);
00670 LogDebug("EcalBeamTask")<< "jiitter from uncalRecHit: " << (*pUncalRH->find( maxHitId ) ).jitter();
00671
00672 }
00673