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  using ReturnType = std::unique_ptr<const L1TUtmTriggerMenu>;
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  return ReturnType(cmenu);
112 }
113 
114 //define this as a plug-in
116 
117 /*
118 
119 
120 
121 
122 int
123 main(int argc, char *argv[])
124 {
125  int opt;
126  const char* file = 0;
127  while ((opt = getopt(argc, argv, "f:")) != -1)
128  {
129  switch (opt)
130  {
131  case 'f':
132  file = optarg;
133  break;
134  }
135  }
136 
137  if (not file)
138  {
139  fprintf(stderr, "Usage: %s -f file\n", argv[0]);
140  exit(EXIT_FAILURE);
141  }
142 
143  using namespace tmeventsetup;
144  const esTriggerMenu* menu = tmeventsetup::getTriggerMenu(file);
145 
146  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
147  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
148  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
149 
150  bool hasPrecision = false;
151  std::map<std::string, unsigned int> precisions;
152  getPrecisions(precisions, scaleMap);
153  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++)
154  {
155  std::cout << cit->first << " = " << cit->second << "\n";
156  hasPrecision = true;
157  }
158 
159 
160  if (hasPrecision)
161  {
162  std::map<std::string, esScale>::iterator it1, it2;
163  const esScale* scale1 = &scaleMap.find("EG-ETA")->second;
164  const esScale* scale2 = &scaleMap.find("MU-ETA")->second;
165 
166  std::vector<long long> lut_eg_2_mu_eta;
167  getCaloMuonEtaConversionLut(lut_eg_2_mu_eta, scale1, scale2);
168 
169 
170  scale1 = &scaleMap.find("EG-PHI")->second;
171  scale2 = &scaleMap.find("MU-PHI")->second;
172 
173  std::vector<long long> lut_eg_2_mu_phi;
174  getCaloMuonPhiConversionLut(lut_eg_2_mu_phi, scale1, scale2);
175 
176 
177  scale1 = &scaleMap.find("EG-ETA")->second;
178  scale2 = &scaleMap.find("MU-ETA")->second;
179 
180  std::vector<double> eg_mu_delta_eta;
181  std::vector<long long> lut_eg_mu_delta_eta;
182  size_t n = getDeltaVector(eg_mu_delta_eta, scale1, scale2);
183  setLut(lut_eg_mu_delta_eta, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Delta"]);
184 
185  std::vector<long long> lut_eg_mu_cosh;
186  applyCosh(eg_mu_delta_eta, n);
187  setLut(lut_eg_mu_cosh, eg_mu_delta_eta, precisions["PRECISION-EG-MU-Math"]);
188 
189 
190  scale1 = &scaleMap.find("EG-PHI")->second;
191  scale2 = &scaleMap.find("MU-PHI")->second;
192 
193  std::vector<double> eg_mu_delta_phi;
194  std::vector<long long> lut_eg_mu_delta_phi;
195  n = getDeltaVector(eg_mu_delta_phi, scale1, scale2);
196  setLut(lut_eg_mu_delta_phi, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Delta"]);
197 
198  std::vector<long long> lut_eg_mu_cos;
199  applyCos(eg_mu_delta_phi, n);
200  setLut(lut_eg_mu_cos, eg_mu_delta_phi, precisions["PRECISION-EG-MU-Math"]);
201 
202 
203  scale1 = &scaleMap.find("EG-ET")->second;
204  std::vector<long long> lut_eg_et;
205  getLut(lut_eg_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
206 
207 
208  scale1 = &scaleMap.find("MU-ET")->second;
209  std::vector<long long> lut_mu_et;
210  getLut(lut_mu_et, scale1, precisions["PRECISION-EG-MU-MassPt"]);
211  for (size_t ii = 0; ii < lut_mu_et.size(); ii++)
212  {
213  std::cout << lut_mu_et.at(ii) << "\n";
214  }
215  }
216 
217 
218  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin();
219  cit != algoMap.end(); cit++)
220  {
221  const esAlgorithm& algo = cit->second;
222  std::cout << "algo name = " << algo.getName() << "\n";
223  std::cout << "algo exp. = " << algo.getExpression() << "\n";
224  std::cout << "algo exp. in cond. = " << algo.getExpressionInCondition() << "\n";
225 
226  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
227  for (size_t ii = 0; ii < rpn_vec.size(); ii++)
228  {
229  const std::string& token = rpn_vec.at(ii);
230  if (Algorithm::isGate(token)) continue;
231  const esCondition& condition = condMap.find(token)->second;
232  std::cout << " cond type = " << condition.getType() << "\n";
233 
234  const std::vector<esCut>& cuts = condition.getCuts();
235  for (size_t jj = 0; jj < cuts.size(); jj++)
236  {
237  const esCut& cut = cuts.at(jj);
238  std::cout << " cut name = " << cut.getName() << "\n";
239  std::cout << " cut target = " << cut.getObjectType() << "\n";
240  std::cout << " cut type = " << cut.getCutType() << "\n";
241  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
242  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
243  std::cout << " cut data = " << cut.getData() << "\n";
244  }
245 
246  const std::vector<esObject>& objects = condition.getObjects();
247  for (size_t jj = 0; jj < objects.size(); jj++)
248  {
249  const esObject& object = objects.at(jj);
250  std::cout << " obj name = " << object.getName() << "\n";
251  std::cout << " obj type = " << object.getType() << "\n";
252  std::cout << " obj op = " << object.getComparisonOperator() << "\n";
253  std::cout << " obj bx = " << object.getBxOffset() << "\n";
254  if (object.getType() == esObjectType::EXT)
255  {
256  std::cout << " ext name = " << object.getExternalSignalName() << "\n";
257  std::cout << " ext ch id = " << object.getExternalChannelId() << "\n";
258  }
259 
260  const std::vector<esCut>& cuts = object.getCuts();
261  for (size_t kk = 0; kk < cuts.size(); kk++)
262  {
263  const esCut& cut = cuts.at(kk);
264  std::cout << " cut name = " << cut.getName() << "\n";
265  std::cout << " cut target = " << cut.getObjectType() << "\n";
266  std::cout << " cut type = " << cut.getCutType() << "\n";
267  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
268  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
269  std::cout << " cut data = " << cut.getData() << "\n";
270  }
271  }
272  }
273  }
274 
275  return 0;
276 }
277 
278 */
T getParameter(std::string const &) const
std::map< DetId, double > ReturnType
std::unique_ptr< const L1TUtmTriggerMenu > ReturnType
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
HLT enums.
L1TUtmTriggerMenuESProducer(const edm::ParameterSet &)
ReturnType produce(const L1TUtmTriggerMenuRcd &)