CMS 3D CMS Logo

L1HOTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1Ntuples
4 // Class: L1HOTreeProducer
5 //
6 
7 
8 // system include files
9 #include <memory>
10 
11 // framework
18 
19 // data formats
22 
23 // ROOT output stuff
26 #include "TTree.h"
27 
29 
30 //
31 // class declaration
32 //
33 
35 public:
36  explicit L1HOTreeProducer(const edm::ParameterSet&);
37  ~L1HOTreeProducer() override;
38 
39 private:
40  void beginJob(void) override ;
41  void analyze(const edm::Event&, const edm::EventSetup&) override;
42  void endJob() override;
43 
44 public:
45 
48 
49 private:
50 
51  // output file
53 
54  // tree
55  TTree * tree_;
56 
57  // EDM input tags
59 };
60 
61 
62 
64 {
65 
66  hoDataFrameToken_ = consumes<edm::SortedCollection<HODataFrame>>(iConfig.getUntrackedParameter<edm::InputTag>("hoDataFrameToken"));
67 
68  l1HOData = l1HO.getData();
69 
70  // set up output
71  tree_=fs_->make<TTree>("L1HOTree", "L1HOTree");
72  tree_->Branch("L1HO", "L1Analysis::L1AnalysisL1HODataFormat", &l1HOData, 32000, 3);
73 }
74 
75 
77 {
78 }
79 
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called to for each event ------------
86 void
88 {
89 
90  l1HO.Reset();
91 
93 
94  iEvent.getByToken(hoDataFrameToken_, hoDataFrame);
95 
96  if (hoDataFrame.isValid()){
97  l1HO.SetHO(*hoDataFrame);
98  } else {
99  edm::LogWarning("MissingProduct") << "HODataFrame not found. Branch will not be filled" << std::endl;
100  }
101 
102  tree_->Fill();
103 }
104 
105 // ------------ method called once each job just before starting event loop ------------
106 void
108 {
109 }
110 
111 // ------------ method called once each job just after ending the event loop ------------
112 void
114 }
115 
116 //define this as a plug-in
T getUntrackedParameter(std::string const &, T const &) const
void SetHO(const edm::SortedCollection< HODataFrame > &hoDataFrame)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:230
L1HOTreeProducer(const edm::ParameterSet &)
void endJob() override
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< edm::SortedCollection< HODataFrame > > hoDataFrameToken_
L1Analysis::L1AnalysisL1HODataFormat * l1HOData
~L1HOTreeProducer() override
L1Analysis::L1AnalysisL1HO l1HO