CMS 3D CMS Logo

List of all members | Public Member Functions
DTTFMasksOnlineProd Class Reference
Inheritance diagram for DTTFMasksOnlineProd:
L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks > edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 DTTFMasksOnlineProd (const edm::ParameterSet &)
 
virtual std::shared_ptr< L1MuDTTFMasksnewObject (const std::string &objectKey) override
 
 ~DTTFMasksOnlineProd ()
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
virtual std::shared_ptr< L1MuDTTFMasksproduce (const L1MuDTTFMasksRcd &iRecord)
 
 ~L1ConfigOnlineProdBase ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~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)
 

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< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >
bool getObjectKey (const L1MuDTTFMasksRcd &record, std::shared_ptr< L1MuDTTFMasks > 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::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 &)
 
- Protected Attributes inherited from L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >
bool m_copyFromCondDB
 
cond::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 33 of file DTTFMasksOnlineProd.cc.

Constructor & Destructor Documentation

DTTFMasksOnlineProd::DTTFMasksOnlineProd ( const edm::ParameterSet iConfig)

Definition at line 50 of file DTTFMasksOnlineProd.cc.

53 {
54  //the following line is needed to tell the framework what
55  // data is being produced
56 
57  //now do what ever other initialization is needed
58 }
DTTFMasksOnlineProd::~DTTFMasksOnlineProd ( )

Definition at line 61 of file DTTFMasksOnlineProd.cc.

62 {
63 
64  // do anything here that needs to be done at desctruction time
65  // (e.g. close files, deallocate resources etc.)
66 
67 }

Member Function Documentation

std::shared_ptr< L1MuDTTFMasks > DTTFMasksOnlineProd::newObject ( const std::string &  objectKey)
overridevirtual

Implements L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >.

Definition at line 70 of file DTTFMasksOnlineProd.cc.

References l1t::OMDSReader::basicQuery(), gather_cfg::cout, TauDecayModes::dec, DEFINE_FWK_EVENTSETUP_MODULE, l1t::OMDSReader::QueryResults::fillVariable(), L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >::m_omdsReader, NULL, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), l1t::OMDSReader::singleAttribute(), and AlCaHLTBitMon_QueryRunRegistry::string.

