File indexing completed on 2023-03-17 11:28:06
0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Validation/MuonCSCDigis/interface/CSCCorrelatedLCTDigiValidation.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 CSCCorrelatedLCTDigiValidation::CSCCorrelatedLCTDigiValidation(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 lctVars_(ps.getParameter<std::vector<std::string>>("lctVars")),
0016
0017 lctNBin_(ps.getParameter<std::vector<unsigned>>("lctNBin")),
0018 lctMinBin_(ps.getParameter<std::vector<double>>("lctMinBin")),
0019 lctMaxBin_(ps.getParameter<std::vector<double>>("lctMaxBin")),
0020 isRun3_(ps.getParameter<bool>("isRun3")) {
0021 const auto &pset = ps.getParameterSet("cscMPLCT");
0022 inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0023 lcts_Token_ = iC.consumes<CSCCorrelatedLCTDigiCollection>(inputTag_);
0024 }
0025
0026 CSCCorrelatedLCTDigiValidation::~CSCCorrelatedLCTDigiValidation() {}
0027
0028 void CSCCorrelatedLCTDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0029 iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/LCT/Occupancy/");
0030
0031 theNDigisPerEventPlot =
0032 iBooker.book1D("CSCCorrelatedLCTDigisPerEvent",
0033 "CorrelatedLCT trigger primitives per event; Number of CorrelatedLCTs; Entries",
0034 100,
0035 0,
0036 100);
0037 for (int i = 1; i <= 10; ++i) {
0038 const std::string t2("CSCCorrelatedLCTDigisPerChamber_" + CSCDetId::chamberName(i));
0039 theNDigisPerChamberPlots[i - 1] =
0040 iBooker.book1D(t2,
0041 "Number of CorrelatedLCTs per chamber " + CSCDetId::chamberName(i) +
0042 ";Number of CorrelatedLCTs per chamber;Entries",
0043 4,
0044 0,
0045 4);
0046 }
0047
0048
0049 if (!isRun3_) {
0050 lctVars_.resize(7);
0051 }
0052
0053
0054 for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0055
0056 for (unsigned iEndcap = 0; iEndcap < 2; iEndcap++) {
0057 const std::string eSign(iEndcap == 0 ? "+" : "-");
0058
0059 for (unsigned iVar = 0; iVar < lctVars_.size(); iVar++) {
0060 if (std::find(chambersRun3_.begin(), chambersRun3_.end(), iType) == chambersRun3_.end()) {
0061 if (iVar > 6)
0062 continue;
0063 }
0064 const std::string key("lct_" + lctVars_[iVar]);
0065 const std::string histName(key + "_" + chambers_[iType] + eSign);
0066 const std::string histTitle(chambers_[iType] + eSign + " LCT " + lctVars_[iVar]);
0067 const unsigned iTypeCorrected(iEndcap == 0 ? iType : iType + chambers_.size());
0068 chamberHistos[iTypeCorrected][key] =
0069 iBooker.book1D(histName, histTitle, lctNBin_[iVar], lctMinBin_[iVar], lctMaxBin_[iVar]);
0070 chamberHistos[iTypeCorrected][key]->getTH1()->SetMinimum(0);
0071
0072
0073 if (lctVars_[iVar] == "type") {
0074 chamberHistos[iTypeCorrected][key]->setBinLabel(1, "CLCTALCT", 1);
0075 chamberHistos[iTypeCorrected][key]->setBinLabel(2, "ALCTCLCT", 1);
0076 chamberHistos[iTypeCorrected][key]->setBinLabel(3, "ALCTCLCTGEM", 1);
0077 chamberHistos[iTypeCorrected][key]->setBinLabel(4, "ALCTCLCT2GEM", 1);
0078 chamberHistos[iTypeCorrected][key]->setBinLabel(5, "ALCT2GEM", 1);
0079 chamberHistos[iTypeCorrected][key]->setBinLabel(6, "CLCT2GEM", 1);
0080 chamberHistos[iTypeCorrected][key]->setBinLabel(7, "CLCTONLY", 1);
0081 chamberHistos[iTypeCorrected][key]->setBinLabel(8, "ALCTONLY", 1);
0082 }
0083 }
0084 }
0085 }
0086 }
0087
0088 void CSCCorrelatedLCTDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0089 edm::Handle<CSCCorrelatedLCTDigiCollection> lcts;
0090 e.getByToken(lcts_Token_, lcts);
0091 if (!lcts.isValid()) {
0092 edm::LogError("CSCDigiDump") << "Cannot get CorrelatedLCTs by label " << inputTag_.encode();
0093 }
0094
0095 unsigned nDigisPerEvent = 0;
0096
0097 for (auto j = lcts->begin(); j != lcts->end(); j++) {
0098 auto beginDigi = (*j).second.first;
0099 auto endDigi = (*j).second.second;
0100 const CSCDetId &detId((*j).first);
0101 int chamberType = detId.iChamberType();
0102 int nDigis = endDigi - beginDigi;
0103 nDigisPerEvent += nDigis;
0104 theNDigisPerChamberPlots[chamberType - 1]->Fill(nDigis);
0105
0106 auto range = lcts->get((*j).first);
0107
0108 const unsigned typeCorrected(detId.endcap() == 1 ? chamberType - 2 : chamberType - 2 + chambers_.size());
0109 for (auto lct = range.first; lct != range.second; lct++) {
0110 if (lct->isValid()) {
0111 chamberHistos[typeCorrected]["lct_pattern"]->Fill(lct->getPattern());
0112 chamberHistos[typeCorrected]["lct_quality"]->Fill(lct->getQuality());
0113 chamberHistos[typeCorrected]["lct_wiregroup"]->Fill(lct->getKeyWG());
0114 chamberHistos[typeCorrected]["lct_halfstrip"]->Fill(lct->getStrip());
0115 chamberHistos[typeCorrected]["lct_bend"]->Fill(lct->getBend());
0116 chamberHistos[typeCorrected]["lct_bx"]->Fill(lct->getBX());
0117 chamberHistos[typeCorrected]["lct_type"]->Fill(lct->getType());
0118 if (isRun3_) {
0119
0120 if (std::find(chambersRun3_.begin(), chambersRun3_.end(), chamberType - 2) == chambersRun3_.end())
0121 continue;
0122 chamberHistos[typeCorrected]["lct_run3pattern"]->Fill(lct->getRun3Pattern());
0123 chamberHistos[typeCorrected]["lct_slope"]->Fill(lct->getSlope());
0124 chamberHistos[typeCorrected]["lct_quartstrip"]->Fill(lct->getStrip(4));
0125 chamberHistos[typeCorrected]["lct_eighthstrip"]->Fill(lct->getStrip(8));
0126 }
0127 }
0128 }
0129 }
0130 theNDigisPerEventPlot->Fill(nDigisPerEvent);
0131 }