Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:12

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1ExtraTestAnalyzer
0004 // Class:      L1ExtraTestAnalyzer
0005 //
0006 /**\class L1ExtraTestAnalyzer \file L1ExtraTestAnalyzer.cc
0007    L1TriggerOffline/L1ExtraTestAnalyzer/src/L1ExtraTestAnalyzer.cc \author
0008    Werner Sun
0009 
0010    Description: simple analyzer to print out L1Extra object information.
0011 */
0012 //
0013 // Original Author:  Werner Sun
0014 //         Created:  Fri Jul 28 14:22:31 EDT 2006
0015 //
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 #include <string>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031 
0032 #include "DataFormats/Common/interface/Handle.h"
0033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0034 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
0035 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
0036 #include "DataFormats/L1Trigger/interface/L1HFRings.h"
0037 #include "DataFormats/L1Trigger/interface/L1HFRingsFwd.h"
0038 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
0039 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
0040 #include "DataFormats/L1Trigger/interface/L1ParticleMap.h"
0041 #include "DataFormats/L1Trigger/interface/L1ParticleMapFwd.h"
0042 
0043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0044 
0045 #include "TFile.h"
0046 #include "TH1.h"
0047 
0048 using namespace std;
0049 
0050 //
0051 // class decleration
0052 //
0053 
0054 class L1ExtraTestAnalyzer : public edm::one::EDAnalyzer<> {
0055 public:
0056   explicit L1ExtraTestAnalyzer(const edm::ParameterSet &);
0057   ~L1ExtraTestAnalyzer() override;
0058 
0059   void analyze(const edm::Event &, const edm::EventSetup &) override;
0060 
0061 private:
0062   // ----------member data ---------------------------
0063 
0064   edm::InputTag isoEmSource_;
0065   edm::InputTag nonIsoEmSource_;
0066   edm::InputTag cenJetSource_;
0067   edm::InputTag forJetSource_;
0068   edm::InputTag tauJetSource_;
0069   edm::InputTag muonSource_;
0070   edm::InputTag etMissSource_;
0071   edm::InputTag htMissSource_;
0072   edm::InputTag hfRingsSource_;
0073   edm::InputTag gtReadoutSource_;
0074   edm::InputTag particleMapSource_;
0075 
0076   TFile file_;
0077   TH1F hist_;
0078 };
0079 
0080 //
0081 // constants, enums and typedefs
0082 //
0083 
0084 //
0085 // static data member definitions
0086 //
0087 
0088 //
0089 // constructors and destructor
0090 //
0091 L1ExtraTestAnalyzer::L1ExtraTestAnalyzer(const edm::ParameterSet &iConfig)
0092     : isoEmSource_(iConfig.getParameter<edm::InputTag>("isolatedEmSource")),
0093       nonIsoEmSource_(iConfig.getParameter<edm::InputTag>("nonIsolatedEmSource")),
0094       cenJetSource_(iConfig.getParameter<edm::InputTag>("centralJetSource")),
0095       forJetSource_(iConfig.getParameter<edm::InputTag>("forwardJetSource")),
0096       tauJetSource_(iConfig.getParameter<edm::InputTag>("tauJetSource")),
0097       muonSource_(iConfig.getParameter<edm::InputTag>("muonSource")),
0098       etMissSource_(iConfig.getParameter<edm::InputTag>("etMissSource")),
0099       htMissSource_(iConfig.getParameter<edm::InputTag>("htMissSource")),
0100       hfRingsSource_(iConfig.getParameter<edm::InputTag>("hfRingsSource")),
0101       gtReadoutSource_(iConfig.getParameter<edm::InputTag>("gtReadoutSource")),
0102       particleMapSource_(iConfig.getParameter<edm::InputTag>("particleMapSource")),
0103       file_("l1extra.root", "RECREATE"),
0104       hist_("triggers",
0105             "Triggers",
0106             2 * l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 1,
0107             -0.75,
0108             static_cast<double>(l1extra::L1ParticleMap::kNumOfL1TriggerTypes) + 0.5 - 0.75) {
0109   // now do what ever initialization is needed
0110 }
0111 
0112 L1ExtraTestAnalyzer::~L1ExtraTestAnalyzer() {
0113   // do anything here that needs to be done at desctruction time
0114   // (e.g. close files, deallocate resources etc.)
0115 
0116   file_.cd();
0117   hist_.Write();
0118 }
0119 
0120 //
0121 // member functions
0122 //
0123 
0124 // ------------ method called to produce the data  ------------
0125 void L1ExtraTestAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0126   using namespace edm;
0127   using namespace l1extra;
0128 
0129   static int iev = 0;
0130   cout << "EVENT " << ++iev << endl;
0131 
0132   cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
0133 
0134   // Isolated EM particles
0135   Handle<L1EmParticleCollection> isoEmColl;
0136   iEvent.getByLabel(isoEmSource_, isoEmColl);
0137   cout << "Number of isolated EM " << isoEmColl->size() << endl;
0138 
0139   for (L1EmParticleCollection::const_iterator emItr = isoEmColl->begin(); emItr != isoEmColl->end(); ++emItr) {
0140     cout << "  p4 (" << emItr->px() << ", " << emItr->py() << ", " << emItr->pz() << ", " << emItr->energy() << ") et "
0141          << emItr->et() << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
0142   }
0143 
0144   // Non-isolated EM particles
0145   Handle<L1EmParticleCollection> nonIsoEmColl;
0146   iEvent.getByLabel(nonIsoEmSource_, nonIsoEmColl);
0147   cout << "Number of non-isolated EM " << nonIsoEmColl->size() << endl;
0148 
0149   for (L1EmParticleCollection::const_iterator emItr = nonIsoEmColl->begin(); emItr != nonIsoEmColl->end(); ++emItr) {
0150     cout << "  p4 (" << emItr->px() << ", " << emItr->py() << ", " << emItr->pz() << ", " << emItr->energy() << ") et "
0151          << emItr->et() << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
0152   }
0153 
0154   // Jet particles
0155   Handle<L1JetParticleCollection> cenJetColl;
0156   iEvent.getByLabel(cenJetSource_, cenJetColl);
0157   cout << "Number of central jets " << cenJetColl->size() << endl;
0158 
0159   for (L1JetParticleCollection::const_iterator jetItr = cenJetColl->begin(); jetItr != cenJetColl->end(); ++jetItr) {
0160     cout << "  p4 (" << jetItr->px() << ", " << jetItr->py() << ", " << jetItr->pz() << ", " << jetItr->energy()
0161          << ") et " << jetItr->et() << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
0162   }
0163 
0164   Handle<L1JetParticleCollection> forJetColl;
0165   iEvent.getByLabel(forJetSource_, forJetColl);
0166   cout << "Number of forward jets " << forJetColl->size() << endl;
0167 
0168   for (L1JetParticleCollection::const_iterator jetItr = forJetColl->begin(); jetItr != forJetColl->end(); ++jetItr) {
0169     cout << "  p4 (" << jetItr->px() << ", " << jetItr->py() << ", " << jetItr->pz() << ", " << jetItr->energy()
0170          << ") et " << jetItr->et() << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
0171   }
0172 
0173   Handle<L1JetParticleCollection> tauColl;
0174   iEvent.getByLabel(tauJetSource_, tauColl);
0175   cout << "Number of tau jets " << tauColl->size() << endl;
0176 
0177   for (L1JetParticleCollection::const_iterator tauItr = tauColl->begin(); tauItr != tauColl->end(); ++tauItr) {
0178     cout << "  p4 (" << tauItr->px() << ", " << tauItr->py() << ", " << tauItr->pz() << ", " << tauItr->energy()
0179          << ") et " << tauItr->et() << " eta " << tauItr->eta() << " phi " << tauItr->phi() << endl;
0180   }
0181 
0182   // Muon particles
0183   Handle<L1MuonParticleCollection> muColl;
0184   iEvent.getByLabel(muonSource_, muColl);
0185   cout << "Number of muons " << muColl->size() << endl;
0186 
0187   for (L1MuonParticleCollection::const_iterator muItr = muColl->begin(); muItr != muColl->end(); ++muItr) {
0188     cout << "  q " << muItr->charge() << " p4 (" << muItr->px() << ", " << muItr->py() << ", " << muItr->pz() << ", "
0189          << muItr->energy() << ") et " << muItr->et() << " eta " << muItr->eta() << endl
0190          << "    phi " << muItr->phi() << " iso " << muItr->isIsolated() << " mip " << muItr->isMip() << " fwd "
0191          << muItr->isForward() << " rpc " << muItr->isRPC() << endl;
0192   }
0193 
0194   // MET
0195   Handle<L1EtMissParticleCollection> etMissColl;
0196   iEvent.getByLabel(etMissSource_, etMissColl);
0197   cout << "MET Coll (" << etMissColl->begin()->px() << ", " << etMissColl->begin()->py() << ", "
0198        << etMissColl->begin()->pz() << ", " << etMissColl->begin()->energy() << ") phi " << etMissColl->begin()->phi()
0199        << " EtTot " << etMissColl->begin()->etTotal() << endl;
0200 
0201   // MHT
0202   Handle<L1EtMissParticleCollection> htMissColl;
0203   iEvent.getByLabel(htMissSource_, htMissColl);
0204   cout << "MHT Coll (" << htMissColl->begin()->px() << ", " << htMissColl->begin()->py() << ", "
0205        << htMissColl->begin()->pz() << ", " << htMissColl->begin()->energy() << ") phi " << htMissColl->begin()->phi()
0206        << " HtTot " << htMissColl->begin()->etTotal() << endl;
0207 
0208   // HF Rings
0209   Handle<L1HFRingsCollection> hfRingsColl;
0210   iEvent.getByLabel(hfRingsSource_, hfRingsColl);
0211   cout << "HF Rings:" << endl;
0212   for (int i = 0; i < L1HFRings::kNumRings; ++i) {
0213     cout << "  " << i << ": et sum = " << hfRingsColl->begin()->hfEtSum((L1HFRings::HFRingLabels)i)
0214          << ", bit count = " << hfRingsColl->begin()->hfBitCount((L1HFRings::HFRingLabels)i) << endl;
0215   }
0216   cout << endl;
0217 
0218   //    // L1GlobalTriggerReadoutRecord
0219   //    Handle< L1GlobalTriggerReadoutRecord > gtRecord ;
0220   //    iEvent.getByLabel( gtReadoutSource_, gtRecord ) ;
0221   //    cout << "Global trigger decision " << gtRecord->decision() << endl ;
0222 
0223   cout << endl;
0224 }
0225 
0226 // define this as a plug-in
0227 DEFINE_FWK_MODULE(L1ExtraTestAnalyzer);