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 
55 class L1ExtraTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
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  usesResource(TFileService::kSharedResource);
119  // set up output
120  tree_ = fs_->make<TTree>("L1ExtraTree", "L1ExtraTree");
121  tree_->Branch("L1Extra", "L1Analysis::L1AnalysisL1ExtraDataFormat", &l1ExtraData, 32000, 3);
122 }
123 
125  // do anything here that needs to be done at desctruction time
126  // (e.g. close files, deallocate resources etc.)
127 }
128 
129 //
130 // member functions
131 //
132 
133 // ------------ method called to for each event ------------
135  l1Extra->Reset();
136 
144  ;
148 
149  iEvent.getByToken(nonIsoEmToken_, nonIsoEm);
150  iEvent.getByToken(isoEmToken_, isoEm);
151  iEvent.getByToken(tauJetToken_, tauJet);
152  iEvent.getByToken(isoTauJetToken_, isoTauJet);
153  iEvent.getByToken(cenJetToken_, cenJet);
154  iEvent.getByToken(fwdJetToken_, fwdJet);
155  iEvent.getByToken(muonToken_, muon);
156  iEvent.getByToken(metToken_, mets);
157  iEvent.getByToken(mhtToken_, mhts);
158  iEvent.getByToken(hfRingsToken_, hfRings);
159 
160  if (isoEm.isValid()) {
161  l1Extra->SetIsoEm(isoEm, maxL1Extra_);
162  } else {
163  edm::LogWarning("MissingProduct") << "L1Extra Iso Em not found. Branch will not be filled" << std::endl;
164  }
165 
166  if (nonIsoEm.isValid()) {
167  l1Extra->SetNonIsoEm(nonIsoEm, maxL1Extra_);
168  } else {
169  edm::LogWarning("MissingProduct") << "L1Extra Non Iso Em not found. Branch will not be filled" << std::endl;
170  }
171 
172  if (cenJet.isValid()) {
173  l1Extra->SetCenJet(cenJet, maxL1Extra_);
174  } else {
175  edm::LogWarning("MissingProduct") << "L1Extra Central Jets not found. Branch will not be filled" << std::endl;
176  }
177 
178  if (tauJet.isValid()) {
179  l1Extra->SetTauJet(tauJet, maxL1Extra_);
180  } else {
181  edm::LogWarning("MissingProduct") << "L1Extra Tau Jets not found. Branch will not be filled" << std::endl;
182  }
183 
184  if (isoTauJet.isValid()) {
185  l1Extra->SetIsoTauJet(isoTauJet, maxL1Extra_);
186  } else {
187  edm::LogWarning("MissingProduct") << "L1Extra Iso Tau Jets not found. Branch will not be filled" << std::endl;
188  }
189 
190  if (fwdJet.isValid()) {
191  l1Extra->SetFwdJet(fwdJet, maxL1Extra_);
192  } else {
193  edm::LogWarning("MissingProduct") << "L1Extra Forward Jets not found. Branch will not be filled" << std::endl;
194  }
195 
196  if (muon.isValid()) {
198  } else {
199  edm::LogWarning("MissingProduct") << "L1Extra Muons not found. Branch will not be filled" << std::endl;
200  }
201 
202  if (mets.isValid()) {
203  l1Extra->SetMet(mets);
204  } else {
205  edm::LogWarning("MissingProduct") << "L1Extra MET not found. Branch will not be filled" << std::endl;
206  }
207 
208  if (mhts.isValid()) {
209  l1Extra->SetMht(mhts);
210  } else {
211  edm::LogWarning("MissingProduct") << "L1Extra MHT not found. Branch will not be filled" << std::endl;
212  }
213 
214  if (hfRings.isValid()) {
215  l1Extra->SetHFring(hfRings);
216  } else {
217  edm::LogWarning("MissingProduct") << "L1Extra HF Rings not found. Branch will not be filled" << std::endl;
218  }
219 
220  tree_->Fill();
221 }
222 
223 // ------------ method called once each job just before starting event loop ------------
225 
226 // ------------ method called once each job just after ending the event loop ------------
228 
229 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
void SetNonIsoEm(const edm::Handle< l1extra::L1EmParticleCollection > nonIsoEm, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > cenJetToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > mhtToken_
void SetIsoEm(const edm::Handle< l1extra::L1EmParticleCollection > isoEm, unsigned maxL1Extra)
edm::EDGetTokenT< l1extra::L1EtMissParticleCollection > metToken_
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()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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)