CMS 3D CMS Logo

L1EventTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TriggerDPG/L1Ntuples
4 // Class: L1EventTreeProducer
5 //
13 //
14 // Original Author:
15 // Created:
16 // $Id: L1EventTreeProducer.cc,v 1.8 2012/08/29 12:44:03 jbrooke Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // framework
30 
31 // data formats
37 
38 // ROOT output stuff
41 #include "TTree.h"
42 
44 
45 //
46 // class declaration
47 //
48 
49 class L1EventTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
50 public:
51  explicit L1EventTreeProducer(const edm::ParameterSet&);
52  ~L1EventTreeProducer() override = default;
53 
54 private:
55  void beginJob(void) override;
56  void analyze(const edm::Event&, const edm::EventSetup&) override;
57  void endJob() override;
58 
59 public:
60  std::unique_ptr<L1Analysis::L1AnalysisEvent> l1Event;
62 
63 private:
64  // output file
66 
67  // tree
68  TTree* tree_;
69 
70  // EDM input tags
72 };
73 
75  : hltSource_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"))) {
76  std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
77  std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
78  std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
79  std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");
80 
81  usesResource(TFileService::kSharedResource);
82 
83  bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
84  double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);
85 
86  l1Event = std::make_unique<L1Analysis::L1AnalysisEvent>(
88  l1EventData = l1Event->getData();
89 
90  // set up output
91  tree_ = fs_->make<TTree>("L1EventTree", "L1EventTree");
92  tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to for each event ------------
101  if (!hltSource_.isUninitialized()) {
102  l1Event->Reset();
103  l1Event->Set(iEvent, hltSource_);
104  }
105  tree_->Fill();
106 }
107 
108 // ------------ method called once each job just before starting event loop ------------
110 
111 // ------------ method called once each job just after ending the event loop ------------
113 
114 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
void beginJob(void) override
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:98
std::unique_ptr< L1Analysis::L1AnalysisEvent > l1Event
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Service< TFileService > fs_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1Analysis::L1AnalysisEventDataFormat * l1EventData
const edm::EDGetTokenT< edm::TriggerResults > hltSource_
HLT enums.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
~L1EventTreeProducer() override=default
L1EventTreeProducer(const edm::ParameterSet &)