CMS 3D CMS Logo

L1TUtmTriggerMenuDumper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // L1TUtmTriggerMenuDumper: Dump the menu to screen...
4 //
5 
6 #include <iostream>
7 #include <unistd.h>
8 #include <cstdio>
9 #include <cstdlib>
10 
11 #include "tmEventSetup/tmEventSetup.hh"
12 #include "tmEventSetup/esTriggerMenu.hh"
13 #include "tmEventSetup/esAlgorithm.hh"
14 #include "tmEventSetup/esCondition.hh"
15 #include "tmEventSetup/esObject.hh"
16 #include "tmEventSetup/esCut.hh"
17 #include "tmEventSetup/esScale.hh"
18 #include "tmGrammar/Algorithm.hh"
19 
27 
30 
31 using namespace edm;
32 using namespace std;
33 using namespace tmeventsetup;
34 
36 public:
37  explicit L1TUtmTriggerMenuDumper(const ParameterSet&);
38  ~L1TUtmTriggerMenuDumper() override;
39 
40  static void fillDescriptions(ConfigurationDescriptions& descriptions);
41 
42 private:
43  void beginJob() override;
44  void analyze(Event const&, EventSetup const&) override;
45  void endJob() override;
46 
47  void beginRun(Run const&, EventSetup const&) override;
48  void endRun(Run const&, EventSetup const&) override;
49  void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
50  void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override;
51 };
52 
54 
56 
58 
59 void L1TUtmTriggerMenuDumper::beginJob() { cout << "INFO: L1TUtmTriggerMenuDumper module beginJob called.\n"; }
60 
61 void L1TUtmTriggerMenuDumper::endJob() { cout << "INFO: L1TUtmTriggerMenuDumper module endJob called.\n"; }
62 
63 void L1TUtmTriggerMenuDumper::beginRun(Run const& run, EventSetup const& iSetup) {
65  iSetup.get<L1TUtmTriggerMenuRcd>().get(hmenu);
66  const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*>(hmenu.product());
67 
68  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
69  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
70  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
71 
72  bool hasPrecision = false;
73  std::map<std::string, unsigned int> precisions;
74  getPrecisions(precisions, scaleMap);
75  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++) {
76  std::cout << cit->first << " = " << cit->second << "\n";
77  hasPrecision = true;
78  }
79 
80  if (hasPrecision) {
81  std::map<std::string, esScale>::iterator it1, it2;
82  const esScale* scale1 = &scaleMap.find("EG-ETA")->second;
83  const esScale* scale2 = &scaleMap.find("MU-ETA")->second;
84 
85  std::vector<long long> lut_eg_2_mu_eta;
86  getCaloMuonEtaConversionLut(lut_eg_2_mu_eta, scale1, scale2);
87 
88  scale1 = &scaleMap.find("EG-PHI")->second;
89  scale2 = &scaleMap.find("MU-PHI")->second;
90 
91  std::vector<long long> lut_eg_2_mu_phi;
92  getCaloMuonPhiConversionLut(lut_eg_2_mu_phi, scale1, scale2);
93 
94  scale1 = &scaleMap.find("EG-ETA")->second;
95  scale2 = &scaleMap.find("MU-ETA")->second;
96 
97  std::vector<double> eg_mu_delta_eta;
98  std::vector<long long> lut_eg_mu_delta_eta;
99  size_t n = getDeltaVector(eg_mu_delta_eta, scale1, scale2);
100  setLut(lut_eg_mu_delta_eta, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Delta"]);
101 
102  std::vector<long long> lut_eg_mu_cosh;
103  applyCosh(eg_mu_delta_eta, n);
104  setLut(lut_eg_mu_cosh, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Math"]);
105 
106  scale1 = &scaleMap.find("EG-PHI")->second;
107  scale2 = &scaleMap.find("MU-PHI")->second;
108 
109  std::vector<double> eg_mu_delta_phi;
110  std::vector<long long> lut_eg_mu_delta_phi;
111  n = getDeltaVector(eg_mu_delta_phi, scale1, scale2);
112  setLut(lut_eg_mu_delta_phi, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Delta"]);
113 
114  std::vector<long long> lut_eg_mu_cos;
115  applyCos(eg_mu_delta_phi, n);
116  setLut(lut_eg_mu_cos, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Math"]);
117 
118  scale1 = &scaleMap.find("EG-ET")->second;
119  std::vector<long long> lut_eg_et;
120  getLut(lut_eg_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
121 
122  scale1 = &scaleMap.find("MU-ET")->second;
123  std::vector<long long> lut_mu_et;
124  getLut(lut_mu_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
125  for (size_t ii = 0; ii < lut_mu_et.size(); ii++) {
126  std::cout << lut_mu_et.at(ii) << "\n";
127  }
128  }
129 
130  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin(); cit != algoMap.end(); cit++) {
131  const esAlgorithm& algo = cit->second;
132  std::cout << "algo name = " << algo.getName() << "\n";
133  std::cout << "algo exp. = " << algo.getExpression() << "\n";
134  std::cout << "algo exp. in cond. = " << algo.getExpressionInCondition() << "\n";
135 
136  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
137  for (size_t ii = 0; ii < rpn_vec.size(); ii++) {
138  const std::string& token = rpn_vec.at(ii);
139  if (Algorithm::isGate(token))
140  continue;
141  const esCondition& condition = condMap.find(token)->second;
142  std::cout << " cond type = " << condition.getType() << "\n";
143 
144  const std::vector<esCut>& cuts = condition.getCuts();
145  for (size_t jj = 0; jj < cuts.size(); jj++) {
146  const esCut& cut = cuts.at(jj);
147  std::cout << " cut name = " << cut.getName() << "\n";
148  std::cout << " cut target = " << cut.getObjectType() << "\n";
149  std::cout << " cut type = " << cut.getCutType() << "\n";
150  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
151  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
152  std::cout << " cut data = " << cut.getData() << "\n";
153  }
154 
155  const std::vector<esObject>& objects = condition.getObjects();
156  for (size_t jj = 0; jj < objects.size(); jj++) {
157  const esObject& object = objects.at(jj);
158  std::cout << " obj name = " << object.getName() << "\n";
159  std::cout << " obj type = " << object.getType() << "\n";
160  std::cout << " obj op = " << object.getComparisonOperator() << "\n";
161  std::cout << " obj bx = " << object.getBxOffset() << "\n";
162  if (object.getType() == esObjectType::EXT) {
163  std::cout << " ext name = " << object.getExternalSignalName() << "\n";
164  std::cout << " ext ch id = " << object.getExternalChannelId() << "\n";
165  }
166 
167  const std::vector<esCut>& cuts = object.getCuts();
168  for (size_t kk = 0; kk < cuts.size(); kk++) {
169  const esCut& cut = cuts.at(kk);
170  std::cout << " cut name = " << cut.getName() << "\n";
171  std::cout << " cut target = " << cut.getObjectType() << "\n";
172  std::cout << " cut type = " << cut.getCutType() << "\n";
173  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index
174  << "\n";
175  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index
176  << "\n";
177  std::cout << " cut data = " << cut.getData() << "\n";
178  }
179  }
180  }
181  }
182 }
183 
185 
187 
189 
191  //The following says we do not know what parameters are allowed so do no validation
192  // Please change this to state exactly what you do use, even if it is no parameters
194  desc.setUnknown();
195  descriptions.addDefault(desc);
196 }
197 
void analyze(Event const &, EventSetup const &) override
void endLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
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)
L1TUtmTriggerMenuDumper(const ParameterSet &)
void endRun(Run const &, EventSetup const &) override
ii
Definition: cuy.py:590
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(Run const &, EventSetup const &) override
HLT enums.
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:45