Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:05

0001 // -*- C++ -*-
0002 //
0003 // Package:    DTTFParametersOnlineProd
0004 // Class:      DTTFParametersOnlineProd
0005 //
0006 /**\class DTTFParametersOnlineProd DTTFParametersOnlineProd.h L1TriggerConfig/DTTrackFinder/src/DTTFParametersOnlineProd.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Werner Man-Li Sun
0015 //         Created:  Fri Oct  3 00:26:52 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <iostream>
0021 
0022 // user include files
0023 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0024 
0025 #include "CondFormats/L1TObjects/interface/L1MuDTTFParameters.h"
0026 #include "CondFormats/DataRecord/interface/L1MuDTTFParametersRcd.h"
0027 
0028 //
0029 // class declaration
0030 //
0031 
0032 class DTTFParametersOnlineProd : public L1ConfigOnlineProdBase<L1MuDTTFParametersRcd, L1MuDTTFParameters> {
0033 public:
0034   DTTFParametersOnlineProd(const edm::ParameterSet&);
0035   ~DTTFParametersOnlineProd() override;
0036 
0037   std::unique_ptr<L1MuDTTFParameters> newObject(const std::string& objectKey) override;
0038 
0039 private:
0040   // ----------member data ---------------------------
0041 };
0042 
0043 //
0044 // constructors and destructor
0045 //
0046 DTTFParametersOnlineProd::DTTFParametersOnlineProd(const edm::ParameterSet& iConfig)
0047     : L1ConfigOnlineProdBase<L1MuDTTFParametersRcd, L1MuDTTFParameters>(iConfig) {
0048   //the following line is needed to tell the framework what
0049   // data is being produced
0050 
0051   //now do what ever other initialization is needed
0052 }
0053 
0054 DTTFParametersOnlineProd::~DTTFParametersOnlineProd() {
0055   // do anything here that needs to be done at desctruction time
0056   // (e.g. close files, deallocate resources etc.)
0057 }
0058 
0059 std::unique_ptr<L1MuDTTFParameters> DTTFParametersOnlineProd::newObject(const std::string& objectKey) {
0060   auto pDTTFParameters = std::make_unique<L1MuDTTFParameters>();
0061 
0062   pDTTFParameters->reset();
0063 
0064   std::string dttfSchema = "CMS_DT_TF";
0065 
0066   // Order of strings is used below -- don't change!
0067   std::vector<std::string> crateKeyColumns;
0068   crateKeyColumns.push_back("WEDGE_CRATE_1");
0069   crateKeyColumns.push_back("WEDGE_CRATE_2");
0070   crateKeyColumns.push_back("WEDGE_CRATE_3");
0071   crateKeyColumns.push_back("WEDGE_CRATE_4");
0072   crateKeyColumns.push_back("WEDGE_CRATE_5");
0073   crateKeyColumns.push_back("WEDGE_CRATE_6");
0074 
0075   l1t::OMDSReader::QueryResults crateKeyResults = m_omdsReader.basicQuery(
0076       crateKeyColumns, dttfSchema, "DTTF_CONF", "DTTF_CONF.ID", m_omdsReader.singleAttribute(objectKey));
0077 
0078   if (crateKeyResults.queryFailed() || crateKeyResults.numberRows() != 1)  // check query successful
0079   {
0080     edm::LogError("L1-O2O") << "Problem with L1MuDTTFParameters key " << objectKey;
0081     return std::unique_ptr<L1MuDTTFParameters>();
0082   }
0083 
0084   // print crate keys -- delete when done debugging
0085   std::string crateKeys[6];
0086   for (int icrate = 0; icrate < 6; ++icrate) {
0087     crateKeyResults.fillVariable(crateKeyColumns[icrate], crateKeys[icrate]);
0088     std::cout << "Crate " << icrate << " key " << crateKeys[icrate] << std::endl;
0089   }
0090 
0091   // Map of sector (0-11) to name (L/R)
0092   std::string sectorNames[12] = {"R", "L", "R", "L", "L", "R", "L", "R", "R", "L", "R", "L"};
0093 
0094   // Map of sector (0-11) to crate (0-5)
0095   int crateNumbers[12] = {3, 3, 4, 4, 5, 5, 2, 2, 1, 1, 0, 0};
0096 
0097   // Map of wheel array index to wheel number (+- 3, 2, 1).
0098   int wheelNumbers[6] = {-3, -2, -1, 1, 2, 3};
0099 
0100   // Map of wheel array index to name ({N,P}{0,1,2}).
0101   std::string wheelNames[6] = {"N2", "N1", "N0", "P0", "P1", "P2"};
0102 
0103   // Needed over and over later
0104   std::vector<std::string> phtfMaskColumns;
0105   phtfMaskColumns.push_back("INREC_QUAL_ST1");
0106   phtfMaskColumns.push_back("INREC_QUAL_ST2");
0107   phtfMaskColumns.push_back("INREC_QUAL_ST3");
0108   phtfMaskColumns.push_back("INREC_QUAL_ST4");
0109   phtfMaskColumns.push_back("SOC_QUAL_CSC");
0110   phtfMaskColumns.push_back("SOC_STDIS_N");
0111   phtfMaskColumns.push_back("SOC_STDIS_WL");
0112   phtfMaskColumns.push_back("SOC_STDIS_WR");
0113   phtfMaskColumns.push_back("SOC_STDIS_ZL");
0114   phtfMaskColumns.push_back("SOC_STDIS_ZR");
0115   phtfMaskColumns.push_back("SOC_QCUT_ST1");
0116   phtfMaskColumns.push_back("SOC_QCUT_ST2");
0117   phtfMaskColumns.push_back("SOC_QCUT_ST4");
0118   phtfMaskColumns.push_back("SOC_RUN_21");
0119   phtfMaskColumns.push_back("SOC_NBX_DEL");
0120   phtfMaskColumns.push_back("SOC_CSC_ETACANC");
0121   phtfMaskColumns.push_back("SOC_OPENLUT_EXTR");
0122 
0123   // Loop over sectors 0-11
0124   for (int isc = 0; isc < 12; ++isc) {
0125     int crateNumber = crateNumbers[isc];
0126     std::cout << "isc " << isc << " icr " << crateNumber << std::endl;
0127 
0128     // Loop over wheels 0-5
0129     for (int iwh = 0; iwh < 6; ++iwh) {
0130       std::string sectorWheelName = sectorNames[isc] + wheelNames[iwh];
0131 
0132       int nwh = wheelNumbers[iwh];
0133 
0134       // Check if non-null crate key
0135       std::string crateKey;
0136       if (crateKeyResults.fillVariable(crateKeyColumns[crateNumber], crateKey)) {
0137         // Get PHTF key
0138         std::vector<std::string> phtfKeyColumns;
0139         phtfKeyColumns.push_back("PHTF_" + sectorWheelName);
0140 
0141         l1t::OMDSReader::QueryResults phtfKeyResults = m_omdsReader.basicQuery(phtfKeyColumns,
0142                                                                                dttfSchema,
0143                                                                                "WEDGE_CRATE_CONF",
0144                                                                                "WEDGE_CRATE_CONF.ID",
0145                                                                                crateKeyResults,
0146                                                                                crateKeyColumns[crateNumber]);
0147 
0148         if (phtfKeyResults.queryFailed() || phtfKeyResults.numberRows() != 1) {
0149           edm::LogError("L1-O2O") << "Problem with WEDGE_CRATE_CONF key.";
0150           return std::unique_ptr<L1MuDTTFParameters>();
0151         }
0152 
0153         std::string dummy;
0154         if (phtfKeyResults.fillVariable(dummy)) {
0155           std::cout << "PHTF key " << dummy << std::endl;
0156 
0157           l1t::OMDSReader::QueryResults phtfMaskResults =
0158               m_omdsReader.basicQuery(phtfMaskColumns, dttfSchema, "PHTF_CONF", "PHTF_CONF.ID", phtfKeyResults);
0159 
0160           if (phtfMaskResults.queryFailed() || phtfMaskResults.numberRows() != 1) {
0161             edm::LogError("L1-O2O") << "Problem with PHTF_CONF key.";
0162             return std::unique_ptr<L1MuDTTFParameters>();
0163           }
0164 
0165           long long tmp;
0166 
0167           phtfMaskResults.fillVariable("INREC_QUAL_ST1", tmp);
0168           std::cout << " INREC_QUAL_ST1 " << tmp;
0169           pDTTFParameters->set_inrec_qual_st1(nwh, isc, tmp);
0170           phtfMaskResults.fillVariable("INREC_QUAL_ST2", tmp);
0171           std::cout << " INREC_QUAL_ST2 " << tmp;
0172           pDTTFParameters->set_inrec_qual_st2(nwh, isc, tmp);
0173           phtfMaskResults.fillVariable("INREC_QUAL_ST3", tmp);
0174           std::cout << " INREC_QUAL_ST3 " << tmp;
0175           pDTTFParameters->set_inrec_qual_st3(nwh, isc, tmp);
0176           phtfMaskResults.fillVariable("INREC_QUAL_ST4", tmp);
0177           std::cout << " INREC_QUAL_ST4 " << tmp << std::endl;
0178           pDTTFParameters->set_inrec_qual_st4(nwh, isc, tmp);
0179           std::cout << " SOC_QUAL_CSC " << tmp << std::endl;
0180           pDTTFParameters->set_soc_qual_csc(nwh, isc, tmp);
0181 
0182           phtfMaskResults.fillVariable("SOC_STDIS_N", tmp);
0183           std::cout << " SOC_STDIS_N " << tmp;
0184           pDTTFParameters->set_soc_stdis_n(nwh, isc, tmp);
0185           phtfMaskResults.fillVariable("SOC_STDIS_WL", tmp);
0186           std::cout << " SOC_STDIS_WL " << tmp;
0187           pDTTFParameters->set_soc_stdis_wl(nwh, isc, tmp);
0188           phtfMaskResults.fillVariable("SOC_STDIS_WR", tmp);
0189           std::cout << " SOC_STDIS_WR " << tmp;
0190           pDTTFParameters->set_soc_stdis_wr(nwh, isc, tmp);
0191           phtfMaskResults.fillVariable("SOC_STDIS_ZL", tmp);
0192           std::cout << " SOC_STDIS_ZL " << tmp;
0193           pDTTFParameters->set_soc_stdis_zl(nwh, isc, tmp);
0194           phtfMaskResults.fillVariable("SOC_STDIS_ZR", tmp);
0195           std::cout << " SOC_STDIS_ZR " << tmp << std::endl;
0196           pDTTFParameters->set_soc_stdis_zr(nwh, isc, tmp);
0197 
0198           phtfMaskResults.fillVariable("SOC_QCUT_ST1", tmp);
0199           std::cout << " SOC_QCUT_ST1 " << tmp;
0200           pDTTFParameters->set_soc_qcut_st1(nwh, isc, tmp);
0201           phtfMaskResults.fillVariable("SOC_QCUT_ST2", tmp);
0202           std::cout << " SOC_QCUT_ST2 " << tmp;
0203           pDTTFParameters->set_soc_qcut_st2(nwh, isc, tmp);
0204           phtfMaskResults.fillVariable("SOC_QCUT_ST4", tmp);
0205           std::cout << " SOC_QCUT_ST4 " << tmp << std::endl;
0206           pDTTFParameters->set_soc_qcut_st4(nwh, isc, tmp);
0207 
0208           phtfMaskResults.fillVariable("SOC_RUN_21", tmp);
0209           std::cout << " SOC_RUN_21 " << tmp;
0210           pDTTFParameters->set_soc_run_21(nwh, isc, tmp);
0211           phtfMaskResults.fillVariable("SOC_NBX_DEL", tmp);
0212           std::cout << " SOC_NBX_DEL " << tmp;
0213           pDTTFParameters->set_soc_nbx_del(nwh, isc, tmp);
0214           phtfMaskResults.fillVariable("SOC_CSC_ETACANC", tmp);
0215           std::cout << " SOC_CSC_ETACANC " << tmp;
0216           pDTTFParameters->set_soc_csc_etacanc(nwh, isc, tmp);
0217           phtfMaskResults.fillVariable("SOC_OPENLUT_EXTR", tmp);
0218           std::cout << " SOC_OPENLUT_EXTR " << tmp << std::endl;
0219           pDTTFParameters->set_soc_openlut_extr(nwh, isc, tmp);
0220         }
0221       }
0222     }
0223   }
0224 
0225   return pDTTFParameters;
0226 }
0227 
0228 // ------------ method called to produce the data  ------------
0229 
0230 //define this as a plug-in
0231 DEFINE_FWK_EVENTSETUP_MODULE(DTTFParametersOnlineProd);