CMS 3D CMS Logo

L1UpgradeTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TriggerDPG/L1Ntuples
4 // Class: L1UpgradeTreeProducer
5 //
13 //
14 // Original Author:
15 // Created:
16 // $Id: L1UpgradeTreeProducer.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
38 
39 // ROOT output stuff
42 #include "TTree.h"
43 
45 
46 //
47 // class declaration
48 //
49 
50 class L1UpgradeTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
51 public:
53  ~L1UpgradeTreeProducer() override = default;
54 
55 private:
56  void beginJob(void) override;
57  void analyze(const edm::Event&, const edm::EventSetup&) override;
58  void endJob() override;
59 
60 public:
63 
64 private:
65  unsigned maxL1Upgrade_;
66 
67  // output file
69 
70  // tree
71  TTree* tree_;
72 
73  // EDM input tags
79  std::vector<edm::EDGetTokenT<l1t::TauBxCollection>> tauTokens_;
80 };
81 
83  : egToken_(consumes<l1t::EGammaBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("egToken"))),
84  jetToken_(consumes<l1t::JetBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("jetToken"))),
85  sumToken_(consumes<l1t::EtSumBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("sumToken"))),
86  muonToken_(consumes<l1t::MuonBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonToken"))),
87  muonShowerToken_(
88  consumes<l1t::MuonShowerBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonShowerToken"))) {
89  const auto& taus = iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("tauTokens");
90  for (const auto& tau : taus) {
91  tauTokens_.push_back(consumes<l1t::TauBxCollection>(tau));
92  }
93 
94  maxL1Upgrade_ = iConfig.getParameter<unsigned int>("maxL1Upgrade");
95 
98 
99  usesResource(TFileService::kSharedResource);
100 
101  // set up output
102  tree_ = fs_->make<TTree>("L1UpgradeTree", "L1UpgradeTree");
103  tree_->Branch("L1Upgrade", "L1Analysis::L1AnalysisL1UpgradeDataFormat", &l1UpgradeData, 32000, 3);
104 }
105 
106 //
107 // member functions
108 //
109 
110 // ------------ method called to for each event ------------
112  l1Upgrade->Reset();
113 
119 
120  iEvent.getByToken(egToken_, eg);
121  iEvent.getByToken(jetToken_, jet);
122  iEvent.getByToken(sumToken_, sums);
123  iEvent.getByToken(muonToken_, muon);
124  iEvent.getByToken(muonShowerToken_, muonShower);
125 
126  if (eg.isValid()) {
128  } else {
129  edm::LogWarning("MissingProduct") << "L1Upgrade Em not found. Branch will not be filled" << std::endl;
130  }
131  if (jet.isValid()) {
133  } else {
134  edm::LogWarning("MissingProduct") << "L1Upgrade Jets not found. Branch will not be filled" << std::endl;
135  }
136 
137  if (sums.isValid()) {
139  } else {
140  edm::LogWarning("MissingProduct") << "L1Upgrade EtSums not found. Branch will not be filled" << std::endl;
141  }
142 
143  if (muon.isValid()) {
145  } else {
146  edm::LogWarning("MissingProduct") << "L1Upgrade Muons not found. Branch will not be filled" << std::endl;
147  }
148 
149  if (muonShower.isValid()) {
150  l1Upgrade->SetMuonShower(muonShower, maxL1Upgrade_);
151  } else {
152  edm::LogWarning("MissingProduct") << "L1Upgrade Muon Showers not found. Branch will not be filled" << std::endl;
153  }
154 
155  for (auto& tautoken : tauTokens_) {
157  iEvent.getByToken(tautoken, tau);
158  if (tau.isValid()) {
160  } else {
161  edm::LogWarning("MissingProduct") << "L1Upgrade Tau not found. Branch will not be filled" << std::endl;
162  }
163  }
164 
165  tree_->Fill();
166 }
167 
168 // ------------ method called once each job just before starting event loop ------------
170 
171 // ------------ method called once each job just after ending the event loop ------------
173 
174 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
BXVector< EGamma > EGammaBxCollection
Definition: EGamma.h:10
std::vector< edm::EDGetTokenT< l1t::TauBxCollection > > tauTokens_
void SetMuon(const edm::Handle< l1t::MuonBxCollection > muon, unsigned maxL1Upgrade)
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Service< TFileService > fs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< l1t::EtSumBxCollection > sumToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< l1t::MuonShowerBxCollection > muonShowerToken_
void SetJet(const edm::Handle< l1t::JetBxCollection > jet, unsigned maxL1Upgrade)
void SetEm(const edm::Handle< l1t::EGammaBxCollection > em, unsigned maxL1Upgrade)
delete x;
Definition: CaloConfig.h:22
const edm::EDGetTokenT< l1t::JetBxCollection > jetToken_
void beginJob(void) override
L1UpgradeTreeProducer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
BXVector< EtSum > EtSumBxCollection
Definition: EtSum.h:10
L1Analysis::L1AnalysisL1Upgrade * l1Upgrade
int iEvent
Definition: GenABIO.cc:224
L1AnalysisL1UpgradeDataFormat * getData()
L1Analysis::L1AnalysisL1UpgradeDataFormat * l1UpgradeData
BXVector< MuonShower > MuonShowerBxCollection
Definition: MuonShower.h:18
void SetTau(const edm::Handle< l1t::TauBxCollection > tau, unsigned maxL1Upgrade)
BXVector< Muon > MuonBxCollection
Definition: Muon.h:11
~L1UpgradeTreeProducer() override=default
BXVector< Jet > JetBxCollection
Definition: Jet.h:10
void SetMuonShower(const edm::Handle< l1t::MuonShowerBxCollection > muonShower, unsigned maxL1Upgrade)
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< l1t::EGammaBxCollection > egToken_
const edm::EDGetTokenT< l1t::MuonBxCollection > muonToken_
HLT enums.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Log< level::Warning, false > LogWarning
void SetSum(const edm::Handle< l1t::EtSumBxCollection > sums, unsigned maxL1Upgrade)