CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
L1TGlobalPrescalesVetosESProducer Class Reference
Inheritance diagram for L1TGlobalPrescalesVetosESProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::shared_ptr< L1TGlobalPrescalesVetosReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

 L1TGlobalPrescalesVetosESProducer (const edm::ParameterSet &)
 
ReturnType produce (const L1TGlobalPrescalesVetosRcd &)
 
 ~L1TGlobalPrescalesVetosESProducer () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- 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 () noexcept(false)
 

Private Attributes

PrescalesVetosHelper data_
 
int m_bx_mask_default
 
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
 
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
 
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
 
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
 
unsigned int m_numberPhysTriggers
 
int m_verbosity
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- 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::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_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 &)
 

Detailed Description

Description: Produces L1T Trigger Menu Condition Format

Implementation: Dummy producer for L1T uGT Trigger Menu

Definition at line 52 of file L1TGlobalPrescalesVetosESProducer.cc.

Member Typedef Documentation

Definition at line 57 of file L1TGlobalPrescalesVetosESProducer.cc.

Constructor & Destructor Documentation

L1TGlobalPrescalesVetosESProducer::L1TGlobalPrescalesVetosESProducer ( const edm::ParameterSet conf)

Definition at line 86 of file L1TGlobalPrescalesVetosESProducer.cc.

References l1t::TrigSystem::addProcRole(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), l1t::TrigSystem::getSettings(), createfilelist::int, m_bx_mask_default, m_initialPrescaleFactorsAlgoTrig, m_initialTriggerAlgoBxMaskAlgoTrig, m_initialTriggerMaskAlgoTrig, m_initialTriggerMaskVetoAlgoTrig, m_numberPhysTriggers, m_verbosity, RecoTauDiscriminantConfiguration::mask, l1t::XmlConfigReader::readDOMFromString(), l1t::XmlConfigReader::readRootElement(), l1t::TrigSystem::setConfigured(), edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, tmp, and TriggerAnalyzer::veto.

