Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:13

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1Trigger/L1TNtuples
0004 // Class:      L1ExtraTreeProducer
0005 //
0006 /**\class L1ExtraTreeProducer L1ExtraTreeProducer.cc L1Trigger/L1TNtuples/src/L1ExtraTreeProducer.cc
0007 
0008 Description: Produce L1 Extra tree
0009 
0010 Implementation:
0011      
0012 */
0013 //
0014 // Original Author:  Alex Tapper
0015 //         Created:
0016 // $Id: L1ExtraTreeProducer.cc,v 1.6 2010/06/17 20:44:45 econte Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // framework
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0030 
0031 // L1Gt Utils
0032 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
0033 
0034 // ROOT output stuff
0035 #include "FWCore/ServiceRegistry/interface/Service.h"
0036 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0037 #include "TTree.h"
0038 
0039 #include "L1Trigger/L1TNtuples/interface/L1AnalysisL1Menu.h"
0040 
0041 //
0042 // class declaration
0043 //
0044 
0045 class L1MenuTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0046 public:
0047   explicit L1MenuTreeProducer(const edm::ParameterSet&);
0048   ~L1MenuTreeProducer() override;
0049 
0050 private:
0051   void analyze(const edm::Event&, const edm::EventSetup&) override;
0052 
0053 public:
0054   L1Analysis::L1AnalysisL1Menu* l1Menu;
0055   L1Analysis::L1AnalysisL1MenuDataFormat* l1MenuData;
0056 
0057 private:
0058   // output file
0059   edm::Service<TFileService> fs_;
0060 
0061   // tree
0062   TTree* tree_;
0063 
0064   // EDM input tags
0065   //  edm::InputTag l1MenuInputTag_;
0066   L1GtUtils l1GtUtils_;
0067 };
0068 
0069 L1MenuTreeProducer::L1MenuTreeProducer(const edm::ParameterSet& iConfig)
0070     :  //  l1MenuInputTag_(iConfig.getParameter<edm::InputTag>("L1MenuInputTag")),
0071       l1GtUtils_(iConfig, consumesCollector(), true, L1GtUtils::UseEventSetupIn::Event) {
0072   usesResource(TFileService::kSharedResource);
0073 
0074   l1Menu = new L1Analysis::L1AnalysisL1Menu();
0075   l1MenuData = l1Menu->getData();
0076 
0077   // set up output
0078   tree_ = fs_->make<TTree>("L1MenuTree", "L1MenuTree");
0079   tree_->Branch("L1Menu", "L1Analysis::L1AnalysisL1MenuDataFormat", &l1MenuData, 32000, 0 /*3*/);
0080 }
0081 
0082 L1MenuTreeProducer::~L1MenuTreeProducer() {}
0083 
0084 //
0085 // member functions
0086 //
0087 
0088 // ------------ method called to for each event  ------------
0089 void L1MenuTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0090   l1Menu->Reset();
0091 
0092   // getting l1GtUtils
0093   edm::LogInfo("L1TNtuples") << "Extracting menu ... " << std::endl;
0094   l1GtUtils_.retrieveL1EventSetup(iSetup);
0095 
0096   // testing menu
0097   edm::LogInfo("L1TNtuples") << "L1 trigger menu name and implementation:"
0098                              << "\n"
0099                              << l1GtUtils_.l1TriggerMenu() << "\n"
0100                              << l1GtUtils_.l1TriggerMenuImplementation() << std::endl;
0101 
0102   // adding PrescaleFactorIndex
0103   l1Menu->SetPrescaleFactorIndex(l1GtUtils_, iEvent);
0104 
0105   tree_->Fill();
0106 }
0107 
0108 //define this as a plug-in
0109 DEFINE_FWK_MODULE(L1MenuTreeProducer);