Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-04 01:25:52

0001 #include "DQM/L1TMonitor/interface/L1TStage2uGMT.h"
0002 
0003 L1TStage2uGMT::L1TStage2uGMT(const edm::ParameterSet& ps)
0004     : ugmtMuonToken_(consumes<l1t::MuonBxCollection>(ps.getParameter<edm::InputTag>("muonProducer"))),
0005       ugmtMuonShowerToken_(consumes<l1t::MuonShowerBxCollection>(ps.getParameter<edm::InputTag>("muonShowerProducer"))),
0006       monitorDir_(ps.getUntrackedParameter<std::string>("monitorDir")),
0007       emul_(ps.getUntrackedParameter<bool>("emulator")),
0008       verbose_(ps.getUntrackedParameter<bool>("verbose")),
0009       displacedQuantities_(ps.getUntrackedParameter<bool>("displacedQuantities")),
0010       hadronicShowers_(ps.getUntrackedParameter<bool>("hadronicShowers")),
0011       etaScale_(0.010875),  // eta scale (CMS DN-2015/017)
0012       phiScale_(0.010908)   // phi scale (2*pi/576 HW values)
0013 {
0014   if (!emul_) {
0015     ugmtBMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfProducer"));
0016     ugmtOMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("omtfProducer"));
0017     ugmtEMTFToken_ = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("emtfProducer"));
0018     ugmtEMTFShowerToken_ =
0019         consumes<l1t::RegionalMuonShowerBxCollection>(ps.getParameter<edm::InputTag>("emtfShowerProducer"));
0020   }
0021 }
0022 
0023 L1TStage2uGMT::~L1TStage2uGMT() {}
0024 
0025 void L1TStage2uGMT::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0026   edm::ParameterSetDescription desc;
0027   desc.add<edm::InputTag>("muonProducer")->setComment("uGMT output muons.");
0028 
0029   desc.add<edm::InputTag>("bmtfProducer")->setComment("RegionalMuonCands from BMTF.");
0030   desc.add<edm::InputTag>("omtfProducer")->setComment("RegionalMuonCands from OMTF.");
0031   desc.add<edm::InputTag>("emtfProducer")->setComment("RegionalMuonCands from EMTF.");
0032   desc.add<edm::InputTag>("muonShowerProducer")->setComment("uGMT output showers.");
0033   desc.add<edm::InputTag>("emtfShowerProducer")->setComment("RegionalMuonShowers from EMTF.");
0034   desc.addUntracked<std::string>("monitorDir", "")
0035       ->setComment("Target directory in the DQM file. Will be created if not existing.");
0036   desc.addUntracked<bool>("emulator", false)
0037       ->setComment("Create histograms for muonProducer input only. xmtfProducer inputs are ignored.");
0038   desc.addUntracked<bool>("verbose", false);
0039   desc.addUntracked<bool>("displacedQuantities", false);
0040   desc.addUntracked<bool>("hadronicShowers", false);
0041   descriptions.add("l1tStage2uGMT", desc);
0042 }
0043 
0044 void L1TStage2uGMT::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) {
0045   if (!emul_) {
0046     // BMTF Input
0047     ibooker.setCurrentFolder(monitorDir_ + "/BMTFInput");
0048 
0049     ugmtBMTFnMuons = ibooker.book1D("ugmtBMTFnMuons", "uGMT BMTF Input Muon Multiplicity", 37, -0.5, 36.5);
0050     ugmtBMTFnMuons->setAxisTitle("Muon Multiplicity (BX == 0)", 1);
0051 
0052     ugmtBMTFhwPt = ibooker.book1D("ugmtBMTFhwPt", "uGMT BMTF Input HW p_{T}", 512, -0.5, 511.5);
0053     ugmtBMTFhwPt->setAxisTitle("Hardware p_{T}", 1);
0054 
0055     if (displacedQuantities_) {
0056       ugmtBMTFhwPtUnconstrained =
0057           ibooker.book1D("ugmtBMTFhwPtUnconstrained", "uGMT BMTF Input HW p_{T} unconstrained", 256, -0.5, 255.5);
0058       ugmtBMTFhwPtUnconstrained->setAxisTitle("Hardware p_{T} unconstrained", 1);
0059 
0060       ugmtBMTFhwDXY = ibooker.book1D("ugmtBMTFhwDXY", "uGMT BMTF Input HW impact parameter", 4, -0.5, 3.5);
0061       ugmtBMTFhwDXY->setAxisTitle("Hardware dXY", 1);
0062     }
0063 
0064     ugmtBMTFhwEta = ibooker.book1D("ugmtBMTFhwEta", "uGMT BMTF Input HW #eta", 201, -100.5, 100.5);
0065     ugmtBMTFhwEta->setAxisTitle("Hardware #eta", 1);
0066 
0067     ugmtBMTFhwPhi = ibooker.book1D("ugmtBMTFhwPhi", "uGMT BMTF Input HW #phi", 71, -10.5, 60.5);
0068     ugmtBMTFhwPhi->setAxisTitle("Hardware #phi", 1);
0069 
0070     ugmtBMTFglbPhi = ibooker.book1D("ugmtBMTFglbhwPhi", "uGMT BMTF Input HW #phi", 577, -1.5, 575.5);
0071     ugmtBMTFglbPhi->setAxisTitle("Global Hardware #phi", 1);
0072 
0073     ugmtBMTFProcvshwPhi =
0074         ibooker.book2D("ugmtBMTFProcvshwPhi", "uGMT BMTF Processor vs HW #phi", 71, -10.5, 60.5, 12, 0, 12);
0075     ugmtBMTFProcvshwPhi->setAxisTitle("Hardware #phi", 1);
0076     ugmtBMTFProcvshwPhi->setAxisTitle("Wedge", 2);
0077     for (int bin = 1; bin <= 12; ++bin) {
0078       ugmtBMTFProcvshwPhi->setBinLabel(bin, std::to_string(bin), 2);
0079     }
0080 
0081     ugmtBMTFhwSign = ibooker.book1D("ugmtBMTFhwSign", "uGMT BMTF Input HW Sign", 4, -1.5, 2.5);
0082     ugmtBMTFhwSign->setAxisTitle("Hardware Sign", 1);
0083 
0084     ugmtBMTFhwSignValid = ibooker.book1D("ugmtBMTFhwSignValid", "uGMT BMTF Input SignValid", 2, -0.5, 1.5);
0085     ugmtBMTFhwSignValid->setAxisTitle("SignValid", 1);
0086 
0087     ugmtBMTFhwQual = ibooker.book1D("ugmtBMTFhwQual", "uGMT BMTF Input Quality", 16, -0.5, 15.5);
0088     ugmtBMTFhwQual->setAxisTitle("Quality", 1);
0089 
0090     ugmtBMTFlink = ibooker.book1D("ugmtBMTFlink", "uGMT BMTF Input Link", 12, 47.5, 59.5);
0091     ugmtBMTFlink->setAxisTitle("Link", 1);
0092 
0093     ugmtBMTFMuMuDEta =
0094         ibooker.book1D("ugmtBMTFMuMuDEta", "uGMT BMTF input muons #Delta#eta between wedges", 100, -0.5, 0.5);
0095     ugmtBMTFMuMuDEta->setAxisTitle("#Delta#eta", 1);
0096 
0097     ugmtBMTFMuMuDPhi =
0098         ibooker.book1D("ugmtBMTFMuMuDPhi", "uGMT BMTF input muons #Delta#phi between wedges", 100, -0.5, 0.5);
0099     ugmtBMTFMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0100 
0101     ugmtBMTFMuMuDR = ibooker.book1D("ugmtBMTFMuMuDR", "uGMT BMTF input muons #DeltaR between wedges", 50, 0., 0.5);
0102     ugmtBMTFMuMuDR->setAxisTitle("#DeltaR", 1);
0103 
0104     // OMTF Input
0105     ibooker.setCurrentFolder(monitorDir_ + "/OMTFInput");
0106 
0107     ugmtOMTFnMuons = ibooker.book1D("ugmtOMTFnMuons", "uGMT OMTF Input Muon Multiplicity", 37, -0.5, 36.5);
0108     ugmtOMTFnMuons->setAxisTitle("Muon Multiplicity (BX == 0)", 1);
0109 
0110     ugmtOMTFhwPt = ibooker.book1D("ugmtOMTFhwPt", "uGMT OMTF Input HW p_{T}", 512, -0.5, 511.5);
0111     ugmtOMTFhwPt->setAxisTitle("Hardware p_{T}", 1);
0112 
0113     ugmtOMTFhwEta = ibooker.book1D("ugmtOMTFhwEta", "uGMT OMTF Input HW #eta", 231, -115.5, 115.5);
0114     ugmtOMTFhwEta->setAxisTitle("Hardware #eta", 1);
0115 
0116     ugmtOMTFhwPhiPos = ibooker.book1D("ugmtOMTFhwPhiPos", "uGMT OMTF Input HW #phi, Positive Side", 122, -16.5, 105.5);
0117     ugmtOMTFhwPhiPos->setAxisTitle("Hardware #phi", 1);
0118 
0119     ugmtOMTFhwPhiNeg = ibooker.book1D("ugmtOMTFhwPhiNeg", "uGMT OMTF Input HW #phi, Negative Side", 122, -16.5, 105.5);
0120     ugmtOMTFhwPhiNeg->setAxisTitle("Hardware #phi", 1);
0121 
0122     ugmtOMTFglbPhiPos =
0123         ibooker.book1D("ugmtOMTFglbhwPhiPos", "uGMT OMTF Input HW #phi, Positive Side", 577, -1.5, 575.5);
0124     ugmtOMTFglbPhiPos->setAxisTitle("Global Hardware #phi", 1);
0125 
0126     ugmtOMTFglbPhiNeg =
0127         ibooker.book1D("ugmtOMTFglbhwPhiNeg", "uGMT OMTF Input HW #phi, Negative Side", 577, -1.5, 575.5);
0128     ugmtOMTFglbPhiNeg->setAxisTitle("Global Hardware #phi", 1);
0129 
0130     ugmtOMTFProcvshwPhiPos =
0131         ibooker.book2D("ugmtOMTFProcvshwPhiPos", "uGMT OMTF Processor vs HW #phi", 122, -16.5, 105.5, 6, 0, 6);
0132     ugmtOMTFProcvshwPhiPos->setAxisTitle("Hardware #phi", 1);
0133     ugmtOMTFProcvshwPhiPos->setAxisTitle("Sector (Positive Side)", 2);
0134 
0135     ugmtOMTFProcvshwPhiNeg =
0136         ibooker.book2D("ugmtOMTFProcvshwPhiNeg", "uGMT OMTF Processor vs HW #phi", 122, -16.5, 105.5, 6, 0, 6);
0137     ugmtOMTFProcvshwPhiNeg->setAxisTitle("Hardware #phi", 1);
0138     ugmtOMTFProcvshwPhiNeg->setAxisTitle("Sector (Negative Side)", 2);
0139 
0140     for (int bin = 1; bin <= 6; ++bin) {
0141       ugmtOMTFProcvshwPhiPos->setBinLabel(bin, std::to_string(bin), 2);
0142       ugmtOMTFProcvshwPhiNeg->setBinLabel(bin, std::to_string(bin), 2);
0143     }
0144 
0145     ugmtOMTFhwSign = ibooker.book1D("ugmtOMTFhwSign", "uGMT OMTF Input HW Sign", 4, -1.5, 2.5);
0146     ugmtOMTFhwSign->setAxisTitle("Hardware Sign", 1);
0147 
0148     ugmtOMTFhwSignValid = ibooker.book1D("ugmtOMTFhwSignValid", "uGMT OMTF Input SignValid", 2, -0.5, 1.5);
0149     ugmtOMTFhwSignValid->setAxisTitle("SignValid", 1);
0150 
0151     ugmtOMTFhwQual = ibooker.book1D("ugmtOMTFhwQual", "uGMT OMTF Input Quality", 16, -0.5, 15.5);
0152     ugmtOMTFhwQual->setAxisTitle("Quality", 1);
0153 
0154     ugmtOMTFlink = ibooker.book1D("ugmtOMTFlink", "uGMT OMTF Input Link", 24, 41.5, 65.5);
0155     ugmtOMTFlink->setAxisTitle("Link", 1);
0156 
0157     ugmtOMTFMuMuDEta =
0158         ibooker.book1D("ugmtOMTFMuMuDEta", "uGMT OMTF input muons #Delta#eta between sectors", 100, -0.5, 0.5);
0159     ugmtOMTFMuMuDEta->setAxisTitle("#Delta#eta", 1);
0160 
0161     ugmtOMTFMuMuDPhi =
0162         ibooker.book1D("ugmtOMTFMuMuDPhi", "uGMT OMTF input muons #Delta#phi between sectors", 100, -0.5, 0.5);
0163     ugmtOMTFMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0164 
0165     ugmtOMTFMuMuDR = ibooker.book1D("ugmtOMTFMuMuDR", "uGMT OMTF input muons #DeltaR between sectors", 50, 0., 0.5);
0166     ugmtOMTFMuMuDR->setAxisTitle("#DeltaR", 1);
0167 
0168     // EMTF Input
0169     ibooker.setCurrentFolder(monitorDir_ + "/EMTFInput");
0170 
0171     ugmtEMTFnMuons = ibooker.book1D("ugmtEMTFnMuons", "uGMT EMTF Input Muon Multiplicity", 37, -0.5, 36.5);
0172     ugmtEMTFnMuons->setAxisTitle("Muon Multiplicity (BX == 0)", 1);
0173 
0174     ugmtEMTFhwPt = ibooker.book1D("ugmtEMTFhwPt", "uGMT EMTF HW p_{T}", 512, -0.5, 511.5);
0175     ugmtEMTFhwPt->setAxisTitle("Hardware p_{T}", 1);
0176 
0177     if (displacedQuantities_) {
0178       ugmtEMTFhwPtUnconstrained =
0179           ibooker.book1D("ugmtEMTFhwPtUnconstrained", "uGMT EMTF Input HW p_{T} unconstrained", 256, -0.5, 255.5);
0180       ugmtEMTFhwPtUnconstrained->setAxisTitle("Hardware p_{T} unconstrained", 1);
0181 
0182       ugmtEMTFhwDXY = ibooker.book1D("ugmtEMTFhwDXY", "uGMT EMTF Input HW impact parameter", 4, -0.5, 3.5);
0183       ugmtEMTFhwDXY->setAxisTitle("Hardware dXY", 1);
0184     }
0185 
0186     ugmtEMTFhwEta = ibooker.book1D("ugmtEMTFhwEta", "uGMT EMTF HW #eta", 461, -230.5, 230.5);
0187     ugmtEMTFhwEta->setAxisTitle("Hardware #eta", 1);
0188 
0189     ugmtEMTFhwPhiPos = ibooker.book1D("ugmtEMTFhwPhiPos", "uGMT EMTF HW #phi, Positive Side", 146, -40.5, 105.5);
0190     ugmtEMTFhwPhiPos->setAxisTitle("Hardware #phi", 1);
0191 
0192     ugmtEMTFhwPhiNeg = ibooker.book1D("ugmtEMTFhwPhiNeg", "uGMT EMTF HW #phi, Negative Side", 146, -40.5, 105.5);
0193     ugmtEMTFhwPhiNeg->setAxisTitle("Hardware #phi", 1);
0194 
0195     ugmtEMTFglbPhiPos =
0196         ibooker.book1D("ugmtEMTFglbhwPhiPos", "uGMT EMTF Input Global HW #phi, Positive Side", 577, -1.5, 575.5);
0197     ugmtEMTFglbPhiPos->setAxisTitle("Global Hardware #phi", 1);
0198 
0199     ugmtEMTFglbPhiNeg =
0200         ibooker.book1D("ugmtEMTFglbhwPhiNeg", "uGMT EMTF Input Global HW #phi, Negative Side", 577, -1.5, 575.5);
0201     ugmtEMTFglbPhiNeg->setAxisTitle("Global Hardware #phi", 1);
0202 
0203     ugmtEMTFProcvshwPhiPos =
0204         ibooker.book2D("ugmtEMTFProcvshwPhiPos", "uGMT EMTF Processor vs HW #phi", 146, -40.5, 105.5, 6, 0, 6);
0205     ugmtEMTFProcvshwPhiPos->setAxisTitle("Hardware #phi", 1);
0206     ugmtEMTFProcvshwPhiPos->setAxisTitle("Sector (Positive Side)", 2);
0207 
0208     ugmtEMTFProcvshwPhiNeg =
0209         ibooker.book2D("ugmtEMTFProcvshwPhiNeg", "uGMT EMTF Processor vs HW #phi", 146, -40.5, 105.5, 6, 0, 6);
0210     ugmtEMTFProcvshwPhiNeg->setAxisTitle("Hardware #phi", 1);
0211     ugmtEMTFProcvshwPhiNeg->setAxisTitle("Sector (Negative Side)", 2);
0212 
0213     for (int bin = 1; bin <= 6; ++bin) {
0214       ugmtEMTFProcvshwPhiPos->setBinLabel(bin, std::to_string(bin), 2);
0215       ugmtEMTFProcvshwPhiNeg->setBinLabel(bin, std::to_string(bin), 2);
0216     }
0217 
0218     ugmtEMTFhwSign = ibooker.book1D("ugmtEMTFhwSign", "uGMT EMTF HW Sign", 4, -1.5, 2.5);
0219     ugmtEMTFhwSign->setAxisTitle("Hardware Sign", 1);
0220 
0221     ugmtEMTFhwSignValid = ibooker.book1D("ugmtEMTFhwSignValid", "uGMT EMTF SignValid", 2, -0.5, 1.5);
0222     ugmtEMTFhwSignValid->setAxisTitle("SignValid", 1);
0223 
0224     ugmtEMTFhwQual = ibooker.book1D("ugmtEMTFhwQual", "uGMT EMTF Quality", 16, -0.5, 15.5);
0225     ugmtEMTFhwQual->setAxisTitle("Quality", 1);
0226 
0227     ugmtEMTFlink = ibooker.book1D("ugmtEMTFlink", "uGMT EMTF Link", 36, 35.5, 71.5);
0228     ugmtEMTFlink->setAxisTitle("Link", 1);
0229 
0230     ugmtEMTFMuMuDEta =
0231         ibooker.book1D("ugmtEMTFMuMuDEta", "uGMT EMTF input muons #Delta#eta between sectors", 100, -0.5, 0.5);
0232     ugmtEMTFMuMuDEta->setAxisTitle("#Delta#eta", 1);
0233 
0234     ugmtEMTFMuMuDPhi =
0235         ibooker.book1D("ugmtEMTFMuMuDPhi", "uGMT EMTF input muons #Delta#phi between sectors", 100, -0.5, 0.5);
0236     ugmtEMTFMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0237 
0238     ugmtEMTFMuMuDR = ibooker.book1D("ugmtEMTFMuMuDR", "uGMT EMTF input muons #DeltaR between sectors", 50, 0., 0.5);
0239     ugmtEMTFMuMuDR->setAxisTitle("#DeltaR", 1);
0240 
0241     // EMTF muon showers
0242     if (hadronicShowers_) {
0243       ibooker.setCurrentFolder(monitorDir_ + "/EMTFInput/Muon showers");
0244 
0245       ugmtEMTFShowerTypeOccupancyPerSector = ibooker.book2D(
0246           "ugmtEMTFShowerTypeOccupancyPerSector", "Shower type occupancy per sector", 12, 1, 13, 2, 1, 3);
0247       ugmtEMTFShowerTypeOccupancyPerSector->setAxisTitle("Processor", 1);
0248       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(12, "+6", 1);
0249       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(11, "+5", 1);
0250       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(10, "+4", 1);
0251       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(9, "+3", 1);
0252       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(8, "+2", 1);
0253       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(7, "+1", 1);
0254       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(6, "-6", 1);
0255       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(5, "-5", 1);
0256       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(4, "-4", 1);
0257       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(3, "-3", 1);
0258       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(2, "-2", 1);
0259       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(1, "-1", 1);
0260       ugmtEMTFShowerTypeOccupancyPerSector->setAxisTitle("Shower type", 2);
0261       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(IDX_TIGHT_SHOWER, "Tight", 2);
0262       ugmtEMTFShowerTypeOccupancyPerSector->setBinLabel(IDX_NOMINAL_SHOWER, "Nominal", 2);
0263     }
0264 
0265     // inter-TF muon correlations
0266     ibooker.setCurrentFolder(monitorDir_ + "/muon_correlations");
0267 
0268     ugmtBOMTFposMuMuDEta =
0269         ibooker.book1D("ugmtBOMTFposMuMuDEta", "uGMT input muons #Delta#eta between BMTF and OMTF+", 100, -0.5, 0.5);
0270     ugmtBOMTFposMuMuDEta->setAxisTitle("#Delta#eta", 1);
0271 
0272     ugmtBOMTFposMuMuDPhi =
0273         ibooker.book1D("ugmtBOMTFposMuMuDPhi", "uGMT input muons #Delta#phi between BMTF and OMTF+", 100, -0.5, 0.5);
0274     ugmtBOMTFposMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0275 
0276     ugmtBOMTFposMuMuDR =
0277         ibooker.book1D("ugmtBOMTFposMuMuDR", "uGMT input muons #DeltaR between BMTF and OMTF+", 50, 0., 0.5);
0278     ugmtBOMTFposMuMuDR->setAxisTitle("#DeltaR", 1);
0279 
0280     ugmtBOMTFnegMuMuDEta =
0281         ibooker.book1D("ugmtBOMTFnegMuMuDEta", "uGMT input muons #Delta#eta between BMTF and OMTF-", 100, -0.5, 0.5);
0282     ugmtBOMTFnegMuMuDEta->setAxisTitle("#Delta#eta", 1);
0283 
0284     ugmtBOMTFnegMuMuDPhi =
0285         ibooker.book1D("ugmtBOMTFnegMuMuDPhi", "uGMT input muons #Delta#phi between BMTF and OMTF-", 100, -0.5, 0.5);
0286     ugmtBOMTFnegMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0287 
0288     ugmtBOMTFnegMuMuDR =
0289         ibooker.book1D("ugmtBOMTFnegMuMuDR", "uGMT input muons #DeltaR between BMTF and OMTF-", 50, 0., 0.5);
0290     ugmtBOMTFnegMuMuDR->setAxisTitle("#DeltaR", 1);
0291 
0292     ugmtEOMTFposMuMuDEta =
0293         ibooker.book1D("ugmtEOMTFposMuMuDEta", "uGMT input muons #Delta#eta between EMTF+ and OMTF+", 100, -0.5, 0.5);
0294     ugmtEOMTFposMuMuDEta->setAxisTitle("#Delta#eta", 1);
0295 
0296     ugmtEOMTFposMuMuDPhi =
0297         ibooker.book1D("ugmtEOMTFposMuMuDPhi", "uGMT input muons #Delta#phi between EMTF+ and OMTF+", 100, -0.5, 0.5);
0298     ugmtEOMTFposMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0299 
0300     ugmtEOMTFposMuMuDR =
0301         ibooker.book1D("ugmtEOMTFposMuMuDR", "uGMT input muons #DeltaR between EMTF+ and OMTF+", 50, 0., 0.5);
0302     ugmtEOMTFposMuMuDR->setAxisTitle("#DeltaR", 1);
0303 
0304     ugmtEOMTFnegMuMuDEta =
0305         ibooker.book1D("ugmtEOMTFnegMuMuDEta", "uGMT input muons #Delta#eta between EMTF- and OMTF-", 100, -0.5, 0.5);
0306     ugmtEOMTFnegMuMuDEta->setAxisTitle("#Delta#eta", 1);
0307 
0308     ugmtEOMTFnegMuMuDPhi =
0309         ibooker.book1D("ugmtEOMTFnegMuMuDPhi", "uGMT input muons #Delta#phi between EMTF- and OMTF-", 100, -0.5, 0.5);
0310     ugmtEOMTFnegMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0311 
0312     ugmtEOMTFnegMuMuDR =
0313         ibooker.book1D("ugmtEOMTFnegMuMuDR", "uGMT input muons #DeltaR between EMTF- and OMTF-", 50, 0., 0.5);
0314     ugmtEOMTFnegMuMuDR->setAxisTitle("#DeltaR", 1);
0315   }
0316 
0317   // Subsystem Monitoring and Muon Output
0318   ibooker.setCurrentFolder(monitorDir_);
0319 
0320   ugmtMuonBX = ibooker.book1D("ugmtMuonBX", "uGMT output muon BX", 7, -3.5, 3.5);
0321   ugmtMuonBX->setAxisTitle("BX", 1);
0322 
0323   ugmtnMuons = ibooker.book1D("ugmtnMuons", "uGMT output muon Multiplicity", 9, -0.5, 8.5);
0324   ugmtnMuons->setAxisTitle("Muon Multiplicity (BX == 0)", 1);
0325 
0326   ugmtMuonIndex = ibooker.book1D("ugmtMuonIndex", "uGMT Input Muon Index", 108, -0.5, 107.5);
0327   ugmtMuonIndex->setAxisTitle("Index", 1);
0328 
0329   ugmtMuonhwPt = ibooker.book1D("ugmtMuonhwPt", "uGMT output muon HW p_{T}", 512, -0.5, 511.5);
0330   ugmtMuonhwPt->setAxisTitle("Hardware p_{T}", 1);
0331 
0332   if (displacedQuantities_) {
0333     ugmtMuonhwPtUnconstrained =
0334         ibooker.book1D("ugmtMuonhwPtUnconstrained", "uGMT output muon HW p_{T} unconstrained", 256, -0.5, 255.5);
0335     ugmtMuonhwPtUnconstrained->setAxisTitle("Hardware p_{T} unconstrained", 1);
0336 
0337     ugmtMuonhwDXY = ibooker.book1D("ugmtMuonhwDXY", "uGMT output muon HW impact parameter", 4, -0.5, 3.5);
0338     ugmtMuonhwDXY->setAxisTitle("Hardware dXY", 1);
0339   }
0340 
0341   ugmtMuonhwEta = ibooker.book1D("ugmtMuonhwEta", "uGMT output muon HW #eta", 461, -230.5, 230.5);
0342   ugmtMuonhwEta->setAxisTitle("Hardware Eta", 1);
0343 
0344   ugmtMuonhwPhi = ibooker.book1D("ugmtMuonhwPhi", "uGMT output muon HW #phi", 577, -1.5, 575.5);
0345   ugmtMuonhwPhi->setAxisTitle("Hardware Phi", 1);
0346 
0347   ugmtMuonhwEtaAtVtx = ibooker.book1D("ugmtMuonhwEtaAtVtx", "uGMT output muon HW #eta at vertex", 461, -230.5, 230.5);
0348   ugmtMuonhwEtaAtVtx->setAxisTitle("Hardware Eta at Vertex", 1);
0349 
0350   ugmtMuonhwPhiAtVtx = ibooker.book1D("ugmtMuonhwPhiAtVtx", "uGMT output muon HW #phi at vertex", 577, -1.5, 575.5);
0351   ugmtMuonhwPhiAtVtx->setAxisTitle("Hardware Phi at Vertex", 1);
0352 
0353   ugmtMuonhwCharge = ibooker.book1D("ugmtMuonhwCharge", "uGMT output muon HW Charge", 4, -1.5, 2.5);
0354   ugmtMuonhwCharge->setAxisTitle("Hardware Charge", 1);
0355 
0356   ugmtMuonhwChargeValid = ibooker.book1D("ugmtMuonhwChargeValid", "uGMT output muon ChargeValid", 2, -0.5, 1.5);
0357   ugmtMuonhwChargeValid->setAxisTitle("ChargeValid", 1);
0358 
0359   ugmtMuonhwQual = ibooker.book1D("ugmtMuonhwQual", "uGMT output muon Quality", 16, -0.5, 15.5);
0360   ugmtMuonhwQual->setAxisTitle("Quality", 1);
0361 
0362   ugmtMuonhwIso = ibooker.book1D("ugmtMuonhwIso", "uGMT output muon Isolation", 4, -0.5, 3.5);
0363   ugmtMuonhwIso->setAxisTitle("Isolation", 1);
0364 
0365   ugmtMuonPt = ibooker.book1D("ugmtMuonPt", "uGMT output muon p_{T}", 128, -0.5, 255.5);
0366   ugmtMuonPt->setAxisTitle("p_{T} [GeV]", 1);
0367 
0368   if (displacedQuantities_) {
0369     ugmtMuonPtUnconstrained =
0370         ibooker.book1D("ugmtMuonPtUnconstrained", "uGMT output muon p_{T} unconstrained", 128, -0.5, 255.5);
0371     ugmtMuonPtUnconstrained->setAxisTitle("p_{T} unconstrained [GeV]", 1);
0372   }
0373 
0374   ugmtMuonEta = ibooker.book1D("ugmtMuonEta", "uGMT output muon #eta", 52, -2.6, 2.6);
0375   ugmtMuonEta->setAxisTitle("#eta", 1);
0376 
0377   ugmtMuonPhi = ibooker.book1D("ugmtMuonPhi", "uGMT output muon #phi", 66, -3.3, 3.3);
0378   ugmtMuonPhi->setAxisTitle("#phi", 1);
0379 
0380   ugmtMuonEtaAtVtx = ibooker.book1D("ugmtMuonEtaAtVtx", "uGMT output muon #eta at vertex", 52, -2.6, 2.6);
0381   ugmtMuonEtaAtVtx->setAxisTitle("#eta at vertex", 1);
0382 
0383   ugmtMuonPhiAtVtx = ibooker.book1D("ugmtMuonPhiAtVtx", "uGMT output muon #phi at vertex", 66, -3.3, 3.3);
0384   ugmtMuonPhiAtVtx->setAxisTitle("#phi at vertex", 1);
0385 
0386   ugmtMuonCharge = ibooker.book1D("ugmtMuonCharge", "uGMT output muon Charge", 3, -1.5, 1.5);
0387   ugmtMuonCharge->setAxisTitle("Charge", 1);
0388 
0389   ugmtMuonPhiBmtf = ibooker.book1D("ugmtMuonPhiBmtf", "uGMT output muon #phi for BMTF Inputs", 66, -3.3, 3.3);
0390   ugmtMuonPhiBmtf->setAxisTitle("#phi", 1);
0391 
0392   ugmtMuonPhiOmtf = ibooker.book1D("ugmtMuonPhiOmtf", "uGMT output muon #phi for OMTF Inputs", 66, -3.3, 3.3);
0393   ugmtMuonPhiOmtf->setAxisTitle("#phi", 1);
0394 
0395   ugmtMuonPhiEmtf = ibooker.book1D("ugmtMuonPhiEmtf", "uGMT output muon #phi for EMTF Inputs", 66, -3.3, 3.3);
0396   ugmtMuonPhiEmtf->setAxisTitle("#phi", 1);
0397 
0398   const float dPhiScale = 4 * phiScale_;
0399   const float dEtaScale = etaScale_;
0400   ugmtMuonDEtavsPtBmtf = ibooker.book2D("ugmtMuonDEtavsPtBmtf",
0401                                         "uGMT output muon from BMTF #eta_{at vertex} - #eta_{at muon system} vs p_{T}",
0402                                         32,
0403                                         0,
0404                                         64,
0405                                         31,
0406                                         -15.5 * dEtaScale,
0407                                         15.5 * dEtaScale);
0408   ugmtMuonDEtavsPtBmtf->setAxisTitle("p_{T} [GeV]", 1);
0409   ugmtMuonDEtavsPtBmtf->setAxisTitle("#eta_{at vertex} - #eta", 2);
0410 
0411   ugmtMuonDPhivsPtBmtf = ibooker.book2D("ugmtMuonDPhivsPtBmtf",
0412                                         "uGMT output muon from BMTF #phi_{at vertex} - #phi_{at muon system} vs p_{T}",
0413                                         32,
0414                                         0,
0415                                         64,
0416                                         31,
0417                                         -15.5 * dPhiScale,
0418                                         15.5 * dPhiScale);
0419   ugmtMuonDPhivsPtBmtf->setAxisTitle("p_{T} [GeV]", 1);
0420   ugmtMuonDPhivsPtBmtf->setAxisTitle("#phi_{at vertex} - #phi", 2);
0421 
0422   ugmtMuonDEtavsPtOmtf = ibooker.book2D("ugmtMuonDEtavsPtOmtf",
0423                                         "uGMT output muon from OMTF #eta_{at vertex} - #eta_{at muon system} vs p_{T}",
0424                                         32,
0425                                         0,
0426                                         64,
0427                                         31,
0428                                         -15.5 * dEtaScale,
0429                                         15.5 * dEtaScale);
0430   ugmtMuonDEtavsPtOmtf->setAxisTitle("p_{T} [GeV]", 1);
0431   ugmtMuonDEtavsPtOmtf->setAxisTitle("#eta_{at vertex} - #eta", 2);
0432 
0433   ugmtMuonDPhivsPtOmtf = ibooker.book2D("ugmtMuonDPhivsPtOmtf",
0434                                         "uGMT output muon from OMTF #phi_{at vertex} - #phi_{at muon system} vs p_{T}",
0435                                         32,
0436                                         0,
0437                                         64,
0438                                         31,
0439                                         -15.5 * dPhiScale,
0440                                         15.5 * dPhiScale);
0441   ugmtMuonDPhivsPtOmtf->setAxisTitle("p_{T} [GeV]", 1);
0442   ugmtMuonDPhivsPtOmtf->setAxisTitle("#phi_{at vertex} - #phi", 2);
0443 
0444   ugmtMuonDEtavsPtEmtf = ibooker.book2D("ugmtMuonDEtavsPtEmtf",
0445                                         "uGMT output muon from EMTF #eta_{at vertex} - #eta_{at muon system} vs p_{T}",
0446                                         32,
0447                                         0,
0448                                         64,
0449                                         31,
0450                                         -15.5 * dEtaScale,
0451                                         15.5 * dEtaScale);
0452   ugmtMuonDEtavsPtEmtf->setAxisTitle("p_{T} [GeV]", 1);
0453   ugmtMuonDEtavsPtEmtf->setAxisTitle("#eta_{at vertex} - #eta", 2);
0454 
0455   ugmtMuonDPhivsPtEmtf = ibooker.book2D("ugmtMuonDPhivsPtEmtf",
0456                                         "uGMT output muon from EMTF #phi_{at vertex} - #phi_{at muon system} vs p_{T}",
0457                                         32,
0458                                         0,
0459                                         64,
0460                                         31,
0461                                         -15.5 * dPhiScale,
0462                                         15.5 * dPhiScale);
0463   ugmtMuonDPhivsPtEmtf->setAxisTitle("p_{T} [GeV]", 1);
0464   ugmtMuonDPhivsPtEmtf->setAxisTitle("#phi_{at vertex} - #phi", 2);
0465 
0466   ugmtMuonPtvsEta =
0467       ibooker.book2D("ugmtMuonPtvsEta", "uGMT output muon p_{T} vs #eta", 100, -2.5, 2.5, 128, -0.5, 255.5);
0468   ugmtMuonPtvsEta->setAxisTitle("#eta", 1);
0469   ugmtMuonPtvsEta->setAxisTitle("p_{T} [GeV]", 2);
0470 
0471   ugmtMuonPtvsPhi =
0472       ibooker.book2D("ugmtMuonPtvsPhi", "uGMT output muon p_{T} vs #phi", 64, -3.2, 3.2, 128, -0.5, 255.5);
0473   ugmtMuonPtvsPhi->setAxisTitle("#phi", 1);
0474   ugmtMuonPtvsPhi->setAxisTitle("p_{T} [GeV]", 2);
0475 
0476   ugmtMuonPhivsEta = ibooker.book2D("ugmtMuonPhivsEta", "uGMT output muon #phi vs #eta", 100, -2.5, 2.5, 64, -3.2, 3.2);
0477   ugmtMuonPhivsEta->setAxisTitle("#eta", 1);
0478   ugmtMuonPhivsEta->setAxisTitle("#phi", 2);
0479 
0480   ugmtMuonPhiAtVtxvsEtaAtVtx = ibooker.book2D(
0481       "ugmtMuonPhiAtVtxvsEtaAtVtx", "uGMT output muon #phi at vertex vs #eta at vertex", 100, -2.5, 2.5, 64, -3.2, 3.2);
0482   ugmtMuonPhiAtVtxvsEtaAtVtx->setAxisTitle("#eta at vertex", 1);
0483   ugmtMuonPhiAtVtxvsEtaAtVtx->setAxisTitle("#phi at vertex", 2);
0484 
0485   ugmtMuonBXvsLink =
0486       ibooker.book2D("ugmtMuonBXvsLink", "uGMT output muon BX vs Input Links", 36, 35.5, 71.5, 5, -2.5, 2.5);
0487   ugmtMuonBXvsLink->setAxisTitle("Muon Input Links", 1);
0488   for (int bin = 1; bin <= 6; ++bin) {
0489     ugmtMuonBXvsLink->setBinLabel(bin, Form("E+%d", bin), 1);
0490     ugmtMuonBXvsLink->setBinLabel(bin + 6, Form("O+%d", bin), 1);
0491     ugmtMuonBXvsLink->setBinLabel(bin + 12, Form("B%d", bin), 1);
0492     ugmtMuonBXvsLink->setBinLabel(bin + 18, Form("B%d", bin + 6), 1);
0493     ugmtMuonBXvsLink->setBinLabel(bin + 24, Form("O-%d", bin), 1);
0494     ugmtMuonBXvsLink->setBinLabel(bin + 30, Form("E-%d", bin), 1);
0495   }
0496   ugmtMuonBXvsLink->setAxisTitle("BX", 2);
0497 
0498   ugmtMuonChargevsLink =
0499       ibooker.book2D("ugmtMuonChargevsLink", "uGMT output muon Charge vs Input Links", 36, 35.5, 71.5, 3, -1.5, 1.5);
0500   ugmtMuonChargevsLink->setAxisTitle("Muon Input Links", 1);
0501   for (int bin = 1; bin <= 6; ++bin) {
0502     ugmtMuonChargevsLink->setBinLabel(bin, Form("E+%d", bin), 1);
0503     ugmtMuonChargevsLink->setBinLabel(bin + 6, Form("O+%d", bin), 1);
0504     ugmtMuonChargevsLink->setBinLabel(bin + 12, Form("B%d", bin), 1);
0505     ugmtMuonChargevsLink->setBinLabel(bin + 18, Form("B%d", bin + 6), 1);
0506     ugmtMuonChargevsLink->setBinLabel(bin + 24, Form("O-%d", bin), 1);
0507     ugmtMuonChargevsLink->setBinLabel(bin + 30, Form("E-%d", bin), 1);
0508   }
0509   ugmtMuonChargevsLink->setAxisTitle("Charge", 2);
0510 
0511   if (hadronicShowers_) {
0512     ugmtMuonShowerTypeOccupancyPerBx =
0513         ibooker.book2D("ugmtMuonShowerTypeOccupancyPerBx", "Shower type occupancy per BX", 7, -3.5, 3.5, 2, 1, 3);
0514     ugmtMuonShowerTypeOccupancyPerBx->setAxisTitle("BX", 1);
0515     ugmtMuonShowerTypeOccupancyPerBx->setAxisTitle("Shower type", 2);
0516     ugmtMuonShowerTypeOccupancyPerBx->setBinLabel(IDX_TIGHT_SHOWER, "Tight", 2);
0517     ugmtMuonShowerTypeOccupancyPerBx->setBinLabel(IDX_NOMINAL_SHOWER, "Nominal", 2);
0518   }
0519 
0520   ugmtMuonBXvshwPt =
0521       ibooker.book2D("ugmtMuonBXvshwPt", "uGMT output muon BX vs HW p_{T}", 128, -0.5, 511.5, 5, -2.5, 2.5);
0522   ugmtMuonBXvshwPt->setAxisTitle("Hardware p_{T}", 1);
0523   ugmtMuonBXvshwPt->setAxisTitle("BX", 2);
0524 
0525   ugmtMuonBXvshwEta =
0526       ibooker.book2D("ugmtMuonBXvshwEta", "uGMT output muon BX vs HW #eta", 93, -232.5, 232.5, 5, -2.5, 2.5);
0527   ugmtMuonBXvshwEta->setAxisTitle("Hardware #eta", 1);
0528   ugmtMuonBXvshwEta->setAxisTitle("BX", 2);
0529 
0530   ugmtMuonBXvshwPhi =
0531       ibooker.book2D("ugmtMuonBXvshwPhi", "uGMT output muon BX vs HW #phi", 116, -2.5, 577.5, 5, -2.5, 2.5);
0532   ugmtMuonBXvshwPhi->setAxisTitle("Hardware #phi", 1);
0533   ugmtMuonBXvshwPhi->setAxisTitle("BX", 2);
0534 
0535   ugmtMuonBXvshwCharge =
0536       ibooker.book2D("ugmtMuonBXvshwCharge", "uGMT output muon BX vs HW Charge", 2, -0.5, 1.5, 5, -2.5, 2.5);
0537   ugmtMuonBXvshwCharge->setAxisTitle("Hardware Charge", 1);
0538   ugmtMuonBXvshwCharge->setAxisTitle("BX", 2);
0539 
0540   ugmtMuonBXvshwChargeValid =
0541       ibooker.book2D("ugmtMuonBXvshwChargeValid", "uGMT output muon BX vs ChargeValid", 2, -0.5, 1.5, 5, -2.5, 2.5);
0542   ugmtMuonBXvshwChargeValid->setAxisTitle("ChargeValid", 1);
0543   ugmtMuonBXvshwChargeValid->setAxisTitle("BX", 2);
0544 
0545   ugmtMuonBXvshwQual =
0546       ibooker.book2D("ugmtMuonBXvshwQual", "uGMT output muon BX vs Quality", 16, -0.5, 15.5, 5, -2.5, 2.5);
0547   ugmtMuonBXvshwQual->setAxisTitle("Quality", 1);
0548   ugmtMuonBXvshwQual->setAxisTitle("BX", 2);
0549 
0550   ugmtMuonBXvshwIso =
0551       ibooker.book2D("ugmtMuonBXvshwIso", "uGMT output muon BX vs Isolation", 4, -0.5, 3.5, 5, -2.5, 2.5);
0552   ugmtMuonBXvshwIso->setAxisTitle("Isolation", 1);
0553   ugmtMuonBXvshwIso->setAxisTitle("BX", 2);
0554 
0555   // muon correlations
0556   ibooker.setCurrentFolder(monitorDir_ + "/muon_correlations");
0557 
0558   ugmtMuMuInvMass = ibooker.book1D("ugmtMuMuInvMass", "uGMT dimuon invariant mass", 200, 0., 200.);
0559   ugmtMuMuInvMass->setAxisTitle("m(#mu#mu) [GeV]", 1);
0560 
0561   ugmtMuMuInvMassAtVtx =
0562       ibooker.book1D("ugmtMuMuInvMassAtVtx", "uGMT dimuon invariant mass with coordinates at vertex", 200, 0., 200.);
0563   ugmtMuMuInvMassAtVtx->setAxisTitle("m(#mu#mu) [GeV]", 1);
0564 
0565   ugmtMuMuDEta = ibooker.book1D("ugmtMuMuDEta", "uGMT output muons #Delta#eta", 100, -1., 1.);
0566   ugmtMuMuDEta->setAxisTitle("#Delta#eta", 1);
0567 
0568   ugmtMuMuDPhi = ibooker.book1D("ugmtMuMuDPhi", "uGMT output muons #Delta#phi", 100, -1., 1.);
0569   ugmtMuMuDPhi->setAxisTitle("#Delta#phi", 1);
0570 
0571   ugmtMuMuDR = ibooker.book1D("ugmtMuMuDR", "uGMT output muons #DeltaR", 50, 0., 1.);
0572   ugmtMuMuDR->setAxisTitle("#DeltaR", 1);
0573 
0574   // barrel - overlap
0575   ugmtMuMuDEtaBOpos =
0576       ibooker.book1D("ugmtMuMuDEtaBOpos", "uGMT output muons #Delta#eta barrel-overlap positive side", 100, -1., 1.);
0577   ugmtMuMuDEtaBOpos->setAxisTitle("#Delta#eta", 1);
0578 
0579   ugmtMuMuDPhiBOpos =
0580       ibooker.book1D("ugmtMuMuDPhiBOpos", "uGMT output muons #Delta#phi barrel-overlap positive side", 100, -1., 1.);
0581   ugmtMuMuDPhiBOpos->setAxisTitle("#Delta#phi", 1);
0582 
0583   ugmtMuMuDRBOpos =
0584       ibooker.book1D("ugmtMuMuDRBOpos", "uGMT output muons #DeltaR barrel-overlap positive side", 50, 0., 1.);
0585   ugmtMuMuDRBOpos->setAxisTitle("#DeltaR", 1);
0586 
0587   ugmtMuMuDEtaBOneg =
0588       ibooker.book1D("ugmtMuMuDEtaBOneg", "uGMT output muons #Delta#eta barrel-overlap negative side", 100, -1., 1.);
0589   ugmtMuMuDEtaBOneg->setAxisTitle("#Delta#eta", 1);
0590 
0591   ugmtMuMuDPhiBOneg =
0592       ibooker.book1D("ugmtMuMuDPhiBOneg", "uGMT output muons #Delta#phi barrel-overlap negative side", 100, -1., 1.);
0593   ugmtMuMuDPhiBOneg->setAxisTitle("#Delta#phi", 1);
0594 
0595   ugmtMuMuDRBOneg =
0596       ibooker.book1D("ugmtMuMuDRBOneg", "uGMT output muons #DeltaR barrel-overlap negative side", 50, 0., 1.);
0597   ugmtMuMuDRBOneg->setAxisTitle("#DeltaR", 1);
0598 
0599   // endcap - overlap
0600   ugmtMuMuDEtaEOpos =
0601       ibooker.book1D("ugmtMuMuDEtaEOpos", "uGMT output muons #Delta#eta endcap-overlap positive side", 100, -1., 1.);
0602   ugmtMuMuDEtaEOpos->setAxisTitle("#Delta#eta", 1);
0603 
0604   ugmtMuMuDPhiEOpos =
0605       ibooker.book1D("ugmtMuMuDPhiEOpos", "uGMT output muons #Delta#phi endcap-overlap positive side", 100, -1., 1.);
0606   ugmtMuMuDPhiEOpos->setAxisTitle("#Delta#phi", 1);
0607 
0608   ugmtMuMuDREOpos =
0609       ibooker.book1D("ugmtMuMuDREOpos", "uGMT output muons #DeltaR endcap-overlap positive side", 50, 0., 1.);
0610   ugmtMuMuDREOpos->setAxisTitle("#DeltaR", 1);
0611 
0612   ugmtMuMuDEtaEOneg =
0613       ibooker.book1D("ugmtMuMuDEtaEOneg", "uGMT output muons #Delta#eta endcap-overlap negative side", 100, -1., 1.);
0614   ugmtMuMuDEtaEOneg->setAxisTitle("#Delta#eta", 1);
0615 
0616   ugmtMuMuDPhiEOneg =
0617       ibooker.book1D("ugmtMuMuDPhiEOneg", "uGMT output muons #Delta#phi endcap-overlap negative side", 100, -1., 1.);
0618   ugmtMuMuDPhiEOneg->setAxisTitle("#Delta#phi", 1);
0619 
0620   ugmtMuMuDREOneg =
0621       ibooker.book1D("ugmtMuMuDREOneg", "uGMT output muons #DeltaR endcap-overlap negative side", 50, 0., 1.);
0622   ugmtMuMuDREOneg->setAxisTitle("#DeltaR", 1);
0623 
0624   // barrel wedges
0625   ugmtMuMuDEtaB = ibooker.book1D("ugmtMuMuDEtaB", "uGMT output muons #Delta#eta between barrel wedges", 100, -1., 1.);
0626   ugmtMuMuDEtaB->setAxisTitle("#Delta#eta", 1);
0627 
0628   ugmtMuMuDPhiB = ibooker.book1D("ugmtMuMuDPhiB", "uGMT output muons #Delta#phi between barrel wedges", 100, -1., 1.);
0629   ugmtMuMuDPhiB->setAxisTitle("#Delta#phi", 1);
0630 
0631   ugmtMuMuDRB = ibooker.book1D("ugmtMuMuDRB", "uGMT output muons #DeltaR between barrel wedges", 50, 0., 1.);
0632   ugmtMuMuDRB->setAxisTitle("#DeltaR", 1);
0633 
0634   // overlap sectors
0635   ugmtMuMuDEtaOpos = ibooker.book1D(
0636       "ugmtMuMuDEtaOpos", "uGMT output muons #Delta#eta between overlap positive side sectors", 100, -1., 1.);
0637   ugmtMuMuDEtaOpos->setAxisTitle("#Delta#eta", 1);
0638 
0639   ugmtMuMuDPhiOpos = ibooker.book1D(
0640       "ugmtMuMuDPhiOpos", "uGMT output muons #Delta#phi between overlap positive side sectors", 100, -1., 1.);
0641   ugmtMuMuDPhiOpos->setAxisTitle("#Delta#phi", 1);
0642 
0643   ugmtMuMuDROpos =
0644       ibooker.book1D("ugmtMuMuDROpos", "uGMT output muons #DeltaR between overlap positive side sectors", 50, 0., 1.);
0645   ugmtMuMuDROpos->setAxisTitle("#DeltaR", 1);
0646 
0647   ugmtMuMuDEtaOneg = ibooker.book1D(
0648       "ugmtMuMuDEtaOneg", "uGMT output muons #Delta#eta between overlap negative side sectors", 100, -1., 1.);
0649   ugmtMuMuDEtaOneg->setAxisTitle("#Delta#eta", 1);
0650 
0651   ugmtMuMuDPhiOneg = ibooker.book1D(
0652       "ugmtMuMuDPhiOneg", "uGMT output muons #Delta#phi between overlap negative side sectors", 100, -1., 1.);
0653   ugmtMuMuDPhiOneg->setAxisTitle("#Delta#phi", 1);
0654 
0655   ugmtMuMuDROneg =
0656       ibooker.book1D("ugmtMuMuDROneg", "uGMT output muons #DeltaR between overlap negative side sectors", 50, 0., 1.);
0657   ugmtMuMuDROneg->setAxisTitle("#DeltaR", 1);
0658 
0659   // endcap sectors
0660   ugmtMuMuDEtaEpos = ibooker.book1D(
0661       "ugmtMuMuDEtaEpos", "uGMT output muons #Delta#eta between endcap positive side sectors", 100, -1., 1.);
0662   ugmtMuMuDEtaEpos->setAxisTitle("#Delta#eta", 1);
0663 
0664   ugmtMuMuDPhiEpos = ibooker.book1D(
0665       "ugmtMuMuDPhiEpos", "uGMT output muons #Delta#phi between endcap positive side sectors", 100, -1., 1.);
0666   ugmtMuMuDPhiEpos->setAxisTitle("#Delta#phi", 1);
0667 
0668   ugmtMuMuDREpos =
0669       ibooker.book1D("ugmtMuMuDREpos", "uGMT output muons #DeltaR between endcap positive side sectors", 50, 0., 1.);
0670   ugmtMuMuDREpos->setAxisTitle("#DeltaR", 1);
0671 
0672   ugmtMuMuDEtaEneg = ibooker.book1D(
0673       "ugmtMuMuDEtaEneg", "uGMT output muons #Delta#eta between endcap negative side sectors", 100, -1., 1.);
0674   ugmtMuMuDEtaEneg->setAxisTitle("#Delta#eta", 1);
0675 
0676   ugmtMuMuDPhiEneg = ibooker.book1D(
0677       "ugmtMuMuDPhiEneg", "uGMT output muons #Delta#phi between endcap negative side sectors", 100, -1., 1.);
0678   ugmtMuMuDPhiEneg->setAxisTitle("#Delta#phi", 1);
0679 
0680   ugmtMuMuDREneg =
0681       ibooker.book1D("ugmtMuMuDREneg", "uGMT output muons #DeltaR between endcap negative side sectors", 50, 0., 1.);
0682   ugmtMuMuDREneg->setAxisTitle("#DeltaR", 1);
0683 }
0684 
0685 void L1TStage2uGMT::analyze(const edm::Event& e, const edm::EventSetup& c) {
0686   if (verbose_)
0687     edm::LogInfo("L1TStage2uGMT") << "L1TStage2uGMT: analyze..." << std::endl;
0688 
0689   if (!emul_) {
0690     edm::Handle<l1t::RegionalMuonCandBxCollection> BMTFBxCollection;
0691     e.getByToken(ugmtBMTFToken_, BMTFBxCollection);
0692 
0693     ugmtBMTFnMuons->Fill(BMTFBxCollection->size(0));
0694 
0695     for (int itBX = BMTFBxCollection->getFirstBX(); itBX <= BMTFBxCollection->getLastBX(); ++itBX) {
0696       for (l1t::RegionalMuonCandBxCollection::const_iterator BMTF = BMTFBxCollection->begin(itBX);
0697            BMTF != BMTFBxCollection->end(itBX);
0698            ++BMTF) {
0699         ugmtBMTFhwPt->Fill(BMTF->hwPt());
0700         if (displacedQuantities_) {
0701           ugmtBMTFhwPtUnconstrained->Fill(BMTF->hwPtUnconstrained());
0702           ugmtBMTFhwDXY->Fill(BMTF->hwDXY());
0703         }
0704         ugmtBMTFhwEta->Fill(BMTF->hwEta());
0705         ugmtBMTFhwPhi->Fill(BMTF->hwPhi());
0706         ugmtBMTFhwSign->Fill(BMTF->hwSign());
0707         ugmtBMTFhwSignValid->Fill(BMTF->hwSignValid());
0708         ugmtBMTFhwQual->Fill(BMTF->hwQual());
0709         ugmtBMTFlink->Fill(BMTF->link());
0710 
0711         int global_hw_phi =
0712             l1t::MicroGMTConfiguration::calcGlobalPhi(BMTF->hwPhi(), BMTF->trackFinderType(), BMTF->processor());
0713         ugmtBMTFglbPhi->Fill(global_hw_phi);
0714 
0715         ugmtBMTFProcvshwPhi->Fill(BMTF->hwPhi(), BMTF->processor());
0716 
0717         // Analyse muon correlations
0718         for (l1t::RegionalMuonCandBxCollection::const_iterator BMTF2 = BMTF + 1; BMTF2 != BMTFBxCollection->end(itBX);
0719              ++BMTF2) {
0720           int global_hw_phi2 =
0721               l1t::MicroGMTConfiguration::calcGlobalPhi(BMTF2->hwPhi(), BMTF2->trackFinderType(), BMTF2->processor());
0722           float dEta = (BMTF->hwEta() - BMTF2->hwEta()) * etaScale_;
0723           float dPhi = (global_hw_phi - global_hw_phi2) * phiScale_;
0724           float dR = sqrt(dEta * dEta + dPhi * dPhi);
0725 
0726           int dLink = std::abs(BMTF->link() - BMTF2->link());
0727           if (dLink == 1 || dLink == 11) {  // two adjacent wedges and wrap around
0728             ugmtBMTFMuMuDEta->Fill(dEta);
0729             ugmtBMTFMuMuDPhi->Fill(dPhi);
0730             ugmtBMTFMuMuDR->Fill(dR);
0731           }
0732         }
0733       }
0734     }
0735 
0736     edm::Handle<l1t::RegionalMuonCandBxCollection> OMTFBxCollection;
0737     e.getByToken(ugmtOMTFToken_, OMTFBxCollection);
0738 
0739     ugmtOMTFnMuons->Fill(OMTFBxCollection->size(0));
0740 
0741     for (int itBX = OMTFBxCollection->getFirstBX(); itBX <= OMTFBxCollection->getLastBX(); ++itBX) {
0742       for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF = OMTFBxCollection->begin(itBX);
0743            OMTF != OMTFBxCollection->end(itBX);
0744            ++OMTF) {
0745         ugmtOMTFhwPt->Fill(OMTF->hwPt());
0746         ugmtOMTFhwEta->Fill(OMTF->hwEta());
0747         ugmtOMTFhwSign->Fill(OMTF->hwSign());
0748         ugmtOMTFhwSignValid->Fill(OMTF->hwSignValid());
0749         ugmtOMTFhwQual->Fill(OMTF->hwQual());
0750         ugmtOMTFlink->Fill(OMTF->link());
0751 
0752         int global_hw_phi =
0753             l1t::MicroGMTConfiguration::calcGlobalPhi(OMTF->hwPhi(), OMTF->trackFinderType(), OMTF->processor());
0754 
0755         l1t::tftype trackFinderType = OMTF->trackFinderType();
0756 
0757         if (trackFinderType == l1t::omtf_neg) {
0758           ugmtOMTFhwPhiNeg->Fill(OMTF->hwPhi());
0759           ugmtOMTFglbPhiNeg->Fill(global_hw_phi);
0760           ugmtOMTFProcvshwPhiNeg->Fill(OMTF->hwPhi(), OMTF->processor());
0761         } else {
0762           ugmtOMTFhwPhiPos->Fill(OMTF->hwPhi());
0763           ugmtOMTFglbPhiPos->Fill(global_hw_phi);
0764           ugmtOMTFProcvshwPhiPos->Fill(OMTF->hwPhi(), OMTF->processor());
0765         }
0766 
0767         // Analyse muon correlations
0768         for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF2 = OMTF + 1; OMTF2 != OMTFBxCollection->end(itBX);
0769              ++OMTF2) {
0770           int global_hw_phi2 =
0771               l1t::MicroGMTConfiguration::calcGlobalPhi(OMTF2->hwPhi(), OMTF2->trackFinderType(), OMTF2->processor());
0772           float dEta = (OMTF->hwEta() - OMTF2->hwEta()) * etaScale_;
0773           float dPhi = (global_hw_phi - global_hw_phi2) * phiScale_;
0774           float dR = sqrt(dEta * dEta + dPhi * dPhi);
0775 
0776           int dLink = std::abs(OMTF->link() - OMTF2->link());
0777           if (dLink == 1 || dLink == 5) {  // two adjacent sectors and wrap around
0778             ugmtOMTFMuMuDEta->Fill(dEta);
0779             ugmtOMTFMuMuDPhi->Fill(dPhi);
0780             ugmtOMTFMuMuDR->Fill(dR);
0781           }
0782         }
0783       }
0784     }
0785 
0786     edm::Handle<l1t::RegionalMuonCandBxCollection> EMTFBxCollection;
0787     e.getByToken(ugmtEMTFToken_, EMTFBxCollection);
0788 
0789     ugmtEMTFnMuons->Fill(EMTFBxCollection->size(0));
0790 
0791     for (int itBX = EMTFBxCollection->getFirstBX(); itBX <= EMTFBxCollection->getLastBX(); ++itBX) {
0792       for (l1t::RegionalMuonCandBxCollection::const_iterator EMTF = EMTFBxCollection->begin(itBX);
0793            EMTF != EMTFBxCollection->end(itBX);
0794            ++EMTF) {
0795         ugmtEMTFhwPt->Fill(EMTF->hwPt());
0796         if (displacedQuantities_) {
0797           ugmtEMTFhwPtUnconstrained->Fill(EMTF->hwPtUnconstrained());
0798           ugmtEMTFhwDXY->Fill(EMTF->hwDXY());
0799         }
0800         ugmtEMTFhwEta->Fill(EMTF->hwEta());
0801         ugmtEMTFhwSign->Fill(EMTF->hwSign());
0802         ugmtEMTFhwSignValid->Fill(EMTF->hwSignValid());
0803         ugmtEMTFhwQual->Fill(EMTF->hwQual());
0804         ugmtEMTFlink->Fill(EMTF->link());
0805 
0806         int global_hw_phi =
0807             l1t::MicroGMTConfiguration::calcGlobalPhi(EMTF->hwPhi(), EMTF->trackFinderType(), EMTF->processor());
0808 
0809         l1t::tftype trackFinderType = EMTF->trackFinderType();
0810 
0811         if (trackFinderType == l1t::emtf_neg) {
0812           ugmtEMTFhwPhiNeg->Fill(EMTF->hwPhi());
0813           ugmtEMTFglbPhiNeg->Fill(global_hw_phi);
0814           ugmtEMTFProcvshwPhiNeg->Fill(EMTF->hwPhi(), EMTF->processor());
0815         } else {
0816           ugmtEMTFhwPhiPos->Fill(EMTF->hwPhi());
0817           ugmtEMTFglbPhiPos->Fill(global_hw_phi);
0818           ugmtEMTFProcvshwPhiPos->Fill(EMTF->hwPhi(), EMTF->processor());
0819         }
0820 
0821         // Analyse muon correlations
0822         for (l1t::RegionalMuonCandBxCollection::const_iterator EMTF2 = EMTF + 1; EMTF2 != EMTFBxCollection->end(itBX);
0823              ++EMTF2) {
0824           int global_hw_phi2 =
0825               l1t::MicroGMTConfiguration::calcGlobalPhi(EMTF2->hwPhi(), EMTF2->trackFinderType(), EMTF2->processor());
0826           float dEta = (EMTF->hwEta() - EMTF2->hwEta()) * etaScale_;
0827           float dPhi = (global_hw_phi - global_hw_phi2) * phiScale_;
0828           float dR = sqrt(dEta * dEta + dPhi * dPhi);
0829 
0830           int dLink = std::abs(EMTF->link() - EMTF2->link());
0831           if (dLink == 1 || dLink == 5) {  // two adjacent sectors and wrap around
0832             ugmtEMTFMuMuDEta->Fill(dEta);
0833             ugmtEMTFMuMuDPhi->Fill(dPhi);
0834             ugmtEMTFMuMuDR->Fill(dR);
0835           }
0836         }
0837       }
0838     }
0839 
0840     // Fill shower plots
0841     if (hadronicShowers_) {
0842       edm::Handle<l1t::RegionalMuonShowerBxCollection> EMTFShowersBxCollection;
0843       e.getByToken(ugmtEMTFShowerToken_, EMTFShowersBxCollection);
0844 
0845       for (int itBX = EMTFShowersBxCollection->getFirstBX(); itBX <= EMTFShowersBxCollection->getLastBX(); ++itBX) {
0846         for (l1t::RegionalMuonShowerBxCollection::const_iterator shower = EMTFShowersBxCollection->begin(itBX);
0847              shower != EMTFShowersBxCollection->end(itBX);
0848              ++shower) {
0849           if (not shower->isValid()) {
0850             continue;
0851           }
0852           if (shower->isOneNominalInTime()) {
0853             ugmtEMTFShowerTypeOccupancyPerSector->Fill(
0854                 shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0),
0855                 IDX_NOMINAL_SHOWER);
0856           }
0857           if (shower->isOneTightInTime()) {
0858             ugmtEMTFShowerTypeOccupancyPerSector->Fill(
0859                 shower->processor() + 1 + (shower->trackFinderType() == l1t::tftype::emtf_pos ? 6 : 0),
0860                 IDX_TIGHT_SHOWER);
0861           }
0862         }
0863       }
0864     }
0865 
0866     // barrel-overlap muon correlations
0867     int firstBxBO = (BMTFBxCollection->getFirstBX() < OMTFBxCollection->getFirstBX()) ? OMTFBxCollection->getFirstBX()
0868                                                                                       : BMTFBxCollection->getFirstBX();
0869     int lastBxBO = (BMTFBxCollection->getLastBX() > OMTFBxCollection->getLastBX()) ? OMTFBxCollection->getLastBX()
0870                                                                                    : BMTFBxCollection->getLastBX();
0871     for (int itBX = firstBxBO; itBX <= lastBxBO; ++itBX) {
0872       if (BMTFBxCollection->size(itBX) < 1 || OMTFBxCollection->size(itBX) < 1) {
0873         continue;
0874       }
0875       for (l1t::RegionalMuonCandBxCollection::const_iterator BMTF = BMTFBxCollection->begin(itBX);
0876            BMTF != BMTFBxCollection->end(itBX);
0877            ++BMTF) {
0878         int global_hw_phi_bmtf =
0879             l1t::MicroGMTConfiguration::calcGlobalPhi(BMTF->hwPhi(), BMTF->trackFinderType(), BMTF->processor());
0880 
0881         for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF = OMTFBxCollection->begin(itBX);
0882              OMTF != OMTFBxCollection->end(itBX);
0883              ++OMTF) {
0884           int global_hw_phi_omtf =
0885               l1t::MicroGMTConfiguration::calcGlobalPhi(OMTF->hwPhi(), OMTF->trackFinderType(), OMTF->processor());
0886           float dEta = (BMTF->hwEta() - OMTF->hwEta()) * etaScale_;
0887           float dPhi = (global_hw_phi_bmtf - global_hw_phi_omtf) * phiScale_;
0888           float dR = sqrt(dEta * dEta + dPhi * dPhi);
0889           if (OMTF->trackFinderType() == l1t::omtf_neg) {
0890             ugmtBOMTFnegMuMuDEta->Fill(dEta);
0891             ugmtBOMTFnegMuMuDPhi->Fill(dPhi);
0892             ugmtBOMTFnegMuMuDR->Fill(dR);
0893           } else {
0894             ugmtBOMTFposMuMuDEta->Fill(dEta);
0895             ugmtBOMTFposMuMuDPhi->Fill(dPhi);
0896             ugmtBOMTFposMuMuDR->Fill(dR);
0897           }
0898         }
0899       }
0900     }
0901 
0902     // endcap-overlap muon correlations
0903     int firstBxEO = (EMTFBxCollection->getFirstBX() < OMTFBxCollection->getFirstBX()) ? OMTFBxCollection->getFirstBX()
0904                                                                                       : EMTFBxCollection->getFirstBX();
0905     int lastBxEO = (EMTFBxCollection->getLastBX() > OMTFBxCollection->getLastBX()) ? OMTFBxCollection->getLastBX()
0906                                                                                    : EMTFBxCollection->getLastBX();
0907     for (int itBX = firstBxEO; itBX <= lastBxEO; ++itBX) {
0908       if (EMTFBxCollection->size(itBX) < 1 || OMTFBxCollection->size(itBX) < 1) {
0909         continue;
0910       }
0911       for (l1t::RegionalMuonCandBxCollection::const_iterator EMTF = EMTFBxCollection->begin(itBX);
0912            EMTF != EMTFBxCollection->end(itBX);
0913            ++EMTF) {
0914         int global_hw_phi_emtf =
0915             l1t::MicroGMTConfiguration::calcGlobalPhi(EMTF->hwPhi(), EMTF->trackFinderType(), EMTF->processor());
0916 
0917         for (l1t::RegionalMuonCandBxCollection::const_iterator OMTF = OMTFBxCollection->begin(itBX);
0918              OMTF != OMTFBxCollection->end(itBX);
0919              ++OMTF) {
0920           int global_hw_phi_omtf =
0921               l1t::MicroGMTConfiguration::calcGlobalPhi(OMTF->hwPhi(), OMTF->trackFinderType(), OMTF->processor());
0922           float dEta = (EMTF->hwEta() - OMTF->hwEta()) * etaScale_;
0923           float dPhi = (global_hw_phi_emtf - global_hw_phi_omtf) * phiScale_;
0924           float dR = sqrt(dEta * dEta + dPhi * dPhi);
0925           if (EMTF->trackFinderType() == l1t::emtf_neg && OMTF->trackFinderType() == l1t::omtf_neg) {
0926             ugmtEOMTFnegMuMuDEta->Fill(dEta);
0927             ugmtEOMTFnegMuMuDPhi->Fill(dPhi);
0928             ugmtEOMTFnegMuMuDR->Fill(dR);
0929           } else if (EMTF->trackFinderType() == l1t::emtf_pos && OMTF->trackFinderType() == l1t::omtf_pos) {
0930             ugmtEOMTFposMuMuDEta->Fill(dEta);
0931             ugmtEOMTFposMuMuDPhi->Fill(dPhi);
0932             ugmtEOMTFposMuMuDR->Fill(dR);
0933           }
0934         }
0935       }
0936     }
0937   }
0938 
0939   edm::Handle<l1t::MuonBxCollection> MuonBxCollection;
0940   e.getByToken(ugmtMuonToken_, MuonBxCollection);
0941 
0942   ugmtnMuons->Fill(MuonBxCollection->size(0));
0943 
0944   for (int itBX = MuonBxCollection->getFirstBX(); itBX <= MuonBxCollection->getLastBX(); ++itBX) {
0945     for (l1t::MuonBxCollection::const_iterator Muon = MuonBxCollection->begin(itBX);
0946          Muon != MuonBxCollection->end(itBX);
0947          ++Muon) {
0948       int tfMuonIndex = Muon->tfMuonIndex();
0949 
0950       ugmtMuonBX->Fill(itBX);
0951       ugmtMuonIndex->Fill(tfMuonIndex);
0952       ugmtMuonhwPt->Fill(Muon->hwPt());
0953       if (displacedQuantities_) {
0954         ugmtMuonhwPtUnconstrained->Fill(Muon->hwPtUnconstrained());
0955         ugmtMuonhwDXY->Fill(Muon->hwDXY());
0956       }
0957       ugmtMuonhwEta->Fill(Muon->hwEta());
0958       ugmtMuonhwPhi->Fill(Muon->hwPhi());
0959       ugmtMuonhwEtaAtVtx->Fill(Muon->hwEtaAtVtx());
0960       ugmtMuonhwPhiAtVtx->Fill(Muon->hwPhiAtVtx());
0961       ugmtMuonhwCharge->Fill(Muon->hwCharge());
0962       ugmtMuonhwChargeValid->Fill(Muon->hwChargeValid());
0963       ugmtMuonhwQual->Fill(Muon->hwQual());
0964       ugmtMuonhwIso->Fill(Muon->hwIso());
0965 
0966       ugmtMuonPt->Fill(Muon->pt());
0967       if (displacedQuantities_) {
0968         ugmtMuonPtUnconstrained->Fill(Muon->ptUnconstrained());
0969       }
0970       ugmtMuonEta->Fill(Muon->eta());
0971       ugmtMuonPhi->Fill(Muon->phi());
0972       ugmtMuonEtaAtVtx->Fill(Muon->etaAtVtx());
0973       ugmtMuonPhiAtVtx->Fill(Muon->phiAtVtx());
0974       ugmtMuonCharge->Fill(Muon->charge());
0975 
0976       l1t::tftype tfType{getTfOrigin(tfMuonIndex)};
0977       if (tfType == l1t::emtf_pos || tfType == l1t::emtf_neg) {
0978         ugmtMuonPhiEmtf->Fill(Muon->phi());
0979         ugmtMuonDEtavsPtEmtf->Fill(Muon->pt(), Muon->hwDEtaExtra() * etaScale_);
0980         ugmtMuonDPhivsPtEmtf->Fill(Muon->pt(), Muon->hwDPhiExtra() * phiScale_);
0981       } else if (tfType == l1t::omtf_pos || tfType == l1t::omtf_neg) {
0982         ugmtMuonPhiOmtf->Fill(Muon->phi());
0983         ugmtMuonDEtavsPtOmtf->Fill(Muon->pt(), Muon->hwDEtaExtra() * etaScale_);
0984         ugmtMuonDPhivsPtOmtf->Fill(Muon->pt(), Muon->hwDPhiExtra() * phiScale_);
0985       } else if (tfType == l1t::bmtf) {
0986         ugmtMuonPhiBmtf->Fill(Muon->phi());
0987         ugmtMuonDEtavsPtBmtf->Fill(Muon->pt(), Muon->hwDEtaExtra() * etaScale_);
0988         ugmtMuonDPhivsPtBmtf->Fill(Muon->pt(), Muon->hwDPhiExtra() * phiScale_);
0989       }
0990 
0991       ugmtMuonPtvsEta->Fill(Muon->eta(), Muon->pt());
0992       ugmtMuonPtvsPhi->Fill(Muon->phi(), Muon->pt());
0993       ugmtMuonPhivsEta->Fill(Muon->eta(), Muon->phi());
0994 
0995       ugmtMuonPhiAtVtxvsEtaAtVtx->Fill(Muon->etaAtVtx(), Muon->phiAtVtx());
0996 
0997       ugmtMuonBXvsLink->Fill(int(Muon->tfMuonIndex() / 3.) + 36, itBX);
0998       ugmtMuonBXvshwPt->Fill(Muon->hwPt(), itBX);
0999       ugmtMuonBXvshwEta->Fill(Muon->hwEta(), itBX);
1000       ugmtMuonBXvshwPhi->Fill(Muon->hwPhi(), itBX);
1001       ugmtMuonBXvshwCharge->Fill(Muon->hwCharge(), itBX);
1002       ugmtMuonBXvshwChargeValid->Fill(Muon->hwChargeValid(), itBX);
1003       ugmtMuonBXvshwQual->Fill(Muon->hwQual(), itBX);
1004       ugmtMuonBXvshwIso->Fill(Muon->hwIso(), itBX);
1005       ugmtMuonChargevsLink->Fill(int(Muon->tfMuonIndex() / 3.) + 36, Muon->charge());
1006 
1007       int link = (int)std::floor(tfMuonIndex / 3.);
1008       reco::Candidate::PolarLorentzVector mu1{Muon->pt(), Muon->eta(), Muon->phi(), 0.106};
1009       reco::Candidate::PolarLorentzVector muAtVtx1{Muon->pt(), Muon->etaAtVtx(), Muon->phiAtVtx(), 0.106};
1010 
1011       // Analyse multi muon events
1012       for (l1t::MuonBxCollection::const_iterator Muon2 = Muon + 1; Muon2 != MuonBxCollection->end(itBX); ++Muon2) {
1013         reco::Candidate::PolarLorentzVector mu2{Muon2->pt(), Muon2->eta(), Muon2->phi(), 0.106};
1014         reco::Candidate::PolarLorentzVector muAtVtx2{Muon2->pt(), Muon2->etaAtVtx(), Muon2->phiAtVtx(), 0.106};
1015         ugmtMuMuInvMass->Fill((mu1 + mu2).M());
1016         ugmtMuMuInvMassAtVtx->Fill((muAtVtx1 + muAtVtx2).M());
1017 
1018         float dEta = Muon->eta() - Muon2->eta();
1019         float dPhi = Muon->phi() - Muon2->phi();
1020         float dR = sqrt(dEta * dEta + dPhi * dPhi);
1021         ugmtMuMuDEta->Fill(dEta);
1022         ugmtMuMuDPhi->Fill(dPhi);
1023         ugmtMuMuDR->Fill(dR);
1024 
1025         // muon distances between muons from different TFs and from different wedges/sectors of one TF
1026         int link2 = (int)std::floor(Muon2->tfMuonIndex() / 3.);
1027         l1t::tftype tfType2{getTfOrigin(Muon2->tfMuonIndex())};
1028         if ((tfType == l1t::bmtf && tfType2 == l1t::omtf_pos) || (tfType == l1t::omtf_pos && tfType2 == l1t::bmtf)) {
1029           ugmtMuMuDEtaBOpos->Fill(dEta);
1030           ugmtMuMuDPhiBOpos->Fill(dPhi);
1031           ugmtMuMuDRBOpos->Fill(dR);
1032         } else if ((tfType == l1t::bmtf && tfType2 == l1t::omtf_neg) ||
1033                    (tfType == l1t::omtf_neg && tfType2 == l1t::bmtf)) {
1034           ugmtMuMuDEtaBOneg->Fill(dEta);
1035           ugmtMuMuDPhiBOneg->Fill(dPhi);
1036           ugmtMuMuDRBOneg->Fill(dR);
1037         } else if ((tfType == l1t::emtf_pos && tfType2 == l1t::omtf_pos) ||
1038                    (tfType == l1t::omtf_pos && tfType2 == l1t::emtf_pos)) {
1039           ugmtMuMuDEtaEOpos->Fill(dEta);
1040           ugmtMuMuDPhiEOpos->Fill(dPhi);
1041           ugmtMuMuDREOpos->Fill(dR);
1042         } else if ((tfType == l1t::emtf_neg && tfType2 == l1t::omtf_neg) ||
1043                    (tfType == l1t::omtf_neg && tfType2 == l1t::emtf_neg)) {
1044           ugmtMuMuDEtaEOneg->Fill(dEta);
1045           ugmtMuMuDPhiEOneg->Fill(dPhi);
1046           ugmtMuMuDREOneg->Fill(dR);
1047         } else if (tfType == l1t::bmtf && tfType2 == l1t::bmtf) {
1048           if (std::abs(link - link2) == 1 || (std::abs(link - link2) == 11)) {  // two adjacent wedges and wrap around
1049             ugmtMuMuDEtaB->Fill(dEta);
1050             ugmtMuMuDPhiB->Fill(dPhi);
1051             ugmtMuMuDRB->Fill(dR);
1052           }
1053         } else if (tfType == l1t::omtf_pos && tfType2 == l1t::omtf_pos) {
1054           if (std::abs(link - link2) == 1 || (std::abs(link - link2) == 5)) {  // two adjacent sectors and wrap around
1055             ugmtMuMuDEtaOpos->Fill(dEta);
1056             ugmtMuMuDPhiOpos->Fill(dPhi);
1057             ugmtMuMuDROpos->Fill(dR);
1058           }
1059         } else if (tfType == l1t::omtf_neg && tfType2 == l1t::omtf_neg) {
1060           if (std::abs(link - link2) == 1 || (std::abs(link - link2) == 5)) {  // two adjacent sectors and wrap around
1061             ugmtMuMuDEtaOneg->Fill(dEta);
1062             ugmtMuMuDPhiOneg->Fill(dPhi);
1063             ugmtMuMuDROneg->Fill(dR);
1064           }
1065         } else if (tfType == l1t::emtf_pos && tfType2 == l1t::emtf_pos) {
1066           if (std::abs(link - link2) == 1 || (std::abs(link - link2) == 5)) {  // two adjacent sectors and wrap around
1067             ugmtMuMuDEtaEpos->Fill(dEta);
1068             ugmtMuMuDPhiEpos->Fill(dPhi);
1069             ugmtMuMuDREpos->Fill(dR);
1070           }
1071         } else if (tfType == l1t::emtf_neg && tfType2 == l1t::emtf_neg) {
1072           if (std::abs(link - link2) == 1 || (std::abs(link - link2) == 5)) {  // two adjacent sectors and wrap around
1073             ugmtMuMuDEtaEneg->Fill(dEta);
1074             ugmtMuMuDPhiEneg->Fill(dPhi);
1075             ugmtMuMuDREneg->Fill(dR);
1076           }
1077         }
1078       }
1079     }
1080   }
1081   // Fill shower plots
1082   if (hadronicShowers_) {
1083     edm::Handle<l1t::MuonShowerBxCollection> showersBxCollection;
1084     e.getByToken(ugmtMuonShowerToken_, showersBxCollection);
1085 
1086     for (int itBX = showersBxCollection->getFirstBX(); itBX <= showersBxCollection->getLastBX(); ++itBX) {
1087       for (l1t::MuonShowerBxCollection::const_iterator shower = showersBxCollection->begin(itBX);
1088            shower != showersBxCollection->end(itBX);
1089            ++shower) {
1090         if (not shower->isValid()) {
1091           continue;
1092         }
1093         if (shower->isOneNominalInTime()) {
1094           ugmtMuonShowerTypeOccupancyPerBx->Fill(itBX, IDX_NOMINAL_SHOWER);
1095         }
1096         if (shower->isOneTightInTime()) {
1097           ugmtMuonShowerTypeOccupancyPerBx->Fill(itBX, IDX_TIGHT_SHOWER);
1098         }
1099       }
1100     }
1101   }
1102 }
1103 
1104 l1t::tftype L1TStage2uGMT::getTfOrigin(const int tfMuonIndex) {
1105   if (tfMuonIndex >= 0 && tfMuonIndex <= 17) {
1106     return l1t::emtf_pos;
1107   } else if (tfMuonIndex >= 90 && tfMuonIndex <= 107) {
1108     return l1t::emtf_neg;
1109   } else if (tfMuonIndex >= 18 && tfMuonIndex <= 35) {
1110     return l1t::omtf_pos;
1111   } else if (tfMuonIndex >= 72 && tfMuonIndex <= 89) {
1112     return l1t::omtf_neg;
1113   } else {
1114     return l1t::bmtf;
1115   }
1116 }