CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
L1TGlobalPrescalesVetosOnlineProd Class Reference
Inheritance diagram for L1TGlobalPrescalesVetosOnlineProd:
L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos > edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 L1TGlobalPrescalesVetosOnlineProd (const edm::ParameterSet &)
 
virtual boost::shared_ptr
< L1TGlobalPrescalesVetos
newObject (const std::string &objectKey, const L1TGlobalPrescalesVetosO2ORcd &record) override
 
 ~L1TGlobalPrescalesVetosOnlineProd (void)
 
- Public Member Functions inherited from L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos >
 L1ConfigOnlineProdBaseExt (const edm::ParameterSet &)
 
boost::shared_ptr
< L1TGlobalPrescalesVetos
produce (const L1TGlobalPrescalesVetosO2ORcd &iRecord)
 
 ~L1ConfigOnlineProdBaseExt ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider ()
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey,
edm::propagate_const
< std::shared_ptr< DataProxy > > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos >
bool getObjectKey (const L1TGlobalPrescalesVetosO2ORcd &record, boost::shared_ptr< L1TGlobalPrescalesVetos > data, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Attributes inherited from L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos >
bool m_copyFromCondDB
 
cond::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Detailed Description

Definition at line 14 of file L1TGlobalPrescalesVetosOnlineProd.cc.

Constructor & Destructor Documentation

L1TGlobalPrescalesVetosOnlineProd::L1TGlobalPrescalesVetosOnlineProd ( const edm::ParameterSet iConfig)
L1TGlobalPrescalesVetosOnlineProd::~L1TGlobalPrescalesVetosOnlineProd ( void  )
inline

Definition at line 20 of file L1TGlobalPrescalesVetosOnlineProd.cc.

20 {}

Member Function Documentation

boost::shared_ptr< L1TGlobalPrescalesVetos > L1TGlobalPrescalesVetosOnlineProd::newObject ( const std::string &  objectKey,
const L1TGlobalPrescalesVetosO2ORcd record 
)
overridevirtual

return boost::shared_ptr< L1TGlobalPrescalesVetos > ( new L1TGlobalPrescalesVetos() );

return boost::shared_ptr< L1TGlobalPrescalesVetos > ( new L1TGlobalPrescalesVetos() );

return boost::shared_ptr< L1TGlobalPrescalesVetos >() ;

return boost::shared_ptr< L1TGlobalPrescalesVetos >() ;

return boost::shared_ptr< L1TGlobalPrescalesVetos >() ;

return boost::shared_ptr< L1TGlobalPrescalesVetos >() ;

the code below is adopted from https://github.com/cms-l1t-offline/cmssw/blob/thomreis_o2o-dev_CMSSW_8_0_7/L1Trigger/L1TGlobal/plugins/L1TGlobalPrescalesVetosESProducer.cc#L124-L365

there may be "missing" rows/bits in the xml description meaning that triggers are not unused int NumAlgos_prescale = tRow_prescale.size();

Implements L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos >.

Definition at line 25 of file L1TGlobalPrescalesVetosOnlineProd.cc.

References l1t::TrigSystem::addProcRole(), bitset_utilities::append(), l1t::OMDSReader::basicQuery(), alignCSCRings::e, l1t::PrescalesVetosHelper::getWriteInstance(), PrescalesVetos_cff::L1TGlobalPrescalesVetos, L1ConfigOnlineProdBaseExt< L1TGlobalPrescalesVetosO2ORcd, L1TGlobalPrescalesVetos >::m_omdsReader, makeHLTPrescaleTable::prescales, l1t::PrescalesVetosHelper::setBxMaskDefault(), l1t::PrescalesVetosHelper::setPrescaleFactorTable(), l1t::PrescalesVetosHelper::setTriggerAlgoBxMask(), l1t::PrescalesVetosHelper::setTriggerMaskVeto(), l1t::OMDSReader::singleAttribute(), AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::veto.

25  {
26  using namespace edm::es;
27 
28  edm::LogInfo( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Producing L1TGlobalPrescalesVetos with RS key =" << objectKey ;
29 
30  if( objectKey.empty() ){
31  edm::LogInfo( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Key is empty";
32  throw std::runtime_error("Empty objecKey");
34  }
35 
36  std::string stage2Schema = "CMS_TRG_L1_CONF" ;
37 
38  std::vector< std::string > queryStrings ;
39  queryStrings.push_back( "MP7" ) ;
40  queryStrings.push_back( "AMC502_EXTCOND" ) ;
41  queryStrings.push_back( "AMC502_FINOR" ) ;
42  queryStrings.push_back( "ALGOBX_MASK" ) ;
43  queryStrings.push_back( "ALGO_FINOR_MASK" ) ;
44  queryStrings.push_back( "ALGO_FINOR_VETO" ) ;
45  queryStrings.push_back( "ALGO_PRESCALE" ) ;
46 
47  std::string prescale_key, bxmask_key, mask_key, vetomask_key;
48 
49  // select MP7, AMC502_EXTCOND, AMC502_FINOR, ALGOBX_MASK, ALGO_FINOR_MASK, ALGO_FINOR_VETO, ALGO_PRESCALE from CMS_TRG_L1_CONF.UGT_RS_KEYS where ID = objectKey ;
50  l1t::OMDSReader::QueryResults queryResult =
51  m_omdsReader.basicQuery( queryStrings,
52  stage2Schema,
53  "UGT_RS_KEYS",
54  "UGT_RS_KEYS.ID",
55  m_omdsReader.singleAttribute(objectKey)
56  ) ;
57 
58  if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
59  edm::LogError( "L1-O2O" ) << "Cannot get UGT_RS_KEYS.{MP7,AMC502_EXTCOND,AMC502_FINOR,ALGOBX_MASK,ALGO_FINOR_MASK,ALGO_FINOR_VETO,ALGO_PRESCALE} for ID = " << objectKey;
60  throw std::runtime_error("Broken key");
62  }
63 
64  if( !queryResult.fillVariable( "ALGO_PRESCALE", prescale_key) ) prescale_key = "";
65  if( !queryResult.fillVariable( "ALGOBX_MASK", bxmask_key) ) bxmask_key = "";
66  if( !queryResult.fillVariable( "ALGO_FINOR_MASK", mask_key) ) mask_key = "";
67  if( !queryResult.fillVariable( "ALGO_FINOR_VETO", vetomask_key) ) vetomask_key = "";
68 
69  queryStrings.clear();
70  queryStrings.push_back( "CONF" ) ;
71 
72 
73  std::string xmlPayload_prescale, xmlPayload_mask_algobx, xmlPayload_mask_finor, xmlPayload_mask_veto;
74 
75  queryResult =
76  m_omdsReader.basicQuery( queryStrings,
77  stage2Schema,
78  "UGT_RS",
79  "UGT_RS.ID",
80  m_omdsReader.singleAttribute(prescale_key)
81  ) ;
82 
83  if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
84  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Cannot get UGT_RS.CONF for prescale_key = "<<prescale_key ;
85  throw std::runtime_error("Broken key");
87  }
88 
89  if( !queryResult.fillVariable( "CONF", xmlPayload_prescale ) ) xmlPayload_prescale = "";
90 
91 
92  queryResult =
93  m_omdsReader.basicQuery( queryStrings,
94  stage2Schema,
95  "UGT_RS",
96  "UGT_RS.ID",
98  ) ;
99 
100  if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
101  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Cannot get UGT_RS.CONF for mask_key = "<<mask_key ;
102  throw std::runtime_error("Broken key");
104  }
105 
106  if( !queryResult.fillVariable( "CONF", xmlPayload_mask_finor ) ) xmlPayload_mask_finor = "";
107 
108 
109  queryResult =
110  m_omdsReader.basicQuery( queryStrings,
111  stage2Schema,
112  "UGT_RS",
113  "UGT_RS.ID",
114  m_omdsReader.singleAttribute(bxmask_key)
115  ) ;
116 
117  if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
118  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Cannot get UGT_RS.CONF for bxmask_key = "<<bxmask_key ;
119  throw std::runtime_error("Broken key");
121  }
122 
123  if( !queryResult.fillVariable( "CONF", xmlPayload_mask_algobx ) ) xmlPayload_mask_algobx = "";
124 
125 
126  queryResult =
127  m_omdsReader.basicQuery( queryStrings,
128  stage2Schema,
129  "UGT_RS",
130  "UGT_RS.ID",
131  m_omdsReader.singleAttribute(vetomask_key)
132  ) ;
133 
134  if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
135  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" ) << "Cannot get UGT_RS.CONF for vetomask_key = "<<vetomask_key ;
136  throw std::runtime_error("Broken key");
138  }
139 
140  if( !queryResult.fillVariable( "CONF", xmlPayload_mask_veto ) ) xmlPayload_mask_veto = "";
141 
142  // for debugging purposes dump the payloads to /tmp
143  std::ofstream output1(std::string("/tmp/").append(prescale_key.substr(0,prescale_key.find("/"))).append(".xml"));
144  output1<<xmlPayload_prescale;
145  output1.close();
146  std::ofstream output2(std::string("/tmp/").append(mask_key.substr(0,mask_key.find("/"))).append(".xml"));
147  output2<<xmlPayload_mask_finor;
148  output2.close();
149  std::ofstream output3(std::string("/tmp/").append(bxmask_key.substr(0,bxmask_key.find("/"))).append(".xml"));
150  output3<<xmlPayload_mask_algobx;
151  output3.close();
152  std::ofstream output4(std::string("/tmp/").append(vetomask_key.substr(0,vetomask_key.find("/"))).append(".xml"));
153  output4<<xmlPayload_mask_veto;
154  output4.close();
155 
157 
158  unsigned int m_numberPhysTriggers = 512;
159  unsigned int m_bx_mask_default = 1;
160 
161 
162  std::vector<std::vector<int> > prescales;
163  std::vector<unsigned int> triggerMasks;
164  std::vector<int> triggerVetoMasks;
165  std::map<int, std::vector<int> > triggerAlgoBxMaskAlgoTrig;
166 
167  // Prescales
168  l1t::XmlConfigReader xmlReader_prescale;
169  l1t::TrigSystem ts_prescale;
170  ts_prescale.addProcRole("uGtProcessor", "uGtProcessor");
171 
172  // run the parser
173  xmlReader_prescale.readDOMFromString( xmlPayload_prescale ); // initialize it
174  xmlReader_prescale.readRootElement( ts_prescale, "uGT" ); // extract all of the relevant context
175  ts_prescale.setConfigured();
176 
177  std::map<std::string, l1t::Setting> settings_prescale = ts_prescale.getSettings("uGtProcessor");
178  std::vector<l1t::TableRow> tRow_prescale = settings_prescale["prescales"].getTableRows();
179 
180  unsigned int numColumns_prescale = 0;
181  if( tRow_prescale.size()>0 ){
182  std::vector<std::string> firstRow_prescale = tRow_prescale[0].getRow();
183  numColumns_prescale = firstRow_prescale.size();
184  }
185 
186  int NumPrescaleSets = numColumns_prescale - 1;
189  unsigned int NumAlgos_prescale = 0;
190  for( auto it=tRow_prescale.begin(); it!=tRow_prescale.end(); it++ ){
191  unsigned int algoBit = it->getRowValue<unsigned int>("algo/prescale-index");
192  if( NumAlgos_prescale < algoBit+1 ) NumAlgos_prescale = algoBit+1;
193  }
194 
195  if( NumPrescaleSets > 0 ){
196  // Fill default prescale set
197  for( int iSet=0; iSet<NumPrescaleSets; iSet++ ){
198  prescales.push_back(std::vector<int>());
199  for( unsigned int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
200  int inputDefaultPrescale = 0; // only prescales that are set in the block below are used
201  prescales[iSet].push_back(inputDefaultPrescale);
202  }
203  }
204 
205  for( auto it=tRow_prescale.begin(); it!=tRow_prescale.end(); it++ ){
206  unsigned int algoBit = it->getRowValue<unsigned int>("algo/prescale-index");
207  for( int iSet=0; iSet<NumPrescaleSets; iSet++ ){
208  int prescale = 0;
209  try{
210  prescale = it->getRowValue<unsigned int>(std::to_string(iSet));
211  } catch (std::runtime_error &e){
212  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" )
213  << "\nWarning: missing value for algoBit " << algoBit << " (row)"
214  << " in prescale set " << iSet << " (column) of " << prescale_key
215  << " also stored in /tmp/" << prescale_key.substr(0,prescale_key.find("/")).append(".xml")
216  << "\nWarning: no information on algoBit, setting to 0 "
217  << std::endl;
218  }
219  prescales[iSet][algoBit] = prescale;
220  }
221  }
222  }
223 
224 
226 
227  // finor mask
228  // Setting mask to default 1 (unmask)
229  for( unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++ )
230  triggerMasks.push_back(1);
231 
232  l1t::XmlConfigReader xmlReader_mask_finor;
233  l1t::TrigSystem ts_mask_finor;
234  ts_mask_finor.addProcRole("uGtProcessor", "uGtProcessor");
235 
236  // run the parser
237  xmlReader_mask_finor.readDOMFromString( xmlPayload_mask_finor ); // initialize it
238  xmlReader_mask_finor.readRootElement( ts_mask_finor, "uGT" ); // extract all of the relevant context
239  ts_mask_finor.setConfigured();
240 
241  std::map<std::string, l1t::Setting> settings_mask_finor = ts_mask_finor.getSettings("uGtProcessor");
242  std::vector<l1t::TableRow> tRow_mask_finor = settings_mask_finor["finorMask"].getTableRows();
243 
244  for( auto it=tRow_mask_finor.begin(); it!=tRow_mask_finor.end(); it++ ){
245  unsigned int algoBit = it->getRowValue<unsigned int>("algo");
246  unsigned int mask = it->getRowValue<unsigned int>("mask");
247  if( algoBit < m_numberPhysTriggers ) triggerMasks[algoBit] = mask;
248  }
249 
251 
252  // veto mask
253  // Setting veto mask to default 0 (no veto)
254  for( unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++ )
255  triggerVetoMasks.push_back(0);
256 
257  l1t::XmlConfigReader xmlReader_mask_veto;
258  l1t::TrigSystem ts_mask_veto;
259  ts_mask_veto.addProcRole("uGtProcessor", "uGtProcessor");
260 
261  // run the parser
262  xmlReader_mask_veto.readDOMFromString( xmlPayload_mask_veto ); // initialize it
263  xmlReader_mask_veto.readRootElement( ts_mask_veto, "uGT" ); // extract all of the relevant context
264  ts_mask_veto.setConfigured();
265 
266  std::map<std::string, l1t::Setting> settings_mask_veto = ts_mask_veto.getSettings("uGtProcessor");
267  std::vector<l1t::TableRow> tRow_mask_veto = settings_mask_veto["vetoMask"].getTableRows();
268 
269  for( auto it=tRow_mask_veto.begin(); it!=tRow_mask_veto.end(); it++ ){
270  unsigned int algoBit = it->getRowValue<unsigned int>("algo");
271  unsigned int veto = it->getRowValue<unsigned int>("veto");
272  if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] = int(veto);
273  }
274 
276 
277  // Algo bx mask
278  l1t::XmlConfigReader xmlReader_mask_algobx;
279  l1t::TrigSystem ts_mask_algobx;
280  ts_mask_algobx.addProcRole("uGtProcessor", "uGtProcessor");
281 
282  // run the parser
283  xmlReader_mask_algobx.readDOMFromString( xmlPayload_mask_algobx ); // initialize it
284  xmlReader_mask_algobx.readRootElement( ts_mask_algobx, "uGT" ); // extract all of the relevant context
285  ts_mask_algobx.setConfigured();
286 
287  std::map<std::string, l1t::Setting> settings_mask_algobx = ts_mask_algobx.getSettings("uGtProcessor");
288  std::vector<l1t::TableRow> tRow_mask_algobx = settings_mask_algobx["algorithmBxMask"].getTableRows();
289 
290  unsigned int numCol_mask_algobx = 0;
291  if( tRow_mask_algobx.size()>0 ){
292  std::vector<std::string> firstRow_mask_algobx = tRow_mask_algobx[0].getRow();
293  numCol_mask_algobx = firstRow_mask_algobx.size();
294  }
295 
296  int NumAlgoBitsInMask = numCol_mask_algobx - 1;
297  if( NumAlgoBitsInMask > 0 ){
298  for( auto it=tRow_mask_algobx.begin(); it!=tRow_mask_algobx.end(); it++ ){
299  int bx = it->getRowValue<unsigned int>("bx/algo");
300  std::vector<int> maskedBits;
301  for( int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
302  unsigned int maskBit = it->getRowValue<unsigned int>(std::to_string(iBit));
303  if( maskBit!=m_bx_mask_default ) maskedBits.push_back(iBit);
304  }
305  if( maskedBits.size()>0 ) triggerAlgoBxMaskAlgoTrig[bx] = maskedBits;
306  }
307  }
308 
309 
310  // Set prescales to zero if masked
311  for( unsigned int iSet=0; iSet < prescales.size(); iSet++ ){
312  for( unsigned int iBit=0; iBit < prescales[iSet].size(); iBit++ ){
313  // Add protection in case prescale table larger than trigger mask size
314  if( iBit >= triggerMasks.size() ){
315  edm::LogError( "L1-O2O: L1TGlobalPrescalesVetosOnlineProd" )
316  << "\nWarning: algoBit in prescale table >= triggerMasks.size() "
317  << "\nWarning: no information on masking bit or not, setting as unmasked "
318  << std::endl;
319  }
320  else {
321  prescales[iSet][iBit] *= triggerMasks[iBit];
322  }
323  }
324  }
325 
327 
329 
330  data_.setBxMaskDefault ( m_bx_mask_default );
331  data_.setPrescaleFactorTable ( prescales );
332  data_.setTriggerMaskVeto ( triggerVetoMasks );
333  data_.setTriggerAlgoBxMask ( triggerAlgoBxMaskAlgoTrig );
334 
335  using namespace edm::es;
336  boost::shared_ptr<L1TGlobalPrescalesVetos> pMenu = boost::shared_ptr< L1TGlobalPrescalesVetos >(data_.getWriteInstance());
337  return pMenu;
338 
339 }
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:296
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
void addProcRole(const std::string &processor, const std::string &role)
Definition: TrigSystem.cc:39
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:86