Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:17

0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Validation/MuonCSCDigis/interface/CSCALCTDigiValidation.h"
0004 
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0007 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0008 
0009 CSCALCTDigiValidation::CSCALCTDigiValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
0010     : CSCBaseValidation(ps),
0011       theNDigisPerChamberPlots(),
0012       chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0013       // variables
0014       alctVars_(ps.getParameter<std::vector<std::string>>("alctVars")),
0015       // binning
0016       alctNBin_(ps.getParameter<std::vector<unsigned>>("alctNBin")),
0017       alctMinBin_(ps.getParameter<std::vector<double>>("alctMinBin")),
0018       alctMaxBin_(ps.getParameter<std::vector<double>>("alctMaxBin")) {
0019   const auto &pset = ps.getParameterSet("cscALCT");
0020   inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0021   alcts_Token_ = iC.consumes<CSCALCTDigiCollection>(inputTag_);
0022 }
0023 
0024 CSCALCTDigiValidation::~CSCALCTDigiValidation() {}
0025 
0026 void CSCALCTDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0027   iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/ALCT/Occupancy/");
0028 
0029   theNDigisPerEventPlot = iBooker.book1D(
0030       "CSCALCTDigisPerEvent", "ALCT trigger primitives per event; Number of ALCTs; Entries", 100, 0, 100);
0031   for (int i = 1; i <= 10; ++i) {
0032     const std::string t2("CSCALCTDigisPerChamber_" + CSCDetId::chamberName(i));
0033     theNDigisPerChamberPlots[i - 1] = iBooker.book1D(
0034         t2, "Number of ALCTs per chamber " + CSCDetId::chamberName(i) + ";Number of ALCTs per chamber;Entries", 4, 0, 4);
0035   }
0036 
0037   // chamber type
0038   for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0039     // consider CSC+ and CSC- separately
0040     for (unsigned iEndcap = 0; iEndcap < 2; iEndcap++) {
0041       const std::string eSign(iEndcap == 0 ? "+" : "-");
0042       // alct variable
0043       for (unsigned iVar = 0; iVar < alctVars_.size(); iVar++) {
0044         const std::string key("alct_" + alctVars_[iVar]);
0045         const std::string histName(key + "_" + chambers_[iType] + eSign);
0046         const std::string histTitle(chambers_[iType] + eSign + " ALCT " + alctVars_[iVar]);
0047         const unsigned iTypeCorrected(iEndcap == 0 ? iType : iType + chambers_.size());
0048         chamberHistos[iTypeCorrected][key] =
0049             iBooker.book1D(histName, histTitle, alctNBin_[iVar], alctMinBin_[iVar], alctMaxBin_[iVar]);
0050         chamberHistos[iTypeCorrected][key]->getTH1()->SetMinimum(0);
0051       }
0052     }
0053   }
0054 }
0055 
0056 void CSCALCTDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0057   edm::Handle<CSCALCTDigiCollection> alcts;
0058   e.getByToken(alcts_Token_, alcts);
0059   if (!alcts.isValid()) {
0060     edm::LogError("CSCALCTDigiValidation") << "Cannot get ALCTs by label " << inputTag_.encode();
0061   }
0062   unsigned nDigisPerEvent = 0;
0063 
0064   for (auto j = alcts->begin(); j != alcts->end(); j++) {
0065     auto beginDigi = (*j).second.first;
0066     auto endDigi = (*j).second.second;
0067     const CSCDetId &detId((*j).first);
0068     int chamberType = detId.iChamberType();
0069     int nDigis = endDigi - beginDigi;
0070     nDigisPerEvent += nDigis;
0071     theNDigisPerChamberPlots[chamberType - 1]->Fill(nDigis);
0072 
0073     auto range = alcts->get((*j).first);
0074     // 1=forward (+Z); 2=backward (-Z)
0075     const unsigned typeCorrected(detId.endcap() == 1 ? chamberType - 2 : chamberType - 2 + chambers_.size());
0076     for (auto alct = range.first; alct != range.second; alct++) {
0077       if (alct->isValid()) {
0078         chamberHistos[typeCorrected]["alct_quality"]->Fill(alct->getQuality());
0079         chamberHistos[typeCorrected]["alct_wiregroup"]->Fill(alct->getKeyWG());
0080         chamberHistos[typeCorrected]["alct_bx"]->Fill(alct->getBX());
0081       }
0082     }
0083   }
0084   theNDigisPerEventPlot->Fill(nDigisPerEvent);
0085 }