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