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
37 
38 // ROOT output stuff
41 #include "TTree.h"
42 
44 
45 //
46 // class declaration
47 //
48 
50 public:
52  ~L1UpgradeTreeProducer() override;
53 
54 private:
55  void beginJob(void) override;
56  void analyze(const edm::Event&, const edm::EventSetup&) override;
57  void endJob() override;
58 
59 public:
62 
63 private:
64  unsigned maxL1Upgrade_;
65 
66  // output file
68 
69  // tree
70  TTree* tree_;
71 
72  // EDM input tags
74  std::vector<edm::EDGetTokenT<l1t::TauBxCollection>> tauTokens_;
78 };
79 
81  egToken_ = consumes<l1t::EGammaBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("egToken"));
82  //tauToken_ = consumes<l1t::TauBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("tauToken"));
83  jetToken_ = consumes<l1t::JetBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("jetToken"));
84  sumToken_ = consumes<l1t::EtSumBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("sumToken"));
85  muonToken_ = consumes<l1t::MuonBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("muonToken"));
86 
87  const auto& taus = iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("tauTokens");
88  for (const auto& tau : taus) {
89  tauTokens_.push_back(consumes<l1t::TauBxCollection>(tau));
90  }
91 
92  maxL1Upgrade_ = iConfig.getParameter<unsigned int>("maxL1Upgrade");
93 
96 
97  // set up output
98  tree_ = fs_->make<TTree>("L1UpgradeTree", "L1UpgradeTree");
99  tree_->Branch("L1Upgrade", "L1Analysis::L1AnalysisL1UpgradeDataFormat", &l1UpgradeData, 32000, 3);
100 }
101 
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 }
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to for each event ------------
113  l1Upgrade->Reset();
114 
119 
120  iEvent.getByToken(egToken_, eg);
121  iEvent.getByToken(jetToken_, jet);
122  iEvent.getByToken(sumToken_, sums);
123  iEvent.getByToken(muonToken_, muon);
124 
125  if (eg.isValid()) {
127  } else {
128  edm::LogWarning("MissingProduct") << "L1Upgrade Em not found. Branch will not be filled" << std::endl;
129  }
130  if (jet.isValid()) {
132  } else {
133  edm::LogWarning("MissingProduct") << "L1Upgrade Jets not found. Branch will not be filled" << std::endl;
134  }
135 
136  if (sums.isValid()) {
138  } else {
139  edm::LogWarning("MissingProduct") << "L1Upgrade EtSums not found. Branch will not be filled" << std::endl;
140  }
141 
142  if (muon.isValid()) {
144  } else {
145  edm::LogWarning("MissingProduct") << "L1Upgrade Muons not found. Branch will not be filled" << std::endl;
146  }
147 
148  for (auto& tautoken : tauTokens_) {
150  iEvent.getByToken(tautoken, tau);
151  if (tau.isValid()) {
153  } else {
154  edm::LogWarning("MissingProduct") << "L1Upgrade Tau not found. Branch will not be filled" << std::endl;
155  }
156  }
157 
158  tree_->Fill();
159 }
160 
161 // ------------ method called once each job just before starting event loop ------------
163 
164 // ------------ method called once each job just after ending the event loop ------------
166 
167 //define this as a plug-in
MessageLogger.h
L1Analysis::L1AnalysisL1Upgrade::Reset
void Reset()
Definition: L1AnalysisL1Upgrade.h:27
L1Analysis::L1AnalysisL1Upgrade::SetJet
void SetJet(const edm::Handle< l1t::JetBxCollection > jet, unsigned maxL1Upgrade)
Definition: L1AnalysisL1Upgrade.cc:64
L1Analysis::L1AnalysisL1Upgrade::getData
L1AnalysisL1UpgradeDataFormat * getData()
Definition: L1AnalysisL1Upgrade.h:33
metsig::tau
Definition: SignAlgoResolutions.h:49
muon
Definition: MuonCocktails.h:17
L1UpgradeTreeProducer::maxL1Upgrade_
unsigned maxL1Upgrade_
Definition: L1UpgradeTreeProducer.cc:64
edm::EDGetTokenT
Definition: EDGetToken.h:33
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
Muon.h
L1UpgradeTreeProducer::muonToken_
edm::EDGetTokenT< l1t::MuonBxCollection > muonToken_
Definition: L1UpgradeTreeProducer.cc:77
Jet.h
L1UpgradeTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1UpgradeTreeProducer.cc:67
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
L1UpgradeTreeProducer::l1UpgradeData
L1Analysis::L1AnalysisL1UpgradeDataFormat * l1UpgradeData
Definition: L1UpgradeTreeProducer.cc:61
HLT_2018_cff.muon
muon
Definition: HLT_2018_cff.py:10349
edm::Handle
Definition: AssociativeIterator.h:50
L1UpgradeTreeProducer::tree_
TTree * tree_
Definition: L1UpgradeTreeProducer.cc:70
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
L1Analysis::L1AnalysisL1UpgradeDataFormat
Definition: L1AnalysisL1UpgradeDataFormat.h:46
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EGamma.h
Service.h
L1UpgradeTreeProducer::~L1UpgradeTreeProducer
~L1UpgradeTreeProducer() override
Definition: L1UpgradeTreeProducer.cc:102
L1Analysis::L1AnalysisL1Upgrade::SetMuon
void SetMuon(const edm::Handle< l1t::MuonBxCollection > muon, unsigned maxL1Upgrade)
Definition: L1AnalysisL1Upgrade.cc:92
edm::LogWarning
Definition: MessageLogger.h:141
TFileService.h
L1UpgradeTreeProducer::beginJob
void beginJob(void) override
Definition: L1UpgradeTreeProducer.cc:162
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
L1UpgradeTreeProducer::l1Upgrade
L1Analysis::L1AnalysisL1Upgrade * l1Upgrade
Definition: L1UpgradeTreeProducer.cc:60
L1UpgradeTreeProducer::egToken_
edm::EDGetTokenT< l1t::EGammaBxCollection > egToken_
Definition: L1UpgradeTreeProducer.cc:73
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
L1Analysis::L1AnalysisL1Upgrade::SetSum
void SetSum(const edm::Handle< l1t::EtSumBxCollection > sums, unsigned maxL1Upgrade)
Definition: L1AnalysisL1Upgrade.cc:121
edm::EventSetup
Definition: EventSetup.h:57
L1UpgradeTreeProducer::L1UpgradeTreeProducer
L1UpgradeTreeProducer(const edm::ParameterSet &)
Definition: L1UpgradeTreeProducer.cc:80
L1UpgradeTreeProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1UpgradeTreeProducer.cc:112
L1Analysis::L1AnalysisL1Upgrade
Definition: L1AnalysisL1Upgrade.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
L1UpgradeTreeProducer::tauTokens_
std::vector< edm::EDGetTokenT< l1t::TauBxCollection > > tauTokens_
Definition: L1UpgradeTreeProducer.cc:74
L1Analysis::L1AnalysisL1Upgrade::SetEm
void SetEm(const edm::Handle< l1t::EGammaBxCollection > em, unsigned maxL1Upgrade)
Definition: L1AnalysisL1Upgrade.cc:7
L1UpgradeTreeProducer::endJob
void endJob() override
Definition: L1UpgradeTreeProducer.cc:165
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
L1AnalysisL1Upgrade.h
L1UpgradeTreeProducer::jetToken_
edm::EDGetTokenT< l1t::JetBxCollection > jetToken_
Definition: L1UpgradeTreeProducer.cc:75
ParameterSet.h
EtSum.h
L1UpgradeTreeProducer
Definition: L1UpgradeTreeProducer.cc:49
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
L1Analysis::L1AnalysisL1Upgrade::SetTau
void SetTau(const edm::Handle< l1t::TauBxCollection > tau, unsigned maxL1Upgrade)
Definition: L1AnalysisL1Upgrade.cc:36
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
L1UpgradeTreeProducer::sumToken_
edm::EDGetTokenT< l1t::EtSumBxCollection > sumToken_
Definition: L1UpgradeTreeProducer.cc:76
Tau.h