86  :
88 {
89  //the following line is needed to tell the framework what
90  // data is being produced
91  setWhatProduced(this);
92  //setWhatProduced(this, conf.getParameter<std::string>("label"));
93 
95 
96  // directory in /data/Luminosity for the trigger menu
97  std::string menuDir = conf.getParameter<std::string>("TriggerMenuLuminosity");
98  //std::string menuDir = "startup";
99 
100  m_verbosity = conf.getParameter<int>("Verbosity");
101  m_bx_mask_default = conf.getParameter<int>("AlgoBxMaskDefault");
102 
103  // XML files
104  std::string prescalesFileName = conf.getParameter<std::string>("PrescaleXMLFile");
105  std::string algobxmaskFileName = conf.getParameter<std::string>("AlgoBxMaskXMLFile");
106  std::string finormaskFileName = conf.getParameter<std::string>("FinOrMaskXMLFile");
107  std::string vetomaskFileName = conf.getParameter<std::string>("VetoMaskXMLFile");
108 
109  // Full path
110  edm::FileInPath f1_prescale("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + prescalesFileName);
111  std::string m_prescaleFile = f1_prescale.fullPath();
112 
113  edm::FileInPath f1_mask_algobx("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + algobxmaskFileName);
114  std::string m_algobxmaskFile = f1_mask_algobx.fullPath();
115 
116  edm::FileInPath f1_mask_finor("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + finormaskFileName);
117  std::string m_finormaskFile = f1_mask_finor.fullPath();
118 
119  edm::FileInPath f1_mask_veto("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + vetomaskFileName);
120  std::string m_vetomaskFile = f1_mask_veto.fullPath();
121 
122  // XML payloads
123  std::string xmlPayload_prescale;
124  std::string xmlPayload_mask_algobx;
125  std::string xmlPayload_mask_finor;
126  std::string xmlPayload_mask_veto;
127 
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;
132 
133  // Prescales
134  std::ifstream input_prescale;
135  input_prescale.open( m_prescaleFile );
136  if (not m_prescaleFile.empty() and not input_prescale) {
137  edm::LogError("L1TGlobalPrescalesVetosESProducer")
138  << "\nCould not find prescale file: " << m_prescaleFile
139  << "\nDeafulting to a single prescale column, with all prescales set to 1 (unprescaled)";
140 
141  const int inputDefaultPrescale = 1;
142  // by default, fill a single prescale column
143  prescales.push_back(std::vector<int>(m_numberPhysTriggers, inputDefaultPrescale));
144  }
145  else {
146  while( !input_prescale.eof() ){
147  string tmp;
148  getline( input_prescale, tmp, '\n' );
149  xmlPayload_prescale.append( tmp );
150  }
151 
152  XmlConfigReader xmlReader_prescale;
153  l1t::TrigSystem ts_prescale;
154  ts_prescale.addProcRole("uGtProcessor", "uGtProcessor");
155 
156  // run the parser
157  xmlReader_prescale.readDOMFromString( xmlPayload_prescale ); // initialize it
158  xmlReader_prescale.readRootElement( ts_prescale, "uGT" ); // extract all of the relevant context
159  ts_prescale.setConfigured();
160 
161  std::map<string, l1t::Setting> settings_prescale = ts_prescale.getSettings("uGtProcessor");
162  std::vector<l1t::TableRow> tRow_prescale = settings_prescale["prescales"].getTableRows();
163 
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;
168  }
169 
170  if (numColumns_prescale > 0) {
171  // set all prescales to 1 (unprescaled) by default
172  const int inputDefaultPrescale = 1;
173  for (unsigned int iSet=0; iSet<numColumns_prescale; ++iSet)
174  prescales.push_back(std::vector<int>(m_numberPhysTriggers, inputDefaultPrescale));
175 
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;
181  }
182  }
183  }
184 
185  }
186  input_prescale.close();
187 
188 
189 
190 
192 
193  // finor mask
194  // set all masks to 1 (unmasked) by default
195  triggerMasks.insert(triggerMasks.end(), m_numberPhysTriggers, 1);
196 
197  std::ifstream input_mask_finor;
198  input_mask_finor.open( m_finormaskFile );
199  if (not m_finormaskFile.empty() and not input_mask_finor) {
200  edm::LogError("L1TGlobalPrescalesVetosESProducer")
201  << "\nCould not find finor mask file: " << m_finormaskFile
202  << "\nDeafulting the finor mask for all triggers to 1 (unmasked)";
203  }
204  else {
205  while( !input_mask_finor.eof() ){
206  string tmp;
207  getline( input_mask_finor, tmp, '\n' );
208  xmlPayload_mask_finor.append( tmp );
209  }
210 
211  XmlConfigReader xmlReader_mask_finor;
212  l1t::TrigSystem ts_mask_finor;
213  ts_mask_finor.addProcRole("uGtProcessor", "uGtProcessor");
214 
215  // run the parser
216  xmlReader_mask_finor.readDOMFromString( xmlPayload_mask_finor ); // initialize it
217  xmlReader_mask_finor.readRootElement( ts_mask_finor, "uGT" ); // extract all of the relevant context
218  ts_mask_finor.setConfigured();
219 
220  std::map<string, l1t::Setting> settings_mask_finor = ts_mask_finor.getSettings("uGtProcessor");
221 
222  std::vector<l1t::TableRow> tRow_mask_finor = settings_mask_finor["finorMask"].getTableRows();
223 
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");
227  if (algoBit < m_numberPhysTriggers)
228  triggerMasks[algoBit] = mask;
229  }
230  }
231  input_mask_finor.close();
232 
233 
235 
236  // veto mask
237  // Setting veto mask to default 0 (no veto)
238  for (unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++)
239  triggerVetoMasks.push_back(0);
240 
241  std::ifstream input_mask_veto;
242  input_mask_veto.open( m_vetomaskFile );
243  if (not m_vetomaskFile.empty() and not input_mask_veto) {
244  edm::LogError("L1TGlobalPrescalesVetosESProducer")
245  << "\nCould not find veto mask file: " << m_vetomaskFile
246  << "\nDeafulting the veto mask for all triggers to 1 (unmasked)";
247  }
248  else {
249  while( !input_mask_veto.eof() ){
250  string tmp;
251  getline( input_mask_veto, tmp, '\n' );
252  xmlPayload_mask_veto.append( tmp );
253  }
254 
255  XmlConfigReader xmlReader_mask_veto;
256  l1t::TrigSystem ts_mask_veto;
257  ts_mask_veto.addProcRole("uGtProcessor", "uGtProcessor");
258 
259  // run the parser
260  xmlReader_mask_veto.readDOMFromString( xmlPayload_mask_veto ); // initialize it
261  xmlReader_mask_veto.readRootElement( ts_mask_veto, "uGT" ); // extract all of the relevant context
262  ts_mask_veto.setConfigured();
263 
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();
266 
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);
271  }
272  }
273  input_mask_veto.close();
274 
276 
277  // Algo bx mask
278  std::ifstream input_mask_algobx;
279  input_mask_algobx.open( m_algobxmaskFile );
280  if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
281  edm::LogError("L1TGlobalPrescalesVetosESProducer")
282  << "\nCould not find bx mask file: " << m_algobxmaskFile
283  << "\nNot filling the bx mask map";
284  }
285  else {
286  while( !input_mask_algobx.eof() ){
287  string tmp;
288  getline( input_mask_algobx, tmp, '\n' );
289  xmlPayload_mask_algobx.append( tmp );
290  }
291 
292  XmlConfigReader xmlReader_mask_algobx;
293  l1t::TrigSystem ts_mask_algobx;
294  ts_mask_algobx.addProcRole("uGtProcessor", "uGtProcessor");
295 
296  // run the parser
297  xmlReader_mask_algobx.readDOMFromString( xmlPayload_mask_algobx ); // initialize it
298  xmlReader_mask_algobx.readRootElement( ts_mask_algobx, "uGT" ); // extract all of the relevant context
299  ts_mask_algobx.setConfigured();
300 
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();
303 
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();
308  }
309 
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));
317  if( int(maskBit)!=m_bx_mask_default ) maskedBits.push_back(iBit);
318  }
319  if( maskedBits.size()>0 ) triggerAlgoBxMaskAlgoTrig[bx] = maskedBits;
320  }
321  }
322 
323  }
324  input_mask_algobx.close();
325 
326 
327  // Set prescales to zero if masked
328  for(auto & prescale : prescales){
329  for( unsigned int iBit=0; iBit < prescale.size(); iBit++ ){
330  // Add protection in case prescale table larger than trigger mask size
331  if( iBit >= triggerMasks.size() ){
332  edm::LogWarning("L1TGlobal")
333  << "\nWarning: algoBit in prescale table >= triggerMasks.size() "
334  << "\nWarning: no information on masking bit or not, setting as unmasked "
335  << std::endl;
336  }
337  else {
338  prescale[iBit] *= triggerMasks[iBit];
339  }
340  }
341  }
342 
344  m_initialTriggerMaskAlgoTrig = triggerMasks;
345  m_initialTriggerMaskVetoAlgoTrig = triggerVetoMasks;
346  m_initialTriggerAlgoBxMaskAlgoTrig = triggerAlgoBxMaskAlgoTrig;
347 
348 }
T getParameter(std::string const &) const
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
void readRootElement(TrigSystem &aTrigSystem, const std::string &sysId="")
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void addProcRole(const std::string &processor, const std::string &role)
Definition: TrigSystem.cc:39
void setConfigured(const bool state=true)
Definition: TrigSystem.h:39
std::map< std::string, Setting > getSettings(const std::string &processor)
Definition: TrigSystem.cc:179
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
L1TGlobalPrescalesVetosESProducer::~L1TGlobalPrescalesVetosESProducer ( )
override

