Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMServices/Core/interface/DQMStore.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "Validation/MuonCSCDigis/interface/CSCStripDigiValidation.h"
0005 
0006 CSCStripDigiValidation::CSCStripDigiValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
0007     : CSCBaseValidation(ps),
0008       thePedestalSum(0),
0009       thePedestalCovarianceSum(0),
0010       thePedestalCount(0),
0011       thePedestalTimeCorrelationPlot(nullptr),
0012       thePedestalNeighborCorrelationPlot(nullptr),
0013       theNDigisPerChamberPlot(nullptr) {
0014   const auto &pset = ps.getParameterSet("cscStripDigi");
0015   inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0016   strips_Token_ = iC.consumes<CSCStripDigiCollection>(inputTag_);
0017 }
0018 
0019 CSCStripDigiValidation::~CSCStripDigiValidation() {}
0020 
0021 void CSCStripDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0022   iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/Strip/Occupancy");
0023 
0024   thePedestalPlot = iBooker.book1D("CSCPedestal", "CSC Pedestal;ADC Counts;Entries", 400, 550, 650);
0025   theAmplitudePlot = iBooker.book1D("CSCStripAmplitude", "CSC Strip Amplitude;Strip Amplitude;Entries", 200, 0, 2000);
0026   theRatio4to5Plot = iBooker.book1D("CSCStrip4to5", "CSC Strip Ratio tbin 4 to tbin 5;Strip Ratio;Entries", 100, 0, 1);
0027   theRatio6to5Plot =
0028       iBooker.book1D("CSCStrip6to5", "CSC Strip Ratio tbin 6 to tbin 5;Strip Ratio;Entries", 120, 0, 1.2);
0029   theNDigisPerLayerPlot =
0030       iBooker.book1D("CSCStripDigisPerLayer",
0031                      "Number of CSC Strip Digis per layer;Number of CSC Strip Digis per layer;Entries",
0032                      48,
0033                      0,
0034                      48);
0035   theNDigisPerEventPlot =
0036       iBooker.book1D("CSCStripDigisPerEvent",
0037                      "Number of CSC Strip Digis per event;Number of CSC Strip Digis per event;Entries",
0038                      100,
0039                      0,
0040                      500);
0041 }
0042 
0043 void CSCStripDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0044   edm::Handle<CSCStripDigiCollection> strips;
0045   e.getByToken(strips_Token_, strips);
0046   if (!strips.isValid()) {
0047     edm::LogError("CSCStripDigiValidation") << "Cannot get strips by label " << inputTag_.encode();
0048   }
0049 
0050   unsigned nDigisPerEvent = 0;
0051 
0052   for (auto j = strips->begin(); j != strips->end(); j++) {
0053     auto digiItr = (*j).second.first;
0054     auto last = (*j).second.second;
0055 
0056     int nDigis = last - digiItr;
0057     nDigisPerEvent += nDigis;
0058     theNDigisPerLayerPlot->Fill(nDigis);
0059 
0060     double maxAmplitude = 0.;
0061 
0062     for (; digiItr != last; ++digiItr) {
0063       // average up the pedestals
0064       std::vector<int> adcCounts = digiItr->getADCCounts();
0065       thePedestalSum += adcCounts[0];
0066       thePedestalSum += adcCounts[1];
0067       thePedestalCount += 2;
0068       float pedestal = thePedestalSum / thePedestalCount;
0069       if (adcCounts[4] - pedestal > maxAmplitude) {
0070         maxAmplitude = adcCounts[4] - pedestal;
0071       }
0072 
0073       // if we have enough pedestal statistics
0074       if (thePedestalCount > 100) {
0075         fillPedestalPlots(*digiItr);
0076 
0077         // see if it's big enough to count as "signal"
0078         if (adcCounts[5] > (thePedestalSum / thePedestalCount + 100)) {
0079           fillSignalPlots(*digiItr);
0080         }
0081       }
0082     }
0083   }  // loop over digis
0084 
0085   theNDigisPerEventPlot->Fill(nDigisPerEvent);
0086 }
0087 
0088 void CSCStripDigiValidation::fillPedestalPlots(const CSCStripDigi &digi) {
0089   std::vector<int> adcCounts = digi.getADCCounts();
0090   thePedestalPlot->Fill(adcCounts[0]);
0091   thePedestalPlot->Fill(adcCounts[1]);
0092 }
0093 
0094 void CSCStripDigiValidation::fillSignalPlots(const CSCStripDigi &digi) {
0095   std::vector<int> adcCounts = digi.getADCCounts();
0096   float pedestal = thePedestalSum / thePedestalCount;
0097   theAmplitudePlot->Fill(adcCounts[4] - pedestal);
0098   theRatio4to5Plot->Fill((adcCounts[3] - pedestal) / (adcCounts[4] - pedestal));
0099   theRatio6to5Plot->Fill((adcCounts[5] - pedestal) / (adcCounts[4] - pedestal));
0100 }