71 {
72  using namespace edm::es;
73 
74  auto pDTTFMasks = std::make_shared< L1MuDTTFMasks >() ;
75 
76  pDTTFMasks->reset() ;
77 
78  std::string dttfSchema = "CMS_DT_TF" ;
79 
80  // Order of strings is used below -- don't change!
81  std::vector< std::string > crateMaskColumns ;
82  crateMaskColumns.push_back( "WEDGE_CRATE_1" ) ;
83  crateMaskColumns.push_back( "WEDGE_CRATE_2" ) ;
84  crateMaskColumns.push_back( "WEDGE_CRATE_3" ) ;
85  crateMaskColumns.push_back( "WEDGE_CRATE_4" ) ;
86  crateMaskColumns.push_back( "WEDGE_CRATE_5" ) ;
87  crateMaskColumns.push_back( "WEDGE_CRATE_6" ) ;
88  crateMaskColumns.push_back( "WEDGE_CRATE_1_E" ) ;
89  crateMaskColumns.push_back( "WEDGE_CRATE_2_E" ) ;
90  crateMaskColumns.push_back( "WEDGE_CRATE_3_E" ) ;
91  crateMaskColumns.push_back( "WEDGE_CRATE_4_E" ) ;
92  crateMaskColumns.push_back( "WEDGE_CRATE_5_E" ) ;
93  crateMaskColumns.push_back( "WEDGE_CRATE_6_E" ) ;
94 
95  l1t::OMDSReader::QueryResults crateMaskResults =
96  m_omdsReader.basicQuery( crateMaskColumns,
97  dttfSchema,
98  "DTTF_RUN_SETTINGS",
99  "DTTF_RUN_SETTINGS.ID",
100  m_omdsReader.singleAttribute( objectKey ) ) ;
101 
102  if( crateMaskResults.queryFailed() ||
103  crateMaskResults.numberRows() != 1 ) // check query successful
104  {
105  edm::LogError( "L1-O2O" )
106  << "Problem with L1MuDTTFMasks key " << objectKey ;
107  return std::shared_ptr< L1MuDTTFMasks >() ;
108  }
109 
110  // Cache crate masks
111  unsigned long crateMaskL[ 6 ] ;
112  unsigned long crateMaskR[ 6 ] ;
113  unsigned long krateMaskL[ 6 ] ;
114  unsigned long krateMaskR[ 6 ] ;
115  for( int icrate = 0 ; icrate < 6 ; ++icrate )
116  {
117  std::string crateMask ;
118  crateMaskResults.fillVariable( crateMaskColumns[ icrate ],
119  crateMask ) ;
120  char* pEnd;
121  crateMaskL[ icrate ] = std::strtol( crateMask.c_str(), &pEnd, 16 ) ;
122  crateMaskR[ icrate ] = std::strtol( pEnd, (char **)NULL, 16 ) ;
123 
124  crateMaskResults.fillVariable( crateMaskColumns[ icrate+6 ],
125  crateMask ) ;
126  krateMaskL[ icrate ] = std::strtol( crateMask.c_str(), &pEnd, 16 ) ;
127  krateMaskR[ icrate ] = std::strtol( pEnd, (char **)NULL, 16 ) ;
128 
129  std::cout << "Crate " << icrate << " masks"
130  << " L: " << std::hex << crateMaskL[ icrate ]
131  << " " << std::hex << krateMaskL[ icrate ]
132  << " R: " << std::hex << crateMaskR[ icrate ]
133  << " " << std::hex << krateMaskR[ icrate ] << std::endl ;
134  }
135 
136  // Map of sector (0-11) to name (L/R)
137  std::string sectorNames[ 12 ] = {
138  "R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L" } ;
139 
140  // Map of sector (0-11) to crate (0-5)
141  int crateNumbers[ 12 ] = { 3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0 } ;
142 
143  // Map of wheel array index to wheel number (+- 3, 2, 1).
144  int wheelNumbers[ 6 ] = { -3, -2, -1, 1, 2, 3 } ;
145 
146  // Map of wheel array index to name ({N,P}{0,1,2}).
147  std::string wheelNames[ 6 ] = { "N2", "N1", "N0", "P0", "P1", "P2" } ;
148 
149  // Map of sector+wheel name to bit number in crate mask
150  std::map< std::string, unsigned int > crateMaskBitmap ;
151  crateMaskBitmap.insert( std::make_pair( "N2", 24 ) ) ;
152  crateMaskBitmap.insert( std::make_pair( "N1", 20 ) ) ;
153  crateMaskBitmap.insert( std::make_pair( "N0", 16 ) ) ;
154  crateMaskBitmap.insert( std::make_pair( "P0", 8 ) ) ;
155  crateMaskBitmap.insert( std::make_pair( "P1", 4 ) ) ;
156  crateMaskBitmap.insert( std::make_pair( "P2", 0 ) ) ;
157 
158  std::map< std::string, unsigned int > krateMaskBitmap ;
159  krateMaskBitmap.insert( std::make_pair( "N2", 16 ) ) ;
160  krateMaskBitmap.insert( std::make_pair( "N1", 12 ) ) ;
161  krateMaskBitmap.insert( std::make_pair( "P0", 8 ) ) ;
162  krateMaskBitmap.insert( std::make_pair( "P1", 4 ) ) ;
163  krateMaskBitmap.insert( std::make_pair( "P2", 0 ) ) ;
164 
165  // Loop over sectors 0-11
166  for( int isc = 0 ; isc < 12 ; ++isc )
167  {
168  int crateNumber = crateNumbers[ isc ] ;
169  unsigned long crateMask = crateMaskL[ crateNumber ] ;
170  if ( sectorNames[ isc ] == "R" ) crateMask = crateMaskR[ crateNumber ] ;
171  unsigned long krateMask = krateMaskL[ crateNumber ] ;
172  if ( sectorNames[ isc ] == "R" ) krateMask = krateMaskR[ crateNumber ] ;
173  std::cout << "isc " << isc << " icr " << crateNumber << std::endl ;
174 
175  // Loop over wheels 0-5
176  for( int iwh = 0 ; iwh < 6 ; ++iwh )
177  {
178  std::string sectorWheelName =
179  sectorNames[ isc ] + wheelNames[ iwh ] ;
180 
181  unsigned int maskBit = 30 ;
182  std::map< std::string, unsigned int >::const_iterator itr =
183  crateMaskBitmap.find( wheelNames[ iwh ] ) ;
184  if( itr != crateMaskBitmap.end() ) maskBit = itr->second ;
185 
186  unsigned long phtfEnabled = ( crateMask >> maskBit ) & 0xF ;
187 
188  if ( wheelNames[ iwh ] == "P2" ) phtfEnabled += ( crateMask >> 24 ) & 0x10 ;
189  if ( wheelNames[ iwh ] == "N2" ) phtfEnabled += ( crateMask >> 25 ) & 0x10 ;
190 
191  std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName
192  << ") of mask " << std::hex << crateMask << " is "
193  << std::hex << phtfEnabled << std::endl ;
194 
195  int nwh = wheelNumbers[ iwh ] ;
196 
197  unsigned long chmask = phtfEnabled & 0x1;
198  std::cout << " INREC_CHDIS_ST1 " << 1-chmask ;
199  pDTTFMasks->set_inrec_chdis_st1( nwh, isc, 1-chmask ) ;
200  chmask = ( phtfEnabled >> 1 ) & 0x1;
201  std::cout << " INREC_CHDIS_ST2 " << 1-chmask ;
202  pDTTFMasks->set_inrec_chdis_st2( nwh, isc, 1-chmask ) ;
203  chmask = ( phtfEnabled >> 2 ) & 0x1;
204  std::cout << " INREC_CHDIS_ST3 " << 1-chmask ;
205  pDTTFMasks->set_inrec_chdis_st3( nwh, isc, 1-chmask ) ;
206  chmask = ( phtfEnabled >> 3 ) & 0x1;
207  std::cout << " INREC_CHDIS_ST4 " << 1-chmask ;
208  pDTTFMasks->set_inrec_chdis_st4( nwh, isc, 1-chmask ) ;
209  chmask = ( phtfEnabled >> 4 ) & 0x1;
210  std::cout << " INREC_CHDIS_CSC " << 1-chmask << std::endl ;
211  pDTTFMasks->set_inrec_chdis_csc( nwh, isc, 1-chmask ) ;
212 
213  if ( wheelNames[ iwh ] == "N0" ) continue ;
214 
215  maskBit = 20 ;
216  itr = krateMaskBitmap.find( wheelNames[ iwh ] ) ;
217  if( itr != krateMaskBitmap.end() ) maskBit = itr->second ;
218 
219  unsigned long ettfEnabled = ( krateMask >> maskBit ) & 0x7 ;
220 
221  std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName
222  << ") of mask " << std::hex << krateMask << " is "
223  << std::hex << ettfEnabled << std::endl ;
224 
225  chmask = ettfEnabled & 0x1;
226  std::cout << " ETSOC_CHDIS_ST1 " << 1-chmask ;
227  pDTTFMasks->set_etsoc_chdis_st1( nwh, isc, 1-chmask ) ;
228  chmask = ( ettfEnabled >> 1 ) & 0x1;
229  std::cout << " ETSOC_CHDIS_ST2 " << 1-chmask ;
230  pDTTFMasks->set_etsoc_chdis_st2( nwh, isc, 1-chmask ) ;
231  chmask = ( ettfEnabled >> 2 ) & 0x1;
232  std::cout << " ETSOC_CHDIS_ST3 " << 1-chmask << std::endl ;
233  pDTTFMasks->set_etsoc_chdis_st3( nwh, isc, 1-chmask ) ;
234  }
235  }
236 
237  return pDTTFMasks ;
238 }
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
#define NULL
Definition: scimark2.h:8
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