00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "L1TriggerConfig/L1ScalesProducers/interface/L1MuTriggerScalesOnlineProducer.h"
00016 #include "L1TriggerConfig/L1ScalesProducers/interface/ScaleRecordHelper.h"
00017 #include <cmath>
00018
00019 using namespace std;
00020
00021 L1MuTriggerScalesOnlineProducer::L1MuTriggerScalesOnlineProducer(const edm::ParameterSet& ps)
00022 : L1ConfigOnlineProdBase<L1MuTriggerScalesRcd, L1MuTriggerScales>(ps),
00023 m_scales(
00024 ps.getParameter<int>("nbitPackingDTEta"),
00025 ps.getParameter<bool>("signedPackingDTEta"),
00026 ps.getParameter<int>("nbinsDTEta"),
00027 ps.getParameter<double>("minDTEta"),
00028 ps.getParameter<double>("maxDTEta"),
00029 ps.getParameter<int>("offsetDTEta"),
00030
00031 ps.getParameter<int>("nbitPackingCSCEta"),
00032 ps.getParameter<int>("nbinsCSCEta"),
00033 ps.getParameter<double>("minCSCEta"),
00034 ps.getParameter<double>("maxCSCEta"),
00035
00036 ps.getParameter<std::vector<double> >("scaleRPCEta"),
00037 ps.getParameter<int>("nbitPackingBrlRPCEta"),
00038 ps.getParameter<bool>("signedPackingBrlRPCEta"),
00039 ps.getParameter<int>("nbinsBrlRPCEta"),
00040 ps.getParameter<int>("offsetBrlRPCEta"),
00041 ps.getParameter<int>("nbitPackingFwdRPCEta"),
00042 ps.getParameter<bool>("signedPackingFwdRPCEta"),
00043 ps.getParameter<int>("nbinsFwdRPCEta"),
00044 ps.getParameter<int>("offsetFwdRPCEta"),
00045
00046
00047
00048
00049 0,
00050
00051 0,
00052
00053 std::vector<double>(1),
00054
00055 0,
00056
00057 false,
00058
00059 0,
00060
00061 0,
00062
00063 0
00064 ),
00065
00066 m_nbitPackingPhi(ps.getParameter<int>("nbitPackingPhi")),
00067 m_nbitPackingEta(ps.getParameter<int>("nbitPackingGMTEta")),
00068 m_nbinsEta(ps.getParameter<int>("nbinsGMTEta")),
00069 m_signedPackingPhi(ps.getParameter<bool>("signedPackingPhi"))
00070 {
00071 }
00072
00073 L1MuTriggerScalesOnlineProducer::~L1MuTriggerScalesOnlineProducer() {}
00074
00075
00076
00077
00078
00079
00080 class PhiScaleHelper {
00081 public:
00082
00083 static L1MuBinnedScale* makeBinnedScale(l1t::OMDSReader::QueryResults& record, int nBits, bool signedPacking) {
00084 short nbins;
00085 record.fillVariable(BinsColumn, nbins);
00086 float lowMark;
00087 record.fillVariable(LowMarkColumn, lowMark);
00088 float step;
00089 record.fillVariable(StepColumn, step);
00090
00091 return new L1MuBinnedScale(nBits, signedPacking,
00092 nbins, deg2rad(lowMark),
00093 deg2rad(lowMark + nbins*step));
00094
00095 }
00096
00097 static void pushColumnNames(vector<string>& columns) {
00098 columns.push_back(BinsColumn);
00099 columns.push_back(LowMarkColumn);
00100 columns.push_back(StepColumn);
00101 }
00102
00103 static double deg2rad(double deg) { return deg*M_PI/180.0; }
00104 static double rad2deg(double rad) { return rad/M_PI*180.0; }
00105
00106 static const string BinsColumn;
00107 static const string LowMarkColumn;
00108 static const string StepColumn;
00109 };
00110
00111 const string PhiScaleHelper::BinsColumn = "PHI_BINS";
00112 const string PhiScaleHelper::LowMarkColumn = "PHI_DEG_BIN_LOW_0";
00113 const string PhiScaleHelper::StepColumn = "PHI_DEG_BIN_STEP";
00114
00115
00116 boost::shared_ptr<L1MuTriggerScales> L1MuTriggerScalesOnlineProducer::newObject(const std::string& objectKey )
00117 {
00118 using namespace edm::es;
00119
00120
00121
00122
00123 vector<string> foreignKeys;
00124
00125 const std::string etaKeyColumn("SC_MUON_ETA_FK");
00126 const std::string phiKeyColumn("SC_MUON_PHI_FK");
00127
00128 foreignKeys.push_back(etaKeyColumn);
00129 foreignKeys.push_back(phiKeyColumn);
00130
00131 l1t::OMDSReader::QueryResults keysRecord =
00132 m_omdsReader.basicQuery(
00133
00134 foreignKeys,
00135
00136 "CMS_GT",
00137
00138 "L1T_SCALES",
00139
00140 "L1T_SCALES.ID",
00141
00142 m_omdsReader.singleAttribute( objectKey ) );
00143
00144 if( keysRecord.numberRows() != 1 )
00145 {
00146 throw cond::Exception("Problem finding L1MuTriggerScales associated "
00147 "with scales key `" + objectKey + "'");
00148 }
00149
00150
00151 std::string etaKeyValue;
00152 std::string phiKeyValue;
00153 keysRecord.fillVariable(etaKeyColumn, etaKeyValue);
00154 keysRecord.fillVariable(phiKeyColumn, phiKeyValue);
00155
00156 vector<string> columns;
00157
00158
00159 ScaleRecordHelper etaHelper("ETA_BIN_LOW", m_nbinsEta);
00160 etaHelper.pushColumnNames(columns);
00161
00162 l1t::OMDSReader::QueryResults etaRecord =
00163 m_omdsReader.basicQuery(
00164
00165 columns,
00166
00167 "CMS_GT",
00168
00169 "L1T_SCALE_MUON_ETA",
00170
00171 "L1T_SCALE_MUON_ETA.ID",
00172
00173 m_omdsReader.singleAttribute( etaKeyValue ) );
00174
00175 vector<double> etaScales;
00176 etaHelper.extractScales(etaRecord, etaScales);
00177
00178 auto_ptr<L1MuSymmetricBinnedScale> ptrEtaScale(new L1MuSymmetricBinnedScale(m_nbitPackingEta, m_nbinsEta, etaScales));
00179 m_scales.setGMTEtaScale(*ptrEtaScale);
00180
00181 columns.clear();
00182
00183
00184 PhiScaleHelper phiHelper;
00185
00186 l1t::OMDSReader::QueryResults phiRecord =
00187 m_omdsReader.basicQuery(
00188
00189 columns,
00190
00191 "CMS_GT",
00192
00193 "L1T_SCALE_MUON_PHI",
00194
00195 "L1T_SCALE_MUON_PHI.ID",
00196
00197 m_omdsReader.singleAttribute( phiKeyValue ) );
00198
00199 auto_ptr<L1MuBinnedScale> ptrPhiScale(phiHelper.makeBinnedScale(phiRecord, m_nbitPackingPhi, m_signedPackingPhi));
00200
00201 m_scales.setPhiScale(*ptrPhiScale);
00202
00203 boost::shared_ptr<L1MuTriggerScales> l1muscale =
00204 boost::shared_ptr<L1MuTriggerScales>( new L1MuTriggerScales( m_scales ) );
00205
00206 return l1muscale ;
00207 }