CMS 3D CMS Logo

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

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