CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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();
27 
28  static void fillDescriptions(ConfigurationDescriptions& descriptions);
29 
30 private:
31  virtual void beginJob();
32  virtual void analyze(Event const&, EventSetup const&);
33  virtual void endJob();
34 
35  virtual void beginRun(Run const&, EventSetup const&);
36  virtual void endRun(Run const&, EventSetup const&);
37  virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&);
38  virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&);
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_;
49  bool bxZeroOnly_;
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 
68 
69  // InputTag barrelTfInputTag = iConfig.getParameter<InputTag>("barrelTFInput");
70  // InputTag overlapTfInputTag = iConfig.getParameter<InputTag>("overlapTFInput");
71  // InputTag forwardTfInputTag = iConfig.getParameter<InputTag>("forwardTFInput");
72  //m_barrelTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(iConfig.getParameter<InputTag>("bmtfDigis"));
73 
74  tag_ = iConfig.getParameter<string>("tag");
75 
76  egCheck_ = iConfig.getParameter<bool>("egCheck");
77  tauCheck_ = iConfig.getParameter<bool>("tauCheck");
78  jetCheck_ = iConfig.getParameter<bool>("jetCheck");
79  sumCheck_ = iConfig.getParameter<bool>("sumCheck");
80  muonCheck_ = iConfig.getParameter<bool>("muonCheck");
81  bxZeroOnly_ = iConfig.getParameter<bool>("bxZeroOnly");
82 
83  //cout << "L1T Summary for " << tag << "\n";
84  //cout << "DEBUG: egCheck: " << egCheck_ << "\n";
85  //cout << "DEBUG: tauCheck: " << tauCheck_ << "\n";
86  //cout << "DEBUG: jetCheck: " << jetCheck_ << "\n";
87  //cout << "DEBUG: sumCheck: " << sumCheck_ << "\n";
88  //cout << "DEBUG: muonCheck: " << muonCheck_ << "\n";
89 
90  if (egCheck_) {egToken_ = consumes<EGammaBxCollection> (iConfig.getParameter<InputTag>("egToken"));}
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_) {jetToken_ = consumes<JetBxCollection> (iConfig.getParameter<InputTag>("jetToken"));}
98  if (sumCheck_) {sumToken_ = consumes<EtSumBxCollection> (iConfig.getParameter<InputTag>("sumToken"));}
99  if (muonCheck_) {muonToken_ = consumes<MuonBxCollection> (iConfig.getParameter<InputTag>("muonToken"));}
100 
101  egCount_ = 0;
102  tauCount_ = 0;
103  jetCount_ = 0;
104  sumCount_ = 0;
105  muonCount_ = 0;
106 }
107 
109 
110 
111 void
113 {
114 
115  cout << "L1TSummary Module output for " << tag_ << "\n";
116  if (egCheck_){
118  iEvent.getByToken(egToken_, XTMP);
119  if (XTMP.isValid()){
120  cout << "INFO: L1T found e-gamma collection.\n";
121  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
122  for (auto it=XTMP->begin(ibx); it!=XTMP->end(ibx); it++){
123  if (bxZeroOnly_ && (ibx != 0)) continue;
124  if (it->et() > 0){
125  egCount_++;
126  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
127  }
128  }
129  }
130  } else {
131  LogWarning("MissingProduct") << "L1Upgrade e-gamma's not found." << std::endl;
132  }
133  }
134 
135  if (tauCheck_){
136  for (auto & tautoken: tauTokens_){
138  iEvent.getByToken(tautoken, XTMP);
139  if (XTMP.isValid()){
140  cout << "INFO: L1T found tau collection.\n";
141  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
142  for (auto it=XTMP->begin(ibx); it!=XTMP->end(ibx); it++){
143  if (it->et() > 0){
144  if (bxZeroOnly_ && (ibx != 0)) continue;
145  tauCount_++;
146  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
147  }
148  }
149  }
150  } else {
151  LogWarning("MissingProduct") << "L1Upgrade tau's not found." << std::endl;
152  }
153  }
154  }
155 
156  if (jetCheck_){
158  iEvent.getByToken(jetToken_, XTMP);
159  if (XTMP.isValid()){
160  cout << "INFO: L1T found jet collection.\n";
161  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
162  for (auto it=XTMP->begin(ibx); it!=XTMP->end(ibx); it++){
163  if (it->et() > 0) {
164  if (bxZeroOnly_ && (ibx != 0)) continue;
165  jetCount_++;
166  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\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)) continue;
184  sumCount_++;
185  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
186  }
187  }
188  }
189  } else {
190  LogWarning("MissingProduct") << "L1T upgrade sums not found." << std::endl;
191  }
192  }
193 
194 
195  if (muonCheck_){
197  iEvent.getByToken(muonToken_, XTMP);
198  if (XTMP.isValid()){
199  cout << "INFO: L1T found muon collection.\n";
200  for (int ibx = XTMP->getFirstBX(); ibx <= XTMP->getLastBX(); ++ibx) {
201  for (auto it=XTMP->begin(ibx); it!=XTMP->end(ibx); it++){
202  if (it->et() > 0){
203  if (bxZeroOnly_ && (ibx != 0)) continue;
204  muonCount_++;
205  cout << "bx: " << ibx << " et: " << it->et() << " eta: " << it->eta() << " phi: " << it->phi() << "\n";
206  }
207  }
208  }
209  } else {
210  LogWarning("MissingProduct") << "L1T upgrade muons not found." << std::endl;
211  }
212  }
213 
214 
215 
216 
217 
218 }
219 
220 void
222 {
223  cout << "INFO: L1TSummary module beginJob called.\n";
224 }
225 
226 void
228  cout << "INFO: L1T Summary for " << tag_ << "\n";
229  cout << "INFO: count of non-zero candidates for each type follows:\n";
230  if (egCheck_) cout << "eg: " << egCount_ << "\n";
231  if (tauCheck_) cout << "tau: " << tauCount_ << "\n";
232  if (jetCheck_) cout << "jet: " << jetCount_ << "\n";
233  if (sumCheck_) cout << "sum: " << sumCount_ << "\n";
234  if (muonCheck_) cout << "muon: " << muonCount_ << "\n";
235 }
236 
237 void
238 L1TSummary::beginRun(Run const& run, EventSetup const& iSetup)
239 {
240 }
241 
242 void
244 {
245 }
246 
247 void
249 {
250 }
251 
252 void
254 {
255 }
256 
257 void
259  //The following says we do not know what parameters are allowed so do no validation
260  // Please change this to state exactly what you do use, even if it is no parameters
262  desc.setUnknown();
263  descriptions.addDefault(desc);
264 }
265 
266 
T getParameter(std::string const &) const
edm::EDGetTokenT< MuonBxCollection > muonToken_
Definition: L1TSummary.cc:56
virtual void endJob()
Definition: L1TSummary.cc:227
virtual void beginJob()
Definition: L1TSummary.cc:221
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: L1TSummary.cc:248
virtual void endRun(Run const &, EventSetup const &)
Definition: L1TSummary.cc:243
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool sumCheck_
Definition: L1TSummary.cc:47
bool egCheck_
Definition: L1TSummary.cc:44
edm::EDGetTokenT< EtSumBxCollection > sumToken_
Definition: L1TSummary.cc:55
bool muonCheck_
Definition: L1TSummary.cc:48
bool tauCheck_
Definition: L1TSummary.cc:45
void beginJob()
Definition: Breakpoints.cc:15
virtual void analyze(Event const &, EventSetup const &)
Definition: L1TSummary.cc:112
virtual void beginRun(Run const &, EventSetup const &)
Definition: L1TSummary.cc:238
int iEvent
Definition: GenABIO.cc:230
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
int muonCount_
Definition: L1TSummary.cc:63
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: L1TSummary.cc:253
int tauCount_
Definition: L1TSummary.cc:60
bool isValid() const
Definition: HandleBase.h:75
int sumCount_
Definition: L1TSummary.cc:62
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: L1TSummary.cc:258
edm::EDGetTokenT< EGammaBxCollection > egToken_
Definition: L1TSummary.cc:52
int jetCount_
Definition: L1TSummary.cc:61
bool jetCheck_
Definition: L1TSummary.cc:46
edm::EDGetTokenT< JetBxCollection > jetToken_
Definition: L1TSummary.cc:54
tuple cout
Definition: gather_cfg.py:145
int egCount_
Definition: L1TSummary.cc:59
Definition: Run.h:43
string tag_
Definition: L1TSummary.cc:41