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 
81 
82  std::vector<edm::EDGetTokenT<l1t::TauBxCollection>> tauTokens_;
83 };
84 
86  : egToken_(consumes<l1t::EGammaBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("egToken"))),
87  jetToken_(consumes<l1t::JetBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("jetToken"))),
88  sumToken_(consumes<l1t::EtSumBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("sumToken"))),
89  muonToken_(consumes<l1t::MuonBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonToken"))),
90  muonShowerToken_(
91  consumes<l1t::MuonShowerBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonShowerToken"))),
92  sumZDCToken_(consumes<l1t::EtSumBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("sumZDCToken"))) {
93  const auto& taus = iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("tauTokens");
94  for (const auto& tau : taus) {
95  tauTokens_.push_back(consumes<l1t::TauBxCollection>(tau));
96  }
97 
98  maxL1Upgrade_ = iConfig.getParameter<unsigned int>("maxL1Upgrade");
99 
102 
103  usesResource(TFileService::kSharedResource);
104 
105  // set up output
106  tree_ = fs_->make<TTree>("L1UpgradeTree", "L1UpgradeTree");
107  tree_->Branch("L1Upgrade", "L1Analysis::L1AnalysisL1UpgradeDataFormat", &l1UpgradeData, 32000, 3);
108 }
109 
110 //
111 // member functions
112 //
113 
114 // ------------ method called to for each event ------------
116  l1Upgrade->Reset();
117 
124 
125  iEvent.getByToken(egToken_, eg);
126  iEvent.getByToken(jetToken_, jet);
127  iEvent.getByToken(sumToken_, sums);
128  iEvent.getByToken(muonToken_, muon);
129  iEvent.getByToken(muonShowerToken_, muonShower);
130  iEvent.getByToken(sumZDCToken_, sumsZDC);
131 
132  if (eg.isValid()) {
134  } else {
135  edm::LogWarning("MissingProduct") << "L1Upgrade Em not found. Branch will not be filled" << std::endl;
136  }
137  if (jet.isValid()) {
139  } else {
140  edm::LogWarning("MissingProduct") << "L1Upgrade Jets not found. Branch will not be filled" << std::endl;
141  }
142 
143  if (sums.isValid()) {
145  } else {
146  edm::LogWarning("MissingProduct") << "L1Upgrade EtSums not found. Branch will not be filled" << std::endl;
147  }
148 
149  if (muon.isValid()) {
151  } else {
152  edm::LogWarning("MissingProduct") << "L1Upgrade Muons not found. Branch will not be filled" << std::endl;
153  }
154 
155  if (muonShower.isValid()) {
156  l1Upgrade->SetMuonShower(muonShower, maxL1Upgrade_);
157  } else {
158  edm::LogWarning("MissingProduct") << "L1Upgrade Muon Showers not found. Branch will not be filled" << std::endl;
159  }
160 
161  if (sumsZDC.isValid()) {
162  l1Upgrade->SetSumZDC(sumsZDC, maxL1Upgrade_);
163  } else {
164  edm::LogWarning("MissingProduct") << "L1Upgrade EtZDCSums not found. Branch will not be filled" << std::endl;
165  }
166 
167  for (auto& tautoken : tauTokens_) {
169  iEvent.getByToken(tautoken, tau);
170  if (tau.isValid()) {
172  } else {
173  edm::LogWarning("MissingProduct") << "L1Upgrade Tau not found. Branch will not be filled" << std::endl;
174  }
175  }
176 
177  tree_->Fill();
178 }
179 
180 // ------------ method called once each job just before starting event loop ------------
182 
183 // ------------ method called once each job just after ending the event loop ------------
185 
186 //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:307
const edm::EDGetTokenT< l1t::EtSumBxCollection > sumToken_
void SetSumZDC(const edm::Handle< l1t::EtSumBxCollection > sumsZDC, unsigned maxL1Upgrade)
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
const edm::EDGetTokenT< l1t::EtSumBxCollection > sumZDCToken_
BXVector< EtSum > EtSumBxCollection
Definition: EtSum.h:10
L1Analysis::L1AnalysisL1Upgrade * l1Upgrade
int iEvent
Definition: GenABIO.cc:224
L1AnalysisL1UpgradeDataFormat * getData()
L1Analysis::L1AnalysisL1UpgradeDataFormat * l1UpgradeData
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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)