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

using ReturnType = std::unique_ptr< L1TGlobalPrescalesVetos >
 
- 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 ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- 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
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- 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())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 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 51 of file L1TGlobalPrescalesVetosESProducer.cc.

Member Typedef Documentation

Definition at line 56 of file L1TGlobalPrescalesVetosESProducer.cc.

Constructor & Destructor Documentation

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

there may be "missing" rows/bits in the xml description meaning that triggers are not unused, so go for max

Definition at line 85 of file L1TGlobalPrescalesVetosESProducer.cc.

References l1t::TriggerSystem::addProcessor(), patPFMETCorrections_cff::algo, cuy::col, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), l1t::TriggerSystem::getParameters(), createfilelist::int, m_bx_mask_default, m_initialPrescaleFactorsAlgoTrig, m_initialTriggerAlgoBxMaskAlgoTrig, m_initialTriggerMaskAlgoTrig, m_initialTriggerMaskVetoAlgoTrig, m_numberPhysTriggers, m_verbosity, RecoTauDiscriminantConfiguration::mask, l1t::XmlConfigParser::readDOMFromString(), l1t::XmlConfigParser::readRootElement(), l1t::TriggerSystem::setConfigured(), edm::ESProducer::setWhatProduced(), AlCaHLTBitMon_QueryRunRegistry::string, tmp, and TriggerAnalyzer::veto.

