Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:03

0001 /*
0002  * \file EcalPreshowerDigisValidation.cc
0003  *
0004  * \author F. Cossutti
0005  *
0006 */
0007 
0008 #include "EcalPreshowerDigisValidation.h"
0009 
0010 EcalPreshowerDigisValidation::EcalPreshowerDigisValidation(const edm::ParameterSet& ps)
0011     : ESdigiCollectionToken_(consumes<ESDigiCollection>(ps.getParameter<edm::InputTag>("ESdigiCollection"))) {
0012   // verbosity switch
0013   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0014 
0015   meESDigiMultiplicity_ = nullptr;
0016 
0017   for (int i = 0; i < 3; i++) {
0018     meESDigiADC_[i] = nullptr;
0019   }
0020 }
0021 
0022 void EcalPreshowerDigisValidation::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0023   Char_t histo[200];
0024 
0025   ibooker.setCurrentFolder("EcalDigisV/EcalDigiTask");
0026 
0027   sprintf(histo, "EcalDigiTask Preshower digis multiplicity");
0028   meESDigiMultiplicity_ = ibooker.book1D(histo, histo, 1000, 0., 137728);
0029 
0030   for (int i = 0; i < 3; i++) {
0031     sprintf(histo, "EcalDigiTask Preshower ADC pulse %02d", i + 1);
0032     meESDigiADC_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
0033   }
0034 }
0035 
0036 void EcalPreshowerDigisValidation::analyze(const edm::Event& e, const edm::EventSetup& c) {
0037   //LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
0038 
0039   edm::Handle<ESDigiCollection> EcalDigiES;
0040 
0041   e.getByToken(ESdigiCollectionToken_, EcalDigiES);
0042 
0043   // Return if no preshower data
0044   if (!EcalDigiES.isValid())
0045     return;
0046 
0047   // PRESHOWER
0048 
0049   // loop over Digis
0050 
0051   const ESDigiCollection* preshowerDigi = EcalDigiES.product();
0052 
0053   std::vector<double> esADCCounts;
0054   esADCCounts.reserve(ESDataFrame::MAXSAMPLES);
0055 
0056   int nDigis = 0;
0057 
0058   for (unsigned int digis = 0; digis < EcalDigiES->size(); ++digis) {
0059     ESDataFrame esdf = (*preshowerDigi)[digis];
0060     int nrSamples = esdf.size();
0061 
0062     ESDetId esid = esdf.id();
0063 
0064     nDigis++;
0065 
0066     for (int sample = 0; sample < nrSamples; ++sample) {
0067       esADCCounts[sample] = 0.;
0068     }
0069 
0070     for (int sample = 0; sample < nrSamples; ++sample) {
0071       ESSample mySample = esdf[sample];
0072       esADCCounts[sample] = (mySample.adc());
0073     }
0074     if (verbose_) {
0075       LogDebug("DigiInfo") << "Preshower Digi for ESDetId: z side " << esid.zside() << "  plane " << esid.plane()
0076                            << esid.six() << ',' << esid.siy() << ':' << esid.strip();
0077       for (int i = 0; i < 3; i++) {
0078         LogDebug("DigiInfo") << "sample " << i << " ADC = " << esADCCounts[i];
0079       }
0080     }
0081 
0082     for (int i = 0; i < 3; i++) {
0083       if (meESDigiADC_[i])
0084         meESDigiADC_[i]->Fill(esADCCounts[i]);
0085     }
0086   }
0087 
0088   if (meESDigiMultiplicity_)
0089     meESDigiMultiplicity_->Fill(nDigis);
0090 }