CMS 3D CMS Logo

DTTFParametersOnlineProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DTTFParametersOnlineProd
4 // Class: DTTFParametersOnlineProd
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Fri Oct 3 00:26:52 CEST 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <iostream>
22 
23 // user include files
25 
28 
29 //
30 // class declaration
31 //
32 
34  public L1ConfigOnlineProdBase< L1MuDTTFParametersRcd, L1MuDTTFParameters > {
35  public:
37  ~DTTFParametersOnlineProd() override;
38 
39  std::shared_ptr< L1MuDTTFParameters > newObject(
40  const std::string& objectKey ) override ;
41 
42  private:
43 
44  // ----------member data ---------------------------
45 };
46 
47 //
48 // constructors and destructor
49 //
51  const edm::ParameterSet& iConfig)
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 }
59 
60 
62 {
63 
64  // do anything here that needs to be done at desctruction time
65  // (e.g. close files, deallocate resources etc.)
66 
67 }
68 
69 std::shared_ptr< L1MuDTTFParameters >
71 {
72  using namespace edm::es;
73 
74  auto pDTTFParameters = std::make_shared< L1MuDTTFParameters >() ;
75 
76  pDTTFParameters->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 > crateKeyColumns ;
82  crateKeyColumns.push_back( "WEDGE_CRATE_1" ) ;
83  crateKeyColumns.push_back( "WEDGE_CRATE_2" ) ;
84  crateKeyColumns.push_back( "WEDGE_CRATE_3" ) ;
85  crateKeyColumns.push_back( "WEDGE_CRATE_4" ) ;
86  crateKeyColumns.push_back( "WEDGE_CRATE_5" ) ;
87  crateKeyColumns.push_back( "WEDGE_CRATE_6" ) ;
88 
89  l1t::OMDSReader::QueryResults crateKeyResults =
90  m_omdsReader.basicQuery( crateKeyColumns,
91  dttfSchema,
92  "DTTF_CONF",
93  "DTTF_CONF.ID",
94  m_omdsReader.singleAttribute( objectKey ) ) ;
95 
96  if( crateKeyResults.queryFailed() ||
97  crateKeyResults.numberRows() != 1 ) // check query successful
98  {
99  edm::LogError( "L1-O2O" )
100  << "Problem with L1MuDTTFParameters key " << objectKey ;
101  return std::shared_ptr< L1MuDTTFParameters >() ;
102  }
103 
104  // print crate keys -- delete when done debugging
105  std::string crateKeys[ 6 ] ;
106  for( int icrate = 0 ; icrate < 6 ; ++icrate )
107  {
108  crateKeyResults.fillVariable( crateKeyColumns[ icrate ],
109  crateKeys[ icrate ] ) ;
110  std::cout << "Crate " << icrate << " key "
111  << crateKeys[ icrate ] << std::endl ;
112  }
113 
114  // Map of sector (0-11) to name (L/R)
115  std::string sectorNames[ 12 ] = {
116  "R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L" } ;
117 
118  // Map of sector (0-11) to crate (0-5)
119  int crateNumbers[ 12 ] = { 3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0 } ;
120 
121  // Map of wheel array index to wheel number (+- 3, 2, 1).
122  int wheelNumbers[ 6 ] = { -3, -2, -1, 1, 2, 3 } ;
123 
124  // Map of wheel array index to name ({N,P}{0,1,2}).
125  std::string wheelNames[ 6 ] = { "N2", "N1", "N0", "P0", "P1", "P2" } ;
126 
127  // Needed over and over later
128  std::vector< std::string > phtfMaskColumns ;
129  phtfMaskColumns.push_back( "INREC_QUAL_ST1" ) ;
130  phtfMaskColumns.push_back( "INREC_QUAL_ST2" ) ;
131  phtfMaskColumns.push_back( "INREC_QUAL_ST3" ) ;
132  phtfMaskColumns.push_back( "INREC_QUAL_ST4" ) ;
133  phtfMaskColumns.push_back( "SOC_QUAL_CSC" ) ;
134  phtfMaskColumns.push_back( "SOC_STDIS_N" ) ;
135  phtfMaskColumns.push_back( "SOC_STDIS_WL" ) ;
136  phtfMaskColumns.push_back( "SOC_STDIS_WR" ) ;
137  phtfMaskColumns.push_back( "SOC_STDIS_ZL" ) ;
138  phtfMaskColumns.push_back( "SOC_STDIS_ZR" ) ;
139  phtfMaskColumns.push_back( "SOC_QCUT_ST1" ) ;
140  phtfMaskColumns.push_back( "SOC_QCUT_ST2" ) ;
141  phtfMaskColumns.push_back( "SOC_QCUT_ST4" ) ;
142  phtfMaskColumns.push_back( "SOC_RUN_21" ) ;
143  phtfMaskColumns.push_back( "SOC_NBX_DEL" ) ;
144  phtfMaskColumns.push_back( "SOC_CSC_ETACANC" ) ;
145  phtfMaskColumns.push_back( "SOC_OPENLUT_EXTR" ) ;
146 
147  // Loop over sectors 0-11
148  for( int isc = 0 ; isc < 12 ; ++isc )
149  {
150  int crateNumber = crateNumbers[ isc ] ;
151  std::cout << "isc " << isc << " icr " << crateNumber << std::endl ;
152 
153  // Loop over wheels 0-5
154  for( int iwh = 0 ; iwh < 6 ; ++iwh )
155  {
156  std::string sectorWheelName =
157  sectorNames[ isc ] + wheelNames[ iwh ] ;
158 
159  int nwh = wheelNumbers[ iwh ] ;
160 
161  // Check if non-null crate key
162  std::string crateKey ;
163  if( crateKeyResults.fillVariable( crateKeyColumns[ crateNumber ],
164  crateKey ) )
165  {
166  // Get PHTF key
167  std::vector< std::string > phtfKeyColumns ;
168  phtfKeyColumns.push_back( "PHTF_" + sectorWheelName ) ;
169 
170  l1t::OMDSReader::QueryResults phtfKeyResults =
171  m_omdsReader.basicQuery( phtfKeyColumns,
172  dttfSchema,
173  "WEDGE_CRATE_CONF",
174  "WEDGE_CRATE_CONF.ID",
175  crateKeyResults,
176  crateKeyColumns[ crateNumber ] ) ;
177 
178  if( phtfKeyResults.queryFailed() ||
179  phtfKeyResults.numberRows() != 1 )
180  {
181  edm::LogError( "L1-O2O" )
182  << "Problem with WEDGE_CRATE_CONF key." ;
183  return std::shared_ptr< L1MuDTTFParameters >() ;
184  }
185 
187  if( phtfKeyResults.fillVariable( dummy ) )
188  {
189  std::cout << "PHTF key " << dummy << std::endl ;
190 
191  l1t::OMDSReader::QueryResults phtfMaskResults =
192  m_omdsReader.basicQuery( phtfMaskColumns,
193  dttfSchema,
194  "PHTF_CONF",
195  "PHTF_CONF.ID",
196  phtfKeyResults ) ;
197 
198  if( phtfMaskResults.queryFailed() ||
199  phtfMaskResults.numberRows() != 1 )
200  {
201  edm::LogError( "L1-O2O" )
202  << "Problem with PHTF_CONF key." ;
203  return std::shared_ptr< L1MuDTTFParameters >() ;
204  }
205 
206  long long tmp ;
207 
208  phtfMaskResults.fillVariable( "INREC_QUAL_ST1", tmp ) ;
209  std::cout << " INREC_QUAL_ST1 " << tmp ;
210  pDTTFParameters->set_inrec_qual_st1( nwh, isc, tmp ) ;
211  phtfMaskResults.fillVariable( "INREC_QUAL_ST2", tmp ) ;
212  std::cout << " INREC_QUAL_ST2 " << tmp ;
213  pDTTFParameters->set_inrec_qual_st2( nwh, isc, tmp ) ;
214  phtfMaskResults.fillVariable( "INREC_QUAL_ST3", tmp ) ;
215  std::cout << " INREC_QUAL_ST3 " << tmp ;
216  pDTTFParameters->set_inrec_qual_st3( nwh, isc, tmp ) ;
217  phtfMaskResults.fillVariable( "INREC_QUAL_ST4", tmp ) ;
218  std::cout << " INREC_QUAL_ST4 " << tmp << std::endl ;
219  pDTTFParameters->set_inrec_qual_st4( nwh, isc, tmp ) ;
220  std::cout << " SOC_QUAL_CSC " << tmp << std::endl ;
221  pDTTFParameters->set_soc_qual_csc( nwh, isc, tmp ) ;
222 
223  phtfMaskResults.fillVariable( "SOC_STDIS_N", tmp ) ;
224  std::cout << " SOC_STDIS_N " << tmp ;
225  pDTTFParameters->set_soc_stdis_n( nwh, isc, tmp ) ;
226  phtfMaskResults.fillVariable( "SOC_STDIS_WL", tmp ) ;
227  std::cout << " SOC_STDIS_WL " << tmp ;
228  pDTTFParameters->set_soc_stdis_wl( nwh, isc, tmp ) ;
229  phtfMaskResults.fillVariable( "SOC_STDIS_WR", tmp ) ;
230  std::cout << " SOC_STDIS_WR " << tmp ;
231  pDTTFParameters->set_soc_stdis_wr( nwh, isc, tmp ) ;
232  phtfMaskResults.fillVariable( "SOC_STDIS_ZL", tmp ) ;
233  std::cout << " SOC_STDIS_ZL " << tmp ;
234  pDTTFParameters->set_soc_stdis_zl( nwh, isc, tmp ) ;
235  phtfMaskResults.fillVariable( "SOC_STDIS_ZR", tmp ) ;
236  std::cout << " SOC_STDIS_ZR " << tmp << std::endl ;
237  pDTTFParameters->set_soc_stdis_zr( nwh, isc, tmp ) ;
238 
239  phtfMaskResults.fillVariable( "SOC_QCUT_ST1", tmp ) ;
240  std::cout << " SOC_QCUT_ST1 " << tmp ;
241  pDTTFParameters->set_soc_qcut_st1( nwh, isc, tmp ) ;
242  phtfMaskResults.fillVariable( "SOC_QCUT_ST2", tmp ) ;
243  std::cout << " SOC_QCUT_ST2 " << tmp ;
244  pDTTFParameters->set_soc_qcut_st2( nwh, isc, tmp ) ;
245  phtfMaskResults.fillVariable( "SOC_QCUT_ST4", tmp ) ;
246  std::cout << " SOC_QCUT_ST4 " << tmp << std::endl ;
247  pDTTFParameters->set_soc_qcut_st4( nwh, isc, tmp ) ;
248 
249  phtfMaskResults.fillVariable( "SOC_RUN_21", tmp ) ;
250  std::cout << " SOC_RUN_21 " << tmp ;
251  pDTTFParameters->set_soc_run_21( nwh, isc, tmp ) ;
252  phtfMaskResults.fillVariable( "SOC_NBX_DEL", tmp ) ;
253  std::cout << " SOC_NBX_DEL " << tmp ;
254  pDTTFParameters->set_soc_nbx_del( nwh, isc, tmp ) ;
255  phtfMaskResults.fillVariable( "SOC_CSC_ETACANC", tmp ) ;
256  std::cout << " SOC_CSC_ETACANC " << tmp ;
257  pDTTFParameters->set_soc_csc_etacanc( nwh, isc, tmp ) ;
258  phtfMaskResults.fillVariable( "SOC_OPENLUT_EXTR", tmp ) ;
259  std::cout << " SOC_OPENLUT_EXTR " << tmp << std::endl ;
260  pDTTFParameters->set_soc_openlut_extr( nwh, isc, tmp ) ;
261  }
262  }
263  }
264  }
265 
266  return pDTTFParameters ;
267 }
268 
269 // ------------ method called to produce the data ------------
270 
271 
272 //define this as a plug-in
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
DTTFParametersOnlineProd(const edm::ParameterSet &)
std::shared_ptr< L1MuDTTFParameters > newObject(const std::string &objectKey) override
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
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100