85  :
87 {
88  //the following line is needed to tell the framework what
89  // data is being produced
90  setWhatProduced(this);
91  //setWhatProduced(this, conf.getParameter<std::string>("label"));
92 
94 
95  // directory in /data/Luminosity for the trigger menu
96  std::string menuDir = conf.getParameter<std::string>("TriggerMenuLuminosity");
97  //std::string menuDir = "startup";
98 
99  m_verbosity = conf.getParameter<int>("Verbosity");
100  m_bx_mask_default = conf.getParameter<int>("AlgoBxMaskDefault");
101 
102  // XML files
103  std::string prescalesFileName = conf.getParameter<std::string>("PrescaleXMLFile");
104  std::string algobxmaskFileName = conf.getParameter<std::string>("AlgoBxMaskXMLFile");
105  std::string finormaskFileName = conf.getParameter<std::string>("FinOrMaskXMLFile");
106  std::string vetomaskFileName = conf.getParameter<std::string>("VetoMaskXMLFile");
107 
108  // Full path
109  edm::FileInPath f1_prescale("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + prescalesFileName);
110  std::string m_prescaleFile = f1_prescale.fullPath();
111 
112  edm::FileInPath f1_mask_algobx("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + algobxmaskFileName);
113  std::string m_algobxmaskFile = f1_mask_algobx.fullPath();
114 
115  edm::FileInPath f1_mask_finor("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + finormaskFileName);
116  std::string m_finormaskFile = f1_mask_finor.fullPath();
117 
118  edm::FileInPath f1_mask_veto("L1Trigger/L1TGlobal/data/Luminosity/" + menuDir + "/" + vetomaskFileName);
119  std::string m_vetomaskFile = f1_mask_veto.fullPath();
120 
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  l1t::XmlConfigParser xmlReader_prescale;
153  l1t::TriggerSystem ts_prescale;
154  ts_prescale.addProcessor("uGtProcessor", "uGtProcessor","-1","-1");
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  const std::map<std::string, l1t::Parameter> &settings_prescale = ts_prescale.getParameters("uGtProcessor");
162  std::map<std::string,unsigned int> prescaleColumns = settings_prescale.at("prescales").getColumnIndices();
163 
164  unsigned int numColumns_prescale = prescaleColumns.size();
165 
166  int NumPrescaleSets = numColumns_prescale - 1;
168  std::vector<unsigned int> algoBits = settings_prescale.at("prescales").getTableColumn<unsigned int>("algo/prescale-index");
169  int NumAlgos_prescale = *std::max_element(algoBits.begin(), algoBits.end()) + 1;
170 
171  if( NumPrescaleSets > 0 ){
172  // Fill default prescale set
173  for( int iSet=0; iSet<NumPrescaleSets; iSet++ ){
174  prescales.push_back(std::vector<int>());
175  for( int iBit = 0; iBit < NumAlgos_prescale; ++iBit ){
176  int inputDefaultPrescale = 0; // only prescales that are set in the block below are used
177  prescales[iSet].push_back(inputDefaultPrescale);
178  }
179  }
180 
181  for(auto &col : prescaleColumns){
182  if( col.second<1 ) continue; // we don't care for the algorithms' indicies in 0th column
183  int iSet = col.second - 1;
184  std::vector<unsigned int> prescalesForSet = settings_prescale.at("prescales").getTableColumn<unsigned int>(col.first.c_str());
185  for(unsigned int row=0; row<prescalesForSet.size(); row++){
186  unsigned int prescale = prescalesForSet[row];
187  unsigned int algoBit = algoBits[row];
188  prescales[iSet][algoBit] = prescale;
189  }
190  }
191  }
192  }
193  input_prescale.close();
194 
195 
197 
198  // finor mask
199  // set all masks to 1 (unmasked) by default
200  triggerMasks.insert(triggerMasks.end(), m_numberPhysTriggers, 1);
201 
202  std::ifstream input_mask_finor;
203  input_mask_finor.open( m_finormaskFile );
204  if (not m_finormaskFile.empty() and not input_mask_finor) {
205  edm::LogError("L1TGlobalPrescalesVetosESProducer")
206  << "\nCould not find finor mask file: " << m_finormaskFile
207  << "\nDeafulting the finor mask for all triggers to 1 (unmasked)";
208  }
209  else {
210  while( !input_mask_finor.eof() ){
211  string tmp;
212  getline( input_mask_finor, tmp, '\n' );
213  xmlPayload_mask_finor.append( tmp );
214  }
215 
216  l1t::XmlConfigParser xmlReader_mask_finor;
217  l1t::TriggerSystem ts_mask_finor;
218  ts_mask_finor.addProcessor("uGtProcessor", "uGtProcessor","-1","-1");
219 
220  // run the parser
221  xmlReader_mask_finor.readDOMFromString( xmlPayload_mask_finor ); // initialize it
222  xmlReader_mask_finor.readRootElement( ts_mask_finor, "uGT" ); // extract all of the relevant context
223  ts_mask_finor.setConfigured();
224 
225  const std::map<std::string, l1t::Parameter>& settings_mask_finor = ts_mask_finor.getParameters("uGtProcessor");
226 
227  std::vector<unsigned int> algo_mask_finor = settings_mask_finor.at("finorMask").getTableColumn<unsigned int>("algo");
228  std::vector<unsigned int> mask_mask_finor = settings_mask_finor.at("finorMask").getTableColumn<unsigned int>("mask");
229 
230  for(unsigned int row=0; row<algo_mask_finor.size(); row++){
231  unsigned int algoBit = algo_mask_finor[row];
232  unsigned int mask = mask_mask_finor[row];
233  if( algoBit < m_numberPhysTriggers ) triggerMasks[algoBit] = mask;
234  }
235  }
236  input_mask_finor.close();
237 
238 
240 
241  // veto mask
242  // Setting veto mask to default 0 (no veto)
243  for (unsigned int iAlg=0; iAlg < m_numberPhysTriggers; iAlg++)
244  triggerVetoMasks.push_back(0);
245 
246  std::ifstream input_mask_veto;
247  input_mask_veto.open( m_vetomaskFile );
248  if (not m_vetomaskFile.empty() and not input_mask_veto) {
249  edm::LogError("L1TGlobalPrescalesVetosESProducer")
250  << "\nCould not find veto mask file: " << m_vetomaskFile
251  << "\nDeafulting the veto mask for all triggers to 1 (unmasked)";
252  }
253  else {
254  while( !input_mask_veto.eof() ){
255  string tmp;
256  getline( input_mask_veto, tmp, '\n' );
257  xmlPayload_mask_veto.append( tmp );
258  }
259 
260  l1t::XmlConfigParser xmlReader_mask_veto;
261  l1t::TriggerSystem ts_mask_veto;
262  ts_mask_veto.addProcessor("uGtProcessor", "uGtProcessor","-1","-1");
263 
264  // run the parser
265  xmlReader_mask_veto.readDOMFromString( xmlPayload_mask_veto ); // initialize it
266  xmlReader_mask_veto.readRootElement( ts_mask_veto, "uGT" ); // extract all of the relevant context
267  ts_mask_veto.setConfigured();
268 
269  const std::map<std::string, l1t::Parameter>& settings_mask_veto = ts_mask_veto.getParameters("uGtProcessor");
270  std::vector<unsigned int> algo_mask_veto = settings_mask_veto.at("vetoMask").getTableColumn<unsigned int>("algo");
271  std::vector<unsigned int> veto_mask_veto = settings_mask_veto.at("vetoMask").getTableColumn<unsigned int>("veto");
272 
273  for(unsigned int row=0; row<algo_mask_veto.size(); row++){
274  unsigned int algoBit = algo_mask_veto[row];
275  unsigned int veto = veto_mask_veto[row];
276  if( algoBit < m_numberPhysTriggers ) triggerVetoMasks[algoBit] = int(veto);
277  }
278  }
279  input_mask_veto.close();
280 
282 
283  // Algo bx mask
284  std::ifstream input_mask_algobx;
285  input_mask_algobx.open( m_algobxmaskFile );
286  if (not m_algobxmaskFile.empty() and not input_mask_algobx) {
287  edm::LogError("L1TGlobalPrescalesVetosESProducer")
288  << "\nCould not find bx mask file: " << m_algobxmaskFile
289  << "\nNot filling the bx mask map";
290  }
291  else {
292  while( !input_mask_algobx.eof() ){
293  string tmp;
294  getline( input_mask_algobx, tmp, '\n' );
295  xmlPayload_mask_algobx.append( tmp );
296  }
297 
298  l1t::XmlConfigParser xmlReader_mask_algobx;
299  l1t::TriggerSystem ts_mask_algobx;
300  ts_mask_algobx.addProcessor("uGtProcessor", "uGtProcessor","-1","-1");
301 
302  // run the parser
303  xmlReader_mask_algobx.readDOMFromString( xmlPayload_mask_algobx ); // initialize it
304  xmlReader_mask_algobx.readRootElement( ts_mask_algobx, "uGT" ); // extract all of the relevant context
305  ts_mask_algobx.setConfigured();
306 
307  const std::map<std::string, l1t::Parameter>& settings_mask_algobx = ts_mask_algobx.getParameters("uGtProcessor");
308  std::map<std::string,unsigned int> mask_algobx_columns = settings_mask_algobx.at("algorithmBxMask").getColumnIndices();
309  std::vector<unsigned int> bunches = settings_mask_algobx.at("algorithmBxMask").getTableColumn<unsigned int>("bx/algo");
310 
311  unsigned int numCol_mask_algobx = mask_algobx_columns.size();
312 
313  int NumAlgoBitsInMask = numCol_mask_algobx - 1;
314  for( int iBit=0; iBit<NumAlgoBitsInMask; iBit++ ){
315  std::vector<unsigned int> algo = settings_mask_algobx.at("algorithmBxMask").getTableColumn<unsigned int>(std::to_string(iBit).c_str());
316  for(unsigned int bx=0; bx<bunches.size(); bx++){
317  if( algo[bx]!=unsigned(m_bx_mask_default) ) triggerAlgoBxMaskAlgoTrig[ bunches[bx] ].push_back(iBit);
318  }
319  }
320  }
321  input_mask_algobx.close();
322 
323 
324  // Set prescales to zero if masked
325  for(auto & prescale : prescales){
326  for( unsigned int iBit=0; iBit < prescale.size(); iBit++ ){
327  // Add protection in case prescale table larger than trigger mask size
328  if( iBit >= triggerMasks.size() ){
329  edm::LogWarning("L1TGlobal")
330  << "\nWarning: algoBit in prescale table >= triggerMasks.size() "
331  << "\nWarning: no information on masking bit or not, setting as unmasked "
332  << std::endl;
333  }
334  else {
335  prescale[iBit] *= triggerMasks[iBit];
336  }
337  }
338  }
339 
341  m_initialTriggerMaskAlgoTrig = triggerMasks;
342  m_initialTriggerMaskVetoAlgoTrig = triggerVetoMasks;
343  m_initialTriggerAlgoBxMaskAlgoTrig = triggerAlgoBxMaskAlgoTrig;
344 
345 }
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
void setConfigured(bool state=true) noexcept
Definition: TriggerSystem.h:73
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
std::map< int, std::vector< int > > m_initialTriggerAlgoBxMaskAlgoTrig
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
const std::map< std::string, Parameter > & getParameters(const char *processor) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
col
Definition: cuy.py:1010
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
L1TGlobalPrescalesVetosESProducer::~L1TGlobalPrescalesVetosESProducer ( )
override

Definition at line 348 of file L1TGlobalPrescalesVetosESProducer.cc.

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

Member Function Documentation

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

Definition at line 363 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().

364 {
365  // configure the helper class parameters via its set funtions, e.g.:
370 
371  if( m_verbosity ){
372  LogDebug("L1TGlobal") << " ====> Prescales table <=== " << std::endl;
373  for( unsigned int ix=0; ix < m_initialPrescaleFactorsAlgoTrig.size(); ix++ ){
374  LogDebug("L1TGlobal") << " Prescale set = " << ix << std::endl;
375  for( unsigned int iy=0; iy < m_initialPrescaleFactorsAlgoTrig[ix].size(); iy++ ){
376  LogDebug("L1TGlobal") << "\t Algo " << iy << ": " << m_initialPrescaleFactorsAlgoTrig[ix][iy] << std::endl;
377  }
378  }
379 
380  LogDebug("L1TGlobal") << " ====> Trigger mask veto <=== " << std::endl;
381  for( unsigned int ix=0; ix < m_initialTriggerMaskVetoAlgoTrig.size(); ix++ ){
382  LogDebug("L1TGlobal") << "\t Algo " << ix << ": " << m_initialTriggerMaskVetoAlgoTrig[ix] << std::endl;
383  }
384 
385  LogDebug("L1TGlobal") << " ====> Algo bx mask <=== " << std::endl;
386  if( m_initialTriggerAlgoBxMaskAlgoTrig.empty() ) LogDebug("L1TGlobal") << "\t(empty map)" << std::endl;
387  for( auto& it: m_initialTriggerAlgoBxMaskAlgoTrig ){
388  LogDebug("L1TGlobal") << " bx = " << it.first << " : iAlg =";
389  std::vector<int> masked = it.second;
390  for(int & iAlg : masked){
391  LogDebug("L1TGlobal") << " " << iAlg;
392  }
393  LogDebug("L1TGlobal") << " " << std::endl;
394  }
395  }
396 
397  // Return copy so that we don't give away our owned pointer to framework
398  return std::make_unique<L1TGlobalPrescalesVetos>(*data_.getWriteInstance());
399 }
#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 62 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