Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:52

0001 #include "DQM/L1TMonitor/interface/L1TGCT.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0004 
0005 // Trigger Headers
0006 
0007 // GCT and RCT data formats
0008 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0009 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0010 #include "DQMServices/Core/interface/DQMStore.h"
0011 
0012 using namespace edm;
0013 
0014 // Define statics for bins etc.
0015 const unsigned int JETETABINS = 22;
0016 const float JETETAMIN = -0.5;
0017 const float JETETAMAX = 21.5;
0018 
0019 const unsigned int EMETABINS = 22;
0020 const float EMETAMIN = -0.5;
0021 const float EMETAMAX = 21.5;
0022 
0023 const unsigned int METPHIBINS = 72;
0024 const float METPHIMIN = -0.5;
0025 const float METPHIMAX = 71.5;
0026 
0027 const unsigned int MHTPHIBINS = 18;
0028 const float MHTPHIMIN = -0.5;
0029 const float MHTPHIMAX = 17.5;
0030 
0031 const unsigned int PHIBINS = 18;
0032 const float PHIMIN = -0.5;
0033 const float PHIMAX = 17.5;
0034 
0035 const unsigned int OFBINS = 2;
0036 const float OFMIN = -0.5;
0037 const float OFMAX = 1.5;
0038 
0039 const unsigned int BXBINS = 5;
0040 const float BXMIN = -2.5;
0041 const float BXMAX = 2.5;
0042 
0043 // Bins for 3, 5, 6, 7, 10 and 12 bits
0044 const unsigned int R3BINS = 8;
0045 const float R3MIN = -0.5;
0046 const float R3MAX = 7.5;
0047 const unsigned int R5BINS = 32;
0048 const float R5MIN = -0.5;
0049 const float R5MAX = 31.5;
0050 const unsigned int R6BINS = 64;
0051 const float R6MIN = -0.5;
0052 const float R6MAX = 63.5;
0053 const unsigned int R7BINS = 128;
0054 const float R7MIN = -0.5;
0055 const float R7MAX = 127.5;
0056 const unsigned int R12BINS = 4096;
0057 const float R12MIN = -0.5;
0058 const float R12MAX = 4095.5;
0059 
0060 L1TGCT::L1TGCT(const edm::ParameterSet& ps)
0061     : monitorDir_(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0062       gctCenJetsSource_(ps.getParameter<edm::InputTag>("gctCentralJetsSource")),
0063       gctForJetsSource_(ps.getParameter<edm::InputTag>("gctForwardJetsSource")),
0064       gctTauJetsSource_(ps.getParameter<edm::InputTag>("gctTauJetsSource")),
0065       gctIsoTauJetsSource_(ps.getParameter<edm::InputTag>("gctIsoTauJetsSource")),
0066       gctEnergySumsSource_(ps.getParameter<edm::InputTag>("gctEnergySumsSource")),
0067       gctIsoEmSource_(ps.getParameter<edm::InputTag>("gctIsoEmSource")),
0068       gctNonIsoEmSource_(ps.getParameter<edm::InputTag>("gctNonIsoEmSource")),
0069       m_stage1_layer2_(ps.getParameter<bool>("stage1_layer2_")),
0070       filterTriggerType_(ps.getParameter<int>("filterTriggerType")) {
0071   // verbosity switch
0072   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0073 
0074   if (verbose_)
0075     edm::LogInfo("L1TGCT") << "L1TGCT: constructor...." << std::endl;
0076 
0077   outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
0078   if (!outputFile_.empty()) {
0079     edm::LogInfo("L1TGCT") << "L1T Monitoring histograms will be saved to " << outputFile_ << std::endl;
0080   }
0081 
0082   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
0083   if (disable) {
0084     outputFile_ = "";
0085   }
0086 
0087   //set Token(-s)
0088   gctIsoEmSourceToken_ = consumes<L1GctEmCandCollection>(ps.getParameter<edm::InputTag>("gctIsoEmSource"));
0089   gctNonIsoEmSourceToken_ = consumes<L1GctEmCandCollection>(ps.getParameter<edm::InputTag>("gctNonIsoEmSource"));
0090   gctCenJetsSourceToken_ = consumes<L1GctJetCandCollection>(ps.getParameter<edm::InputTag>("gctCentralJetsSource"));
0091   gctForJetsSourceToken_ = consumes<L1GctJetCandCollection>(ps.getParameter<edm::InputTag>("gctForwardJetsSource"));
0092   gctTauJetsSourceToken_ = consumes<L1GctJetCandCollection>(ps.getParameter<edm::InputTag>("gctTauJetsSource"));
0093   if (m_stage1_layer2_ == true) {
0094     gctIsoTauJetsSourceToken_ = consumes<L1GctJetCandCollection>(ps.getParameter<edm::InputTag>("gctIsoTauJetsSource"));
0095   }
0096   gctEnergySumsSourceToken_ =
0097       consumes<L1GctHFRingEtSumsCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0098   l1HFCountsToken_ = consumes<L1GctHFBitCountsCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0099   l1EtMissToken_ = consumes<L1GctEtMissCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0100   l1HtMissToken_ = consumes<L1GctHtMissCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0101   l1EtHadToken_ = consumes<L1GctEtHadCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0102   l1EtTotalToken_ = consumes<L1GctEtTotalCollection>(ps.getParameter<edm::InputTag>("gctEnergySumsSource"));
0103 }
0104 
0105 L1TGCT::~L1TGCT() {}
0106 
0107 void L1TGCT::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0108   nev_ = 0;
0109 
0110   ibooker.setCurrentFolder(monitorDir_);
0111 
0112   triggerType_ = ibooker.book1D("TriggerType", "TriggerType", 17, -0.5, 16.5);
0113 
0114   l1GctAllJetsEtEtaPhi_ = ibooker.book2D(
0115       "AllJetsEtEtaPhi", "CENTRAL AND FORWARD JET E_{T}", JETETABINS, JETETAMIN, JETETAMAX, PHIBINS, PHIMIN, PHIMAX);
0116   l1GctCenJetsEtEtaPhi_ =
0117       ibooker.book2D("CenJetsEtEtaPhi", "CENTRAL JET E_{T}", JETETABINS, JETETAMIN, JETETAMAX, PHIBINS, PHIMIN, PHIMAX);
0118   l1GctForJetsEtEtaPhi_ =
0119       ibooker.book2D("ForJetsEtEtaPhi", "FORWARD JET E_{T}", JETETABINS, JETETAMIN, JETETAMAX, PHIBINS, PHIMIN, PHIMAX);
0120   l1GctTauJetsEtEtaPhi_ =
0121       ibooker.book2D("TauJetsEtEtaPhi", "TAU JET E_{T}", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0122   if (m_stage1_layer2_ == true) {
0123     l1GctIsoTauJetsEtEtaPhi_ = ibooker.book2D(
0124         "IsoTauJetsEtEtaPhi", "ISOTAU JET E_{T}", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0125   }
0126   l1GctIsoEmRankEtaPhi_ =
0127       ibooker.book2D("IsoEmRankEtaPhi", "ISO EM E_{T}", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0128   l1GctNonIsoEmRankEtaPhi_ =
0129       ibooker.book2D("NonIsoEmRankEtaPhi", "NON-ISO EM E_{T}", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0130   l1GctAllJetsOccEtaPhi_ = ibooker.book2D("AllJetsOccEtaPhi",
0131                                           "CENTRAL AND FORWARD JET OCCUPANCY",
0132                                           JETETABINS,
0133                                           JETETAMIN,
0134                                           JETETAMAX,
0135                                           PHIBINS,
0136                                           PHIMIN,
0137                                           PHIMAX);
0138   l1GctCenJetsOccEtaPhi_ = ibooker.book2D(
0139       "CenJetsOccEtaPhi", "CENTRAL JET OCCUPANCY", JETETABINS, JETETAMIN, JETETAMAX, PHIBINS, PHIMIN, PHIMAX);
0140   l1GctForJetsOccEtaPhi_ = ibooker.book2D(
0141       "ForJetsOccEtaPhi", "FORWARD JET OCCUPANCY", JETETABINS, JETETAMIN, JETETAMAX, PHIBINS, PHIMIN, PHIMAX);
0142   l1GctTauJetsOccEtaPhi_ =
0143       ibooker.book2D("TauJetsOccEtaPhi", "TAU JET OCCUPANCY", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0144   if (m_stage1_layer2_ == true) {
0145     l1GctIsoTauJetsOccEtaPhi_ = ibooker.book2D(
0146         "IsoTauJetsOccEtaPhi", "ISOTAU JET OCCUPANCY", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0147   }
0148   l1GctIsoEmOccEtaPhi_ =
0149       ibooker.book2D("IsoEmOccEtaPhi", "ISO EM OCCUPANCY", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0150   l1GctNonIsoEmOccEtaPhi_ = ibooker.book2D(
0151       "NonIsoEmOccEtaPhi", "NON-ISO EM OCCUPANCY", EMETABINS, EMETAMIN, EMETAMAX, PHIBINS, PHIMIN, PHIMAX);
0152 
0153   //HF Ring stuff
0154 
0155   l1GctHFRing1TowerCountPosEtaNegEta_ = ibooker.book2D(
0156       "HFRing1TowerCountCorr", "HF RING1 TOWER COUNT CORRELATION +/-  #eta", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0157   l1GctHFRing2TowerCountPosEtaNegEta_ = ibooker.book2D(
0158       "HFRing2TowerCountCorr", "HF RING2 TOWER COUNT CORRELATION +/-  #eta", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0159 
0160   l1GctHFRing1TowerCountPosEta_ =
0161       ibooker.book1D("HFRing1TowerCountPosEta", "HF RING1 TOWER COUNT  #eta  +", R3BINS, R3MIN, R3MAX);
0162   l1GctHFRing1TowerCountNegEta_ =
0163       ibooker.book1D("HFRing1TowerCountNegEta", "HF RING1 TOWER COUNT  #eta  -", R3BINS, R3MIN, R3MAX);
0164   l1GctHFRing2TowerCountPosEta_ =
0165       ibooker.book1D("HFRing2TowerCountPosEta", "HF RING2 TOWER COUNT  #eta  +", R3BINS, R3MIN, R3MAX);
0166   l1GctHFRing2TowerCountNegEta_ =
0167       ibooker.book1D("HFRing2TowerCountNegEta", "HF RING2 TOWER COUNT  #eta  -", R3BINS, R3MIN, R3MAX);
0168 
0169   l1GctHFRingTowerCountOccBx_ =
0170       ibooker.book2D("HFRingTowerCountOccBx", "HF RING TOWER COUNT PER BX", BXBINS, BXMIN, BXMAX, R3BINS, R3MIN, R3MAX);
0171 
0172   if (m_stage1_layer2_ == false) {
0173     l1GctHFRing1PosEtaNegEta_ = ibooker.book2D(
0174         "HFRing1Corr", "HF RING1 E_{T} CORRELATION +/-  #eta", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0175     l1GctHFRing2PosEtaNegEta_ = ibooker.book2D(
0176         "HFRing2Corr", "HF RING2 E_{T} CORRELATION +/-  #eta", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0177     l1GctHFRing1ETSumPosEta_ = ibooker.book1D("HFRing1ETSumPosEta", "HF RING1 E_{T}  #eta  +", R3BINS, R3MIN, R3MAX);
0178     l1GctHFRing1ETSumNegEta_ = ibooker.book1D("HFRing1ETSumNegEta", "HF RING1 E_{T}  #eta  -", R3BINS, R3MIN, R3MAX);
0179     l1GctHFRing2ETSumPosEta_ = ibooker.book1D("HFRing2ETSumPosEta", "HF RING2 E_{T}  #eta  +", R3BINS, R3MIN, R3MAX);
0180     l1GctHFRing2ETSumNegEta_ = ibooker.book1D("HFRing2ETSumNegEta", "HF RING2 E_{T}  #eta  -", R3BINS, R3MIN, R3MAX);
0181     l1GctHFRingETSumOccBx_ =
0182         ibooker.book2D("HFRingETSumOccBx", "HF RING E_{T} PER BX", BXBINS, BXMIN, BXMAX, R3BINS, R3MIN, R3MAX);
0183     l1GctHFRingRatioPosEta_ = ibooker.book1D("HFRingRatioPosEta", "HF RING E_{T} RATIO  #eta  +", R5BINS, R5MIN, R5MAX);
0184     l1GctHFRingRatioNegEta_ = ibooker.book1D("HFRingRatioNegEta", "HF RING E_{T} RATIO  #eta  -", R5BINS, R5MIN, R5MAX);
0185   }
0186 
0187   if (m_stage1_layer2_ == true) {
0188     l1GctHFRing1PosEtaNegEta_ = ibooker.book2D(
0189         "IsoTau 1 2 Corr", "IsoTau 1 IsoTau 2 E_{T} CORRELATION", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0190     l1GctHFRing2PosEtaNegEta_ =
0191         ibooker.book2D("IsoTau 3 4 Corr", "IsoTau 3 IsoTau 4 CORRELATION", R3BINS, R3MIN, R3MAX, R3BINS, R3MIN, R3MAX);
0192     l1GctHFRing1ETSumPosEta_ = ibooker.book1D("Iso Tau 1 Et", "Isolated Tau1 E_{T}", 9, -0.5, 8.5);
0193     l1GctHFRing1ETSumNegEta_ = ibooker.book1D("Iso Tau 2 Et", "Isolated Tau2 E_{T}", 9, -0.5, 8.5);
0194     l1GctHFRing2ETSumPosEta_ = ibooker.book1D("Iso Tau 3 Et", "Isolated Tau3 E_{T}", 9, -0.5, 8.5);
0195     l1GctHFRing2ETSumNegEta_ = ibooker.book1D("Iso Tau 4 Et", "Isolated Tau4 E_{T}", 9, -0.5, 8.5);
0196     l1GctHFRingETSumOccBx_ =
0197         ibooker.book2D("IsoTau HFRingSum OccBx", "Iso Tau PER BX", BXBINS, BXMIN, BXMAX, R3BINS, R3MIN, R3MAX);
0198     l1GctHFRingRatioPosEta_ = ibooker.book1D("IsoTau Ratio 1 2", "IsoTau E_{T} RATIO", 9, -0.5, 8.5);
0199     l1GctHFRingRatioNegEta_ = ibooker.book1D("IsoTau Ratio 1 2", "IsoTau E_{T} RATIO", 9, -0.5, 8.5);
0200   }
0201 
0202   // Rank histograms
0203   l1GctCenJetsRank_ = ibooker.book1D("CenJetsRank", "CENTRAL JET E_{T}", R6BINS, R6MIN, R6MAX);
0204   l1GctForJetsRank_ = ibooker.book1D("ForJetsRank", "FORWARD JET E_{T}", R6BINS, R6MIN, R6MAX);
0205   l1GctTauJetsRank_ = ibooker.book1D("TauJetsRank", "TAU JET E_{T}", R6BINS, R6MIN, R6MAX);
0206   if (m_stage1_layer2_ == true) {
0207     l1GctIsoTauJetsRank_ = ibooker.book1D("IsoTauJetsRank", "ISOTAU JET E_{T}", R6BINS, R6MIN, R6MAX);
0208   }
0209   l1GctIsoEmRank_ = ibooker.book1D("IsoEmRank", "ISO EM E_{T}", R6BINS, R6MIN, R6MAX);
0210   l1GctNonIsoEmRank_ = ibooker.book1D("NonIsoEmRank", "NON-ISO EM E_{T}", R6BINS, R6MIN, R6MAX);
0211 
0212   l1GctAllJetsOccRankBx_ =
0213       ibooker.book2D("AllJetsOccRankBx", "ALL JETS E_{T} PER BX", BXBINS, BXMIN, BXMAX, R6BINS, R6MIN, R6MAX);
0214   l1GctAllEmOccRankBx_ =
0215       ibooker.book2D("AllEmOccRankBx", "ALL EM E_{T} PER BX", BXBINS, BXMIN, BXMAX, R6BINS, R6MIN, R6MAX);
0216 
0217   // Energy sums
0218   l1GctEtMiss_ = ibooker.book1D("EtMiss", "MET", R12BINS, R12MIN, R12MAX);
0219   l1GctEtMissPhi_ = ibooker.book1D("EtMissPhi", "MET  #phi", METPHIBINS, METPHIMIN, METPHIMAX);
0220   l1GctEtMissOf_ = ibooker.book1D("EtMissOf", "MET OVERFLOW", OFBINS, OFMIN, OFMAX);
0221   l1GctEtMissOccBx_ = ibooker.book2D("EtMissOccBx", "MET PER BX", BXBINS, BXMIN, BXMAX, R12BINS, R12MIN, R12MAX);
0222   if (m_stage1_layer2_ == false) {
0223     l1GctHtMiss_ = ibooker.book1D("HtMiss", "MHT", R7BINS, R7MIN, R7MAX);
0224     l1GctHtMissPhi_ = ibooker.book1D("HtMissPhi", "MHT  #phi", MHTPHIBINS, MHTPHIMIN, MHTPHIMAX);
0225     l1GctHtMissOf_ = ibooker.book1D("HtMissOf", "MHT OVERFLOW", OFBINS, OFMIN, OFMAX);
0226     l1GctHtMissOccBx_ = ibooker.book2D("HtMissOccBx", "MHT PER BX", BXBINS, BXMIN, BXMAX, R7BINS, R7MIN, R7MAX);
0227   }
0228   if (m_stage1_layer2_ == true) {
0229     l1GctHtMiss_ = ibooker.book1D("HtMissHtTotal", "MHTHT", R7BINS, R7MIN, R7MAX);
0230     l1GctHtMissPhi_ = ibooker.book1D("HtMissHtTotal Phi", "MHTHT  #phi", MHTPHIBINS, MHTPHIMIN, MHTPHIMAX);
0231     l1GctHtMissOf_ = ibooker.book1D("HtMissHtTotal Of", "MHTHT OVERFLOW", OFBINS, OFMIN, OFMAX);
0232     l1GctHtMissOccBx_ =
0233         ibooker.book2D("HtMissHtTotal OccBx", "MHTHT PER BX", BXBINS, BXMIN, BXMAX, R7BINS, R7MIN, R7MAX);
0234   }
0235   l1GctEtMissHtMissCorr_ =
0236       ibooker.book2D("EtMissHtMissCorr", "MET MHT CORRELATION", R6BINS, R12MIN, R12MAX, R6BINS, R7MIN, R7MAX);
0237   l1GctEtMissHtMissCorrPhi_ = ibooker.book2D("EtMissHtMissPhiCorr",
0238                                              "MET MHT  #phi  CORRELATION",
0239                                              METPHIBINS,
0240                                              METPHIMIN,
0241                                              METPHIMAX,
0242                                              MHTPHIBINS,
0243                                              MHTPHIMIN,
0244                                              MHTPHIMAX);
0245   l1GctEtTotal_ = ibooker.book1D("EtTotal", "SUM E_{T}", R12BINS, R12MIN, R12MAX);
0246   l1GctEtTotalOf_ = ibooker.book1D("EtTotalOf", "SUM E_{T} OVERFLOW", OFBINS, OFMIN, OFMAX);
0247   l1GctEtTotalOccBx_ =
0248       ibooker.book2D("EtTotalOccBx", "SUM E_{T} PER BX", BXBINS, BXMIN, BXMAX, R12BINS, R12MIN, R12MAX);
0249   l1GctEtHad_ = ibooker.book1D("EtHad", "H_{T}", R12BINS, R12MIN, R12MAX);
0250   l1GctEtHadOf_ = ibooker.book1D("EtHadOf", "H_{T} OVERFLOW", OFBINS, OFMIN, OFMAX);
0251   l1GctEtHadOccBx_ = ibooker.book2D("EtHadOccBx", "H_{T} PER BX", BXBINS, BXMIN, BXMAX, R12BINS, R12MIN, R12MAX);
0252   l1GctEtTotalEtHadCorr_ =
0253       ibooker.book2D("EtTotalEtHadCorr", "Sum E_{T} H_{T} CORRELATION", R6BINS, R12MIN, R12MAX, R6BINS, R12MIN, R12MAX);
0254   //}
0255 }
0256 
0257 void L1TGCT::analyze(const edm::Event& e, const edm::EventSetup& c) {
0258   nev_++;
0259   if (verbose_) {
0260     edm::LogInfo("L1TGCT") << "L1TGCT: analyze...." << std::endl;
0261   }
0262 
0263   // filter according trigger type
0264   //  enum ExperimentType {
0265   //        Undefined          =  0,
0266   //        PhysicsTrigger     =  1,
0267   //        CalibrationTrigger =  2,
0268   //        RandomTrigger      =  3,
0269   //        Reserved           =  4,
0270   //        TracedEvent        =  5,
0271   //        TestTrigger        =  6,
0272   //        ErrorTrigger       = 15
0273 
0274   // fill a histogram with the trigger type, for normalization fill also last bin
0275   // ErrorTrigger + 1
0276   double triggerType = static_cast<double>(e.experimentType()) + 0.001;
0277   double triggerTypeLast = static_cast<double>(edm::EventAuxiliary::ExperimentType::ErrorTrigger) + 0.001;
0278   triggerType_->Fill(triggerType);
0279   triggerType_->Fill(triggerTypeLast + 1);
0280 
0281   // filter only if trigger type is greater than 0, negative values disable filtering
0282   if (filterTriggerType_ >= 0) {
0283     // now filter, for real data only
0284     if (e.isRealData()) {
0285       if (!(e.experimentType() == filterTriggerType_)) {
0286         edm::LogInfo("L1TGCT") << "\n Event of TriggerType " << e.experimentType() << " rejected" << std::endl;
0287         return;
0288       }
0289     }
0290   }
0291 
0292   // Get all the collections
0293   edm::Handle<L1GctEmCandCollection> l1IsoEm;
0294   edm::Handle<L1GctEmCandCollection> l1NonIsoEm;
0295   edm::Handle<L1GctJetCandCollection> l1CenJets;
0296   edm::Handle<L1GctJetCandCollection> l1ForJets;
0297   edm::Handle<L1GctJetCandCollection> l1TauJets;
0298   if (m_stage1_layer2_ == true) {
0299     edm::Handle<L1GctJetCandCollection> l1IsoTauJets;
0300     e.getByToken(gctIsoTauJetsSourceToken_, l1IsoTauJets);
0301   }
0302   edm::Handle<L1GctHFRingEtSumsCollection> l1HFSums;
0303   edm::Handle<L1GctHFBitCountsCollection> l1HFCounts;
0304   edm::Handle<L1GctEtMissCollection> l1EtMiss;
0305   edm::Handle<L1GctHtMissCollection> l1HtMiss;
0306   edm::Handle<L1GctEtHadCollection> l1EtHad;
0307   edm::Handle<L1GctEtTotalCollection> l1EtTotal;
0308 
0309   e.getByToken(gctIsoEmSourceToken_, l1IsoEm);
0310   e.getByToken(gctNonIsoEmSourceToken_, l1NonIsoEm);
0311   e.getByToken(gctCenJetsSourceToken_, l1CenJets);
0312   e.getByToken(gctForJetsSourceToken_, l1ForJets);
0313   e.getByToken(gctTauJetsSourceToken_, l1TauJets);
0314   e.getByToken(gctEnergySumsSourceToken_, l1HFSums);
0315   e.getByToken(l1HFCountsToken_, l1HFCounts);
0316   e.getByToken(l1EtMissToken_, l1EtMiss);
0317   e.getByToken(l1HtMissToken_, l1HtMiss);
0318   e.getByToken(l1EtHadToken_, l1EtHad);
0319   e.getByToken(l1EtTotalToken_, l1EtTotal);
0320 
0321   // Fill histograms
0322 
0323   // Central jets
0324   if (l1CenJets.isValid()) {
0325     for (L1GctJetCandCollection::const_iterator cj = l1CenJets->begin(); cj != l1CenJets->end(); cj++) {
0326       // only plot central BX
0327       if (cj->bx() == 0) {
0328         l1GctCenJetsRank_->Fill(cj->rank());
0329         // only plot eta and phi maps for non-zero candidates
0330         if (cj->rank()) {
0331           l1GctAllJetsEtEtaPhi_->Fill(cj->regionId().ieta(), cj->regionId().iphi(), cj->rank());
0332           l1GctAllJetsOccEtaPhi_->Fill(cj->regionId().ieta(), cj->regionId().iphi());
0333           l1GctCenJetsEtEtaPhi_->Fill(cj->regionId().ieta(), cj->regionId().iphi(), cj->rank());
0334           l1GctCenJetsOccEtaPhi_->Fill(cj->regionId().ieta(), cj->regionId().iphi());
0335         }
0336       }
0337       if (cj->rank())
0338         l1GctAllJetsOccRankBx_->Fill(cj->bx(), cj->rank());  // for all BX
0339     }
0340   } else {
0341     edm::LogWarning("DataNotFound") << " Could not find l1CenJets label was " << gctCenJetsSource_;
0342   }
0343 
0344   // Forward jets
0345   if (l1ForJets.isValid()) {
0346     for (L1GctJetCandCollection::const_iterator fj = l1ForJets->begin(); fj != l1ForJets->end(); fj++) {
0347       // only plot central BX
0348       if (fj->bx() == 0) {
0349         l1GctForJetsRank_->Fill(fj->rank());
0350         // only plot eta and phi maps for non-zero candidates
0351         if (fj->rank()) {
0352           l1GctAllJetsEtEtaPhi_->Fill(fj->regionId().ieta(), fj->regionId().iphi(), fj->rank());
0353           l1GctAllJetsOccEtaPhi_->Fill(fj->regionId().ieta(), fj->regionId().iphi());
0354           l1GctForJetsEtEtaPhi_->Fill(fj->regionId().ieta(), fj->regionId().iphi(), fj->rank());
0355           l1GctForJetsOccEtaPhi_->Fill(fj->regionId().ieta(), fj->regionId().iphi());
0356         }
0357       }
0358       if (fj->rank())
0359         l1GctAllJetsOccRankBx_->Fill(fj->bx(), fj->rank());  // for all BX
0360     }
0361   } else {
0362     edm::LogWarning("DataNotFound") << " Could not find l1ForJets label was " << gctForJetsSource_;
0363   }
0364 
0365   // Tau jets
0366   if (l1TauJets.isValid()) {
0367     for (L1GctJetCandCollection::const_iterator tj = l1TauJets->begin(); tj != l1TauJets->end(); tj++) {
0368       // only plot central BX
0369       if (tj->bx() == 0) {
0370         l1GctTauJetsRank_->Fill(tj->rank());
0371         // only plot eta and phi maps for non-zero candidates
0372         if (tj->rank()) {
0373           l1GctTauJetsEtEtaPhi_->Fill(tj->regionId().ieta(), tj->regionId().iphi(), tj->rank());
0374           l1GctTauJetsOccEtaPhi_->Fill(tj->regionId().ieta(), tj->regionId().iphi());
0375         }
0376       }
0377       if (tj->rank())
0378         l1GctAllJetsOccRankBx_->Fill(tj->bx(), tj->rank());  // for all BX
0379     }
0380   } else {
0381     edm::LogWarning("DataNotFound") << " Could not find l1TauJets label was " << gctTauJetsSource_;
0382   }
0383 
0384   // IsoTau jets
0385   if (m_stage1_layer2_ == true) {
0386     edm::Handle<L1GctJetCandCollection> l1IsoTauJets;
0387     e.getByToken(gctIsoTauJetsSourceToken_, l1IsoTauJets);
0388     if (l1IsoTauJets.isValid()) {
0389       for (L1GctJetCandCollection::const_iterator itj = l1IsoTauJets->begin(); itj != l1IsoTauJets->end(); itj++) {
0390         // only plot central BX
0391         if (itj->bx() == 0) {
0392           l1GctIsoTauJetsRank_->Fill(itj->rank());
0393           // only plot eta and phi maps for non-zero candidates
0394           if (itj->rank()) {
0395             l1GctIsoTauJetsEtEtaPhi_->Fill(itj->regionId().ieta(), itj->regionId().iphi(), itj->rank());
0396             l1GctIsoTauJetsOccEtaPhi_->Fill(itj->regionId().ieta(), itj->regionId().iphi());
0397           }
0398         }
0399         if (itj->rank())
0400           l1GctAllJetsOccRankBx_->Fill(itj->bx(), itj->rank());  // for all BX
0401       }
0402     } else {
0403       edm::LogWarning("DataNotFound") << " Could not find l1IsoTauJets label was " << gctIsoTauJetsSource_;
0404     }
0405   }
0406 
0407   // Missing ET
0408   if (l1EtMiss.isValid()) {
0409     for (L1GctEtMissCollection::const_iterator met = l1EtMiss->begin(); met != l1EtMiss->end(); met++) {
0410       // only plot central BX
0411       if (met->bx() == 0) {
0412         if (met->overFlow() == 0 && met->et() > 0) {
0413           //Avoid problems with met=0 candidates affecting MET_PHI plots
0414           l1GctEtMiss_->Fill(met->et());
0415           l1GctEtMissPhi_->Fill(met->phi());
0416         }
0417         l1GctEtMissOf_->Fill(met->overFlow());
0418       }
0419       if (met->overFlow() == 0 && met->et() > 0)
0420         l1GctEtMissOccBx_->Fill(met->bx(), met->et());  // for all BX
0421     }
0422   } else {
0423     edm::LogWarning("DataNotFound") << " Could not find l1EtMiss label was " << gctEnergySumsSource_;
0424   }
0425 
0426   // Missing HT
0427   if (l1HtMiss.isValid()) {
0428     for (L1GctHtMissCollection::const_iterator mht = l1HtMiss->begin(); mht != l1HtMiss->end(); mht++) {
0429       // only plot central BX
0430       if (mht->bx() == 0) {
0431         if (mht->overFlow() == 0 && mht->et() > 0) {
0432           //Avoid problems with mht=0 candidates affecting MHT_PHI plots
0433           l1GctHtMiss_->Fill(mht->et());
0434           l1GctHtMissPhi_->Fill(mht->phi());
0435         }
0436         l1GctHtMissOf_->Fill(mht->overFlow());
0437       }
0438       if (mht->overFlow() == 0 && mht->et() > 0)
0439         l1GctHtMissOccBx_->Fill(mht->bx(), mht->et());  // for all BX
0440     }
0441   } else {
0442     edm::LogWarning("DataNotFound") << " Could not find l1HtMiss label was " << gctEnergySumsSource_;
0443   }
0444 
0445   // Missing ET HT correlations
0446   if (l1HtMiss.isValid() && l1EtMiss.isValid()) {
0447     if (l1HtMiss->size() == l1EtMiss->size()) {
0448       for (unsigned i = 0; i < l1HtMiss->size(); i++) {
0449         if (l1HtMiss->at(i).overFlow() == 0 && l1EtMiss->at(i).overFlow() == 0 && l1HtMiss->at(i).bx() == 0 &&
0450             l1EtMiss->at(i).bx() == 0) {
0451           // Avoid problems overflows and only plot central BX
0452           l1GctEtMissHtMissCorr_->Fill(l1EtMiss->at(i).et(), l1HtMiss->at(i).et());
0453           if (l1HtMiss->at(i).et() && l1EtMiss->at(i).et()) {  // Don't plot phi if one or other is zero
0454             l1GctEtMissHtMissCorrPhi_->Fill(l1EtMiss->at(i).phi(), l1HtMiss->at(i).phi());
0455           }
0456         }
0457       }
0458     }
0459   } else {
0460     edm::LogWarning("DataNotFound") << " Could not find l1EtMiss or l1HtMiss label was " << gctEnergySumsSource_;
0461   }
0462 
0463   // HT
0464   if (l1EtHad.isValid()) {
0465     for (L1GctEtHadCollection::const_iterator ht = l1EtHad->begin(); ht != l1EtHad->end(); ht++) {
0466       // only plot central BX
0467       if (ht->bx() == 0) {
0468         l1GctEtHad_->Fill(ht->et());
0469         l1GctEtHadOf_->Fill(ht->overFlow());
0470       }
0471       l1GctEtHadOccBx_->Fill(ht->bx(), ht->et());  // for all BX
0472     }
0473   } else {
0474     edm::LogWarning("DataNotFound") << " Could not find l1EtHad label was " << gctEnergySumsSource_;
0475   }
0476 
0477   // Total ET
0478   if (l1EtTotal.isValid()) {
0479     for (L1GctEtTotalCollection::const_iterator et = l1EtTotal->begin(); et != l1EtTotal->end(); et++) {
0480       // only plot central BX
0481       if (et->bx() == 0) {
0482         l1GctEtTotal_->Fill(et->et());
0483         l1GctEtTotalOf_->Fill(et->overFlow());
0484       }
0485       l1GctEtTotalOccBx_->Fill(et->bx(), et->et());  // for all BX
0486     }
0487   } else {
0488     edm::LogWarning("DataNotFound") << " Could not find l1EtTotal label was " << gctEnergySumsSource_;
0489   }
0490 
0491   // Total ET HT correlations
0492   if (l1EtTotal.isValid() && l1EtHad.isValid()) {
0493     if (l1EtTotal->size() == l1EtHad->size()) {
0494       for (unsigned i = 0; i < l1EtHad->size(); i++) {
0495         if (l1EtHad->at(i).overFlow() == 0 && l1EtTotal->at(i).overFlow() == 0 && l1EtHad->at(i).bx() == 0 &&
0496             l1EtTotal->at(i).bx() == 0) {
0497           // Avoid problems overflows and only plot central BX
0498           l1GctEtTotalEtHadCorr_->Fill(l1EtTotal->at(i).et(), l1EtHad->at(i).et());
0499         }
0500       }
0501     }
0502   } else {
0503     edm::LogWarning("DataNotFound") << " Could not find l1EtTotal or l1EtHad label was " << gctEnergySumsSource_;
0504   }
0505 
0506   //HF Ring Et Sums
0507   if (l1HFSums.isValid()) {
0508     for (L1GctHFRingEtSumsCollection::const_iterator hfs = l1HFSums->begin(); hfs != l1HFSums->end(); hfs++) {
0509       // only plot central BX
0510       if (hfs->bx() == 0) {
0511         // Individual ring Et sums
0512         l1GctHFRing1ETSumPosEta_->Fill(hfs->etSum(0));
0513         l1GctHFRing1ETSumNegEta_->Fill(hfs->etSum(1));
0514         l1GctHFRing2ETSumPosEta_->Fill(hfs->etSum(2));
0515         l1GctHFRing2ETSumNegEta_->Fill(hfs->etSum(3));
0516         // Ratio of ring Et sums
0517         if (hfs->etSum(2) != 0)
0518           l1GctHFRingRatioPosEta_->Fill((hfs->etSum(0)) / (hfs->etSum(2)));
0519         if (hfs->etSum(3) != 0)
0520           l1GctHFRingRatioNegEta_->Fill((hfs->etSum(1)) / (hfs->etSum(3)));
0521         // Correlate positive and neagative eta
0522         l1GctHFRing1PosEtaNegEta_->Fill(hfs->etSum(0), hfs->etSum(1));
0523         l1GctHFRing2PosEtaNegEta_->Fill(hfs->etSum(2), hfs->etSum(3));
0524       }
0525       // Occupancy vs BX
0526       for (unsigned i = 0; i < 4; i++) {
0527         l1GctHFRingETSumOccBx_->Fill(hfs->bx(), hfs->etSum(i));
0528       }
0529     }
0530   } else {
0531     edm::LogWarning("DataNotFound") << " Could not find l1HFSums label was " << gctEnergySumsSource_;
0532   }
0533 
0534   // HF Ring Counts
0535   if (l1HFCounts.isValid()) {
0536     for (L1GctHFBitCountsCollection::const_iterator hfc = l1HFCounts->begin(); hfc != l1HFCounts->end(); hfc++) {
0537       // only plot central BX
0538       if (hfc->bx() == 0) {
0539         // Individual ring counts
0540         l1GctHFRing1TowerCountPosEta_->Fill(hfc->bitCount(0));
0541         l1GctHFRing1TowerCountNegEta_->Fill(hfc->bitCount(1));
0542         l1GctHFRing2TowerCountPosEta_->Fill(hfc->bitCount(2));
0543         l1GctHFRing2TowerCountNegEta_->Fill(hfc->bitCount(3));
0544         // Correlate positive and negative eta
0545         l1GctHFRing1TowerCountPosEtaNegEta_->Fill(hfc->bitCount(0), hfc->bitCount(1));
0546         l1GctHFRing2TowerCountPosEtaNegEta_->Fill(hfc->bitCount(2), hfc->bitCount(3));
0547       }
0548       // Occupancy vs BX
0549       for (unsigned i = 0; i < 4; i++) {
0550         l1GctHFRingTowerCountOccBx_->Fill(hfc->bx(), hfc->bitCount(i));
0551       }
0552     }
0553   } else {
0554     edm::LogWarning("DataNotFound") << " Could not find l1HFCounts label was " << gctEnergySumsSource_;
0555   }
0556 
0557   // Isolated EM
0558   if (l1IsoEm.isValid()) {
0559     for (L1GctEmCandCollection::const_iterator ie = l1IsoEm->begin(); ie != l1IsoEm->end(); ie++) {
0560       // only plot central BX
0561       if (ie->bx() == 0) {
0562         l1GctIsoEmRank_->Fill(ie->rank());
0563         // only plot eta and phi maps for non-zero candidates
0564         if (ie->rank()) {
0565           l1GctIsoEmRankEtaPhi_->Fill(ie->regionId().ieta(), ie->regionId().iphi(), ie->rank());
0566           l1GctIsoEmOccEtaPhi_->Fill(ie->regionId().ieta(), ie->regionId().iphi());
0567         }
0568       }
0569       if (ie->rank())
0570         l1GctAllEmOccRankBx_->Fill(ie->bx(), ie->rank());  // for all BX
0571     }
0572   } else {
0573     edm::LogWarning("DataNotFound") << " Could not find l1IsoEm label was " << gctIsoEmSource_;
0574   }
0575 
0576   // Non-isolated EM
0577   if (l1NonIsoEm.isValid()) {
0578     for (L1GctEmCandCollection::const_iterator ne = l1NonIsoEm->begin(); ne != l1NonIsoEm->end(); ne++) {
0579       // only plot central BX
0580       if (ne->bx() == 0) {
0581         l1GctNonIsoEmRank_->Fill(ne->rank());
0582         // only plot eta and phi maps for non-zero candidates
0583         if (ne->rank()) {
0584           l1GctNonIsoEmRankEtaPhi_->Fill(ne->regionId().ieta(), ne->regionId().iphi(), ne->rank());
0585           l1GctNonIsoEmOccEtaPhi_->Fill(ne->regionId().ieta(), ne->regionId().iphi());
0586         }
0587       }
0588       if (ne->rank())
0589         l1GctAllEmOccRankBx_->Fill(ne->bx(), ne->rank());  // for all BX
0590     }
0591   } else {
0592     edm::LogWarning("DataNotFound") << " Could not find l1NonIsoEm label was " << gctNonIsoEmSource_;
0593   }
0594   edm::LogInfo("L1TGCT") << "L1TGCT: end job...." << std::endl;
0595   edm::LogInfo("EndJob") << "analyzed " << nev_ << " events";
0596 }