Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:58

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1GmtTriggerSource
0004 // Class:      L1GmtTriggerSource
0005 //
0006 /**\class L1GmtTriggerSource L1GmtTriggerSource.cc 
0007 
0008  Description: Analyzer to determine the source of muon triggers
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Ivan Mikulec
0015 //         Created:
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <vector>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 
0032 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
0033 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
0034 //
0035 // class decleration
0036 //
0037 
0038 class L1GmtTriggerSource : public edm::one::EDAnalyzer<> {
0039 public:
0040   explicit L1GmtTriggerSource(const edm::ParameterSet&);
0041   ~L1GmtTriggerSource() override;
0042 
0043 private:
0044   void beginJob() override;
0045   void analyze(const edm::Event&, const edm::EventSetup&) override;
0046   void endJob() override;
0047 
0048   // ----------member data ---------------------------
0049   edm::InputTag m_GMTInputTag;
0050 };
0051 
0052 //
0053 // constants, enums and typedefs
0054 //
0055 
0056 //
0057 // static data member definitions
0058 //
0059 
0060 //
0061 // constructors and destructor
0062 //
0063 L1GmtTriggerSource::L1GmtTriggerSource(const edm::ParameterSet& ps)
0064 
0065 {
0066   //now do what ever initialization is needed
0067   m_GMTInputTag = ps.getParameter<edm::InputTag>("GMTInputTag");
0068 }
0069 
0070 L1GmtTriggerSource::~L1GmtTriggerSource() {
0071   // do anything here that needs to be done at desctruction time
0072   // (e.g. close files, deallocate resources etc.)
0073 }
0074 
0075 //
0076 // member functions
0077 //
0078 
0079 // ------------ method called to for each event  ------------
0080 void L1GmtTriggerSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0081   using namespace edm;
0082 
0083   edm::Handle<L1MuGMTReadoutCollection> gmtrc_handle;
0084   iEvent.getByLabel(m_GMTInputTag, gmtrc_handle);
0085   L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
0086 
0087   bool dt_l1a = false;
0088   bool csc_l1a = false;
0089   bool halo_l1a = false;
0090   bool rpcb_l1a = false;
0091   bool rpcf_l1a = false;
0092 
0093   std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0094   std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
0095 
0096   for (igmtrr = gmt_records.begin(); igmtrr != gmt_records.end(); igmtrr++) {
0097     std::vector<L1MuRegionalCand>::const_iterator iter1;
0098     std::vector<L1MuRegionalCand> rmc;
0099 
0100     // DT muon candidates
0101     int idt = 0;
0102     rmc = igmtrr->getDTBXCands();
0103     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0104       if (!(*iter1).empty()) {
0105         idt++;
0106       }
0107     }
0108 
0109     if (idt > 0)
0110       std::cout << "Found " << idt << " valid DT candidates in bx wrt. L1A = " << igmtrr->getBxInEvent() << std::endl;
0111     if (igmtrr->getBxInEvent() == 0 && idt > 0)
0112       dt_l1a = true;
0113 
0114     // CSC muon candidates
0115     int icsc = 0;
0116     int ihalo = 0;
0117     rmc = igmtrr->getCSCCands();
0118     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0119       if (!(*iter1).empty()) {
0120         if ((*iter1).isFineHalo()) {
0121           ihalo++;
0122         } else {
0123           icsc++;
0124         }
0125       }
0126     }
0127 
0128     if (icsc > 0)
0129       std::cout << "Found " << icsc << " valid CSC candidates in bx wrt. L1A = " << igmtrr->getBxInEvent() << std::endl;
0130     if (ihalo > 0)
0131       std::cout << "Found " << ihalo << " valid CSC halo candidates in bx wrt. L1A = " << igmtrr->getBxInEvent()
0132                 << std::endl;
0133     if (igmtrr->getBxInEvent() == 0 && icsc > 0)
0134       csc_l1a = true;
0135     if (igmtrr->getBxInEvent() == 0 && ihalo > 0)
0136       halo_l1a = true;
0137 
0138     // RPC barrel muon candidates
0139     int irpcb = 0;
0140     rmc = igmtrr->getBrlRPCCands();
0141     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0142       if (!(*iter1).empty()) {
0143         irpcb++;
0144       }
0145     }
0146 
0147     if (irpcb > 0)
0148       std::cout << "Found " << irpcb << " valid barrel RPC candidates in bx wrt. L1A = " << igmtrr->getBxInEvent()
0149                 << std::endl;
0150     if (igmtrr->getBxInEvent() == 0 && irpcb > 0)
0151       rpcb_l1a = true;
0152 
0153     // RPC endcap muon candidates
0154     int irpcf = 0;
0155     rmc = igmtrr->getFwdRPCCands();
0156     for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0157       if (!(*iter1).empty()) {
0158         irpcf++;
0159       }
0160     }
0161 
0162     if (irpcf > 0)
0163       std::cout << "Found " << irpcf << " valid endcap RPC candidates in bx wrt. L1A = " << igmtrr->getBxInEvent()
0164                 << std::endl;
0165     if (igmtrr->getBxInEvent() == 0 && irpcf > 0)
0166       rpcf_l1a = true;
0167   }
0168 
0169   std::cout << "**** L1 Muon Trigger Source ****" << std::endl;
0170   if (dt_l1a)
0171     std::cout << "DT" << std::endl;
0172   if (csc_l1a)
0173     std::cout << "CSC" << std::endl;
0174   if (halo_l1a)
0175     std::cout << "CSC halo" << std::endl;
0176   if (rpcb_l1a)
0177     std::cout << "barrel RPC" << std::endl;
0178   if (rpcf_l1a)
0179     std::cout << "endcap RPC" << std::endl;
0180   std::cout << "************************" << std::endl;
0181 }
0182 
0183 // ------------ method called once each job just before starting event loop  ------------
0184 void L1GmtTriggerSource::beginJob() {}
0185 
0186 // ------------ method called once each job just after ending the event loop  ------------
0187 void L1GmtTriggerSource::endJob() {}
0188 
0189 //define this as a plug-in
0190 DEFINE_FWK_MODULE(L1GmtTriggerSource);