Back to home page

Project CMSSW displayed by LXR

 
 

    


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/CSCCLCTPreTriggerDigiValidation.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 CSCCLCTPreTriggerDigiValidation::CSCCLCTPreTriggerDigiValidation(const edm::ParameterSet &ps,
0010                                                                  edm::ConsumesCollector &&iC)
0011     : CSCBaseValidation(ps),
0012       chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0013       // variables
0014       preclctVars_(ps.getParameter<std::vector<std::string>>("preclctVars")),
0015       // binning
0016       preclctNBin_(ps.getParameter<std::vector<unsigned>>("preclctNBin")),
0017       preclctMinBin_(ps.getParameter<std::vector<double>>("preclctMinBin")),
0018       preclctMaxBin_(ps.getParameter<std::vector<double>>("preclctMaxBin")) {
0019   const auto &pset = ps.getParameterSet("cscCLCTPreTrigger");
0020   inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0021   preclcts_Token_ = iC.consumes<CSCCLCTPreTriggerDigiCollection>(inputTag_);
0022 }
0023 
0024 CSCCLCTPreTriggerDigiValidation::~CSCCLCTPreTriggerDigiValidation() {}
0025 
0026 void CSCCLCTPreTriggerDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0027   iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/PreCLCT/Occupancy/");
0028 
0029   // chamber type
0030   for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0031     // consider CSC+ and CSC- separately
0032     for (unsigned iEndcap = 0; iEndcap < 2; iEndcap++) {
0033       const std::string eSign(iEndcap == 0 ? "+" : "-");
0034       // preclct variable
0035       for (unsigned iVar = 0; iVar < preclctVars_.size(); iVar++) {
0036         const std::string key("preclct_" + preclctVars_[iVar]);
0037         const std::string histName(key + "_" + chambers_[iType] + eSign);
0038         const std::string histTitle(chambers_[iType] + eSign + " CLCTPreTrigger " + preclctVars_[iVar]);
0039         const unsigned iTypeCorrected(iEndcap == 0 ? iType : iType + chambers_.size());
0040         chamberHistos[iTypeCorrected][key] =
0041             iBooker.book1D(histName, histTitle, preclctNBin_[iVar], preclctMinBin_[iVar], preclctMaxBin_[iVar]);
0042         chamberHistos[iTypeCorrected][key]->getTH1()->SetMinimum(0);
0043       }
0044     }
0045   }
0046 }
0047 
0048 void CSCCLCTPreTriggerDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0049   edm::Handle<CSCCLCTPreTriggerDigiCollection> preclcts;
0050   e.getByToken(preclcts_Token_, preclcts);
0051   if (!preclcts.isValid()) {
0052     edm::LogError("CSCCLCTPreTriggerDigiValidation") << "Cannot get CLCTPreTriggers by label " << inputTag_.encode();
0053   }
0054 
0055   for (auto j = preclcts->begin(); j != preclcts->end(); j++) {
0056     const CSCDetId &detId((*j).first);
0057     int chamberType = detId.iChamberType();
0058 
0059     auto range = preclcts->get((*j).first);
0060     // 1=forward (+Z); 2=backward (-Z)
0061     const unsigned typeCorrected(detId.endcap() == 1 ? chamberType - 2 : chamberType - 2 + chambers_.size());
0062     for (auto preclct = range.first; preclct != range.second; preclct++) {
0063       if (preclct->isValid()) {
0064         chamberHistos[typeCorrected]["preclct_cfeb"]->Fill(preclct->getCFEB());
0065         chamberHistos[typeCorrected]["preclct_halfstrip"]->Fill(preclct->getKeyStrip());
0066         chamberHistos[typeCorrected]["preclct_bx"]->Fill(preclct->getBX());
0067       }
0068     }
0069   }
0070 }