Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-24 22:38:21

0001 /*
0002  * \file L1TCSCTF.cc
0003  *
0004  * \author J. Berryhill
0005  *
0006  */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TCSCTF.h"
0009 #include "DQMServices/Core/interface/DQMStore.h"
0010 
0011 // includes to fetch all reguired data products from the edm::Event
0012 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0013 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
0014 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCStatusDigiCollection.h"
0015 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0016 
0017 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0018 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0019 
0020 using namespace std;
0021 using namespace edm;
0022 
0023 L1TCSCTF::L1TCSCTF(const ParameterSet& ps)
0024     // if some piece of data is absent - configure corresponding source with 'null:'
0025     //  : csctfSource_( ps.getParameter< InputTag >("csctfSource") )
0026     : gmtProducer(ps.getParameter<InputTag>("gmtProducer")),
0027       lctProducer(ps.getParameter<InputTag>("lctProducer")),
0028       trackProducer(ps.getParameter<InputTag>("trackProducer")),
0029       statusProducer(ps.getParameter<InputTag>("statusProducer")),
0030       mbProducer(ps.getParameter<InputTag>("mbProducer")),
0031       l1muTscalesToken_(esConsumes()),
0032       ptscalesToken_(esConsumes()) {
0033   // verbosity switch
0034   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0035 
0036   if (verbose_)
0037     edm::LogInfo("DataNotFound") << "L1TCSCTF: constructor...." << endl;
0038 
0039   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
0040   if (!outputFile_.empty()) {
0041     edm::LogInfo("DataNotFound") << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
0042   }
0043 
0044   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
0045   if (disable) {
0046     outputFile_ = "";
0047   }
0048 
0049   gangedME11a_ = ps.getUntrackedParameter<bool>("gangedME11a", false);
0050 
0051   // instantiate standard on-fly SR LUTs from CSC TF emulator package
0052   bzero(srLUTs_, sizeof(srLUTs_));
0053   //int sector=1;    // assume SR LUTs are all same for every sector
0054   bool TMB07 = true;  // specific TMB firmware
0055   // Create a pset for SR/PT LUTs: if you do not change the value in the
0056   // configuration file, it will load the default minitLUTs
0057   edm::ParameterSet srLUTset;
0058   srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
0059   srLUTset.addUntrackedParameter<bool>("Binary", false);
0060   srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
0061 
0062   // positive endcap
0063   int endcap = 1;
0064   for (int sector = 0; sector < 6; sector++) {
0065     for (int station = 1, fpga = 0; station <= 4 && fpga < 5; station++) {
0066       if (station == 1)
0067         for (int subSector = 0; subSector < 2 && fpga < 5; subSector++)
0068           srLUTs_[fpga++][1][sector] =
0069               new CSCSectorReceiverLUT(endcap, sector + 1, subSector + 1, station, srLUTset, TMB07);
0070       else
0071         srLUTs_[fpga++][1][sector] = new CSCSectorReceiverLUT(endcap, sector + 1, 0, station, srLUTset, TMB07);
0072     }
0073   }
0074 
0075   // negative endcap
0076   endcap = 2;
0077   for (int sector = 0; sector < 6; sector++) {
0078     for (int station = 1, fpga = 0; station <= 4 && fpga < 5; station++) {
0079       if (station == 1)
0080         for (int subSector = 0; subSector < 2 && fpga < 5; subSector++)
0081           srLUTs_[fpga++][0][sector] =
0082               new CSCSectorReceiverLUT(endcap, sector + 1, subSector + 1, station, srLUTset, TMB07);
0083       else
0084         srLUTs_[fpga++][0][sector] = new CSCSectorReceiverLUT(endcap, sector + 1, 0, station, srLUTset, TMB07);
0085     }
0086   }
0087 
0088   //set Token(-s)
0089   edm::InputTag statusTag_(statusProducer.label(), statusProducer.instance());
0090   edm::InputTag corrlctsTag_(lctProducer.label(), lctProducer.instance());
0091   edm::InputTag tracksTag_(trackProducer.label(), trackProducer.instance());
0092   edm::InputTag dtStubsTag_(mbProducer.label(), mbProducer.instance());
0093   edm::InputTag mbtracksTag_(trackProducer.label(), trackProducer.instance());
0094 
0095   gmtProducerToken_ = consumes<L1MuGMTReadoutCollection>(ps.getParameter<InputTag>("gmtProducer"));
0096   statusToken_ = consumes<L1CSCStatusDigiCollection>(statusTag_);
0097   corrlctsToken_ = consumes<CSCCorrelatedLCTDigiCollection>(corrlctsTag_);
0098   tracksToken_ = consumes<L1CSCTrackCollection>(tracksTag_);
0099   dtStubsToken_ = consumes<CSCTriggerContainer<csctf::TrackStub> >(dtStubsTag_);
0100   mbtracksToken_ = consumes<L1CSCTrackCollection>(mbtracksTag_);
0101 }
0102 
0103 L1TCSCTF::~L1TCSCTF() {
0104   for (unsigned int j = 0; j < 2; j++)
0105     for (unsigned int i = 0; i < 5; i++)
0106       for (unsigned int s = 0; s < 6; s++)
0107         delete srLUTs_[i][j][s];  //free the array of pointers
0108 }
0109 
0110 void L1TCSCTF::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0111   m_scalesCacheID = -999;
0112   m_ptScaleCacheID = -999;
0113 
0114   nev_ = 0;
0115   ibooker.setCurrentFolder("L1T/L1TCSCTF");
0116 
0117   //  Error counting histogram:
0118   //  1) checks TF data integrity (error rate - first bin),
0119   //  2) monitors sychronization on input links (4 errors types: SE/SM/BX/AF; ORed for all time bins, links, and SPs),
0120   //  3) reports FMM status (if in any SP FMM status != "Ready" - fill the last bin)
0121   csctferrors = ibooker.book1D("CSCTF_errors", "CSCTF Errors", 6, 0, 6);
0122   csctferrors->setAxisTitle("Error type", 1);
0123   csctferrors->setAxisTitle("Number of Errors", 2);
0124   csctferrors->setBinLabel(1, "Corruptions", 1);
0125   csctferrors->setBinLabel(2, "Synch. Err.", 1);
0126   csctferrors->setBinLabel(3, "Synch. Mod.", 1);
0127   csctferrors->setBinLabel(4, "BX mismatch", 1);
0128   csctferrors->setBinLabel(5, "Time misalign.", 1);
0129   csctferrors->setBinLabel(6, "FMM != Ready", 1);
0130 
0131   // Error with detailed MCPID
0132   csctferrors_mpc = ibooker.book2D("CSCTF_errors_mpc", "CSCTF Errors", 6, 0, 6, 60, 1, 61);
0133   csctferrors_mpc->setAxisTitle("Error type", 1);
0134   csctferrors_mpc->setAxisTitle("MPC ID", 2);
0135   csctferrors_mpc->setBinLabel(1, "Corruptions", 1);
0136   csctferrors_mpc->setBinLabel(2, "Synch. Err.", 1);
0137   csctferrors_mpc->setBinLabel(3, "Synch. Mod.", 1);
0138   csctferrors_mpc->setBinLabel(4, "BX mismatch", 1);
0139   csctferrors_mpc->setBinLabel(5, "Time misalign.", 1);
0140   csctferrors_mpc->setBinLabel(6, "FMM != Ready", 1);
0141   for (int ybin = 1; ybin <= 60; ybin++) {
0142     if (ybin % 5)
0143       continue;
0144     char ytitle[50];
0145     snprintf(ytitle, 50, "%d", ybin);
0146     csctferrors_mpc->setBinLabel(ybin, ytitle, 2);
0147   }
0148 
0149   //  Occupancy histogram Eta x Y, where Y:
0150   //  1) Phi_packed of input LCTs from 1st, 2nd, 3rd, and 4th stations
0151   //  2) Phi_packed of output tracks
0152   //  (all 12 SPs - 360 degree coveradge)
0153   csctfoccupancies = ibooker.book2D("CSCTF_occupancies", "CSCTF Occupancies", 64, -32, 31, 32, 0, 6.2);
0154   csctfoccupancies->setAxisTitle("#eta", 1);
0155   csctfoccupancies->setAxisTitle("#phi", 2);
0156   csctfoccupancies->setBinLabel(1, "-2.5", 1);
0157   csctfoccupancies->setBinLabel(8, "-2.1", 1);
0158   csctfoccupancies->setBinLabel(18, "-1.6", 1);
0159   csctfoccupancies->setBinLabel(26, "-1.2", 1);
0160   csctfoccupancies->setBinLabel(32, "-0.9", 1);
0161   csctfoccupancies->setBinLabel(33, "0.9", 1);
0162   csctfoccupancies->setBinLabel(39, "1.2", 1);
0163   csctfoccupancies->setBinLabel(47, "1.6", 1);
0164   csctfoccupancies->setBinLabel(57, "2.1", 1);
0165   csctfoccupancies->setBinLabel(64, "2.5", 1);
0166 
0167   // ... and for halo muons only
0168   csctfoccupancies_H = ibooker.book2D("CSCTF_occupancies_H", "CSCTF Halo Occupancies", 64, -32, 31, 32, 0, 6.2);
0169   csctfoccupancies_H->setAxisTitle("#eta", 1);
0170   csctfoccupancies_H->setAxisTitle("#phi", 2);
0171   csctfoccupancies_H->setBinLabel(1, "-2.5", 1);
0172   csctfoccupancies_H->setBinLabel(8, "-2.1", 1);
0173   csctfoccupancies_H->setBinLabel(18, "-1.6", 1);
0174   csctfoccupancies_H->setBinLabel(26, "-1.2", 1);
0175   csctfoccupancies_H->setBinLabel(32, "-0.9", 1);
0176   csctfoccupancies_H->setBinLabel(33, "0.9", 1);
0177   csctfoccupancies_H->setBinLabel(39, "1.2", 1);
0178   csctfoccupancies_H->setBinLabel(47, "1.6", 1);
0179   csctfoccupancies_H->setBinLabel(57, "2.1", 1);
0180   csctfoccupancies_H->setBinLabel(64, "2.5", 1);
0181 
0182   //haloDelEta12  = ibooker.book1D("CSCTF_Halo_Eta12", "#Delta #eta_{12} for Halo Muons", 40, -0.20,0.30);
0183   //haloDelEta112 = ibooker.book1D("CSCTF_Halo_Eta112","#Delta #eta_{112} for Halo Muons", 40, -0.20,0.30);
0184   //haloDelEta13  = ibooker.book1D("CSCTF_Halo_Eta13", "#Delta #eta_{13} for Halo Muons", 40, -0.20,0.30);
0185   //haloDelEta113 = ibooker.book1D("CSCTF_Halo_Eta113","#Delta #eta_{113} for Halo Muons", 40, -0.20,0.30);
0186 
0187   // Quality VS Mode
0188   trackModeVsQ = ibooker.book2D("CSCTF_Track_ModeVsQual", "CSC Track Mode Vs Quality", 19, -0.5, 18.5, 4, 0, 4);
0189   trackModeVsQ->setAxisTitle("Track Type", 1);
0190   trackModeVsQ->setBinLabel(1, "No Track", 1);
0191   trackModeVsQ->setBinLabel(2, "Bad Phi/Single", 1);
0192   trackModeVsQ->setBinLabel(3, "ME1-2-3", 1);
0193   trackModeVsQ->setBinLabel(4, "ME1-2-4", 1);
0194   trackModeVsQ->setBinLabel(5, "ME1-3-4", 1);
0195   trackModeVsQ->setBinLabel(6, "ME2-3-4", 1);
0196   trackModeVsQ->setBinLabel(7, "ME1-2", 1);
0197   trackModeVsQ->setBinLabel(8, "ME1-3", 1);
0198   trackModeVsQ->setBinLabel(9, "ME2-3", 1);
0199   trackModeVsQ->setBinLabel(10, "ME2-4", 1);
0200   trackModeVsQ->setBinLabel(11, "ME3-4", 1);
0201   trackModeVsQ->setBinLabel(12, "MB1-ME3", 1);
0202   trackModeVsQ->setBinLabel(13, "MB1-ME2", 1);
0203   trackModeVsQ->setBinLabel(14, "ME1-4", 1);
0204   trackModeVsQ->setBinLabel(15, "MB1-ME1", 1);
0205   trackModeVsQ->setBinLabel(16, "Halo Trigger", 1);
0206   trackModeVsQ->setBinLabel(17, "MB1-ME1-2", 1);
0207   trackModeVsQ->setBinLabel(18, "MB1-ME1-3", 1);
0208   trackModeVsQ->setBinLabel(19, "MB1-ME2-3", 1);
0209 
0210   trackModeVsQ->setAxisTitle("Quality", 2);
0211   trackModeVsQ->setBinLabel(1, "0", 2);
0212   trackModeVsQ->setBinLabel(2, "1", 2);
0213   trackModeVsQ->setBinLabel(3, "2", 2);
0214   trackModeVsQ->setBinLabel(4, "3", 2);
0215 
0216   // Mode
0217   csctfTrackM = ibooker.book1D("CSCTF_Track_Mode", "CSC Track Mode", 19, -0.5, 18.5);
0218   csctfTrackM->setAxisTitle("Track Type", 1);
0219   csctfTrackM->setBinLabel(1, "No Track", 1);
0220   csctfTrackM->setBinLabel(2, "Bad Phi/Single", 1);
0221   csctfTrackM->setBinLabel(3, "ME1-2-3", 1);
0222   csctfTrackM->setBinLabel(4, "ME1-2-4", 1);
0223   csctfTrackM->setBinLabel(5, "ME1-3-4", 1);
0224   csctfTrackM->setBinLabel(6, "ME2-3-4", 1);
0225   csctfTrackM->setBinLabel(7, "ME1-2", 1);
0226   csctfTrackM->setBinLabel(8, "ME1-3", 1);
0227   csctfTrackM->setBinLabel(9, "ME2-3", 1);
0228   csctfTrackM->setBinLabel(10, "ME2-4", 1);
0229   csctfTrackM->setBinLabel(11, "ME3-4", 1);
0230   csctfTrackM->setBinLabel(12, "MB1-ME3", 1);
0231   csctfTrackM->setBinLabel(13, "MB1-ME2", 1);
0232   csctfTrackM->setBinLabel(14, "ME1-4", 1);
0233   csctfTrackM->setBinLabel(15, "MB1-ME1", 1);
0234   csctfTrackM->setBinLabel(16, "Halo Trigger", 1);
0235   csctfTrackM->setBinLabel(17, "MB1-ME1-2", 1);
0236   csctfTrackM->setBinLabel(18, "MB1-ME1-3", 1);
0237   csctfTrackM->setBinLabel(19, "MB1-ME2-3", 1);
0238 
0239   // Chamber Occupancy
0240   csctfChamberOccupancies =
0241       ibooker.book2D("CSCTF_Chamber_Occupancies", "CSCTF Chamber Occupancies", 54, -0.05, 5.35, 10, -5.5, 4.5);
0242   csctfChamberOccupancies->setAxisTitle("Sector, (chambers 1-9 not labeled)", 1);
0243   csctfChamberOccupancies->setBinLabel(1, "ME-4", 2);
0244   csctfChamberOccupancies->setBinLabel(2, "ME-3", 2);
0245   csctfChamberOccupancies->setBinLabel(3, "ME-2", 2);
0246   csctfChamberOccupancies->setBinLabel(4, "ME-1b", 2);
0247   csctfChamberOccupancies->setBinLabel(5, "ME-1a", 2);
0248   csctfChamberOccupancies->setBinLabel(6, "ME+1a", 2);
0249   csctfChamberOccupancies->setBinLabel(7, "ME+1b", 2);
0250   csctfChamberOccupancies->setBinLabel(8, "ME+2", 2);
0251   csctfChamberOccupancies->setBinLabel(9, "ME+3", 2);
0252   csctfChamberOccupancies->setBinLabel(10, "ME+4", 2);
0253   csctfChamberOccupancies->setBinLabel(1, "1", 1);
0254   csctfChamberOccupancies->setBinLabel(10, "2", 1);
0255   csctfChamberOccupancies->setBinLabel(19, "3", 1);
0256   csctfChamberOccupancies->setBinLabel(28, "4", 1);
0257   csctfChamberOccupancies->setBinLabel(37, "5", 1);
0258   csctfChamberOccupancies->setBinLabel(46, "6", 1);
0259 
0260   // Track Phi
0261   csctfTrackPhi = ibooker.book1D("CSCTF_Track_Phi", "CSCTF Track #phi", 144, 0, 2 * M_PI);
0262   csctfTrackPhi->setAxisTitle("Track #phi", 1);
0263 
0264   // Track Eta
0265   csctfTrackEta = ibooker.book1D("CSCTF_Track_Eta", "CSCTF Track #eta", 64, -32, 32);
0266   csctfTrackEta->setAxisTitle("Track #eta", 1);
0267   csctfTrackEta->setBinLabel(1, "-2.5", 1);
0268   csctfTrackEta->setBinLabel(8, "-2.1", 1);
0269   csctfTrackEta->setBinLabel(18, "-1.6", 1);
0270   csctfTrackEta->setBinLabel(26, "-1.2", 1);
0271   csctfTrackEta->setBinLabel(32, "-0.9", 1);
0272   csctfTrackEta->setBinLabel(33, "0.9", 1);
0273   csctfTrackEta->setBinLabel(39, "1.2", 1);
0274   csctfTrackEta->setBinLabel(47, "1.6", 1);
0275   csctfTrackEta->setBinLabel(57, "2.1", 1);
0276   csctfTrackEta->setBinLabel(64, "2.5", 1);
0277 
0278   // Track Eta Low Quality
0279   csctfTrackEtaLowQ = ibooker.book1D("CSCTF_Track_Eta_LowQ", "CSCTF Track #eta LQ", 64, -32, 32);
0280   csctfTrackEtaLowQ->setAxisTitle("Track #eta", 1);
0281   csctfTrackEtaLowQ->setBinLabel(1, "-2.5", 1);
0282   csctfTrackEtaLowQ->setBinLabel(8, "-2.1", 1);
0283   csctfTrackEtaLowQ->setBinLabel(18, "-1.6", 1);
0284   csctfTrackEtaLowQ->setBinLabel(26, "-1.2", 1);
0285   csctfTrackEtaLowQ->setBinLabel(32, "-0.9", 1);
0286   csctfTrackEtaLowQ->setBinLabel(33, "0.9", 1);
0287   csctfTrackEtaLowQ->setBinLabel(39, "1.2", 1);
0288   csctfTrackEtaLowQ->setBinLabel(47, "1.6", 1);
0289   csctfTrackEtaLowQ->setBinLabel(57, "2.1", 1);
0290   csctfTrackEtaLowQ->setBinLabel(64, "2.5", 1);
0291 
0292   // Track Eta High Quality
0293   csctfTrackEtaHighQ = ibooker.book1D("CSCTF_Track_Eta_HighQ", "CSCTF Track #eta HQ", 64, -32, 32);
0294   csctfTrackEtaHighQ->setAxisTitle("Track #eta", 1);
0295   csctfTrackEtaHighQ->setBinLabel(1, "-2.5", 1);
0296   csctfTrackEtaHighQ->setBinLabel(8, "-2.1", 1);
0297   csctfTrackEtaHighQ->setBinLabel(18, "-1.6", 1);
0298   csctfTrackEtaHighQ->setBinLabel(26, "-1.2", 1);
0299   csctfTrackEtaHighQ->setBinLabel(32, "-0.9", 1);
0300   csctfTrackEtaHighQ->setBinLabel(33, "0.9", 1);
0301   csctfTrackEtaHighQ->setBinLabel(39, "1.2", 1);
0302   csctfTrackEtaHighQ->setBinLabel(47, "1.6", 1);
0303   csctfTrackEtaHighQ->setBinLabel(57, "2.1", 1);
0304   csctfTrackEtaHighQ->setBinLabel(64, "2.5", 1);
0305 
0306   // Halo Phi
0307   csctfTrackPhi_H = ibooker.book1D("CSCTF_Track_Phi_H", "CSCTF Halo #phi", 144, 0, 2 * M_PI);
0308   csctfTrackPhi_H->setAxisTitle("Track #phi", 1);
0309 
0310   // Halo Eta
0311   csctfTrackEta_H = ibooker.book1D("CSCTF_Track_Eta_H", "CSCTF Halo #eta", 64, -32, 32);
0312   csctfTrackEta_H->setAxisTitle("Track #eta", 1);
0313   csctfTrackEta_H->setBinLabel(1, "-2.5", 1);
0314   csctfTrackEta_H->setBinLabel(8, "-2.1", 1);
0315   csctfTrackEta_H->setBinLabel(18, "-1.6", 1);
0316   csctfTrackEta_H->setBinLabel(26, "-1.2", 1);
0317   csctfTrackEta_H->setBinLabel(32, "-0.9", 1);
0318   csctfTrackEta_H->setBinLabel(33, "0.9", 1);
0319   csctfTrackEta_H->setBinLabel(39, "1.2", 1);
0320   csctfTrackEta_H->setBinLabel(47, "1.6", 1);
0321   csctfTrackEta_H->setBinLabel(57, "2.1", 1);
0322   csctfTrackEta_H->setBinLabel(64, "2.5", 1);
0323 
0324   // Track Timing
0325   csctfbx = ibooker.book2D("CSCTF_bx", "CSCTF BX", 12, 1, 13, 7, -3, 3);
0326   csctfbx->setAxisTitle("Sector (Endcap)", 1);
0327   csctfbx->setBinLabel(1, " 1 (+)", 1);
0328   csctfbx->setBinLabel(2, " 2 (+)", 1);
0329   csctfbx->setBinLabel(3, " 3 (+)", 1);
0330   csctfbx->setBinLabel(4, " 4 (+)", 1);
0331   csctfbx->setBinLabel(5, " 5 (+)", 1);
0332   csctfbx->setBinLabel(6, " 6 (+)", 1);
0333   csctfbx->setBinLabel(7, " 7 (-)", 1);
0334   csctfbx->setBinLabel(8, " 8 (-)", 1);
0335   csctfbx->setBinLabel(9, " 9 (-)", 1);
0336   csctfbx->setBinLabel(10, "10 (-)", 1);
0337   csctfbx->setBinLabel(11, "11 (-)", 1);
0338   csctfbx->setBinLabel(12, "12 (-)", 1);
0339 
0340   csctfbx->setAxisTitle("CSCTF BX", 2);
0341   csctfbx->setBinLabel(1, "-3", 2);
0342   csctfbx->setBinLabel(2, "-2", 2);
0343   csctfbx->setBinLabel(3, "-1", 2);
0344   csctfbx->setBinLabel(4, "-0", 2);
0345   csctfbx->setBinLabel(5, " 1", 2);
0346   csctfbx->setBinLabel(6, " 2", 2);
0347   csctfbx->setBinLabel(7, " 3", 2);
0348 
0349   // Halo Timing
0350   csctfbx_H = ibooker.book2D("CSCTF_bx_H", "CSCTF HALO BX", 12, 1, 13, 7, -3, 3);
0351   csctfbx_H->setAxisTitle("Sector (Endcap)", 1);
0352   csctfbx_H->setBinLabel(1, " 1 (+)", 1);
0353   csctfbx_H->setBinLabel(2, " 2 (+)", 1);
0354   csctfbx_H->setBinLabel(3, " 3 (+)", 1);
0355   csctfbx_H->setBinLabel(4, " 4 (+)", 1);
0356   csctfbx_H->setBinLabel(5, " 5 (+)", 1);
0357   csctfbx_H->setBinLabel(6, " 6 (+)", 1);
0358   csctfbx_H->setBinLabel(7, " 7 (-)", 1);
0359   csctfbx_H->setBinLabel(8, " 8 (-)", 1);
0360   csctfbx_H->setBinLabel(9, " 9 (-)", 1);
0361   csctfbx_H->setBinLabel(10, "10 (-)", 1);
0362   csctfbx_H->setBinLabel(11, "11 (-)", 1);
0363   csctfbx_H->setBinLabel(12, "12 (-)", 1);
0364 
0365   csctfbx_H->setAxisTitle("CSCTF BX", 2);
0366   csctfbx_H->setBinLabel(1, "-3", 2);
0367   csctfbx_H->setBinLabel(2, "-2", 2);
0368   csctfbx_H->setBinLabel(3, "-1", 2);
0369   csctfbx_H->setBinLabel(4, "-0", 2);
0370   csctfbx_H->setBinLabel(5, " 1", 2);
0371   csctfbx_H->setBinLabel(6, " 2", 2);
0372   csctfbx_H->setBinLabel(7, " 3", 2);
0373 
0374   // Number of Tracks Stubs
0375   cscTrackStubNumbers = ibooker.book1D("CSCTF_TrackStubs", "Number of Stubs in CSCTF Tracks", 5, 0, 5);
0376   cscTrackStubNumbers->setBinLabel(1, "0", 1);
0377   cscTrackStubNumbers->setBinLabel(2, "1", 1);
0378   cscTrackStubNumbers->setBinLabel(3, "2", 1);
0379   cscTrackStubNumbers->setBinLabel(4, "3", 1);
0380   cscTrackStubNumbers->setBinLabel(5, "4", 1);
0381 
0382   // Number of Tracks
0383   csctfntrack = ibooker.book1D("CSCTF_ntrack", "Number of CSCTracks found per event", 5, 0, 5);
0384   csctfntrack->setBinLabel(1, "0", 1);
0385   csctfntrack->setBinLabel(2, "1", 1);
0386   csctfntrack->setBinLabel(3, "2", 1);
0387   csctfntrack->setBinLabel(4, "3", 1);
0388   csctfntrack->setBinLabel(5, "4", 1);
0389   //}
0390 
0391   char hname[200];
0392   char htitle[200];
0393 
0394   for (int i = 0; i < 12; i++) {
0395     sprintf(hname, "DTstubsTimeTrackMenTimeArrival_%d", i + 1);
0396     sprintf(htitle, "T_{track} - T_{DT stub} sector %d", i + 1);
0397 
0398     DTstubsTimeTrackMenTimeArrival[i] = ibooker.book2D(hname, htitle, 7, -3, 3, 2, 1, 3);
0399     DTstubsTimeTrackMenTimeArrival[i]->getTH2F()->SetMinimum(0);
0400 
0401     // axis makeup
0402     DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("bx_{CSC track} - bx_{DT stub}", 1);
0403     DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("subsector", 2);
0404 
0405     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(1, "-3", 1);
0406     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(2, "-2", 1);
0407     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(3, "-1", 1);
0408     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(4, "0", 1);
0409     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(5, "+1", 1);
0410     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(6, "+2", 1);
0411     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(7, "+3", 1);
0412 
0413     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(1, "sub1", 2);
0414     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(2, "sub2", 2);
0415   }
0416 
0417   cscWireStripOverflow = ibooker.book2D("CSC_WireStripOverflow", "CSC WireStrip Overflow", 36, 1, 37, 18, 0, 18);
0418 
0419   // NEW: CSC EVENT LCT PLOTS
0420   csctflcts = ibooker.book2D("CSCTF_LCT", "CSCTF LCTs", 12, 1, 13, 18, 0, 18);
0421   csctflcts->setAxisTitle("CSCTF LCT BX", 1);
0422   csctflcts->setBinLabel(1, "1", 1);
0423   csctflcts->setBinLabel(2, "2", 1);
0424   csctflcts->setBinLabel(3, "3", 1);
0425   csctflcts->setBinLabel(4, "4", 1);
0426   csctflcts->setBinLabel(5, "5", 1);
0427   csctflcts->setBinLabel(6, "6", 1);
0428   csctflcts->setBinLabel(7, "7", 1);
0429   csctflcts->setBinLabel(8, "8", 1);
0430   csctflcts->setBinLabel(9, "9", 1);
0431   csctflcts->setBinLabel(10, "10", 1);
0432   csctflcts->setBinLabel(11, "11", 1);
0433   csctflcts->setBinLabel(12, "12", 1);
0434 
0435   int ihist = 0;
0436   for (int iEndcap = 0; iEndcap < 2; iEndcap++) {
0437     for (int iStation = 1; iStation < 5; iStation++) {
0438       for (int iRing = 1; iRing < 4; iRing++) {
0439         if (iStation != 1 && iRing > 2)
0440           continue;
0441         TString signEndcap = "+";
0442         if (iEndcap == 0)
0443           signEndcap = "-";
0444 
0445         char lcttitle[200];
0446         snprintf(lcttitle, 200, "ME%s%d/%d", signEndcap.Data(), iStation, iRing);
0447         if (ihist <= 8) {
0448           csctflcts->setBinLabel(9 - ihist, lcttitle, 2);
0449           cscWireStripOverflow->setBinLabel(9 - ihist, lcttitle, 2);
0450         } else {
0451           csctflcts->setBinLabel(ihist + 1, lcttitle, 2);
0452           cscWireStripOverflow->setBinLabel(ihist + 1, lcttitle, 2);
0453         }
0454 
0455         ihist++;
0456       }
0457     }
0458   }
0459 
0460   // plots for ME1/1 chambers
0461   me11_lctStrip = ibooker.book1D("CSC_ME11_LCT_Strip", "CSC_ME11_LCT_Strip", 223, 0, 223);
0462   me11_lctStrip->setAxisTitle("Cathode HalfStrip, ME1/1", 1);
0463 
0464   me11_lctWire = ibooker.book1D("CSC_ME11_LCT_Wire", "CSC_ME11_LCT_Wire", 112, 0, 112);
0465   me11_lctWire->setAxisTitle("Anode Wiregroup, ME1/1", 1);
0466 
0467   me11_lctLocalPhi = ibooker.book1D("CSC_ME11_LCT_LocalPhi", "CSC_ME11_LCT_LocalPhi", 200, 0, 1024);
0468   me11_lctLocalPhi->setAxisTitle("LCT Local #it{#phi}, ME1/1", 1);
0469 
0470   me11_lctPackedPhi = ibooker.book1D("CSC_ME11_LCT_PackedPhi", "CSC_ME11_LCT_PackedPhi", 200, 0, 4096);
0471   me11_lctPackedPhi->setAxisTitle("LCT Packed #it{#phi}, ME1/1", 1);
0472 
0473   me11_lctGblPhi = ibooker.book1D("CSC_ME11_LCT_GblPhi", "CSC_ME11_LCT_GblPhi", 200, 0, 2 * M_PI);
0474   me11_lctGblPhi->setAxisTitle("LCT Global #it{#phi}, ME1/1", 1);
0475 
0476   me11_lctGblEta = ibooker.book1D("CSC_ME11_LCT_GblEta", "CSC_ME11_LCT_GblEta", 50, 0.9, 2.5);
0477   me11_lctGblEta->setAxisTitle("LCT Global #eta, ME1/1", 1);
0478 
0479   // plots for ME4/2 chambers
0480   me42_lctGblPhi = ibooker.book1D("CSC_ME42_LCT_GblPhi", "CSC_ME42_LCT_GblPhi", 200, 0, 2 * M_PI);
0481   me42_lctGblPhi->setAxisTitle("LCT Global #it{#phi}, ME4/2", 1);
0482 
0483   me42_lctGblEta = ibooker.book1D("CSC_ME42_LCT_GblEta", "CSC_ME42_LCT_GblEta", 50, 0.9, 2.5);
0484   me42_lctGblEta->setAxisTitle("LCT Global #eta, ME4/2", 1);
0485 
0486   //
0487   csc_strip_MEplus11 = ibooker.book2D("csc_strip_MEplus11", "csc_strip_MEplus11", 36, 1, 37, 240, 0, 240);
0488   csc_strip_MEplus11->setAxisTitle("Cathode HalfStrip", 2);
0489   csc_strip_MEplus11->setAxisTitle("ME+1/1", 1);
0490   csc_strip_MEplus12 = ibooker.book2D("csc_strip_MEplus12", "csc_strip_MEplus12", 36, 1, 37, 240, 0, 240);
0491   csc_strip_MEplus12->setAxisTitle("Cathode HalfStrip", 2);
0492   csc_strip_MEplus12->setAxisTitle("ME+1/2", 1);
0493   csc_strip_MEplus13 = ibooker.book2D("csc_strip_MEplus13", "csc_strip_MEplus13", 36, 1, 37, 240, 0, 240);
0494   csc_strip_MEplus13->setAxisTitle("Cathode HalfStrip", 2);
0495   csc_strip_MEplus13->setAxisTitle("ME+1/3", 1);
0496   csc_strip_MEplus21 = ibooker.book2D("csc_strip_MEplus21", "csc_strip_MEplus21", 18, 1, 19, 240, 0, 240);
0497   csc_strip_MEplus21->setAxisTitle("Cathode HalfStrip", 2);
0498   csc_strip_MEplus21->setAxisTitle("ME+2/1", 1);
0499   csc_strip_MEplus22 = ibooker.book2D("csc_strip_MEplus22", "csc_strip_MEplus22", 36, 1, 37, 240, 0, 240);
0500   csc_strip_MEplus22->setAxisTitle("Cathode HalfStrip", 2);
0501   csc_strip_MEplus22->setAxisTitle("ME+2/2", 1);
0502   csc_strip_MEplus31 = ibooker.book2D("csc_strip_MEplus31", "csc_strip_MEplus31", 18, 1, 19, 240, 0, 240);
0503   csc_strip_MEplus31->setAxisTitle("Cathode HalfStrip", 2);
0504   csc_strip_MEplus31->setAxisTitle("ME+3/1", 1);
0505   csc_strip_MEplus32 = ibooker.book2D("csc_strip_MEplus32", "csc_strip_MEplus32", 36, 1, 37, 240, 0, 240);
0506   csc_strip_MEplus32->setAxisTitle("Cathode HalfStrip", 2);
0507   csc_strip_MEplus32->setAxisTitle("ME+3/2", 1);
0508   csc_strip_MEplus41 = ibooker.book2D("csc_strip_MEplus41", "csc_strip_MEplus41", 18, 1, 19, 240, 0, 240);
0509   csc_strip_MEplus41->setAxisTitle("Cathode HalfStrip", 2);
0510   csc_strip_MEplus41->setAxisTitle("ME+4/1", 1);
0511   csc_strip_MEplus42 = ibooker.book2D("csc_strip_MEplus42", "csc_strip_MEplus42", 36, 1, 37, 240, 0, 240);
0512   csc_strip_MEplus42->setAxisTitle("Cathode HalfStrip", 2);
0513   csc_strip_MEplus42->setAxisTitle("ME+4/2", 1);
0514 
0515   csc_strip_MEminus11 = ibooker.book2D("csc_strip_MEminus11", "csc_strip_MEminus11", 36, 1, 37, 240, 0, 240);
0516   csc_strip_MEminus11->setAxisTitle("Cathode HalfStrip", 2);
0517   csc_strip_MEminus11->setAxisTitle("ME-1/1", 1);
0518   csc_strip_MEminus12 = ibooker.book2D("csc_strip_MEminus12", "csc_strip_MEminus12", 36, 1, 37, 240, 0, 240);
0519   csc_strip_MEminus12->setAxisTitle("Cathode HalfStrip", 2);
0520   csc_strip_MEminus12->setAxisTitle("ME-1/2", 1);
0521   csc_strip_MEminus13 = ibooker.book2D("csc_strip_MEminus13", "csc_strip_MEminus13", 36, 1, 37, 240, 0, 240);
0522   csc_strip_MEminus13->setAxisTitle("Cathode HalfStrip", 2);
0523   csc_strip_MEminus13->setAxisTitle("ME-1/3", 1);
0524   csc_strip_MEminus21 = ibooker.book2D("csc_strip_MEminus21", "csc_strip_MEminus21", 18, 1, 19, 240, 0, 240);
0525   csc_strip_MEminus21->setAxisTitle("Cathode HalfStrip", 2);
0526   csc_strip_MEminus21->setAxisTitle("ME-2/1", 1);
0527   csc_strip_MEminus22 = ibooker.book2D("csc_strip_MEminus22", "csc_strip_MEminus22", 36, 1, 37, 240, 0, 240);
0528   csc_strip_MEminus22->setAxisTitle("Cathode HalfStrip", 2);
0529   csc_strip_MEminus22->setAxisTitle("ME-2/2", 1);
0530   csc_strip_MEminus31 = ibooker.book2D("csc_strip_MEminus31", "csc_strip_MEminus31", 18, 1, 19, 240, 0, 240);
0531   csc_strip_MEminus31->setAxisTitle("Cathode HalfStrip", 2);
0532   csc_strip_MEminus31->setAxisTitle("ME-3/1", 1);
0533   csc_strip_MEminus32 = ibooker.book2D("csc_strip_MEminus32", "csc_strip_MEminus32", 36, 1, 37, 240, 0, 240);
0534   csc_strip_MEminus32->setAxisTitle("Cathode HalfStrip", 2);
0535   csc_strip_MEminus32->setAxisTitle("ME-3/2", 1);
0536   csc_strip_MEminus41 = ibooker.book2D("csc_strip_MEminus41", "csc_strip_MEminus41", 18, 1, 19, 240, 0, 240);
0537   csc_strip_MEminus41->setAxisTitle("Cathode HalfStrip", 2);
0538   csc_strip_MEminus41->setAxisTitle("ME-4/1", 1);
0539   csc_strip_MEminus42 = ibooker.book2D("csc_strip_MEminus42", "csc_strip_MEminus42", 36, 1, 37, 240, 0, 240);
0540   csc_strip_MEminus42->setAxisTitle("Cathode HalfStrip", 2);
0541   csc_strip_MEminus42->setAxisTitle("ME-4/2", 1);
0542 
0543   csc_wire_MEplus11 = ibooker.book2D("csc_wire_MEplus11", "csc_wire_MEplus11", 36, 1, 37, 120, 0, 120);
0544   csc_wire_MEplus11->setAxisTitle("Anode Wiregroup", 2);
0545   csc_wire_MEplus11->setAxisTitle("ME+1/1", 1);
0546   csc_wire_MEplus12 = ibooker.book2D("csc_wire_MEplus12", "csc_wire_MEplus12", 36, 1, 37, 120, 0, 120);
0547   csc_wire_MEplus12->setAxisTitle("Anode Wiregroup", 2);
0548   csc_wire_MEplus12->setAxisTitle("ME+1/2", 1);
0549   csc_wire_MEplus13 = ibooker.book2D("csc_wire_MEplus13", "csc_wire_MEplus13", 36, 1, 37, 120, 0, 120);
0550   csc_wire_MEplus13->setAxisTitle("Anode Wiregroup", 2);
0551   csc_wire_MEplus13->setAxisTitle("ME+1/3", 1);
0552   csc_wire_MEplus21 = ibooker.book2D("csc_wire_MEplus21", "csc_wire_MEplus21", 18, 1, 19, 120, 0, 120);
0553   csc_wire_MEplus21->setAxisTitle("Anode Wiregroup", 2);
0554   csc_wire_MEplus21->setAxisTitle("ME+2/1", 1);
0555   csc_wire_MEplus22 = ibooker.book2D("csc_wire_MEplus22", "csc_wire_MEplus22", 36, 1, 37, 120, 0, 120);
0556   csc_wire_MEplus22->setAxisTitle("Anode Wiregroup", 2);
0557   csc_wire_MEplus22->setAxisTitle("ME+2/2", 1);
0558   csc_wire_MEplus31 = ibooker.book2D("csc_wire_MEplus31", "csc_wire_MEplus31", 18, 1, 19, 120, 0, 120);
0559   csc_wire_MEplus31->setAxisTitle("Anode Wiregroup", 2);
0560   csc_wire_MEplus31->setAxisTitle("ME+3/1", 1);
0561   csc_wire_MEplus32 = ibooker.book2D("csc_wire_MEplus32", "csc_wire_MEplus32", 36, 1, 37, 120, 0, 120);
0562   csc_wire_MEplus32->setAxisTitle("Anode Wiregroup", 2);
0563   csc_wire_MEplus32->setAxisTitle("ME+3/2", 1);
0564   csc_wire_MEplus41 = ibooker.book2D("csc_wire_MEplus41", "csc_wire_MEplus41", 18, 1, 19, 120, 0, 120);
0565   csc_wire_MEplus41->setAxisTitle("Anode Wiregroup", 2);
0566   csc_wire_MEplus41->setAxisTitle("ME+4/1", 1);
0567   csc_wire_MEplus42 = ibooker.book2D("csc_wire_MEplus42", "csc_wire_MEplus42", 36, 1, 37, 120, 0, 120);
0568   csc_wire_MEplus42->setAxisTitle("Anode Wiregroup", 2);
0569   csc_wire_MEplus42->setAxisTitle("ME+4/2", 1);
0570 
0571   csc_wire_MEminus11 = ibooker.book2D("csc_wire_MEminus11", "csc_wire_MEminus11", 36, 1, 37, 120, 0, 120);
0572   csc_wire_MEminus11->setAxisTitle("Anode Wiregroup", 2);
0573   csc_wire_MEminus11->setAxisTitle("ME-1/1", 1);
0574   csc_wire_MEminus12 = ibooker.book2D("csc_wire_MEminus12", "csc_wire_MEminus12", 36, 1, 37, 120, 0, 120);
0575   csc_wire_MEminus12->setAxisTitle("Anode Wiregroup", 2);
0576   csc_wire_MEminus12->setAxisTitle("ME-1/2", 1);
0577   csc_wire_MEminus13 = ibooker.book2D("csc_wire_MEminus13", "csc_wire_MEminus13", 36, 1, 37, 120, 0, 120);
0578   csc_wire_MEminus13->setAxisTitle("Anode Wiregroup", 2);
0579   csc_wire_MEminus13->setAxisTitle("ME-1/3", 1);
0580   csc_wire_MEminus21 = ibooker.book2D("csc_wire_MEminus21", "csc_wire_MEminus21", 18, 1, 19, 120, 0, 120);
0581   csc_wire_MEminus21->setAxisTitle("Anode Wiregroup", 2);
0582   csc_wire_MEminus21->setAxisTitle("ME-2/1", 1);
0583   csc_wire_MEminus22 = ibooker.book2D("csc_wire_MEminus22", "csc_wire_MEminus22", 36, 1, 37, 120, 0, 120);
0584   csc_wire_MEminus22->setAxisTitle("Anode Wiregroup", 2);
0585   csc_wire_MEminus22->setAxisTitle("ME-2/2", 1);
0586   csc_wire_MEminus31 = ibooker.book2D("csc_wire_MEminus31", "csc_wire_MEminus31", 18, 1, 19, 120, 0, 120);
0587   csc_wire_MEminus31->setAxisTitle("Anode Wiregroup", 2);
0588   csc_wire_MEminus31->setAxisTitle("ME-3/1", 1);
0589   csc_wire_MEminus32 = ibooker.book2D("csc_wire_MEminus32", "csc_wire_MEminus32", 36, 1, 37, 120, 0, 120);
0590   csc_wire_MEminus32->setAxisTitle("Anode Wiregroup", 2);
0591   csc_wire_MEminus32->setAxisTitle("ME-3/2", 1);
0592   csc_wire_MEminus41 = ibooker.book2D("csc_wire_MEminus41", "csc_wire_MEminus41", 18, 1, 19, 120, 0, 120);
0593   csc_wire_MEminus41->setAxisTitle("Anode Wiregroup", 2);
0594   csc_wire_MEminus41->setAxisTitle("ME-4/1", 1);
0595   csc_wire_MEminus42 = ibooker.book2D("csc_wire_MEminus42", "csc_wire_MEminus42", 36, 1, 37, 120, 0, 120);
0596   csc_wire_MEminus42->setAxisTitle("Anode Wiregroup", 2);
0597   csc_wire_MEminus42->setAxisTitle("ME-4/2", 1);
0598 
0599   for (int cscid = 1; cscid < 37; cscid++) {
0600     char bxtitle[100];
0601     sprintf(bxtitle, "%d", cscid);
0602 
0603     cscWireStripOverflow->setBinLabel(cscid, bxtitle, 1);
0604     csc_strip_MEplus11->setBinLabel(cscid, bxtitle, 1);
0605     csc_strip_MEplus12->setBinLabel(cscid, bxtitle, 1);
0606     csc_strip_MEplus13->setBinLabel(cscid, bxtitle, 1);
0607     csc_strip_MEplus22->setBinLabel(cscid, bxtitle, 1);
0608     csc_strip_MEplus32->setBinLabel(cscid, bxtitle, 1);
0609     csc_strip_MEplus42->setBinLabel(cscid, bxtitle, 1);
0610 
0611     csc_strip_MEminus11->setBinLabel(cscid, bxtitle, 1);
0612     csc_strip_MEminus12->setBinLabel(cscid, bxtitle, 1);
0613     csc_strip_MEminus13->setBinLabel(cscid, bxtitle, 1);
0614     csc_strip_MEminus22->setBinLabel(cscid, bxtitle, 1);
0615     csc_strip_MEminus32->setBinLabel(cscid, bxtitle, 1);
0616     csc_strip_MEminus42->setBinLabel(cscid, bxtitle, 1);
0617 
0618     csc_wire_MEplus11->setBinLabel(cscid, bxtitle, 1);
0619     csc_wire_MEplus12->setBinLabel(cscid, bxtitle, 1);
0620     csc_wire_MEplus13->setBinLabel(cscid, bxtitle, 1);
0621     csc_wire_MEplus22->setBinLabel(cscid, bxtitle, 1);
0622     csc_wire_MEplus32->setBinLabel(cscid, bxtitle, 1);
0623     csc_wire_MEplus42->setBinLabel(cscid, bxtitle, 1);
0624 
0625     csc_wire_MEminus11->setBinLabel(cscid, bxtitle, 1);
0626     csc_wire_MEminus12->setBinLabel(cscid, bxtitle, 1);
0627     csc_wire_MEminus13->setBinLabel(cscid, bxtitle, 1);
0628     csc_wire_MEminus22->setBinLabel(cscid, bxtitle, 1);
0629     csc_wire_MEminus32->setBinLabel(cscid, bxtitle, 1);
0630     csc_wire_MEminus42->setBinLabel(cscid, bxtitle, 1);
0631   }
0632 
0633   for (int cscid = 1; cscid < 19; cscid++) {
0634     char bxtitle[100];
0635     sprintf(bxtitle, "%d", cscid);
0636 
0637     csc_strip_MEplus21->setBinLabel(cscid, bxtitle, 1);
0638     csc_strip_MEplus31->setBinLabel(cscid, bxtitle, 1);
0639     csc_strip_MEplus41->setBinLabel(cscid, bxtitle, 1);
0640 
0641     csc_strip_MEminus21->setBinLabel(cscid, bxtitle, 1);
0642     csc_strip_MEminus31->setBinLabel(cscid, bxtitle, 1);
0643     csc_strip_MEminus41->setBinLabel(cscid, bxtitle, 1);
0644 
0645     csc_wire_MEplus21->setBinLabel(cscid, bxtitle, 1);
0646     csc_wire_MEplus31->setBinLabel(cscid, bxtitle, 1);
0647     csc_wire_MEplus41->setBinLabel(cscid, bxtitle, 1);
0648 
0649     csc_wire_MEminus21->setBinLabel(cscid, bxtitle, 1);
0650     csc_wire_MEminus31->setBinLabel(cscid, bxtitle, 1);
0651     csc_wire_MEminus41->setBinLabel(cscid, bxtitle, 1);
0652   }
0653 }
0654 
0655 void L1TCSCTF::analyze(const Event& e, const EventSetup& c) {
0656   if (c.get<L1MuTriggerScalesRcd>().cacheIdentifier() != m_scalesCacheID ||
0657       c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier() != m_ptScaleCacheID) {
0658     ts = &c.getData(l1muTscalesToken_);
0659     tpts = &c.getData(ptscalesToken_);
0660 
0661     m_scalesCacheID = c.get<L1MuTriggerScalesRcd>().cacheIdentifier();
0662     m_ptScaleCacheID = c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier();
0663 
0664     edm::LogInfo("L1TCSCTF") << "Changing triggerscales and triggerptscales...";
0665   }
0666 
0667   int NumCSCTfTracksRep = 0;
0668   nev_++;
0669   if (verbose_)
0670     edm::LogInfo("DataNotFound") << "L1TCSCTF: analyze...." << endl;
0671 
0672   edm::Handle<L1MuGMTReadoutCollection> pCollection;
0673   if (gmtProducer.label() != "null") {  // GMT block
0674     e.getByToken(gmtProducerToken_, pCollection);
0675     if (!pCollection.isValid()) {
0676       edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label ";  // << csctfSource_.label() ;
0677       return;
0678     }
0679 
0680     L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
0681     vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0682     vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
0683 
0684     // Look if the readout window contains one (and only one CSC cands)
0685     // to make it simpler I reject events with more than a CSC cand in the
0686     // same readout window
0687 
0688     // count non-empty candidates in this bx
0689     int bxWindow = 0;
0690     int nCands = 0;
0691 
0692     for (RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++) {
0693       bxWindow++;
0694 
0695       // get the csc candidates
0696       vector<L1MuRegionalCand> INPCands = RRItr->getCSCCands();
0697       vector<L1MuRegionalCand>::const_iterator INPItr;
0698 
0699       BxInEvent_ = 0;
0700       isCSCcand_ = false;
0701       int nCandsBx = 0;
0702 
0703       for (INPItr = INPCands.begin(); INPItr != INPCands.end(); ++INPItr) {
0704         if (!INPItr->empty()) {
0705           nCandsBx++;
0706           nCands++;
0707           BxInEvent_ = RRItr->getBxInEvent();
0708           if (verbose_)
0709             edm::LogInfo("DataNotFound") << "cand " << nCandsBx << " -> assigned CSCTF bx: " << INPItr->bx() << endl;
0710         }
0711       }
0712       if (verbose_)
0713         if (nCandsBx)
0714           edm::LogInfo("DataNotFound") << nCandsBx << " cands in bx: " << BxInEvent_ << endl;
0715     }
0716 
0717     if (nCands != 1)
0718       return;
0719     else
0720       isCSCcand_ = true;
0721     if (verbose_)
0722       edm::LogInfo("DataNotFound") << "bxWindow: " << bxWindow << endl;
0723 
0724     int ncsctftrack = 0;
0725     if (verbose_) {
0726       edm::LogInfo("DataNotFound") << "\tCSCTFCand ntrack " << ncsctftrack << endl;
0727     }
0728   }  // end of GMT block
0729 
0730   L1ABXN = -999;
0731   if (statusProducer.label() != "null") {
0732     edm::Handle<L1CSCStatusDigiCollection> status;
0733     e.getByToken(statusToken_, status);
0734     bool integrity = status->first, se = false, sm = false, bx = false, af = false, fmm = false;
0735     int nStat = 0;
0736 
0737     for (std::vector<L1CSCSPStatusDigi>::const_iterator stat = status->second.begin(); stat != status->second.end();
0738          stat++) {
0739       se |= stat->SEs() & 0xFFF;
0740       sm |= stat->SMs() & 0xFFF;
0741       bx |= stat->BXs() & 0xFFF;
0742       af |= stat->AFs() & 0xFFF;
0743       fmm |= stat->FMM() != 8;
0744 
0745       int ise = stat->SEs() & 0xFFF;
0746       int ism = stat->SMs() & 0xFFF;
0747       int ibx = stat->BXs() & 0xFFF;
0748       int iaf = stat->AFs() & 0xFFF;
0749       int ifmm = stat->FMM();
0750       int slot = stat->slot();
0751 
0752       for (int j = 0; j < 15; j++) {
0753         int link = j + 1;
0754         int mpc_id = 0;
0755         int sp_num = 0;
0756         if (slot >= 6 && slot <= 11)
0757           sp_num = slot - 5;
0758         if (slot >= 16 && slot <= 21)
0759           sp_num = slot - 9;
0760 
0761         if (sp_num == 1) {
0762           if (link >= 1 && link <= 3)
0763             mpc_id = 2;
0764           else if (link >= 4 && link <= 6)
0765             mpc_id = 3;
0766           else if (link >= 7 && link <= 9)
0767             mpc_id = 13;
0768           else if (link >= 10 && link <= 12)
0769             mpc_id = 19;
0770           else if (link >= 13 && link <= 15)
0771             mpc_id = 25;
0772         } else if (sp_num == 2) {
0773           if (link >= 1 && link <= 3)
0774             mpc_id = 4;
0775           else if (link >= 4 && link <= 6)
0776             mpc_id = 5;
0777           else if (link >= 7 && link <= 9)
0778             mpc_id = 14;
0779           else if (link >= 10 && link <= 12)
0780             mpc_id = 20;
0781           else if (link >= 13 && link <= 15)
0782             mpc_id = 26;
0783         } else if (sp_num == 3) {
0784           if (link >= 1 && link <= 3)
0785             mpc_id = 6;
0786           else if (link >= 4 && link <= 6)
0787             mpc_id = 7;
0788           else if (link >= 7 && link <= 9)
0789             mpc_id = 15;
0790           else if (link >= 10 && link <= 12)
0791             mpc_id = 21;
0792           else if (link >= 13 && link <= 15)
0793             mpc_id = 27;
0794         } else if (sp_num == 4) {
0795           if (link >= 1 && link <= 3)
0796             mpc_id = 8;
0797           else if (link >= 4 && link <= 6)
0798             mpc_id = 9;
0799           else if (link >= 7 && link <= 9)
0800             mpc_id = 16;
0801           else if (link >= 10 && link <= 12)
0802             mpc_id = 22;
0803           else if (link >= 13 && link <= 15)
0804             mpc_id = 28;
0805         } else if (sp_num == 5) {
0806           if (link >= 1 && link <= 3)
0807             mpc_id = 10;
0808           else if (link >= 4 && link <= 6)
0809             mpc_id = 11;
0810           else if (link >= 7 && link <= 9)
0811             mpc_id = 17;
0812           else if (link >= 10 && link <= 12)
0813             mpc_id = 23;
0814           else if (link >= 13 && link <= 15)
0815             mpc_id = 29;
0816         } else if (sp_num == 6) {
0817           if (link >= 1 && link <= 3)
0818             mpc_id = 12;
0819           else if (link >= 4 && link <= 6)
0820             mpc_id = 1;
0821           else if (link >= 7 && link <= 9)
0822             mpc_id = 18;
0823           else if (link >= 10 && link <= 12)
0824             mpc_id = 24;
0825           else if (link >= 13 && link <= 15)
0826             mpc_id = 30;
0827         } else if (sp_num == 7) {
0828           if (link >= 1 && link <= 3)
0829             mpc_id = 32;
0830           else if (link >= 4 && link <= 6)
0831             mpc_id = 33;
0832           else if (link >= 7 && link <= 9)
0833             mpc_id = 43;
0834           else if (link >= 10 && link <= 12)
0835             mpc_id = 49;
0836           else if (link >= 13 && link <= 15)
0837             mpc_id = 55;
0838         } else if (sp_num == 8) {
0839           if (link >= 1 && link <= 3)
0840             mpc_id = 34;
0841           else if (link >= 4 && link <= 6)
0842             mpc_id = 35;
0843           else if (link >= 7 && link <= 9)
0844             mpc_id = 44;
0845           else if (link >= 10 && link <= 12)
0846             mpc_id = 50;
0847           else if (link >= 13 && link <= 15)
0848             mpc_id = 56;
0849         } else if (sp_num == 9) {
0850           if (link >= 1 && link <= 3)
0851             mpc_id = 36;
0852           else if (link >= 4 && link <= 6)
0853             mpc_id = 37;
0854           else if (link >= 7 && link <= 9)
0855             mpc_id = 45;
0856           else if (link >= 10 && link <= 12)
0857             mpc_id = 51;
0858           else if (link >= 13 && link <= 15)
0859             mpc_id = 57;
0860         } else if (sp_num == 10) {
0861           if (link >= 1 && link <= 3)
0862             mpc_id = 38;
0863           else if (link >= 4 && link <= 6)
0864             mpc_id = 39;
0865           else if (link >= 7 && link <= 9)
0866             mpc_id = 46;
0867           else if (link >= 10 && link <= 12)
0868             mpc_id = 52;
0869           else if (link >= 13 && link <= 15)
0870             mpc_id = 58;
0871         } else if (sp_num == 11) {
0872           if (link >= 1 && link <= 3)
0873             mpc_id = 40;
0874           else if (link >= 4 && link <= 6)
0875             mpc_id = 41;
0876           else if (link >= 7 && link <= 9)
0877             mpc_id = 47;
0878           else if (link >= 10 && link <= 12)
0879             mpc_id = 53;
0880           else if (link >= 13 && link <= 15)
0881             mpc_id = 59;
0882         } else if (sp_num == 12) {
0883           if (link >= 1 && link <= 3)
0884             mpc_id = 42;
0885           else if (link >= 4 && link <= 6)
0886             mpc_id = 31;
0887           else if (link >= 7 && link <= 9)
0888             mpc_id = 48;
0889           else if (link >= 10 && link <= 12)
0890             mpc_id = 54;
0891           else if (link >= 13 && link <= 15)
0892             mpc_id = 60;
0893         }
0894 
0895         if (integrity)
0896           csctferrors_mpc->Fill(0.5, mpc_id);
0897         if ((ise >> j) & 0x1)
0898           csctferrors_mpc->Fill(1.5, mpc_id);
0899         if ((ism >> j) & 0x1)
0900           csctferrors_mpc->Fill(2.5, mpc_id);
0901         if ((ibx >> j) & 0x1)
0902           csctferrors_mpc->Fill(3.5, mpc_id);
0903         if ((iaf >> j) & 0x1)
0904           csctferrors_mpc->Fill(4.5, mpc_id);
0905         if (ifmm != 8)
0906           csctferrors_mpc->Fill(5.5, mpc_id);
0907       }
0908 
0909       if (stat->VPs() != 0) {
0910         L1ABXN += stat->BXN();
0911         nStat++;
0912       }
0913     }
0914     // compute the average
0915     if (nStat != 0)
0916       L1ABXN /= nStat;
0917     if (integrity)
0918       csctferrors->Fill(0.5);
0919     if (se)
0920       csctferrors->Fill(1.5);
0921     if (sm)
0922       csctferrors->Fill(2.5);
0923     if (bx)
0924       csctferrors->Fill(3.5);
0925     if (af)
0926       csctferrors->Fill(4.5);
0927     if (fmm)
0928       csctferrors->Fill(5.5);
0929   }
0930 
0931   if (lctProducer.label() != "null") {
0932     //edm::ESHandle<CSCGeometry> pDD;
0933     //c.get<MuonGeometryRecord>().get(pDD);
0934 
0935     edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
0936     e.getByToken(corrlctsToken_, corrlcts);
0937 
0938     for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc = corrlcts.product()->begin();
0939          csc != corrlcts.product()->end();
0940          csc++) {
0941       CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
0942       for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range1.first; lct != range1.second; lct++) {
0943         int endcap = (*csc).first.endcap() - 1;
0944         int station = (*csc).first.station() - 1;
0945         int sector = (*csc).first.triggerSector() - 1;
0946         int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
0947         int ring = (*csc).first.ring();
0948         int cscId = (*csc).first.triggerCscId() - 1;
0949         int fpga = (subSector ? subSector - 1 : station + 1);
0950         int strip = lct->getStrip();
0951         int keyWire = lct->getKeyWG();
0952         int bx = lct->getBX();
0953 
0954         int endcapAssignment = 1;
0955         int shift = 1;
0956         float sectorArg = sector;
0957         //float sectorArg = j;
0958 
0959         if (endcap == 1) {
0960           endcapAssignment = -1;
0961           shift = 2;
0962           //sectorArg = sector - 6;
0963         }
0964 
0965         int signedStation = (station + shift) * endcapAssignment;
0966         if ((station == 0) && (endcap == 0))
0967           signedStation = subSector - 1;
0968         if ((station == 0) && (endcap == 1))
0969           signedStation = (-1) * subSector;
0970 
0971         float chamberArg1 = cscId * 0.1 + sectorArg;
0972         //float chamberArg1 = i*0.1 + sectorArg;
0973         //std::cout << "First" << i << " " << sectorArg << " " << chamberArg1 << std::endl;
0974 
0975         float chamberArg11 = chamberArg1;
0976         if (sectorArg == 1)
0977           chamberArg1 = chamberArg11 - 0.1;
0978         if (sectorArg == 2)
0979           chamberArg1 = chamberArg11 - 0.2;
0980         if (sectorArg == 3)
0981           chamberArg1 = chamberArg11 - 0.3;
0982         if (sectorArg == 4)
0983           chamberArg1 = chamberArg11 - 0.4;
0984         if (sectorArg == 5)
0985           chamberArg1 = chamberArg11 - 0.5;
0986 
0987         //std::cout << "cscId, station, sector, endcap, sectorArg, chamber Arg: " << cscId << ", " << station << ", " <<sector << ", " << endcap << ", " << chamberArg1 << ", " << signedStation << std::endl;
0988 
0989         csctfChamberOccupancies->Fill(chamberArg1, signedStation);
0990         //int bunchX = ( (lct->getBX()) - 6 );
0991 
0992         //int timingSectorArg = 3*(sector) + (lct->getMPCLink());
0993         //if( endcap == 1) timingSectorArg = 3*(sector + 6) + (lct->getMPCLink());
0994         //std::cout << "Sector, MPCLink, TSA, endcap: " << sector << ", " << lct->getMPCLink() << ", " << timingSectorArg << ", " << endcap << std::endl;
0995 
0996         //csctfbx->Fill(timingSectorArg, bunchX );
0997         //std::cout << "LCT'S, encap: " << endcap << ", station: " << station << ", sector: " << sector << ", subSector: " << subSector << ", cscId: " << cscId << std:: endl;
0998         //End JAG
0999 
1000         // Check if Det Id is within pysical range:
1001         if (endcap < 0 || endcap > 1 || sector < 0 || sector > 6 || station < 0 || station > 3 || cscId < 0 ||
1002             cscId > 8 || fpga < 0 || fpga > 4) {
1003           edm::LogError("L1CSCTF: CSC TP are out of range: ")
1004               << "  endcap: " << (endcap + 1) << "  station: " << (station + 1) << "  sector: " << (sector + 1)
1005               << "  subSector: " << subSector << "  fpga: " << fpga << "  cscId: " << (cscId + 1);
1006           continue;
1007         }
1008 
1009         int EndCapLUT = 1;
1010         //if(endcap==0) EndCapLUT=1; // ME+
1011         if (endcap == 1)
1012           EndCapLUT = 0;  // ME-
1013 
1014         lclphidat lclPhi;
1015         try {
1016           lclPhi = srLUTs_[fpga][EndCapLUT][sector]->localPhi(
1017               lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend(), gangedME11a_);
1018         } catch (cms::Exception&) {
1019           bzero(&lclPhi, sizeof(lclPhi));
1020         }
1021 
1022         gblphidat gblPhi;
1023         try {
1024           gblPhi =
1025               srLUTs_[fpga][EndCapLUT][sector]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId + 1, gangedME11a_);
1026         } catch (cms::Exception&) {
1027           bzero(&gblPhi, sizeof(gblPhi));
1028         }
1029 
1030         gbletadat gblEta;
1031         try {
1032           gblEta = srLUTs_[fpga][EndCapLUT][sector]->globalEtaME(
1033               lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId + 1, gangedME11a_);
1034         } catch (cms::Exception&) {
1035           bzero(&gblEta, sizeof(gblEta));
1036         }
1037 
1038         //TrackStub
1039         csctf::TrackStub theStub((*lct), (*csc).first);
1040         theStub.setPhiPacked(gblPhi.global_phi);
1041         theStub.setEtaPacked(gblEta.global_eta);
1042 
1043         float etaG = theStub.etaValue();
1044         float phiG = fmod(theStub.phiValue() + 15.0 * M_PI / 180 + (sector)*60.0 * M_PI / 180, 2. * M_PI);
1045 
1046         //BX plots
1047         // endcap==1: minus side; endcap==0: plus side
1048         // station=0,1,2,3; ring=1,2,3;
1049         if (endcap == 1) {
1050           if (station == 0) {
1051             if (ring == 1)
1052               csctflcts->Fill(bx, 8.5);
1053             else if (ring == 2)
1054               csctflcts->Fill(bx, 7.5);
1055             else
1056               csctflcts->Fill(bx, 6.5);
1057           } else if (station == 1) {
1058             if (ring == 1)
1059               csctflcts->Fill(bx, 5.5);
1060             else
1061               csctflcts->Fill(bx, 4.5);
1062           } else if (station == 2) {
1063             if (ring == 1)
1064               csctflcts->Fill(bx, 3.5);
1065             else
1066               csctflcts->Fill(bx, 2.5);
1067           } else if (station == 3) {
1068             if (ring == 1)
1069               csctflcts->Fill(bx, 1.5);
1070             else
1071               csctflcts->Fill(bx, 0.5);
1072           }
1073 
1074         } else {
1075           if (station == 0) {
1076             if (ring == 1)
1077               csctflcts->Fill(bx, 9.5);
1078             else if (ring == 2)
1079               csctflcts->Fill(bx, 10.5);
1080             else
1081               csctflcts->Fill(bx, 11.5);
1082           } else if (station == 1) {
1083             if (ring == 1)
1084               csctflcts->Fill(bx, 12.5);
1085             else
1086               csctflcts->Fill(bx, 13.5);
1087           } else if (station == 2) {
1088             if (ring == 1)
1089               csctflcts->Fill(bx, 14.5);
1090             else
1091               csctflcts->Fill(bx, 15.5);
1092           } else if (station == 3) {
1093             if (ring == 1)
1094               csctflcts->Fill(bx, 16.5);
1095             else
1096               csctflcts->Fill(bx, 17.5);
1097           }
1098         }
1099 
1100         // only for ME1/1
1101         if (station == 0 && ring == 1) {
1102           me11_lctStrip->Fill(strip);
1103           me11_lctWire->Fill(keyWire);
1104           me11_lctLocalPhi->Fill(lclPhi.phi_local);
1105           me11_lctPackedPhi->Fill(theStub.phiPacked());
1106           me11_lctGblPhi->Fill(phiG);
1107           me11_lctGblEta->Fill(etaG);
1108         }
1109 
1110         // only for ME4/2
1111         if (station == 3 && ring == 2) {
1112           me42_lctGblPhi->Fill(phiG);
1113           me42_lctGblEta->Fill(etaG);
1114         }
1115 
1116         //ME1/1
1117         if (station == 0 && ring == 1) {
1118           int realID = cscId + 6 * sector + 3 * subSector;
1119           if (realID > 36)
1120             realID -= 36;
1121           if (endcap == 0) {
1122             csc_strip_MEplus11->Fill(realID, strip);
1123             csc_wire_MEplus11->Fill(realID, keyWire);
1124             if (keyWire > 48 || strip > 224)
1125               cscWireStripOverflow->Fill(realID, 9.5, 1);
1126           }
1127           if (endcap == 1) {
1128             csc_strip_MEminus11->Fill(realID, strip);
1129             csc_wire_MEminus11->Fill(realID, keyWire);
1130             if (keyWire > 48 || strip > 224)
1131               cscWireStripOverflow->Fill(realID, 8.5, 1);
1132           }
1133         }
1134         //ME1/2
1135         if (station == 0 && ring == 2) {
1136           int realID = (cscId - 3) + 6 * sector + 3 * subSector;
1137           if (realID > 36)
1138             realID -= 36;
1139           if (endcap == 0) {
1140             csc_strip_MEplus12->Fill(realID, strip);
1141             csc_wire_MEplus12->Fill(realID, keyWire);
1142             if (keyWire > 64 || strip > 160)
1143               cscWireStripOverflow->Fill(realID, 10.5, 1);
1144           }
1145           if (endcap == 1) {
1146             csc_strip_MEminus12->Fill(realID, strip);
1147             csc_wire_MEminus12->Fill(realID, keyWire);
1148             if (keyWire > 64 || strip > 160)
1149               cscWireStripOverflow->Fill(realID, 7.5, 1);
1150           }
1151         }
1152         //ME1/3
1153         if (station == 0 && ring == 3) {
1154           int realID = (cscId - 6) + 6 * sector + 3 * subSector;
1155           if (realID > 36)
1156             realID -= 36;
1157           if (endcap == 0) {
1158             csc_strip_MEplus13->Fill(realID, strip);
1159             csc_wire_MEplus13->Fill(realID, keyWire);
1160             if (keyWire > 32 || strip > 128)
1161               cscWireStripOverflow->Fill(realID, 11.5, 1);
1162           }
1163           if (endcap == 1) {
1164             csc_strip_MEminus13->Fill(realID, strip);
1165             csc_wire_MEminus13->Fill(realID, keyWire);
1166             if (keyWire > 32 || strip > 128)
1167               cscWireStripOverflow->Fill(realID, 6.5, 1);
1168           }
1169         }
1170         //ME2/1
1171         if (station == 1 && ring == 1) {
1172           int realID = cscId + 3 * sector + 2;
1173           if (realID > 18)
1174             realID -= 18;
1175           if (endcap == 0) {
1176             csc_strip_MEplus21->Fill(realID, strip);
1177             csc_wire_MEplus21->Fill(realID, keyWire);
1178             if (keyWire > 112 || strip > 160)
1179               cscWireStripOverflow->Fill(realID, 12.5, 1);
1180           }
1181           if (endcap == 1) {
1182             csc_strip_MEminus21->Fill(realID, strip);
1183             csc_wire_MEminus21->Fill(realID, keyWire);
1184             if (keyWire > 112 || strip > 160)
1185               cscWireStripOverflow->Fill(realID, 5.5, 1);
1186           }
1187         }
1188         //ME2/2
1189         if (station == 1 && ring == 2) {
1190           int realID = (cscId - 3) + 6 * sector + 3;
1191           if (realID > 36)
1192             realID -= 36;
1193           if (endcap == 0) {
1194             csc_strip_MEplus22->Fill(realID, strip);
1195             csc_wire_MEplus22->Fill(realID, keyWire);
1196             if (keyWire > 64 || strip > 160)
1197               cscWireStripOverflow->Fill(realID, 13.5, 1);
1198           }
1199           if (endcap == 1) {
1200             csc_strip_MEminus22->Fill(realID, strip);
1201             csc_wire_MEminus22->Fill(realID, keyWire);
1202             if (keyWire > 64 || strip > 160)
1203               cscWireStripOverflow->Fill(realID, 4.5, 1);
1204           }
1205         }
1206 
1207         //ME3/1
1208         if (station == 2 && ring == 1) {
1209           int realID = cscId + 3 * sector + 2;
1210           if (realID > 18)
1211             realID -= 18;
1212           if (endcap == 0) {
1213             csc_strip_MEplus31->Fill(realID, strip);
1214             csc_wire_MEplus31->Fill(realID, keyWire);
1215             if (keyWire > 96 || strip > 160)
1216               cscWireStripOverflow->Fill(realID, 14.5, 1);
1217           }
1218           if (endcap == 1) {
1219             csc_strip_MEminus31->Fill(realID, strip);
1220             csc_wire_MEminus31->Fill(realID, keyWire);
1221             if (keyWire > 96 || strip > 160)
1222               cscWireStripOverflow->Fill(realID, 3.5, 1);
1223           }
1224         }
1225 
1226         //ME3/2
1227         if (station == 2 && ring == 2) {
1228           int realID = (cscId - 3) + 6 * sector + 3;
1229           if (realID > 36)
1230             realID -= 36;
1231           if (endcap == 0) {
1232             csc_strip_MEplus32->Fill(realID, strip);
1233             csc_wire_MEplus32->Fill(realID, keyWire);
1234             if (keyWire > 64 || strip > 160)
1235               cscWireStripOverflow->Fill(realID, 15.5, 1);
1236           }
1237           if (endcap == 1) {
1238             csc_strip_MEminus32->Fill(realID, strip);
1239             csc_wire_MEminus32->Fill(realID, keyWire);
1240             if (keyWire > 64 || strip > 160)
1241               cscWireStripOverflow->Fill(realID, 2.5, 1);
1242           }
1243         }
1244         //ME4/1
1245         if (station == 3 && ring == 1) {
1246           int realID = cscId + 3 * sector + 2;
1247           if (realID > 18)
1248             realID -= 18;
1249           if (endcap == 0) {
1250             csc_strip_MEplus41->Fill(realID, strip);
1251             csc_wire_MEplus41->Fill(realID, keyWire);
1252             if (keyWire > 96 || strip > 160)
1253               cscWireStripOverflow->Fill(realID, 16.5, 1);
1254           }
1255           if (endcap == 1) {
1256             csc_strip_MEminus41->Fill(realID, strip);
1257             csc_wire_MEminus41->Fill(realID, keyWire);
1258             if (keyWire > 96 || strip > 160)
1259               cscWireStripOverflow->Fill(realID, 1.5, 1);
1260           }
1261         }
1262         //ME4/2
1263         if (station == 3 && ring == 2) {
1264           int realID = (cscId - 3) + 6 * sector + 3;
1265           if (realID > 36)
1266             realID -= 36;
1267           if (endcap == 0) {
1268             csc_strip_MEplus42->Fill(realID, strip);
1269             csc_wire_MEplus42->Fill(realID, keyWire);
1270             if (keyWire > 64 || strip > 160)
1271               cscWireStripOverflow->Fill(realID, 17.5, 1);
1272           }
1273           if (endcap == 1) {
1274             csc_strip_MEminus42->Fill(realID, strip);
1275             csc_wire_MEminus42->Fill(realID, keyWire);
1276             if (keyWire > 64 || strip > 160)
1277               cscWireStripOverflow->Fill(realID, 0.5, 1);
1278           }
1279         }
1280 
1281         // SR LUT gives packed eta and phi values -> normilize them to 1 by scale them to 'max' and shift by 'min'
1282         //float etaP = gblEta.global_eta/127*1.5 + 0.9;
1283         //float phiP =  (gblPhi.global_phi);// + ( sector )*4096 + station*4096*12) * 1./(4*4096*12);
1284         //std::cout << "LCT Eta & Phi Coordinates: " << etaP << ", " << phiP << "." << std::endl;
1285         //csctfoccupancies->Fill( gblEta.global_eta/127. * 1.5 + 0.9, (gblPhi.global_phi + ( sector + (endcap?0:6) )*4096 + station*4096*12) * 1./(4*4096*12) );
1286       }  //lct != range1.scond
1287     }    //csc!=corrlcts.product()->end()
1288   }      // lctProducer.label() != "null"
1289 
1290   if (trackProducer.label() != "null") {
1291     edm::Handle<L1CSCTrackCollection> tracks;
1292     e.getByToken(tracksToken_, tracks);
1293     for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk < tracks->end(); trk++) {
1294       NumCSCTfTracksRep++;
1295       long LUTAdd = trk->first.ptLUTAddress();
1296       int trigMode = ((LUTAdd)&0xf0000) >> 16;
1297       int trEta = (trk->first.eta_packed());
1298 
1299       // trk->first.endcap() = 2 for - endcap
1300       //                     = 1 for + endcap
1301       //int trEndcap = (trk->first.endcap()==2 ? trk->first.endcap()-3 : trk->first.endcap());
1302       if (trk->first.endcap() != 1) {
1303         int holder = trEta;
1304         trEta = -1 * holder;
1305         trEta -= 1;
1306       }
1307 
1308       int trSector = 6 * (trk->first.endcap() - 1) + trk->first.sector();
1309       int trBX = trk->first.BX();
1310 
1311       //Here is what is done with output phi value:
1312       //output_phi = (phi / 32) * 3 /16
1313       //where:
1314       //phi is 12-bit phi, 4096 bins covering 62 degrees
1315       //output_phi is 5-bit value
1316 
1317       //Easy to see that output_phi can have values from 0 to 23, or 24 total combinations.
1318       //This gives per-bin phi value of 62/24 = 2.583333 degrees.
1319 
1320       // Sector 1 nominally starts at 15 degrees but there 1 degree overlap between sectors so 14 degrees effectively
1321       //double trPhi = trk->first.localPhi() * 62. / 24.;
1322       double trPhi = ts->getPhiScale()->getLowEdge(trk->first.localPhi());
1323       double trPhi02PI = fmod(trPhi + ((trSector - 1) * M_PI / 3) + (M_PI * 14 / 180.), 2 * M_PI);
1324 
1325       if (trigMode == 15) {
1326         csctfTrackPhi_H->Fill(trPhi02PI);
1327         csctfTrackEta_H->Fill(trEta);
1328         csctfoccupancies_H->Fill(trEta, trPhi02PI);
1329         csctfbx_H->Fill(trSector, trBX);
1330       } else {
1331         csctfTrackPhi->Fill(trPhi02PI);
1332         csctfTrackEta->Fill(trEta);
1333         csctfoccupancies->Fill(trEta, trPhi02PI);
1334         csctfbx->Fill(trSector, trBX);
1335 
1336         // Low Quality / High Quality Eta Distributions
1337         //|eta| < 2.1
1338         if (abs(trEta) < 24) {
1339           if (trigMode == 2 || trigMode == 3 || trigMode == 4 || trigMode == 5 || trigMode == 6 || trigMode == 7 ||
1340               trigMode == 11 || trigMode == 12 || trigMode == 13 || trigMode == 14)
1341             csctfTrackEtaHighQ->Fill(trEta);
1342 
1343           if (trigMode == 8 || trigMode == 9 || trigMode == 10)
1344             csctfTrackEtaLowQ->Fill(trEta);
1345         } else {  //|eta| > 2.1
1346           if (trigMode == 2 || trigMode == 3 || trigMode == 4 || trigMode == 5)
1347             csctfTrackEtaHighQ->Fill(trEta);
1348           else
1349             csctfTrackEtaLowQ->Fill(trEta);
1350         }
1351       }
1352 
1353       csctfTrackM->Fill(trk->first.modeExtended());
1354 
1355       // we monitor the track quality only on the first link
1356       // so let's make sure to fill the plot if there is something that
1357       // is read from the hardware
1358       int trRank = trk->first.rank();
1359       if (trRank) {
1360         int trQuality = ((trRank >> 5) & 0x3);
1361         trackModeVsQ->Fill(trk->first.modeExtended(), trQuality);
1362       }
1363 
1364       /*
1365              OLD METHOD FOR FILLING HALO PLOTS, IMPROVED METHOD USING ASSOCIATED TRACK STUBS
1366              BELOW ~LINE 605
1367              if( trigMode == 15 )
1368              {
1369 
1370              double haloVals[4][4];
1371              for( int i = 0; i < 4; i++)
1372              {
1373              haloVals[i][0] = 0;
1374              }
1375 
1376              edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
1377              for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
1378              {
1379              CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
1380              for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
1381              {
1382              int endcap  = (*csc).first.endcap()-1;
1383              int station = (*csc).first.station()-1;
1384              int sector  = (*csc).first.triggerSector()-1;
1385              int cscId   = (*csc).first.triggerCscId()-1;
1386              int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
1387              int fpga    = ( subSector ? subSector-1 : station+1 );
1388 
1389              if(station != 4)
1390              {
1391              int modEnd = 1;
1392              if( endcap == 0 ) modEnd = -1;
1393              int indexHalo = modEnd + station;
1394              if(haloVals[indexHalo][0] == 1.0) haloVals[indexHalo][3] = 1.0;
1395              if(haloVals[indexHalo][0] == 0) haloVals[indexHalo][0] = 1.0;
1396              haloVals[indexHalo][1] = sector*1.0;
1397 
1398              lclphidat lclPhi;
1399              lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
1400              gblphidat gblPhi;
1401              gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1402              gbletadat gblEta;
1403              gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1404 
1405              haloVals[indexHalo][2] = gblEta.global_eta/127. * 1.5 + 0.9;
1406              } //station1 or 2
1407              } //lct first to second
1408              } //corrlcts
1409 
1410              if( (haloVals[0][0] == 1.) && (haloVals[1][0] == 1.) && (haloVals[0][3] != 1.) && (haloVals[1][3] != 1.)  )
1411              {
1412              if( haloVals[0][1] == haloVals[1][1] ){
1413              double delEta23 = haloVals[1][2] - haloVals[0][2];
1414              haloDelEta23->Fill( delEta23 );
1415              }
1416              }
1417 
1418              if( (haloVals[2][0] == 1.) && (haloVals[3][0] == 1.) && (haloVals[2][3] != 1.) && (haloVals[3][3] != 1.)  )
1419              {
1420              if( haloVals[2][1] == haloVals[3][1] ){
1421              double delEta23 = haloVals[3][2] - haloVals[2][2];
1422              haloDelEta23->Fill( delEta23 );
1423              }
1424              }
1425              } //halo trigger
1426           */
1427 
1428       int cscTrackStub = 0;
1429       //float haloEta[3];
1430       //for(int i=0; i<3; i++) haloEta[i]=-1.0;
1431       //bool haloME11 = false;
1432       CSCCorrelatedLCTDigiCollection lctsOfTracks = trk->second;
1433       for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator trackStub = lctsOfTracks.begin();
1434            trackStub != lctsOfTracks.end();
1435            trackStub++) {
1436         CSCCorrelatedLCTDigiCollection::Range range2 = lctsOfTracks.get((*trackStub).first);
1437         for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range2.first; lct != range2.second; lct++) {
1438           //                   int station = (*trackStub).first.station()-1;
1439           //                   if(station != 4)
1440           //                     {
1441           //                       // int endcap  = (*trackStub).first.endcap()-1;
1442           //                       // int sector  = (*trackStub).first.triggerSector()-1;
1443           //                       int cscId   = (*trackStub).first.triggerCscId()-1;
1444           //                       int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*trackStub).first);
1445           //                       int fpga    = ( subSector ? subSector-1 : station+1 );
1446 
1447           //                       lclphidat lclPhi;
1448           //                       lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
1449           //                       gblphidat gblPhi;
1450           //                       gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1451           //                       gbletadat gblEta;
1452           //                       gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1453           //                       haloEta[station-1] = gblEta.global_eta/127. * 1.5 + 0.9;
1454           //                       if(station==1 && cscId<2) haloME11 = true;
1455           //                    }
1456           cscTrackStub++;
1457         }
1458       }
1459       cscTrackStubNumbers->Fill(cscTrackStub);
1460 
1461       //           if(trigMode == 15)
1462       //             {
1463       //               float dEta13 = haloEta[2]-haloEta[0];
1464       //               float dEta12 = haloEta[1]-haloEta[0];
1465       //               if(haloME11)
1466       //                 {
1467       //                   if(haloEta[1]!=-1.0) haloDelEta112->Fill(dEta12);
1468       //                   if(haloEta[2]!=-1.0) haloDelEta113->Fill(dEta13);
1469       //                 } else {
1470       //                 if(haloEta[1]!=-1.0) haloDelEta12->Fill(dEta12);
1471       //                 if(haloEta[2]!=-1.0) haloDelEta13->Fill(dEta13);
1472       //               }
1473       //             }
1474       //
1475     }
1476   }
1477   csctfntrack->Fill(NumCSCTfTracksRep);
1478 
1479   if (mbProducer.label() != "null") {
1480     // handle to needed collections
1481     edm::Handle<CSCTriggerContainer<csctf::TrackStub> > dtStubs;
1482     e.getByToken(dtStubsToken_, dtStubs);
1483     edm::Handle<L1CSCTrackCollection> tracks;
1484     e.getByToken(mbtracksToken_, tracks);
1485 
1486     // loop on the DT stubs
1487     std::vector<csctf::TrackStub> vstubs = dtStubs->get();
1488     for (std::vector<csctf::TrackStub>::const_iterator stub = vstubs.begin(); stub != vstubs.end(); stub++) {
1489       if (verbose_) {
1490         edm::LogInfo("DataNotFound") << "\n mbEndcap: " << stub->endcap();
1491         edm::LogInfo("DataNotFound") << "\n stub->getStrip()[FLAG]: " << stub->getStrip();
1492         edm::LogInfo("DataNotFound") << "\n stub->getKeyWG()[CAL]: " << stub->getKeyWG();
1493         edm::LogInfo("DataNotFound") << "\n stub->BX(): " << stub->BX();
1494         edm::LogInfo("DataNotFound") << "\n stub->sector(): " << stub->sector();
1495         edm::LogInfo("DataNotFound") << "\n stub->subsector(): " << stub->subsector();
1496         edm::LogInfo("DataNotFound") << "\n stub->station(): " << stub->station();
1497         edm::LogInfo("DataNotFound") << "\n stub->phiPacked(): " << stub->phiPacked();
1498         edm::LogInfo("DataNotFound") << "\n stub->getBend(): " << stub->getBend();
1499         edm::LogInfo("DataNotFound") << "\n stub->getQuality(): " << stub->getQuality();
1500         edm::LogInfo("DataNotFound") << "\n stub->cscid(): " << stub->cscid() << endl;
1501       }
1502       // define the sector ID
1503       int mbId = (stub->endcap() == 2) ? 6 : 0;
1504       mbId += stub->sector();
1505       // *** do not fill if CalMB variable is set ***
1506       // horrible! They used the same class to write up the LCT and MB info,
1507       // but given the MB does not have strip and WG they replaced this two
1508       // with the flag and cal bits... :S
1509       if (stub->getKeyWG() == 0)  //!CAL as Janos adviced
1510       {
1511         // if FLAG =1, muon belong to previous BX
1512         int bxDT = stub->BX() - stub->getStrip();  // correct by the FLAG
1513         int subDT = stub->subsector();
1514 
1515         // Fill the event only if CSC had or would have triggered
1516         if (isCSCcand_) {
1517           //look for tracks in the event and compare the matching DT stubs
1518           int trkBX = 0;
1519           for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk < tracks->end(); trk++) {
1520             trkBX = trk->first.BX();
1521             int trkId = (trk->first.endcap() == 2) ? 6 : 0;
1522             trkId += trk->first.sector();
1523             if (verbose_) {
1524               edm::LogInfo("DataNotFound")
1525                   << "\n trk BX: " << trkBX << " Sector: " << trkId << " SubSector: " << trk->first.subsector()
1526                   << " Endcap: " << trk->first.endcap();
1527 
1528               edm::LogInfo("DataNotFound")
1529                   << "\n DT  BX: " << stub->BX() << " Sector: " << mbId << " SubSector: " << stub->subsector()
1530                   << " Endcap: " << stub->endcap() << endl;
1531             }
1532 
1533             if (mbId == trkId) {
1534               if (verbose_) {
1535                 edm::LogInfo("DataNotFound") << " --> MATCH" << endl;
1536                 edm::LogInfo("DataNotFound") << "Fill :" << trkBX + 6 - bxDT << " -- " << subDT << " -- cands" << endl;
1537               }
1538               // DT bx ranges from 3 to 9
1539               // trk bx ranges from -3 to 3
1540               DTstubsTimeTrackMenTimeArrival[mbId - 1]->Fill(bxDT - trkBX - 6, subDT);  //subsec
1541             }
1542           }  // loop on the tracks
1543         }    //if (isCSCcand_){
1544       }      //if (stub->getKeyWG() == 0) {
1545     }
1546   }
1547 }