Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  * \file L1TRCT.cc
0003  *
0004  * \author P. Wittich
0005  *
0006  */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TRCT.h"
0009 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0010 
0011 //DQMStore
0012 #include "DQMServices/Core/interface/DQMStore.h"
0013 
0014 using namespace edm;
0015 
0016 namespace {
0017   constexpr unsigned int PHIBINS = 18;
0018   constexpr float PHIMIN = -0.5;
0019   constexpr float PHIMAX = 17.5;
0020 
0021   // Ranks 6, 10 and 12 bits
0022   constexpr unsigned int R6BINS = 64;
0023   constexpr float R6MIN = -0.5;
0024   constexpr float R6MAX = 63.5;
0025   constexpr unsigned int R10BINS = 1024;
0026   constexpr float R10MIN = -0.5;
0027   constexpr float R10MAX = 1023.5;
0028 
0029   constexpr unsigned int ETABINS = 22;
0030   constexpr float ETAMIN = -0.5;
0031   constexpr float ETAMAX = 21.5;
0032 }  // namespace
0033 
0034 L1TRCT::L1TRCT(const ParameterSet &ps)
0035     : histFolder_(ps.getUntrackedParameter<std::string>("HistFolder", "L1T/L1TRCT")),
0036       rctSource_L1CRCollection_(consumes<L1CaloRegionCollection>(ps.getParameter<InputTag>("rctSource"))),
0037       rctSource_L1CEMCollection_(consumes<L1CaloEmCollection>(ps.getParameter<InputTag>("rctSource"))),
0038       filterTriggerType_(ps.getParameter<int>("filterTriggerType")),
0039       selectBX_(ps.getUntrackedParameter<int>("selectBX", 2)) {
0040   // verbosity switch
0041   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0042 
0043   if (verbose_)
0044     std::cout << "L1TRCT: constructor...." << std::endl;
0045 }
0046 
0047 L1TRCT::~L1TRCT() {}
0048 
0049 void L1TRCT::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) {
0050   ibooker.setCurrentFolder(histFolder_);
0051 
0052   runId_ = ibooker.bookInt("iRun");
0053   runId_->Fill(-1);
0054   lumisecId_ = ibooker.bookInt("lumiSection");
0055   lumisecId_->Fill(-1);
0056 
0057   triggerType_ = ibooker.book1D("TriggerType", "TriggerType", 17, -0.5, 16.5);
0058 
0059   // RCT UNPACKER
0060 
0061   // electrons
0062   rctIsoEmEtEtaPhi_ =
0063       ibooker.book2D("RctEmIsoEmEtEtaPhi", "ISO EM E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0064   rctIsoEmOccEtaPhi_ =
0065       ibooker.book2D("RctEmIsoEmOccEtaPhi", "ISO EM OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0066   rctNonIsoEmEtEtaPhi_ =
0067       ibooker.book2D("RctEmNonIsoEmEtEtaPhi", "NON-ISO EM E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0068   rctNonIsoEmOccEtaPhi_ = ibooker.book2D(
0069       "RctEmNonIsoEmOccEtaPhi", "NON-ISO EM OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0070 
0071   // global regions
0072   rctRegionsEtEtaPhi_ =
0073       ibooker.book2D("RctRegionsEtEtaPhi", "REGION E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0074   rctRegionsOccEtaPhi_ =
0075       ibooker.book2D("RctRegionsOccEtaPhi", "REGION OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0076 
0077   // bits
0078   rctOverFlowEtaPhi_ =
0079       ibooker.book2D("RctBitOverFlowEtaPhi", "OVER FLOW OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0080   rctTauVetoEtaPhi_ =
0081       ibooker.book2D("RctBitTauVetoEtaPhi", "TAU VETO OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0082   rctMipEtaPhi_ = ibooker.book2D("RctBitMipEtaPhi", "MIP OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0083   rctQuietEtaPhi_ =
0084       ibooker.book2D("RctBitQuietEtaPhi", "QUIET OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0085   rctHfPlusTauEtaPhi_ = ibooker.book2D(
0086       "RctBitHfPlusTauEtaPhi", "HF plus Tau OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0087 
0088   // rank histos
0089   rctRegionRank_ = ibooker.book1D("RctRegionRank", "REGION RANK", R10BINS, R10MIN, R10MAX);
0090   rctIsoEmRank_ = ibooker.book1D("RctEmIsoEmRank", "ISO EM RANK", R6BINS, R6MIN, R6MAX);
0091   rctNonIsoEmRank_ = ibooker.book1D("RctEmNonIsoEmRank", "NON-ISO EM RANK", R6BINS, R6MIN, R6MAX);
0092 
0093   // bx histos
0094   rctRegionBx_ = ibooker.book1D("RctRegionBx", "Region BX", 10, -2.5, 7.5);
0095   rctEmBx_ = ibooker.book1D("RctEmBx", "EM BX", 10, -2.5, 7.5);
0096 
0097   // NOT CENTRAL BXs
0098   rctNotCentralRegionsEtEtaPhi_ =
0099       ibooker.book2D("rctNotCentralRegionsEtEtaPhi", "REGION E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0100   rctNotCentralRegionsOccEtaPhi_ = ibooker.book2D(
0101       "rctNotCentralRegionsOccEtaPhi", "REGION OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0102   rctNotCentralIsoEmEtEtaPhi_ =
0103       ibooker.book2D("rctNotCentralEmIsoEmEtEtaPhi", "ISO EM E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0104   rctNotCentralIsoEmOccEtaPhi_ = ibooker.book2D(
0105       "rctNotCentralEmIsoEmOccEtaPhi", "ISO EM OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0106   rctNotCentralNonIsoEmEtEtaPhi_ = ibooker.book2D(
0107       "rctNotCentralEmNonIsoEmEtEtaPhi", "NON-ISO EM E_{T}", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0108   rctNotCentralNonIsoEmOccEtaPhi_ = ibooker.book2D(
0109       "rctNotCentralEmNonIsoEmOccEtaPhi", "NON-ISO EM OCCUPANCY", ETABINS, ETAMIN, ETAMAX, PHIBINS, PHIMIN, PHIMAX);
0110 }
0111 
0112 void L1TRCT::analyze(const Event &e, const EventSetup &c) {
0113   if (verbose_) {
0114     std::cout << "L1TRCT: analyze...." << std::endl;
0115   }
0116 
0117   // filter according trigger type
0118   //  enum ExperimentType {
0119   //        Undefined          =  0,
0120   //        PhysicsTrigger     =  1,
0121   //        CalibrationTrigger =  2,
0122   //        RandomTrigger      =  3,
0123   //        Reserved           =  4,
0124   //        TracedEvent        =  5,
0125   //        TestTrigger        =  6,
0126   //        ErrorTrigger       = 15
0127 
0128   // fill a histogram with the trigger type, for normalization fill also last bin
0129   // ErrorTrigger + 1
0130   double triggerType = static_cast<double>(e.experimentType()) + 0.001;
0131   double triggerTypeLast = static_cast<double>(edm::EventAuxiliary::ExperimentType::ErrorTrigger) + 0.001;
0132   triggerType_->Fill(triggerType);
0133   triggerType_->Fill(triggerTypeLast + 1);
0134 
0135   // filter only if trigger type is greater than 0, negative values disable filtering
0136   if (filterTriggerType_ >= 0) {
0137     // now filter, for real data only
0138     if (e.isRealData()) {
0139       if (!(e.experimentType() == filterTriggerType_)) {
0140         edm::LogInfo("L1TRCT") << "\n Event of TriggerType " << e.experimentType() << " rejected" << std::endl;
0141         return;
0142       }
0143     }
0144   }
0145 
0146   // Get the RCT digis
0147   edm::Handle<L1CaloEmCollection> em;
0148   edm::Handle<L1CaloRegionCollection> rgn;
0149 
0150   bool doEm = true;
0151   bool doHd = true;
0152 
0153   e.getByToken(rctSource_L1CRCollection_, rgn);
0154   e.getByToken(rctSource_L1CEMCollection_, em);
0155 
0156   if (!rgn.isValid()) {
0157     edm::LogInfo("DataNotFound") << "can't find L1CaloRegionCollection - RCT";
0158     doHd = false;
0159   }
0160 
0161   if (!em.isValid()) {
0162     edm::LogInfo("DataNotFound") << "can't find L1CaloEmCollection - Layer2 ";
0163     doEm = false;
0164   }
0165 
0166   if (doHd) {
0167     // Fill the RCT histograms
0168 
0169     for (L1CaloRegionCollection::const_iterator ireg = rgn->begin(); ireg != rgn->end(); ireg++) {
0170       if (ireg->et() > 0) {
0171         rctRegionBx_->Fill(ireg->bx());
0172       }
0173 
0174       if (selectBX_ == -1 || selectBX_ == ireg->bx()) {
0175         if (ireg->et() > 0) {
0176           rctRegionRank_->Fill(ireg->et());
0177           if (ireg->et() > 5) {
0178             rctRegionsOccEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0179           }
0180           rctRegionsEtEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi(), ireg->et());
0181         }
0182 
0183         if (ireg->overFlow())
0184           rctOverFlowEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0185         if (ireg->tauVeto())
0186           rctTauVetoEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0187         if (ireg->mip())
0188           rctMipEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0189         if (ireg->quiet())
0190           rctQuietEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0191         if (ireg->fineGrain())
0192           rctHfPlusTauEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0193 
0194       } else if (selectBX_ != -1 && selectBX_ != ireg->bx()) {
0195         if (ireg->et() > 5)
0196           rctNotCentralRegionsOccEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi());
0197         rctNotCentralRegionsEtEtaPhi_->Fill(ireg->gctEta(), ireg->gctPhi(), ireg->et());
0198       }
0199     }
0200   }
0201 
0202   if (doEm) {
0203     // Isolated and non-isolated EM
0204     for (L1CaloEmCollection::const_iterator iem = em->begin(); iem != em->end(); iem++) {
0205       if (iem->rank() == 0)
0206         continue;
0207       rctEmBx_->Fill(iem->bx());
0208       if (selectBX_ == -1 || selectBX_ == iem->bx()) {
0209         if (iem->isolated()) {
0210           rctIsoEmRank_->Fill(iem->rank());
0211           rctIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi(), iem->rank());
0212           if (iem->rank() > 10) {
0213             rctIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi());
0214           }
0215         } else {
0216           rctNonIsoEmRank_->Fill(iem->rank());
0217           rctNonIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi(), iem->rank());
0218           if (iem->rank() > 10) {
0219             rctNonIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi());
0220           }
0221         }
0222       } else if (selectBX_ != -1 && selectBX_ != iem->bx()) {
0223         if (iem->isolated()) {
0224           rctNotCentralIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi(), iem->rank());
0225           if (iem->rank() > 10) {
0226             rctNotCentralIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi());
0227           }
0228         } else {
0229           rctNotCentralNonIsoEmEtEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi(), iem->rank());
0230           if (iem->rank() > 10) {
0231             rctNotCentralNonIsoEmOccEtaPhi_->Fill(iem->regionId().ieta(), iem->regionId().iphi());
0232           }
0233         }
0234       }
0235     }
0236   }
0237 }