File indexing completed on 2024-04-06 12:32:48
0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Validation/MuonCSCDigis/interface/CSCCLCTDigiValidation.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 CSCCLCTDigiValidation::CSCCLCTDigiValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
0010 : CSCBaseValidation(ps),
0011 theNDigisPerChamberPlots(),
0012 chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0013 chambersRun3_(ps.getParameter<std::vector<unsigned>>("chambersRun3")),
0014
0015 clctVars_(ps.getParameter<std::vector<std::string>>("clctVars")),
0016
0017 clctNBin_(ps.getParameter<std::vector<unsigned>>("clctNBin")),
0018 clctMinBin_(ps.getParameter<std::vector<double>>("clctMinBin")),
0019 clctMaxBin_(ps.getParameter<std::vector<double>>("clctMaxBin")),
0020 isRun3_(ps.getParameter<bool>("isRun3")) {
0021 const auto &pset = ps.getParameterSet("cscCLCT");
0022 inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0023 clcts_Token_ = iC.consumes<CSCCLCTDigiCollection>(inputTag_);
0024 }
0025
0026 CSCCLCTDigiValidation::~CSCCLCTDigiValidation() {}
0027
0028 void CSCCLCTDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0029 iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/CLCT/Occupancy/");
0030
0031 theNDigisPerEventPlot = iBooker.book1D(
0032 "CSCCLCTDigisPerEvent", "CLCT trigger primitives per event; Number of CLCTs; Entries", 100, 0, 100);
0033 for (int i = 1; i <= 10; ++i) {
0034 const std::string t2("CSCCLCTDigisPerChamber_" + CSCDetId::chamberName(i));
0035 theNDigisPerChamberPlots[i - 1] = iBooker.book1D(
0036 t2, "Number of CLCTs per chamber " + CSCDetId::chamberName(i) + ";Number of CLCTs per chamber;Entries", 4, 0, 4);
0037 }
0038
0039
0040 if (!isRun3_) {
0041 clctVars_.resize(5);
0042 }
0043
0044
0045 for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0046
0047 for (unsigned iEndcap = 0; iEndcap < 2; iEndcap++) {
0048 const std::string eSign(iEndcap == 0 ? "+" : "-");
0049
0050 for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
0051 if (std::find(chambersRun3_.begin(), chambersRun3_.end(), iType) == chambersRun3_.end()) {
0052 if (iVar > 4)
0053 continue;
0054 }
0055 const std::string key("clct_" + clctVars_[iVar]);
0056 const std::string histName(key + "_" + chambers_[iType] + eSign);
0057 const std::string histTitle(chambers_[iType] + eSign + " CLCT " + clctVars_[iVar]);
0058 const unsigned iTypeCorrected(iEndcap == 0 ? iType : iType + chambers_.size());
0059 chamberHistos[iTypeCorrected][key] =
0060 iBooker.book1D(histName, histTitle, clctNBin_[iVar], clctMinBin_[iVar], clctMaxBin_[iVar]);
0061 chamberHistos[iTypeCorrected][key]->getTH1()->SetMinimum(0);
0062 }
0063 }
0064 }
0065 }
0066
0067 void CSCCLCTDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0068 edm::Handle<CSCCLCTDigiCollection> clcts;
0069 e.getByToken(clcts_Token_, clcts);
0070 if (!clcts.isValid()) {
0071 edm::LogError("CSCDigiDump") << "Cannot get CLCTs by label " << inputTag_.encode();
0072 }
0073
0074 unsigned nDigisPerEvent = 0;
0075
0076 for (auto j = clcts->begin(); j != clcts->end(); j++) {
0077 auto beginDigi = (*j).second.first;
0078 auto endDigi = (*j).second.second;
0079 const CSCDetId &detId((*j).first);
0080 int chamberType = detId.iChamberType();
0081 int nDigis = endDigi - beginDigi;
0082 nDigisPerEvent += nDigis;
0083 theNDigisPerChamberPlots[chamberType - 1]->Fill(nDigis);
0084
0085 auto range = clcts->get((*j).first);
0086
0087 const unsigned typeCorrected(detId.endcap() == 1 ? chamberType - 2 : chamberType - 2 + chambers_.size());
0088 for (auto clct = range.first; clct != range.second; clct++) {
0089 if (clct->isValid()) {
0090 chamberHistos[typeCorrected]["clct_pattern"]->Fill(clct->getPattern());
0091 chamberHistos[typeCorrected]["clct_quality"]->Fill(clct->getQuality());
0092 chamberHistos[typeCorrected]["clct_halfstrip"]->Fill(clct->getKeyStrip());
0093 chamberHistos[typeCorrected]["clct_bend"]->Fill(clct->getBend());
0094 chamberHistos[typeCorrected]["clct_bx"]->Fill(clct->getBX());
0095 if (isRun3_) {
0096
0097 if (std::find(chambersRun3_.begin(), chambersRun3_.end(), chamberType - 2) == chambersRun3_.end())
0098 continue;
0099 chamberHistos[typeCorrected]["clct_run3pattern"]->Fill(clct->getRun3Pattern());
0100 chamberHistos[typeCorrected]["clct_quartstrip"]->Fill(clct->getKeyStrip(4));
0101 chamberHistos[typeCorrected]["clct_eighthstrip"]->Fill(clct->getKeyStrip(8));
0102 chamberHistos[typeCorrected]["clct_slope"]->Fill(clct->getSlope());
0103 chamberHistos[typeCorrected]["clct_compcode"]->Fill(clct->getCompCode());
0104 }
0105 }
0106 }
0107 }
0108 theNDigisPerEventPlot->Fill(nDigisPerEvent);
0109 }