Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:55:29

0001 #include <string>
0002 #include <vector>
0003 #include <iostream>
0004 #include <map>
0005 
0006 #include "DQM/L1TMonitor/interface/L1TStage2RegionalShower.h"
0007 
0008 L1TStage2RegionalShower::L1TStage2RegionalShower(const edm::ParameterSet& ps)
0009     : EMTFShowerToken(consumes<l1t::RegionalMuonShowerBxCollection>(ps.getParameter<edm::InputTag>("emtfSource"))),
0010       CSCShowerToken(consumes<CSCShowerDigiCollection>(ps.getParameter<edm::InputTag>("cscSource"))),
0011       monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0012       verbose(ps.getUntrackedParameter<bool>("verbose", false)) {}
0013 
0014 L1TStage2RegionalShower::~L1TStage2RegionalShower() {}
0015 
0016 void L1TStage2RegionalShower::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) {
0017   ibooker.setCurrentFolder(monitorDir);
0018 
0019   const std::array<std::string, 9> suffix_label{{"4/2", "4/1", "3/2", "3/1", " 2/2", "2/1", "1/3", "1/2", "1/1"}};
0020 
0021   // CSC local shower
0022   cscShowerOccupancyLoose =
0023       ibooker.book2D("cscShowerOccupancyLoose", "CSC Loose Shower Occupancy", 36, 1, 37, 18, 0, 18);
0024   cscShowerOccupancyLoose->setAxisTitle("Chamber", 1);
0025   for (int ybin = 1; ybin <= 9; ++ybin) {
0026     cscShowerOccupancyLoose->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0027     cscShowerOccupancyLoose->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0028   }
0029 
0030   cscShowerOccupancyNom = ibooker.book2D("cscShowerOccupancyNom", "CSC Nominal Shower Occupancy", 36, 1, 37, 18, 0, 18);
0031   cscShowerOccupancyNom->setAxisTitle("Chamber", 1);
0032   for (int ybin = 1; ybin <= 9; ++ybin) {
0033     cscShowerOccupancyNom->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0034     cscShowerOccupancyNom->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0035   }
0036 
0037   cscShowerOccupancyTight =
0038       ibooker.book2D("cscShowerOccupancyTight", "CSC Tight Shower Occupancy", 36, 1, 37, 18, 0, 18);
0039   cscShowerOccupancyTight->setAxisTitle("Chamber", 1);
0040   for (int ybin = 1; ybin <= 9; ++ybin) {
0041     cscShowerOccupancyTight->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0042     cscShowerOccupancyTight->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0043   }
0044 
0045   cscShowerStationRing =
0046       ibooker.book2D("cscShowerStationRing", "CSC shower types in stations and rings", 4, 0, 4, 18, 0, 18);
0047   cscShowerStationRing->setAxisTitle("Type", 1);
0048   cscShowerStationRing->setBinLabel(1, "Total", 1);
0049   cscShowerStationRing->setBinLabel(2, "Loose", 1);
0050   cscShowerStationRing->setBinLabel(3, "Nominal", 1);
0051   cscShowerStationRing->setBinLabel(4, "Tight", 1);
0052   for (int ybin = 1; ybin <= 9; ++ybin) {
0053     cscShowerStationRing->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0054     cscShowerStationRing->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0055   }
0056 
0057   cscShowerChamber = ibooker.book2D("cscShowerChamber", "CSC shower types in chambers", 36, 1, 37, 4, 0, 4);
0058   cscShowerChamber->setAxisTitle("Chamber", 1);
0059   cscShowerChamber->setAxisTitle("Type", 2);
0060   cscShowerChamber->setBinLabel(1, "Total", 2);
0061   cscShowerChamber->setBinLabel(2, "Loose", 2);
0062   cscShowerChamber->setBinLabel(3, "Nominal", 2);
0063   cscShowerChamber->setBinLabel(4, "Tight", 2);
0064 
0065   // EMTF regional shower
0066   emtfShowerTypeOccupancy = ibooker.book2D("emtfShowerTypeOccupancy", "EMTF shower Type Occupancy", 6, 1, 7, 8, 0, 8);
0067   emtfShowerTypeOccupancy->setAxisTitle("Sector", 1);
0068   emtfShowerTypeOccupancy->setBinLabel(8, "ME+ Tight", 2);
0069   emtfShowerTypeOccupancy->setBinLabel(7, "ME+ 2Loose", 2);
0070   emtfShowerTypeOccupancy->setBinLabel(6, "ME+ Nom", 2);
0071   emtfShowerTypeOccupancy->setBinLabel(5, "ME+ Tot", 2);
0072   emtfShowerTypeOccupancy->setBinLabel(4, "ME- Tot", 2);
0073   emtfShowerTypeOccupancy->setBinLabel(3, "ME- Nom", 2);
0074   emtfShowerTypeOccupancy->setBinLabel(2, "ME- 2Loose", 2);
0075   emtfShowerTypeOccupancy->setBinLabel(1, "ME- Tight", 2);
0076 }
0077 
0078 void L1TStage2RegionalShower::analyze(const edm::Event& e, const edm::EventSetup& c) {
0079   l1t::RegionalMuonShowerBxCollection const& EmtfShowers = e.get(EMTFShowerToken);
0080   CSCShowerDigiCollection const& CscShowers = e.get(CSCShowerToken);
0081 
0082   const std::map<std::pair<int, int>, int> histIndexCSC = {{{1, 1}, 8},
0083                                                            {{1, 2}, 7},
0084                                                            {{1, 3}, 6},
0085                                                            {{2, 1}, 5},
0086                                                            {{2, 2}, 4},
0087                                                            {{3, 1}, 3},
0088                                                            {{3, 2}, 2},
0089                                                            {{4, 1}, 1},
0090                                                            {{4, 2}, 0}};
0091 
0092   // Fill CSC local shower plots
0093   for (auto const& element : CscShowers) {
0094     auto detId = element.first;
0095     int endcap = (detId.endcap() == 1 ? 1 : -1);
0096     int station = detId.station();
0097     int ring = detId.ring();
0098     int chamber = detId.chamber();
0099     int sr = histIndexCSC.at({station, ring});
0100     if (endcap == 1)
0101       sr = 17 - sr;
0102     float evt_wgt = (station > 1 && ring == 1) ? 0.5 : 1.0;
0103 
0104     auto cscShower = element.second.first;
0105     auto cscShowerEnd = element.second.second;
0106     for (; cscShower != cscShowerEnd; ++cscShower) {
0107       if (station > 1 && (ring % 2) == 1) {
0108         if (cscShower->isLooseInTime())
0109           cscShowerOccupancyLoose->Fill(chamber * 2, sr, evt_wgt);
0110         if (cscShower->isNominalInTime())
0111           cscShowerOccupancyNom->Fill(chamber * 2, sr, evt_wgt);
0112         if (cscShower->isTightInTime())
0113           cscShowerOccupancyTight->Fill(chamber * 2, sr, evt_wgt);
0114         if (cscShower->isLooseInTime())
0115           cscShowerOccupancyLoose->Fill(chamber * 2 - 1, sr, evt_wgt);
0116         if (cscShower->isNominalInTime())
0117           cscShowerOccupancyNom->Fill(chamber * 2 - 1, sr, evt_wgt);
0118         if (cscShower->isTightInTime())
0119           cscShowerOccupancyTight->Fill(chamber * 2 - 1, sr, evt_wgt);
0120       } else {
0121         if (cscShower->isLooseInTime())
0122           cscShowerOccupancyLoose->Fill(chamber, sr);
0123         if (cscShower->isNominalInTime())
0124           cscShowerOccupancyNom->Fill(chamber, sr);
0125         if (cscShower->isTightInTime())
0126           cscShowerOccupancyTight->Fill(chamber, sr);
0127       }
0128 
0129       cscShowerStationRing->Fill(0.5, sr);
0130       if (cscShower->isLooseInTime())
0131         cscShowerStationRing->Fill(1.5, sr);
0132       if (cscShower->isNominalInTime())
0133         cscShowerStationRing->Fill(2.5, sr);
0134       if (cscShower->isTightInTime())
0135         cscShowerStationRing->Fill(3.5, sr);
0136 
0137       if (station > 1 && (ring % 2) == 1) {
0138         cscShowerChamber->Fill(chamber * 2, 0.5, evt_wgt);
0139         cscShowerChamber->Fill(chamber * 2 - 1, 0.5, evt_wgt);
0140         if (cscShower->isLooseInTime())
0141           cscShowerChamber->Fill(chamber * 2, 1.5, evt_wgt);
0142         if (cscShower->isNominalInTime())
0143           cscShowerChamber->Fill(chamber * 2, 2.5, evt_wgt);
0144         if (cscShower->isTightInTime())
0145           cscShowerChamber->Fill(chamber * 2, 3.5, evt_wgt);
0146         if (cscShower->isLooseInTime())
0147           cscShowerChamber->Fill(chamber * 2 - 1, 1.5, evt_wgt);
0148         if (cscShower->isNominalInTime())
0149           cscShowerChamber->Fill(chamber * 2 - 1, 2.5, evt_wgt);
0150         if (cscShower->isTightInTime())
0151           cscShowerChamber->Fill(chamber * 2 - 1, 3.5, evt_wgt);
0152       } else {
0153         cscShowerChamber->Fill(chamber, 0.5);
0154         if (cscShower->isLooseInTime())
0155           cscShowerChamber->Fill(chamber, 1.5);
0156         if (cscShower->isNominalInTime())
0157           cscShowerChamber->Fill(chamber, 2.5);
0158         if (cscShower->isTightInTime())
0159           cscShowerChamber->Fill(chamber, 3.5);
0160       }
0161     }
0162   }
0163 
0164   // Fill EMTF regional shower plots
0165   for (auto const& Shower : EmtfShowers) {
0166     if (not Shower.isValid())
0167       continue;
0168     if (Shower.isOneNominalInTime() or Shower.isTwoLooseInTime() or Shower.isOneTightInTime()) {
0169       int endcap = Shower.trackFinderType() == l1t::tftype::emtf_pos ? 1 : -1;
0170       int sector = Shower.processor() + 1;
0171       if (Shower.isOneTightInTime())
0172         emtfShowerTypeOccupancy->Fill(sector, (endcap == 1) ? 7.5 : 0.5);
0173       if (Shower.isTwoLooseInTime())
0174         emtfShowerTypeOccupancy->Fill(sector, (endcap == 1) ? 6.5 : 1.5);
0175       if (Shower.isOneNominalInTime())
0176         emtfShowerTypeOccupancy->Fill(sector, (endcap == 1) ? 5.5 : 2.5);
0177       emtfShowerTypeOccupancy->Fill(sector, (endcap == 1) ? 4.5 : 3.5);
0178     }
0179   }
0180 }