CMS 3D CMS Logo

SiStripConfigDb.h
Go to the documentation of this file.
1 
2 #ifndef OnlineDB_SiStripConfigDb_SiStripConfigDb_h
3 #define OnlineDB_SiStripConfigDb_SiStripConfigDb_h
4 
5 #define DATABASE // Needed by DeviceFactory API! Do not comment!
6 //#define USING_DATABASE_MASKING
7 
17 #include "DeviceFactory.h"
18 #include "boost/range/iterator_range.hpp"
19 #include <iostream>
20 #include <fstream>
21 #include <sstream>
22 #include <ostream>
23 #include <vector>
24 #include <string>
25 #include <list>
26 #include <map>
27 #include <atomic>
28 
29 #include "DbClient.h"
30 #include <cstdint>
31 
32 namespace sistrip {
33  static const uint16_t FEC_CRATE_OFFSET = 0; //@@ temporary
34  static const uint16_t FEC_RING_OFFSET = 0; //@@ temporary
35 } // namespace sistrip
36 
37 // Friend class
38 namespace cms {
39  class SiStripO2O;
40 }
41 
48 public:
49  // ---------- Constructors, destructors ----------
50 
55 
58 
59  // ---------- PROTECTED INTERFACE ----------
60 
61 protected:
62  /*
63  Access to the configuration database is reserved solely for the
64  commissioning (database) client and the online-to-offline transfer
65  tool. If you wish to use this interface to the configuration
66  database, then please contact one of the package administrators.
67  */
68 
69  // ESSources and O2O
74  friend class SiStripPsuDetIdMap;
75 
76  // Commissioning clients
82  friend class ApvTimingHistosUsingDb;
83  friend class OptoScanHistosUsingDb;
84  friend class PedestalsHistosUsingDb;
86  friend class PedsOnlyHistosUsingDb;
87  friend class NoiseHistosUsingDb;
88  friend class VpspScanHistosUsingDb;
89  friend class LatencyHistosUsingDb;
90  friend class FineDelayHistosUsingDb;
93 
94  // Utility and tests
95  friend class SiStripPartition;
96  friend class testSiStripConfigDb;
97 
98  // ---------- Typedefs ----------
99 
100  // FED connections
101  typedef ConnectionDescription FedConnection;
104  typedef std::vector<FedConnection*> FedConnectionsV;
105 
106  // Device descriptions
107  typedef enumDeviceType DeviceType;
108  typedef deviceDescription DeviceDescription;
111  typedef std::vector<DeviceDescription*> DeviceDescriptionsV;
112 
113  // FED descriptions
114  typedef Fed9U::Fed9UDescription FedDescription;
117  typedef std::vector<FedDescription*> FedDescriptionsV;
118 
119  // FED ids
120  typedef std::vector<uint16_t> FedIds;
121  typedef boost::iterator_range<FedIds::const_iterator> FedIdsRange;
122 
123  // DCU-DetId map
124  typedef Sgi::hash_map<unsigned long, TkDcuInfo*> DcuDetIdMap;
125  typedef std::pair<uint32_t, TkDcuInfo*> DcuDetId;
128  typedef std::vector<DcuDetId> DcuDetIdsV;
129 
130  // Analysis descriptions
131  typedef CommissioningAnalysisDescription::commissioningType AnalysisType;
132  typedef CommissioningAnalysisDescription AnalysisDescription;
135  typedef std::vector<AnalysisDescription*> AnalysisDescriptionsV;
136 
137  // ---------- Useful structs ----------
138 
142  public:
143  DeviceAddress();
144  void reset();
145  uint16_t fecCrate_;
146  uint16_t fecSlot_;
147  uint16_t fecRing_;
148  uint16_t ccuAddr_;
149  uint16_t ccuChan_;
150  uint16_t lldChan_;
151  uint16_t i2cAddr_;
152  uint16_t fedId_;
153  uint16_t feUnit_;
154  uint16_t feChan_;
155  };
156 
157  // ---------- Connection and useful methods ----------
158 
160  void openDbConnection();
161 
163  void closeDbConnection();
164 
166  inline const SiStripDbParams& dbParams() const;
167 
169  inline bool usingDb() const;
170 
172  DeviceFactory* const deviceFactory(std::string method_name = "") const;
173 
175  DbClient* const databaseCache(std::string method_name = "") const;
176 
177  // ---------- Run numbers for partitions and run types ----------
178 
179  class Run {
180  public:
183  uint16_t number_;
185  };
186 
187  typedef std::vector<Run> Runs;
188 
189  typedef std::map<sistrip::RunType, Runs> RunsByType;
190 
191  typedef std::map<std::string, Runs> RunsByPartition;
192 
194  void runs(Runs&) const;
195 
197  void runs(const Runs& in, RunsByType& out, std::string optional_partition = "") const;
198 
200  void runs(const Runs& in, RunsByPartition& out, sistrip::RunType optional_type = sistrip::UNDEFINED_RUN_TYPE) const;
201 
203  void partitions(std::list<std::string>&) const;
204 
205  //@@ SiStripPartition::Versions ???
206 
207  // ---------- FED connections ----------
208 
211 
214 
217 
220 
223 
224  // ---------- FEC / Front-End devices ----------
225 
228 
232 
235 
238 
241 
244 
246  DeviceAddress deviceAddress(const deviceDescription&); //@@ uses temp offsets!
247 
248  // ---------- FED descriptions ----------
249 
252 
255 
258 
261 
264 
267 
269  inline bool usingStrips() const;
270 
272  inline void usingStrips(bool);
273 
274  // ---------- DCU-DetId info ----------
275 
278 
281 
284 
287 
290 
292  static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin,
293  DcuDetIdsV::const_iterator end,
294  uint32_t dcu_id);
295 
297  static DcuDetIdsV::iterator findDcuDetId(DcuDetIdsV::iterator begin, DcuDetIdsV::iterator end, uint32_t dcu_id);
298 
299  // ---------- Commissioning analyses ----------
300 
303 
306 
308  void uploadAnalysisDescriptions(bool calibration_for_physics = false, std::string partition = "");
309 
312 
315 
317  DeviceAddress deviceAddress(const AnalysisDescription&); //@@ uses temp offsets!
318 
321 
322 private:
323  // ---------- Private methods ----------
324 
326  void clearLocalCache();
327 
329  void usingDatabase();
330 
332  void usingDatabaseCache();
333 
335  void usingXmlFiles();
336 
338  void handleException(const std::string& method_name, const std::string& extra_info = "") const;
339 
341  bool checkFileExists(const std::string& path);
342 
344  std::string deviceType(const enumDeviceType& device_type) const;
345 
346  void clone(const DcuDetIdMap& in, DcuDetIdsV& out) const;
347 
348  void clone(const DcuDetIdsV& in, DcuDetIdMap& out) const;
349 
350  void clone(const DcuDetIdsV& in, DcuDetIdsV& out) const;
351 
352  // ---------- Database connection, partitions and versions ----------
353 
355  DeviceFactory* factory_;
356 
358  DbClient* dbCache_;
359 
362 
363  // ---------- Local cache of vectors ----------
364 
367 
370 
373 
376 
379 
382 
385 
388 
391 
394 
397 
400 
403 
404  // ---------- Miscellaneous ----------
405 
408 
411 
413  static std::atomic<uint32_t> cntr_;
414 
415  static std::atomic<bool> allowCalibUpload_;
416 };
417 
418 // ---------- Inline methods ----------
419 
422 
424 bool SiStripConfigDb::usingDb() const { return dbParams_.usingDb(); }
425 
428 
430 void SiStripConfigDb::usingStrips(bool using_strips) { usingStrips_ = using_strips; }
431 
432 #endif // OnlineDB_SiStripConfigDb_SiStripConfigDb_h
bool usingDb() const
DeviceDescriptionsV apvDevices_
DeviceDescriptionsV typedDevices_
DeviceDescriptionsV dohDevices_
bool usingDb() const
DcuDetIds::range DcuDetIdsRange
DeviceFactory * factory_
DeviceDescriptionsV lldDevices_
void addDeviceDescriptions(std::string partition, DeviceDescriptionsV &)
void uploadFedConnections(std::string partition="")
FedDescriptionsRange getFedDescriptions(std::string partition="")
DbClient *const databaseCache(std::string method_name="") const
void uploadAnalysisDescriptions(bool calibration_for_physics=false, std::string partition="")
void addAnalysisDescriptions(std::string partition, AnalysisDescriptionsV &)
static const uint16_t FEC_RING_OFFSET
SiStripConfigDb(const edm::ParameterSet &, const edm::ActivityRegistry &)
AnalysisDescriptions analyses_
Sgi::hash_map< unsigned long, TkDcuInfo * > DcuDetIdMap
FedDescriptions::range FedDescriptionsRange
std::vector< uint16_t > FedIds
Constants and enumerated type for sistrip::RunType.
Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map...
std::map< std::string, Runs > RunsByPartition
ConnectionDescription FedConnection
void clearDeviceDescriptions(std::string partition="")
void runs(Runs &) const
bool checkFileExists(const std::string &path)
edm::MapOfVectors< std::string, DeviceDescription * > DeviceDescriptions
void uploadDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:183
FedConnections connections_
sistrip classes
DeviceDescriptionsV pllDevices_
void addFedDescriptions(std::string partition, FedDescriptionsV &)
friend class FedCablingHistosUsingDb
Class which reads a root file containing "commissioning histograms", analyzes the histograms to extra...
edm::MapOfVectors< std::string, DcuDetId > DcuDetIds
FedConnections::range FedConnectionsRange
DeviceDescriptionsV dcuDevices_
friend class testSiStripConfigDb
edm::MapOfVectors< std::string, AnalysisDescription * > AnalysisDescriptions
static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
Definition: DcuDetIds.cc:412
enumDeviceType DeviceType
void partitions(std::list< std::string > &) const
CommissioningAnalysisDescription AnalysisDescription
DeviceDescriptions::range DeviceDescriptionsRange
FedConnectionsRange getFedConnections(std::string partition="")
bool usingStrips() const
void clearAnalysisDescriptions(std::string partition="")
An interface class to the DeviceFactory.
static std::atomic< uint32_t > cntr_
FedDescriptions feds_
FedIdsRange getFedIds(std::string partition="")
Container class for database partition parameters.
void printDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:349
DeviceAddress deviceAddress(const deviceDescription &)
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
std::map< sistrip::RunType, Runs > RunsByType
void clearFedConnections(std::string partition="")
Fed9U::Fed9UDescription FedDescription
deviceDescription DeviceDescription
std::vector< Run > Runs
Namespace of DDCMS conversion namespace.
void printFedDescriptions(std::string partition="")
std::string analysisType(AnalysisType) const
sistrip::RunType type_
std::vector< DcuDetId > DcuDetIdsV
AnalysisDescriptions::range AnalysisDescriptionsRange
Container class for database connection parameters.
void uploadFedDescriptions(std::string partition="")
CommissioningAnalysisDescription::commissioningType AnalysisType
void handleException(const std::string &method_name, const std::string &extra_info="") const
boost::iterator_range< FedIds::const_iterator > FedIdsRange
void printFedConnections(std::string partition="")
void addDcuDetIds(std::string partition, DcuDetIdsV &)
Definition: DcuDetIds.cc:110
DeviceDescriptionsV muxDevices_
DeviceDescriptions devices_
edm::MapOfVectors< std::string, FedDescription * > FedDescriptions
SiStripDbParams dbParams_
friend class SiStripCommissioningDbClient
std::vector< AnalysisDescription * > AnalysisDescriptionsV
void printDeviceDescriptions(std::string partition="")
static const uint16_t FEC_CRATE_OFFSET
static std::atomic< bool > allowCalibUpload_
void printAnalysisDescriptions(std::string partition="")
boost::iterator_range< data_iterator > range
Definition: MapOfVectors.h:34
void clone(const DcuDetIdMap &in, DcuDetIdsV &out) const
Definition: DcuDetIds.cc:373
std::vector< FedConnection * > FedConnectionsV
DbClient * dbCache_
const SiStripDbParams & dbParams() const
void addFedConnections(std::string partition, FedConnectionsV &)
std::string deviceType(const enumDeviceType &device_type) const
void clearDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:270
void clearFedDescriptions(std::string partition="")
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
std::pair< uint32_t, TkDcuInfo * > DcuDetId
void uploadDeviceDescriptions(std::string partition="")
std::vector< FedDescription * > FedDescriptionsV
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
std::vector< DeviceDescription * > DeviceDescriptionsV
DeviceFactory *const deviceFactory(std::string method_name="") const
DcuDetIds dcuDetIds_
edm::MapOfVectors< std::string, FedConnection * > FedConnections