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