Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-04 02:02:46

0001 // -*- C++ -*-
0002 //
0003 // Package:     GctErrorAnalyzer
0004 // Class:   GctErrorAnalyzer
0005 //
0006 /**\class GctErrorAnalyzer GctErrorAnalyzer.cc L1Trigger/L1GctAnalyzer/src/GctErrorAnalyzer.cc
0007 
0008 Description: Tool to debug the GCT with useful output
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jad Marrouche
0015 //         Created:  Wed May 20 14:19:23 CEST 2009
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/EDAnalyzer.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #include "FWCore/Utilities/interface/InputTag.h"
0030 #include "FWCore/ServiceRegistry/interface/Service.h"
0031 //TFile maker include
0032 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0033 //ROOT includes
0034 #include "TH1.h"
0035 #include "TH2.h"
0036 #include "TAxis.h"
0037 //RCT and GCT DataFormat Collections
0038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0039 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0040 //GctErrorAnalyzer includes
0041 #include "L1Trigger/L1GctAnalyzer/interface/GctErrorAnalyzerDefinitions.h"
0042 #include "L1Trigger/L1GctAnalyzer/interface/compareCands.h"
0043 #include "L1Trigger/L1GctAnalyzer/interface/compareRingSums.h"
0044 #include "L1Trigger/L1GctAnalyzer/interface/compareBitCounts.h"
0045 #include "L1Trigger/L1GctAnalyzer/interface/compareTotalEnergySums.h"
0046 #include "L1Trigger/L1GctAnalyzer/interface/compareMissingEnergySums.h"
0047 //STL includes
0048 #include <string>
0049 #include <vector>
0050 #include <sstream>
0051 #include <algorithm>
0052 
0053 //
0054 // class declaration
0055 //
0056 
0057 class GctErrorAnalyzer : public edm::EDAnalyzer {
0058 public:
0059   GctErrorAnalyzer() = delete;
0060   GctErrorAnalyzer(const GctErrorAnalyzer &) = delete;
0061   GctErrorAnalyzer operator=(const GctErrorAnalyzer &) = delete;
0062 
0063 private:
0064   void plotRCTRegions(const edm::Handle<L1CaloRegionCollection> &caloRegions);
0065   void plotIsoEm(const edm::Handle<L1GctEmCandCollection> &data, const edm::Handle<L1GctEmCandCollection> &emu);
0066   void plotNonIsoEm(const edm::Handle<L1GctEmCandCollection> &data, const edm::Handle<L1GctEmCandCollection> &emu);
0067   void plotEGErrors(const edm::Handle<L1GctEmCandCollection> &dataiso,
0068                     const edm::Handle<L1GctEmCandCollection> &emuiso,
0069                     const edm::Handle<L1GctEmCandCollection> &datanoniso,
0070                     const edm::Handle<L1GctEmCandCollection> &emunoniso,
0071                     const edm::Handle<L1CaloEmCollection> &regions);
0072   void plotCenJets(const edm::Handle<L1GctJetCandCollection> &data, const edm::Handle<L1GctJetCandCollection> &emu);
0073   void plotTauJets(const edm::Handle<L1GctJetCandCollection> &data, const edm::Handle<L1GctJetCandCollection> &emu);
0074   void plotForJets(const edm::Handle<L1GctJetCandCollection> &data, const edm::Handle<L1GctJetCandCollection> &emu);
0075   void plotIntJets(const edm::Handle<L1GctInternJetDataCollection> &emu);
0076   static bool sortJets(const jetData &jet1,
0077                        const jetData &jet2);  //define this as static as it doesn't need a GctErrorAnalyzer object
0078   void plotJetErrors(const edm::Handle<L1GctJetCandCollection> &cendata,
0079                      const edm::Handle<L1GctJetCandCollection> &cenemu,
0080                      const edm::Handle<L1GctJetCandCollection> &taudata,
0081                      const edm::Handle<L1GctJetCandCollection> &tauemu,
0082                      const edm::Handle<L1GctJetCandCollection> &fordata,
0083                      const edm::Handle<L1GctJetCandCollection> &foremu,
0084                      const edm::Handle<L1CaloRegionCollection> &regions);
0085   void plotHFRingSums(const edm::Handle<L1GctHFRingEtSumsCollection> &data,
0086                       const edm::Handle<L1GctHFRingEtSumsCollection> &emu);
0087   void plotHFBitCounts(const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsD,
0088                        const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsE);
0089   void plotHFErrors(const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsD,
0090                     const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsE,
0091                     const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsD,
0092                     const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsE,
0093                     const edm::Handle<L1CaloRegionCollection> &caloRegions);
0094   void plotTotalE(const edm::Handle<L1GctEtTotalCollection> &totalEtD,
0095                   const edm::Handle<L1GctEtTotalCollection> &totalEtE);
0096   void plotTotalH(const edm::Handle<L1GctEtHadCollection> &totalHtD, const edm::Handle<L1GctEtHadCollection> &totalHtE);
0097   void plotTotalEErrors(const edm::Handle<L1GctEtTotalCollection> &totalEtD,
0098                         const edm::Handle<L1GctEtTotalCollection> &totalEtE,
0099                         const edm::Handle<L1GctEtHadCollection> &totalHtD,
0100                         const edm::Handle<L1GctEtHadCollection> &totalHtE,
0101                         const edm::Handle<L1CaloRegionCollection> &caloRegions);
0102   void plotMissingEt(const edm::Handle<L1GctEtMissCollection> &missingEtD,
0103                      const edm::Handle<L1GctEtMissCollection> &missingEtE);
0104   void plotMissingHt(const edm::Handle<L1GctHtMissCollection> &missingHtD,
0105                      const edm::Handle<L1GctHtMissCollection> &missingHtE);
0106   void plotMissingEErrors(const edm::Handle<L1GctEtMissCollection> &missingEtD,
0107                           const edm::Handle<L1GctEtMissCollection> &missingEtE,
0108                           const edm::Handle<L1GctHtMissCollection> &missingHtD,
0109                           const edm::Handle<L1GctHtMissCollection> &missingHtE,
0110                           edm::Handle<L1CaloRegionCollection> &caloRegions,
0111                           const edm::Handle<L1GctInternJetDataCollection> &intjetsemu,
0112                           const edm::Handle<L1GctInternHtMissCollection> intMissingHtD);
0113   template <class T>
0114   bool checkCollections(const T &collection, const unsigned int &constraint, const std::string &label);
0115 
0116 public:
0117   explicit GctErrorAnalyzer(const edm::ParameterSet &);
0118   ~GctErrorAnalyzer() override;
0119 
0120 private:
0121   void beginJob() override;
0122   void analyze(const edm::Event &, const edm::EventSetup &) override;
0123   void endJob() override;
0124 
0125   // ----------member data ---------------------------
0126   //the following flags select what we'd like to plot and whether or not we want error information
0127   bool doRCT_;
0128   bool doEg_;
0129   bool doIsoDebug_;
0130   bool doNonIsoDebug_;
0131   bool doJets_;
0132   bool doCenJetsDebug_;
0133   bool doTauJetsDebug_;
0134   bool doForJetsDebug_;
0135   bool doHF_;
0136   bool doRingSumDebug_;
0137   bool doBitCountDebug_;
0138   bool doTotalEnergySums_;
0139   bool doTotalEtDebug_;
0140   bool doTotalHtDebug_;
0141   bool doMissingEnergySums_;
0142   bool doMissingETDebug_;
0143   bool doMissingHTDebug_;
0144   bool doExtraMissingHTDebug_;
0145   //the following flags configure whether or not we want multiple BX behaviour for
0146   //1. RCT regions
0147   //2. Emulator output
0148   //3. Hardware output
0149   bool doRCTMBx_;
0150   bool doEmuMBx_;
0151   bool doGCTMBx_;
0152   //the following values select the definition of the "triggered" Bx i.e. where to define Bx=0
0153   int RCTTrigBx_;
0154   int EmuTrigBx_;
0155   int GCTTrigBx_;
0156   //the following flags contain the location of the hardware and emulator digis
0157   edm::InputTag dataTag_;
0158   edm::InputTag emuTag_;
0159   //the following is a string which dictates whether or not we want to use the lab or full system parameters
0160   std::string useSys_;
0161 
0162   //the following declares a struct to hold the MBX Info to make it easy to pass the information around
0163   GctErrorAnalyzerMBxInfo MBxInfo;
0164 
0165   // histograms
0166   //RCT Regions
0167   TH2I *RCT_EtEtaPhi_, *RCT_TvEtaPhi_, *RCT_FgEtaPhi_, *RCT_OfEtaPhi_;
0168   //isoEg
0169   TH1I *isoEgD_Rank_, *isoEgE_Rank_;
0170   TH2I *isoEgD_EtEtaPhi_, *isoEgE_EtEtaPhi_;
0171   TH2I *isoEgD_OccEtaPhi_, *isoEgE_OccEtaPhi_;
0172   TH1I *isoEg_errorFlag_;
0173   //Global Error Histograms
0174   TH1I *isoEgD_GlobalError_Rank_;
0175   TH1I *isoEgE_GlobalError_Rank_;
0176   TH2I *isoEgD_GlobalError_EtEtaPhi_;
0177   TH2I *isoEgE_GlobalError_EtEtaPhi_;
0178   //nonIsoEg
0179   TH1I *nonIsoEgD_Rank_, *nonIsoEgE_Rank_;
0180   TH2I *nonIsoEgD_EtEtaPhi_, *nonIsoEgE_EtEtaPhi_;
0181   TH2I *nonIsoEgD_OccEtaPhi_, *nonIsoEgE_OccEtaPhi_;
0182   TH1I *nonIsoEg_errorFlag_;
0183   //Global Error Histograms
0184   TH1I *nonIsoEgD_GlobalError_Rank_;
0185   TH1I *nonIsoEgE_GlobalError_Rank_;
0186   TH2I *nonIsoEgD_GlobalError_EtEtaPhi_;
0187   TH2I *nonIsoEgE_GlobalError_EtEtaPhi_;
0188   //cenJet
0189   TH1I *cenJetD_Rank_, *cenJetE_Rank_;
0190   TH2I *cenJetD_EtEtaPhi_, *cenJetE_EtEtaPhi_;
0191   TH2I *cenJetD_OccEtaPhi_, *cenJetE_OccEtaPhi_;
0192   TH1I *cenJet_errorFlag_;
0193   //Global Error Histograms
0194   TH1I *cenJetD_GlobalError_Rank_;
0195   TH1I *cenJetE_GlobalError_Rank_;
0196   TH2I *cenJetD_GlobalError_EtEtaPhi_;
0197   TH2I *cenJetE_GlobalError_EtEtaPhi_;
0198   //tauJet
0199   TH1I *tauJetD_Rank_, *tauJetE_Rank_;
0200   TH2I *tauJetD_EtEtaPhi_, *tauJetE_EtEtaPhi_;
0201   TH2I *tauJetD_OccEtaPhi_, *tauJetE_OccEtaPhi_;
0202   TH1I *tauJet_errorFlag_;
0203   //Global Error Histograms
0204   TH1I *tauJetD_GlobalError_Rank_;
0205   TH1I *tauJetE_GlobalError_Rank_;
0206   TH2I *tauJetD_GlobalError_EtEtaPhi_;
0207   TH2I *tauJetE_GlobalError_EtEtaPhi_;
0208   //forJet
0209   TH1I *forJetD_Rank_, *forJetE_Rank_;
0210   TH2I *forJetD_EtEtaPhi_, *forJetE_EtEtaPhi_;
0211   TH2I *forJetD_OccEtaPhi_, *forJetE_OccEtaPhi_;
0212   TH1I *forJet_errorFlag_;
0213   //Global Error Histograms
0214   TH1I *forJetD_GlobalError_Rank_;
0215   TH1I *forJetE_GlobalError_Rank_;
0216   TH2I *forJetD_GlobalError_EtEtaPhi_;
0217   TH2I *forJetE_GlobalError_EtEtaPhi_;
0218   //intJet
0219   TH2I *intJetEtEtaPhiE_;
0220   TH1I *intJetE_Et_;
0221   TH1I *intJetE_Of_;
0222   TH1I *intJetE_Jet1Et_;
0223   TH1I *intJetE_Jet2Et_;
0224   TH1I *intJetE_Jet3Et_;
0225   TH1I *intJetE_Jet4Et_;
0226   //ringSums
0227   TH1I *hfRingSumD_1pos_, *hfRingSumD_1neg_, *hfRingSumD_2pos_, *hfRingSumD_2neg_;
0228   TH1I *hfRingSumE_1pos_, *hfRingSumE_1neg_, *hfRingSumE_2pos_, *hfRingSumE_2neg_;
0229   TH1I *hfRingSum_errorFlag_;
0230   //bitcounts
0231   TH1I *hfBitCountD_1pos_, *hfBitCountD_1neg_, *hfBitCountD_2pos_, *hfBitCountD_2neg_;
0232   TH1I *hfBitCountE_1pos_, *hfBitCountE_1neg_, *hfBitCountE_2pos_, *hfBitCountE_2neg_;
0233   TH1I *hfBitCount_errorFlag_;
0234   //totalEt
0235   TH1I *totalEtD_, *totalEtE_;
0236   TH1I *totalEtD_Of_, *totalEtE_Of_;
0237   TH1I *totalEt_errorFlag_;
0238   //ET GlobalError Histograms
0239   //TH1I *totalEtD_GlobalError_, *totalEtE_GlobalError_;
0240   //TH1I *totalEtD_GlobalError_Of_, *totalEtE_GlobalError_Of_;
0241   //totalHt
0242   TH1I *totalHtD_, *totalHtE_;
0243   TH1I *totalHtD_Of_, *totalHtE_Of_;
0244   TH1I *totalHt_errorFlag_;
0245   //HT GlobalError Histograms
0246   //TH1I *totalHtD_GlobalError_, *totalHtE_GlobalError_;
0247   //TH1I *totalHtD_GlobalError_Of_, *totalHtE_GlobalError_Of_;
0248   //missingET
0249   TH1I *missingEtD_, *missingEtE_;
0250   TH1I *missingEtD_Of_, *missingEtE_Of_;
0251   TH1I *missingEtD_Phi_, *missingEtE_Phi_;
0252   TH1I *missingEt_errorFlag_;
0253   //missingHT
0254   TH1I *missingHtD_, *missingHtE_;
0255   TH1I *missingHtD_Of_, *missingHtE_Of_;
0256   TH1I *missingHtD_Phi_, *missingHtE_Phi_;
0257   TH1I *missingHt_errorFlag_;
0258   TH1I *missingHtD_HtXPosLeaf1, *missingHtD_HtXPosLeaf2, *missingHtD_HtXPosLeaf3, *missingHtD_HtXNegLeaf1,
0259       *missingHtD_HtXNegLeaf2, *missingHtD_HtXNegLeaf3;
0260   TH1I *missingHtD_HtYPosLeaf1, *missingHtD_HtYPosLeaf2, *missingHtD_HtYPosLeaf3, *missingHtD_HtYNegLeaf1,
0261       *missingHtD_HtYNegLeaf2, *missingHtD_HtYNegLeaf3;
0262 
0263   //error flags to decide whether or not to print debug info
0264   bool isIsoError;
0265   bool isNonIsoError;
0266   bool isCenJetError;
0267   bool isTauJetError;
0268   bool isForJetError;
0269   bool isRingSumError;
0270   bool isBitCountError;
0271   bool isTotalEError;
0272   bool isTotalHError;
0273   bool isMissingEError;
0274   bool isMissingHError;
0275 
0276   //Directories - put this here because we want to
0277   //add directories dynamically to this folder
0278   //depending on the errors we find
0279   std::vector<TFileDirectory> errorHistCat;
0280 
0281   //the event number
0282   unsigned int eventNumber;
0283 
0284   const unsigned int *RCT_REGION_QUANTA;
0285 };
0286 
0287 //
0288 // constants, enums and typedefs
0289 // use in conjunction with the templated bits
0290 typedef compareCands<edm::Handle<L1GctEmCandCollection> > compareEG;
0291 typedef compareCands<edm::Handle<L1GctJetCandCollection> > compareJets;
0292 typedef compareTotalEnergySums<edm::Handle<L1GctEtTotalCollection> > compareTotalE;
0293 typedef compareTotalEnergySums<edm::Handle<L1GctEtHadCollection> > compareTotalH;
0294 typedef compareMissingEnergySums<edm::Handle<L1GctEtMissCollection> > compareMissingE;
0295 typedef compareMissingEnergySums<edm::Handle<L1GctHtMissCollection> > compareMissingH;
0296 //
0297 // static data member definitions
0298 //
0299 
0300 //
0301 // constructors and destructor
0302 //
0303 GctErrorAnalyzer::GctErrorAnalyzer(const edm::ParameterSet &iConfig)
0304     : doRCT_(iConfig.getUntrackedParameter<bool>("doRCT", true)),
0305       doEg_(iConfig.getUntrackedParameter<bool>("doEg", true)),
0306       doIsoDebug_(iConfig.getUntrackedParameter<bool>("doIsoDebug", true)),
0307       doNonIsoDebug_(iConfig.getUntrackedParameter<bool>("doNonIsoDebug", true)),
0308       doJets_(iConfig.getUntrackedParameter<bool>("doJets", true)),
0309       doCenJetsDebug_(iConfig.getUntrackedParameter<bool>("doCenJetsDebug", true)),
0310       doTauJetsDebug_(iConfig.getUntrackedParameter<bool>("doTauJetsDebug", true)),
0311       doForJetsDebug_(iConfig.getUntrackedParameter<bool>("doForJetsDebug", true)),
0312       doHF_(iConfig.getUntrackedParameter<bool>("doHF", true)),
0313       doRingSumDebug_(iConfig.getUntrackedParameter<bool>("doRingSumDebug", true)),
0314       doBitCountDebug_(iConfig.getUntrackedParameter<bool>("doBitCountDebug", true)),
0315       doTotalEnergySums_(iConfig.getUntrackedParameter<bool>("doTotalEnergySums", true)),
0316       doTotalEtDebug_(iConfig.getUntrackedParameter<bool>("doTotalEtDebug", true)),
0317       doTotalHtDebug_(iConfig.getUntrackedParameter<bool>("doTotalHtDebug", true)),
0318       doMissingEnergySums_(iConfig.getUntrackedParameter<bool>("doMissingEnergySums", true)),
0319       doMissingETDebug_(iConfig.getUntrackedParameter<bool>("doMissingETDebug", true)),
0320       doMissingHTDebug_(iConfig.getUntrackedParameter<bool>("doMissingHTDebug", true)),
0321       doExtraMissingHTDebug_(iConfig.getUntrackedParameter<bool>("doExtraMissingHTDebug", false)),
0322       doRCTMBx_(iConfig.getUntrackedParameter<bool>("doRCTMBx", false)),
0323       doEmuMBx_(iConfig.getUntrackedParameter<bool>("doEmuMBx", false)),
0324       doGCTMBx_(iConfig.getUntrackedParameter<bool>("doGCTMBx", false)),
0325       RCTTrigBx_(iConfig.getUntrackedParameter<int>("RCTTrigBx", 0)),
0326       EmuTrigBx_(iConfig.getUntrackedParameter<int>("EmuTrigBx", 0)),
0327       GCTTrigBx_(iConfig.getUntrackedParameter<int>("GCTTrigBx", 0)),
0328       dataTag_(iConfig.getUntrackedParameter<edm::InputTag>("dataTag", edm::InputTag("gctDigis"))),
0329       emuTag_(iConfig.getUntrackedParameter<edm::InputTag>("emuTag", edm::InputTag("gctEmuDigis"))),
0330       useSys_(iConfig.getUntrackedParameter<std::string>("useSys", "P5")) {
0331   //now do what ever initialization is needed
0332   //make the root file
0333   edm::Service<TFileService> fs;
0334 
0335   //to try to make this look more elegant
0336   //make a string for each folder we'd like for the Data and Emulator Histograms
0337   std::vector<std::string> quantities;
0338   quantities.push_back("IsoEm");
0339   quantities.push_back("NonIsoEM");
0340   quantities.push_back("CenJets");
0341   quantities.push_back("TauJets");
0342   quantities.push_back("ForJets");
0343   quantities.push_back("HFRingSums");
0344   quantities.push_back("HFBitCounts");
0345   quantities.push_back("TotalESums");
0346   quantities.push_back("MissingESums");
0347 
0348   //make the Emulator Histogram directory
0349   TFileDirectory emuHist = fs->mkdir("EmulatorHistograms");
0350   std::vector<TFileDirectory> emuHistCat;
0351 
0352   //make the Data Histogram directory
0353   TFileDirectory dataHist = fs->mkdir("DataHistograms");
0354   std::vector<TFileDirectory> dataHistCat;
0355 
0356   //make the ErrorFlags directory
0357   TFileDirectory errorHistFlags = fs->mkdir("ErrorHistograms_Flags");
0358 
0359   //make the ErrorDebug directory
0360   TFileDirectory errorHistDetails = fs->mkdir("ErrorHistograms_Details");
0361 
0362   for (unsigned int i = 0; i < quantities.size(); i++) {
0363     //fill the data and emulator folders with the directories
0364     emuHistCat.push_back(emuHist.mkdir(quantities.at(i)));
0365     dataHistCat.push_back(dataHist.mkdir(quantities.at(i)));
0366   }
0367 
0368   //add a folder for RCT Regions - which only exist in data
0369   dataHistCat.push_back(dataHist.mkdir("RCTRegions"));
0370   //and add a folder for the Intermediate Jets - which only exist in emulator
0371   emuHistCat.push_back(emuHist.mkdir("IntJets"));
0372 
0373   //Fill the ErrorDebug folder with the directories
0374   errorHistCat.push_back(errorHistDetails.mkdir("EM"));
0375   errorHistCat.push_back(errorHistDetails.mkdir("Jets"));
0376   errorHistCat.push_back(errorHistDetails.mkdir("HF"));
0377   errorHistCat.push_back(errorHistDetails.mkdir("TotalE"));
0378   errorHistCat.push_back(errorHistDetails.mkdir("MissingE"));
0379 
0380   //BOOK HISTOGRAMS
0381   RCT_EtEtaPhi_ = dataHistCat.at(9).make<TH2I>(
0382       "RCT_EtEtaPhi", "RCT_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0383   RCT_TvEtaPhi_ = dataHistCat.at(9).make<TH2I>(
0384       "RCT_TvEtaPhi", "RCT_TvEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0385   RCT_FgEtaPhi_ = dataHistCat.at(9).make<TH2I>(
0386       "RCT_FgEtaPhi", "RCT_FgEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0387   RCT_OfEtaPhi_ = dataHistCat.at(9).make<TH2I>(
0388       "RCT_OfEtEtaPhi", "RCT_OfEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0389   //isoEg
0390   isoEgD_Rank_ = dataHistCat.at(0).make<TH1I>("isoEgD_Rank", "isoEgD_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0391   isoEgE_Rank_ = emuHistCat.at(0).make<TH1I>("isoEgE_Rank", "isoEgE_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0392   isoEgD_EtEtaPhi_ = dataHistCat.at(0).make<TH2I>(
0393       "isoEgD_EtEtaPhi", "isoEgD_EtEtaPhi;#eta (GCT Units);#phi(GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0394   isoEgE_EtEtaPhi_ = emuHistCat.at(0).make<TH2I>(
0395       "isoEgE_EtEtaPhi", "isoEgE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0396   isoEgD_OccEtaPhi_ = dataHistCat.at(0).make<TH2I>(
0397       "isoEgD_OccEtaPhi", "isoEgD_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0398   isoEgE_OccEtaPhi_ = emuHistCat.at(0).make<TH2I>(
0399       "isoEgE_OccEtaPhi", "isoEgE_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0400   isoEg_errorFlag_ =
0401       errorHistFlags.make<TH1I>("isoEg_errorFlag", "isoEg_errorFlag;Status;Number of Candidates", 3, -0.5, 2.5);
0402   //Global isoEg Error
0403   isoEgD_GlobalError_Rank_ = errorHistCat.at(0).make<TH1I>(
0404       "isoEgD_GlobalError_Rank", "isoEgD_GlobalError_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0405   isoEgE_GlobalError_Rank_ = errorHistCat.at(0).make<TH1I>(
0406       "isoEgE_GlobalError_Rank", "isoEgE_GlobalError_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0407   isoEgD_GlobalError_EtEtaPhi_ = errorHistCat.at(0).make<TH2I>(
0408       "isoEgD_GlobalError_EtEtaPhi", "isoEgD_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0409   isoEgE_GlobalError_EtEtaPhi_ = errorHistCat.at(0).make<TH2I>(
0410       "isoEgE_GlobalError_EtEtaPhi", "isoEgE_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0411   //nonIsoEg
0412   nonIsoEgD_Rank_ =
0413       dataHistCat.at(1).make<TH1I>("nonIsoEgD_Rank", "nonIsoEgD_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0414   nonIsoEgE_Rank_ =
0415       emuHistCat.at(1).make<TH1I>("nonIsoEgE_Rank", "nonIsoEgE_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0416   nonIsoEgD_EtEtaPhi_ = dataHistCat.at(1).make<TH2I>(
0417       "nonIsoEgD_EtEtaPhi", "nonIsoEgD_EtEtaPhi;#eta (GCT Units);#phi(GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0418   nonIsoEgE_EtEtaPhi_ = emuHistCat.at(1).make<TH2I>(
0419       "nonIsoEgE_EtEtaPhi", "nonIsoEgE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0420   nonIsoEgD_OccEtaPhi_ = dataHistCat.at(1).make<TH2I>(
0421       "nonIsoEgD_OccEtaPhi", "nonIsoEgD_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0422   nonIsoEgE_OccEtaPhi_ = emuHistCat.at(1).make<TH2I>(
0423       "nonIsoEgE_OccEtaPhi", "nonIsoEgE_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0424   nonIsoEg_errorFlag_ =
0425       errorHistFlags.make<TH1I>("nonIsoEg_errorFlag", "nonIsoEg_errorFlag;Status;Number of Candidates", 3, -0.5, 2.5);
0426   //Global nonIsoEg Error
0427   nonIsoEgD_GlobalError_Rank_ = errorHistCat.at(0).make<TH1I>(
0428       "nonIsoEgD_GlobalError_Rank", "nonIsoEgD_GlobalError_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0429   nonIsoEgE_GlobalError_Rank_ = errorHistCat.at(0).make<TH1I>(
0430       "nonIsoEgE_GlobalError_Rank", "nonIsoEgE_GlobalError_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0431   nonIsoEgD_GlobalError_EtEtaPhi_ = errorHistCat.at(0).make<TH2I>(
0432       "nonIsoEgD_GlobalError_EtEtaPhi", "nonIsoEgD_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0433   nonIsoEgE_GlobalError_EtEtaPhi_ = errorHistCat.at(0).make<TH2I>(
0434       "nonIsoEgE_GlobalError_EtEtaPhi", "nonIsoEgE_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0435   //CenJets
0436   cenJetD_Rank_ = dataHistCat.at(2).make<TH1I>("cenJetD_Rank", "cenJetD_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0437   cenJetE_Rank_ = emuHistCat.at(2).make<TH1I>("cenJetE_Rank", "cenJetE_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0438   cenJetD_EtEtaPhi_ = dataHistCat.at(2).make<TH2I>(
0439       "cenJetD_EtEtaPhi", "cenJetD_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0440   cenJetE_EtEtaPhi_ = emuHistCat.at(2).make<TH2I>(
0441       "cenJetE_EtEtaPhi", "cenJetE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0442   cenJetD_OccEtaPhi_ = dataHistCat.at(2).make<TH2I>(
0443       "cenJetD_OccEtaPhi", "cenJetD_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0444   cenJetE_OccEtaPhi_ = emuHistCat.at(2).make<TH2I>(
0445       "cenJetE_OccEtaPhi", "cenJetE_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0446   cenJet_errorFlag_ =
0447       errorHistFlags.make<TH1I>("cenJet_errorFlag", "cenJet_errorFlag;Status;Number of Candidates", 3, -0.5, 2.5);
0448   //Global CenJet Error
0449   cenJetD_GlobalError_Rank_ =
0450       errorHistCat.at(1).make<TH1I>("cenJetD_GlobalError_Rank", "cenJetD_GlobalError_Rank", 64, -0.5, 63.5);
0451   cenJetE_GlobalError_Rank_ =
0452       errorHistCat.at(1).make<TH1I>("cenJetE_GlobalError_Rank", "cenJetE_GlobalError_Rank", 64, -0.5, 63.5);
0453   cenJetD_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0454       "cenJetD_GlobalError_EtEtaPhi", "cenJetD_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0455   cenJetE_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0456       "cenJetE_GlobalError_EtEtaPhi", "cenJetE_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0457   //TauJets
0458   tauJetD_Rank_ = dataHistCat.at(3).make<TH1I>("tauJetD_Rank", "tauJetD_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0459   tauJetE_Rank_ = emuHistCat.at(3).make<TH1I>("tauJetE_Rank", "tauJetE_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0460   tauJetD_EtEtaPhi_ = dataHistCat.at(3).make<TH2I>(
0461       "tauJetD_EtEtaPhi", "tauJetD_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0462   tauJetE_EtEtaPhi_ = emuHistCat.at(3).make<TH2I>(
0463       "tauJetE_EtEtaPhi", "tauJetE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0464   tauJetD_OccEtaPhi_ = dataHistCat.at(3).make<TH2I>(
0465       "tauJetD_OccEtaPhi", "tauJetD_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0466   tauJetE_OccEtaPhi_ = emuHistCat.at(3).make<TH2I>(
0467       "tauJetE_OccEtaPhi", "tauJetE_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0468   tauJet_errorFlag_ =
0469       errorHistFlags.make<TH1I>("tauJet_errorFlag", "tauJet_errorFlag;Status;Number of Candidates", 3, -0.5, 2.5);
0470   //Global TauJet Error
0471   tauJetD_GlobalError_Rank_ =
0472       errorHistCat.at(1).make<TH1I>("tauJetD_GlobalError_Rank", "tauJetD_GlobalError_Rank", 64, -0.5, 63.5);
0473   tauJetE_GlobalError_Rank_ =
0474       errorHistCat.at(1).make<TH1I>("tauJetE_GlobalError_Rank", "tauJetE_GlobalError_Rank", 64, -0.5, 63.5);
0475   tauJetD_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0476       "tauJetD_GlobalError_EtEtaPhi", "tauJetD_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0477   tauJetE_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0478       "tauJetE_GlobalError_EtEtaPhi", "tauJetE_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0479   //ForJets
0480   forJetD_Rank_ = dataHistCat.at(4).make<TH1I>("forJetD_Rank", "forJetD_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0481   forJetE_Rank_ = emuHistCat.at(4).make<TH1I>("forJetE_Rank", "forJetE_Rank;Rank;Number of Events", 64, -0.5, 63.5);
0482   forJetD_EtEtaPhi_ = dataHistCat.at(4).make<TH2I>(
0483       "forJetD_EtEtaPhi", "forJetD_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0484   forJetE_EtEtaPhi_ = emuHistCat.at(4).make<TH2I>(
0485       "forJetE_EtEtaPhi", "forJetE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0486   forJetD_OccEtaPhi_ = dataHistCat.at(4).make<TH2I>(
0487       "forJetD_OccEtaPhi", "forJetD_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0488   forJetE_OccEtaPhi_ = emuHistCat.at(4).make<TH2I>(
0489       "forJetE_OccEtaPhi", "forJetE_OccEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0490   forJet_errorFlag_ =
0491       errorHistFlags.make<TH1I>("forJet_errorFlag", "forJet_errorFlag;Status;Number of Candidates", 3, -0.5, 2.5);
0492   //Global ForJet Error
0493   forJetD_GlobalError_Rank_ =
0494       errorHistCat.at(1).make<TH1I>("forJetD_GlobalError_Rank", "forJetD_GlobalError_Rank", 64, -0.5, 63.5);
0495   forJetE_GlobalError_Rank_ =
0496       errorHistCat.at(1).make<TH1I>("forJetE_GlobalError_Rank", "forJetE_GlobalError_Rank", 64, -0.5, 63.5);
0497   forJetD_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0498       "forJetD_GlobalError_EtEtaPhi", "forJetD_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0499   forJetE_GlobalError_EtEtaPhi_ = errorHistCat.at(1).make<TH2I>(
0500       "forJetE_GlobalError_EtEtaPhi", "forJetE_GlobalError_EtEtaPhi", 22, -0.5, 21.5, 18, -0.5, 17.5);
0501   //IntJets
0502   intJetEtEtaPhiE_ = emuHistCat.at(9).make<TH2I>(
0503       "intJetEtEtaPhiE_", "intJetEtEtaPhiE_;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
0504   intJetE_Et_ = emuHistCat.at(9).make<TH1I>("intJetE_Et", "intJetE_Et;E_{T};Number of Events", 1024, -0.5, 1023.5);
0505   intJetE_Of_ =
0506       emuHistCat.at(9).make<TH1I>("intJetE_Of", "intJetE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0507   intJetE_Jet1Et_ =
0508       emuHistCat.at(9).make<TH1I>("intJetE_Jet1Et", "intJetE_Jet1Et;E_{T};Number of Events", 1024, -0.5, 1023.5);
0509   intJetE_Jet2Et_ =
0510       emuHistCat.at(9).make<TH1I>("intJetE_Jet2Et", "intJetE_Jet2Et;E_{T};Number of Events", 1024, -0.5, 1023.5);
0511   intJetE_Jet3Et_ =
0512       emuHistCat.at(9).make<TH1I>("intJetE_Jet3Et", "intJetE_Jet3Et;E_{T};Number of Events", 1024, -0.5, 1023.5);
0513   intJetE_Jet4Et_ =
0514       emuHistCat.at(9).make<TH1I>("intJetE_Jet4Et", "intJetE_Jet4Et;E_{T};Number of Events", 1024, -0.5, 1023.5);
0515   //HFRing Sums
0516   hfRingSumD_1pos_ = dataHistCat.at(5).make<TH1I>("hfRingSumD_1+", "hfRingSumD_1+;Rank;Number of Events", 8, -0.5, 7.5);
0517   hfRingSumD_1neg_ = dataHistCat.at(5).make<TH1I>("hfRingSumD_1-", "hfRingSumD_1-;Rank;Number of Events", 8, -0.5, 7.5);
0518   hfRingSumD_2pos_ = dataHistCat.at(5).make<TH1I>("hfRingSumD_2+", "hfRingSumD_2+;Rank;Number of Events", 8, -0.5, 7.5);
0519   hfRingSumD_2neg_ = dataHistCat.at(5).make<TH1I>("hfRingSumD_2-", "hfRingSumD_2-;Rank;Number of Events", 8, -0.5, 7.5);
0520   hfRingSumE_1pos_ = emuHistCat.at(5).make<TH1I>("hfRingSumE_1+", "hfRingSumE_1+;Rank;Number of Events", 8, -0.5, 7.5);
0521   hfRingSumE_1neg_ = emuHistCat.at(5).make<TH1I>("hfRingSumE_1-", "hfRingSumE_1-;Rank;Number of Events", 8, -0.5, 7.5);
0522   hfRingSumE_2pos_ = emuHistCat.at(5).make<TH1I>("hfRingSumE_2+", "hfRingSumE_2+;Rank;Number of Events", 8, -0.5, 7.5);
0523   hfRingSumE_2neg_ = emuHistCat.at(5).make<TH1I>("hfRingSumE_2-", "hfRingSumE_2-;Rank;Number of Events", 8, -0.5, 7.5);
0524   hfRingSum_errorFlag_ =
0525       errorHistFlags.make<TH1I>("hfRingSum_errorFlag", "hfRingSum_errorFlag;Status;Number of Candidates", 2, -0.5, 1.5);
0526   //HFRing BitCounts
0527   hfBitCountD_1pos_ =
0528       dataHistCat.at(6).make<TH1I>("hfBitCountD_1+", "hfBitCountD_1+;Rank;Number of Events", 8, -0.5, 7.5);
0529   hfBitCountD_1neg_ =
0530       dataHistCat.at(6).make<TH1I>("hfBitCountD_1-", "hfBitCountD_1-;Rank;Number of Events", 8, -0.5, 7.5);
0531   hfBitCountD_2pos_ =
0532       dataHistCat.at(6).make<TH1I>("hfBitCountD_2+", "hfBitCountD_2+;Rank;Number of Events", 8, -0.5, 7.5);
0533   hfBitCountD_2neg_ =
0534       dataHistCat.at(6).make<TH1I>("hfBitCountD_2-", "hfBitCountD_2-;Rank;Number of Events", 8, -0.5, 7.5);
0535   hfBitCountE_1pos_ =
0536       emuHistCat.at(6).make<TH1I>("hfBitCountE_1+", "hfBitCountE_1+;Rank;Number of Events", 8, -0.5, 7.5);
0537   hfBitCountE_1neg_ =
0538       emuHistCat.at(6).make<TH1I>("hfBitCountE_1-", "hfBitCountE_1-;Rank;Number of Events", 8, -0.5, 7.5);
0539   hfBitCountE_2pos_ =
0540       emuHistCat.at(6).make<TH1I>("hfBitCountE_2+", "hfBitCountE_2+;Rank;Number of Events", 8, -0.5, 7.5);
0541   hfBitCountE_2neg_ =
0542       emuHistCat.at(6).make<TH1I>("hfBitCountE_2-", "hfBitCountE_2-;Rank;Number of Events", 8, -0.5, 7.5);
0543   hfBitCount_errorFlag_ = errorHistFlags.make<TH1I>(
0544       "hfBitCount_errorFlag", "hfBitCount_errorFlag;Status;Number of Candidates", 2, -0.5, 1.5);
0545   //Total ET
0546   totalEtD_ = dataHistCat.at(7).make<TH1I>("totalEtD", "totalEtD;E_{T};Number of Events", 2048, -0.5, 2047.5);
0547   totalEtD_Of_ =
0548       dataHistCat.at(7).make<TH1I>("totalEtD_Of", "totalEtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0549   totalEtE_ = emuHistCat.at(7).make<TH1I>("totalEtE", "totalEtE;E_{T};Number of Events", 2048, -0.5, 2047.5);
0550   totalEtE_Of_ =
0551       emuHistCat.at(7).make<TH1I>("totalEtE_Of", "totalEtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0552   totalEt_errorFlag_ =
0553       errorHistFlags.make<TH1I>("totalEt_errorFlag", "totalEt_errorFlag;Status;Number of Candidates", 2, -0.5, 1.5);
0554   //Book the Global ET Error histograms in the errorHistCat
0555   //totalEtD_GlobalError_ = errorHistCat.at(3).make<TH1I>("totalEtD_GlobalError", "totalEtD_GlobalError;E_{T};Number of Events", 1024, -0.5, 1023.5);
0556   //totalEtE_GlobalError_ = errorHistCat.at(3).make<TH1I>("totalEtE_GlobalError", "totalEtE_GlobalError;E_{T};Number of Events", 1024, -0.5, 1023.5);
0557   //totalEtD_GlobalError_Of_ = errorHistCat.at(3).make<TH1I>("totalEtD_GlobalError_Of", "totalEtD_GlobalError_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0558   //totalEtE_GlobalError_Of_ = errorHistCat.at(3).make<TH1I>("totalEtE_GlobalError_Of", "totalEtE_GlobalError_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0559   //Total HT
0560   totalHtD_ = dataHistCat.at(7).make<TH1I>("totalHtD", "totalHtD;H_{T};Number of Events", 2048, -0.5, 2047.5);
0561   totalHtD_Of_ =
0562       dataHistCat.at(7).make<TH1I>("totalHtD_Of", "totalHtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0563   totalHtE_ = emuHistCat.at(7).make<TH1I>("totalHtE", "totalHtE;H_{T};Number of Events", 2048, -0.5, 2047.5);
0564   totalHtE_Of_ =
0565       emuHistCat.at(7).make<TH1I>("totalHtE_Of", "totalHtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0566   totalHt_errorFlag_ =
0567       errorHistFlags.make<TH1I>("totalHt_errorFlag", "totalHt_errorFlag;Status;Number of Candidates", 2, -0.5, 1.5);
0568   //Book the Global HT Error histograms in the errorHistCat
0569   //totalHtD_GlobalError_ = errorHistCat.at(3).make<TH1I>("totalHtD_GlobalError", "totalHtD_GlobalError;E_{T};Number of Events", 1024, -0.5, 1023.5);
0570   //totalHtE_GlobalError_ = errorHistCat.at(3).make<TH1I>("totalHtE_GlobalError", "totalHtE_GlobalError;E_{T};Number of Events", 1024, -0.5, 1023.5);
0571   //totalHtD_GlobalError_Of_ = errorHistCat.at(3).make<TH1I>("totalHtD_GlobalError_Of", "totalHtD_GlobalError_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0572   //totalHtE_GlobalError_Of_ = errorHistCat.at(3).make<TH1I>("totalHtE_GlobalError_Of", "totalHtE_GlobalError_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0573   //MissingEt
0574   missingEtD_ =
0575       dataHistCat.at(8).make<TH1I>("missingEtD", "missingEtD;Missing E_{T};Number of Events", 1024, -0.5, 1023.5);
0576   missingEtD_Of_ =
0577       dataHistCat.at(8).make<TH1I>("missingEtD_Of", "missingEtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0578   missingEtD_Phi_ = dataHistCat.at(8).make<TH1I>(
0579       "missingEtD_Phi", "missingEtD_Phi;Missing E_{T} #phi;Number of Events", 72, -0.5, 71.5);
0580   missingEtE_ =
0581       emuHistCat.at(8).make<TH1I>("missingEtE", "missingEtE;Missing E_{T};Number of Events", 1024, -0.5, 1023.5);
0582   missingEtE_Of_ =
0583       emuHistCat.at(8).make<TH1I>("missingEtE_Of", "missingEtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0584   missingEtE_Phi_ = emuHistCat.at(8).make<TH1I>(
0585       "missingEtE_Phi", "missingEtE_Phi;Missing E_{T} #phi;Number of Events", 72, -0.5, 71.5);
0586   missingEt_errorFlag_ =
0587       errorHistFlags.make<TH1I>("missingEt_errorFlag", "missingEt_errorFlag;Status;Number of Candidates", 4, -0.5, 3.5);
0588   //MissingHt
0589   missingHtD_ =
0590       dataHistCat.at(8).make<TH1I>("missingHtD", "missingHtD;Missing H_{T};Number of Events", 1024, -0.5, 1023.5);
0591   missingHtD_Of_ =
0592       dataHistCat.at(8).make<TH1I>("missingHtD_Of", "missingHtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0593   missingHtD_Phi_ = dataHistCat.at(8).make<TH1I>(
0594       "missingHtD_Phi", "missingHtD_Phi;Missing H_{T} #phi;Number of Events", 72, -0.5, 71.5);
0595   missingHtE_ =
0596       emuHistCat.at(8).make<TH1I>("missingHtE", "missingHtE;Missing H_{T};Number of Events", 1024, -0.5, 1023.5);
0597   missingHtE_Of_ =
0598       emuHistCat.at(8).make<TH1I>("missingHtE_Of", "missingHtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
0599   missingHtE_Phi_ = emuHistCat.at(8).make<TH1I>(
0600       "missingHtE_Phi", "missingHtE_Phi;Missing H_{T} #phi;Number of Events", 72, -0.5, 71.5);
0601   missingHt_errorFlag_ =
0602       errorHistFlags.make<TH1I>("missingHt_errorFlag", "missingHt_errorFlag;Status;Number of Candidates", 4, -0.5, 3.5);
0603   //Additional MissingHt Debug histograms
0604   missingHtD_HtXPosLeaf1 = dataHistCat.at(8).make<TH1I>(
0605       "missingHtD_HtXPosLeaf1", "missingHtD;Missing H_{T} X PosLeaf1;Number of Events", 4096, -2048.5, 2047.5);
0606   missingHtD_HtXPosLeaf2 = dataHistCat.at(8).make<TH1I>(
0607       "missingHtD_HtXPosLeaf2", "missingHtD;Missing H_{T} X PosLeaf2;Number of Events", 4096, -2048.5, 2047.5);
0608   missingHtD_HtXPosLeaf3 = dataHistCat.at(8).make<TH1I>(
0609       "missingHtD_HtXPosLeaf3", "missingHtD;Missing H_{T} X PosLeaf3;Number of Events", 4096, -2048.5, 2047.5);
0610   missingHtD_HtXNegLeaf1 = dataHistCat.at(8).make<TH1I>(
0611       "missingHtD_HtXNegLeaf1", "missingHtD;Missing H_{T} X NegLeaf1;Number of Events", 4096, -2048.5, 2047.5);
0612   missingHtD_HtXNegLeaf2 = dataHistCat.at(8).make<TH1I>(
0613       "missingHtD_HtXNegLeaf2", "missingHtD;Missing H_{T} X NegLeaf2;Number of Events", 4096, -2048.5, 2047.5);
0614   missingHtD_HtXNegLeaf3 = dataHistCat.at(8).make<TH1I>(
0615       "missingHtD_HtXNegLeaf3", "missingHtD;Missing H_{T} X NegLeaf3;Number of Events", 4096, -2048.5, 2047.5);
0616 
0617   missingHtD_HtYPosLeaf1 = dataHistCat.at(8).make<TH1I>(
0618       "missingHtD_HtYPosLeaf1", "missingHtD;Missing H_{T} Y PosLeaf1;Number of Events", 4096, -2048.5, 2047.5);
0619   missingHtD_HtYPosLeaf2 = dataHistCat.at(8).make<TH1I>(
0620       "missingHtD_HtYPosLeaf2", "missingHtD;Missing H_{T} Y PosLeaf2;Number of Events", 4096, -2048.5, 2047.5);
0621   missingHtD_HtYPosLeaf3 = dataHistCat.at(8).make<TH1I>(
0622       "missingHtD_HtYPosLeaf3", "missingHtD;Missing H_{T} Y PosLeaf3;Number of Events", 4096, -2048.5, 2047.5);
0623   missingHtD_HtYNegLeaf1 = dataHistCat.at(8).make<TH1I>(
0624       "missingHtD_HtYNegLeaf1", "missingHtD;Missing H_{T} Y NegLeaf1;Number of Events", 4096, -2048.5, 2047.5);
0625   missingHtD_HtYNegLeaf2 = dataHistCat.at(8).make<TH1I>(
0626       "missingHtD_HtYNegLeaf2", "missingHtD;Missing H_{T} Y NegLeaf2;Number of Events", 4096, -2048.5, 2047.5);
0627   missingHtD_HtYNegLeaf3 = dataHistCat.at(8).make<TH1I>(
0628       "missingHtD_HtYNegLeaf3", "missingHtD;Missing H_{T} Y NegLeaf3;Number of Events", 4096, -2048.5, 2047.5);
0629 
0630   //Annotate the labels of the error flags
0631   //For the electrons and jets
0632   std::vector<std::string> errorFlagLabels;
0633   errorFlagLabels.push_back("Matched");
0634   errorFlagLabels.push_back("Unmatched Data Cand");
0635   errorFlagLabels.push_back("Unmatched Emul Cand");
0636 
0637   for (unsigned int i = 0; i < errorFlagLabels.size(); i++) {
0638     isoEg_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0639     nonIsoEg_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0640     cenJet_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0641     tauJet_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0642     forJet_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0643   }
0644   errorFlagLabels.clear();
0645 
0646   //For the Total Energy Sums and HF
0647   errorFlagLabels.push_back("Matched");
0648   errorFlagLabels.push_back("Unmatched");
0649 
0650   for (unsigned int i = 0; i < errorFlagLabels.size(); i++) {
0651     hfRingSum_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0652     hfBitCount_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0653     totalEt_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0654     totalHt_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0655   }
0656   errorFlagLabels.clear();
0657 
0658   //For the Missing Energy Sums
0659   errorFlagLabels.push_back("Matched");
0660   errorFlagLabels.push_back("Matched Mag");
0661   errorFlagLabels.push_back("Matched Phi");
0662   errorFlagLabels.push_back("Unmatched");
0663 
0664   for (unsigned int i = 0; i < errorFlagLabels.size(); i++) {
0665     missingEt_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0666     missingHt_errorFlag_->GetXaxis()->SetBinLabel(i + 1, errorFlagLabels.at(i).c_str());
0667   }
0668 
0669   //initialise - set all flags to false as they will be set on an event-by-event basis
0670   isIsoError = false;
0671   isNonIsoError = false;
0672   isCenJetError = false;
0673   isTauJetError = false;
0674   isForJetError = false;
0675   isRingSumError = false;
0676   isBitCountError = false;
0677   isTotalEError = false;
0678   isTotalHError = false;
0679   isMissingEError = false;
0680   isMissingHError = false;
0681 
0682   //fill the struct of MBXinformation. It is easier to pass this information to the respective functions as used below this way
0683   MBxInfo.RCTTrigBx = RCTTrigBx_;
0684   MBxInfo.EmuTrigBx = EmuTrigBx_;
0685   MBxInfo.GCTTrigBx = GCTTrigBx_;
0686 
0687   //set the parameters according to the system chosen
0688   if (useSys_ == "P5") {
0689     RCT_REGION_QUANTA = &RCT_REGION_QUANTA_P5;
0690   } else if (useSys_ == "Lab") {
0691     RCT_REGION_QUANTA = &RCT_REGION_QUANTA_LAB;
0692   } else {
0693     edm::LogWarning("ChosenSystem") << " "
0694                                     << "The system you chose to use (" << useSys_
0695                                     << ") was not recognised. Defaulting to the full system geometry";
0696     RCT_REGION_QUANTA = &RCT_REGION_QUANTA_P5;
0697   }
0698 }
0699 
0700 GctErrorAnalyzer::~GctErrorAnalyzer() {
0701   // do anything here that needs to be done at desctruction time
0702   // (e.g. close files, deallocate resources etc.)
0703 }
0704 
0705 //
0706 // member functions
0707 //
0708 
0709 // ------------ method called to for each event  ------------
0710 void GctErrorAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0711   using namespace edm;
0712   using namespace std;
0713 
0714   Handle<L1CaloRegionCollection> caloRegions;
0715   Handle<L1CaloEmCollection> emRegions;
0716 
0717   Handle<L1GctEmCandCollection> nonIsoEgD;
0718   Handle<L1GctEmCandCollection> nonIsoEgE;
0719   Handle<L1GctEmCandCollection> isoEgD;
0720   Handle<L1GctEmCandCollection> isoEgE;
0721 
0722   Handle<L1GctJetCandCollection> cenJetsD;
0723   Handle<L1GctJetCandCollection> cenJetsE;
0724   Handle<L1GctJetCandCollection> forJetsD;
0725   Handle<L1GctJetCandCollection> forJetsE;
0726   Handle<L1GctJetCandCollection> tauJetsD;
0727   Handle<L1GctJetCandCollection> tauJetsE;
0728 
0729   Handle<L1GctInternJetDataCollection> intJetsE;
0730 
0731   Handle<L1GctHFRingEtSumsCollection> hfRingSumsD;
0732   Handle<L1GctHFRingEtSumsCollection> hfRingSumsE;
0733 
0734   Handle<L1GctHFBitCountsCollection> hfBitCountsD;
0735   Handle<L1GctHFBitCountsCollection> hfBitCountsE;
0736 
0737   Handle<L1GctEtTotalCollection> totalEtD;
0738   Handle<L1GctEtTotalCollection> totalEtE;
0739 
0740   Handle<L1GctEtHadCollection> totalHtD;
0741   Handle<L1GctEtHadCollection> totalHtE;
0742 
0743   Handle<L1GctEtMissCollection> missingEtD;
0744   Handle<L1GctEtMissCollection> missingEtE;
0745 
0746   Handle<L1GctHtMissCollection> missingHtD;
0747   Handle<L1GctHtMissCollection> missingHtE;
0748 
0749   Handle<L1GctInternHtMissCollection> intHtMissD;
0750 
0751   //we need this for all user cases...
0752   iEvent.getByLabel(dataTag_.label(), caloRegions);
0753 
0754   //in order to allow the debug folders to have a unique name (so that when jobs are split in crab, we can merge)
0755   //use the eventnum in the folder name
0756   eventNumber = iEvent.id().event();
0757 
0758   if (doRCT_) {
0759     if (checkCollections(caloRegions, *RCT_REGION_QUANTA, "RCT CaloRegions"))
0760       plotRCTRegions(caloRegions);
0761   }
0762 
0763   if (doEg_) {
0764     iEvent.getByLabel(dataTag_.label(), "nonIsoEm", nonIsoEgD);
0765     iEvent.getByLabel(emuTag_.label(), "nonIsoEm", nonIsoEgE);
0766 
0767     iEvent.getByLabel(dataTag_.label(), "isoEm", isoEgD);
0768     iEvent.getByLabel(emuTag_.label(), "isoEm", isoEgE);
0769 
0770     isIsoError = false;
0771     isNonIsoError = false;
0772 
0773     if (checkCollections(isoEgD, GCT_OBJECT_QUANTA, "Iso e/g Data") &&
0774         checkCollections(isoEgE, GCT_OBJECT_QUANTA, "Iso e/g Emulator")) {
0775       plotIsoEm(isoEgD, isoEgE);
0776       compareEG isoCompare(isoEgD, isoEgE, MBxInfo);
0777       isIsoError = isoCompare.doCompare(isoEg_errorFlag_,
0778                                         isoEgD_GlobalError_Rank_,
0779                                         isoEgD_GlobalError_EtEtaPhi_,
0780                                         isoEgE_GlobalError_Rank_,
0781                                         isoEgE_GlobalError_EtEtaPhi_);
0782     }
0783 
0784     if (checkCollections(nonIsoEgD, GCT_OBJECT_QUANTA, "NonIso e/g Data") &&
0785         checkCollections(nonIsoEgE, GCT_OBJECT_QUANTA, "NonIso e/g Emulator")) {
0786       plotNonIsoEm(nonIsoEgD, nonIsoEgE);
0787       compareEG nonIsoCompare(nonIsoEgD, nonIsoEgE, MBxInfo);
0788       isNonIsoError = nonIsoCompare.doCompare(nonIsoEg_errorFlag_,
0789                                               nonIsoEgD_GlobalError_Rank_,
0790                                               nonIsoEgD_GlobalError_EtEtaPhi_,
0791                                               nonIsoEgE_GlobalError_Rank_,
0792                                               nonIsoEgE_GlobalError_EtEtaPhi_);
0793     }
0794 
0795     if ((isIsoError && doIsoDebug_) || (isNonIsoError && doNonIsoDebug_)) {
0796       iEvent.getByLabel(dataTag_.label(), emRegions);
0797       if (checkCollections(emRegions, RCT_EM_OBJECT_QUANTA, "RCT EMRegions"))
0798         plotEGErrors(isoEgD, isoEgE, nonIsoEgD, nonIsoEgE, emRegions);
0799     }
0800   }
0801 
0802   if (doJets_) {
0803     iEvent.getByLabel(emuTag_.label(), "cenJets", cenJetsE);
0804     iEvent.getByLabel(dataTag_.label(), "cenJets", cenJetsD);
0805 
0806     iEvent.getByLabel(emuTag_.label(), "forJets", forJetsE);
0807     iEvent.getByLabel(dataTag_.label(), "forJets", forJetsD);
0808 
0809     iEvent.getByLabel(emuTag_.label(), "tauJets", tauJetsE);
0810     iEvent.getByLabel(dataTag_.label(), "tauJets", tauJetsD);
0811 
0812     iEvent.getByLabel(emuTag_.label(), intJetsE);
0813 
0814     isCenJetError = false;
0815     isTauJetError = false;
0816     isForJetError = false;
0817 
0818     //Central Jets
0819     if (checkCollections(cenJetsD, GCT_OBJECT_QUANTA, "Central Jets Data") &&
0820         checkCollections(cenJetsE, GCT_OBJECT_QUANTA, "Central Jets Emulator")) {
0821       plotCenJets(cenJetsD, cenJetsE);
0822       compareJets cenJetsCompare(cenJetsD, cenJetsE, MBxInfo);
0823       isCenJetError = cenJetsCompare.doCompare(cenJet_errorFlag_,
0824                                                cenJetD_GlobalError_Rank_,
0825                                                cenJetD_GlobalError_EtEtaPhi_,
0826                                                cenJetE_GlobalError_Rank_,
0827                                                cenJetE_GlobalError_EtEtaPhi_);
0828     }
0829 
0830     //Tau Jets
0831     if (checkCollections(tauJetsD, GCT_OBJECT_QUANTA, "Tau Jets Data") &&
0832         checkCollections(tauJetsE, GCT_OBJECT_QUANTA, "Tau Jets Emulator")) {
0833       plotTauJets(tauJetsD, tauJetsE);
0834       compareJets tauJetsCompare(tauJetsD, tauJetsE, MBxInfo);
0835       isTauJetError = tauJetsCompare.doCompare(tauJet_errorFlag_,
0836                                                tauJetD_GlobalError_Rank_,
0837                                                tauJetD_GlobalError_EtEtaPhi_,
0838                                                tauJetE_GlobalError_Rank_,
0839                                                tauJetE_GlobalError_EtEtaPhi_);
0840     }
0841 
0842     //For Jets
0843     if (checkCollections(forJetsD, GCT_OBJECT_QUANTA, "Forward Jets Data") &&
0844         checkCollections(forJetsE, GCT_OBJECT_QUANTA, "Forward Jets Emulator")) {
0845       plotForJets(forJetsD, forJetsE);
0846       compareJets forJetsCompare(forJetsD, forJetsE, MBxInfo);
0847       isForJetError = forJetsCompare.doCompare(forJet_errorFlag_,
0848                                                forJetD_GlobalError_Rank_,
0849                                                forJetD_GlobalError_EtEtaPhi_,
0850                                                forJetE_GlobalError_Rank_,
0851                                                forJetE_GlobalError_EtEtaPhi_);
0852     }
0853 
0854     //Emulator Intermediate Jets
0855     if (checkCollections(intJetsE, NUM_INT_JETS, "Intermediate Jets Emulator"))
0856       plotIntJets(intJetsE);
0857 
0858     if ((isCenJetError && doCenJetsDebug_) || (isTauJetError && doTauJetsDebug_) ||
0859         (isForJetError && doForJetsDebug_)) {
0860       plotJetErrors(cenJetsD, cenJetsE, tauJetsD, tauJetsE, forJetsD, forJetsE, caloRegions);
0861     }
0862   }
0863 
0864   if (doHF_) {
0865     iEvent.getByLabel(dataTag_.label(), hfRingSumsD);
0866     iEvent.getByLabel(emuTag_.label(), hfRingSumsE);
0867 
0868     iEvent.getByLabel(dataTag_.label(), hfBitCountsD);
0869     iEvent.getByLabel(emuTag_.label(), hfBitCountsE);
0870 
0871     isRingSumError = false;
0872     isBitCountError = false;
0873 
0874     if (checkCollections(hfRingSumsD, GCT_SUMS_QUANTA, "HF Ring Sums Data") &&
0875         checkCollections(hfRingSumsE, GCT_SUMS_QUANTA, "HF Ring Sums Emulator")) {
0876       plotHFRingSums(hfRingSumsD, hfRingSumsE);
0877       compareRingSums HFRingSums(hfRingSumsD, hfRingSumsE, MBxInfo);
0878       isRingSumError = HFRingSums.doCompare(hfRingSum_errorFlag_);
0879     }
0880 
0881     if (checkCollections(hfBitCountsD, GCT_SUMS_QUANTA, "HF Bit Counts Data") &&
0882         checkCollections(hfBitCountsE, GCT_SUMS_QUANTA, "HF Bit Counts Emulator")) {
0883       plotHFBitCounts(hfBitCountsD, hfBitCountsE);
0884       compareBitCounts HFBitCounts(hfBitCountsD, hfBitCountsE, MBxInfo);
0885       isBitCountError = HFBitCounts.doCompare(hfBitCount_errorFlag_);
0886     }
0887 
0888     if ((isRingSumError && doRingSumDebug_) || (isBitCountError && doBitCountDebug_)) {
0889       plotHFErrors(hfRingSumsD, hfRingSumsE, hfBitCountsD, hfBitCountsE, caloRegions);
0890     }
0891   }
0892 
0893   if (doTotalEnergySums_) {
0894     iEvent.getByLabel(dataTag_.label(), totalEtD);
0895     iEvent.getByLabel(emuTag_.label(), totalEtE);
0896 
0897     iEvent.getByLabel(dataTag_.label(), totalHtD);
0898     iEvent.getByLabel(emuTag_.label(), totalHtE);
0899 
0900     isTotalEError = false;
0901     isTotalHError = false;
0902 
0903     if (checkCollections(totalEtD, GCT_SUMS_QUANTA, "Total Et Data") &&
0904         checkCollections(totalEtE, GCT_SUMS_QUANTA, "Total Et Emulator")) {
0905       plotTotalE(totalEtD, totalEtE);
0906       compareTotalE compareET(totalEtD, totalEtE, MBxInfo);
0907       isTotalEError = compareET.doCompare(totalEt_errorFlag_);
0908     }
0909 
0910     if (checkCollections(totalHtD, GCT_SUMS_QUANTA, "Total Ht Data") &&
0911         checkCollections(totalHtE, GCT_SUMS_QUANTA, "Total Ht Emulator")) {
0912       plotTotalH(totalHtD, totalHtE);
0913       compareTotalH compareHT(totalHtD, totalHtE, MBxInfo);
0914       isTotalHError = compareHT.doCompare(totalHt_errorFlag_);
0915     }
0916 
0917     if ((isTotalEError && doTotalEtDebug_) || (isTotalHError && doTotalHtDebug_)) {
0918       plotTotalEErrors(totalEtD, totalEtE, totalHtD, totalHtE, caloRegions);
0919     }
0920   }
0921 
0922   if (doMissingEnergySums_) {
0923     iEvent.getByLabel(dataTag_.label(), missingEtD);
0924     iEvent.getByLabel(emuTag_.label(), missingEtE);
0925 
0926     iEvent.getByLabel(dataTag_.label(), missingHtD);
0927     iEvent.getByLabel(emuTag_.label(), missingHtE);
0928 
0929     isMissingEError = false;
0930     isMissingHError = false;
0931 
0932     if (checkCollections(missingEtD, GCT_SUMS_QUANTA, "Missing Et Data") &&
0933         checkCollections(missingEtE, GCT_SUMS_QUANTA, "Missing Et Emulator")) {
0934       plotMissingEt(missingEtD, missingEtE);
0935       compareMissingE compareMET(missingEtD, missingEtE, MBxInfo);
0936       isMissingEError = compareMET.doCompare(missingEt_errorFlag_);
0937     }
0938 
0939     if (checkCollections(missingHtD, GCT_SUMS_QUANTA, "Missing Ht Data") &&
0940         checkCollections(missingHtE, GCT_SUMS_QUANTA, "Missing Ht Emulator")) {
0941       plotMissingHt(missingHtD, missingHtE);
0942       compareMissingH compareMHT(missingHtD, missingHtE, MBxInfo);
0943       isMissingHError = compareMHT.doCompare(missingHt_errorFlag_);
0944 
0945       //added 19/03/2010 for intermediate information on MissingHt quantities in the data
0946       if (doExtraMissingHTDebug_) {
0947         iEvent.getByLabel(dataTag_.label(), "", intHtMissD);
0948         if (checkCollections(intHtMissD, GCT_INT_HTMISS_QUANTA, "Internal Missing Ht Data")) {
0949           for (unsigned int i = 0; i < intHtMissD->size(); i++) {
0950             if (doGCTMBx_ || intHtMissD->at(i).bx() == GCTTrigBx_) {
0951               if (!intHtMissD->at(i).overflow()) {
0952                 //the capBlock 0x301 is the input pipeline at the wheel for positive eta, whereas 0x701 is for negative eta
0953                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 0 &&
0954                     intHtMissD->at(i).isThereHtx())
0955                   missingHtD_HtXPosLeaf1->Fill(intHtMissD->at(i).htx());
0956                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 1 &&
0957                     intHtMissD->at(i).isThereHtx())
0958                   missingHtD_HtXPosLeaf2->Fill(intHtMissD->at(i).htx());
0959                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 2 &&
0960                     intHtMissD->at(i).isThereHtx())
0961                   missingHtD_HtXPosLeaf3->Fill(intHtMissD->at(i).htx());
0962                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 0 &&
0963                     intHtMissD->at(i).isThereHtx())
0964                   missingHtD_HtXNegLeaf1->Fill(intHtMissD->at(i).htx());
0965                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 1 &&
0966                     intHtMissD->at(i).isThereHtx())
0967                   missingHtD_HtXNegLeaf2->Fill(intHtMissD->at(i).htx());
0968                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 2 &&
0969                     intHtMissD->at(i).isThereHtx())
0970                   missingHtD_HtXNegLeaf3->Fill(intHtMissD->at(i).htx());
0971 
0972                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 0 &&
0973                     intHtMissD->at(i).isThereHty())
0974                   missingHtD_HtYPosLeaf1->Fill(intHtMissD->at(i).hty());
0975                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 1 &&
0976                     intHtMissD->at(i).isThereHty())
0977                   missingHtD_HtYPosLeaf2->Fill(intHtMissD->at(i).hty());
0978                 if (intHtMissD->at(i).capBlock() == 0x301 && intHtMissD->at(i).capIndex() == 2 &&
0979                     intHtMissD->at(i).isThereHty())
0980                   missingHtD_HtYPosLeaf3->Fill(intHtMissD->at(i).hty());
0981                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 0 &&
0982                     intHtMissD->at(i).isThereHty())
0983                   missingHtD_HtYNegLeaf1->Fill(intHtMissD->at(i).hty());
0984                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 1 &&
0985                     intHtMissD->at(i).isThereHty())
0986                   missingHtD_HtYNegLeaf2->Fill(intHtMissD->at(i).hty());
0987                 if (intHtMissD->at(i).capBlock() == 0x701 && intHtMissD->at(i).capIndex() == 2 &&
0988                     intHtMissD->at(i).isThereHty())
0989                   missingHtD_HtYNegLeaf3->Fill(intHtMissD->at(i).hty());
0990               }
0991             }
0992           }
0993         }
0994       }
0995     }
0996 
0997     if ((isMissingEError && doMissingETDebug_) || (isMissingHError && doMissingHTDebug_)) {
0998       plotMissingEErrors(missingEtD, missingEtE, missingHtD, missingHtE, caloRegions, intJetsE, intHtMissD);
0999     }
1000   }
1001 }
1002 
1003 // ------------ method called once each job just before starting event loop  ------------
1004 void GctErrorAnalyzer::beginJob() {}
1005 
1006 // ------------ method called once each job just after ending the event loop  ------------
1007 void GctErrorAnalyzer::endJob() {}
1008 
1009 void GctErrorAnalyzer::plotRCTRegions(const edm::Handle<L1CaloRegionCollection> &caloRegions) {
1010   //if more than one Bx is readout per event, then caloRegions->size() will be some multiple of 396
1011   for (unsigned int i = 0; i < caloRegions->size(); i++) {
1012     //if the RCTMBx flag is set to true, write out all the info into the same histogram
1013     //otherwise only the RCTTrigBx will be written out - could skip (RCT_REGION_QUANTA-1) events here to speed things up...
1014     if (doRCTMBx_ || caloRegions->at(i).bx() == RCTTrigBx_) {
1015       if (caloRegions->at(i).et() > 0)
1016         RCT_EtEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi(), caloRegions->at(i).et());
1017       if (caloRegions->at(i).tauVeto())
1018         RCT_TvEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1019       if (caloRegions->at(i).fineGrain())
1020         RCT_FgEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1021       if (caloRegions->at(i).overFlow())
1022         RCT_OfEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1023     }
1024   }
1025 }
1026 
1027 void GctErrorAnalyzer::plotIsoEm(const edm::Handle<L1GctEmCandCollection> &isoEgD,
1028                                  const edm::Handle<L1GctEmCandCollection> &isoEgE) {
1029   //loop over all the data candidates - if multiple bx, then this should be a multiple of GCT_OBJECT_QUANTA
1030   for (unsigned int i = 0; i < isoEgD->size(); i++) {
1031     //if the GCTMBx flag is set, plot all Bx for this quantity, otherwise only plot Bx = GCTTrigBx_
1032     if (doGCTMBx_ || isoEgD->at(i).bx() == GCTTrigBx_) {
1033       isoEgD_Rank_->Fill(isoEgD->at(i).rank());
1034       if (isoEgD->at(i).rank() > 0) {
1035         isoEgD_EtEtaPhi_->Fill(isoEgD->at(i).regionId().ieta(), isoEgD->at(i).regionId().iphi(), isoEgD->at(i).rank());
1036         isoEgD_OccEtaPhi_->Fill(isoEgD->at(i).regionId().ieta(), isoEgD->at(i).regionId().iphi());
1037       }
1038     }
1039   }
1040   //now repeat for the emulator candidates
1041   for (unsigned int i = 0; i < isoEgE->size(); i++) {
1042     if (doEmuMBx_ || isoEgE->at(i).bx() == EmuTrigBx_) {
1043       isoEgE_Rank_->Fill(isoEgE->at(i).rank());
1044       if (isoEgE->at(i).rank() > 0) {
1045         isoEgE_EtEtaPhi_->Fill(isoEgE->at(i).regionId().ieta(), isoEgE->at(i).regionId().iphi(), isoEgE->at(i).rank());
1046         isoEgE_OccEtaPhi_->Fill(isoEgE->at(i).regionId().ieta(), isoEgE->at(i).regionId().iphi());
1047       }
1048     }
1049   }
1050 }
1051 
1052 void GctErrorAnalyzer::plotNonIsoEm(const edm::Handle<L1GctEmCandCollection> &nonIsoEgD,
1053                                     const edm::Handle<L1GctEmCandCollection> &nonIsoEgE) {
1054   //loop over all the data candidates - if multiple bx, then this should be a multiple of GCT_OBJECT_QUANTA
1055   for (unsigned int i = 0; i < nonIsoEgD->size(); i++) {
1056     //if the GCTMBx flag is set, plot all Bx for this quantity, otherwise only plot Bx = GCTTrigBx_
1057     if (doGCTMBx_ || nonIsoEgD->at(i).bx() == GCTTrigBx_) {
1058       nonIsoEgD_Rank_->Fill(nonIsoEgD->at(i).rank());
1059       if (nonIsoEgD->at(i).rank() > 0) {
1060         nonIsoEgD_EtEtaPhi_->Fill(
1061             nonIsoEgD->at(i).regionId().ieta(), nonIsoEgD->at(i).regionId().iphi(), nonIsoEgD->at(i).rank());
1062         nonIsoEgD_OccEtaPhi_->Fill(nonIsoEgD->at(i).regionId().ieta(), nonIsoEgD->at(i).regionId().iphi());
1063       }
1064     }
1065   }
1066   //now repeat for the emulator candidates
1067   for (unsigned int i = 0; i < nonIsoEgE->size(); i++) {
1068     if (doEmuMBx_ || nonIsoEgE->at(i).bx() == EmuTrigBx_) {
1069       nonIsoEgE_Rank_->Fill(nonIsoEgE->at(i).rank());
1070       if (nonIsoEgE->at(i).rank() > 0) {
1071         nonIsoEgE_EtEtaPhi_->Fill(
1072             nonIsoEgE->at(i).regionId().ieta(), nonIsoEgE->at(i).regionId().iphi(), nonIsoEgE->at(i).rank());
1073         nonIsoEgE_OccEtaPhi_->Fill(nonIsoEgE->at(i).regionId().ieta(), nonIsoEgE->at(i).regionId().iphi());
1074       }
1075     }
1076   }
1077 }
1078 
1079 void GctErrorAnalyzer::plotEGErrors(const edm::Handle<L1GctEmCandCollection> &isoEgD,
1080                                     const edm::Handle<L1GctEmCandCollection> &isoEgE,
1081                                     const edm::Handle<L1GctEmCandCollection> &nonIsoEgD,
1082                                     const edm::Handle<L1GctEmCandCollection> &nonIsoEgE,
1083                                     const edm::Handle<L1CaloEmCollection> &emRegions) {
1084   std::string errorDirName = "err_";
1085   if (isIsoError)
1086     errorDirName.append("I");
1087   if (isNonIsoError)
1088     errorDirName.append("N");
1089   std::stringstream caseNumber;
1090   caseNumber << eventNumber;
1091   errorDirName.append(caseNumber.str());
1092   TFileDirectory errorDir = errorHistCat.at(0).mkdir(errorDirName);
1093 
1094   TH2I *errorEmRegionIsoEtEtaPhi_ = errorDir.make<TH2I>("errorEmRegionIsoEtEtaPhi",
1095                                                         "errorEmRegionIsoEtEtaPhi;#eta (GCT Units);#phi (GCT Units)",
1096                                                         22,
1097                                                         -0.5,
1098                                                         21.5,
1099                                                         18,
1100                                                         -0.5,
1101                                                         17.5);
1102   TH2I *errorEmRegionNonIsoEtEtaPhi_ =
1103       errorDir.make<TH2I>("errorEmRegionNonIsoEtEtaPhi",
1104                           "errorEmRegionNonIsoEtEtaPhi;#eta (GCT Units);#phi (GCT Units)",
1105                           22,
1106                           -0.5,
1107                           21.5,
1108                           18,
1109                           -0.5,
1110                           17.5);
1111   TH2I *errorIsoEtEtaPhiD_ = errorDir.make<TH2I>(
1112       "errorIsoEtEtaPhiD", "errorIsoEtEtaPhiD;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1113   TH2I *errorNonIsoEtEtaPhiD_ = errorDir.make<TH2I>(
1114       "errorNonIsoEtEtaPhiD", "errorNonIsoEtEtaPhiD;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1115   TH2I *errorIsoEtEtaPhiE_ = errorDir.make<TH2I>(
1116       "errorIsoEtEtaPhiE", "errorIsoEtEtaPhiE;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1117   TH2I *errorNonIsoEtEtaPhiE_ = errorDir.make<TH2I>(
1118       "errorNonIsoEtEtaPhiE", "errorNonIsoEtEtaPhiE;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1119 
1120   //fill the EM input collection
1121   //should only fill the correct bx for emRegions - and since this is showing an error in the comparison, we should plot the input to this comparison i.e. Bx=RCTTrigBx
1122   //this assumes that comparison is done on the central Bx i.e. RctBx=0 corresponds to GctBx=0, and EmuBx=0 takes RctBx=0
1123   for (unsigned int i = 0; i < emRegions->size(); i++) {
1124     if (emRegions->at(i).bx() == RCTTrigBx_) {
1125       if (emRegions->at(i).isolated()) {
1126         if (emRegions->at(i).rank() > 0)
1127           errorEmRegionIsoEtEtaPhi_->Fill(
1128               emRegions->at(i).regionId().ieta(), emRegions->at(i).regionId().iphi(), emRegions->at(i).rank());
1129       } else {
1130         if (emRegions->at(i).rank() > 0)
1131           errorEmRegionNonIsoEtEtaPhi_->Fill(
1132               emRegions->at(i).regionId().ieta(), emRegions->at(i).regionId().iphi(), emRegions->at(i).rank());
1133       }
1134     }
1135   }
1136 
1137   //no need to have the rank plot, because you can't have two electrons in the same place (eta,phi), in the same event...
1138   //in this case, since we're actually comparing the GCTTrigBx_ with the EmuTrigBx_, we plot these individually
1139   for (unsigned int i = 0; i < isoEgD->size(); i++) {
1140     if (isoEgD->at(i).bx() == GCTTrigBx_) {
1141       if (isoEgD->at(i).rank() > 0)
1142         errorIsoEtEtaPhiD_->Fill(
1143             isoEgD->at(i).regionId().ieta(), isoEgD->at(i).regionId().iphi(), isoEgD->at(i).rank());
1144     }
1145   }
1146   for (unsigned int i = 0; i < nonIsoEgD->size(); i++) {
1147     if (nonIsoEgD->at(i).bx() == GCTTrigBx_) {
1148       if (nonIsoEgD->at(i).rank() > 0)
1149         errorNonIsoEtEtaPhiD_->Fill(
1150             nonIsoEgD->at(i).regionId().ieta(), nonIsoEgD->at(i).regionId().iphi(), nonIsoEgD->at(i).rank());
1151     }
1152   }
1153 
1154   //now for the emulator candidates
1155   for (unsigned int i = 0; i < isoEgE->size(); i++) {
1156     if (isoEgE->at(i).bx() == EmuTrigBx_) {
1157       if (isoEgE->at(i).rank() > 0)
1158         errorIsoEtEtaPhiE_->Fill(
1159             isoEgE->at(i).regionId().ieta(), isoEgE->at(i).regionId().iphi(), isoEgE->at(i).rank());
1160     }
1161   }
1162   for (unsigned int i = 0; i < nonIsoEgE->size(); i++) {
1163     if (nonIsoEgE->at(i).bx() == EmuTrigBx_) {
1164       if (nonIsoEgE->at(i).rank() > 0)
1165         errorNonIsoEtEtaPhiE_->Fill(
1166             nonIsoEgE->at(i).regionId().ieta(), nonIsoEgE->at(i).regionId().iphi(), nonIsoEgE->at(i).rank());
1167     }
1168   }
1169 }
1170 
1171 void GctErrorAnalyzer::plotCenJets(const edm::Handle<L1GctJetCandCollection> &cenJetsD,
1172                                    const edm::Handle<L1GctJetCandCollection> &cenJetsE) {
1173   for (unsigned int i = 0; i < cenJetsD->size(); i++) {
1174     if (doGCTMBx_ || cenJetsD->at(i).bx() == GCTTrigBx_) {
1175       cenJetD_Rank_->Fill(cenJetsD->at(i).rank());
1176       if (cenJetsD->at(i).rank() > 0) {
1177         cenJetD_EtEtaPhi_->Fill(
1178             cenJetsD->at(i).regionId().ieta(), cenJetsD->at(i).regionId().iphi(), cenJetsD->at(i).rank());
1179         cenJetD_OccEtaPhi_->Fill(cenJetsD->at(i).regionId().ieta(), cenJetsD->at(i).regionId().iphi());
1180       }
1181     }
1182   }
1183 
1184   for (unsigned int i = 0; i < cenJetsE->size(); i++) {
1185     if (doEmuMBx_ || cenJetsE->at(i).bx() == EmuTrigBx_) {
1186       cenJetE_Rank_->Fill(cenJetsE->at(i).rank());
1187       if (cenJetsE->at(i).rank() > 0) {
1188         cenJetE_EtEtaPhi_->Fill(
1189             cenJetsE->at(i).regionId().ieta(), cenJetsE->at(i).regionId().iphi(), cenJetsE->at(i).rank());
1190         cenJetE_OccEtaPhi_->Fill(cenJetsE->at(i).regionId().ieta(), cenJetsE->at(i).regionId().iphi());
1191       }
1192     }
1193   }
1194 }
1195 
1196 void GctErrorAnalyzer::plotTauJets(const edm::Handle<L1GctJetCandCollection> &tauJetsD,
1197                                    const edm::Handle<L1GctJetCandCollection> &tauJetsE) {
1198   for (unsigned int i = 0; i < tauJetsD->size(); i++) {
1199     if (doGCTMBx_ || tauJetsD->at(i).bx() == GCTTrigBx_) {
1200       tauJetD_Rank_->Fill(tauJetsD->at(i).rank());
1201       if (tauJetsD->at(i).rank() > 0) {
1202         tauJetD_EtEtaPhi_->Fill(
1203             tauJetsD->at(i).regionId().ieta(), tauJetsD->at(i).regionId().iphi(), tauJetsD->at(i).rank());
1204         tauJetD_OccEtaPhi_->Fill(tauJetsD->at(i).regionId().ieta(), tauJetsD->at(i).regionId().iphi());
1205       }
1206     }
1207   }
1208 
1209   for (unsigned int i = 0; i < tauJetsE->size(); i++) {
1210     if (doEmuMBx_ || tauJetsE->at(i).bx() == EmuTrigBx_) {
1211       tauJetE_Rank_->Fill(tauJetsE->at(i).rank());
1212       if (tauJetsE->at(i).rank() > 0) {
1213         tauJetE_EtEtaPhi_->Fill(
1214             tauJetsE->at(i).regionId().ieta(), tauJetsE->at(i).regionId().iphi(), tauJetsE->at(i).rank());
1215         tauJetE_OccEtaPhi_->Fill(tauJetsE->at(i).regionId().ieta(), tauJetsE->at(i).regionId().iphi());
1216       }
1217     }
1218   }
1219 }
1220 
1221 void GctErrorAnalyzer::plotForJets(const edm::Handle<L1GctJetCandCollection> &forJetsD,
1222                                    const edm::Handle<L1GctJetCandCollection> &forJetsE) {
1223   for (unsigned int i = 0; i < forJetsD->size(); i++) {
1224     if (doGCTMBx_ || forJetsD->at(i).bx() == GCTTrigBx_) {
1225       forJetD_Rank_->Fill(forJetsD->at(i).rank());
1226       if (forJetsD->at(i).rank() > 0) {
1227         forJetD_EtEtaPhi_->Fill(
1228             forJetsD->at(i).regionId().ieta(), forJetsD->at(i).regionId().iphi(), forJetsD->at(i).rank());
1229         forJetD_OccEtaPhi_->Fill(forJetsD->at(i).regionId().ieta(), forJetsD->at(i).regionId().iphi());
1230       }
1231     }
1232   }
1233 
1234   for (unsigned int i = 0; i < forJetsE->size(); i++) {
1235     if (doEmuMBx_ || forJetsE->at(i).bx() == EmuTrigBx_) {
1236       forJetE_Rank_->Fill(forJetsE->at(i).rank());
1237       if (forJetsE->at(i).rank() > 0) {
1238         forJetE_EtEtaPhi_->Fill(
1239             forJetsE->at(i).regionId().ieta(), forJetsE->at(i).regionId().iphi(), forJetsE->at(i).rank());
1240         forJetE_OccEtaPhi_->Fill(forJetsE->at(i).regionId().ieta(), forJetsE->at(i).regionId().iphi());
1241       }
1242     }
1243   }
1244 }
1245 
1246 void GctErrorAnalyzer::plotIntJets(const edm::Handle<L1GctInternJetDataCollection> &intJetsE) {
1247   jetData intJet;
1248   std::vector<jetData> intJetCollection(
1249       NUM_INT_JETS);  //define fixed size for the vector to avoid reallocation (i.e. max size possible)
1250 
1251   //since we don't read out the intermediate (i.e. leaf card) jets, we can only plot the emulator distributions
1252   //the 1st-4th jet Et will prove useful in understanding and motivating cuts on individual jets in HT and MHT.
1253   for (unsigned int i = 0; i < intJetsE->size(); i++) {
1254     if (doEmuMBx_ || intJetsE->at(i).bx() == EmuTrigBx_) {
1255       //the intermediate jets are not sorted in terms of Et so
1256       //in order to do this independently of the data format,
1257       //copy to a user defined struct and sort that way
1258       intJet.et = intJetsE->at(i).et();
1259       intJet.phi = intJetsE->at(i).phi();
1260       intJet.eta = intJetsE->at(i).eta();
1261       intJetCollection.at(i % NUM_INT_JETS) = intJet;
1262 
1263       //remember, if the event has 1 overflowed jet, then we fill the internal jet dist overflow histogram
1264       //and skip the event - there is no point looking at the leading jet distributions etc for an event
1265       //with an overflowed jet - this will imply HT, ET, MET and MHT all overflow too.
1266       if (intJetsE->at(i).oflow()) {
1267         intJetE_Of_->Fill(intJetsE->at(i).oflow());
1268         return;
1269       }
1270 
1271       //plot the (et,eta,phi) distribution of the intermediate jets (for non-zero et)
1272       if (intJetsE->at(i).et())
1273         intJetEtEtaPhiE_->Fill(
1274             intJetsE->at(i).regionId().ieta(), intJetsE->at(i).regionId().iphi(), intJetsE->at(i).et());
1275     }
1276   }
1277 
1278   //if we get this far, there are no jets with an overflow bit so fill the overflow histogram and
1279   //sort the intJetCollection according to the rule defined in sortJets (i.e. largest et first)
1280   intJetE_Of_->Fill(0);
1281   std::sort(intJetCollection.begin(), intJetCollection.end(), sortJets);
1282 
1283   std::vector<TH1I *> leadingJetDist(4);
1284   leadingJetDist.at(0) = intJetE_Jet1Et_;
1285   leadingJetDist.at(1) = intJetE_Jet2Et_;
1286   leadingJetDist.at(2) = intJetE_Jet3Et_;
1287   leadingJetDist.at(3) = intJetE_Jet4Et_;
1288 
1289   unsigned int i = 0;
1290   unsigned int j = 0;
1291   unsigned int currentEt = 0;
1292   while (intJetCollection.at(i).et > 0) {
1293     if (j < leadingJetDist.size()) {
1294       if (i == 0) {
1295         leadingJetDist.at(j)->Fill(intJetCollection.at(i).et);
1296         currentEt = intJetCollection.at(i).et;
1297         j++;
1298       } else {
1299         if (intJetCollection.at(i).et < currentEt) {
1300           leadingJetDist.at(j)->Fill(intJetCollection.at(i).et);
1301           currentEt = intJetCollection.at(i).et;
1302           j++;
1303         }
1304       }
1305     }
1306 
1307     intJetE_Et_->Fill(intJetCollection.at(i).et);
1308     i++;
1309   }
1310   return;
1311 }
1312 
1313 bool GctErrorAnalyzer::sortJets(const jetData &jet1, const jetData &jet2) { return jet1.et > jet2.et; }
1314 
1315 template <class T>
1316 bool GctErrorAnalyzer::checkCollections(const T &collection, const unsigned int &constraint, const std::string &label) {
1317   //unfortunately, the dataformats are not consistent with the name() method (i.e. some have it, others don't)
1318   //and a typeof() function doesn't exist in ANSI C++, so to identify the templated type, we pass a std::string
1319 
1320   if (!collection.isValid()) {
1321     edm::LogWarning("DataNotFound") << " Could not find " << label << " label";
1322     return false;
1323   }
1324   if (collection->size() % constraint != 0 || collection->empty()) {
1325     edm::LogWarning("CollectionSizeError")
1326         << " " << label << " collection size is " << collection->size() << ", expected multiple of " << constraint;
1327     return false;
1328   }
1329 
1330   return true;
1331 }
1332 
1333 void GctErrorAnalyzer::plotJetErrors(const edm::Handle<L1GctJetCandCollection> &cenJetsD,
1334                                      const edm::Handle<L1GctJetCandCollection> &cenJetsE,
1335                                      const edm::Handle<L1GctJetCandCollection> &tauJetsD,
1336                                      const edm::Handle<L1GctJetCandCollection> &tauJetsE,
1337                                      const edm::Handle<L1GctJetCandCollection> &forJetsD,
1338                                      const edm::Handle<L1GctJetCandCollection> &forJetsE,
1339                                      const edm::Handle<L1CaloRegionCollection> &caloRegions) {
1340   std::string errorDirName = "err_";
1341   if (isCenJetError)
1342     errorDirName.append("C");
1343   if (isTauJetError)
1344     errorDirName.append("T");
1345   if (isForJetError)
1346     errorDirName.append("F");
1347   std::stringstream caseNumber;
1348   caseNumber << eventNumber;
1349   errorDirName.append(caseNumber.str());
1350   TFileDirectory errorDir = errorHistCat.at(1).mkdir(errorDirName);
1351 
1352   TH2I *errorRegionEtEtaPhi_ = errorDir.make<TH2I>(
1353       "errorRegionEtEtaPhi", "errorRegionEtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1354   TH2I *errorRegionTvEtaPhi_ = errorDir.make<TH2I>(
1355       "errorRegionTvEtaPhi", "errorRegionTvEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1356   TH2I *errorRegionOfEtaPhi_ = errorDir.make<TH2I>(
1357       "errorRegionOfEtaPhi", "errorRegionOfEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1358 
1359   //make sure to only plot the caloRegion bx which corresponds to the data vs emulator comparison
1360   for (unsigned int i = 0; i < caloRegions->size(); i++) {
1361     if (caloRegions->at(i).bx() == RCTTrigBx_) {
1362       if (caloRegions->at(i).et() > 0)
1363         errorRegionEtEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi(), caloRegions->at(i).et());
1364       if (caloRegions->at(i).tauVeto())
1365         errorRegionTvEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1366       if (caloRegions->at(i).overFlow())
1367         errorRegionOfEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1368     }
1369   }
1370 
1371   TH2I *cenJet_errorEtEtaPhiData_ = errorDir.make<TH2I>("cenJet_errorEtEtaPhiData",
1372                                                         "cenJet_errorEtEtaPhiData;#eta (GCT Units);#phi (GCT Units)",
1373                                                         22,
1374                                                         -0.5,
1375                                                         21.5,
1376                                                         18,
1377                                                         -0.5,
1378                                                         17.5);
1379   TH2I *cenJet_errorEtEtaPhiEmu_ = errorDir.make<TH2I>("cenJet_errorEtEtaPhiEmu",
1380                                                        "cenJet_errorEtEtaPhiEmu;#eta (GCT Units);#phi (GCT Units)",
1381                                                        22,
1382                                                        -0.5,
1383                                                        21.5,
1384                                                        18,
1385                                                        -0.5,
1386                                                        17.5);
1387   TH2I *tauJet_errorEtEtaPhiData_ = errorDir.make<TH2I>("tauJet_errorEtEtaPhiData",
1388                                                         "tauJet_errorEtEtaPhiData;#eta (GCT Units);#phi (GCT Units)",
1389                                                         22,
1390                                                         -0.5,
1391                                                         21.5,
1392                                                         18,
1393                                                         -0.5,
1394                                                         17.5);
1395   TH2I *tauJet_errorEtEtaPhiEmu_ = errorDir.make<TH2I>("tauJet_errorEtEtaPhiEmu",
1396                                                        "tauJet_errorEtEtaPhiEmu;#eta (GCT Units);#phi (GCT Units)",
1397                                                        22,
1398                                                        -0.5,
1399                                                        21.5,
1400                                                        18,
1401                                                        -0.5,
1402                                                        17.5);
1403   TH2I *forJet_errorEtEtaPhiData_ = errorDir.make<TH2I>("forJet_errorEtEtaPhiData",
1404                                                         "forJet_errorEtEtaPhiData;#eta (GCT Units);#phi (GCT Units)",
1405                                                         22,
1406                                                         -0.5,
1407                                                         21.5,
1408                                                         18,
1409                                                         -0.5,
1410                                                         17.5);
1411   TH2I *forJet_errorEtEtaPhiEmu_ = errorDir.make<TH2I>("forJet_errorEtEtaPhiEmu",
1412                                                        "forJet_errorEtEtaPhiEmu;#eta (GCT Units);#phi (GCT Units)",
1413                                                        22,
1414                                                        -0.5,
1415                                                        21.5,
1416                                                        18,
1417                                                        -0.5,
1418                                                        17.5);
1419 
1420   //first plot the data candiates for the Trigger Bx that this error corresponds to
1421   for (unsigned int i = 0; i < cenJetsD->size(); i++) {
1422     if (cenJetsD->at(i).bx() == GCTTrigBx_) {
1423       if (cenJetsD->at(i).rank() > 0)
1424         cenJet_errorEtEtaPhiData_->Fill(
1425             cenJetsD->at(i).regionId().ieta(), cenJetsD->at(i).regionId().iphi(), cenJetsD->at(i).rank());
1426     }
1427   }
1428   for (unsigned int i = 0; i < tauJetsD->size(); i++) {
1429     if (tauJetsD->at(i).bx() == GCTTrigBx_) {
1430       if (tauJetsD->at(i).rank() > 0)
1431         tauJet_errorEtEtaPhiData_->Fill(
1432             tauJetsD->at(i).regionId().ieta(), tauJetsD->at(i).regionId().iphi(), tauJetsD->at(i).rank());
1433     }
1434   }
1435   for (unsigned int i = 0; i < forJetsD->size(); i++) {
1436     if (forJetsD->at(i).bx() == GCTTrigBx_) {
1437       if (forJetsD->at(i).rank() > 0)
1438         forJet_errorEtEtaPhiData_->Fill(
1439             forJetsD->at(i).regionId().ieta(), forJetsD->at(i).regionId().iphi(), forJetsD->at(i).rank());
1440     }
1441   }
1442 
1443   //now the emulator candidates
1444   for (unsigned int i = 0; i < cenJetsE->size(); i++) {
1445     if (cenJetsE->at(i).bx() == EmuTrigBx_) {
1446       if (cenJetsE->at(i).rank() > 0)
1447         cenJet_errorEtEtaPhiEmu_->Fill(
1448             cenJetsE->at(i).regionId().ieta(), cenJetsE->at(i).regionId().iphi(), cenJetsE->at(i).rank());
1449     }
1450   }
1451   for (unsigned int i = 0; i < tauJetsE->size(); i++) {
1452     if (tauJetsE->at(i).bx() == EmuTrigBx_) {
1453       if (tauJetsE->at(i).rank() > 0)
1454         tauJet_errorEtEtaPhiEmu_->Fill(
1455             tauJetsE->at(i).regionId().ieta(), tauJetsE->at(i).regionId().iphi(), tauJetsE->at(i).rank());
1456     }
1457   }
1458   for (unsigned int i = 0; i < forJetsE->size(); i++) {
1459     if (forJetsE->at(i).bx() == EmuTrigBx_) {
1460       if (forJetsE->at(i).rank() > 0)
1461         forJet_errorEtEtaPhiEmu_->Fill(
1462             forJetsE->at(i).regionId().ieta(), forJetsE->at(i).regionId().iphi(), forJetsE->at(i).rank());
1463     }
1464   }
1465 }
1466 
1467 void GctErrorAnalyzer::plotHFRingSums(const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsD,
1468                                       const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsE) {
1469   for (unsigned int i = 0; i < hfRingSumsD->size(); i++) {
1470     if (doGCTMBx_ || hfRingSumsD->at(i).bx() == GCTTrigBx_) {
1471       //there are 4 rings - just fill the histograms
1472       hfRingSumD_1pos_->Fill(hfRingSumsD->at(i).etSum(0));
1473       hfRingSumD_1neg_->Fill(hfRingSumsD->at(i).etSum(1));
1474       hfRingSumD_2pos_->Fill(hfRingSumsD->at(i).etSum(2));
1475       hfRingSumD_2neg_->Fill(hfRingSumsD->at(i).etSum(3));
1476     }
1477   }
1478 
1479   for (unsigned int i = 0; i < hfRingSumsE->size(); i++) {
1480     if (doEmuMBx_ || hfRingSumsE->at(i).bx() == EmuTrigBx_) {
1481       hfRingSumE_1pos_->Fill(hfRingSumsE->at(i).etSum(0));
1482       hfRingSumE_1neg_->Fill(hfRingSumsE->at(i).etSum(1));
1483       hfRingSumE_2pos_->Fill(hfRingSumsE->at(i).etSum(2));
1484       hfRingSumE_2neg_->Fill(hfRingSumsE->at(i).etSum(3));
1485     }
1486   }
1487 }
1488 
1489 void GctErrorAnalyzer::plotHFBitCounts(const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsD,
1490                                        const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsE) {
1491   for (unsigned int i = 0; i < hfBitCountsD->size(); i++) {
1492     if (doGCTMBx_ || hfBitCountsD->at(i).bx() == GCTTrigBx_) {
1493       //there are 4 rings - just fill the histograms
1494       hfBitCountD_1pos_->Fill(hfBitCountsD->at(i).bitCount(0));
1495       hfBitCountD_1neg_->Fill(hfBitCountsD->at(i).bitCount(1));
1496       hfBitCountD_2pos_->Fill(hfBitCountsD->at(i).bitCount(2));
1497       hfBitCountD_2neg_->Fill(hfBitCountsD->at(i).bitCount(3));
1498     }
1499   }
1500   for (unsigned int i = 0; i < hfBitCountsE->size(); i++) {
1501     if (doEmuMBx_ || hfBitCountsE->at(i).bx() == EmuTrigBx_) {
1502       hfBitCountE_1pos_->Fill(hfBitCountsE->at(i).bitCount(0));
1503       hfBitCountE_1neg_->Fill(hfBitCountsE->at(i).bitCount(1));
1504       hfBitCountE_2pos_->Fill(hfBitCountsE->at(i).bitCount(2));
1505       hfBitCountE_2neg_->Fill(hfBitCountsE->at(i).bitCount(3));
1506     }
1507   }
1508 }
1509 
1510 void GctErrorAnalyzer::plotHFErrors(const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsD,
1511                                     const edm::Handle<L1GctHFRingEtSumsCollection> &hfRingSumsE,
1512                                     const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsD,
1513                                     const edm::Handle<L1GctHFBitCountsCollection> &hfBitCountsE,
1514                                     const edm::Handle<L1CaloRegionCollection> &caloRegions) {
1515   std::string errorDirName = "err_";
1516   if (isRingSumError)
1517     errorDirName.append("R");
1518   if (isBitCountError)
1519     errorDirName.append("B");
1520   std::stringstream caseNumber;
1521   caseNumber << eventNumber;
1522   errorDirName.append(caseNumber.str());
1523   TFileDirectory errorDir = errorHistCat.at(2).mkdir(errorDirName);
1524 
1525   TH2I *errorRegionEtEtaPhi_ = errorDir.make<TH2I>(
1526       "errorRegionEtEtaPhi", "errorRegionEtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1527   TH2I *errorRegionFgEtaPhi_ = errorDir.make<TH2I>(
1528       "errorRegionFgEtaPhi", "errorRegionFgEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1529   TH2I *errorRegionOfEtaPhi_ = errorDir.make<TH2I>(
1530       "errorRegionOfEtaPhi", "errorRegionOfEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1531 
1532   TH1I *errorHFRingSumD_1pos_ =
1533       errorDir.make<TH1I>("errorHFRingSumD_1+", "errorHFRingSumD_1+;Rank;Number of Events", 8, -0.5, 7.5);
1534   TH1I *errorHFRingSumD_2pos_ =
1535       errorDir.make<TH1I>("errorHFRingSumD_2+", "errorHFRingSumD_2+;Rank;Number of Events", 8, -0.5, 7.5);
1536   TH1I *errorHFRingSumD_1neg_ =
1537       errorDir.make<TH1I>("errorHFRingSumD_1-", "errorHFRingSumD_1-;Rank;Number of Events", 8, -0.5, 7.5);
1538   TH1I *errorHFRingSumD_2neg_ =
1539       errorDir.make<TH1I>("errorHFRingSumD_2-", "errorHFRingSumD_2-;Rank;Number of Events", 8, -0.5, 7.5);
1540   TH1I *errorHFRingSumE_1pos_ =
1541       errorDir.make<TH1I>("errorHFRingSumE_1+", "errorHFRingSumE_1+;Rank;Number of Events", 8, -0.5, 7.5);
1542   TH1I *errorHFRingSumE_2pos_ =
1543       errorDir.make<TH1I>("errorHFRingSumE_2+", "errorHFRingSumE_2+;Rank;Number of Events", 8, -0.5, 7.5);
1544   TH1I *errorHFRingSumE_1neg_ =
1545       errorDir.make<TH1I>("errorHFRingSumE_1-", "errorHFRingSumE_1-;Rank;Number of Events", 8, -0.5, 7.5);
1546   TH1I *errorHFRingSumE_2neg_ =
1547       errorDir.make<TH1I>("errorHFRingSumE_2-", "errorHFRingSumE_2-;Rank;Number of Events", 8, -0.5, 7.5);
1548 
1549   TH1I *errorHFBitCountD_1pos_ =
1550       errorDir.make<TH1I>("errorHFBitCountD_1+", "errorHFBitCountD_1+;Rank;Number of Events", 8, -0.5, 7.5);
1551   TH1I *errorHFBitCountD_2pos_ =
1552       errorDir.make<TH1I>("errorHFBitCountD_2+", "errorHFBitCountD_2+;Rank;Number of Events", 8, -0.5, 7.5);
1553   TH1I *errorHFBitCountD_1neg_ =
1554       errorDir.make<TH1I>("errorHFBitCountD_1-", "errorHFBitCountD_1-;Rank;Number of Events", 8, -0.5, 7.5);
1555   TH1I *errorHFBitCountD_2neg_ =
1556       errorDir.make<TH1I>("errorHFBitCountD_2-", "errorHFBitCountD_2-;Rank;Number of Events", 8, -0.5, 7.5);
1557   TH1I *errorHFBitCountE_1pos_ =
1558       errorDir.make<TH1I>("errorHFBitCountE_1+", "errorHFBitCountE_1+;Rank;Number of Events", 8, -0.5, 7.5);
1559   TH1I *errorHFBitCountE_2pos_ =
1560       errorDir.make<TH1I>("errorHFBitCountE_2+", "errorHFBitCountE_2+;Rank;Number of Events", 8, -0.5, 7.5);
1561   TH1I *errorHFBitCountE_1neg_ =
1562       errorDir.make<TH1I>("errorHFBitCountE_1-", "errorHFBitCountE_1-;Rank;Number of Events", 8, -0.5, 7.5);
1563   TH1I *errorHFBitCountE_2neg_ =
1564       errorDir.make<TH1I>("errorHFBitCountE_2-", "errorHFBitCountE_2-;Rank;Number of Events", 8, -0.5, 7.5);
1565 
1566   for (unsigned int i = 0; i < caloRegions->size(); i++) {
1567     if (caloRegions->at(i).bx() == RCTTrigBx_) {
1568       if (caloRegions->at(i).et() > 0)
1569         errorRegionEtEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi(), caloRegions->at(i).et());
1570       if (caloRegions->at(i).fineGrain())
1571         errorRegionFgEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1572       if (caloRegions->at(i).overFlow())
1573         errorRegionOfEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1574     }
1575   }
1576 
1577   for (unsigned int i = 0; i < hfRingSumsD->size(); i++) {
1578     if (hfRingSumsD->at(i).bx() == GCTTrigBx_) {
1579       errorHFRingSumD_1pos_->Fill(hfRingSumsD->at(i).etSum(0));
1580       errorHFRingSumD_1neg_->Fill(hfRingSumsD->at(i).etSum(1));
1581       errorHFRingSumD_2pos_->Fill(hfRingSumsD->at(i).etSum(2));
1582       errorHFRingSumD_2neg_->Fill(hfRingSumsD->at(i).etSum(3));
1583     }
1584   }
1585   for (unsigned int i = 0; i < hfRingSumsE->size(); i++) {
1586     if (hfRingSumsE->at(i).bx() == EmuTrigBx_) {
1587       errorHFRingSumE_1pos_->Fill(hfRingSumsE->at(i).etSum(0));
1588       errorHFRingSumE_1neg_->Fill(hfRingSumsE->at(i).etSum(1));
1589       errorHFRingSumE_2pos_->Fill(hfRingSumsE->at(i).etSum(2));
1590       errorHFRingSumE_2neg_->Fill(hfRingSumsE->at(i).etSum(3));
1591     }
1592   }
1593 
1594   for (unsigned int i = 0; i < hfBitCountsD->size(); i++) {
1595     if (hfBitCountsD->at(i).bx() == GCTTrigBx_) {
1596       errorHFBitCountD_1pos_->Fill(hfBitCountsD->at(i).bitCount(0));
1597       errorHFBitCountD_1neg_->Fill(hfBitCountsD->at(i).bitCount(1));
1598       errorHFBitCountD_2pos_->Fill(hfBitCountsD->at(i).bitCount(2));
1599       errorHFBitCountD_2neg_->Fill(hfBitCountsD->at(i).bitCount(3));
1600     }
1601   }
1602   for (unsigned int i = 0; i < hfBitCountsE->size(); i++) {
1603     if (hfBitCountsE->at(i).bx() == EmuTrigBx_) {
1604       errorHFBitCountE_1pos_->Fill(hfBitCountsE->at(i).bitCount(0));
1605       errorHFBitCountE_1neg_->Fill(hfBitCountsE->at(i).bitCount(1));
1606       errorHFBitCountE_2pos_->Fill(hfBitCountsE->at(i).bitCount(2));
1607       errorHFBitCountE_2neg_->Fill(hfBitCountsE->at(i).bitCount(3));
1608     }
1609   }
1610 }
1611 
1612 void GctErrorAnalyzer::plotTotalE(const edm::Handle<L1GctEtTotalCollection> &totalEtD,
1613                                   const edm::Handle<L1GctEtTotalCollection> &totalEtE) {
1614   for (unsigned int i = 0; i < totalEtD->size(); i++) {
1615     if (doGCTMBx_ || totalEtD->at(i).bx() == GCTTrigBx_) {
1616       totalEtD_Of_->Fill(totalEtD->at(i).overFlow());
1617       if (!totalEtD->at(i).overFlow())
1618         totalEtD_->Fill(totalEtD->at(i).et());
1619     }
1620   }
1621   for (unsigned int i = 0; i < totalEtE->size(); i++) {
1622     if (doEmuMBx_ || totalEtE->at(i).bx() == EmuTrigBx_) {
1623       totalEtE_Of_->Fill(totalEtE->at(i).overFlow());
1624       if (!totalEtE->at(i).overFlow())
1625         totalEtE_->Fill(totalEtE->at(i).et());
1626     }
1627   }
1628 }
1629 
1630 void GctErrorAnalyzer::plotTotalH(const edm::Handle<L1GctEtHadCollection> &totalHtD,
1631                                   const edm::Handle<L1GctEtHadCollection> &totalHtE) {
1632   for (unsigned int i = 0; i < totalHtD->size(); i++) {
1633     if (doGCTMBx_ || totalHtD->at(i).bx() == GCTTrigBx_) {
1634       totalHtD_Of_->Fill(totalHtD->at(i).overFlow());
1635       if (!totalHtD->at(i).overFlow())
1636         totalHtD_->Fill(totalHtD->at(i).et());
1637     }
1638   }
1639   for (unsigned int i = 0; i < totalHtE->size(); i++) {
1640     if (doEmuMBx_ || totalHtE->at(i).bx() == EmuTrigBx_) {
1641       totalHtE_Of_->Fill(totalHtE->at(i).overFlow());
1642       if (!totalHtE->at(i).overFlow())
1643         totalHtE_->Fill(totalHtE->at(i).et());
1644     }
1645   }
1646 }
1647 
1648 void GctErrorAnalyzer::plotTotalEErrors(const edm::Handle<L1GctEtTotalCollection> &totalEtD,
1649                                         const edm::Handle<L1GctEtTotalCollection> &totalEtE,
1650                                         const edm::Handle<L1GctEtHadCollection> &totalHtD,
1651                                         const edm::Handle<L1GctEtHadCollection> &totalHtE,
1652                                         const edm::Handle<L1CaloRegionCollection> &caloRegions) {
1653   std::string errorDirName = "err_";
1654   if (isTotalEError)
1655     errorDirName.append("E");
1656   if (isTotalHError)
1657     errorDirName.append("H");
1658   std::stringstream caseNumber;
1659   caseNumber << eventNumber;
1660   errorDirName.append(caseNumber.str());
1661   TFileDirectory errorDir = errorHistCat.at(3).mkdir(errorDirName);
1662 
1663   TH2I *errorRegionEtEtaPhi_ = errorDir.make<TH2I>(
1664       "errorRegionEtEtaPhi", "errorRegionEtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1665   TH2I *errorRegionOfEtaPhi_ = errorDir.make<TH2I>(
1666       "errorRegionOfEtaPhi", "errorRegionOfEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1667   TH1I *errorTotalEtD_ =
1668       errorDir.make<TH1I>("errorTotalEtD", "errorTotalEtD;E_{T};Number of Events", 1024, -0.5, 1023.5);
1669   TH1I *errorTotalEtD_Of_ =
1670       errorDir.make<TH1I>("errorTotalEtD_Of", "errorTotalEtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1671   TH1I *errorTotalEtE_ =
1672       errorDir.make<TH1I>("errorTotalEtE", "errorTotalEtE;E_{T};Number of Events", 1024, -0.5, 1023.5);
1673   TH1I *errorTotalEtE_Of_ =
1674       errorDir.make<TH1I>("errorTotalEtE_Of", "errorTotalEtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1675   TH1I *errorTotalHtD_ =
1676       errorDir.make<TH1I>("errorTotalHtD", "errorTotalHtD;E_{T};Number of Events", 1024, -0.5, 1023.5);
1677   TH1I *errorTotalHtD_Of_ =
1678       errorDir.make<TH1I>("errorTotalHtD_Of", "errorTotalHtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1679   TH1I *errorTotalHtE_ =
1680       errorDir.make<TH1I>("errorTotalHtE", "errorTotalHtE;E_{T};Number of Events", 1024, -0.5, 1023.5);
1681   TH1I *errorTotalHtE_Of_ =
1682       errorDir.make<TH1I>("errorTotalHtE_Of", "errorTotalHtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1683 
1684   //plot the region ET and OF bits
1685   for (unsigned int i = 0; i < caloRegions->size(); i++) {
1686     if (caloRegions->at(i).bx() == RCTTrigBx_) {
1687       if (caloRegions->at(i).et() > 0)
1688         errorRegionEtEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi(), caloRegions->at(i).et());
1689       if (caloRegions->at(i).overFlow())
1690         errorRegionOfEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1691     }
1692   }
1693   //now plot the error ET
1694   for (unsigned int i = 0; i < totalEtD->size(); i++) {
1695     if (totalEtD->at(i).bx() == GCTTrigBx_) {
1696       errorTotalEtD_Of_->Fill(totalEtD->at(i).overFlow());
1697       if (!totalEtD->at(i).overFlow())
1698         errorTotalEtD_->Fill(totalEtD->at(i).et());
1699     }
1700   }
1701   for (unsigned int i = 0; i < totalEtE->size(); i++) {
1702     if (totalEtE->at(i).bx() == EmuTrigBx_) {
1703       errorTotalEtE_Of_->Fill(totalEtE->at(i).overFlow());
1704       if (!totalEtE->at(i).overFlow())
1705         errorTotalEtE_->Fill(totalEtE->at(i).et());
1706     }
1707   }
1708   //and now the error HT
1709   for (unsigned int i = 0; i < totalHtD->size(); i++) {
1710     if (totalHtD->at(i).bx() == GCTTrigBx_) {
1711       errorTotalHtD_Of_->Fill(totalHtD->at(i).overFlow());
1712       if (!totalHtD->at(i).overFlow())
1713         errorTotalHtD_->Fill(totalHtD->at(i).et());
1714     }
1715   }
1716   for (unsigned int i = 0; i < totalHtE->size(); i++) {
1717     if (totalHtE->at(i).bx() == EmuTrigBx_) {
1718       errorTotalHtE_Of_->Fill(totalHtE->at(i).overFlow());
1719       if (!totalHtE->at(i).overFlow())
1720         errorTotalHtE_->Fill(totalHtE->at(i).et());
1721     }
1722   }
1723 }
1724 
1725 void GctErrorAnalyzer::plotMissingEt(const edm::Handle<L1GctEtMissCollection> &missingEtD,
1726                                      const edm::Handle<L1GctEtMissCollection> &missingEtE) {
1727   for (unsigned int i = 0; i < missingEtD->size(); i++) {
1728     if (doGCTMBx_ || missingEtD->at(i).bx() == GCTTrigBx_) {
1729       missingEtD_Of_->Fill(missingEtD->at(i).overFlow());
1730       if (!missingEtD->at(i).overFlow() && missingEtD->at(i).et() > 0) {
1731         missingEtD_->Fill(missingEtD->at(i).et());
1732         missingEtD_Phi_->Fill(missingEtD->at(i).phi());
1733       }
1734     }
1735   }
1736 
1737   for (unsigned int i = 0; i < missingEtE->size(); i++) {
1738     if (doEmuMBx_ || missingEtE->at(i).bx() == EmuTrigBx_) {
1739       missingEtE_Of_->Fill(missingEtE->at(i).overFlow());
1740       if (!missingEtE->at(i).overFlow() && missingEtE->at(i).et()) {
1741         missingEtE_->Fill(missingEtE->at(i).et());
1742         missingEtE_Phi_->Fill(missingEtE->at(i).phi());
1743       }
1744     }
1745   }
1746 }
1747 
1748 void GctErrorAnalyzer::plotMissingHt(const edm::Handle<L1GctHtMissCollection> &missingHtD,
1749                                      const edm::Handle<L1GctHtMissCollection> &missingHtE) {
1750   for (unsigned int i = 0; i < missingHtD->size(); i++) {
1751     if (doGCTMBx_ || missingHtD->at(i).bx() == GCTTrigBx_) {
1752       missingHtD_Of_->Fill(missingHtD->at(i).overFlow());
1753       if (!missingHtD->at(i).overFlow() && missingHtD->at(i).et() > 0) {
1754         missingHtD_->Fill(missingHtD->at(i).et());
1755         missingHtD_Phi_->Fill(missingHtD->at(i).phi());
1756       }
1757     }
1758   }
1759 
1760   for (unsigned int i = 0; i < missingHtE->size(); i++) {
1761     if (doEmuMBx_ || missingHtE->at(i).bx() == EmuTrigBx_) {
1762       missingHtE_Of_->Fill(missingHtE->at(i).overFlow());
1763       if (!missingHtE->at(i).overFlow() && missingHtE->at(i).et() > 0) {
1764         missingHtE_->Fill(missingHtE->at(i).et());
1765         missingHtE_Phi_->Fill(missingHtE->at(i).phi());
1766       }
1767     }
1768   }
1769 }
1770 
1771 void GctErrorAnalyzer::plotMissingEErrors(const edm::Handle<L1GctEtMissCollection> &missingEtD,
1772                                           const edm::Handle<L1GctEtMissCollection> &missingEtE,
1773                                           const edm::Handle<L1GctHtMissCollection> &missingHtD,
1774                                           const edm::Handle<L1GctHtMissCollection> &missingHtE,
1775                                           edm::Handle<L1CaloRegionCollection> &caloRegions,
1776                                           const edm::Handle<L1GctInternJetDataCollection> &intJetsE,
1777                                           const edm::Handle<L1GctInternHtMissCollection> intMissingHtD) {
1778   std::string errorDirName = "err_";
1779   if (isMissingEError)
1780     errorDirName.append("E");
1781   if (isMissingHError)
1782     errorDirName.append("H");
1783 
1784   //added 05.03.2010 to highlight overflow errors in the missing energy sum calculation
1785   for (unsigned int i = 0; i < missingHtE->size(); i++) {
1786     if (missingHtE->at(i).bx() == EmuTrigBx_) {
1787       for (unsigned int j = 0; j < missingHtD->size(); j++) {
1788         if (missingHtD->at(j).bx() == GCTTrigBx_) {
1789           if (missingHtD->at(j).overFlow() != missingHtE->at(i).overFlow())
1790             errorDirName.append("O");
1791         }
1792       }
1793     }
1794   }
1795 
1796   std::stringstream caseNumber;
1797   caseNumber << eventNumber;
1798   errorDirName.append(caseNumber.str());
1799   TFileDirectory errorDir = errorHistCat.at(4).mkdir(errorDirName);
1800 
1801   TH2I *errorRegionEtEtaPhi_ = errorDir.make<TH2I>(
1802       "errorRegionEtEtaPhi", "errorRegionEtEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1803   TH2I *errorRegionOfEtaPhi_ = errorDir.make<TH2I>(
1804       "errorRegionOfEtaPhi", "errorRegionOfEtaPhi;#eta (GCT Units);#phi (GCT Units)", 22, -0.5, 21.5, 18, -0.5, 17.5);
1805   TH1I *errorMissingEtD_ =
1806       errorDir.make<TH1I>("errorMissingEtD", "errorMissingEtD;E_{T};Number of Events", 1024, -0.5, 1023.5);
1807   TH1I *errorMissingEtD_Of_ = errorDir.make<TH1I>(
1808       "errorMissingEtD_Of", "errorMissingEtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1809   TH1I *errorMissingEtD_Phi_ = errorDir.make<TH1I>(
1810       "errorMissingEtD_Phi", "errorMissingEtD_Phi;Missing E_{T} #phi;Number of Events", 72, -0.5, 71.5);
1811   TH1I *errorMissingEtE_ =
1812       errorDir.make<TH1I>("errorMissingEtE", "errorMissingEtE;E_{T};Number of Events", 1024, -0.5, 1023.5);
1813   TH1I *errorMissingEtE_Of_ = errorDir.make<TH1I>(
1814       "errorMissingEtE_Of", "errorMissingEtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1815   TH1I *errorMissingEtE_Phi_ = errorDir.make<TH1I>(
1816       "errorMissingEtE_Phi", "errorMissingEtE_Phi;Missing E_{T} #phi;Number of Events", 72, -0.5, 71.5);
1817   TH1I *errorMissingHtD_ =
1818       errorDir.make<TH1I>("errorMissingHtD", "errorMissingHtD;H_{T};Number of Events", 1024, -0.5, 1023.5);
1819   TH1I *errorMissingHtD_Of_ = errorDir.make<TH1I>(
1820       "errorMissingHtD_Of", "errorMissingHtD_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1821   TH1I *errorMissingHtD_Phi_ = errorDir.make<TH1I>(
1822       "errorMissingHtD_Phi", "errorMissingHtD_Phi;Missing H_{T} #phi;Number of Events", 72, -0.5, 71.5);
1823   TH1I *errorMissingHtE_ =
1824       errorDir.make<TH1I>("errorMissingHtE", "errorMissingHtE;H_{T};Number of Events", 1024, -0.5, 1023.5);
1825   TH1I *errorMissingHtE_Of_ = errorDir.make<TH1I>(
1826       "errorMissingHtE_Of", "errorMissingHtE_Of;Overflow Bit Status;Number of Events", 2, -0.5, 1.5);
1827   TH1I *errorMissingHtE_Phi_ = errorDir.make<TH1I>(
1828       "errorMissingHtE_Phi", "errorMissingHtE_Phi;Missing H_{T} #phi;Number of Events", 72, -0.5, 71.5);
1829 
1830   //Added 19.03.2010 to provide additional information in the case of missingHt failures
1831   //1. The MHT from both wheel inputs (i.e. the leaf cards)
1832   //2. The emulator jet et,eta,phi for all jets found in an event
1833   if (doExtraMissingHTDebug_) {
1834     if (checkCollections(intMissingHtD, GCT_INT_HTMISS_QUANTA, "Internal Missing Ht Data")) {
1835       TH1I *errorMissingHtD_HtXPosLeaf1 = errorDir.make<TH1I>(
1836           "errorMissingHtD_HtXPosLeaf1", "missingHtD;Missing H_{T} X PosLeaf1;Number of Events", 4096, -2048.5, 2047.5);
1837       TH1I *errorMissingHtD_HtXPosLeaf2 = errorDir.make<TH1I>(
1838           "errorMissingHtD_HtXPosLeaf2", "missingHtD;Missing H_{T} X PosLeaf2;Number of Events", 4096, -2048.5, 2047.5);
1839       TH1I *errorMissingHtD_HtXPosLeaf3 = errorDir.make<TH1I>(
1840           "errorMissingHtD_HtXPosLeaf3", "missingHtD;Missing H_{T} X PosLeaf3;Number of Events", 4096, -2048.5, 2047.5);
1841       TH1I *errorMissingHtD_HtXNegLeaf1 = errorDir.make<TH1I>(
1842           "errorMissingHtD_HtXNegLeaf1", "missingHtD;Missing H_{T} X NegLeaf1;Number of Events", 4096, -2048.5, 2047.5);
1843       TH1I *errorMissingHtD_HtXNegLeaf2 = errorDir.make<TH1I>(
1844           "errorMissingHtD_HtXNegLeaf2", "missingHtD;Missing H_{T} X NegLeaf2;Number of Events", 4096, -2048.5, 2047.5);
1845       TH1I *errorMissingHtD_HtXNegLeaf3 = errorDir.make<TH1I>(
1846           "errorMissingHtD_HtXNegLeaf3", "missingHtD;Missing H_{T} X NegLeaf3;Number of Events", 4096, -2048.5, 2047.5);
1847 
1848       TH1I *errorMissingHtD_HtYPosLeaf1 = errorDir.make<TH1I>(
1849           "errorMissingHtD_HtYPosLeaf1", "missingHtD;Missing H_{T} Y PosLeaf1;Number of Events", 4096, -2048.5, 2047.5);
1850       TH1I *errorMissingHtD_HtYPosLeaf2 = errorDir.make<TH1I>(
1851           "errorMissingHtD_HtYPosLeaf2", "missingHtD;Missing H_{T} Y PosLeaf2;Number of Events", 4096, -2048.5, 2047.5);
1852       TH1I *errorMissingHtD_HtYPosLeaf3 = errorDir.make<TH1I>(
1853           "errorMissingHtD_HtYPosLeaf3", "missingHtD;Missing H_{T} Y PosLeaf3;Number of Events", 4096, -2048.5, 2047.5);
1854       TH1I *errorMissingHtD_HtYNegLeaf1 = errorDir.make<TH1I>(
1855           "errorMissingHtD_HtYNegLeaf1", "missingHtD;Missing H_{T} Y NegLeaf1;Number of Events", 4096, -2048.5, 2047.5);
1856       TH1I *errorMissingHtD_HtYNegLeaf2 = errorDir.make<TH1I>(
1857           "errorMissingHtD_HtYNegLeaf2", "missingHtD;Missing H_{T} Y NegLeaf2;Number of Events", 4096, -2048.5, 2047.5);
1858       TH1I *errorMissingHtD_HtYNegLeaf3 = errorDir.make<TH1I>(
1859           "errorMissingHtD_HtYNegLeaf3", "missingHtD;Missing H_{T} Y NegLeaf3;Number of Events", 4096, -2048.5, 2047.5);
1860 
1861       for (unsigned int i = 0; i < intMissingHtD->size(); i++) {
1862         if (intMissingHtD->at(i).bx() == GCTTrigBx_) {
1863           if (!intMissingHtD->at(i).overflow()) {
1864             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 0 &&
1865                 intMissingHtD->at(i).isThereHtx())
1866               errorMissingHtD_HtXPosLeaf1->Fill(intMissingHtD->at(i).htx());
1867             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 1 &&
1868                 intMissingHtD->at(i).isThereHtx())
1869               errorMissingHtD_HtXPosLeaf2->Fill(intMissingHtD->at(i).htx());
1870             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 2 &&
1871                 intMissingHtD->at(i).isThereHtx())
1872               errorMissingHtD_HtXPosLeaf3->Fill(intMissingHtD->at(i).htx());
1873             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 0 &&
1874                 intMissingHtD->at(i).isThereHtx())
1875               errorMissingHtD_HtXNegLeaf1->Fill(intMissingHtD->at(i).htx());
1876             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 1 &&
1877                 intMissingHtD->at(i).isThereHtx())
1878               errorMissingHtD_HtXNegLeaf2->Fill(intMissingHtD->at(i).htx());
1879             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 2 &&
1880                 intMissingHtD->at(i).isThereHtx())
1881               errorMissingHtD_HtXNegLeaf3->Fill(intMissingHtD->at(i).htx());
1882 
1883             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 0 &&
1884                 intMissingHtD->at(i).isThereHty())
1885               errorMissingHtD_HtYPosLeaf1->Fill(intMissingHtD->at(i).hty());
1886             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 1 &&
1887                 intMissingHtD->at(i).isThereHty())
1888               errorMissingHtD_HtYPosLeaf2->Fill(intMissingHtD->at(i).hty());
1889             if (intMissingHtD->at(i).capBlock() == 0x301 && intMissingHtD->at(i).capIndex() == 2 &&
1890                 intMissingHtD->at(i).isThereHty())
1891               errorMissingHtD_HtYPosLeaf3->Fill(intMissingHtD->at(i).hty());
1892             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 0 &&
1893                 intMissingHtD->at(i).isThereHty())
1894               errorMissingHtD_HtYNegLeaf1->Fill(intMissingHtD->at(i).hty());
1895             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 1 &&
1896                 intMissingHtD->at(i).isThereHty())
1897               errorMissingHtD_HtYNegLeaf2->Fill(intMissingHtD->at(i).hty());
1898             if (intMissingHtD->at(i).capBlock() == 0x701 && intMissingHtD->at(i).capIndex() == 2 &&
1899                 intMissingHtD->at(i).isThereHty())
1900               errorMissingHtD_HtYNegLeaf3->Fill(intMissingHtD->at(i).hty());
1901           }
1902         }
1903       }
1904     }
1905   }
1906 
1907   if (checkCollections(intJetsE, NUM_INT_JETS, "Intermediate Jets Emulator")) {
1908     TH2I *errorIntJetsE_EtEtaPhi = errorDir.make<TH2I>("errorIntJetsE_EtEtaPhi",
1909                                                        "errorIntJetsE_EtEtaPhi;#eta (GCT Units);#phi (GCT Units)",
1910                                                        22,
1911                                                        -0.5,
1912                                                        21.5,
1913                                                        18,
1914                                                        -0.5,
1915                                                        17.5);
1916 
1917     for (unsigned int i = 0; i < intJetsE->size(); i++) {
1918       if (intJetsE->at(i).bx() == EmuTrigBx_) {
1919         if (!intJetsE->at(i).oflow() && intJetsE->at(i).et())
1920           errorIntJetsE_EtEtaPhi->Fill(
1921               intJetsE->at(i).regionId().ieta(), intJetsE->at(i).regionId().iphi(), intJetsE->at(i).et());
1922       }
1923     }
1924   }
1925 
1926   for (unsigned int i = 0; i < caloRegions->size(); i++) {
1927     if (caloRegions->at(i).bx() == RCTTrigBx_) {
1928       if (caloRegions->at(i).et() > 0)
1929         errorRegionEtEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi(), caloRegions->at(i).et());
1930       if (caloRegions->at(i).overFlow())
1931         errorRegionOfEtaPhi_->Fill(caloRegions->at(i).gctEta(), caloRegions->at(i).gctPhi());
1932     }
1933   }
1934 
1935   //plot the data candidates relating to this mismatch
1936   for (unsigned int i = 0; i < missingEtD->size(); i++) {
1937     if (missingEtD->at(i).bx() == GCTTrigBx_) {
1938       errorMissingEtD_Of_->Fill(missingEtD->at(i).overFlow());
1939       if (!missingEtD->at(i).overFlow()) {
1940         errorMissingEtD_->Fill(missingEtD->at(i).et());
1941         errorMissingEtD_Phi_->Fill(missingEtD->at(i).phi());
1942       }
1943     }
1944   }
1945   for (unsigned int i = 0; i < missingHtD->size(); i++) {
1946     if (missingHtD->at(i).bx() == GCTTrigBx_) {
1947       errorMissingHtD_Of_->Fill(missingHtD->at(i).overFlow());
1948       if (!missingHtD->at(i).overFlow()) {
1949         errorMissingHtD_->Fill(missingHtD->at(i).et());
1950         errorMissingHtD_Phi_->Fill(missingHtD->at(i).phi());
1951       }
1952     }
1953   }
1954   //and now for the emulator candidates
1955   for (unsigned int i = 0; i < missingEtE->size(); i++) {
1956     if (missingEtE->at(i).bx() == EmuTrigBx_) {
1957       errorMissingEtE_Of_->Fill(missingEtE->at(i).overFlow());
1958       if (!missingEtE->at(i).overFlow()) {
1959         errorMissingEtE_->Fill(missingEtE->at(i).et());
1960         errorMissingEtE_Phi_->Fill(missingEtE->at(i).phi());
1961       }
1962     }
1963   }
1964   for (unsigned int i = 0; i < missingHtE->size(); i++) {
1965     if (missingHtE->at(i).bx() == EmuTrigBx_) {
1966       errorMissingHtE_Of_->Fill(missingHtE->at(i).overFlow());
1967       if (!missingHtE->at(i)
1968                .overFlow()) {  //to see what values the emulator outputs despite the o/f bit being set comment out this statement
1969         errorMissingHtE_->Fill(missingHtE->at(i).et());
1970         errorMissingHtE_Phi_->Fill(missingHtE->at(i).phi());
1971       }
1972     }
1973   }
1974 }
1975 
1976 //define this as a plug-in
1977 DEFINE_FWK_MODULE(GctErrorAnalyzer);