Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-20 02:15:13

0001 /*
0002  * \file EcalPreshowerNoiseDistrib.cc
0003  *
0004 */
0005 
0006 #include "EcalPreshowerNoiseDistrib.h"
0007 
0008 EcalPreshowerNoiseDistrib::EcalPreshowerNoiseDistrib(const edm::ParameterSet& ps)
0009     : ESdigiCollectionToken_(consumes<ESDigiCollection>(ps.getParameter<edm::InputTag>("ESdigiCollection"))) {
0010   // verbosity switch
0011   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0012 
0013   // histos
0014   meESDigiMultiplicity_ = nullptr;
0015   for (int ii = 0; ii < 3; ii++) {
0016     meESDigiADC_[ii] = nullptr;
0017   }
0018 }
0019 
0020 void EcalPreshowerNoiseDistrib::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0021   Char_t histo[200];
0022 
0023   sprintf(histo, "multiplicity");
0024   meESDigiMultiplicity_ = ibooker.book1D(histo, histo, 1000, 0., 137728);
0025 
0026   for (int ii = 0; ii < 3; ii++) {
0027     sprintf(histo, "esRefHistos%02d", ii);
0028     meESDigiADC_[ii] = ibooker.book1D(histo, histo, 35, 983.5, 1018.5);
0029   }
0030 
0031   for (int ii = 0; ii < 3; ii++) {
0032     sprintf(histo, "esRefHistosCorr%02d", ii);
0033     meESDigiCorr_[ii] = ibooker.book2D(histo, histo, 35, 983.5, 1018.5, 35, 983.5, 1018.5);
0034   }
0035 
0036   meESDigi3D_ = ibooker.book3D("meESDigi3D_", "meESDigi3D_", 35, 983.5, 1018.5, 35, 983.5, 1018.5, 35, 983.5, 1018.5);
0037 }
0038 
0039 void EcalPreshowerNoiseDistrib::analyze(const edm::Event& e, const edm::EventSetup& c) {
0040   edm::Handle<ESDigiCollection> EcalDigiES;
0041 
0042   e.getByToken(ESdigiCollectionToken_, EcalDigiES);
0043 
0044   // retrun if no data
0045   if (!EcalDigiES.isValid())
0046     return;
0047 
0048   // loop over Digis
0049   const ESDigiCollection* preshowerDigi = EcalDigiES.product();
0050 
0051   std::vector<double> esADCCounts;
0052   esADCCounts.reserve(ESDataFrame::MAXSAMPLES);
0053 
0054   int nDigis = 0;
0055 
0056   for (unsigned int digis = 0; digis < EcalDigiES->size(); ++digis) {
0057     nDigis++;
0058     ESDataFrame esdf = (*preshowerDigi)[digis];
0059     int nrSamples = esdf.size();
0060     for (int sample = 0; sample < nrSamples; ++sample) {
0061       ESSample mySample = esdf[sample];
0062       if (meESDigiADC_[sample]) {
0063         meESDigiADC_[sample]->Fill(mySample.adc());
0064       }
0065     }
0066 
0067     // to study correlations
0068     if (meESDigiCorr_[0]) {
0069       meESDigiCorr_[0]->Fill(esdf[0].adc(), esdf[1].adc());
0070     }
0071     if (meESDigiCorr_[1]) {
0072       meESDigiCorr_[1]->Fill(esdf[0].adc(), esdf[2].adc());
0073     }
0074     if (meESDigiCorr_[2]) {
0075       meESDigiCorr_[2]->Fill(esdf[1].adc(), esdf[2].adc());
0076     }
0077 
0078     // reference histo: sample0, sample1, sample2
0079     if (meESDigi3D_)
0080       meESDigi3D_->Fill(esdf[0].adc(), esdf[1].adc(), esdf[2].adc());
0081   }
0082 
0083   if (meESDigiMultiplicity_)
0084     meESDigiMultiplicity_->Fill(nDigis);
0085 }