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" 57 typedef std::shared_ptr<L1TGlobalPrescalesVetos>
ReturnType;
110 edm::FileInPath f1_prescale(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + prescalesFileName);
111 std::string m_prescaleFile = f1_prescale.fullPath();
113 edm::FileInPath f1_mask_algobx(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + algobxmaskFileName);
116 edm::FileInPath f1_mask_finor(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + finormaskFileName);
119 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.
addProcRole(
"uGtProcessor",
"uGtProcessor");
161 std::map<string, l1t::Setting> settings_prescale = ts_prescale.
getSettings(
"uGtProcessor");
162 std::vector<l1t::TableRow> tRow_prescale = settings_prescale[
"prescales"].getTableRows();
164 unsigned int numColumns_prescale = 0;
165 if( tRow_prescale.size()>0 ){
166 std::vector<std::string> firstRow_prescale = tRow_prescale[0].getRow();
167 numColumns_prescale = firstRow_prescale.size() - 1;
170 if (numColumns_prescale > 0) {
172 const int inputDefaultPrescale = 1;
173 for (
unsigned int iSet=0; iSet<numColumns_prescale; ++iSet)
176 for (
auto & row : tRow_prescale) {
177 unsigned int algoBit = row.getRowValue<
unsigned int>(
"algo/prescale-index");
178 for (
unsigned int iSet=0; iSet<numColumns_prescale; ++iSet) {
179 int prescale = row.getRowValue<
unsigned int>(std::to_string(iSet));
180 prescales[iSet][algoBit] = prescale;
186 input_prescale.close();
197 std::ifstream input_mask_finor;
198 input_mask_finor.open( m_finormaskFile );
199 if (not m_finormaskFile.empty() and not input_mask_finor) {
201 <<
"\nCould not find finor mask file: " << m_finormaskFile
202 <<
"\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.
addProcRole(
"uGtProcessor",
"uGtProcessor");
220 std::map<string, l1t::Setting> settings_mask_finor = ts_mask_finor.
getSettings(
"uGtProcessor");
222 std::vector<l1t::TableRow> tRow_mask_finor = settings_mask_finor[
"finorMask"].getTableRows();
224 for (
auto & row : tRow_mask_finor) {
225 unsigned int algoBit = row.getRowValue<
unsigned int>(
"algo");
226 unsigned int mask = row.getRowValue<
unsigned int>(
"mask");
228 triggerMasks[algoBit] =
mask;
231 input_mask_finor.close();
239 triggerVetoMasks.push_back(0);
241 std::ifstream input_mask_veto;
242 input_mask_veto.open( m_vetomaskFile );
243 if (not m_vetomaskFile.empty() and not input_mask_veto) {
245 <<
"\nCould not find veto mask file: " << m_vetomaskFile
246 <<
"\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.
addProcRole(
"uGtProcessor",
"uGtProcessor");
264 std::map<string, l1t::Setting> settings_mask_veto = ts_mask_veto.
getSettings(
"uGtProcessor");
265 std::vector<l1t::TableRow> tRow_mask_veto = settings_mask_veto[
"vetoMask"].getTableRows();
267 for(
auto & row : tRow_mask_veto){
268 unsigned int algoBit = row.getRowValue<
unsigned int>(
"algo");
269 unsigned int veto = row.getRowValue<
unsigned int>(
"veto");
270 if (algoBit < m_numberPhysTriggers) triggerVetoMasks[algoBit] =
int(veto);
273 input_mask_veto.close();
278 std::ifstream input_mask_algobx;
279 input_mask_algobx.open( m_algobxmaskFile );
280 if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
282 <<
"\nCould not find bx mask file: " << m_algobxmaskFile
283 <<
"\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.
addProcRole(
"uGtProcessor",
"uGtProcessor");
301 std::map<string, l1t::Setting> settings_mask_algobx = ts_mask_algobx.
getSettings(
"uGtProcessor");
302 std::vector<l1t::TableRow> tRow_mask_algobx = settings_mask_algobx[
"algorithmBxMask"].getTableRows();
304 unsigned int numCol_mask_algobx = 0;
305 if( tRow_mask_algobx.size()>0 ){
306 std::vector<std::string> firstRow_mask_algobx = tRow_mask_algobx[0].getRow();
307 numCol_mask_algobx = firstRow_mask_algobx.size();
310 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
311 if( NumAlgoBitsInMask > 0 ){
312 for(
auto & row : tRow_mask_algobx){
313 int bx = row.getRowValue<
unsigned int>(
"bx/algo");
314 std::vector<int> maskedBits;
315 for(
int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
316 unsigned int maskBit = row.getRowValue<
unsigned int>(std::to_string(iBit));
319 if( maskedBits.size()>0 ) triggerAlgoBxMaskAlgoTrig[bx] = maskedBits;
324 input_mask_algobx.close();
328 for(
auto & prescale : prescales){
329 for(
unsigned int iBit=0; iBit < prescale.size(); iBit++ ){
331 if( iBit >= triggerMasks.size() ){
333 <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() " 334 <<
"\nWarning: no information on masking bit or not, setting as unmasked " 338 prescale[iBit] *= triggerMasks[iBit];
375 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
377 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
383 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
388 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
391 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
392 std::vector<int> masked = it.second;
393 for(
int & iAlg : masked){
394 LogDebug(
"L1TGlobal") <<
" " << iAlg;
396 LogDebug(
"L1TGlobal") <<
" " << std::endl;
T getParameter(std::string const &) const
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
unsigned int m_numberPhysTriggers
void readRootElement(TrigSystem &aTrigSystem, const std::string &sysId="")
std::shared_ptr< L1TGlobalPrescalesVetos > ReturnType
L1TGlobalPrescalesVetosESProducer(const edm::ParameterSet &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
void addProcRole(const std::string &processor, const std::string &role)
~L1TGlobalPrescalesVetosESProducer() override
void setConfigured(const bool state=true)
void setTriggerMaskVeto(std::vector< int > value)
std::map< std::string, Setting > getSettings(const std::string &processor)
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
PrescalesVetosHelper data_
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
ReturnType produce(const L1TGlobalPrescalesVetosRcd &)
std::vector< std::vector< double > > tmp
void setBxMaskDefault(int value)
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
std::string fullPath() const
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
L1TGlobalPrescalesVetos * getWriteInstance()