13 #include "boost/shared_ptr.hpp"
20 #include "tmEventSetup/tmEventSetup.hh"
21 #include "tmEventSetup/esTriggerMenu.hh"
22 #include "tmEventSetup/esAlgorithm.hh"
23 #include "tmEventSetup/esCondition.hh"
24 #include "tmEventSetup/esObject.hh"
25 #include "tmEventSetup/esCut.hh"
26 #include "tmEventSetup/esScale.hh"
27 #include "tmGrammar/Algorithm.hh"
58 typedef boost::shared_ptr<L1TGlobalPrescalesVetos>
ReturnType;
111 edm::FileInPath f1_prescale(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + prescalesFileName);
112 std::string m_prescaleFile = f1_prescale.fullPath();
114 edm::FileInPath f1_mask_algobx(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + algobxmaskFileName);
117 edm::FileInPath f1_mask_finor(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + finormaskFileName);
120 edm::FileInPath f1_mask_veto(
"L1Trigger/L1TGlobal/data/Luminosity/" + menuDir +
"/" + vetomaskFileName);
129 std::vector<std::vector<int> >
prescales;
130 std::vector<unsigned int> triggerMasks;
131 std::vector<int> triggerVetoMasks;
132 std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
135 std::ifstream input_prescale;
136 input_prescale.open( m_prescaleFile );
137 if( !input_prescale ){
138 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
139 <<
"\nCould not find file: " << m_prescaleFile
140 <<
"\nFilling the prescale vectors with prescale 1"
144 prescales.push_back(std::vector<int>());
146 int inputDefaultPrescale = 1;
147 prescales[
col].push_back(inputDefaultPrescale);
152 while( !input_prescale.eof() ){
154 getline( input_prescale, tmp,
'\n' );
155 xmlPayload_prescale.append( tmp );
160 ts_prescale.
addProcRole(
"uGtProcessor",
"uGtProcessor");
167 std::map<string, l1t::Setting> settings_prescale = ts_prescale.
getSettings(
"uGtProcessor");
168 std::vector<l1t::TableRow> tRow_prescale = settings_prescale[
"prescales"].getTableRows();
170 unsigned int numColumns_prescale = 0;
171 if( tRow_prescale.size()>0 ){
172 std::vector<std::string> firstRow_prescale = tRow_prescale[0].getRow();
173 numColumns_prescale = firstRow_prescale.size();
176 int NumPrescaleSets = numColumns_prescale - 1;
177 int NumAlgos_prescale = tRow_prescale.size();
179 if( NumPrescaleSets > 0 ){
181 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
182 prescales.push_back(std::vector<int>());
183 for(
int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
184 int inputDefaultPrescale = 1;
185 prescales[iSet].push_back(inputDefaultPrescale);
189 for(
auto it=tRow_prescale.begin(); it!=tRow_prescale.end(); it++ ){
190 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo/prescale-index");
191 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
192 int prescale = it->getRowValue<
unsigned int>(std::to_string(iSet));
193 prescales[iSet][algoBit] = prescale;
199 input_prescale.close();
209 triggerMasks.push_back(1);
212 std::ifstream input_mask_finor;
213 input_mask_finor.open( m_finormaskFile );
214 if( !input_mask_finor ){
215 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
216 <<
"\nCould not find file: " << m_finormaskFile
217 <<
"\nFilling the finor mask vectors with 1 (unmask)"
221 while( !input_mask_finor.eof() ){
223 getline( input_mask_finor, tmp,
'\n' );
224 xmlPayload_mask_finor.append( tmp );
229 ts_mask_finor.
addProcRole(
"uGtProcessor",
"uGtProcessor");
236 std::map<string, l1t::Setting> settings_mask_finor = ts_mask_finor.
getSettings(
"uGtProcessor");
238 std::vector<l1t::TableRow> tRow_mask_finor = settings_mask_finor[
"finorMask"].getTableRows();
240 for(
auto it=tRow_mask_finor.begin(); it!=tRow_mask_finor.end(); it++ ){
241 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo");
242 unsigned int mask = it->getRowValue<
unsigned int>(
"mask");
243 if( algoBit < m_numberPhysTriggers ) triggerMasks[algoBit] = mask;
246 input_mask_finor.close();
254 triggerVetoMasks.push_back(0);
256 std::ifstream input_mask_veto;
257 input_mask_veto.open( m_vetomaskFile );
258 if( !input_mask_veto ){
259 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
260 <<
"\nCould not find file: " << m_vetomaskFile
261 <<
"\nFilling the veto mask vectors with 1 (unmask)"
265 while( !input_mask_veto.eof() ){
267 getline( input_mask_veto, tmp,
'\n' );
268 xmlPayload_mask_veto.append( tmp );
273 ts_mask_veto.
addProcRole(
"uGtProcessor",
"uGtProcessor");
280 std::map<string, l1t::Setting> settings_mask_veto = ts_mask_veto.
getSettings(
"uGtProcessor");
281 std::vector<l1t::TableRow> tRow_mask_veto = settings_mask_veto[
"vetoMask"].getTableRows();
283 for(
auto it=tRow_mask_veto.begin(); it!=tRow_mask_veto.end(); it++ ){
284 unsigned int algoBit = it->getRowValue<
unsigned int>(
"algo");
285 unsigned int veto = it->getRowValue<
unsigned int>(
"veto");
286 if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] = int(veto);
289 input_mask_veto.close();
294 std::ifstream input_mask_algobx;
295 input_mask_algobx.open( m_algobxmaskFile );
296 if( !input_mask_algobx ){
297 LogTrace(
"L1TGlobalPrescalesVetosESProducer")
298 <<
"\nCould not find file: " << m_algobxmaskFile
299 <<
"\nNot filling map"
303 while( !input_mask_algobx.eof() ){
305 getline( input_mask_algobx, tmp,
'\n' );
306 xmlPayload_mask_algobx.append( tmp );
311 ts_mask_algobx.
addProcRole(
"uGtProcessor",
"uGtProcessor");
318 std::map<string, l1t::Setting> settings_mask_algobx = ts_mask_algobx.
getSettings(
"uGtProcessor");
319 std::vector<l1t::TableRow> tRow_mask_algobx = settings_mask_algobx[
"algorithmBxMask"].getTableRows();
321 unsigned int numCol_mask_algobx = 0;
322 if( tRow_mask_algobx.size()>0 ){
323 std::vector<std::string> firstRow_mask_algobx = tRow_mask_algobx[0].getRow();
324 numCol_mask_algobx = firstRow_mask_algobx.size();
327 int NumAlgoBitsInMask = numCol_mask_algobx - 1;
328 if( NumAlgoBitsInMask > 0 ){
329 for(
auto it=tRow_mask_algobx.begin(); it!=tRow_mask_algobx.end(); it++ ){
330 int bx = it->getRowValue<
unsigned int>(
"bx/algo");
331 std::vector<int> maskedBits;
332 for(
int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
333 unsigned int maskBit = it->getRowValue<
unsigned int>(std::to_string(iBit));
336 if( maskedBits.size()>0 ) triggerAlgoBxMaskAlgoTrig[bx] = maskedBits;
341 input_mask_algobx.close();
345 for(
unsigned int iSet=0; iSet < prescales.size(); iSet++ ){
346 for(
unsigned int iBit=0; iBit < prescales[iSet].size(); iBit++ ){
348 if( iBit >= triggerMasks.size() ){
350 <<
"\nWarning: algoBit in prescale table >= triggerMasks.size() "
351 <<
"\nWarning: no information on masking bit or not, setting as unmasked "
355 prescales[iSet][iBit] *= triggerMasks[iBit];
392 LogDebug(
"L1TGlobal") <<
" ====> Prescales table <=== " << std::endl;
394 LogDebug(
"L1TGlobal") <<
" Prescale set = " << ix << std::endl;
400 LogDebug(
"L1TGlobal") <<
" ====> Trigger mask veto <=== " << std::endl;
405 LogDebug(
"L1TGlobal") <<
" ====> Algo bx mask <=== " << std::endl;
408 LogDebug(
"L1TGlobal") <<
" bx = " << it.first <<
" : iAlg =";
409 std::vector<int> masked = it.second;
410 for(
unsigned int iAlg=0; iAlg < masked.size(); iAlg++ ){
411 LogDebug(
"L1TGlobal") <<
" " << masked[iAlg];
413 LogDebug(
"L1TGlobal") <<
" " << std::endl;
418 using namespace edm::es;
419 boost::shared_ptr<L1TGlobalPrescalesVetos> pMenu = boost::shared_ptr< L1TGlobalPrescalesVetos >(
data_.
getWriteInstance());
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="")
boost::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()