Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:17

0001 // system include files
0002 #include <memory>
0003 
0004 // framework
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 // data formats
0013 #include "DataFormats/L1TMuon/interface/RegionalMuonShower.h"
0014 
0015 // ROOT output stuff
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0018 #include "TTree.h"
0019 
0020 #include "L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeTfMuonShower.h"
0021 
0022 //
0023 // class declaration
0024 //
0025 
0026 class L1UpgradeTfMuonShowerTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0027 public:
0028   explicit L1UpgradeTfMuonShowerTreeProducer(const edm::ParameterSet&);
0029   ~L1UpgradeTfMuonShowerTreeProducer() override = default;
0030 
0031 private:
0032   void beginJob(void) override;
0033   void analyze(const edm::Event&, const edm::EventSetup&) override;
0034   void endJob() override;
0035 
0036 public:
0037   L1Analysis::L1AnalysisL1UpgradeTfMuonShower l1UpgradeEmtf;
0038   L1Analysis::L1AnalysisL1UpgradeTfMuonShowerDataFormat* l1UpgradeEmtfData;
0039 
0040 private:
0041   unsigned maxL1UpgradeTfMuonShower_;
0042 
0043   // output file
0044   edm::Service<TFileService> fs_;
0045 
0046   // tree
0047   TTree* tree_;
0048 
0049   // EDM input tags
0050   edm::EDGetTokenT<l1t::RegionalMuonShowerBxCollection> emtfMuonShowerToken_;
0051 };
0052 
0053 L1UpgradeTfMuonShowerTreeProducer::L1UpgradeTfMuonShowerTreeProducer(const edm::ParameterSet& iConfig) {
0054   emtfMuonShowerToken_ = consumes<l1t::RegionalMuonShowerBxCollection>(
0055       iConfig.getUntrackedParameter<edm::InputTag>("emtfMuonShowerToken"));
0056 
0057   maxL1UpgradeTfMuonShower_ = iConfig.getParameter<unsigned int>("maxL1UpgradeTfMuonShower");
0058 
0059   l1UpgradeEmtfData = l1UpgradeEmtf.getData();
0060 
0061   usesResource(TFileService::kSharedResource);
0062 
0063   // set up output
0064   tree_ = fs_->make<TTree>("L1UpgradeTfMuonShowerTree", "L1UpgradeTfMuonShowerTree");
0065   tree_->Branch(
0066       "L1UpgradeEmtfMuonShower", "L1Analysis::L1AnalysisL1UpgradeTfMuonShowerDataFormat", &l1UpgradeEmtfData, 32000, 3);
0067 }
0068 
0069 //
0070 // member functions
0071 //
0072 
0073 // ------------ method called to for each event  ------------
0074 void L1UpgradeTfMuonShowerTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0075   l1UpgradeEmtf.Reset();
0076 
0077   edm::Handle<l1t::RegionalMuonShowerBxCollection> emtfMuonShower;
0078 
0079   iEvent.getByToken(emtfMuonShowerToken_, emtfMuonShower);
0080 
0081   if (emtfMuonShower.isValid()) {
0082     l1UpgradeEmtf.SetTfMuonShower(*emtfMuonShower, maxL1UpgradeTfMuonShower_);
0083   } else {
0084     edm::LogWarning("MissingProduct") << "L1Upgrade EMTF muons not found. Branch will not be filled" << std::endl;
0085   }
0086 
0087   tree_->Fill();
0088 }
0089 
0090 // ------------ method called once each job just before starting event loop  ------------
0091 void L1UpgradeTfMuonShowerTreeProducer::beginJob(void) {}
0092 
0093 // ------------ method called once each job just after ending the event loop  ------------
0094 void L1UpgradeTfMuonShowerTreeProducer::endJob() {}
0095 
0096 //define this as a plug-in
0097 DEFINE_FWK_MODULE(L1UpgradeTfMuonShowerTreeProducer);