CMS 3D CMS Logo

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 // system include files
21 #include <memory>
22 
23 // framework
30 
31 // data formats
43 
44 // ROOT output stuff
47 #include "TTree.h"
48 
50 
51 //
52 // class declaration
53 //
54 
56 public:
57  explicit L1ExtraTreeProducer(const edm::ParameterSet&);
58  ~L1ExtraTreeProducer() override;
59 
60 private:
61  void beginJob(void) override;
62  void analyze(const edm::Event&, const edm::EventSetup&) override;
63  void endJob() override;
64 
65 public:
68 
69 private:
70  unsigned maxL1Extra_;
71 
72  // output file
74 
75  // tree
76  TTree* tree_;
77 
78  // EDM input tags
89 };
90 
92  nonIsoEmToken_ = consumes<l1extra::L1EmParticleCollection>(
93  iConfig.getUntrackedParameter("nonIsoEmToken", edm::InputTag("l1extraParticles:NonIsolated")));
94  isoEmToken_ = consumes<l1extra::L1EmParticleCollection>(
95  iConfig.getUntrackedParameter("isoEmToken", edm::InputTag("l1extraParticles:Isolated")));
96  tauJetToken_ = consumes<l1extra::L1JetParticleCollection>(
97  iConfig.getUntrackedParameter("tauJetToken", edm::InputTag("l1extraParticles:Tau")));
98  isoTauJetToken_ = consumes<l1extra::L1JetParticleCollection>(
99  iConfig.getUntrackedParameter("isoTauJetToken", edm::InputTag("l1extraParticles:IsoTau")));
100  cenJetToken_ = consumes<l1extra::L1JetParticleCollection>(
101  iConfig.getUntrackedParameter("cenJetToken", edm::InputTag("l1extraParticles:Central")));
102  fwdJetToken_ = consumes<l1extra::L1JetParticleCollection>(
103  iConfig.getUntrackedParameter("fwdJetToken", edm::InputTag("l1extraParticles:Forward")));
104  muonToken_ = consumes<l1extra::L1MuonParticleCollection>(
105  iConfig.getUntrackedParameter("muonToken", edm::InputTag("l1extraParticles")));
106  metToken_ = consumes<l1extra::L1EtMissParticleCollection>(
107  iConfig.getUntrackedParameter("metToken", edm::InputTag("l1extraParticles:MET")));
108  mhtToken_ = consumes<l1extra::L1EtMissParticleCollection>(
109  iConfig.getUntrackedParameter("mhtToken", edm::InputTag("l1extraParticles:MHT")));
110  hfRingsToken_ = consumes<l1extra::L1HFRingsCollection>(
111  iConfig.getUntrackedParameter("hfRingsToken", edm::InputTag("l1extraParticles")));
112 
113  maxL1Extra_ = iConfig.getParameter<unsigned int>("maxL1Extra");
114 
117 
118  // set up output
119  tree_ = fs_->make<TTree>("L1ExtraTree", "L1ExtraTree");
120  tree_->Branch("L1Extra", "L1Analysis::L1AnalysisL1ExtraDataFormat", &l1ExtraData, 32000, 3);
121 }
122 
124  // do anything here that needs to be done at desctruction time
125  // (e.g. close files, deallocate resources etc.)
126 }
127 
128 //
129 // member functions
130 //
131 
132 // ------------ method called to for each event ------------
134  l1Extra->Reset();
135 
143  ;
147 
148  iEvent.getByToken(nonIsoEmToken_, nonIsoEm);
149  iEvent.getByToken(isoEmToken_, isoEm);
150  iEvent.getByToken(tauJetToken_, tauJet);
151  iEvent.getByToken(isoTauJetToken_, isoTauJet);
152  iEvent.getByToken(cenJetToken_, cenJet);
153  iEvent.getByToken(fwdJetToken_, fwdJet);
154  iEvent.getByToken(muonToken_, muon);
155  iEvent.getByToken(metToken_, mets);
156  iEvent.getByToken(mhtToken_, mhts);
157  iEvent.getByToken(hfRingsToken_, hfRings);
158 
159  if (isoEm.isValid()) {
160  l1Extra->SetIsoEm(isoEm, maxL1Extra_);
161  } else {
162  edm::LogWarning("MissingProduct") << "L1Extra Iso Em not found. Branch will not be filled" << std::endl;
163  }
164 
165  if (nonIsoEm.isValid()) {
166  l1Extra->SetNonIsoEm(nonIsoEm, maxL1Extra_);
167  } else {
168  edm::LogWarning("MissingProduct") << "L1Extra Non Iso Em not found. Branch will not be filled" << std::endl;
169  }
170 
171  if (cenJet.isValid()) {
172  l1Extra->SetCenJet(cenJet, maxL1Extra_);
173  } else {
174  edm::LogWarning("MissingProduct") << "L1Extra Central Jets not found. Branch will not be filled" << std::endl;
175  }
176 
177  if (tauJet.isValid()) {
178  l1Extra->SetTauJet(tauJet, maxL1Extra_);
179  } else {
180  edm::LogWarning("MissingProduct") << "L1Extra Tau Jets not found. Branch will not be filled" << std::endl;
181  }
182 
183  if (isoTauJet.isValid()) {
184  l1Extra->SetIsoTauJet(isoTauJet, maxL1Extra_);
185  } else {
186  edm::LogWarning("MissingProduct") << "L1Extra Iso Tau Jets not found. Branch will not be filled" << std::endl;
187  }
188 
189  if (fwdJet.isValid()) {
190  l1Extra->SetFwdJet(fwdJet, maxL1Extra_);
191  } else {
192  edm::LogWarning("MissingProduct") << "L1Extra Forward Jets not found. Branch will not be filled" << std::endl;
193  }
194 
195  if (muon.isValid()) {
197  } else {
198  edm::LogWarning("MissingProduct") << "L1Extra Muons not found. Branch will not be filled" << std::endl;
199  }
200 
201  if (mets.isValid()) {
202  l1Extra->SetMet(mets);
203  } else {
204  edm::LogWarning("MissingProduct") << "L1Extra MET not found. Branch will not be filled" << std::endl;
205  }
206 
207  if (mhts.isValid()) {
208  l1Extra->SetMht(mhts);
209  } else {
210  edm::LogWarning("MissingProduct") << "L1Extra MHT not found. Branch will not be filled" << std::endl;
211  }
212 
213  if (hfRings.isValid()) {
214  l1Extra->SetHFring(hfRings);
215  } else {
216  edm::LogWarning("MissingProduct") << "L1Extra HF Rings not found. Branch will not be filled" << std::endl;
217  }
218 
219  tree_->Fill();
220 }
221 
222 // ------------ method called once each job just before starting event loop ------------
224 
225 // ------------ method called once each job just after ending the event loop ------------
227 
228 //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
Definition: ParameterSet.h:303
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > mhtToken_
void SetIsoEm(const edm::Handle< l1extra::L1EmParticleCollection > isoEm, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > metToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void beginJob(void) override
void SetMuon(const edm::Handle< l1extra::L1MuonParticleCollection > muon, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tauJetToken_
void SetTauJet(const edm::Handle< l1extra::L1JetParticleCollection > tauJet, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1HFRingsCollection > hfRingsToken_
void SetMet(const edm::Handle< l1extra::L1EtMissParticleCollection > mets)
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
L1AnalysisL1ExtraDataFormat * getData()
void SetHFring(const edm::Handle< l1extra::L1HFRingsCollection > hfRings)
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)
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< l1extra::L1EmParticleCollection > nonIsoEmToken_
edm::EDGetTokenT< l1extra::L1JetParticleCollection > fwdJetToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void SetFwdJet(const edm::Handle< l1extra::L1JetParticleCollection > fwdJet, unsigned maxL1Extra)
Log< level::Warning, false > LogWarning
void SetMht(const edm::Handle< l1extra::L1EtMissParticleCollection > mhts)
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< l1extra::L1JetParticleCollection > isoTauJetToken_
L1Analysis::L1AnalysisL1Extra * l1Extra
void SetCenJet(const edm::Handle< l1extra::L1JetParticleCollection > cenJet, unsigned maxL1Extra)