CMS 3D CMS Logo

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