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  std::cout << "CCLA Begin constructor" << std::endl;
86  hltSource_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("hltSource"));
87 
88  std::string puMCFile = iConfig.getUntrackedParameter<std::string>("puMCFile", "");
89  std::string puMCHist = iConfig.getUntrackedParameter<std::string>("puMCHist", "pileup");
90  std::string puDataFile = iConfig.getUntrackedParameter<std::string>("puDataFile", "");
91  std::string puDataHist = iConfig.getUntrackedParameter<std::string>("puDataHist", "pileup");
92 
93  bool useAvgVtx = iConfig.getUntrackedParameter<bool>("useAvgVtx", true);
94  double maxAllowedWeight = iConfig.getUntrackedParameter<double>("maxAllowedWeight", -1);
95 
96  l1Event = new L1Analysis::L1AnalysisEvent(puMCFile, puMCHist,
97  puDataFile, puDataHist,
98  useAvgVtx, maxAllowedWeight);
99  l1EventData = l1Event->getData();
100 
101  // set up output
102  tree_=fs_->make<TTree>("L1EventTree", "L1EventTree");
103  tree_->Branch("Event", "L1Analysis::L1AnalysisEventDataFormat", &l1EventData, 32000, 3);
104 }
105 
106 
108 {
109 
110  // do anything here that needs to be done at desctruction time
111  // (e.g. close files, deallocate resources etc.)
112  delete l1Event;
113 
114 }
115 
116 
117 //
118 // member functions
119 //
120 
121 // ------------ method called to for each event ------------
122 void
124 {
125  if(!hltSource_.isUninitialized()) {
126  l1Event->Reset();
127  l1Event->Set(iEvent,hltSource_);
128  }
129  tree_->Fill();
130 }
131 
132 // ------------ method called once each job just before starting event loop ------------
133 void
135 {
136 }
137 
138 // ------------ method called once each job just after ending the event loop ------------
139 void
141 }
142 
143 //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_
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
tuple cout
Definition: gather_cfg.py:145
L1EventTreeProducer(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)