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 
21 // system include files
22 #include <memory>
23 
24 // framework
31 
32 // data formats
38 
39 // ROOT output stuff
42 #include "TTree.h"
43 
45 
46 //
47 // class declaration
48 //
49 
51 public:
53  ~L1UpgradeTreeProducer() override;
54 
55 
56 private:
57  void beginJob(void) override ;
58  void analyze(const edm::Event&, const edm::EventSetup&) override;
59  void endJob() override;
60 
61 public:
62 
65 
66 private:
67 
68  unsigned maxL1Upgrade_;
69 
70  // output file
72 
73  // tree
74  TTree * tree_;
75 
76  // EDM input tags
78  std::vector< edm::EDGetTokenT<l1t::TauBxCollection> > tauTokens_;
82 
83 };
84 
85 
86 
88 {
89 
90  egToken_ = consumes<l1t::EGammaBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("egToken"));
91  //tauToken_ = consumes<l1t::TauBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("tauToken"));
92  jetToken_ = consumes<l1t::JetBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("jetToken"));
93  sumToken_ = consumes<l1t::EtSumBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("sumToken"));
94  muonToken_ = consumes<l1t::MuonBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonToken"));
95 
96  const auto& taus = iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("tauTokens");
97  for (const auto& tau: taus) {
98  tauTokens_.push_back(consumes<l1t::TauBxCollection>(tau));
99  }
100 
101 
102  maxL1Upgrade_ = iConfig.getParameter<unsigned int>("maxL1Upgrade");
103 
105  l1UpgradeData = l1Upgrade->getData();
106 
107  // set up output
108  tree_=fs_->make<TTree>("L1UpgradeTree", "L1UpgradeTree");
109  tree_->Branch("L1Upgrade", "L1Analysis::L1AnalysisL1UpgradeDataFormat", &l1UpgradeData, 32000, 3);
110 
111 }
112 
113 
115 {
116 
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 
120 }
121 
122 
123 //
124 // member functions
125 //
126 
127 // ------------ method called to for each event ------------
128 void
130 {
131 
132  l1Upgrade->Reset();
133 
138 
139  iEvent.getByToken(egToken_, eg);
140  iEvent.getByToken(jetToken_, jet);
141  iEvent.getByToken(sumToken_, sums);
142  iEvent.getByToken(muonToken_, muon);
143 
144  if (eg.isValid()){
146  } else {
147  edm::LogWarning("MissingProduct") << "L1Upgrade Em not found. Branch will not be filled" << std::endl;
148  }
149  if (jet.isValid()){
151  } else {
152  edm::LogWarning("MissingProduct") << "L1Upgrade Jets not found. Branch will not be filled" << std::endl;
153  }
154 
155  if (sums.isValid()){
156  l1Upgrade->SetSum(sums, maxL1Upgrade_);
157  } else {
158  edm::LogWarning("MissingProduct") << "L1Upgrade EtSums not found. Branch will not be filled" << std::endl;
159  }
160 
161  if (muon.isValid()){
163  } else {
164  edm::LogWarning("MissingProduct") << "L1Upgrade Muons 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 
181 // ------------ method called once each job just before starting event loop ------------
182 void
184 {
185 }
186 
187 // ------------ method called once each job just after ending the event loop ------------
188 void
190 }
191 
192 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void SetMuon(const edm::Handle< l1t::MuonBxCollection > muon, unsigned maxL1Upgrade)
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Service< TFileService > fs_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void SetJet(const edm::Handle< l1t::JetBxCollection > jet, unsigned maxL1Upgrade)
void SetEm(const edm::Handle< l1t::EGammaBxCollection > em, unsigned maxL1Upgrade)
std::vector< edm::EDGetTokenT< l1t::TauBxCollection > > tauTokens_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void beginJob(void) override
L1UpgradeTreeProducer(const edm::ParameterSet &)
L1Analysis::L1AnalysisL1Upgrade * l1Upgrade
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1Analysis::L1AnalysisL1UpgradeDataFormat * l1UpgradeData
edm::EDGetTokenT< l1t::EGammaBxCollection > egToken_
edm::EDGetTokenT< l1t::EtSumBxCollection > sumToken_
bool isValid() const
Definition: HandleBase.h:74
void SetTau(const edm::Handle< l1t::TauBxCollection > tau, unsigned maxL1Upgrade)
edm::EDGetTokenT< l1t::MuonBxCollection > muonToken_
edm::EDGetTokenT< l1t::JetBxCollection > jetToken_
void SetSum(const edm::Handle< l1t::EtSumBxCollection > sums, unsigned maxL1Upgrade)