Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-29 02:41:38

0001 
0002 /*
0003  * \file EcalDigiStudy.h
0004  *
0005  * \author Sunanda Banerjee
0006  *
0007 */
0008 
0009 #include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
0010 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0011 
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 #include "FWCore/ServiceRegistry/interface/Service.h"
0022 #include "FWCore/Utilities/interface/EDGetToken.h"
0023 #include "FWCore/Utilities/interface/InputTag.h"
0024 
0025 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0026 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0027 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0028 
0029 #include <iostream>
0030 #include <fstream>
0031 #include <vector>
0032 #include <map>
0033 
0034 #include "TH2D.h"
0035 #include "TH1D.h"
0036 
0037 //#define EDM_ML_DEBUG
0038 
0039 class EcalDigiStudy : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
0040 public:
0041   EcalDigiStudy(const edm::ParameterSet& ps);
0042   ~EcalDigiStudy() override = default;
0043 
0044   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0045 
0046 protected:
0047   void beginJob() override {}
0048   void endJob() override {}
0049   void beginRun(edm::Run const&, edm::EventSetup const&) override;
0050   void endRun(edm::Run const&, edm::EventSetup const&) override {}
0051   void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0052   void checkCalibrations(edm::EventSetup const& c);
0053 
0054 private:
0055   bool verbose_;
0056 
0057   std::string outputFile_;
0058 
0059   edm::EDGetTokenT<EBDigiCollection> EBdigiCollection_;
0060   edm::EDGetTokenT<EEDigiCollection> EEdigiCollection_;
0061   edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;
0062   std::map<int, double, std::less<int> > gainConv_;
0063 
0064   double barrelADCtoGeV_;
0065   double endcapADCtoGeV_;
0066 
0067   TH2D* meEBDigiOccupancy_;
0068   TH1D* meEBDigiMultiplicity_;
0069   TH1D* meEBDigiADCAnalog_[10];
0070   TH1D* meEBDigiADCgS_[10];
0071   TH1D* meEBDigiADCg1_[10];
0072   TH1D* meEBDigiADCg6_[10];
0073   TH1D* meEBDigiADCg12_[10];
0074   TH1D* meEBDigiGain_[10];
0075   TH1D* meEBPedestal_;
0076   TH1D* meEBMaximumgt100ADC_;
0077   TH1D* meEBMaximumgt10ADC_;
0078   TH1D* meEBnADCafterSwitch_;
0079 
0080   TH2D* meEEDigiOccupancyzp_;
0081   TH2D* meEEDigiOccupancyzm_;
0082   TH1D* meEEDigiMultiplicityzp_;
0083   TH1D* meEEDigiMultiplicityzm_;
0084   TH1D* meEEDigiADCAnalog_[10];
0085   TH1D* meEEDigiADCgS_[10];
0086   TH1D* meEEDigiADCg1_[10];
0087   TH1D* meEEDigiADCg6_[10];
0088   TH1D* meEEDigiADCg12_[10];
0089   TH1D* meEEDigiGain_[10];
0090   TH1D* meEEPedestal_;
0091   TH1D* meEEMaximumgt100ADC_;
0092   TH1D* meEEMaximumgt20ADC_;
0093   TH1D* meEEnADCafterSwitch_;
0094 };
0095 
0096 EcalDigiStudy::EcalDigiStudy(const edm::ParameterSet& ps)
0097     : EBdigiCollection_(consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"))),
0098       EEdigiCollection_(consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"))),
0099       pAgc(esConsumes<edm::Transition::BeginRun>()) {
0100   usesResource(TFileService::kSharedResource);
0101   // verbosity switch
0102   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0103 
0104   // get hold of back-end interface
0105 
0106   gainConv_[1] = 1.;
0107   gainConv_[2] = 2.;
0108   gainConv_[3] = 12.;
0109   gainConv_[0] = 12.;  // saturated channels
0110   barrelADCtoGeV_ = 0.035;
0111   endcapADCtoGeV_ = 0.06;
0112 }
0113 
0114 void EcalDigiStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0115   edm::ParameterSetDescription desc;
0116   desc.add<edm::InputTag>("EBdigiCollection", edm::InputTag("simEcalDigis", "ebDigis"));
0117   desc.add<edm::InputTag>("EEdigiCollection", edm::InputTag("simEcalDigis", "eeDigis"));
0118   desc.addUntracked<bool>("verbose", "false");
0119   descriptions.add("ecalDigiStudy", desc);
0120 }
0121 
0122 void EcalDigiStudy::beginRun(const edm::Run&, const edm::EventSetup& es) {
0123   checkCalibrations(es);
0124 
0125   edm::Service<TFileService> fs;
0126   Char_t histo[200];
0127 
0128   // ECAL Barrel
0129   sprintf(histo, "EcalDigiTask Barrel occupancy");
0130   meEBDigiOccupancy_ = fs->make<TH2D>(histo, histo, 360, 0., 360., 170, -85., 85.);
0131   sprintf(histo, "EcalDigiTask Barrel digis multiplicity");
0132   meEBDigiMultiplicity_ = fs->make<TH1D>(histo, histo, 612, 0., 61200);
0133   sprintf(histo, "EcalDigiTask Barrel global pulse shape");
0134   for (int i = 0; i < 10; i++) {
0135     sprintf(histo, "EcalDigiTask Barrel analog pulse %02d", i + 1);
0136     meEBDigiADCAnalog_[i] = fs->make<TH1D>(histo, histo, 4000, 0., 400.);
0137     sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 0 - Saturated", i + 1);
0138     meEBDigiADCgS_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0139     sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 1", i + 1);
0140     meEBDigiADCg1_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0141     sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 6", i + 1);
0142     meEBDigiADCg6_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0143     sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 12", i + 1);
0144     meEBDigiADCg12_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0145     sprintf(histo, "EcalDigiTask Barrel gain pulse %02d", i + 1);
0146     meEBDigiGain_[i] = fs->make<TH1D>(histo, histo, 4, 0, 4);
0147   }
0148   sprintf(histo, "EcalDigiTask Barrel pedestal for pre-sample");
0149   meEBPedestal_ = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0150   sprintf(histo, "EcalDigiTask Barrel maximum position gt 100 ADC");
0151   meEBMaximumgt100ADC_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0152   sprintf(histo, "EcalDigiTask Barrel maximum position gt 10 ADC");
0153   meEBMaximumgt10ADC_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0154   sprintf(histo, "EcalDigiTask Barrel ADC counts after gain switch");
0155   meEBnADCafterSwitch_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0156 
0157   //ECAL Endcap
0158   sprintf(histo, "EcalDigiTask Endcap occupancy z+");
0159   meEEDigiOccupancyzp_ = fs->make<TH2D>(histo, histo, 100, 0., 100., 100, 0., 100.);
0160   sprintf(histo, "EcalDigiTask Endcap occupancy z-");
0161   meEEDigiOccupancyzm_ = fs->make<TH2D>(histo, histo, 100, 0., 100., 100, 0., 100.);
0162   sprintf(histo, "EcalDigiTask Endcap multiplicity z+");
0163   meEEDigiMultiplicityzp_ = fs->make<TH1D>(histo, histo, 100, 0., 7324.);
0164   sprintf(histo, "EcalDigiTask Endcap multiplicity z-");
0165   meEEDigiMultiplicityzm_ = fs->make<TH1D>(histo, histo, 100, 0., 7324.);
0166   sprintf(histo, "EcalDigiTask Endcap global pulse shape");
0167   for (int i = 0; i < 10; i++) {
0168     sprintf(histo, "EcalDigiTask Endcap analog pulse %02d", i + 1);
0169     meEEDigiADCAnalog_[i] = fs->make<TH1D>(histo, histo, 4000, 0., 400.);
0170     sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 0 - Saturated", i + 1);
0171     meEEDigiADCgS_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0172     sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 1", i + 1);
0173     meEEDigiADCg1_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0174     sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 6", i + 1);
0175     meEEDigiADCg6_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0176     sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 12", i + 1);
0177     meEEDigiADCg12_[i] = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0178     sprintf(histo, "EcalDigiTask Endcap gain pulse %02d", i + 1);
0179     meEEDigiGain_[i] = fs->make<TH1D>(histo, histo, 4, 0, 4);
0180   }
0181   sprintf(histo, "EcalDigiTask Endcap pedestal for pre-sample");
0182   meEEPedestal_ = fs->make<TH1D>(histo, histo, 4096, -0.5, 4095.5);
0183   sprintf(histo, "EcalDigiTask Endcap maximum position gt 100 ADC");
0184   meEEMaximumgt100ADC_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0185   sprintf(histo, "EcalDigiTask Endcap maximum position gt 20 ADC");
0186   meEEMaximumgt20ADC_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0187   sprintf(histo, "EcalDigiTask Endcap ADC counts after gain switch");
0188   meEEnADCafterSwitch_ = fs->make<TH1D>(histo, histo, 10, 0., 10.);
0189 }
0190 
0191 void EcalDigiStudy::analyze(edm::Event const& e, edm::EventSetup const& c) {
0192 #ifdef EDM_ML_DEBUG
0193   edm::LogVerbatim("EcalDigiStudy") << " Run = " << e.id().run() << " Event = " << e.id().event();
0194 #endif
0195 
0196   edm::Handle<EBDigiCollection> EcalDigiEB;
0197   e.getByToken(EBdigiCollection_, EcalDigiEB);
0198 #ifdef EDM_ML_DEBUG
0199   edm::LogVerbatim("EcalDigiStudy") << " EB collection " << EcalDigiEB.isValid();
0200 #endif
0201 
0202   if (EcalDigiEB.isValid()) {
0203     // BARREL: Loop over Digis
0204 
0205     const EBDigiCollection* barrelDigi = EcalDigiEB.product();
0206 #ifdef EDM_ML_DEBUG
0207     edm::LogVerbatim("EcalDigiStudy") << " EB Digi size " << EcalDigiEB->size();
0208 #endif
0209 
0210     std::vector<double> ebAnalogSignal, ebADCCounts, ebADCGains;
0211     ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
0212     ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
0213     ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
0214 
0215     int nDigis(0);
0216     for (unsigned int digis = 0; digis < EcalDigiEB->size(); ++digis) {
0217       EBDataFrame ebdf = (*barrelDigi)[digis];
0218       int nrSamples = ebdf.size();
0219       EBDetId ebid = ebdf.id();
0220 
0221       nDigis++;
0222       meEBDigiOccupancy_->Fill(ebid.iphi(), ebid.ieta());
0223       double Emax(0.);
0224       int Pmax(0);
0225       double pedestalPreSample(0.), pedestalPreSampleAnalog(0.);
0226       int countsAfterGainSwitch = -1;
0227       double higherGain = 1.;
0228       int higherGainSample = 0;
0229 
0230       for (int sample = 0; sample < nrSamples; ++sample) {
0231         ebAnalogSignal[sample] = 0.;
0232         ebADCCounts[sample] = 0.;
0233         ebADCGains[sample] = 0.;
0234       }
0235 
0236       for (int sample = 0; sample < nrSamples; ++sample) {
0237         EcalMGPASample thisSample = ebdf[sample];
0238 
0239         ebADCCounts[sample] = (thisSample.adc());
0240         ebADCGains[sample] = (thisSample.gainId());
0241         ebAnalogSignal[sample] = (ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_);
0242 
0243         if (Emax < ebAnalogSignal[sample]) {
0244           Emax = ebAnalogSignal[sample];
0245           Pmax = sample;
0246         }
0247 
0248         if (sample < 3) {
0249           pedestalPreSample += ebADCCounts[sample];
0250           pedestalPreSampleAnalog += ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_;
0251         }
0252 
0253         if (sample > 0 && (((ebADCGains[sample] > ebADCGains[sample - 1]) && (ebADCGains[sample - 1] != 0)) ||
0254                            (countsAfterGainSwitch < 0 && ebADCGains[sample] == 0))) {
0255           higherGain = ebADCGains[sample];
0256           higherGainSample = sample;
0257           countsAfterGainSwitch = 1;
0258         }
0259 
0260         if ((higherGain > 1 && (higherGainSample != sample) && (ebADCGains[sample] == higherGain)) ||
0261             (higherGain == 3 && (higherGainSample != sample) && (ebADCGains[sample] == 0)) ||
0262             (higherGain == 0 && (higherGainSample != sample) &&
0263              ((ebADCGains[sample] == 3) || (ebADCGains[sample] == 0)))) {
0264           countsAfterGainSwitch++;
0265         }
0266       }
0267 
0268       pedestalPreSample /= 3.;
0269       pedestalPreSampleAnalog /= 3.;
0270 
0271 #ifdef EDM_ML_DEBUG
0272       if (verbose_) {
0273         edm::LogVerbatim("EcalDigiStudy")
0274             << "Barrel Digi for EBDetId = " << ebid.rawId() << " eta,phi " << ebid.ieta() << " " << ebid.iphi();
0275         for (int i = 0; i < 10; i++)
0276           edm::LogVerbatim("EcalDigiSTudy") << "sample " << i << " ADC = " << ebADCCounts[i]
0277                                             << " gain = " << ebADCGains[i] << " Analog = " << ebAnalogSignal[i];
0278         edm::LogVerbatim("EcalDigiStudy") << "Maximum energy = " << Emax << " in sample " << Pmax
0279                                           << " Pedestal from pre-sample = " << pedestalPreSampleAnalog;
0280         if (countsAfterGainSwitch > 0)
0281           edm::LogVerbatim("EcalDigiStudy") << "Counts after switch " << countsAfterGainSwitch;
0282       }
0283 #endif
0284       if (countsAfterGainSwitch > 0 && countsAfterGainSwitch < 5) {
0285         edm::LogWarning("EcalDigiStudy") << "Wrong number of counts after gain switch before next switch! "
0286                                          << countsAfterGainSwitch;
0287         for (int i = 0; i < 10; i++)
0288           edm::LogWarning("EcalDigiStudy") << "sample " << i << " ADC = " << ebADCCounts[i]
0289                                            << " gain = " << ebADCGains[i] << " Analog = " << ebAnalogSignal[i];
0290       }
0291 
0292       for (int i = 0; i < 10; i++) {
0293         meEBDigiADCAnalog_[i]->Fill(ebAnalogSignal[i]);
0294 
0295         if (ebADCGains[i] == 0) {
0296           meEBDigiADCgS_[i]->Fill(ebADCCounts[i]);
0297         } else if (ebADCGains[i] == 3) {
0298           meEBDigiADCg1_[i]->Fill(ebADCCounts[i]);
0299         } else if (ebADCGains[i] == 2) {
0300           meEBDigiADCg6_[i]->Fill(ebADCCounts[i]);
0301         } else if (ebADCGains[i] == 1) {
0302           meEBDigiADCg12_[i]->Fill(ebADCCounts[i]);
0303         }
0304         meEBDigiGain_[i]->Fill(ebADCGains[i]);
0305       }
0306 
0307       meEBPedestal_->Fill(pedestalPreSample);
0308       if ((Emax - pedestalPreSampleAnalog * gainConv_[(int)ebADCGains[Pmax]]) > 10. * barrelADCtoGeV_)
0309         meEBMaximumgt10ADC_->Fill(Pmax);
0310       if ((Emax - pedestalPreSampleAnalog * gainConv_[(int)ebADCGains[Pmax]]) > 100. * barrelADCtoGeV_)
0311         meEBMaximumgt100ADC_->Fill(Pmax);
0312       meEBnADCafterSwitch_->Fill(countsAfterGainSwitch);
0313     }
0314     meEBDigiMultiplicity_->Fill(nDigis);
0315   }
0316 
0317   edm::Handle<EEDigiCollection> EcalDigiEE;
0318   e.getByToken(EEdigiCollection_, EcalDigiEE);
0319 #ifdef EDM_ML_DEBUG
0320   edm::LogVerbatim("EcalDigiStudy") << " EE collection " << EcalDigiEE.isValid();
0321 #endif
0322 
0323   if (EcalDigiEE.isValid()) {
0324     // ENDCAP: Loop over Digis
0325     const EEDigiCollection* endcapDigi = EcalDigiEE.product();
0326 #ifdef EDM_ML_DEBUG
0327     edm::LogVerbatim("EcalDigiStudy") << " EE Digi size " << EcalDigiEE->size();
0328 #endif
0329 
0330     std::vector<double> eeAnalogSignal, eeADCCounts, eeADCGains;
0331     eeAnalogSignal.reserve(EEDataFrame::MAXSAMPLES);
0332     eeADCCounts.reserve(EEDataFrame::MAXSAMPLES);
0333     eeADCGains.reserve(EEDataFrame::MAXSAMPLES);
0334 
0335     int nDigiszp(0), nDigiszm(0);
0336 
0337     for (unsigned int digis = 0; digis < EcalDigiEE->size(); ++digis) {
0338       EEDataFrame eedf = (*endcapDigi)[digis];
0339       int nrSamples = eedf.size();
0340 
0341       EEDetId eeid = eedf.id();
0342 
0343       if (eeid.zside() > 0) {
0344         meEEDigiOccupancyzp_->Fill(eeid.ix(), eeid.iy());
0345         nDigiszp++;
0346       } else if (eeid.zside() < 0) {
0347         meEEDigiOccupancyzm_->Fill(eeid.ix(), eeid.iy());
0348         nDigiszm++;
0349       }
0350 
0351       double Emax(0.);
0352       int Pmax(0);
0353       double pedestalPreSample(0.), pedestalPreSampleAnalog(0.);
0354       int countsAfterGainSwitch(-1);
0355       double higherGain(1.);
0356       int higherGainSample(0);
0357 
0358       for (int sample = 0; sample < nrSamples; ++sample) {
0359         eeAnalogSignal[sample] = 0.;
0360         eeADCCounts[sample] = 0.;
0361         eeADCGains[sample] = 0.;
0362       }
0363 
0364       for (int sample = 0; sample < nrSamples; ++sample) {
0365         EcalMGPASample mySample = eedf[sample];
0366 
0367         eeADCCounts[sample] = (mySample.adc());
0368         eeADCGains[sample] = (mySample.gainId());
0369         eeAnalogSignal[sample] = (eeADCCounts[sample] * gainConv_[(int)eeADCGains[sample]] * endcapADCtoGeV_);
0370 
0371         if (Emax < eeAnalogSignal[sample]) {
0372           Emax = eeAnalogSignal[sample];
0373           Pmax = sample;
0374         }
0375 
0376         if (sample < 3) {
0377           pedestalPreSample += eeADCCounts[sample];
0378           pedestalPreSampleAnalog += eeADCCounts[sample] * gainConv_[(int)eeADCGains[sample]] * endcapADCtoGeV_;
0379         }
0380 
0381         if (sample > 0 && (((eeADCGains[sample] > eeADCGains[sample - 1]) && (eeADCGains[sample - 1] != 0)) ||
0382                            (countsAfterGainSwitch < 0 && eeADCGains[sample] == 0))) {
0383           higherGain = eeADCGains[sample];
0384           higherGainSample = sample;
0385           countsAfterGainSwitch = 1;
0386         }
0387 
0388         if ((higherGain > 1 && (higherGainSample != sample) && (eeADCGains[sample] == higherGain)) ||
0389             (higherGain == 3 && (higherGainSample != sample) && (eeADCGains[sample] == 0)) ||
0390             (higherGain == 0 && (higherGainSample != sample) &&
0391              ((eeADCGains[sample] == 0) || (eeADCGains[sample] == 3))))
0392           countsAfterGainSwitch++;
0393       }
0394       pedestalPreSample /= 3.;
0395       pedestalPreSampleAnalog /= 3.;
0396 
0397 #ifdef EDM_ML_DEBUG
0398       edm::LogVerbatim("EcalDigiStudy") << "Endcap Digi for EEDetId = " << eeid.rawId() << " x,y " << eeid.ix() << " "
0399                                         << eeid.iy();
0400       for (int i = 0; i < 10; i++)
0401         edm::LogVerbatim("EcalDigiStudy") << "sample " << i << " ADC = " << eeADCCounts[i]
0402                                           << " gain = " << eeADCGains[i] << " Analog = " << eeAnalogSignal[i];
0403       edm::LogVerbatim("EcalDigiStudy") << "Maximum energy = " << Emax << " in sample " << Pmax
0404                                         << " Pedestal from pre-sample = " << pedestalPreSampleAnalog;
0405       if (countsAfterGainSwitch > 0)
0406         edm::LogVerbatim("EcalDigiStudy") << "Counts after switch " << countsAfterGainSwitch;
0407 #endif
0408       if (countsAfterGainSwitch > 0 && countsAfterGainSwitch < 5) {
0409         edm::LogWarning("EcalDigiStudy") << "Wrong number of counts after gain switch before next switch! "
0410                                          << countsAfterGainSwitch;
0411         for (int i = 0; i < 10; i++)
0412           edm::LogWarning("EcalDigiStudy") << "sample " << i << " ADC = " << eeADCCounts[i]
0413                                            << " gain = " << eeADCGains[i] << " Analog = " << eeAnalogSignal[i];
0414       }
0415 
0416       for (int i = 0; i < 10; i++) {
0417         meEEDigiADCAnalog_[i]->Fill(eeAnalogSignal[i]);
0418         if (eeADCGains[i] == 0) {
0419           meEEDigiADCgS_[i]->Fill(eeADCCounts[i]);
0420         } else if (eeADCGains[i] == 3) {
0421           meEEDigiADCg1_[i]->Fill(eeADCCounts[i]);
0422         } else if (eeADCGains[i] == 2) {
0423           meEEDigiADCg6_[i]->Fill(eeADCCounts[i]);
0424         } else if (eeADCGains[i] == 1) {
0425           meEEDigiADCg12_[i]->Fill(eeADCCounts[i]);
0426         }
0427         meEEDigiGain_[i]->Fill(eeADCGains[i]);
0428       }
0429 
0430       meEEPedestal_->Fill(pedestalPreSample);
0431       if ((Emax - pedestalPreSampleAnalog * gainConv_[(int)eeADCGains[Pmax]]) > 20. * endcapADCtoGeV_)
0432         meEEMaximumgt20ADC_->Fill(Pmax);
0433       if ((Emax - pedestalPreSampleAnalog * gainConv_[(int)eeADCGains[Pmax]]) > 100. * endcapADCtoGeV_)
0434         meEEMaximumgt100ADC_->Fill(Pmax);
0435       meEEnADCafterSwitch_->Fill(countsAfterGainSwitch);
0436     }
0437 
0438     meEEDigiMultiplicityzp_->Fill(nDigiszp);
0439     meEEDigiMultiplicityzm_->Fill(nDigiszm);
0440   }
0441 }
0442 
0443 void EcalDigiStudy::checkCalibrations(edm::EventSetup const& eventSetup) {
0444   // ADC -> GeV Scale
0445 
0446   const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);
0447   EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();
0448 
0449   gainConv_[1] = 1.;
0450   gainConv_[2] = defaultRatios->gain12Over6();
0451   gainConv_[3] = gainConv_[2] * (defaultRatios->gain6Over1());
0452   gainConv_[0] = gainConv_[2] * (defaultRatios->gain6Over1());
0453 
0454   edm::LogVerbatim("EcalDigiStudy") << " Gains conversions: "
0455                                     << "\n"
0456                                     << " g0 = " << gainConv_[0] << "\n"
0457                                     << " g1 = " << gainConv_[1] << "\n"
0458                                     << " g2 = " << gainConv_[2] << "\n"
0459                                     << " g3 = " << gainConv_[3];
0460 
0461   delete defaultRatios;
0462 
0463   edm::LogVerbatim("EcalDigiStudy") << " Barrel GeV/ADC = " << agc->getEBValue();
0464   edm::LogVerbatim("EcalDigiStudy") << " Endcap GeV/ADC = " << agc->getEEValue();
0465 }
0466 
0467 //define this as a plug-in
0468 DEFINE_FWK_MODULE(EcalDigiStudy);