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"
55 using ReturnType = std::unique_ptr<L1TGlobalPrescalesVetos>;
106 edm::FileInPath f1_prescale(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + prescalesFileName);
107 std::string m_prescaleFile = f1_prescale.fullPath();
109 edm::FileInPath f1_mask_algobx(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + algobxmaskFileName);
112 edm::FileInPath f1_mask_finor(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + finormaskFileName);
115 edm::FileInPath f1_mask_veto(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + vetomaskFileName);
124 std::vector<std::vector<int> >
prescales;
125 std::vector<unsigned int> triggerMasks;
126 std::vector<int> triggerVetoMasks;
127 std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
130 std::ifstream input_prescale;
131 input_prescale.open(m_prescaleFile);
132 if (not m_prescaleFile.empty() and not input_prescale) {
134 <<
"\nCould not find prescale file: " << m_prescaleFile
135 <<
"\nDeafulting to a single prescale column, with all prescales set to 1 (unprescaled)";
137 const int inputDefaultPrescale = 1;
141 while (!input_prescale.eof()) {
143 getline(input_prescale,
tmp,
'\n');
144 xmlPayload_prescale.append(
tmp);
149 ts_prescale.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
156 const std::map<std::string, l1t::Parameter>& settings_prescale = ts_prescale.
getParameters(
"uGtProcessor");
157 std::map<std::string, unsigned int> prescaleColumns = settings_prescale.at(
"prescales").getColumnIndices();
159 unsigned int numColumns_prescale = prescaleColumns.size();
161 int NumPrescaleSets = numColumns_prescale - 1;
163 std::vector<unsigned int> algoBits =
164 settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
"algo/prescale-index");
165 int NumAlgos_prescale = *std::max_element(algoBits.begin(), algoBits.end()) + 1;
167 if (NumPrescaleSets > 0) {
169 for (
int iSet = 0; iSet < NumPrescaleSets; iSet++) {
171 for (
int iBit = 0; iBit < NumAlgos_prescale; ++iBit) {
172 int inputDefaultPrescale = 0;
173 prescales[iSet].push_back(inputDefaultPrescale);
177 for (
auto&
col : prescaleColumns) {
180 int iSet =
col.second - 1;
181 std::vector<unsigned int> prescalesForSet =
182 settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
col.first.c_str());
183 for (
unsigned int row = 0; row < prescalesForSet.size(); row++) {
184 unsigned int prescale = prescalesForSet[row];
185 unsigned int algoBit = algoBits[row];
191 input_prescale.close();
199 std::ifstream input_mask_finor;
200 input_mask_finor.open(m_finormaskFile);
201 if (not m_finormaskFile.empty() and not input_mask_finor) {
203 <<
"\nCould not find finor mask file: " << m_finormaskFile
204 <<
"\nDeafulting the finor mask for all triggers to 1 (unmasked)";
206 while (!input_mask_finor.eof()) {
208 getline(input_mask_finor,
tmp,
'\n');
209 xmlPayload_mask_finor.append(
tmp);
214 ts_mask_finor.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
221 const std::map<std::string, l1t::Parameter>& settings_mask_finor = ts_mask_finor.
getParameters(
"uGtProcessor");
223 std::vector<unsigned int> algo_mask_finor =
224 settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"algo");
225 std::vector<unsigned int> mask_mask_finor =
226 settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"mask");
228 for (
unsigned int row = 0; row < algo_mask_finor.size(); row++) {
229 unsigned int algoBit = algo_mask_finor[row];
230 unsigned int mask = mask_mask_finor[row];
232 triggerMasks[algoBit] = mask;
235 input_mask_finor.close();
242 triggerVetoMasks.push_back(0);
244 std::ifstream input_mask_veto;
245 input_mask_veto.open(m_vetomaskFile);
246 if (not m_vetomaskFile.empty() and not input_mask_veto) {
247 edm::LogError(
"L1TGlobalPrescalesVetosESProducer") <<
"\nCould not find veto mask file: " << m_vetomaskFile
248 <<
"\nDeafulting the veto mask for all triggers to 1 (unmasked)";
250 while (!input_mask_veto.eof()) {
252 getline(input_mask_veto,
tmp,
'\n');
253 xmlPayload_mask_veto.append(
tmp);
258 ts_mask_veto.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
265 const std::map<std::string, l1t::Parameter>& settings_mask_veto = ts_mask_veto.
getParameters(
"uGtProcessor");
266 std::vector<unsigned int> algo_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"algo");
267 std::vector<unsigned int> veto_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"veto");
269 for (
unsigned int row = 0; row < algo_mask_veto.size(); row++) {
270 unsigned int algoBit = algo_mask_veto[row];
271 unsigned int veto = veto_mask_veto[row];
273 triggerVetoMasks[algoBit] =
int(
veto);
276 input_mask_veto.close();
281 std::ifstream input_mask_algobx;
282 input_mask_algobx.open(m_algobxmaskFile);
283 if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
285 <<
"\nCould not find bx mask file: " << m_algobxmaskFile <<
"\nNot filling the bx mask map";
287 while (!input_mask_algobx.eof()) {
289 getline(input_mask_algobx,
tmp,
'\n');
290 xmlPayload_mask_algobx.append(
tmp);
295 ts_mask_algobx.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
302 const std::map<std::string, l1t::Parameter>& settings_mask_algobx = ts_mask_algobx.
getParameters(
"uGtProcessor");
303 std::map<std::string, unsigned int> mask_algobx_columns =
304 settings_mask_algobx.at(
"algorithmBxMask").getColumnIndices();
305 std::vector<unsigned int> bunches =
306 settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(
"bx/algo");
308 unsigned int numCol_mask_algobx = mask_algobx_columns.size();
310 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
311 for (
int iBit = 0; iBit < NumAlgoBitsInMask; iBit++) {
312 std::vector<unsigned int>
algo =
313 settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(std::to_string(iBit).c_str());
314 for (
unsigned int bx = 0;
bx < bunches.size();
bx++) {
316 triggerAlgoBxMaskAlgoTrig[bunches[
bx]].push_back(iBit);
320 input_mask_algobx.close();
324 for (
unsigned int iBit = 0; iBit <
prescale.size(); iBit++) {
326 if (iBit >= triggerMasks.size()) {
327 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() "
328 <<
"\nWarning: no information on masking bit or not, setting as unmasked "
331 prescale[iBit] *= triggerMasks[iBit];
361 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
363 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
369 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
374 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
376 LogDebug(
"L1TGlobal") <<
"\t(empty map)" << std::endl;
378 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
379 std::vector<int> masked = it.second;
380 for (
int& iAlg : masked) {
381 LogDebug(
"L1TGlobal") <<
" " << iAlg;
383 LogDebug(
"L1TGlobal") <<
" " << std::endl;