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 // system include files
20 #include <iostream>
21 
22 // user include files
24 
27 
28 //
29 // class declaration
30 //
31 
32 class DTTFParametersOnlineProd : public L1ConfigOnlineProdBase<L1MuDTTFParametersRcd, L1MuDTTFParameters> {
33 public:
35  ~DTTFParametersOnlineProd() override;
36 
37  std::unique_ptr<L1MuDTTFParameters> newObject(const std::string& objectKey) override;
38 
39 private:
40  // ----------member data ---------------------------
41 };
42 
43 //
44 // constructors and destructor
45 //
48  //the following line is needed to tell the framework what
49  // data is being produced
50 
51  //now do what ever other initialization is needed
52 }
53 
55  // do anything here that needs to be done at desctruction time
56  // (e.g. close files, deallocate resources etc.)
57 }
58 
59 std::unique_ptr<L1MuDTTFParameters> DTTFParametersOnlineProd::newObject(const std::string& objectKey) {
60  auto pDTTFParameters = std::make_unique<L1MuDTTFParameters>();
61 
62  pDTTFParameters->reset();
63 
64  std::string dttfSchema = "CMS_DT_TF";
65 
66  // Order of strings is used below -- don't change!
67  std::vector<std::string> crateKeyColumns;
68  crateKeyColumns.push_back("WEDGE_CRATE_1");
69  crateKeyColumns.push_back("WEDGE_CRATE_2");
70  crateKeyColumns.push_back("WEDGE_CRATE_3");
71  crateKeyColumns.push_back("WEDGE_CRATE_4");
72  crateKeyColumns.push_back("WEDGE_CRATE_5");
73  crateKeyColumns.push_back("WEDGE_CRATE_6");
74 
76  crateKeyColumns, dttfSchema, "DTTF_CONF", "DTTF_CONF.ID", m_omdsReader.singleAttribute(objectKey));
77 
78  if (crateKeyResults.queryFailed() || crateKeyResults.numberRows() != 1) // check query successful
79  {
80  edm::LogError("L1-O2O") << "Problem with L1MuDTTFParameters key " << objectKey;
81  return std::unique_ptr<L1MuDTTFParameters>();
82  }
83 
84  // print crate keys -- delete when done debugging
85  std::string crateKeys[6];
86  for (int icrate = 0; icrate < 6; ++icrate) {
87  crateKeyResults.fillVariable(crateKeyColumns[icrate], crateKeys[icrate]);
88  std::cout << "Crate " << icrate << " key " << crateKeys[icrate] << std::endl;
89  }
90 
91  // Map of sector (0-11) to name (L/R)
92  std::string sectorNames[12] = {"R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L"};
93 
94  // Map of sector (0-11) to crate (0-5)
95  int crateNumbers[12] = {3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0};
96 
97  // Map of wheel array index to wheel number (+- 3, 2, 1).
98  int wheelNumbers[6] = {-3, -2, -1, 1, 2, 3};
99 
100  // Map of wheel array index to name ({N,P}{0,1,2}).
101  std::string wheelNames[6] = {"N2", "N1", "N0", "P0", "P1", "P2"};
102 
103  // Needed over and over later
104  std::vector<std::string> phtfMaskColumns;
105  phtfMaskColumns.push_back("INREC_QUAL_ST1");
106  phtfMaskColumns.push_back("INREC_QUAL_ST2");
107  phtfMaskColumns.push_back("INREC_QUAL_ST3");
108  phtfMaskColumns.push_back("INREC_QUAL_ST4");
109  phtfMaskColumns.push_back("SOC_QUAL_CSC");
110  phtfMaskColumns.push_back("SOC_STDIS_N");
111  phtfMaskColumns.push_back("SOC_STDIS_WL");
112  phtfMaskColumns.push_back("SOC_STDIS_WR");
113  phtfMaskColumns.push_back("SOC_STDIS_ZL");
114  phtfMaskColumns.push_back("SOC_STDIS_ZR");
115  phtfMaskColumns.push_back("SOC_QCUT_ST1");
116  phtfMaskColumns.push_back("SOC_QCUT_ST2");
117  phtfMaskColumns.push_back("SOC_QCUT_ST4");
118  phtfMaskColumns.push_back("SOC_RUN_21");
119  phtfMaskColumns.push_back("SOC_NBX_DEL");
120  phtfMaskColumns.push_back("SOC_CSC_ETACANC");
121  phtfMaskColumns.push_back("SOC_OPENLUT_EXTR");
122 
123  // Loop over sectors 0-11
124  for (int isc = 0; isc < 12; ++isc) {
125  int crateNumber = crateNumbers[isc];
126  std::cout << "isc " << isc << " icr " << crateNumber << std::endl;
127 
128  // Loop over wheels 0-5
129  for (int iwh = 0; iwh < 6; ++iwh) {
130  std::string sectorWheelName = sectorNames[isc] + wheelNames[iwh];
131 
132  int nwh = wheelNumbers[iwh];
133 
134  // Check if non-null crate key
135  std::string crateKey;
136  if (crateKeyResults.fillVariable(crateKeyColumns[crateNumber], crateKey)) {
137  // Get PHTF key
138  std::vector<std::string> phtfKeyColumns;
139  phtfKeyColumns.push_back("PHTF_" + sectorWheelName);
140 
141  l1t::OMDSReader::QueryResults phtfKeyResults = m_omdsReader.basicQuery(phtfKeyColumns,
142  dttfSchema,
143  "WEDGE_CRATE_CONF",
144  "WEDGE_CRATE_CONF.ID",
145  crateKeyResults,
146  crateKeyColumns[crateNumber]);
147 
148  if (phtfKeyResults.queryFailed() || phtfKeyResults.numberRows() != 1) {
149  edm::LogError("L1-O2O") << "Problem with WEDGE_CRATE_CONF key.";
150  return std::unique_ptr<L1MuDTTFParameters>();
151  }
152 
154  if (phtfKeyResults.fillVariable(dummy)) {
155  std::cout << "PHTF key " << dummy << std::endl;
156 
157  l1t::OMDSReader::QueryResults phtfMaskResults =
158  m_omdsReader.basicQuery(phtfMaskColumns, dttfSchema, "PHTF_CONF", "PHTF_CONF.ID", phtfKeyResults);
159 
160  if (phtfMaskResults.queryFailed() || phtfMaskResults.numberRows() != 1) {
161  edm::LogError("L1-O2O") << "Problem with PHTF_CONF key.";
162  return std::unique_ptr<L1MuDTTFParameters>();
163  }
164 
165  long long tmp;
166 
167  phtfMaskResults.fillVariable("INREC_QUAL_ST1", tmp);
168  std::cout << " INREC_QUAL_ST1 " << tmp;
169  pDTTFParameters->set_inrec_qual_st1(nwh, isc, tmp);
170  phtfMaskResults.fillVariable("INREC_QUAL_ST2", tmp);
171  std::cout << " INREC_QUAL_ST2 " << tmp;
172  pDTTFParameters->set_inrec_qual_st2(nwh, isc, tmp);
173  phtfMaskResults.fillVariable("INREC_QUAL_ST3", tmp);
174  std::cout << " INREC_QUAL_ST3 " << tmp;
175  pDTTFParameters->set_inrec_qual_st3(nwh, isc, tmp);
176  phtfMaskResults.fillVariable("INREC_QUAL_ST4", tmp);
177  std::cout << " INREC_QUAL_ST4 " << tmp << std::endl;
178  pDTTFParameters->set_inrec_qual_st4(nwh, isc, tmp);
179  std::cout << " SOC_QUAL_CSC " << tmp << std::endl;
180  pDTTFParameters->set_soc_qual_csc(nwh, isc, tmp);
181 
182  phtfMaskResults.fillVariable("SOC_STDIS_N", tmp);
183  std::cout << " SOC_STDIS_N " << tmp;
184  pDTTFParameters->set_soc_stdis_n(nwh, isc, tmp);
185  phtfMaskResults.fillVariable("SOC_STDIS_WL", tmp);
186  std::cout << " SOC_STDIS_WL " << tmp;
187  pDTTFParameters->set_soc_stdis_wl(nwh, isc, tmp);
188  phtfMaskResults.fillVariable("SOC_STDIS_WR", tmp);
189  std::cout << " SOC_STDIS_WR " << tmp;
190  pDTTFParameters->set_soc_stdis_wr(nwh, isc, tmp);
191  phtfMaskResults.fillVariable("SOC_STDIS_ZL", tmp);
192  std::cout << " SOC_STDIS_ZL " << tmp;
193  pDTTFParameters->set_soc_stdis_zl(nwh, isc, tmp);
194  phtfMaskResults.fillVariable("SOC_STDIS_ZR", tmp);
195  std::cout << " SOC_STDIS_ZR " << tmp << std::endl;
196  pDTTFParameters->set_soc_stdis_zr(nwh, isc, tmp);
197 
198  phtfMaskResults.fillVariable("SOC_QCUT_ST1", tmp);
199  std::cout << " SOC_QCUT_ST1 " << tmp;
200  pDTTFParameters->set_soc_qcut_st1(nwh, isc, tmp);
201  phtfMaskResults.fillVariable("SOC_QCUT_ST2", tmp);
202  std::cout << " SOC_QCUT_ST2 " << tmp;
203  pDTTFParameters->set_soc_qcut_st2(nwh, isc, tmp);
204  phtfMaskResults.fillVariable("SOC_QCUT_ST4", tmp);
205  std::cout << " SOC_QCUT_ST4 " << tmp << std::endl;
206  pDTTFParameters->set_soc_qcut_st4(nwh, isc, tmp);
207 
208  phtfMaskResults.fillVariable("SOC_RUN_21", tmp);
209  std::cout << " SOC_RUN_21 " << tmp;
210  pDTTFParameters->set_soc_run_21(nwh, isc, tmp);
211  phtfMaskResults.fillVariable("SOC_NBX_DEL", tmp);
212  std::cout << " SOC_NBX_DEL " << tmp;
213  pDTTFParameters->set_soc_nbx_del(nwh, isc, tmp);
214  phtfMaskResults.fillVariable("SOC_CSC_ETACANC", tmp);
215  std::cout << " SOC_CSC_ETACANC " << tmp;
216  pDTTFParameters->set_soc_csc_etacanc(nwh, isc, tmp);
217  phtfMaskResults.fillVariable("SOC_OPENLUT_EXTR", tmp);
218  std::cout << " SOC_OPENLUT_EXTR " << tmp << std::endl;
219  pDTTFParameters->set_soc_openlut_extr(nwh, isc, tmp);
220  }
221  }
222  }
223  }
224 
225  return pDTTFParameters;
226 }
227 
228 // ------------ method called to produce the data ------------
229 
230 //define this as a plug-in
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
DTTFParametersOnlineProd(const edm::ParameterSet &)
Log< level::Error, false > LogError
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:75
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
std::unique_ptr< L1MuDTTFParameters > newObject(const std::string &objectKey) override
tmp
align.sh
Definition: createJobs.py:716