CMS 3D CMS Logo

L1TSummary.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // L1TSummary: produce command line visible summary of L1T system
4 //
5 
6 #include <iostream>
18 
19 using namespace std;
20 using namespace edm;
21 using namespace l1t;
22 
23 class L1TSummary : public one::EDAnalyzer<> {
24 public:
25  explicit L1TSummary(const ParameterSet&);
26 
27  static void fillDescriptions(ConfigurationDescriptions& descriptions);
28 
29 private:
30  void beginJob() override;
31  void analyze(Event const&, EventSetup const&) override;
32  void endJob() override;
33 
34  // Tag string to mark summary with:
35  string tag_;
36 
37  // Checks to perform:
38  bool egCheck_;
39  bool tauCheck_;
40  bool jetCheck_;
41  bool sumCheck_;
42  bool muonCheck_;
44 
45  // EDM tokens:
47  std::vector<edm::EDGetTokenT<TauBxCollection>> tauTokens_;
51 
52  // keep a tally for summary:
53  int egCount_;
54  int tauCount_;
55  int jetCount_;
56  int sumCount_;
58 };
59 
61  // InputTag barrelTfInputTag = iConfig.getParameter<InputTag>("barrelTFInput");
62  // InputTag overlapTfInputTag = iConfig.getParameter<InputTag>("overlapTFInput");
63  // InputTag forwardTfInputTag = iConfig.getParameter<InputTag>("forwardTFInput");
64  //m_barrelTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(iConfig.getParameter<InputTag>("bmtfDigis"));
65 
66  tag_ = iConfig.getParameter<string>("tag");
67 
68  egCheck_ = iConfig.getParameter<bool>("egCheck");
69  tauCheck_ = iConfig.getParameter<bool>("tauCheck");
70  jetCheck_ = iConfig.getParameter<bool>("jetCheck");
71  sumCheck_ = iConfig.getParameter<bool>("sumCheck");
72  muonCheck_ = iConfig.getParameter<bool>("muonCheck");
73  bxZeroOnly_ = iConfig.getParameter<bool>("bxZeroOnly");
74 
75  //cout << "L1T Summary for " << tag << "\n";
76  //cout << "DEBUG: egCheck: " << egCheck_ << "\n";
77  //cout << "DEBUG: tauCheck: " << tauCheck_ << "\n";
78  //cout << "DEBUG: jetCheck: " << jetCheck_ << "\n";
79  //cout << "DEBUG: sumCheck: " << sumCheck_ << "\n";
80  //cout << "DEBUG: muonCheck: " << muonCheck_ << "\n";
81 
82  if (egCheck_) {
83  egToken_ = consumes<EGammaBxCollection>(iConfig.getParameter<InputTag>("egToken"));
84  }
85  if (tauCheck_) {
86  const auto& taus = iConfig.getParameter<std::vector<edm::InputTag>>("tauTokens");
87  for (const auto& tau : taus) {
88  tauTokens_.push_back(consumes<l1t::TauBxCollection>(tau));
89  }
90  }
91  if (jetCheck_) {
92  jetToken_ = consumes<JetBxCollection>(iConfig.getParameter<InputTag>("jetToken"));
93  }
94  if (sumCheck_) {
95  sumToken_ = consumes<EtSumBxCollection>(iConfig.getParameter<InputTag>("sumToken"));
96  }
97  if (muonCheck_) {
98  muonToken_ = consumes<MuonBxCollection>(iConfig.getParameter<InputTag>("muonToken"));
99  }
100 
101  egCount_ = 0;
102  tauCount_ = 0;
103  jetCount_ = 0;
104  sumCount_ = 0;
105  muonCount_ = 0;
106 }
107 
108 void L1TSummary::analyze(Event const& iEvent, EventSetup const& iSetup) {
109  cout << "L1TSummary Module output for " << tag_ << "\n";
110  if (egCheck_) {
112  iEvent.getByToken(egToken_, XTMP);
113  if (XTMP.isValid()) {
114  cout << "INFO: L1T found e-gamma collection.\n";
115  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
116  for (auto it = XTMP->begin(ibx); it != XTMP->end(ibx); it++) {
117  if (bxZeroOnly_ && (ibx != 0))
118  continue;
119  if (it->et() > 0) {
120  egCount_++;
121  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi()
122  << "\n";
123  }
124  }
125  }
126  } else {
127  LogWarning("MissingProduct") << "L1Upgrade e-gamma's not found." << std::endl;
128  }
129  }
130 
131  if (tauCheck_) {
132  for (auto& tautoken : tauTokens_) {
134  iEvent.getByToken(tautoken, XTMP);
135  if (XTMP.isValid()) {
136  cout << "INFO: L1T found tau collection.\n";
137  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
138  for (auto it = XTMP->begin(ibx); it != XTMP->end(ibx); it++) {
139  if (it->et() > 0) {
140  if (bxZeroOnly_ && (ibx != 0))
141  continue;
142  tauCount_++;
143  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi()
144  << "\n";
145  }
146  }
147  }
148  } else {
149  LogWarning("MissingProduct") << "L1Upgrade tau's not found." << std::endl;
150  }
151  }
152  }
153 
154  if (jetCheck_) {
156  iEvent.getByToken(jetToken_, XTMP);
157  if (XTMP.isValid()) {
158  cout << "INFO: L1T found jet collection.\n";
159  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
160  for (auto it = XTMP->begin(ibx); it != XTMP->end(ibx); it++) {
161  if (it->et() > 0) {
162  if (bxZeroOnly_ && (ibx != 0))
163  continue;
164  jetCount_++;
165  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi()
166  << "\n";
167  }
168  }
169  }
170  } else {
171  LogWarning("MissingProduct") << "L1T upgrade jets not found." << std::endl;
172  }
173  }
174 
175  if (sumCheck_) {
177  iEvent.getByToken(sumToken_, XTMP);
178  if (XTMP.isValid()) {
179  cout << "INFO: L1T found sum collection.\n";
180  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
181  for (auto it = XTMP->begin(ibx); it != XTMP->end(ibx); it++) {
182  //if (it->et() > 0) {
183  if (bxZeroOnly_ && (ibx != 0))
184  continue;
185  sumCount_++;
186  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi()
187  << " type: " << it->getType() << "\n";
188  //}
189  }
190  }
191  } else {
192  LogWarning("MissingProduct") << "L1T upgrade sums not found." << std::endl;
193  }
194  }
195 
196  if (muonCheck_) {
198  iEvent.getByToken(muonToken_, XTMP);
199  if (XTMP.isValid()) {
200  cout << "INFO: L1T found muon collection.\n";
201  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
202  for (auto it = XTMP->begin(ibx); it != XTMP->end(ibx); it++) {
203  if (it->et() > 0) {
204  if (bxZeroOnly_ && (ibx != 0))
205  continue;
206  muonCount_++;
207  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi()
208  << "\n";
209  }
210  }
211  }
212  } else {
213  LogWarning("MissingProduct") << "L1T upgrade muons not found." << std::endl;
214  }
215  }
216 }
217 
218 void L1TSummary::beginJob() { cout << "INFO: L1TSummary module beginJob called.\n"; }
219 
221  cout << "INFO: L1T Summary for " << tag_ << "\n";
222  cout << "INFO: count of non-zero candidates for each type follows:\n";
223  if (egCheck_)
224  cout << "eg: " << egCount_ << "\n";
225  if (tauCheck_)
226  cout << "tau: " << tauCount_ << "\n";
227  if (jetCheck_)
228  cout << "jet: " << jetCount_ << "\n";
229  if (sumCheck_)
230  cout << "sum: " << sumCount_ << "\n";
231  if (muonCheck_)
232  cout << "muon: " << muonCount_ << "\n";
233 }
234 
236  //The following says we do not know what parameters are allowed so do no validation
237  // Please change this to state exactly what you do use, even if it is no parameters
239  desc.setUnknown();
240  descriptions.addDefault(desc);
241 }
242 
int getLastBX() const
int getFirstBX() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< MuonBxCollection > muonToken_
Definition: L1TSummary.cc:50
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool sumCheck_
Definition: L1TSummary.cc:41
bool egCheck_
Definition: L1TSummary.cc:38
delete x;
Definition: CaloConfig.h:22
edm::EDGetTokenT< EtSumBxCollection > sumToken_
Definition: L1TSummary.cc:49
void endJob() override
Definition: L1TSummary.cc:220
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bool muonCheck_
Definition: L1TSummary.cc:42
bool tauCheck_
Definition: L1TSummary.cc:39
void beginJob()
Definition: Breakpoints.cc:14
const_iterator begin(int bx) const
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
L1TSummary(const ParameterSet &)
Definition: L1TSummary.cc:60
bool bxZeroOnly_
Definition: L1TSummary.cc:43
std::vector< edm::EDGetTokenT< TauBxCollection > > tauTokens_
Definition: L1TSummary.cc:47
int muonCount_
Definition: L1TSummary.cc:57
int tauCount_
Definition: L1TSummary.cc:54
int sumCount_
Definition: L1TSummary.cc:56
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: L1TSummary.cc:235
edm::EDGetTokenT< EGammaBxCollection > egToken_
Definition: L1TSummary.cc:46
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int jetCount_
Definition: L1TSummary.cc:55
bool isValid() const
Definition: HandleBase.h:70
bool jetCheck_
Definition: L1TSummary.cc:40
void analyze(Event const &, EventSetup const &) override
Definition: L1TSummary.cc:108
const_iterator end(int bx) const
HLT enums.
edm::EDGetTokenT< JetBxCollection > jetToken_
Definition: L1TSummary.cc:48
Log< level::Warning, false > LogWarning
int egCount_
Definition: L1TSummary.cc:53
void beginJob() override
Definition: L1TSummary.cc:218
string tag_
Definition: L1TSummary.cc:35