Definition at line 351 of file L1TGlobalPrescalesVetosESProducer.cc.

352 {
353 
354  // do anything here that needs to be done at desctruction time
355  // (e.g. close files, deallocate resources etc.)
356 
357 }

Member Function Documentation

L1TGlobalPrescalesVetosESProducer::ReturnType L1TGlobalPrescalesVetosESProducer::produce ( const L1TGlobalPrescalesVetosRcd iRecord)

Definition at line 366 of file L1TGlobalPrescalesVetosESProducer.cc.

References data_, DEFINE_FWK_EVENTSETUP_MODULE, l1t::PrescalesVetosHelper::getWriteInstance(), LogDebug, m_bx_mask_default, m_initialPrescaleFactorsAlgoTrig, m_initialTriggerAlgoBxMaskAlgoTrig, m_initialTriggerMaskVetoAlgoTrig, m_verbosity, l1t::PrescalesVetosHelper::setBxMaskDefault(), l1t::PrescalesVetosHelper::setPrescaleFactorTable(), l1t::PrescalesVetosHelper::setTriggerAlgoBxMask(), and l1t::PrescalesVetosHelper::setTriggerMaskVeto().

367 {
368  // configure the helper class parameters via its set funtions, e.g.:
373 
374  if( m_verbosity ){
375  LogDebug("L1TGlobal") << " ====> Prescales table <=== " << std::endl;
376  for( unsigned int ix=0; ix < m_initialPrescaleFactorsAlgoTrig.size(); ix++ ){
377  LogDebug("L1TGlobal") << " Prescale set = " << ix << std::endl;
378  for( unsigned int iy=0; iy < m_initialPrescaleFactorsAlgoTrig[ix].size(); iy++ ){
379  LogDebug("L1TGlobal") << "\t Algo " << iy << ": " << m_initialPrescaleFactorsAlgoTrig[ix][iy] << std::endl;
380  }
381  }
382 
383  LogDebug("L1TGlobal") << " ====> Trigger mask veto <=== " << std::endl;
384  for( unsigned int ix=0; ix < m_initialTriggerMaskVetoAlgoTrig.size(); ix++ ){
385  LogDebug("L1TGlobal") << "\t Algo " << ix << ": " << m_initialTriggerMaskVetoAlgoTrig[ix] << std::endl;
386  }
387 
388  LogDebug("L1TGlobal") << " ====> Algo bx mask <=== " << std::endl;
389  if( m_initialTriggerAlgoBxMaskAlgoTrig.size()==0 ) LogDebug("L1TGlobal") << "\t(empty map)" << std::endl;
390  for( auto& it: m_initialTriggerAlgoBxMaskAlgoTrig ){
391  LogDebug("L1TGlobal") << " bx = " << it.first << " : iAlg =";
392  std::vector<int> masked = it.second;
393  for(int & iAlg : masked){
394  LogDebug("L1TGlobal") << " " << iAlg;
395  }
396  LogDebug("L1TGlobal") << " " << std::endl;
397  }
398  }
399 
400  // write the condition format to the event setup via the helper:
401  using namespace edm::es;
402  std::shared_ptr<L1TGlobalPrescalesVetos> pMenu(data_.getWriteInstance());
403  return pMenu;
404 }
#define LogDebug(id)
void setPrescaleFactorTable(std::vector< std::vector< int > > value)
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
void setTriggerMaskVeto(std::vector< int > value)
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
void setTriggerAlgoBxMask(std::map< int, std::vector< int > > value)
L1TGlobalPrescalesVetos * getWriteInstance()

Member Data Documentation

PrescalesVetosHelper L1TGlobalPrescalesVetosESProducer::data_
private

Definition at line 63 of file L1TGlobalPrescalesVetosESProducer.cc.

Referenced by produce().

int L1TGlobalPrescalesVetosESProducer::m_bx_mask_default
private
std::vector<std::vector<int> > L1TGlobalPrescalesVetosESProducer::m_initialPrescaleFactorsAlgoTrig
private
std::map<int, std::vector<int> > L1TGlobalPrescalesVetosESProducer::m_initialTriggerAlgoBxMaskAlgoTrig
private
std::vector<unsigned int> L1TGlobalPrescalesVetosESProducer::m_initialTriggerMaskAlgoTrig
private
std::vector<int> L1TGlobalPrescalesVetosESProducer::m_initialTriggerMaskVetoAlgoTrig
private
unsigned int L1TGlobalPrescalesVetosESProducer::m_numberPhysTriggers
private
int L1TGlobalPrescalesVetosESProducer::m_verbosity
private