File indexing completed on 2024-04-06 12:23:18
0001
0002 #ifndef OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
0003 #define OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
0004
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0007 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
0008 #include "OnlineDB/SiStripConfigDb/interface/SiStripDbParams.h"
0009 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0010
0011 #include "OnlineDB/SiStripESSources/interface/SiStripCondObjBuilderFromDb.h"
0012 #include "OnlineDB/SiStripESSources/interface/SiStripFedCablingBuilderFromDb.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0015 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
0016 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
0017 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
0018 #include "CondFormats/SiStripObjects/interface/SiStripThreshold.h"
0019 #include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
0020 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
0021 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
0022 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0023 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
0024 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0025 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0026 #include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
0027
0028 #include <memory>
0029 #include <vector>
0030 #include <string>
0031 #include <typeinfo>
0032 #include <cstdint>
0033
0034 class SiStripFecCabling;
0035 class SiStripDetCabling;
0036 class SiStripPedestals;
0037 class SiStripNoises;
0038 class SiStripQuality;
0039 class SiStripThreshold;
0040 class DcuDetIdMap;
0041 class SiStripApvGain;
0042 class SiStripLatency;
0043 class TrackerTopology;
0044
0045 class SiStripCondObjBuilderFromDb {
0046 public:
0047
0048 typedef std::pair<uint32_t, FedChannelConnection> pair_apvpairconn;
0049 typedef std::vector<pair_apvpairconn> v_apvpairconn;
0050 typedef std::pair<uint32_t, v_apvpairconn> pair_detcon;
0051 typedef std::vector<pair_detcon> trackercon;
0052
0053 typedef std::vector<pair_detcon>::iterator i_trackercon;
0054 typedef std::vector<pair_apvpairconn>::iterator i_apvpairconn;
0055
0056 class SkipDeviceDescription {
0057
0058
0059
0060 public:
0061 SkipDeviceDescription();
0062 SkipDeviceDescription(const edm::ParameterSet& pset);
0063 bool isConsistent(const FedChannelConnection& fc) const;
0064 std::string dump() const;
0065
0066 private:
0067 SiStripFecKey fec_;
0068 SiStripFedKey fed_;
0069 uint32_t detid_;
0070 };
0071
0072 SiStripCondObjBuilderFromDb();
0073 SiStripCondObjBuilderFromDb(const edm::ParameterSet&, const edm::ActivityRegistry&);
0074 virtual ~SiStripCondObjBuilderFromDb();
0075
0076 TrackerTopology* buildTrackerTopology();
0077
0078
0079 inline const SiStripDbParams& dbParams() const { return db_->dbParams(); }
0080
0081
0082
0083 void buildCondObj();
0084 void buildStripRelatedObjects(SiStripConfigDb* const db, const SiStripDetCabling& det_cabling);
0085 void buildAnalysisRelatedObjects(SiStripConfigDb* const db, const trackercon& tc);
0086 void buildFECRelatedObjects(SiStripConfigDb* const db, const trackercon& tc);
0087 void buildFEDRelatedObjects(SiStripConfigDb* const db, const trackercon& tc);
0088
0089 bool checkForCompatibility(std::stringstream& input, std::stringstream& output, std::string& label);
0090 std::string getConfigString(const std::type_info& typeInfo);
0091
0092 SiStripFedCabling* getFedCabling() {
0093 checkUpdate();
0094 return fed_cabling_;
0095 }
0096 SiStripPedestals* getPedestals() {
0097 checkUpdate();
0098 return pedestals_;
0099 }
0100 SiStripNoises* getNoises() {
0101 checkUpdate();
0102 return noises_;
0103 }
0104 SiStripThreshold* getThreshold() {
0105 checkUpdate();
0106 return threshold_;
0107 }
0108 SiStripQuality* getQuality() {
0109 checkUpdate();
0110 return quality_;
0111 }
0112 SiStripApvGain* getApvGain() {
0113 checkUpdate();
0114 return gain_;
0115 }
0116 SiStripLatency* getApvLatency() {
0117 checkUpdate();
0118 return latency_;
0119 }
0120
0121 void getValue(SiStripFedCabling*& val) { val = getFedCabling(); }
0122 void getValue(SiStripPedestals*& val) { val = getPedestals(); }
0123 void getValue(SiStripNoises*& val) { val = getNoises(); }
0124 void getValue(SiStripThreshold*& val) { val = getThreshold(); }
0125 void getValue(SiStripQuality*& val) { val = getQuality(); }
0126 void getValue(SiStripBadStrip*& val) { val = new SiStripBadStrip(*(const SiStripBadStrip*)getQuality()); }
0127 void getValue(SiStripApvGain*& val) { val = getApvGain(); }
0128 void getValue(SiStripLatency*& val) { val = getApvLatency(); }
0129
0130 void setLastIovGain(std::shared_ptr<SiStripApvGain> gain) { gain_last_ = gain; }
0131
0132 protected:
0133 void checkUpdate();
0134
0135
0136
0137 edm::Service<SiStripConfigDb> db_;
0138
0139
0140 SiStripDbParams dbParams_;
0141 SiStripFedCabling* fed_cabling_;
0142 SiStripPedestals* pedestals_;
0143 SiStripNoises* noises_;
0144 SiStripThreshold* threshold_;
0145 SiStripQuality* quality_;
0146 SiStripApvGain* gain_;
0147 SiStripLatency* latency_;
0148
0149 std::shared_ptr<SiStripApvGain> gain_last_;
0150 std::vector<SkipDeviceDescription> skippedDevices;
0151 std::vector<uint32_t> skippedDetIds;
0152 std::vector<SkipDeviceDescription>
0153 whitelistedDevices;
0154 std::vector<uint32_t> whitelistedDetIds;
0155
0156
0157 bool setValuesApvLatency(SiStripLatency& latency_,
0158 SiStripConfigDb* const db,
0159 FedChannelConnection& ipair,
0160 uint32_t detid,
0161 uint16_t apvnr,
0162 SiStripConfigDb::DeviceDescriptionsRange apvs);
0163 bool setValuesApvTiming(SiStripConfigDb* const db, FedChannelConnection& ipair);
0164
0165 bool setValuesCabling(SiStripConfigDb::FedDescriptionsRange& descriptions,
0166 FedChannelConnection& ipair,
0167 uint32_t detid);
0168 bool retrieveFedDescriptions(SiStripConfigDb* const db);
0169 bool retrieveTimingAnalysisDescriptions(SiStripConfigDb* const db);
0170 vector<uint32_t> retrieveActiveDetIds(const SiStripDetCabling& det_cabling);
0171 vector<const FedChannelConnection*> buildConnections(const SiStripDetCabling& det_cabling, uint32_t det_id);
0172 uint16_t retrieveNumberAPVPairs(uint32_t det_id);
0173
0174
0175 void setDefaultValuesCabling(uint16_t apvPair);
0176 void setDefaultValuesApvTiming(uint32_t detid, uint32_t apvPair);
0177 void setDefaultValuesApvLatency(SiStripLatency& latency_,
0178 const FedChannelConnection& ipair,
0179 uint32_t detid,
0180 uint16_t apvnr);
0181 void storePedestals(uint32_t det_id);
0182 void storeNoise(uint32_t det_id);
0183 void storeThreshold(uint32_t det_id);
0184 void storeQuality(uint32_t det_id);
0185 void storeTiming(uint32_t det_id);
0186
0187
0188 edm::VParameterSet m_skippedDevices;
0189 edm::VParameterSet
0190 m_whitelistedDevices;
0191 float m_tickmarkThreshold;
0192 float m_gaincalibrationfactor;
0193 float m_defaultpedestalvalue;
0194 float m_defaultnoisevalue;
0195 float m_defaultthresholdhighvalue;
0196 float m_defaultthresholdlowvalue;
0197 uint16_t m_defaultapvmodevalue;
0198 uint16_t m_defaultapvlatencyvalue;
0199 float m_defaulttickheightvalue;
0200 bool m_useanalysis;
0201 bool m_usefed;
0202 bool m_usefec;
0203 bool m_debug;
0204 SiStripDetInfo m_detInfo;
0205
0206
0207 TrackerTopology* tTopo;
0208 SiStripPedestals::InputVector inputPedestals;
0209 SiStripNoises::InputVector inputNoises;
0210 SiStripThreshold::InputVector inputThreshold;
0211 SiStripQuality::InputVector inputQuality;
0212 SiStripApvGain::InputVector inputApvGain;
0213
0214
0215 pair_apvpairconn p_apvpcon;
0216 v_apvpairconn v_apvpcon;
0217 pair_detcon p_detcon;
0218 trackercon v_trackercon;
0219 };
0220 #endif