test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
21 // system include files
22 #include <memory>
23 
24 // framework
31 
32 // data formats
38 
39 // ROOT output stuff
42 #include "TTree.h"
43 
45 
46 //
47 // class declaration
48 //
49 
51 public:
52  explicit L1EventTreeProducer(const edm::ParameterSet&);
54 
55 
56 private:
57  virtual void beginJob(void) ;
58  virtual void analyze(const edm::Event&, const edm::EventSetup&);
59  virtual void endJob();
60 
61 public:
62 
65 
66 private:
67 
68  // output file
70 
71  // tree
72  TTree * tree_;
73 
75 
76  // EDM input tags
77  //edm::EDGetTokenT<l1t::EGammaBxCollection> egToken_;
78 
79 };
80 
81 
82 
84 {
85  hltSource_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"));
86 
87  std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
88  std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
89  std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
90  std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");
91 
92  bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
93  double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);
94 
95  l1Event = new L1Analysis::L1AnalysisEvent(puMCFile, puMCHist,
96  puDataFile, puDataHist,
97  useAvgVtx, maxAllowedWeight,consumesCollector());
98  l1EventData = l1Event->getData();
99 
100  // set up output
101  tree_=fs_->make<TTree>("L1EventTree", "L1EventTree");
102  tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
103 }
104 
105 
107 {
108 
109  // do anything here that needs to be done at desctruction time
110  // (e.g. close files, deallocate resources etc.)
111  delete l1Event;
112 
113 }
114 
115 
116 //
117 // member functions
118 //
119 
120 // ------------ method called to for each event ------------
121 void
123 {
124  if(!hltSource_.isUninitialized()) {
125  l1Event->Reset();
126  l1Event->Set(iEvent,hltSource_);
127  }
128  tree_->Fill();
129 }
130 
131 // ------------ method called once each job just before starting event loop ------------
132 void
134 {
135 }
136 
137 // ------------ method called once each job just after ending the event loop ------------
138 void
140 }
141 
142 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::TriggerResults > hltSource_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob(void)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
int iEvent
Definition: GenABIO.cc:230
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_)
bool isUninitialized() const
Definition: EDGetToken.h:73
L1EventTreeProducer(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)