File indexing completed on 2024-04-06 12:21:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022
0023
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
0032 #include "DataFormats/L1Trigger/interface/EGamma.h"
0033 #include "DataFormats/L1Trigger/interface/Tau.h"
0034 #include "DataFormats/L1Trigger/interface/Jet.h"
0035 #include "DataFormats/L1Trigger/interface/Muon.h"
0036 #include "DataFormats/L1Trigger/interface/EtSum.h"
0037
0038
0039 #include "FWCore/ServiceRegistry/interface/Service.h"
0040 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0041 #include "TTree.h"
0042
0043 #include "L1Trigger/L1TNtuples/interface/L1AnalysisEvent.h"
0044
0045
0046
0047
0048
0049 class L1EventTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0050 public:
0051 explicit L1EventTreeProducer(const edm::ParameterSet&);
0052 ~L1EventTreeProducer() override = default;
0053
0054 private:
0055 void beginJob(void) override;
0056 void analyze(const edm::Event&, const edm::EventSetup&) override;
0057 void endJob() override;
0058
0059 public:
0060 std::unique_ptr<L1Analysis::L1AnalysisEvent> l1Event;
0061 L1Analysis::L1AnalysisEventDataFormat* l1EventData;
0062
0063 private:
0064
0065 edm::Service<TFileService> fs_;
0066
0067
0068 TTree* tree_;
0069
0070
0071 const edm::EDGetTokenT<edm::TriggerResults> hltSource_;
0072 };
0073
0074 L1EventTreeProducer::L1EventTreeProducer(const edm::ParameterSet& iConfig)
0075 : hltSource_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"))) {
0076 std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
0077 std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
0078 std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
0079 std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");
0080
0081 usesResource(TFileService::kSharedResource);
0082
0083 bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
0084 double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);
0085
0086 l1Event = std::make_unique<L1Analysis::L1AnalysisEvent>(
0087 puMCFile, puMCHist, puDataFile, puDataHist, useAvgVtx, maxAllowedWeight, consumesCollector());
0088 l1EventData = l1Event->getData();
0089
0090
0091 tree_ = fs_->make<TTree>("L1EventTree", "L1EventTree");
0092 tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
0093 }
0094
0095
0096
0097
0098
0099
0100 void L1EventTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0101 if (!hltSource_.isUninitialized()) {
0102 l1Event->Reset();
0103 l1Event->Set(iEvent, hltSource_);
0104 }
0105 tree_->Fill();
0106 }
0107
0108
0109 void L1EventTreeProducer::beginJob(void) {}
0110
0111
0112 void L1EventTreeProducer::endJob() {}
0113
0114
0115 DEFINE_FWK_MODULE(L1EventTreeProducer);