CMS 3D CMS Logo

L1TBasicDemo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // L1TBasicDemo: demonstrate basic access of L1T objects
4 //
5 
18 
19 // leaving out the following namespaces, so namespaces are explicit in the demo code:
20 // using namespace l1t;
21 // using namespace edm;
22 
24 public:
25  explicit L1TBasicDemo(const edm::ParameterSet&);
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28 
29 private:
30  void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
31 
32  // EDM tokens:
38 
40 };
41 
43  egToken_ = consumes<l1t::EGammaBxCollection>(iConfig.getParameter<edm::InputTag>("EgTag"));
44  tauToken_ = consumes<l1t::TauBxCollection>(iConfig.getParameter<edm::InputTag>("TauTag"));
45  jetToken_ = consumes<l1t::JetBxCollection>(iConfig.getParameter<edm::InputTag>("JetTag"));
46  sumToken_ = consumes<l1t::EtSumBxCollection>(iConfig.getParameter<edm::InputTag>("SumTag"));
47  muonToken_ = consumes<l1t::MuonBxCollection>(iConfig.getParameter<edm::InputTag>("MuonTag"));
48  trigger_bx_only = iConfig.getParameter<bool>("UseTriggerBxOnly");
49 }
50 
52  cout << "INFO: dumping EGamma BX collection:\n";
54  iEvent.getByToken(egToken_, eg);
55  if (eg.isValid()) {
56  for (int ibx = eg->getFirstBX(); ibx <= eg->getLastBX(); ++ibx) {
57  if (trigger_bx_only && (ibx != 0))
58  continue;
59  for (auto it = eg->begin(ibx); it != eg->end(ibx); it++) {
60  if (it->et() == 0)
61  continue; // if you don't care about L1T candidates with zero ET.
62  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
63  }
64  }
65  } else {
66  edm::LogWarning("MissingProduct") << "L1Upgrade e-gamma bx collection not found." << std::endl;
67  }
68 
69  cout << "INFO: dumping Tau BX collection:\n";
71  iEvent.getByToken(tauToken_, tau);
72  if (tau.isValid()) {
73  for (int ibx = tau->getFirstBX(); ibx <= tau->getLastBX(); ++ibx) {
74  if (trigger_bx_only && (ibx != 0))
75  continue;
76  for (auto it = tau->begin(ibx); it != tau->end(ibx); it++) {
77  if (it->et() == 0)
78  continue; // if you don't care about L1T candidates with zero ET.
79  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
80  }
81  }
82  } else {
83  edm::LogWarning("MissingProduct") << "L1Upgrade tau bx collection not found." << std::endl;
84  }
85 
86  cout << "INFO: dumping Jet BX collection:\n";
88  iEvent.getByToken(jetToken_, jet);
89  if (jet.isValid()) {
90  for (int ibx = jet->getFirstBX(); ibx <= jet->getLastBX(); ++ibx) {
91  if (trigger_bx_only && (ibx != 0))
92  continue;
93  for (auto it = jet->begin(ibx); it != jet->end(ibx); it++) {
94  if (it->et() == 0)
95  continue; // if you don't care about L1T candidates with zero ET.
96  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
97  }
98  }
99  } else {
100  edm::LogWarning("MissingProduct") << "L1Upgrade jet bx collection not found." << std::endl;
101  }
102 
103  cout << "INFO: dumping EtSum BX collection:\n";
105  iEvent.getByToken(sumToken_, sum);
106  if (sum.isValid()) {
107  l1t::EtSumHelper hsum(sum);
108  cout << "met: " << hsum.MissingEt() << "\n";
109  cout << "met phi: " << hsum.MissingEtPhi() << "\n";
110  cout << "mht: " << hsum.MissingHt() << "\n";
111  cout << "mht phi: " << hsum.MissingHtPhi() << "\n";
112  cout << "sum et: " << hsum.TotalEt() << "\n";
113  cout << "sum ht: " << hsum.TotalHt() << "\n";
114  } else {
115  edm::LogWarning("MissingProduct") << "L1Upgrade sum bx collection not found." << std::endl;
116  }
117 
118  cout << "INFO: dumping Muon BX collection:\n";
120  iEvent.getByToken(muonToken_, muon);
121  if (muon.isValid()) {
122  for (int ibx = muon->getFirstBX(); ibx <= muon->getLastBX(); ++ibx) {
123  if (trigger_bx_only && (ibx != 0))
124  continue;
125  for (auto it = muon->begin(ibx); it != muon->end(ibx); it++) {
126  if (it->et() == 0)
127  continue; // if you don't care about L1T candidates with zero ET.
128  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
129  }
130  }
131  } else {
132  edm::LogWarning("MissingProduct") << "L1Upgrade muon bx collection not found." << std::endl;
133  }
134 }
135 
137  //The following says we do not know what parameters are allowed so do no validation
138  // Please change this to state exactly what you do use, even if it is no parameters
140  desc.setUnknown();
141  descriptions.addDefault(desc);
142 }
143 
int getLastBX() const
double TotalEt() const
Definition: EtSumHelper.cc:38
double MissingEt() const
Definition: EtSumHelper.cc:6
int getFirstBX() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< l1t::EtSumBxCollection > sumToken_
Definition: L1TBasicDemo.cc:36
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const_iterator begin(int bx) const
double MissingEtPhi() const
Definition: EtSumHelper.cc:14
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
double MissingHt() const
Definition: EtSumHelper.cc:22
L1TBasicDemo(const edm::ParameterSet &)
Definition: L1TBasicDemo.cc:42
double TotalHt() const
Definition: EtSumHelper.cc:46
edm::EDGetTokenT< l1t::TauBxCollection > tauToken_
Definition: L1TBasicDemo.cc:34
edm::EDGetTokenT< l1t::MuonBxCollection > muonToken_
Definition: L1TBasicDemo.cc:37
edm::EDGetTokenT< l1t::JetBxCollection > jetToken_
Definition: L1TBasicDemo.cc:35
edm::EDGetTokenT< l1t::EGammaBxCollection > egToken_
Definition: L1TBasicDemo.cc:33
bool isValid() const
Definition: HandleBase.h:70
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
Definition: L1TBasicDemo.cc:51
const_iterator end(int bx) const
double MissingHtPhi() const
Definition: EtSumHelper.cc:30
Log< level::Warning, false > LogWarning