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 
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
L1TSummary::beginRun
void beginRun(Run const &, EventSetup const &) override
Definition: L1TSummary.cc:243
L1TSummary::sumCount_
int sumCount_
Definition: L1TSummary.cc:62
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
L1TSummary::egToken_
edm::EDGetTokenT< EGammaBxCollection > egToken_
Definition: L1TSummary.cc:52
MessageLogger.h
L1TSummary::bxZeroOnly_
bool bxZeroOnly_
Definition: L1TSummary.cc:49
L1TSummary::~L1TSummary
~L1TSummary() override
Definition: L1TSummary.cc:114
L1TSummary::tauTokens_
std::vector< edm::EDGetTokenT< TauBxCollection > > tauTokens_
Definition: L1TSummary.cc:53
metsig::tau
Definition: SignAlgoResolutions.h:49
L1TSummary
Definition: L1TSummary.cc:23
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< EGammaBxCollection >
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
L1TSummary::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: L1TSummary.cc:251
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TSummary::muonCount_
int muonCount_
Definition: L1TSummary.cc:63
Muon.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Jet.h
L1TSummary::tauCount_
int tauCount_
Definition: L1TSummary.cc:60
L1TSummary::endRun
void endRun(Run const &, EventSetup const &) override
Definition: L1TSummary.cc:245
L1TSummary::jetCount_
int jetCount_
Definition: L1TSummary.cc:61
L1TSummary::jetCheck_
bool jetCheck_
Definition: L1TSummary.cc:46
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
BXVector::getFirstBX
int getFirstBX() const
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EGamma.h
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
L1TSummary::analyze
void analyze(Event const &, EventSetup const &) override
Definition: L1TSummary.cc:116
L1TSummary::tag_
string tag_
Definition: L1TSummary.cc:41
L1TSummary::jetToken_
edm::EDGetTokenT< JetBxCollection > jetToken_
Definition: L1TSummary.cc:54
BXVector::begin
const_iterator begin(int bx) const
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
L1TSummary::beginJob
void beginJob() override
Definition: L1TSummary.cc:226
BXVector::end
const_iterator end(int bx) const
edm::ParameterSet
Definition: ParameterSet.h:47
L1TSummary::beginLuminosityBlock
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
Definition: L1TSummary.cc:247
L1TSummary::sumCheck_
bool sumCheck_
Definition: L1TSummary.cc:47
Event.h
L1TSummary::egCount_
int egCount_
Definition: L1TSummary.cc:59
l1t
delete x;
Definition: CaloConfig.h:22
iEvent
int iEvent
Definition: GenABIO.cc:224
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
L1TSummary::endJob
void endJob() override
Definition: L1TSummary.cc:228
edm::EventSetup
Definition: EventSetup.h:57
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
L1TSummary::egCheck_
bool egCheck_
Definition: L1TSummary.cc:44
L1TSummary::muonToken_
edm::EDGetTokenT< MuonBxCollection > muonToken_
Definition: L1TSummary.cc:56
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1TSummary::endLuminosityBlock
void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
Definition: L1TSummary.cc:249
L1TSummary::tauCheck_
bool tauCheck_
Definition: L1TSummary.cc:45
ParameterSet.h
EtSum.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
L1TSummary::sumToken_
edm::EDGetTokenT< EtSumBxCollection > sumToken_
Definition: L1TSummary.cc:55
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
BXVector::getLastBX
int getLastBX() const
edm::InputTag
Definition: InputTag.h:15
L1TSummary::muonCheck_
bool muonCheck_
Definition: L1TSummary.cc:48
L1TSummary::L1TSummary
L1TSummary(const ParameterSet &)
Definition: L1TSummary.cc:66
Tau.h