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 
34 public:
35  explicit L1HOTreeProducer(const edm::ParameterSet&);
36  ~L1HOTreeProducer() override;
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 
60  consumes<edm::SortedCollection<HODataFrame>>(iConfig.getUntrackedParameter<edm::InputTag>("hoDataFrameToken"));
61 
62  l1HOData = l1HO.getData();
63 
64  // set up output
65  tree_ = fs_->make<TTree>("L1HOTree", "L1HOTree");
66  tree_->Branch("L1HO", "L1Analysis::L1AnalysisL1HODataFormat", &l1HOData, 32000, 3);
67 }
68 
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called to for each event ------------
77  l1HO.Reset();
78 
80 
81  iEvent.getByToken(hoDataFrameToken_, hoDataFrame);
82 
83  if (hoDataFrame.isValid()) {
84  l1HO.SetHO(*hoDataFrame);
85  } else {
86  edm::LogWarning("MissingProduct") << "HODataFrame not found. Branch will not be filled" << std::endl;
87  }
88 
89  tree_->Fill();
90 }
91 
92 // ------------ method called once each job just before starting event loop ------------
94 
95 // ------------ method called once each job just after ending the event loop ------------
97 
98 //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: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
edm::EDGetTokenT< edm::SortedCollection< HODataFrame > > hoDataFrameToken_
L1Analysis::L1AnalysisL1HODataFormat * l1HOData
~L1HOTreeProducer() override
Log< level::Warning, false > LogWarning
L1Analysis::L1AnalysisL1HO l1HO