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" 54 using ReturnType = std::unique_ptr<L1TGlobalPrescalesVetosFract>;
105 edm::FileInPath f1_prescale(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + prescalesFileName);
106 std::string m_prescaleFile = f1_prescale.fullPath();
108 edm::FileInPath f1_mask_algobx(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + algobxmaskFileName);
111 edm::FileInPath f1_mask_finor(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + finormaskFileName);
114 edm::FileInPath f1_mask_veto(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + vetomaskFileName);
123 std::vector<std::vector<double> >
prescales;
124 std::vector<unsigned int> triggerMasks;
125 std::vector<int> triggerVetoMasks;
126 std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
129 std::ifstream input_prescale;
130 input_prescale.open(m_prescaleFile);
131 if (not m_prescaleFile.empty() and not input_prescale) {
133 <<
"\nCould not find prescale file: " << m_prescaleFile
134 <<
"\nDeafulting to a single prescale column, with all prescales set to 1 (unprescaled)";
136 const int inputDefaultPrescale = 1;
140 while (!input_prescale.eof()) {
142 getline(input_prescale,
tmp,
'\n');
143 xmlPayload_prescale.append(
tmp);
148 ts_prescale.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
155 const std::map<std::string, l1t::Parameter>& settings_prescale = ts_prescale.
getParameters(
"uGtProcessor");
156 std::map<std::string, unsigned int> prescaleColumns = settings_prescale.at(
"prescales").getColumnIndices();
158 unsigned int numColumns_prescale = prescaleColumns.size();
160 int NumPrescaleSets = numColumns_prescale - 1;
162 std::vector<unsigned int> algoBits =
163 settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
"algo/prescale-index");
164 int NumAlgos_prescale = *std::max_element(algoBits.begin(), algoBits.end()) + 1;
166 if (NumPrescaleSets > 0) {
168 for (
int iSet = 0; iSet < NumPrescaleSets; iSet++) {
169 prescales.push_back(std::vector<double>());
170 for (
int iBit = 0; iBit < NumAlgos_prescale; ++iBit) {
171 int inputDefaultPrescale = 0;
172 prescales[iSet].push_back(inputDefaultPrescale);
176 for (
auto&
col : prescaleColumns) {
179 int iSet =
col.second - 1;
180 std::vector<double> prescalesForSet =
181 settings_prescale.at(
"prescales").getTableColumn<
double>(
col.first.c_str());
182 for (
unsigned int row = 0; row < prescalesForSet.size(); row++) {
183 double prescale = prescalesForSet[row];
184 unsigned int algoBit = algoBits[row];
190 input_prescale.close();
198 std::ifstream input_mask_finor;
199 input_mask_finor.open(m_finormaskFile);
200 if (not m_finormaskFile.empty() and not input_mask_finor) {
202 <<
"\nCould not find finor mask file: " << m_finormaskFile
203 <<
"\nDeafulting the finor mask for all triggers to 1 (unmasked)";
205 while (!input_mask_finor.eof()) {
207 getline(input_mask_finor,
tmp,
'\n');
208 xmlPayload_mask_finor.append(
tmp);
213 ts_mask_finor.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
220 const std::map<std::string, l1t::Parameter>& settings_mask_finor = ts_mask_finor.
getParameters(
"uGtProcessor");
222 std::vector<unsigned int> algo_mask_finor =
223 settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"algo");
224 std::vector<unsigned int> mask_mask_finor =
225 settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"mask");
227 for (
unsigned int row = 0; row < algo_mask_finor.size(); row++) {
228 unsigned int algoBit = algo_mask_finor[row];
229 unsigned int mask = mask_mask_finor[row];
231 triggerMasks[algoBit] =
mask;
234 input_mask_finor.close();
241 triggerVetoMasks.push_back(0);
243 std::ifstream input_mask_veto;
244 input_mask_veto.open(m_vetomaskFile);
245 if (not m_vetomaskFile.empty() and not input_mask_veto) {
247 <<
"\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());
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;
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
void setConfigured(bool state=true) noexcept
T getParameter(std::string const &) const
unsigned int m_numberPhysTriggers
std::string fullPath() const
void setTriggerMaskVeto(std::vector< int > value)
std::vector< std::vector< double > > m_initialPrescaleFactorsAlgoTrig
~L1TGlobalPrescalesVetosFractESProducer() override
std::unique_ptr< L1TGlobalPrescalesVetosFract > ReturnType
Log< level::Error, false > LogError
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
static std::string to_string(const XMLCh *ch)
L1TGlobalPrescalesVetosFract * getWriteInstance()
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
const std::map< std::string, Parameter > & getParameters(const char *processor) const
L1TGlobalPrescalesVetosFractESProducer(const edm::ParameterSet &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
PrescalesVetosFractHelper data_
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
ReturnType produce(const L1TGlobalPrescalesVetosFractRcd &)
void setBxMaskDefault(int value)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
Log< level::Warning, false > LogWarning
void setPrescaleFactorTable(std::vector< std::vector< double > > value)
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig