CMS 3D CMS Logo

L1TUtmTriggerMenuESProducer.cc
Go to the documentation of this file.
1 
10 
11 // system include files
12 #include <memory>
13 #include <iostream>
14 #include <fstream>
15 #include <unistd.h>
16 #include <cstdio>
17 #include <cstdlib>
18 
19 #include "tmEventSetup/tmEventSetup.hh"
20 #include "tmEventSetup/esTriggerMenu.hh"
21 #include "tmEventSetup/esAlgorithm.hh"
22 #include "tmEventSetup/esCondition.hh"
23 #include "tmEventSetup/esObject.hh"
24 #include "tmEventSetup/esCut.hh"
25 #include "tmEventSetup/esScale.hh"
26 #include "tmGrammar/Algorithm.hh"
27 
34 
37 
38 using namespace std;
39 using namespace edm;
40 
41 //
42 // class declaration
43 //
44 
46 public:
48  ~L1TUtmTriggerMenuESProducer() override;
49 
50  typedef std::shared_ptr<L1TUtmTriggerMenu> ReturnType;
51 
52  ReturnType produce(const L1TUtmTriggerMenuRcd&);
53 
54 private:
55 
57 
58 };
59 
60 //
61 // constants, enums and typedefs
62 //
63 
64 //
65 // static data member definitions
66 //
67 
68 //
69 // constructors and destructor
70 //
72 {
73  //the following line is needed to tell the framework what
74  // data is being produced
75  setWhatProduced(this);
76  //setWhatProduced(this, conf.getParameter<std::string>("label"));
77 
78 
79  // def.xml file
80  std::string L1TriggerMenuFile = conf.getParameter<std::string>("L1TriggerMenuFile");
81 
82  edm::FileInPath f1("L1Trigger/L1TGlobal/data/Luminosity/startup/" + L1TriggerMenuFile);
83 
84  m_L1TriggerMenuFile = f1.fullPath();
85 
86 
87 }
88 
89 
91 {
92 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 
96 }
97 
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to produce the data ------------
106 {
107 
108 
109  //const L1TUtmTriggerMenu * cmenu = reinterpret_cast<const L1TUtmTriggerMenu *>(tmeventsetup::getTriggerMenu("/afs/cern.ch/user/t/tmatsush/public/tmGui/test-menu.xml"));
110  const L1TUtmTriggerMenu * cmenu = reinterpret_cast<const L1TUtmTriggerMenu *>(tmeventsetup::getTriggerMenu(m_L1TriggerMenuFile));
111  L1TUtmTriggerMenu * menu = const_cast<L1TUtmTriggerMenu *>(cmenu);
112 
113  using namespace edm::es;
114  std::shared_ptr<L1TUtmTriggerMenu> pMenu ;
115  pMenu = std::shared_ptr< L1TUtmTriggerMenu >(menu);
116  return pMenu;
117 }
118 
119 //define this as a plug-in
121 
122 /*
123 
124 
125 
126 
127 int
128 main(int argc, char *argv[])
129 {
130  int opt;
131  const char* file = 0;
132  while ((opt = getopt(argc, argv, "f:")) != -1)
133  {
134  switch (opt)
135  {
136  case 'f':
137  file = optarg;
138  break;
139  }
140  }
141 
142  if (not file)
143  {
144  fprintf(stderr, "Usage: %s -f file\n", argv[0]);
145  exit(EXIT_FAILURE);
146  }
147 
148  using namespace tmeventsetup;
149  const esTriggerMenu* menu = tmeventsetup::getTriggerMenu(file);
150 
151  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
152  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
153  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
154 
155  bool hasPrecision = false;
156  std::map<std::string, unsigned int> precisions;
157  getPrecisions(precisions, scaleMap);
158  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++)
159  {
160  std::cout << cit->first << " = " << cit->second << "\n";
161  hasPrecision = true;
162  }
163 
164 
165  if (hasPrecision)
166  {
167  std::map<std::string, esScale>::iterator it1, it2;
168  const esScale* scale1 = &scaleMap.find("EG-ETA")->second;
169  const esScale* scale2 = &scaleMap.find("MU-ETA")->second;
170 
171  std::vector<long long> lut_eg_2_mu_eta;
172  getCaloMuonEtaConversionLut(lut_eg_2_mu_eta, scale1, scale2);
173 
174 
175  scale1 = &scaleMap.find("EG-PHI")->second;
176  scale2 = &scaleMap.find("MU-PHI")->second;
177 
178  std::vector<long long> lut_eg_2_mu_phi;
179  getCaloMuonPhiConversionLut(lut_eg_2_mu_phi, scale1, scale2);
180 
181 
182  scale1 = &scaleMap.find("EG-ETA")->second;
183  scale2 = &scaleMap.find("MU-ETA")->second;
184 
185  std::vector<double> eg_mu_delta_eta;
186  std::vector<long long> lut_eg_mu_delta_eta;
187  size_t n = getDeltaVector(eg_mu_delta_eta, scale1, scale2);
188  setLut(lut_eg_mu_delta_eta, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Delta"]);
189 
190  std::vector<long long> lut_eg_mu_cosh;
191  applyCosh(eg_mu_delta_eta, n);
192  setLut(lut_eg_mu_cosh, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Math"]);
193 
194 
195  scale1 = &scaleMap.find("EG-PHI")->second;
196  scale2 = &scaleMap.find("MU-PHI")->second;
197 
198  std::vector<double> eg_mu_delta_phi;
199  std::vector<long long> lut_eg_mu_delta_phi;
200  n = getDeltaVector(eg_mu_delta_phi, scale1, scale2);
201  setLut(lut_eg_mu_delta_phi, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Delta"]);
202 
203  std::vector<long long> lut_eg_mu_cos;
204  applyCos(eg_mu_delta_phi, n);
205  setLut(lut_eg_mu_cos, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Math"]);
206 
207 
208  scale1 = &scaleMap.find("EG-ET")->second;
209  std::vector<long long> lut_eg_et;
210  getLut(lut_eg_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
211 
212 
213  scale1 = &scaleMap.find("MU-ET")->second;
214  std::vector<long long> lut_mu_et;
215  getLut(lut_mu_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
216  for (size_t ii = 0; ii < lut_mu_et.size(); ii++)
217  {
218  std::cout << lut_mu_et.at(ii) << "\n";
219  }
220  }
221 
222 
223  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin();
224  cit != algoMap.end(); cit++)
225  {
226  const esAlgorithm& algo = cit->second;
227  std::cout << "algo name = " << algo.getName() << "\n";
228  std::cout << "algo exp. = " << algo.getExpression() << "\n";
229  std::cout << "algo exp. in cond. = " << algo.getExpressionInCondition() << "\n";
230 
231  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
232  for (size_t ii = 0; ii < rpn_vec.size(); ii++)
233  {
234  const std::string& token = rpn_vec.at(ii);
235  if (Algorithm::isGate(token)) continue;
236  const esCondition& condition = condMap.find(token)->second;
237  std::cout << " cond type = " << condition.getType() << "\n";
238 
239  const std::vector<esCut>& cuts = condition.getCuts();
240  for (size_t jj = 0; jj < cuts.size(); jj++)
241  {
242  const esCut& cut = cuts.at(jj);
243  std::cout << " cut name = " << cut.getName() << "\n";
244  std::cout << " cut target = " << cut.getObjectType() << "\n";
245  std::cout << " cut type = " << cut.getCutType() << "\n";
246  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
247  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
248  std::cout << " cut data = " << cut.getData() << "\n";
249  }
250 
251  const std::vector<esObject>& objects = condition.getObjects();
252  for (size_t jj = 0; jj < objects.size(); jj++)
253  {
254  const esObject& object = objects.at(jj);
255  std::cout << " obj name = " << object.getName() << "\n";
256  std::cout << " obj type = " << object.getType() << "\n";
257  std::cout << " obj op = " << object.getComparisonOperator() << "\n";
258  std::cout << " obj bx = " << object.getBxOffset() << "\n";
259  if (object.getType() == esObjectType::EXT)
260  {
261  std::cout << " ext name = " << object.getExternalSignalName() << "\n";
262  std::cout << " ext ch id = " << object.getExternalChannelId() << "\n";
263  }
264 
265  const std::vector<esCut>& cuts = object.getCuts();
266  for (size_t kk = 0; kk < cuts.size(); kk++)
267  {
268  const esCut& cut = cuts.at(kk);
269  std::cout << " cut name = " << cut.getName() << "\n";
270  std::cout << " cut target = " << cut.getObjectType() << "\n";
271  std::cout << " cut type = " << cut.getCutType() << "\n";
272  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
273  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
274  std::cout << " cut data = " << cut.getData() << "\n";
275  }
276  }
277  }
278  }
279 
280  return 0;
281 }
282 
283 */
T getParameter(std::string const &) const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
HLT enums.
std::shared_ptr< L1TUtmTriggerMenu > ReturnType
L1TUtmTriggerMenuESProducer(const edm::ParameterSet &)
ReturnType produce(const L1TUtmTriggerMenuRcd &)