CMS 3D CMS Logo

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