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<L1TGlobalPrescalesVetos>;
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<int> >
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++) {
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<unsigned int> prescalesForSet =
181 settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
col.first.c_str());
182 for (
unsigned int row = 0; row < prescalesForSet.size(); row++) {
183 unsigned int 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) {
246 edm::LogError(
"L1TGlobalPrescalesVetosESProducer") <<
"\nCould not find veto mask file: " << m_vetomaskFile
247 <<
"\nDeafulting the veto mask for all triggers to 1 (unmasked)";
249 while (!input_mask_veto.eof()) {
251 getline(input_mask_veto,
tmp,
'\n');
252 xmlPayload_mask_veto.append(
tmp);
257 ts_mask_veto.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
264 const std::map<std::string, l1t::Parameter>& settings_mask_veto = ts_mask_veto.
getParameters(
"uGtProcessor");
265 std::vector<unsigned int> algo_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"algo");
266 std::vector<unsigned int> veto_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"veto");
268 for (
unsigned int row = 0; row < algo_mask_veto.size(); row++) {
269 unsigned int algoBit = algo_mask_veto[row];
270 unsigned int veto = veto_mask_veto[row];
272 triggerVetoMasks[algoBit] =
int(
veto);
275 input_mask_veto.close();
280 std::ifstream input_mask_algobx;
281 input_mask_algobx.open(m_algobxmaskFile);
282 if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
284 <<
"\nCould not find bx mask file: " << m_algobxmaskFile <<
"\nNot filling the bx mask map";
286 while (!input_mask_algobx.eof()) {
288 getline(input_mask_algobx,
tmp,
'\n');
289 xmlPayload_mask_algobx.append(
tmp);
294 ts_mask_algobx.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
301 const std::map<std::string, l1t::Parameter>& settings_mask_algobx = ts_mask_algobx.
getParameters(
"uGtProcessor");
302 std::map<std::string, unsigned int> mask_algobx_columns =
303 settings_mask_algobx.at(
"algorithmBxMask").getColumnIndices();
304 std::vector<unsigned int> bunches =
305 settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(
"bx/algo");
307 unsigned int numCol_mask_algobx = mask_algobx_columns.size();
309 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
310 for (
int iBit = 0; iBit < NumAlgoBitsInMask; iBit++) {
311 std::vector<unsigned int>
algo =
312 settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(
std::to_string(iBit).c_str());
313 for (
unsigned int bx = 0;
bx < bunches.size();
bx++) {
315 triggerAlgoBxMaskAlgoTrig[bunches[
bx]].
push_back(iBit);
319 input_mask_algobx.close();
323 for (
unsigned int iBit = 0; iBit <
prescale.size(); iBit++) {
325 if (iBit >= triggerMasks.size()) {
326 edm::LogWarning(
"L1TGlobal") <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() " 327 <<
"\nWarning: no information on masking bit or not, setting as unmasked " 330 prescale[iBit] *= triggerMasks[iBit];
360 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
362 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
368 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
373 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
375 LogDebug(
"L1TGlobal") <<
"\t(empty map)" << std::endl;
377 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
378 std::vector<int> masked = it.second;
379 for (
int& iAlg : masked) {
380 LogDebug(
"L1TGlobal") <<
" " << iAlg;
382 LogDebug(
"L1TGlobal") <<
" " << std::endl;
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
void setConfigured(bool state=true) noexcept
T getParameter(std::string const &) const
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
std::string fullPath() const
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
unsigned int m_numberPhysTriggers
std::string to_string(const V &value)
Log< level::Error, false > LogError
L1TGlobalPrescalesVetosESProducer(const edm::ParameterSet &)
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
const std::map< std::string, Parameter > & getParameters(const char *processor) const
~L1TGlobalPrescalesVetosESProducer() override
void setTriggerMaskVeto(std::vector< int > value)
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
PrescalesVetosHelper data_
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
ReturnType produce(const L1TGlobalPrescalesVetosRcd &)
void setBxMaskDefault(int value)
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
std::unique_ptr< L1TGlobalPrescalesVetos > ReturnType
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
Log< level::Warning, false > LogWarning
L1TGlobalPrescalesVetos * getWriteInstance()