CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
50 public:
51  explicit L1EventTreeProducer(const edm::ParameterSet&);
52  ~L1EventTreeProducer() override;
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:
62 
63 private:
64  // output file
66 
67  // tree
68  TTree* tree_;
69 
71 
72  // EDM input tags
73  //edm::EDGetTokenT<l1t::EGammaBxCollection> egToken_;
74 };
75 
77  hltSource_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"));
78 
79  std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
80  std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
81  std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
82  std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");
83 
84  bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
85  double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);
86 
88  puMCFile, puMCHist, puDataFile, puDataHist, useAvgVtx, maxAllowedWeight, consumesCollector());
89  l1EventData = l1Event->getData();
90 
91  // set up output
92  tree_ = fs_->make<TTree>("L1EventTree", "L1EventTree");
93  tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
94 }
95 
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99  delete l1Event;
100 }
101 
102 //
103 // member functions
104 //
105 
106 // ------------ method called to for each event ------------
108  if (!hltSource_.isUninitialized()) {
109  l1Event->Reset();
110  l1Event->Set(iEvent, hltSource_);
111  }
112  tree_->Fill();
113 }
114 
115 // ------------ method called once each job just before starting event loop ------------
117 
118 // ------------ method called once each job just after ending the event loop ------------
120 
121 //define this as a plug-in
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::TriggerResults > hltSource_
void beginJob(void) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
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.
L1Analysis::L1AnalysisEvent * l1Event
L1Analysis::L1AnalysisEventDataFormat * l1EventData
void Set(const edm::Event &e, const edm::EDGetTokenT< edm::TriggerResults > &hlt_)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1EventTreeProducer(const edm::ParameterSet &)