CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/EcalEndcapMonitorTasks/src/EELedTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EELedTask.cc
00003  *
00004  * $Date: 2011/10/28 14:15:47 $
00005  * $Revision: 1.68 $
00006  * \author G. Della Ricca
00007  *
00008 */
00009 
00010 #include <iostream>
00011 #include <sstream>
00012 #include <vector>
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/EEDetId.h"
00023 #include "DataFormats/EcalDigi/interface/EEDataFrame.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 "DQM/EcalCommon/interface/Numbers.h"
00029 #include "DQM/EcalCommon/interface/NumbersPn.h"
00030 
00031 #include "DQM/EcalEndcapMonitorTasks/interface/EELedTask.h"
00032 
00033 EELedTask::EELedTask(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   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00046   EEDigiCollection_ = ps.getParameter<edm::InputTag>("EEDigiCollection");
00047   EcalPnDiodeDigiCollection_ = ps.getParameter<edm::InputTag>("EcalPnDiodeDigiCollection");
00048   EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
00049 
00050   // vector of enabled wavelengths (Default to all 2)
00051   ledWavelengths_.reserve(2);
00052   for ( unsigned int i = 1; i <= 2; i++ ) ledWavelengths_.push_back(i);
00053   ledWavelengths_ = ps.getUntrackedParameter<std::vector<int> >("ledWavelengths", ledWavelengths_);
00054 
00055   for (int i = 0; i < 18; i++) {
00056     meShapeMapL1_[i] = 0;
00057     meAmplMapL1_[i] = 0;
00058     meTimeMapL1_[i] = 0;
00059     meAmplPNMapL1_[i] = 0;
00060     mePnAmplMapG01L1_[i] = 0;
00061     mePnPedMapG01L1_[i] = 0;
00062     mePnAmplMapG16L1_[i] = 0;
00063     mePnPedMapG16L1_[i] = 0;
00064 
00065     meShapeMapL2_[i] = 0;
00066     meAmplMapL2_[i] = 0;
00067     meTimeMapL2_[i] = 0;
00068     meAmplPNMapL2_[i] = 0;
00069     mePnAmplMapG01L2_[i] = 0;
00070     mePnPedMapG01L2_[i] = 0;
00071     mePnAmplMapG16L2_[i] = 0;
00072     mePnPedMapG16L2_[i] = 0;
00073   }
00074 
00075 }
00076 
00077 EELedTask::~EELedTask(){
00078 
00079 }
00080 
00081 void EELedTask::beginJob(void){
00082 
00083   ievt_ = 0;
00084 
00085   if ( dqmStore_ ) {
00086     dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask");
00087     dqmStore_->rmdir(prefixME_ + "/EELedTask");
00088   }
00089 
00090 }
00091 
00092 void EELedTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00093 
00094   Numbers::initGeometry(c, false);
00095 
00096   if ( ! mergeRuns_ ) this->reset();
00097 
00098 }
00099 
00100 void EELedTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00101 
00102   for (int i = 0; i < 18; i++) {
00103     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00104       if ( meShapeMapL1_[i] )  meShapeMapL1_[i]->Reset();
00105       if ( meAmplMapL1_[i] ) meAmplMapL1_[i]->Reset();
00106       if ( meTimeMapL1_[i] ) meTimeMapL1_[i]->Reset();
00107       if ( meAmplPNMapL1_[i] ) meAmplPNMapL1_[i]->Reset();
00108     }
00109 
00110     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00111       if ( meShapeMapL2_[i] )  meShapeMapL2_[i]->Reset();
00112       if ( meAmplMapL2_[i] ) meAmplMapL2_[i]->Reset();
00113       if ( meTimeMapL2_[i] ) meTimeMapL2_[i]->Reset();
00114       if ( meAmplPNMapL2_[i] ) meAmplPNMapL2_[i]->Reset();
00115     }
00116 
00117     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00118       if ( mePnAmplMapG01L1_[i] ) mePnAmplMapG01L1_[i]->Reset();
00119       if ( mePnPedMapG01L1_[i] ) mePnPedMapG01L1_[i]->Reset();
00120 
00121       if ( mePnAmplMapG16L1_[i] ) mePnAmplMapG16L1_[i]->Reset();
00122       if ( mePnPedMapG16L1_[i] ) mePnPedMapG16L1_[i]->Reset();
00123     }
00124 
00125     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00126       if ( mePnAmplMapG01L2_[i] ) mePnAmplMapG01L2_[i]->Reset();
00127       if ( mePnPedMapG01L2_[i] ) mePnPedMapG01L2_[i]->Reset();
00128 
00129       if ( mePnAmplMapG16L2_[i] ) mePnAmplMapG16L2_[i]->Reset();
00130       if ( mePnPedMapG16L2_[i] ) mePnPedMapG16L2_[i]->Reset();
00131     }
00132   }
00133 
00134 }
00135 
00136 void EELedTask::reset(void) {
00137 
00138 }
00139 
00140 void EELedTask::setup(void){
00141 
00142   init_ = true;
00143 
00144   std::string name;
00145   std::stringstream LedN, LN;
00146 
00147   if ( dqmStore_ ) {
00148     dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask");
00149 
00150     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00151 
00152       LedN.str("");
00153       LedN << "Led" << 1;
00154       LN.str("");
00155       LN << "L" << 1;
00156 
00157       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str());
00158       for (int i = 0; i < 18; i++) {
00159         name = "EELDT shape " + Numbers::sEE(i+1) + " " + LN.str();
00160         meShapeMapL1_[i] = dqmStore_->bookProfile2D(name, name, 850, 0., 850., 10, 0., 10., 4096, 0., 4096., "s");
00161         meShapeMapL1_[i]->setAxisTitle("channel", 1);
00162         meShapeMapL1_[i]->setAxisTitle("sample", 2);
00163         meShapeMapL1_[i]->setAxisTitle("amplitude", 3);
00164         dqmStore_->tag(meShapeMapL1_[i], i+1);
00165 
00166         name = "EELDT amplitude " + Numbers::sEE(i+1) + " " + LN.str(); 
00167         meAmplMapL1_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 4096, 0., 4096.*12., "s");
00168         meAmplMapL1_[i]->setAxisTitle("ix", 1);
00169         if ( i+1 >= 1 && i+1 <= 9 ) meAmplMapL1_[i]->setAxisTitle("101-ix", 1);
00170         meAmplMapL1_[i]->setAxisTitle("iy", 2);
00171         dqmStore_->tag(meAmplMapL1_[i], i+1);
00172 
00173         name = "EELDT timing " + Numbers::sEE(i+1) + " " + LN.str(); 
00174         meTimeMapL1_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 250, 0., 10., "s");
00175         meTimeMapL1_[i]->setAxisTitle("ix", 1);
00176         if ( i+1 >= 1 && i+1 <= 9 ) meTimeMapL1_[i]->setAxisTitle("101-ix", 1);
00177         meTimeMapL1_[i]->setAxisTitle("iy", 2);
00178         dqmStore_->tag(meTimeMapL1_[i], i+1);
00179 
00180         name = "EELDT amplitude over PN " + Numbers::sEE(i+1) + " " + LN.str(); 
00181         meAmplPNMapL1_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 4096, 0., 4096.*12., "s");
00182         meAmplPNMapL1_[i]->setAxisTitle("ix", 1);
00183         if ( i+1 >= 1 && i+1 <= 9 ) meAmplPNMapL1_[i]->setAxisTitle("101-ix", 1);
00184         meAmplPNMapL1_[i]->setAxisTitle("iy", 2);
00185         dqmStore_->tag(meAmplPNMapL1_[i], i+1);
00186       }
00187 
00188       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN");
00189 
00190       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN/Gain01");
00191       for (int i = 0; i < 18; i++) {
00192         name = "EELDT PNs amplitude " + Numbers::sEE(i+1) + " G01 " + LN.str();
00193         mePnAmplMapG01L1_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00194         mePnAmplMapG01L1_[i]->setAxisTitle("channel", 1);
00195         mePnAmplMapG01L1_[i]->setAxisTitle("amplitude", 2);
00196         dqmStore_->tag(mePnAmplMapG01L1_[i], i+1);
00197 
00198         name = "EELDT PNs pedestal " + Numbers::sEE(i+1) + " G01 " + LN.str();
00199         mePnPedMapG01L1_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00200         mePnPedMapG01L1_[i]->setAxisTitle("channel", 1);
00201         mePnPedMapG01L1_[i]->setAxisTitle("pedestal", 2);
00202         dqmStore_->tag(mePnPedMapG01L1_[i], i+1);
00203       }
00204 
00205       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN/Gain16");
00206 
00207       for (int i = 0; i < 18; i++) {
00208         name = "EELDT PNs amplitude " + Numbers::sEE(i+1) + " G16 " + LN.str();
00209         mePnAmplMapG16L1_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00210         mePnAmplMapG16L1_[i]->setAxisTitle("channel", 1);
00211         mePnAmplMapG16L1_[i]->setAxisTitle("amplitude", 2);
00212         dqmStore_->tag(mePnAmplMapG16L1_[i], i+1);
00213 
00214         name = "EELDT PNs pedestal " + Numbers::sEE(i+1) + " G16 " + LN.str();
00215         mePnPedMapG16L1_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00216         mePnPedMapG16L1_[i]->setAxisTitle("channel", 1);
00217         mePnPedMapG16L1_[i]->setAxisTitle("pedestal", 2);
00218         dqmStore_->tag(mePnPedMapG16L1_[i], i+1);
00219       }
00220 
00221     }
00222 
00223     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00224 
00225       LedN.str("");
00226       LedN << "Led" << 2;
00227       LN.str("");
00228       LN << "L" << 2;
00229 
00230       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str());
00231       for (int i = 0; i < 18; i++) {
00232         name = "EELDT shape " + Numbers::sEE(i+1) + " " + LN.str();
00233         meShapeMapL2_[i] = dqmStore_->bookProfile2D(name, name, 850, 0., 850., 10, 0., 10., 4096, 0., 4096., "s");
00234         meShapeMapL2_[i]->setAxisTitle("channel", 1);
00235         meShapeMapL2_[i]->setAxisTitle("sample", 2);
00236         meShapeMapL2_[i]->setAxisTitle("amplitude", 3);
00237         dqmStore_->tag(meShapeMapL2_[i], i+1);
00238 
00239         name = "EELDT amplitude " + Numbers::sEE(i+1) + " " + LN.str(); 
00240         meAmplMapL2_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 4096, 0., 4096.*12., "s");
00241         meAmplMapL2_[i]->setAxisTitle("ix", 1);
00242         if ( i+1 >= 1 && i+1 <= 9 ) meAmplMapL2_[i]->setAxisTitle("101-ix", 1);
00243         meAmplMapL2_[i]->setAxisTitle("iy", 2);
00244         dqmStore_->tag(meAmplMapL2_[i], i+1);
00245 
00246         name = "EELDT timing " + Numbers::sEE(i+1) + " " + LN.str(); 
00247         meTimeMapL2_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 250, 0., 10., "s");
00248         meTimeMapL2_[i]->setAxisTitle("ix", 1);
00249         if ( i+1 >= 1 && i+1 <= 9 ) meTimeMapL2_[i]->setAxisTitle("101-ix", 1);
00250         meTimeMapL2_[i]->setAxisTitle("iy", 2);
00251         dqmStore_->tag(meTimeMapL2_[i], i+1);
00252 
00253         name = "EELDT amplitude over PN " + Numbers::sEE(i+1) + " " + LN.str(); 
00254         meAmplPNMapL2_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 4096, 0., 4096.*12., "s");
00255         meAmplPNMapL2_[i]->setAxisTitle("ix", 1);
00256         if ( i+1 >= 1 && i+1 <= 9 ) meAmplPNMapL2_[i]->setAxisTitle("101-ix", 1);
00257         meAmplPNMapL2_[i]->setAxisTitle("iy", 2);
00258         dqmStore_->tag(meAmplPNMapL2_[i], i+1);
00259       }
00260 
00261       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN");
00262 
00263       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN/Gain01");
00264       for (int i = 0; i < 18; i++) {
00265         name = "EELDT PNs amplitude " + Numbers::sEE(i+1) + " G01 " + LN.str();
00266         mePnAmplMapG01L2_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00267         mePnAmplMapG01L2_[i]->setAxisTitle("channel", 1);
00268         mePnAmplMapG01L2_[i]->setAxisTitle("amplitude", 2);
00269         dqmStore_->tag(mePnAmplMapG01L2_[i], i+1);
00270 
00271         name = "EELDT PNs pedestal " + Numbers::sEE(i+1) + " G01 " + LN.str();
00272         mePnPedMapG01L2_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00273         mePnPedMapG01L2_[i]->setAxisTitle("channel", 1);
00274         mePnPedMapG01L2_[i]->setAxisTitle("pedestal", 2);
00275         dqmStore_->tag(mePnPedMapG01L2_[i], i+1);
00276       }
00277 
00278       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/" + LedN.str() + "/PN/Gain16");
00279 
00280       for (int i = 0; i < 18; i++) {
00281         name = "EELDT PNs amplitude " + Numbers::sEE(i+1) + " G16 " + LN.str();
00282         mePnAmplMapG16L2_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00283         mePnAmplMapG16L2_[i]->setAxisTitle("channel", 1);
00284         mePnAmplMapG16L2_[i]->setAxisTitle("amplitude", 2);
00285         dqmStore_->tag(mePnAmplMapG16L2_[i], i+1);
00286 
00287         name = "EELDT PNs pedestal " + Numbers::sEE(i+1) + " G16 " + LN.str();
00288         mePnPedMapG16L2_[i] = dqmStore_->bookProfile(name, name, 10, 0., 10., 4096, 0., 4096., "s");
00289         mePnPedMapG16L2_[i]->setAxisTitle("channel", 1);
00290         mePnPedMapG16L2_[i]->setAxisTitle("pedestal", 2);
00291         dqmStore_->tag(mePnPedMapG16L2_[i], i+1);
00292       }
00293 
00294     }
00295 
00296   }
00297 
00298 }
00299 
00300 void EELedTask::cleanup(void){
00301 
00302   if ( ! init_ ) return;
00303 
00304   if ( dqmStore_ ) {
00305     dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask");
00306 
00307     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00308 
00309       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led1");
00310       for (int i = 0; i < 18; i++) {
00311         if ( meShapeMapL1_[i] )  dqmStore_->removeElement( meShapeMapL1_[i]->getName() );
00312         meShapeMapL1_[i] = 0;
00313         if ( meAmplMapL1_[i] ) dqmStore_->removeElement( meAmplMapL1_[i]->getName() );
00314         meAmplMapL1_[i] = 0;
00315         if ( meTimeMapL1_[i] ) dqmStore_->removeElement( meTimeMapL1_[i]->getName() );
00316         meTimeMapL1_[i] = 0;
00317         if ( meAmplPNMapL1_[i] ) dqmStore_->removeElement( meAmplPNMapL1_[i]->getName() );
00318         meAmplPNMapL1_[i] = 0;
00319       }
00320 
00321     }
00322 
00323     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00324 
00325       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led2");
00326       for (int i = 0; i < 18; i++) {
00327         if ( meShapeMapL2_[i] )  dqmStore_->removeElement( meShapeMapL2_[i]->getName() );
00328         meShapeMapL2_[i] = 0;
00329         if ( meAmplMapL2_[i] ) dqmStore_->removeElement( meAmplMapL2_[i]->getName() );
00330         meAmplMapL2_[i] = 0;
00331         if ( meTimeMapL2_[i] ) dqmStore_->removeElement( meTimeMapL2_[i]->getName() );
00332         meTimeMapL2_[i] = 0;
00333         if ( meAmplPNMapL2_[i] ) dqmStore_->removeElement( meAmplPNMapL2_[i]->getName() );
00334         meAmplPNMapL2_[i] = 0;
00335       }
00336 
00337     }
00338 
00339     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00340 
00341       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led1/PN");
00342 
00343       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led1/PN/Gain01");
00344       for (int i = 0; i < 18; i++) {
00345         if ( mePnAmplMapG01L1_[i] ) dqmStore_->removeElement( mePnAmplMapG01L1_[i]->getName() );
00346         mePnAmplMapG01L1_[i] = 0;
00347         if ( mePnPedMapG01L1_[i] ) dqmStore_->removeElement( mePnPedMapG01L1_[i]->getName() );
00348         mePnPedMapG01L1_[i] = 0;
00349       }
00350 
00351       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led1/PN/Gain16");
00352       for (int i = 0; i < 18; i++) {
00353         if ( mePnAmplMapG16L1_[i] ) dqmStore_->removeElement( mePnAmplMapG16L1_[i]->getName() );
00354         mePnAmplMapG16L1_[i] = 0;
00355         if ( mePnPedMapG16L1_[i] ) dqmStore_->removeElement( mePnPedMapG16L1_[i]->getName() );
00356         mePnPedMapG16L1_[i] = 0;
00357       }
00358 
00359     }
00360 
00361     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00362 
00363       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led2/PN");
00364 
00365       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led2/PN/Gain01");
00366       for (int i = 0; i < 18; i++) {
00367         if ( mePnAmplMapG01L2_[i] ) dqmStore_->removeElement( mePnAmplMapG01L2_[i]->getName() );
00368         mePnAmplMapG01L2_[i] = 0;
00369         if ( mePnPedMapG01L2_[i] ) dqmStore_->removeElement( mePnPedMapG01L2_[i]->getName() );
00370         mePnPedMapG01L2_[i] = 0;
00371       }
00372 
00373       dqmStore_->setCurrentFolder(prefixME_ + "/EELedTask/Led2/PN/Gain16");
00374       for (int i = 0; i < 18; i++) {
00375         if ( mePnAmplMapG16L2_[i] ) dqmStore_->removeElement( mePnAmplMapG16L2_[i]->getName() );
00376         mePnAmplMapG16L2_[i] = 0;
00377         if ( mePnPedMapG16L2_[i] ) dqmStore_->removeElement( mePnPedMapG16L2_[i]->getName() );
00378         mePnPedMapG16L2_[i] = 0;
00379       }
00380 
00381     }
00382 
00383   }
00384 
00385   init_ = false;
00386 
00387 }
00388 
00389 void EELedTask::endJob(void){
00390 
00391   edm::LogInfo("EELedTask") << "analyzed " << ievt_ << " events";
00392 
00393   if ( enableCleanup_ ) this->cleanup();
00394 
00395 }
00396 
00397 void EELedTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00398 
00399   bool enable = false;
00400   int runType[18];
00401   for (int i=0; i<18; i++) runType[i] = -1;
00402   unsigned rtHalf[18];
00403   for (int i=0; i<18; i++) rtHalf[i] = -1;
00404   int waveLength[18];
00405   for (int i=0; i<18; i++) waveLength[i] = -1;
00406 
00407   edm::Handle<EcalRawDataCollection> dcchs;
00408 
00409   if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00410 
00411     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00412 
00413       if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00414 
00415       int ism = Numbers::iSM( *dcchItr, EcalEndcap );
00416 
00417       runType[ism-1] = dcchItr->getRunType();
00418       rtHalf[ism-1] = dcchItr->getRtHalf();
00419       waveLength[ism-1] = dcchItr->getEventSettings().wavelength;
00420 
00421       if ( dcchItr->getRunType() == EcalDCCHeaderBlock::LED_STD ||
00422            dcchItr->getRunType() == EcalDCCHeaderBlock::LED_GAP ) enable = true;
00423 
00424     }
00425 
00426   } else {
00427 
00428     edm::LogWarning("EELedTask") << EcalRawDataCollection_ << " not available";
00429 
00430   }
00431 
00432   if ( ! enable ) return;
00433 
00434   if ( ! init_ ) this->setup();
00435 
00436   ievt_++;
00437 
00438   bool numPN[80];
00439   float adcPN[80];
00440   for ( int i = 0; i < 80; i++ ) {
00441     numPN[i] = false;
00442     adcPN[i] = 0.;
00443   }
00444 
00445   std::vector<int> PNs;
00446   PNs.reserve(12);
00447 
00448   edm::Handle<EEDigiCollection> digis;
00449 
00450   if ( e.getByLabel(EEDigiCollection_, digis) ) {
00451 
00452     int need = digis->size();
00453     LogDebug("EELedTask") << "event " << ievt_ << " digi collection size " << need;
00454 
00455     for ( EEDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00456 
00457       EEDetId id = digiItr->id();
00458 
00459       int ix = id.ix();
00460       int iy = id.iy();
00461 
00462       int ism = Numbers::iSM( id );
00463 
00464       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::LED_STD ||
00465                runType[ism-1] == EcalDCCHeaderBlock::LED_GAP ) ) continue;
00466 
00467       if ( runType[ism-1] == EcalDCCHeaderBlock::LED_GAP &&
00468            rtHalf[ism-1] != Numbers::RtHalf(id) ) continue;
00469 
00470       int ic = Numbers::icEE(ism, ix, iy);
00471 
00472       EEDataFrame dataframe = (*digiItr);
00473 
00474       for (int i = 0; i < 10; i++) {
00475 
00476         int adc = dataframe.sample(i).adc();
00477 
00478         MonitorElement* meShapeMap = 0;
00479 
00480         if ( Numbers::RtHalf(id) == 0 || Numbers::RtHalf(id) == 1 ) {
00481 
00482           if ( waveLength[ism-1] == 0 ) meShapeMap = meShapeMapL1_[ism-1];
00483           if ( waveLength[ism-1] == 2 ) meShapeMap = meShapeMapL2_[ism-1];
00484 
00485         } else {
00486 
00487           edm::LogWarning("EELedTask") << " RtHalf = " << Numbers::RtHalf(id);
00488 
00489         }
00490 
00491         float xval = float(adc);
00492 
00493         if ( meShapeMap ) meShapeMap->Fill(ic - 0.5, i + 0.5, xval);
00494 
00495       }
00496 
00497       NumbersPn::getPNs( ism, ix, iy, PNs );
00498 
00499       for (unsigned int i=0; i<PNs.size(); i++) {
00500         int ipn = PNs[i];
00501         if ( ipn >= 0 && ipn < 80 ) numPN[ipn] = true;
00502       }
00503 
00504     }
00505 
00506   } else {
00507 
00508     edm::LogWarning("EELedTask") << EEDigiCollection_ << " not available";
00509 
00510   }
00511 
00512   edm::Handle<EcalPnDiodeDigiCollection> pns;
00513 
00514   if ( e.getByLabel(EcalPnDiodeDigiCollection_, pns) ) {
00515 
00516     int nep = pns->size();
00517     LogDebug("EELedTask") << "event " << ievt_ << " pns collection size " << nep;
00518 
00519     for ( EcalPnDiodeDigiCollection::const_iterator pnItr = pns->begin(); pnItr != pns->end(); ++pnItr ) {
00520 
00521       if ( Numbers::subDet( pnItr->id() ) != EcalEndcap ) continue;
00522 
00523       int ism = Numbers::iSM( pnItr->id() );
00524 
00525       int num = pnItr->id().iPnId();
00526 
00527       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::LED_STD ||
00528                runType[ism-1] == EcalDCCHeaderBlock::LED_GAP ) ) continue;
00529 
00530       int ipn = NumbersPn::ipnEE( ism, num );
00531 
00532       if ( ipn >= 0 && ipn < 80 && numPN[ipn] == false ) continue;
00533 
00534       float xvalped = 0.;
00535 
00536       for (int i = 0; i < 4; i++) {
00537 
00538         int adc = pnItr->sample(i).adc();
00539 
00540         MonitorElement* mePNPed = 0;
00541 
00542         if ( pnItr->sample(i).gainId() == 0 ) {
00543           if ( waveLength[ism-1] == 0 ) mePNPed = mePnPedMapG01L1_[ism-1];
00544           if ( waveLength[ism-1] == 2 ) mePNPed = mePnPedMapG01L2_[ism-1];
00545         }
00546         if ( pnItr->sample(i).gainId() == 1 ) {
00547           if ( waveLength[ism-1] == 0 ) mePNPed = mePnPedMapG16L1_[ism-1];
00548           if ( waveLength[ism-1] == 2 ) mePNPed = mePnPedMapG16L2_[ism-1];
00549         }
00550 
00551         float xval = float(adc);
00552 
00553         if ( mePNPed ) mePNPed->Fill(num - 0.5, xval);
00554 
00555         xvalped = xvalped + xval;
00556 
00557       }
00558 
00559       xvalped = xvalped / 4;
00560 
00561       float xvalmax = 0.;
00562 
00563       MonitorElement* mePN = 0;
00564 
00565       for (int i = 0; i < 50; i++) {
00566 
00567         int adc = pnItr->sample(i).adc();
00568 
00569         float xval = float(adc);
00570 
00571         if ( xval >= xvalmax ) xvalmax = xval;
00572 
00573       }
00574 
00575       xvalmax = xvalmax - xvalped;
00576 
00577       if ( pnItr->sample(0).gainId() == 0 ) {
00578         if ( waveLength[ism-1] == 0 ) mePN = mePnAmplMapG01L1_[ism-1];
00579         if ( waveLength[ism-1] == 2 ) mePN = mePnAmplMapG01L2_[ism-1];
00580       }
00581       if ( pnItr->sample(0).gainId() == 1 ) {
00582         if ( waveLength[ism-1] == 0 ) mePN = mePnAmplMapG16L1_[ism-1];
00583         if ( waveLength[ism-1] == 2 ) mePN = mePnAmplMapG16L2_[ism-1];
00584       }
00585 
00586       if ( mePN ) mePN->Fill(num - 0.5, xvalmax);
00587 
00588       if ( ipn >= 0 && ipn < 80 ) adcPN[ipn] = xvalmax;
00589 
00590     }
00591 
00592   } else {
00593 
00594     edm::LogWarning("EELedTask") << EcalPnDiodeDigiCollection_ << " not available";
00595 
00596   }
00597 
00598   edm::Handle<EcalUncalibratedRecHitCollection> hits;
00599 
00600   if ( e.getByLabel(EcalUncalibratedRecHitCollection_, hits) ) {
00601 
00602     int neh = hits->size();
00603     LogDebug("EELedTask") << "event " << ievt_ << " hits collection size " << neh;
00604 
00605     for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00606 
00607       EEDetId id = hitItr->id();
00608 
00609       int ix = id.ix();
00610       int iy = id.iy();
00611 
00612       int ism = Numbers::iSM( id );
00613 
00614       if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
00615 
00616       float xix = ix - 0.5;
00617       float xiy = iy - 0.5;
00618 
00619       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::LED_STD ||
00620                runType[ism-1] == EcalDCCHeaderBlock::LED_GAP ) ) continue;
00621 
00622       if ( runType[ism-1] == EcalDCCHeaderBlock::LED_GAP &&
00623            rtHalf[ism-1] != Numbers::RtHalf(id) ) continue;
00624 
00625       MonitorElement* meAmplMap = 0;
00626       MonitorElement* meTimeMap = 0;
00627       MonitorElement* meAmplPNMap = 0;
00628 
00629       if ( Numbers::RtHalf(id) == 0 || Numbers::RtHalf(id) == 1 ) {
00630 
00631         if ( waveLength[ism-1] == 0 ) {
00632           meAmplMap = meAmplMapL1_[ism-1];
00633           meTimeMap = meTimeMapL1_[ism-1];
00634           meAmplPNMap = meAmplPNMapL1_[ism-1];
00635         }
00636         if ( waveLength[ism-1] == 2 ) {
00637           meAmplMap = meAmplMapL2_[ism-1];
00638           meTimeMap = meTimeMapL2_[ism-1];
00639           meAmplPNMap = meAmplPNMapL2_[ism-1];
00640         }
00641 
00642       } else {
00643 
00644         edm::LogWarning("EELedTask") << " RtHalf = " << Numbers::RtHalf(id);
00645 
00646       }
00647 
00648       float xval = hitItr->amplitude();
00649       if ( xval <= 0. ) xval = 0.0;
00650       float yval = hitItr->jitter() + 6.0;
00651       if ( yval <= 0. ) yval = 0.0;
00652       float zval = hitItr->pedestal();
00653       if ( zval <= 0. ) zval = 0.0;
00654 
00655       if ( meAmplMap ) meAmplMap->Fill(xix, xiy, xval);
00656 
00657       if ( xval > 16. ) {
00658         if ( meTimeMap ) meTimeMap->Fill(xix, xiy, yval);
00659       }
00660 
00661       float wval = 0.;
00662 
00663       NumbersPn::getPNs( ism, ix, iy, PNs );
00664 
00665       if ( PNs.size() > 0 ) {
00666         int ipn = PNs[0];
00667         if ( ipn >= 0 && ipn < 80 ) {
00668           if ( adcPN[ipn] != 0. ) wval = xval / adcPN[ipn];
00669         }
00670       }
00671 
00672       if ( meAmplPNMap ) meAmplPNMap->Fill(xix, xiy, wval);
00673 
00674     }
00675 
00676   } else {
00677 
00678     edm::LogWarning("EELedTask") << EcalUncalibratedRecHitCollection_ << " not available";
00679 
00680   }
00681 
00682 }
00683