test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1ExtraTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TNtuples
4 // Class: L1ExtraTreeProducer
5 //
13 //
14 // Original Author: Alex Tapper
15 // Created:
16 // $Id: L1ExtraTreeProducer.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
44 
45 // ROOT output stuff
48 #include "TTree.h"
49 
51 
52 //
53 // class declaration
54 //
55 
57 public:
58  explicit L1ExtraTreeProducer(const edm::ParameterSet&);
60 
61 
62 private:
63  virtual void beginJob(void) ;
64  virtual void analyze(const edm::Event&, const edm::EventSetup&);
65  virtual void endJob();
66 
67 public:
68 
71 
72 private:
73 
74  unsigned maxL1Extra_;
75 
76  // output file
78 
79  // tree
80  TTree * tree_;
81 
82  // EDM input tags
93 
94 };
95 
96 
97 
99 
100 
101  nonIsoEmToken_ = consumes<l1extra::L1EmParticleCollection>(iConfig.getUntrackedParameter("nonIsoEmToken",edm::InputTag("l1extraParticles:NonIsolated")));
102  isoEmToken_ = consumes<l1extra::L1EmParticleCollection>(iConfig.getUntrackedParameter("isoEmToken",edm::InputTag("l1extraParticles:Isolated")));
103  tauJetToken_ = consumes<l1extra::L1JetParticleCollection>(iConfig.getUntrackedParameter("tauJetToken",edm::InputTag("l1extraParticles:Tau")));
104  isoTauJetToken_ = consumes<l1extra::L1JetParticleCollection>(iConfig.getUntrackedParameter("isoTauJetToken",edm::InputTag("l1extraParticles:IsoTau")));
105  cenJetToken_ = consumes<l1extra::L1JetParticleCollection>(iConfig.getUntrackedParameter("cenJetToken",edm::InputTag("l1extraParticles:Central")));
106  fwdJetToken_ = consumes<l1extra::L1JetParticleCollection>(iConfig.getUntrackedParameter("fwdJetToken",edm::InputTag("l1extraParticles:Forward")));
107  muonToken_ = consumes<l1extra::L1MuonParticleCollection>(iConfig.getUntrackedParameter("muonToken",edm::InputTag("l1extraParticles")));
108  metToken_ = consumes<l1extra::L1EtMissParticleCollection>(iConfig.getUntrackedParameter("metToken",edm::InputTag("l1extraParticles:MET")));
109  mhtToken_ = consumes<l1extra::L1EtMissParticleCollection>(iConfig.getUntrackedParameter("mhtToken",edm::InputTag("l1extraParticles:MHT")));
110  hfRingsToken_ = consumes<l1extra::L1HFRingsCollection>(iConfig.getUntrackedParameter("hfRingsToken",edm::InputTag("l1extraParticles")));
111 
112  maxL1Extra_ = iConfig.getParameter<unsigned int>("maxL1Extra");
113 
115  l1ExtraData = l1Extra->getData();
116 
117  // set up output
118  tree_=fs_->make<TTree>("L1ExtraTree", "L1ExtraTree");
119  tree_->Branch("L1Extra", "L1Analysis::L1AnalysisL1ExtraDataFormat", &l1ExtraData, 32000, 3);
120 
121 }
122 
123 
125 {
126 
127  // do anything here that needs to be done at desctruction time
128  // (e.g. close files, deallocate resources etc.)
129 
130 }
131 
132 
133 //
134 // member functions
135 //
136 
137 // ------------ method called to for each event ------------
138 void
140 {
141 
142  l1Extra->Reset();
143 
154 
155  iEvent.getByToken(nonIsoEmToken_, nonIsoEm);
156  iEvent.getByToken(isoEmToken_, isoEm);
157  iEvent.getByToken(tauJetToken_, tauJet);
158  iEvent.getByToken(isoTauJetToken_, isoTauJet);
159  iEvent.getByToken(cenJetToken_, cenJet);
160  iEvent.getByToken(fwdJetToken_, fwdJet);
161  iEvent.getByToken(muonToken_, muon);
162  iEvent.getByToken(metToken_, mets);
163  iEvent.getByToken(mhtToken_, mhts);
164  iEvent.getByToken(hfRingsToken_, hfRings);
165 
166  if (isoEm.isValid()){
167  l1Extra->SetIsoEm(isoEm, maxL1Extra_);
168  } else {
169  edm::LogWarning("MissingProduct") << "L1Extra Iso Em not found. Branch will not be filled" << std::endl;
170  }
171 
172  if (nonIsoEm.isValid()){
173  l1Extra->SetNonIsoEm(nonIsoEm, maxL1Extra_);
174  } else {
175  edm::LogWarning("MissingProduct") << "L1Extra Non Iso Em not found. Branch will not be filled" << std::endl;
176  }
177 
178  if (cenJet.isValid()){
179  l1Extra->SetCenJet(cenJet, maxL1Extra_);
180  } else {
181  edm::LogWarning("MissingProduct") << "L1Extra Central Jets not found. Branch will not be filled" << std::endl;
182  }
183 
184  if (tauJet.isValid()){
185  l1Extra->SetTauJet(tauJet, maxL1Extra_);
186  } else {
187  edm::LogWarning("MissingProduct") << "L1Extra Tau Jets not found. Branch will not be filled" << std::endl;
188  }
189 
190  if (isoTauJet.isValid()){
191  l1Extra->SetIsoTauJet(isoTauJet, maxL1Extra_);
192  } else {
193  edm::LogWarning("MissingProduct") << "L1Extra Iso Tau Jets not found. Branch will not be filled" << std::endl;
194  }
195 
196  if (fwdJet.isValid()){
197  l1Extra->SetFwdJet(fwdJet, maxL1Extra_);
198  } else {
199  edm::LogWarning("MissingProduct") << "L1Extra Forward Jets not found. Branch will not be filled" << std::endl;
200  }
201 
202  if (muon.isValid()){
203  l1Extra->SetMuon(muon, maxL1Extra_);
204  } else {
205  edm::LogWarning("MissingProduct") << "L1Extra Muons not found. Branch will not be filled" << std::endl;
206  }
207 
208  if (mets.isValid()){
209  l1Extra->SetMet(mets);
210  } else {
211  edm::LogWarning("MissingProduct") << "L1Extra MET not found. Branch will not be filled" << std::endl;
212  }
213 
214  if (mhts.isValid()){
215  l1Extra->SetMht(mhts);
216  } else {
217  edm::LogWarning("MissingProduct") << "L1Extra MHT not found. Branch will not be filled" << std::endl;
218  }
219 
220  if (hfRings.isValid()){
221  l1Extra->SetHFring(hfRings);
222  } else {
223  edm::LogWarning("MissingProduct") << "L1Extra HF Rings not found. Branch will not be filled" << std::endl;
224  }
225 
226  tree_->Fill();
227 
228 }
229 
230 // ------------ method called once each job just before starting event loop ------------
231 void
233 {
234 }
235 
236 // ------------ method called once each job just after ending the event loop ------------
237 void
239 }
240 
241 //define this as a plug-in
void SetNonIsoEm(const edm::Handle< l1extra::L1EmParticleCollection > nonIsoEm, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > cenJetToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > mhtToken_
void SetIsoEm(const edm::Handle< l1extra::L1EmParticleCollection > isoEm, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > metToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void SetMuon(const edm::Handle< l1extra::L1MuonParticleCollection > muon, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tauJetToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void SetTauJet(const edm::Handle< l1extra::L1JetParticleCollection > tauJet, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1HFRingsCollection > hfRingsToken_
void SetMet(const edm::Handle< l1extra::L1EtMissParticleCollection > mets)
int iEvent
Definition: GenABIO.cc:230
void SetHFring(const edm::Handle< l1extra::L1HFRingsCollection > hfRings)
bool isValid() const
Definition: HandleBase.h:75
L1Analysis::L1AnalysisL1ExtraDataFormat * l1ExtraData
edm::Service< TFileService > fs_
L1ExtraTreeProducer(const edm::ParameterSet &)
edm::EDGetTokenT< l1extra::L1EmParticleCollection > isoEmToken_
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > muonToken_
void SetIsoTauJet(const edm::Handle< l1extra::L1JetParticleCollection > isoTauJet, unsigned maxL1Extra)
virtual void beginJob(void)
edm::EDGetTokenT< l1extra::L1EmParticleCollection > nonIsoEmToken_
edm::EDGetTokenT< l1extra::L1JetParticleCollection > fwdJetToken_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void SetFwdJet(const edm::Handle< l1extra::L1JetParticleCollection > fwdJet, unsigned maxL1Extra)
void SetMht(const edm::Handle< l1extra::L1EtMissParticleCollection > mhts)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > isoTauJetToken_
L1Analysis::L1AnalysisL1Extra * l1Extra
void SetCenJet(const edm::Handle< l1extra::L1JetParticleCollection > cenJet, unsigned maxL1Extra)