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( !input_prescale ){
137 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
138 <<
"\nCould not find file: " << m_prescaleFile
139 <<
"\nFilling the prescale vectors with prescale 1"
143 prescales.push_back(std::vector<int>());
145 int inputDefaultPrescale = 1;
146 prescales[
col].push_back(inputDefaultPrescale);
151 while( !input_prescale.eof() ){
153 getline( input_prescale, tmp,
'\n' );
154 xmlPayload_prescale.append( tmp );
159 ts_prescale.
addProcRole(
"uGtProcessor",
"uGtProcessor");
166 std::map<string, l1t::Setting> settings_prescale = ts_prescale.
getSettings(
"uGtProcessor");
167 std::vector<l1t::TableRow> tRow_prescale = settings_prescale[
"prescales"].getTableRows();
169 unsigned int numColumns_prescale = 0;
170 if( tRow_prescale.size()>0 ){
171 std::vector<std::string> firstRow_prescale = tRow_prescale[0].getRow();
172 numColumns_prescale = firstRow_prescale.size();
175 int NumPrescaleSets = numColumns_prescale - 1;
176 int NumAlgos_prescale = tRow_prescale.size();
178 if( NumPrescaleSets > 0 ){
180 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
181 prescales.push_back(std::vector<int>());
182 for(
int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
183 int inputDefaultPrescale = 1;
184 prescales[iSet].push_back(inputDefaultPrescale);
188 for(
auto it=tRow_prescale.begin(); it!=tRow_prescale.end(); it++ ){
189 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo/prescale-index");
190 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
191 int prescale = it->getRowValue<
unsigned int>(std::to_string(iSet));
192 prescales[iSet][algoBit] = prescale;
198 input_prescale.close();
208 triggerMasks.push_back(1);
211 std::ifstream input_mask_finor;
212 input_mask_finor.open( m_finormaskFile );
213 if( !input_mask_finor ){
214 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
215 <<
"\nCould not find file: " << m_finormaskFile
216 <<
"\nFilling the finor mask vectors with 1 (unmask)"
220 while( !input_mask_finor.eof() ){
222 getline( input_mask_finor, tmp,
'\n' );
223 xmlPayload_mask_finor.append( tmp );
228 ts_mask_finor.
addProcRole(
"uGtProcessor",
"uGtProcessor");
235 std::map<string, l1t::Setting> settings_mask_finor = ts_mask_finor.
getSettings(
"uGtProcessor");
237 std::vector<l1t::TableRow> tRow_mask_finor = settings_mask_finor[
"finorMask"].getTableRows();
239 for(
auto it=tRow_mask_finor.begin(); it!=tRow_mask_finor.end(); it++ ){
240 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo");
241 unsigned int mask = it->getRowValue<
unsigned int>(
"mask");
242 if( algoBit < m_numberPhysTriggers ) triggerMasks[algoBit] = mask;
245 input_mask_finor.close();
253 triggerVetoMasks.push_back(0);
255 std::ifstream input_mask_veto;
256 input_mask_veto.open( m_vetomaskFile );
257 if( !input_mask_veto ){
258 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
259 <<
"\nCould not find file: " << m_vetomaskFile
260 <<
"\nFilling the veto mask vectors with 1 (unmask)"
264 while( !input_mask_veto.eof() ){
266 getline( input_mask_veto, tmp,
'\n' );
267 xmlPayload_mask_veto.append( tmp );
272 ts_mask_veto.
addProcRole(
"uGtProcessor",
"uGtProcessor");
279 std::map<string, l1t::Setting> settings_mask_veto = ts_mask_veto.
getSettings(
"uGtProcessor");
280 std::vector<l1t::TableRow> tRow_mask_veto = settings_mask_veto[
"vetoMask"].getTableRows();
282 for(
auto it=tRow_mask_veto.begin(); it!=tRow_mask_veto.end(); it++ ){
283 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo");
284 unsigned int veto = it->getRowValue<
unsigned int>(
"veto");
285 if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] = int(veto);
288 input_mask_veto.close();
293 std::ifstream input_mask_algobx;
294 input_mask_algobx.open( m_algobxmaskFile );
295 if( !input_mask_algobx ){
296 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
297 <<
"\nCould not find file: " << m_algobxmaskFile
298 <<
"\nNot filling map"
302 while( !input_mask_algobx.eof() ){
304 getline( input_mask_algobx, tmp,
'\n' );
305 xmlPayload_mask_algobx.append( tmp );
310 ts_mask_algobx.
addProcRole(
"uGtProcessor",
"uGtProcessor");
317 std::map<string, l1t::Setting> settings_mask_algobx = ts_mask_algobx.
getSettings(
"uGtProcessor");
318 std::vector<l1t::TableRow> tRow_mask_algobx = settings_mask_algobx[
"algorithmBxMask"].getTableRows();
320 unsigned int numCol_mask_algobx = 0;
321 if( tRow_mask_algobx.size()>0 ){
322 std::vector<std::string> firstRow_mask_algobx = tRow_mask_algobx[0].getRow();
323 numCol_mask_algobx = firstRow_mask_algobx.size();
326 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
327 if( NumAlgoBitsInMask > 0 ){
328 for(
auto it=tRow_mask_algobx.begin(); it!=tRow_mask_algobx.end(); it++ ){
329 int bx = it->getRowValue<
unsigned int>(
"bx/algo");
330 std::vector<int> maskedBits;
331 for(
int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
332 unsigned int maskBit = it->getRowValue<
unsigned int>(std::to_string(iBit));
335 if( maskedBits.size()>0 ) triggerAlgoBxMaskAlgoTrig[bx] = maskedBits;
340 input_mask_algobx.close();
344 for(
unsigned int iSet=0; iSet < prescales.size(); iSet++ ){
345 for(
unsigned int iBit=0; iBit < prescales[iSet].size(); iBit++ ){
347 if( iBit >= triggerMasks.size() ){
349 <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() "
350 <<
"\nWarning: no information on masking bit or not, setting as unmasked "
354 prescales[iSet][iBit] *= triggerMasks[iBit];
391 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
393 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
399 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
404 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
407 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
408 std::vector<int> masked = it.second;
409 for(
unsigned int iAlg=0; iAlg < masked.size(); iAlg++ ){
410 LogDebug(
"L1TGlobal") <<
" " << masked[iAlg];
412 LogDebug(
"L1TGlobal") <<
" " << std::endl;
417 using namespace edm::es;
T getParameter(std::string const &) const
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
~L1TGlobalPrescalesVetosESProducer()
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)
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()