CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/EcalBarrelMonitorTasks/src/EBTestPulseTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBTestPulseTask.cc
00003  *
00004  * $Date: 2010/08/08 08:46:05 $
00005  * $Revision: 1.116 $
00006  * \author G. Della Ricca
00007  * \author G. Franzoni
00008  *
00009 */
00010 
00011 #include <iostream>
00012 #include <fstream>
00013 #include <vector>
00014 
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 
00018 #include "DQMServices/Core/interface/MonitorElement.h"
00019 
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 
00022 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00023 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00024 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00025 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00026 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
00027 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00028 
00029 #include "DQM/EcalCommon/interface/Numbers.h"
00030 
00031 #include "DQM/EcalBarrelMonitorTasks/interface/EBTestPulseTask.h"
00032 
00033 EBTestPulseTask::EBTestPulseTask(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   EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
00047   EcalPnDiodeDigiCollection_ = ps.getParameter<edm::InputTag>("EcalPnDiodeDigiCollection");
00048   EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
00049 
00050   MGPAGains_.reserve(3);
00051   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGains_.push_back(i);
00052   MGPAGains_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGains", MGPAGains_);
00053 
00054   MGPAGainsPN_.reserve(2);
00055   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGainsPN_.push_back(i);
00056   MGPAGainsPN_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN", MGPAGainsPN_);
00057 
00058   for (int i = 0; i < 36; i++) {
00059     meShapeMapG01_[i] = 0;
00060     meAmplMapG01_[i] = 0;
00061     meShapeMapG06_[i] = 0;
00062     meAmplMapG06_[i] = 0;
00063     meShapeMapG12_[i] = 0;
00064     meAmplMapG12_[i] = 0;
00065     mePnAmplMapG01_[i] = 0;
00066     mePnPedMapG01_[i] = 0;
00067     mePnAmplMapG16_[i] = 0;
00068     mePnPedMapG16_[i] = 0;
00069   }
00070 
00071 
00072 }
00073 
00074 EBTestPulseTask::~EBTestPulseTask(){
00075 
00076 }
00077 
00078 void EBTestPulseTask::beginJob(void){
00079 
00080   ievt_ = 0;
00081 
00082   if ( dqmStore_ ) {
00083     dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask");
00084     dqmStore_->rmdir(prefixME_ + "/EBTestPulseTask");
00085   }
00086 
00087 }
00088 
00089 void EBTestPulseTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00090 
00091   Numbers::initGeometry(c, false);
00092 
00093   if ( ! mergeRuns_ ) this->reset();
00094 
00095 }
00096 
00097 void EBTestPulseTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00098 
00099 }
00100 
00101 void EBTestPulseTask::reset(void) {
00102 
00103   for (int i = 0; i < 36; i++) {
00104     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00105       if ( meShapeMapG01_[i] ) meShapeMapG01_[i]->Reset();
00106       if ( meAmplMapG01_[i] ) meAmplMapG01_[i]->Reset();
00107     }
00108     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00109       if ( meShapeMapG06_[i] ) meShapeMapG06_[i]->Reset();
00110       if ( meAmplMapG06_[i] ) meAmplMapG06_[i]->Reset();
00111     }
00112     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00113       if ( meShapeMapG12_[i] ) meShapeMapG12_[i]->Reset();
00114       if ( meAmplMapG12_[i] ) meAmplMapG12_[i]->Reset();
00115     }
00116     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00117       if ( mePnAmplMapG01_[i] ) mePnAmplMapG01_[i]->Reset();
00118       if ( mePnPedMapG01_[i] ) mePnPedMapG01_[i]->Reset();
00119     }
00120     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00121       if ( mePnAmplMapG16_[i] ) mePnAmplMapG16_[i]->Reset();
00122       if ( mePnPedMapG16_[i] ) mePnPedMapG16_[i]->Reset();
00123     }
00124   }
00125 
00126 }
00127 
00128 void EBTestPulseTask::setup(void){
00129 
00130   init_ = true;
00131 
00132   char histo[200];
00133 
00134   if ( dqmStore_ ) {
00135     dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask");
00136 
00137     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00138 
00139       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain01");
00140       for (int i = 0; i < 36; i++) {
00141         sprintf(histo, "EBTPT shape %s G01", Numbers::sEB(i+1).c_str());
00142         meShapeMapG01_[i] = dqmStore_->bookProfile2D(histo, histo, 1700, 0., 1700., 10, 0., 10., 4096, 0., 4096., "s");
00143         meShapeMapG01_[i]->setAxisTitle("channel", 1);
00144         meShapeMapG01_[i]->setAxisTitle("sample", 2);
00145         meShapeMapG01_[i]->setAxisTitle("amplitude", 3);
00146         dqmStore_->tag(meShapeMapG01_[i], i+1);
00147         sprintf(histo, "EBTPT amplitude %s G01", Numbers::sEB(i+1).c_str());
00148         meAmplMapG01_[i] = dqmStore_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 4096, 0., 4096.*12., "s");
00149         meAmplMapG01_[i]->setAxisTitle("ieta", 1);
00150         meAmplMapG01_[i]->setAxisTitle("iphi", 2);
00151         dqmStore_->tag(meAmplMapG01_[i], i+1);
00152       }
00153 
00154     }
00155 
00156     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00157 
00158       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain06");
00159       for (int i = 0; i < 36; i++) {
00160         sprintf(histo, "EBTPT shape %s G06", Numbers::sEB(i+1).c_str());
00161         meShapeMapG06_[i] = dqmStore_->bookProfile2D(histo, histo, 1700, 0., 1700., 10, 0., 10., 4096, 0., 4096., "s");
00162         meShapeMapG06_[i]->setAxisTitle("channel", 1);
00163         meShapeMapG06_[i]->setAxisTitle("sample", 2);
00164         meShapeMapG06_[i]->setAxisTitle("amplitude", 3);
00165         dqmStore_->tag(meShapeMapG06_[i], i+1);
00166         sprintf(histo, "EBTPT amplitude %s G06", Numbers::sEB(i+1).c_str());
00167         meAmplMapG06_[i] = dqmStore_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 4096, 0., 4096.*12., "s");
00168         meAmplMapG06_[i]->setAxisTitle("ieta", 1);
00169         meAmplMapG06_[i]->setAxisTitle("iphi", 2);
00170         dqmStore_->tag(meAmplMapG06_[i], i+1);
00171       }
00172 
00173     }
00174 
00175     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00176 
00177       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain12");
00178       for (int i = 0; i < 36; i++) {
00179         sprintf(histo, "EBTPT shape %s G12", Numbers::sEB(i+1).c_str());
00180         meShapeMapG12_[i] = dqmStore_->bookProfile2D(histo, histo, 1700, 0., 1700., 10, 0., 10., 4096, 0., 4096., "s");
00181         meShapeMapG12_[i]->setAxisTitle("channel", 1);
00182         meShapeMapG12_[i]->setAxisTitle("sample", 2);
00183         meShapeMapG12_[i]->setAxisTitle("amplitude", 3);
00184         dqmStore_->tag(meShapeMapG12_[i], i+1);
00185         sprintf(histo, "EBTPT amplitude %s G12", Numbers::sEB(i+1).c_str());
00186         meAmplMapG12_[i] = dqmStore_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 4096, 0., 4096.*12., "s");
00187         meAmplMapG12_[i]->setAxisTitle("ieta", 1);
00188         meAmplMapG12_[i]->setAxisTitle("iphi", 2);
00189         dqmStore_->tag(meAmplMapG12_[i], i+1);
00190       }
00191 
00192     }
00193 
00194     dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN");
00195 
00196     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00197 
00198       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN/Gain01");
00199       for (int i = 0; i < 36; i++) {
00200         sprintf(histo, "EBTPT PNs amplitude %s G01", Numbers::sEB(i+1).c_str());
00201         mePnAmplMapG01_[i] = dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00202         mePnAmplMapG01_[i]->setAxisTitle("channel", 1);
00203         mePnAmplMapG01_[i]->setAxisTitle("amplitude", 2);
00204         dqmStore_->tag(mePnAmplMapG01_[i], i+1);
00205         sprintf(histo, "EBTPT PNs pedestal %s G01", Numbers::sEB(i+1).c_str());
00206         mePnPedMapG01_[i] =  dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00207         mePnPedMapG01_[i]->setAxisTitle("channel", 1);
00208         mePnPedMapG01_[i]->setAxisTitle("pedestal", 2);
00209         dqmStore_->tag(mePnPedMapG01_[i], i+1);
00210       }
00211 
00212     }
00213 
00214     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00215 
00216       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN/Gain16");
00217       for (int i = 0; i < 36; i++) {
00218         sprintf(histo, "EBTPT PNs amplitude %s G16", Numbers::sEB(i+1).c_str());
00219         mePnAmplMapG16_[i] = dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00220         mePnAmplMapG16_[i]->setAxisTitle("channel", 1);
00221         mePnAmplMapG16_[i]->setAxisTitle("amplitude", 2);
00222         dqmStore_->tag(mePnAmplMapG16_[i], i+1);
00223         sprintf(histo, "EBTPT PNs pedestal %s G16", Numbers::sEB(i+1).c_str());
00224         mePnPedMapG16_[i] =  dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00225         mePnPedMapG16_[i]->setAxisTitle("channel", 1);
00226         mePnPedMapG16_[i]->setAxisTitle("pedestal", 2);
00227         dqmStore_->tag(mePnPedMapG16_[i], i+1);
00228       }
00229 
00230     }
00231 
00232   }
00233 
00234 }
00235 
00236 void EBTestPulseTask::cleanup(void){
00237 
00238   if ( ! init_ ) return;
00239 
00240   if ( dqmStore_ ) {
00241     dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask");
00242 
00243     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00244 
00245       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain01");
00246       for (int i = 0; i < 36; i++) {
00247         if ( meShapeMapG01_[i] ) dqmStore_->removeElement( meShapeMapG01_[i]->getName() );
00248         meShapeMapG01_[i] = 0;
00249         if ( meAmplMapG01_[i] ) dqmStore_->removeElement( meAmplMapG01_[i]->getName() );
00250         meAmplMapG01_[i] = 0;
00251       }
00252 
00253     }
00254 
00255     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00256 
00257       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain06");
00258       for (int i = 0; i < 36; i++) {
00259         if ( meShapeMapG06_[i] ) dqmStore_->removeElement( meShapeMapG06_[i]->getName() );
00260         meShapeMapG06_[i] = 0;
00261         if ( meAmplMapG06_[i] ) dqmStore_->removeElement( meAmplMapG06_[i]->getName() );
00262         meAmplMapG06_[i] = 0;
00263       }
00264 
00265     }
00266 
00267     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00268 
00269       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/Gain12");
00270       for (int i = 0; i < 36; i++) {
00271         if ( meShapeMapG12_[i] ) dqmStore_->removeElement( meShapeMapG12_[i]->getName() );
00272         meShapeMapG12_[i] = 0;
00273         if ( meAmplMapG12_[i] ) dqmStore_->removeElement( meAmplMapG12_[i]->getName() );
00274         meAmplMapG12_[i] = 0;
00275       }
00276 
00277     }
00278 
00279     dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN");
00280 
00281     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00282 
00283       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN/Gain01");
00284       for (int i = 0; i < 36; i++) {
00285         if ( mePnAmplMapG01_[i] ) dqmStore_->removeElement( mePnAmplMapG01_[i]->getName() );
00286         mePnAmplMapG01_[i] = 0;
00287         if ( mePnPedMapG01_[i] ) dqmStore_->removeElement( mePnPedMapG01_[i]->getName() );
00288         mePnPedMapG01_[i] = 0;
00289       }
00290 
00291     }
00292 
00293 
00294     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00295 
00296       dqmStore_->setCurrentFolder(prefixME_ + "/EBTestPulseTask/PN/Gain16");
00297       for (int i = 0; i < 36; i++) {
00298         if ( mePnAmplMapG16_[i] ) dqmStore_->removeElement( mePnAmplMapG16_[i]->getName() );
00299         mePnAmplMapG16_[i] = 0;
00300         if ( mePnPedMapG16_[i] ) dqmStore_->removeElement( mePnPedMapG16_[i]->getName() );
00301         mePnPedMapG16_[i] = 0;
00302       }
00303 
00304     }
00305 
00306   }
00307 
00308   init_ = false;
00309 
00310 }
00311 
00312 void EBTestPulseTask::endJob(void){
00313 
00314   edm::LogInfo("EBTestPulseTask") << "analyzed " << ievt_ << " events";
00315 
00316   if ( enableCleanup_ ) this->cleanup();
00317 
00318 }
00319 
00320 void EBTestPulseTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00321 
00322   bool enable = false;
00323   int runType[36];
00324   for (int i=0; i<36; i++) runType[i] = -1;
00325   int mgpaGain[36];
00326   for (int i=0; i<36; i++) mgpaGain[i] = -1;
00327 
00328   edm::Handle<EcalRawDataCollection> dcchs;
00329 
00330   if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00331 
00332     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00333 
00334       if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00335 
00336       int ism = Numbers::iSM( *dcchItr, EcalBarrel );
00337 
00338       runType[ism-1] = dcchItr->getRunType();
00339       mgpaGain[ism-1] = dcchItr->getMgpaGain();
00340 
00341       if ( dcchItr->getRunType() == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00342            dcchItr->getRunType() == EcalDCCHeaderBlock::TESTPULSE_GAP ) enable = true;
00343 
00344     }
00345 
00346   } else {
00347 
00348     edm::LogWarning("EBTestPulseTask") << EcalRawDataCollection_ << " not available";
00349 
00350   }
00351 
00352   if ( ! enable ) return;
00353 
00354   if ( ! init_ ) this->setup();
00355 
00356   ievt_++;
00357 
00358   edm::Handle<EBDigiCollection> digis;
00359 
00360   if ( e.getByLabel(EBDigiCollection_, digis) ) {
00361 
00362     int nebd = digis->size();
00363     LogDebug("EBTestPulseTask") << "event " << ievt_ << " digi collection size " << nebd;
00364 
00365     for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00366 
00367       EBDetId id = digiItr->id();
00368 
00369       int ic = id.ic();
00370 
00371       int ism = Numbers::iSM( id );
00372 
00373       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00374                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00375 
00376       EBDataFrame dataframe = (*digiItr);
00377 
00378       for (int i = 0; i < 10; i++) {
00379 
00380         int adc = dataframe.sample(i).adc();
00381         float gain = 1.;
00382 
00383         MonitorElement* meShapeMap = 0;
00384 
00385         if ( dataframe.sample(i).gainId() == 1 ) gain = 1./12.;
00386         if ( dataframe.sample(i).gainId() == 2 ) gain = 1./ 6.;
00387         if ( dataframe.sample(i).gainId() == 3 ) gain = 1./ 1.;
00388 
00389         if ( mgpaGain[ism-1] == 3 ) meShapeMap = meShapeMapG01_[ism-1];
00390         if ( mgpaGain[ism-1] == 2 ) meShapeMap = meShapeMapG06_[ism-1];
00391         if ( mgpaGain[ism-1] == 1 ) meShapeMap = meShapeMapG12_[ism-1];
00392 
00393 //        float xval = float(adc) * gain;
00394         float xval = float(adc);
00395 
00396         if ( meShapeMap ) meShapeMap->Fill(ic - 0.5, i + 0.5, xval);
00397 
00398       }
00399 
00400     }
00401 
00402   } else {
00403 
00404     edm::LogWarning("EBTestPulseTask") << EBDigiCollection_ << " not available";
00405 
00406   }
00407 
00408   edm::Handle<EcalUncalibratedRecHitCollection> hits;
00409 
00410   if ( e.getByLabel(EcalUncalibratedRecHitCollection_, hits) ) {
00411 
00412     int neh = hits->size();
00413     LogDebug("EBTestPulseTask") << "event " << ievt_ << " hits collection size " << neh;
00414 
00415     for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00416 
00417       EBDetId id = hitItr->id();
00418 
00419       int ic = id.ic();
00420       int ie = (ic-1)/20 + 1;
00421       int ip = (ic-1)%20 + 1;
00422 
00423       int ism = Numbers::iSM( id );
00424 
00425       float xie = ie - 0.5;
00426       float xip = ip - 0.5;
00427 
00428       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00429                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00430 
00431       MonitorElement* meAmplMap = 0;
00432 
00433       if ( mgpaGain[ism-1] == 3 ) meAmplMap = meAmplMapG01_[ism-1];
00434       if ( mgpaGain[ism-1] == 2 ) meAmplMap = meAmplMapG06_[ism-1];
00435       if ( mgpaGain[ism-1] == 1 ) meAmplMap = meAmplMapG12_[ism-1];
00436 
00437       float xval = hitItr->amplitude();
00438       if ( xval <= 0. ) xval = 0.0;
00439 
00440 //      if ( mgpaGain[ism-1] == 3 ) xval = xval * 1./12.;
00441 //      if ( mgpaGain[ism-1] == 2 ) xval = xval * 1./ 2.;
00442 //      if ( mgpaGain[ism-1] == 1 ) xval = xval * 1./ 1.;
00443 
00444       if ( meAmplMap ) meAmplMap->Fill(xie, xip, xval);
00445 
00446     }
00447 
00448   } else {
00449 
00450     edm::LogWarning("EBTestPulseTask") << EcalUncalibratedRecHitCollection_ << " not available";
00451 
00452   }
00453 
00454   edm::Handle<EcalPnDiodeDigiCollection> pns;
00455 
00456   if ( e.getByLabel(EcalPnDiodeDigiCollection_, pns) ) {
00457 
00458     int nep = pns->size();
00459     LogDebug("EBTestPulseTask") << "event " << ievt_ << " pns collection size " << nep;
00460 
00461     for ( EcalPnDiodeDigiCollection::const_iterator pnItr = pns->begin(); pnItr != pns->end(); ++pnItr ) {
00462 
00463       if ( Numbers::subDet( pnItr->id() ) != EcalBarrel ) continue;
00464 
00465       int ism = Numbers::iSM( pnItr->id() );
00466 
00467       int num = pnItr->id().iPnId();
00468 
00469       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00470                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00471 
00472       float xvalped = 0.;
00473 
00474       for (int i = 0; i < 4; i++) {
00475 
00476         int adc = pnItr->sample(i).adc();
00477 
00478         MonitorElement* mePNPed = 0;
00479 
00480         if ( pnItr->sample(i).gainId() == 0 ) mePNPed = mePnPedMapG01_[ism-1];
00481         if ( pnItr->sample(i).gainId() == 1 ) mePNPed = mePnPedMapG16_[ism-1];
00482 
00483         float xval = float(adc);
00484 
00485         if ( mePNPed ) mePNPed->Fill(num - 0.5, xval);
00486 
00487         xvalped = xvalped + xval;
00488 
00489       }
00490 
00491       xvalped = xvalped / 4;
00492 
00493       float xvalmax = 0.;
00494 
00495       MonitorElement* mePN = 0;
00496 
00497       for (int i = 0; i < 50; i++) {
00498 
00499         int adc = pnItr->sample(i).adc();
00500 
00501         float xval = float(adc);
00502 
00503         if ( xval >= xvalmax ) xvalmax = xval;
00504 
00505       }
00506 
00507       xvalmax = xvalmax - xvalped;
00508 
00509       if ( pnItr->sample(0).gainId() == 0 ) mePN = mePnAmplMapG01_[ism-1];
00510       if ( pnItr->sample(0).gainId() == 1 ) mePN = mePnAmplMapG16_[ism-1];
00511 
00512       if ( mePN ) mePN->Fill(num - 0.5, xvalmax);
00513 
00514     }
00515 
00516   } else {
00517 
00518     edm::LogWarning("EBTestPulseTask") << EcalPnDiodeDigiCollection_ << " not available";
00519 
00520   }
00521 
00522 }
00523