CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/EcalEndcapMonitorTasks/src/EETestPulseTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EETestPulseTask.cc
00003  *
00004  * $Date: 2010/08/08 08:46:09 $
00005  * $Revision: 1.58 $
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 
00030 #include "DQM/EcalEndcapMonitorTasks/interface/EETestPulseTask.h"
00031 
00032 EETestPulseTask::EETestPulseTask(const edm::ParameterSet& ps){
00033 
00034   init_ = false;
00035 
00036   dqmStore_ = edm::Service<DQMStore>().operator->();
00037 
00038   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00039 
00040   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00041 
00042   mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00043 
00044   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00045   EEDigiCollection_ = ps.getParameter<edm::InputTag>("EEDigiCollection");
00046   EcalPnDiodeDigiCollection_ = ps.getParameter<edm::InputTag>("EcalPnDiodeDigiCollection");
00047   EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
00048 
00049   MGPAGains_.reserve(3);
00050   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGains_.push_back(i);
00051   MGPAGains_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGains", MGPAGains_);
00052 
00053   MGPAGainsPN_.reserve(2);
00054   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGainsPN_.push_back(i);
00055   MGPAGainsPN_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN", MGPAGainsPN_);
00056 
00057   for (int i = 0; i < 18; i++) {
00058     meShapeMapG01_[i] = 0;
00059     meAmplMapG01_[i] = 0;
00060     meShapeMapG06_[i] = 0;
00061     meAmplMapG06_[i] = 0;
00062     meShapeMapG12_[i] = 0;
00063     meAmplMapG12_[i] = 0;
00064     mePnAmplMapG01_[i] = 0;
00065     mePnPedMapG01_[i] = 0;
00066     mePnAmplMapG16_[i] = 0;
00067     mePnPedMapG16_[i] = 0;
00068   }
00069 
00070 }
00071 
00072 EETestPulseTask::~EETestPulseTask(){
00073 
00074 }
00075 
00076 void EETestPulseTask::beginJob(void){
00077 
00078   ievt_ = 0;
00079 
00080   if ( dqmStore_ ) {
00081     dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask");
00082     dqmStore_->rmdir(prefixME_ + "/EETestPulseTask");
00083   }
00084 
00085 }
00086 
00087 void EETestPulseTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00088 
00089   Numbers::initGeometry(c, false);
00090 
00091   if ( ! mergeRuns_ ) this->reset();
00092 
00093 }
00094 
00095 void EETestPulseTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00096 
00097 }
00098 
00099 void EETestPulseTask::reset(void) {
00100 
00101   for (int i = 0; i < 18; i++) {
00102     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00103       if ( meShapeMapG01_[i] ) meShapeMapG01_[i]->Reset();
00104       if ( meAmplMapG01_[i] ) meAmplMapG01_[i]->Reset();
00105     }
00106     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00107       if ( meShapeMapG06_[i] ) meShapeMapG06_[i]->Reset();
00108       if ( meAmplMapG06_[i] ) meAmplMapG06_[i]->Reset();
00109     }
00110     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00111       if ( meShapeMapG12_[i] ) meShapeMapG12_[i]->Reset();
00112       if ( meAmplMapG12_[i] ) meAmplMapG12_[i]->Reset();
00113     }
00114     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00115       if ( mePnAmplMapG01_[i] ) mePnAmplMapG01_[i]->Reset();
00116       if ( mePnPedMapG01_[i] ) mePnPedMapG01_[i]->Reset();
00117     }
00118     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00119       if ( mePnAmplMapG16_[i] ) mePnAmplMapG16_[i]->Reset();
00120       if ( mePnPedMapG16_[i] ) mePnPedMapG16_[i]->Reset();
00121     }
00122   }
00123 
00124 }
00125 
00126 void EETestPulseTask::setup(void){
00127 
00128   init_ = true;
00129 
00130   char histo[200];
00131 
00132   if ( dqmStore_ ) {
00133     dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask");
00134 
00135     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00136 
00137       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/Gain01");
00138       for (int i = 0; i < 18; i++) {
00139         sprintf(histo, "EETPT shape %s G01", Numbers::sEE(i+1).c_str());
00140         meShapeMapG01_[i] = dqmStore_->bookProfile2D(histo, histo, 850, 0., 850., 10, 0., 10., 4096, 0., 4096., "s");
00141         meShapeMapG01_[i]->setAxisTitle("channel", 1);
00142         meShapeMapG01_[i]->setAxisTitle("sample", 2);
00143         meShapeMapG01_[i]->setAxisTitle("amplitude", 3);
00144         dqmStore_->tag(meShapeMapG01_[i], i+1);
00145         sprintf(histo, "EETPT amplitude %s G01", Numbers::sEE(i+1).c_str());
00146         meAmplMapG01_[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");
00147         meAmplMapG01_[i]->setAxisTitle("ix", 1);
00148         if ( i+1 >= 1 && i+1 <= 9 ) meAmplMapG01_[i]->setAxisTitle("101-ix", 1);
00149         meAmplMapG01_[i]->setAxisTitle("iy", 2);
00150         dqmStore_->tag(meAmplMapG01_[i], i+1);
00151       }
00152 
00153     }
00154 
00155     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00156 
00157       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/Gain06");
00158       for (int i = 0; i < 18; i++) {
00159         sprintf(histo, "EETPT shape %s G06", Numbers::sEE(i+1).c_str());
00160         meShapeMapG06_[i] = dqmStore_->bookProfile2D(histo, histo, 850, 0., 850., 10, 0., 10., 4096, 0., 4096., "s");
00161         meShapeMapG06_[i]->setAxisTitle("channel", 1);
00162         meShapeMapG06_[i]->setAxisTitle("sample", 2);
00163         meShapeMapG06_[i]->setAxisTitle("amplitude", 3);
00164         dqmStore_->tag(meShapeMapG06_[i], i+1);
00165         sprintf(histo, "EETPT amplitude %s G06", Numbers::sEE(i+1).c_str());
00166         meAmplMapG06_[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");
00167         meAmplMapG06_[i]->setAxisTitle("ix", 1);
00168         if ( i+1 >= 1 && i+1 <= 9 ) meAmplMapG06_[i]->setAxisTitle("101-ix", 1);
00169         meAmplMapG06_[i]->setAxisTitle("iy", 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_ + "/EETestPulseTask/Gain12");
00178       for (int i = 0; i < 18; i++) {
00179         sprintf(histo, "EETPT shape %s G12", Numbers::sEE(i+1).c_str());
00180         meShapeMapG12_[i] = dqmStore_->bookProfile2D(histo, histo, 850, 0., 850., 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, "EETPT amplitude %s G12", Numbers::sEE(i+1).c_str());
00186         meAmplMapG12_[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");
00187         meAmplMapG12_[i]->setAxisTitle("ix", 1);
00188         if ( i+1 >= 1 && i+1 <= 9 ) meAmplMapG12_[i]->setAxisTitle("101-ix", 1);
00189         meAmplMapG12_[i]->setAxisTitle("iy", 2);
00190         dqmStore_->tag(meAmplMapG12_[i], i+1);
00191       }
00192 
00193     }
00194 
00195     dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN");
00196 
00197     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00198 
00199       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN/Gain01");
00200       for (int i = 0; i < 18; i++) {
00201         sprintf(histo, "EETPT PNs amplitude %s G01", Numbers::sEE(i+1).c_str());
00202         mePnAmplMapG01_[i] = dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00203         mePnAmplMapG01_[i]->setAxisTitle("channel", 1);
00204         mePnAmplMapG01_[i]->setAxisTitle("amplitude", 2);
00205         dqmStore_->tag(mePnAmplMapG01_[i], i+1);
00206         sprintf(histo, "EETPT PNs pedestal %s G01", Numbers::sEE(i+1).c_str());
00207         mePnPedMapG01_[i] =  dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00208         mePnPedMapG01_[i]->setAxisTitle("channel", 1);
00209         mePnPedMapG01_[i]->setAxisTitle("pedestal", 2);
00210         dqmStore_->tag(mePnPedMapG01_[i], i+1);
00211       }
00212 
00213     }
00214 
00215     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00216 
00217       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN/Gain16");
00218       for (int i = 0; i < 18; i++) {
00219         sprintf(histo, "EETPT PNs amplitude %s G16", Numbers::sEE(i+1).c_str());
00220         mePnAmplMapG16_[i] = dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00221         mePnAmplMapG16_[i]->setAxisTitle("channel", 1);
00222         mePnAmplMapG16_[i]->setAxisTitle("amplitude", 2);
00223         dqmStore_->tag(mePnAmplMapG16_[i], i+1);
00224         sprintf(histo, "EETPT PNs pedestal %s G16", Numbers::sEE(i+1).c_str());
00225         mePnPedMapG16_[i] =  dqmStore_->bookProfile(histo, histo, 10, 0., 10., 4096, 0., 4096., "s");
00226         mePnPedMapG16_[i]->setAxisTitle("channel", 1);
00227         mePnPedMapG16_[i]->setAxisTitle("pedestal", 2);
00228         dqmStore_->tag(mePnPedMapG16_[i], i+1);
00229       }
00230 
00231     }
00232 
00233   }
00234 
00235 }
00236 
00237 void EETestPulseTask::cleanup(void){
00238 
00239   if ( ! init_ ) return;
00240 
00241   if ( dqmStore_ ) {
00242     dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask");
00243 
00244     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00245 
00246       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/Gain01");
00247       for (int i = 0; i < 18; i++) {
00248         if ( meShapeMapG01_[i] ) dqmStore_->removeElement( meShapeMapG01_[i]->getName() );
00249         meShapeMapG01_[i] = 0;
00250         if ( meAmplMapG01_[i] ) dqmStore_->removeElement( meAmplMapG01_[i]->getName() );
00251         meAmplMapG01_[i] = 0;
00252       }
00253 
00254     }
00255 
00256     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00257 
00258       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/Gain06");
00259       for (int i = 0; i < 18; i++) {
00260         if ( meShapeMapG06_[i] ) dqmStore_->removeElement( meShapeMapG06_[i]->getName() );
00261         meShapeMapG06_[i] = 0;
00262         if ( meAmplMapG06_[i] ) dqmStore_->removeElement( meAmplMapG06_[i]->getName() );
00263         meAmplMapG06_[i] = 0;
00264       }
00265 
00266     }
00267 
00268     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00269 
00270       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/Gain12");
00271       for (int i = 0; i < 18; i++) {
00272         if ( meShapeMapG12_[i] ) dqmStore_->removeElement( meShapeMapG12_[i]->getName() );
00273         meShapeMapG12_[i] = 0;
00274         if ( meAmplMapG12_[i] ) dqmStore_->removeElement( meAmplMapG12_[i]->getName() );
00275         meAmplMapG12_[i] = 0;
00276       }
00277 
00278     }
00279 
00280     dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN");
00281 
00282     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00283 
00284       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN/Gain01");
00285       for (int i = 0; i < 18; i++) {
00286         if ( mePnAmplMapG01_[i] ) dqmStore_->removeElement( mePnAmplMapG01_[i]->getName() );
00287         mePnAmplMapG01_[i] = 0;
00288         if ( mePnPedMapG01_[i] ) dqmStore_->removeElement( mePnPedMapG01_[i]->getName() );
00289         mePnPedMapG01_[i] = 0;
00290       }
00291 
00292     }
00293 
00294     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00295 
00296       dqmStore_->setCurrentFolder(prefixME_ + "/EETestPulseTask/PN/Gain16");
00297       for (int i = 0; i < 18; 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 EETestPulseTask::endJob(void){
00313 
00314   edm::LogInfo("EETestPulseTask") << "analyzed " << ievt_ << " events";
00315 
00316   if ( enableCleanup_ ) this->cleanup();
00317 
00318 }
00319 
00320 void EETestPulseTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00321 
00322   bool enable = false;
00323   int runType[18];
00324   for (int i=0; i<18; i++) runType[i] = -1;
00325   int mgpaGain[18];
00326   for (int i=0; i<18; 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 ) != EcalEndcap ) continue;
00335 
00336       int ism = Numbers::iSM( *dcchItr, EcalEndcap );
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("EETestPulseTask") << EcalRawDataCollection_ << " not available";
00349 
00350   }
00351 
00352   if ( ! enable ) return;
00353 
00354   if ( ! init_ ) this->setup();
00355 
00356   ievt_++;
00357 
00358   edm::Handle<EEDigiCollection> digis;
00359 
00360   if ( e.getByLabel(EEDigiCollection_, digis) ) {
00361 
00362     int need = digis->size();
00363     LogDebug("EETestPulseTask") << "event " << ievt_ << " digi collection size " << need;
00364 
00365     for ( EEDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00366 
00367       EEDetId id = digiItr->id();
00368 
00369       int ix = id.ix();
00370       int iy = id.iy();
00371 
00372       int ism = Numbers::iSM( id );
00373 
00374       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00375                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00376 
00377       int ic = Numbers::icEE(ism, ix, iy);
00378 
00379       EEDataFrame dataframe = (*digiItr);
00380 
00381       for (int i = 0; i < 10; i++) {
00382 
00383         int adc = dataframe.sample(i).adc();
00384         float gain = 1.;
00385 
00386         MonitorElement* meShapeMap = 0;
00387 
00388         if ( dataframe.sample(i).gainId() == 1 ) gain = 1./12.;
00389         if ( dataframe.sample(i).gainId() == 2 ) gain = 1./ 6.;
00390         if ( dataframe.sample(i).gainId() == 3 ) gain = 1./ 1.;
00391 
00392         if ( mgpaGain[ism-1] == 3 ) meShapeMap = meShapeMapG01_[ism-1];
00393         if ( mgpaGain[ism-1] == 2 ) meShapeMap = meShapeMapG06_[ism-1];
00394         if ( mgpaGain[ism-1] == 1 ) meShapeMap = meShapeMapG12_[ism-1];
00395 
00396 //        float xval = float(adc) * gain;
00397         float xval = float(adc);
00398 
00399         if ( meShapeMap ) meShapeMap->Fill(ic - 0.5, i + 0.5, xval);
00400 
00401       }
00402 
00403     }
00404 
00405   } else {
00406 
00407     edm::LogWarning("EETestPulseTask") << EEDigiCollection_ << " not available";
00408 
00409   }
00410 
00411   edm::Handle<EcalUncalibratedRecHitCollection> hits;
00412 
00413   if ( e.getByLabel(EcalUncalibratedRecHitCollection_, hits) ) {
00414 
00415     int neh = hits->size();
00416     LogDebug("EETestPulseTask") << "event " << ievt_ << " hits collection size " << neh;
00417 
00418     for ( EcalUncalibratedRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00419 
00420       EEDetId id = hitItr->id();
00421 
00422       int ix = id.ix();
00423       int iy = id.iy();
00424 
00425       int ism = Numbers::iSM( id );
00426 
00427       if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
00428 
00429       float xix = ix - 0.5;
00430       float xiy = iy - 0.5;
00431 
00432       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00433                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00434 
00435       MonitorElement* meAmplMap = 0;
00436 
00437       if ( mgpaGain[ism-1] == 3 ) meAmplMap = meAmplMapG01_[ism-1];
00438       if ( mgpaGain[ism-1] == 2 ) meAmplMap = meAmplMapG06_[ism-1];
00439       if ( mgpaGain[ism-1] == 1 ) meAmplMap = meAmplMapG12_[ism-1];
00440 
00441       float xval = hitItr->amplitude();
00442       if ( xval <= 0. ) xval = 0.0;
00443 
00444 //      if ( mgpaGain[ism-1] == 3 ) xval = xval * 1./12.;
00445 //      if ( mgpaGain[ism-1] == 2 ) xval = xval * 1./ 2.;
00446 //      if ( mgpaGain[ism-1] == 1 ) xval = xval * 1./ 1.;
00447 
00448       if ( meAmplMap ) meAmplMap->Fill(xix, xiy, xval);
00449 
00450     }
00451 
00452   } else {
00453 
00454     edm::LogWarning("EETestPulseTask") << EcalUncalibratedRecHitCollection_ << " not available";
00455 
00456   }
00457 
00458   edm::Handle<EcalPnDiodeDigiCollection> pns;
00459 
00460   if ( e.getByLabel(EcalPnDiodeDigiCollection_, pns) ) {
00461 
00462     int nep = pns->size();
00463     LogDebug("EETestPulseTask") << "event " << ievt_ << " pns collection size " << nep;
00464 
00465     for ( EcalPnDiodeDigiCollection::const_iterator pnItr = pns->begin(); pnItr != pns->end(); ++pnItr ) {
00466 
00467       if ( Numbers::subDet( pnItr->id() ) != EcalEndcap ) continue;
00468 
00469       int ism = Numbers::iSM( pnItr->id() );
00470 
00471       int num = pnItr->id().iPnId();
00472 
00473       if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00474                runType[ism-1] == EcalDCCHeaderBlock::TESTPULSE_GAP ) ) continue;
00475 
00476       float xvalped = 0.;
00477 
00478       for (int i = 0; i < 4; i++) {
00479 
00480         int adc = pnItr->sample(i).adc();
00481 
00482         MonitorElement* mePNPed = 0;
00483 
00484         if ( pnItr->sample(i).gainId() == 0 ) mePNPed = mePnPedMapG01_[ism-1];
00485         if ( pnItr->sample(i).gainId() == 1 ) mePNPed = mePnPedMapG16_[ism-1];
00486 
00487         float xval = float(adc);
00488 
00489         if ( mePNPed ) mePNPed->Fill(num - 0.5, xval);
00490 
00491         xvalped = xvalped + xval;
00492 
00493       }
00494 
00495       xvalped = xvalped / 4;
00496 
00497       float xvalmax = 0.;
00498 
00499       MonitorElement* mePN = 0;
00500 
00501       for (int i = 0; i < 50; i++) {
00502 
00503         int adc = pnItr->sample(i).adc();
00504 
00505         float xval = float(adc);
00506 
00507         if ( xval >= xvalmax ) xvalmax = xval;
00508 
00509       }
00510 
00511       xvalmax = xvalmax - xvalped;
00512 
00513       if ( pnItr->sample(0).gainId() == 0 ) mePN = mePnAmplMapG01_[ism-1];
00514       if ( pnItr->sample(0).gainId() == 1 ) mePN = mePnAmplMapG16_[ism-1];
00515 
00516       if ( mePN ) mePN->Fill(num - 0.5, xvalmax);
00517 
00518     }
00519 
00520   } else {
00521 
00522     edm::LogWarning("EETestPulseTask") << EcalPnDiodeDigiCollection_ << " not available";
00523 
00524   }
00525 
00526 }
00527