28 edm::LogInfo(
"L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) <<
"Producing L1TGlobalPrescalesVetos with RS key = " << objectKey ;
30 if( objectKey.empty() ){
31 edm::LogError(
"L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) <<
"Key is empty";
32 throw std::runtime_error(
"Empty objecKey");
35 std::vector< std::string > queryColumns ;
36 queryColumns.push_back(
"ALGOBX_MASK" ) ;
37 queryColumns.push_back(
"ALGO_FINOR_MASK" ) ;
38 queryColumns.push_back(
"ALGO_FINOR_VETO" ) ;
39 queryColumns.push_back(
"ALGO_PRESCALE" ) ;
41 std::string prescale_key, bxmask_key, mask_key, vetomask_key;
42 std::string xmlPayload_prescale, xmlPayload_mask_algobx, xmlPayload_mask_finor, xmlPayload_mask_veto;
45 prescale_key = subKeys[
"ALGO_PRESCALE"];
46 bxmask_key = subKeys[
"ALGOBX_MASK"];
47 mask_key = subKeys[
"ALGO_FINOR_MASK"];
48 vetomask_key = subKeys[
"ALGO_FINOR_VETO"];
53 }
catch ( std::runtime_error &
e ) {
54 edm::LogError(
"L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << e.what();
55 throw std::runtime_error(
"Broken key");
60 std::ofstream output1(
std::string(
"/tmp/").
append(prescale_key.substr(0,prescale_key.find(
"/"))).append(
".xml"));
61 output1<<xmlPayload_prescale;
63 std::ofstream output2(
std::string(
"/tmp/").
append(mask_key.substr(0,mask_key.find(
"/"))).append(
".xml"));
64 output2<<xmlPayload_mask_finor;
66 std::ofstream output3(
std::string(
"/tmp/").
append(bxmask_key.substr(0,bxmask_key.find(
"/"))).append(
".xml"));
67 output3<<xmlPayload_mask_algobx;
69 std::ofstream output4(
std::string(
"/tmp/").
append(vetomask_key.substr(0,vetomask_key.find(
"/"))).append(
".xml"));
70 output4<<xmlPayload_mask_veto;
75 unsigned int m_numberPhysTriggers = 512;
76 unsigned int m_bx_mask_default = 1;
79 std::vector<std::vector<int> > prescales;
80 std::vector<unsigned int> triggerMasks;
81 std::vector<int> triggerVetoMasks;
82 std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
87 ts_prescale.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
94 const std::map<std::string, l1t::Parameter> &settings_prescale = ts_prescale.
getParameters(
"uGtProcessor");
95 std::map<std::string,unsigned int> prescaleColumns = settings_prescale.at(
"prescales").getColumnIndices();
97 unsigned int numColumns_prescale = prescaleColumns.size();
99 int NumPrescaleSets = numColumns_prescale - 1;
101 std::vector<unsigned int> algoBits = settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
"algo/prescale-index");
102 int NumAlgos_prescale = *std::max_element(algoBits.begin(), algoBits.end()) + 1;
104 if( NumPrescaleSets > 0 ){
106 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
107 prescales.push_back(std::vector<int>());
108 for(
int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
109 int inputDefaultPrescale = 0;
110 prescales[iSet].push_back(inputDefaultPrescale);
114 for(
auto &
col : prescaleColumns){
115 if(
col.second<1 )
continue;
116 int iSet =
col.second - 1;
117 std::vector<unsigned int> prescalesForSet = settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
col.first.c_str());
118 for(
unsigned int row=0; row<prescalesForSet.size(); row++){
119 unsigned int prescale = prescalesForSet[row];
120 unsigned int algoBit = algoBits[row];
121 prescales[iSet][algoBit] = prescale;
131 for(
unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++ )
132 triggerMasks.push_back(1);
136 ts_mask_finor.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
143 const std::map<std::string, l1t::Parameter>& settings_mask_finor = ts_mask_finor.
getParameters(
"uGtProcessor");
145 std::vector<unsigned int> algo_mask_finor = settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"algo");
146 std::vector<unsigned int> mask_mask_finor = settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"mask");
148 for(
unsigned int row=0; row<algo_mask_finor.size(); row++){
149 unsigned int algoBit = algo_mask_finor[row];
150 unsigned int mask = mask_mask_finor[row];
151 if( algoBit < m_numberPhysTriggers ) triggerMasks[algoBit] =
mask;
158 for(
unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++ )
159 triggerVetoMasks.push_back(0);
163 ts_mask_veto.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
170 const std::map<std::string, l1t::Parameter>& settings_mask_veto = ts_mask_veto.
getParameters(
"uGtProcessor");
171 std::vector<unsigned int> algo_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"algo");
172 std::vector<unsigned int> veto_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"veto");
174 for(
unsigned int row=0; row<algo_mask_veto.size(); row++){
175 unsigned int algoBit = algo_mask_veto[row];
176 unsigned int veto = veto_mask_veto[row];
177 if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] =
int(veto);
185 ts_mask_algobx.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
192 const std::map<std::string, l1t::Parameter>& settings_mask_algobx = ts_mask_algobx.
getParameters(
"uGtProcessor");
193 std::map<std::string,unsigned int> mask_algobx_columns = settings_mask_algobx.at(
"algorithmBxMask").getColumnIndices();
194 std::vector<unsigned int> bunches = settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(
"bx/algo");
196 unsigned int numCol_mask_algobx = mask_algobx_columns.size();
198 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
199 for(
int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
200 std::vector<unsigned int>
algo = settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(std::to_string(iBit).c_str());
201 for(
unsigned int bx=0; bx<bunches.size(); bx++){
202 if( algo[bx]!=m_bx_mask_default ) triggerAlgoBxMaskAlgoTrig[ bunches[bx] ].push_back(iBit);
208 for(
unsigned int iSet=0; iSet < prescales.size(); iSet++ ){
209 for(
unsigned int iBit=0; iBit < prescales[iSet].size(); iBit++ ){
211 if( iBit >= triggerMasks.size() ){
213 <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() " 214 <<
"\nWarning: no information on masking bit or not, setting as unmasked " 218 prescales[iSet][iBit] *= triggerMasks[iBit];
L1TGlobalPrescalesVetosOnlineProd(const edm::ParameterSet &)
void setConfigured(bool state=true) noexcept
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
virtual std::shared_ptr< L1TGlobalPrescalesVetos > newObject(const std::string &objectKey, const L1TGlobalPrescalesVetosO2ORcd &record) override
l1t::OMDSReader m_omdsReader
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
static std::map< std::string, std::string > fetch(const std::vector< std::string > &queryColumns, const std::string &table, const std::string &key, l1t::OMDSReader &m_omdsReader)
void setTriggerMaskVeto(std::vector< int > value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
const std::map< std::string, Parameter > & getParameters(const char *processor) const
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)
~L1TGlobalPrescalesVetosOnlineProd(void)
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
L1TGlobalPrescalesVetos * getWriteInstance()