19 #include "tmEventSetup/tmEventSetup.hh" 20 #include "tmEventSetup/esTriggerMenu.hh" 21 #include "tmEventSetup/esAlgorithm.hh" 22 #include "tmEventSetup/esCondition.hh" 23 #include "tmEventSetup/esObject.hh" 24 #include "tmEventSetup/esCut.hh" 25 #include "tmEventSetup/esScale.hh" 26 #include "tmGrammar/Algorithm.hh" 56 using ReturnType = std::unique_ptr<L1TGlobalPrescalesVetos>;
109 edm::FileInPath f1_prescale(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + prescalesFileName);
110 std::string m_prescaleFile = f1_prescale.fullPath();
112 edm::FileInPath f1_mask_algobx(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + algobxmaskFileName);
115 edm::FileInPath f1_mask_finor(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + finormaskFileName);
118 edm::FileInPath f1_mask_veto(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + vetomaskFileName);
128 std::vector<std::vector<int> > prescales;
129 std::vector<unsigned int> triggerMasks;
130 std::vector<int> triggerVetoMasks;
131 std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
134 std::ifstream input_prescale;
135 input_prescale.open( m_prescaleFile );
136 if (not m_prescaleFile.empty() and not input_prescale) {
138 <<
"\nCould not find prescale file: " << m_prescaleFile
139 <<
"\nDeafulting to a single prescale column, with all prescales set to 1 (unprescaled)";
141 const int inputDefaultPrescale = 1;
146 while( !input_prescale.eof() ){
148 getline( input_prescale, tmp,
'\n' );
149 xmlPayload_prescale.append( tmp );
154 ts_prescale.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
161 const std::map<std::string, l1t::Parameter> &settings_prescale = ts_prescale.
getParameters(
"uGtProcessor");
162 std::map<std::string,unsigned int> prescaleColumns = settings_prescale.at(
"prescales").getColumnIndices();
164 unsigned int numColumns_prescale = prescaleColumns.size();
166 int NumPrescaleSets = numColumns_prescale - 1;
168 std::vector<unsigned int> algoBits = settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
"algo/prescale-index");
169 int NumAlgos_prescale = *std::max_element(algoBits.begin(), algoBits.end()) + 1;
171 if( NumPrescaleSets > 0 ){
173 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
174 prescales.push_back(std::vector<int>());
175 for(
int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
176 int inputDefaultPrescale = 0;
177 prescales[iSet].push_back(inputDefaultPrescale);
181 for(
auto &
col : prescaleColumns){
182 if(
col.second<1 )
continue;
183 int iSet =
col.second - 1;
184 std::vector<unsigned int> prescalesForSet = settings_prescale.at(
"prescales").getTableColumn<
unsigned int>(
col.first.c_str());
185 for(
unsigned int row=0; row<prescalesForSet.size(); row++){
186 unsigned int prescale = prescalesForSet[row];
187 unsigned int algoBit = algoBits[row];
188 prescales[iSet][algoBit] = prescale;
193 input_prescale.close();
202 std::ifstream input_mask_finor;
203 input_mask_finor.open( m_finormaskFile );
204 if (not m_finormaskFile.empty() and not input_mask_finor) {
206 <<
"\nCould not find finor mask file: " << m_finormaskFile
207 <<
"\nDeafulting the finor mask for all triggers to 1 (unmasked)";
210 while( !input_mask_finor.eof() ){
212 getline( input_mask_finor, tmp,
'\n' );
213 xmlPayload_mask_finor.append( tmp );
218 ts_mask_finor.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
225 const std::map<std::string, l1t::Parameter>& settings_mask_finor = ts_mask_finor.
getParameters(
"uGtProcessor");
227 std::vector<unsigned int> algo_mask_finor = settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"algo");
228 std::vector<unsigned int> mask_mask_finor = settings_mask_finor.at(
"finorMask").getTableColumn<
unsigned int>(
"mask");
230 for(
unsigned int row=0; row<algo_mask_finor.size(); row++){
231 unsigned int algoBit = algo_mask_finor[row];
232 unsigned int mask = mask_mask_finor[row];
236 input_mask_finor.close();
244 triggerVetoMasks.push_back(0);
246 std::ifstream input_mask_veto;
247 input_mask_veto.open( m_vetomaskFile );
248 if (not m_vetomaskFile.empty() and not input_mask_veto) {
250 <<
"\nCould not find veto mask file: " << m_vetomaskFile
251 <<
"\nDeafulting the veto mask for all triggers to 1 (unmasked)";
254 while( !input_mask_veto.eof() ){
256 getline( input_mask_veto, tmp,
'\n' );
257 xmlPayload_mask_veto.append( tmp );
262 ts_mask_veto.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
269 const std::map<std::string, l1t::Parameter>& settings_mask_veto = ts_mask_veto.
getParameters(
"uGtProcessor");
270 std::vector<unsigned int> algo_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"algo");
271 std::vector<unsigned int> veto_mask_veto = settings_mask_veto.at(
"vetoMask").getTableColumn<
unsigned int>(
"veto");
273 for(
unsigned int row=0; row<algo_mask_veto.size(); row++){
274 unsigned int algoBit = algo_mask_veto[row];
275 unsigned int veto = veto_mask_veto[row];
276 if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] =
int(veto);
279 input_mask_veto.close();
284 std::ifstream input_mask_algobx;
285 input_mask_algobx.open( m_algobxmaskFile );
286 if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
288 <<
"\nCould not find bx mask file: " << m_algobxmaskFile
289 <<
"\nNot filling the bx mask map";
292 while( !input_mask_algobx.eof() ){
294 getline( input_mask_algobx, tmp,
'\n' );
295 xmlPayload_mask_algobx.append( tmp );
300 ts_mask_algobx.
addProcessor(
"uGtProcessor",
"uGtProcessor",
"-1",
"-1");
307 const std::map<std::string, l1t::Parameter>& settings_mask_algobx = ts_mask_algobx.
getParameters(
"uGtProcessor");
308 std::map<std::string,unsigned int> mask_algobx_columns = settings_mask_algobx.at(
"algorithmBxMask").getColumnIndices();
309 std::vector<unsigned int> bunches = settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(
"bx/algo");
311 unsigned int numCol_mask_algobx = mask_algobx_columns.size();
313 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
314 for(
int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
315 std::vector<unsigned int>
algo = settings_mask_algobx.at(
"algorithmBxMask").getTableColumn<
unsigned int>(std::to_string(iBit).c_str());
316 for(
unsigned int bx=0; bx<bunches.size(); bx++){
317 if( algo[bx]!=
unsigned(m_bx_mask_default) ) triggerAlgoBxMaskAlgoTrig[ bunches[bx] ].push_back(iBit);
321 input_mask_algobx.close();
326 for(
unsigned int iBit=0; iBit <
prescale.size(); iBit++ ){
328 if( iBit >= triggerMasks.size() ){
330 <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() " 331 <<
"\nWarning: no information on masking bit or not, setting as unmasked " 335 prescale[iBit] *= triggerMasks[iBit];
372 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
374 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
380 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
385 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
388 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
389 std::vector<int> masked = it.second;
390 for(
int & iAlg : masked){
391 LogDebug(
"L1TGlobal") <<
" " << iAlg;
393 LogDebug(
"L1TGlobal") <<
" " << std::endl;
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
void setConfigured(bool state=true) noexcept
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
unsigned int m_numberPhysTriggers
L1TGlobalPrescalesVetosESProducer(const edm::ParameterSet &)
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
~L1TGlobalPrescalesVetosESProducer() override
void setTriggerMaskVeto(std::vector< int > value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
PrescalesVetosHelper data_
const std::map< std::string, Parameter > & getParameters(const char *processor) const
ReturnType produce(const L1TGlobalPrescalesVetosRcd &)
std::vector< std::vector< double > > tmp
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
std::string fullPath() const
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
L1TGlobalPrescalesVetos * getWriteInstance()