CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1HOTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1Ntuples
4 // Class: L1HOTreeProducer
5 //
6 
7 // system include files
8 #include <memory>
9 
10 // framework
17 
18 // data formats
21 
22 // ROOT output stuff
25 #include "TTree.h"
26 
28 
29 //
30 // class declaration
31 //
32 
33 class L1HOTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
34 public:
35  explicit L1HOTreeProducer(const edm::ParameterSet&);
36  ~L1HOTreeProducer() override = default;
37 
38 private:
39  void beginJob(void) override;
40  void analyze(const edm::Event&, const edm::EventSetup&) override;
41  void endJob() override;
42 
43 public:
46 
47 private:
48  // output file
50 
51  // tree
52  TTree* tree_;
53 
54  // EDM input tags
56 };
57 
59  : hoDataFrameToken_(consumes<edm::SortedCollection<HODataFrame>>(
60  iConfig.getUntrackedParameter<edm::InputTag>("hoDataFrameToken"))) {
61  l1HOData = l1HO.getData();
62  usesResource(TFileService::kSharedResource);
63 
64  // set up output
65  tree_ = fs_->make<TTree>("L1HOTree", "L1HOTree");
66  tree_->Branch("L1HO", "L1Analysis::L1AnalysisL1HODataFormat", &l1HOData, 32000, 3);
67 }
68 
69 //
70 // member functions
71 //
72 
73 // ------------ method called to for each event ------------
75  l1HO.Reset();
76 
78 
79  iEvent.getByToken(hoDataFrameToken_, hoDataFrame);
80 
81  if (hoDataFrame.isValid()) {
82  l1HO.SetHO(*hoDataFrame);
83  } else {
84  edm::LogWarning("MissingProduct") << "HODataFrame not found. Branch will not be filled" << std::endl;
85  }
86 
87  tree_->Fill();
88 }
89 
90 // ------------ method called once each job just before starting event loop ------------
92 
93 // ------------ method called once each job just after ending the event loop ------------
95 
96 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
void SetHO(const edm::SortedCollection< HODataFrame > &hoDataFrame)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Service< TFileService > fs_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
L1AnalysisL1HODataFormat * getData()
void beginJob(void) override
int iEvent
Definition: GenABIO.cc:224
L1HOTreeProducer(const edm::ParameterSet &)
void endJob() override
bool isValid() const
Definition: HandleBase.h:70
L1Analysis::L1AnalysisL1HODataFormat * l1HOData
~L1HOTreeProducer() override=default
Log< level::Warning, false > LogWarning
L1Analysis::L1AnalysisL1HO l1HO
const edm::EDGetTokenT< edm::SortedCollection< HODataFrame > > hoDataFrameToken_