00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023
00024
00025 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00026
00027 #include "CondFormats/L1TObjects/interface/L1MuDTTFMasks.h"
00028 #include "CondFormats/DataRecord/interface/L1MuDTTFMasksRcd.h"
00029
00030
00031
00032
00033
00034 class DTTFMasksOnlineProd :
00035 public L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks > {
00036 public:
00037 DTTFMasksOnlineProd(const edm::ParameterSet&);
00038 ~DTTFMasksOnlineProd();
00039
00040 virtual boost::shared_ptr< L1MuDTTFMasks > newObject(
00041 const std::string& objectKey ) ;
00042
00043 private:
00044
00045
00046 };
00047
00048
00049
00050
00051 DTTFMasksOnlineProd::DTTFMasksOnlineProd(
00052 const edm::ParameterSet& iConfig)
00053 : L1ConfigOnlineProdBase< L1MuDTTFMasksRcd, L1MuDTTFMasks >( iConfig )
00054 {
00055
00056
00057
00058
00059 }
00060
00061
00062 DTTFMasksOnlineProd::~DTTFMasksOnlineProd()
00063 {
00064
00065
00066
00067
00068 }
00069
00070 boost::shared_ptr< L1MuDTTFMasks >
00071 DTTFMasksOnlineProd::newObject( const std::string& objectKey )
00072 {
00073 using namespace edm::es;
00074
00075 boost::shared_ptr< L1MuDTTFMasks > pDTTFMasks(
00076 new L1MuDTTFMasks() ) ;
00077
00078 pDTTFMasks->reset() ;
00079
00080 std::string dttfSchema = "CMS_DT_TF" ;
00081
00082
00083 std::vector< std::string > crateMaskColumns ;
00084 crateMaskColumns.push_back( "WEDGE_CRATE_1" ) ;
00085 crateMaskColumns.push_back( "WEDGE_CRATE_2" ) ;
00086 crateMaskColumns.push_back( "WEDGE_CRATE_3" ) ;
00087 crateMaskColumns.push_back( "WEDGE_CRATE_4" ) ;
00088 crateMaskColumns.push_back( "WEDGE_CRATE_5" ) ;
00089 crateMaskColumns.push_back( "WEDGE_CRATE_6" ) ;
00090 crateMaskColumns.push_back( "WEDGE_CRATE_1_E" ) ;
00091 crateMaskColumns.push_back( "WEDGE_CRATE_2_E" ) ;
00092 crateMaskColumns.push_back( "WEDGE_CRATE_3_E" ) ;
00093 crateMaskColumns.push_back( "WEDGE_CRATE_4_E" ) ;
00094 crateMaskColumns.push_back( "WEDGE_CRATE_5_E" ) ;
00095 crateMaskColumns.push_back( "WEDGE_CRATE_6_E" ) ;
00096
00097 l1t::OMDSReader::QueryResults crateMaskResults =
00098 m_omdsReader.basicQuery( crateMaskColumns,
00099 dttfSchema,
00100 "DTTF_RUN_SETTINGS",
00101 "DTTF_RUN_SETTINGS.ID",
00102 m_omdsReader.singleAttribute( objectKey ) ) ;
00103
00104 if( crateMaskResults.queryFailed() ||
00105 crateMaskResults.numberRows() != 1 )
00106 {
00107 edm::LogError( "L1-O2O" )
00108 << "Problem with L1MuDTTFMasks key " << objectKey ;
00109 return boost::shared_ptr< L1MuDTTFMasks >() ;
00110 }
00111
00112
00113 unsigned long crateMaskL[ 6 ] ;
00114 unsigned long crateMaskR[ 6 ] ;
00115 unsigned long krateMaskL[ 6 ] ;
00116 unsigned long krateMaskR[ 6 ] ;
00117 for( int icrate = 0 ; icrate < 6 ; ++icrate )
00118 {
00119 std::string crateMask ;
00120 crateMaskResults.fillVariable( crateMaskColumns[ icrate ],
00121 crateMask ) ;
00122 char* pEnd;
00123 crateMaskL[ icrate ] = std::strtol( crateMask.c_str(), &pEnd, 16 ) ;
00124 crateMaskR[ icrate ] = std::strtol( pEnd, (char **)NULL, 16 ) ;
00125
00126 crateMaskResults.fillVariable( crateMaskColumns[ icrate+6 ],
00127 crateMask ) ;
00128 krateMaskL[ icrate ] = std::strtol( crateMask.c_str(), &pEnd, 16 ) ;
00129 krateMaskR[ icrate ] = std::strtol( pEnd, (char **)NULL, 16 ) ;
00130
00131 std::cout << "Crate " << icrate << " masks"
00132 << " L: " << std::hex << crateMaskL[ icrate ]
00133 << " " << std::hex << krateMaskL[ icrate ]
00134 << " R: " << std::hex << crateMaskR[ icrate ]
00135 << " " << std::hex << krateMaskR[ icrate ] << std::endl ;
00136 }
00137
00138
00139 std::string sectorNames[ 12 ] = {
00140 "R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L" } ;
00141
00142
00143 int crateNumbers[ 12 ] = { 3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0 } ;
00144
00145
00146 int wheelNumbers[ 6 ] = { -3, -2, -1, 1, 2, 3 } ;
00147
00148
00149 std::string wheelNames[ 6 ] = { "N2", "N1", "N0", "P0", "P1", "P2" } ;
00150
00151
00152 std::map< std::string, unsigned int > crateMaskBitmap ;
00153 crateMaskBitmap.insert( std::make_pair( "N2", 24 ) ) ;
00154 crateMaskBitmap.insert( std::make_pair( "N1", 20 ) ) ;
00155 crateMaskBitmap.insert( std::make_pair( "N0", 16 ) ) ;
00156 crateMaskBitmap.insert( std::make_pair( "P0", 8 ) ) ;
00157 crateMaskBitmap.insert( std::make_pair( "P1", 4 ) ) ;
00158 crateMaskBitmap.insert( std::make_pair( "P2", 0 ) ) ;
00159
00160 std::map< std::string, unsigned int > krateMaskBitmap ;
00161 krateMaskBitmap.insert( std::make_pair( "N2", 16 ) ) ;
00162 krateMaskBitmap.insert( std::make_pair( "N1", 12 ) ) ;
00163 krateMaskBitmap.insert( std::make_pair( "P0", 8 ) ) ;
00164 krateMaskBitmap.insert( std::make_pair( "P1", 4 ) ) ;
00165 krateMaskBitmap.insert( std::make_pair( "P2", 0 ) ) ;
00166
00167
00168 for( int isc = 0 ; isc < 12 ; ++isc )
00169 {
00170 int crateNumber = crateNumbers[ isc ] ;
00171 unsigned long crateMask = crateMaskL[ crateNumber ] ;
00172 if ( sectorNames[ isc ] == "R" ) crateMask = crateMaskR[ crateNumber ] ;
00173 unsigned long krateMask = krateMaskL[ crateNumber ] ;
00174 if ( sectorNames[ isc ] == "R" ) krateMask = krateMaskR[ crateNumber ] ;
00175 std::cout << "isc " << isc << " icr " << crateNumber << std::endl ;
00176
00177
00178 for( int iwh = 0 ; iwh < 6 ; ++iwh )
00179 {
00180 std::string sectorWheelName =
00181 sectorNames[ isc ] + wheelNames[ iwh ] ;
00182
00183 unsigned int maskBit = 30 ;
00184 std::map< std::string, unsigned int >::const_iterator itr =
00185 crateMaskBitmap.find( wheelNames[ iwh ] ) ;
00186 if( itr != crateMaskBitmap.end() ) maskBit = itr->second ;
00187
00188 unsigned long phtfEnabled = ( crateMask >> maskBit ) & 0xF ;
00189
00190 if ( wheelNames[ iwh ] == "P2" ) phtfEnabled += ( crateMask >> 24 ) & 0x10 ;
00191 if ( wheelNames[ iwh ] == "N2" ) phtfEnabled += ( crateMask >> 25 ) & 0x10 ;
00192
00193 std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName
00194 << ") of mask " << std::hex << crateMask << " is "
00195 << std::hex << phtfEnabled << std::endl ;
00196
00197 int nwh = wheelNumbers[ iwh ] ;
00198
00199 unsigned long chmask = phtfEnabled & 0x1;
00200 std::cout << " INREC_CHDIS_ST1 " << 1-chmask ;
00201 pDTTFMasks->set_inrec_chdis_st1( nwh, isc, 1-chmask ) ;
00202 chmask = ( phtfEnabled >> 1 ) & 0x1;
00203 std::cout << " INREC_CHDIS_ST2 " << 1-chmask ;
00204 pDTTFMasks->set_inrec_chdis_st2( nwh, isc, 1-chmask ) ;
00205 chmask = ( phtfEnabled >> 2 ) & 0x1;
00206 std::cout << " INREC_CHDIS_ST3 " << 1-chmask ;
00207 pDTTFMasks->set_inrec_chdis_st3( nwh, isc, 1-chmask ) ;
00208 chmask = ( phtfEnabled >> 3 ) & 0x1;
00209 std::cout << " INREC_CHDIS_ST4 " << 1-chmask ;
00210 pDTTFMasks->set_inrec_chdis_st4( nwh, isc, 1-chmask ) ;
00211 chmask = ( phtfEnabled >> 4 ) & 0x1;
00212 std::cout << " INREC_CHDIS_CSC " << 1-chmask << std::endl ;
00213 pDTTFMasks->set_inrec_chdis_csc( nwh, isc, 1-chmask ) ;
00214
00215 if ( wheelNames[ iwh ] == "N0" ) continue ;
00216
00217 maskBit = 20 ;
00218 itr = krateMaskBitmap.find( wheelNames[ iwh ] ) ;
00219 if( itr != krateMaskBitmap.end() ) maskBit = itr->second ;
00220
00221 unsigned long ettfEnabled = ( krateMask >> maskBit ) & 0x7 ;
00222
00223 std::cout << "Bits " << std::dec << maskBit << " (" << sectorWheelName
00224 << ") of mask " << std::hex << krateMask << " is "
00225 << std::hex << ettfEnabled << std::endl ;
00226
00227 chmask = ettfEnabled & 0x1;
00228 std::cout << " ETSOC_CHDIS_ST1 " << 1-chmask ;
00229 pDTTFMasks->set_etsoc_chdis_st1( nwh, isc, 1-chmask ) ;
00230 chmask = ( ettfEnabled >> 1 ) & 0x1;
00231 std::cout << " ETSOC_CHDIS_ST2 " << 1-chmask ;
00232 pDTTFMasks->set_etsoc_chdis_st2( nwh, isc, 1-chmask ) ;
00233 chmask = ( ettfEnabled >> 2 ) & 0x1;
00234 std::cout << " ETSOC_CHDIS_ST3 " << 1-chmask << std::endl ;
00235 pDTTFMasks->set_etsoc_chdis_st3( nwh, isc, 1-chmask ) ;
00236 }
00237 }
00238
00239 return pDTTFMasks ;
00240 }
00241
00242
00243
00244
00245
00246 DEFINE_FWK_EVENTSETUP_MODULE(DTTFMasksOnlineProd);