test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 "boost/cstdint.hpp"
20 #include <iostream>
21 #include <fstream>
22 #include <sstream>
23 #include <ostream>
24 #include <vector>
25 #include <string>
26 #include <list>
27 #include <map>
28 #include <atomic>
29 
30 #include "DbClient.h"
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 }
36 
37 // Friend class
38 namespace cms { class SiStripO2O; }
39 
46 
47  public:
48 
49 
50  // ---------- Constructors, destructors ----------
51 
52 
57  const edm::ActivityRegistry& );
58 
61 
62 
63  // ---------- PROTECTED INTERFACE ----------
64 
65 
66  protected:
67 
68  /*
69  Access to the configuration database is reserved solely for the
70  commissioning (database) client and the online-to-offline transfer
71  tool. If you wish to use this interface to the configuration
72  database, then please contact one of the package administrators.
73  */
74 
75  // ESSources and O2O
80  friend class SiStripPsuDetIdMap;
81 
82 
83  // Commissioning clients
89  friend class ApvTimingHistosUsingDb;
90  friend class OptoScanHistosUsingDb;
91  friend class PedestalsHistosUsingDb;
93  friend class PedsOnlyHistosUsingDb;
94  friend class NoiseHistosUsingDb;
95  friend class VpspScanHistosUsingDb;
96  friend class LatencyHistosUsingDb;
97  friend class FineDelayHistosUsingDb;
99 
100  // Utility and tests
101  friend class SiStripPartition;
102  friend class testSiStripConfigDb;
103 
104 
105 
106  // ---------- Typedefs ----------
107 
108 
109  // FED connections
110  typedef ConnectionDescription FedConnection;
113  typedef std::vector<FedConnection*> FedConnectionsV;
114 
115  // Device descriptions
116  typedef enumDeviceType DeviceType;
117  typedef deviceDescription DeviceDescription;
120  typedef std::vector<DeviceDescription*> DeviceDescriptionsV;
121 
122  // FED descriptions
123  typedef Fed9U::Fed9UDescription FedDescription;
126  typedef std::vector<FedDescription*> FedDescriptionsV;
127 
128  // FED ids
129  typedef std::vector<uint16_t> FedIds;
130  typedef boost::iterator_range<FedIds::const_iterator> FedIdsRange;
131 
132  // DCU-DetId map
133  typedef Sgi::hash_map<unsigned long,TkDcuInfo*> DcuDetIdMap;
134  typedef std::pair<uint32_t,TkDcuInfo*> DcuDetId;
137  typedef std::vector<DcuDetId> DcuDetIdsV;
138 
139 
140  // Analysis descriptions
141  typedef CommissioningAnalysisDescription::commissioningType AnalysisType;
142  typedef CommissioningAnalysisDescription AnalysisDescription;
145  typedef std::vector<AnalysisDescription*> AnalysisDescriptionsV;
146 
147 
148  // ---------- Useful structs ----------
149 
150 
153  class DeviceAddress {
154  public:
155  DeviceAddress();
156  void reset();
157  uint16_t fecCrate_;
158  uint16_t fecSlot_;
159  uint16_t fecRing_;
160  uint16_t ccuAddr_;
161  uint16_t ccuChan_;
162  uint16_t lldChan_;
163  uint16_t i2cAddr_;
164  uint16_t fedId_;
165  uint16_t feUnit_;
166  uint16_t feChan_;
167  };
168 
169 
170  // ---------- Connection and useful methods ----------
171 
172 
174  void openDbConnection();
175 
177  void closeDbConnection();
178 
180  inline const SiStripDbParams& dbParams() const;
181 
183  inline bool usingDb() const;
184 
186  DeviceFactory* const deviceFactory( std::string method_name = "" ) const;
187 
189  DbClient* const databaseCache( std::string method_name = "" ) const;
190 
191 
192  // ---------- Run numbers for partitions and run types ----------
193 
194 
195  class Run {
196  public:
199  uint16_t number_;
200  Run() : type_(sistrip::UNDEFINED_RUN_TYPE), partition_(""), number_(0) {;}
201  };
202 
203  typedef std::vector<Run> Runs;
204 
205  typedef std::map<sistrip::RunType,Runs> RunsByType;
206 
207  typedef std::map<std::string,Runs> RunsByPartition;
208 
210  void runs( Runs& ) const;
211 
213  void runs( const Runs& in,
214  RunsByType& out,
215  std::string optional_partition = "" ) const;
216 
218  void runs( const Runs& in,
220  sistrip::RunType optional_type = sistrip::UNDEFINED_RUN_TYPE ) const;
221 
223  void partitions( std::list<std::string>& ) const;
224 
225  //@@ SiStripPartition::Versions ???
226 
227 
228  // ---------- FED connections ----------
229 
230 
233 
235  void addFedConnections( std::string partition, FedConnectionsV& );
236 
238  void uploadFedConnections( std::string partition = "" );
239 
241  void clearFedConnections( std::string partition = "" );
242 
244  void printFedConnections( std::string partition = "" );
245 
246 
247  // ---------- FEC / Front-End devices ----------
248 
249 
252 
256 
259 
261  void uploadDeviceDescriptions( std::string partition = "" );
262 
264  void clearDeviceDescriptions( std::string partition = "" );
265 
267  void printDeviceDescriptions( std::string partition = "" );
268 
270  DeviceAddress deviceAddress( const deviceDescription& ); //@@ uses temp offsets!
271 
272 
273  // ---------- FED descriptions ----------
274 
275 
278 
280  void addFedDescriptions( std::string partition, FedDescriptionsV& );
281 
283  void uploadFedDescriptions( std::string partition = "" );
284 
286  void clearFedDescriptions( std::string partition = "" );
287 
289  void printFedDescriptions( std::string partition = "" );
290 
292  FedIdsRange getFedIds( std::string partition = "" );
293 
295  inline bool usingStrips() const;
296 
298  inline void usingStrips( bool );
299 
300 
301  // ---------- DCU-DetId info ----------
302 
303 
305  DcuDetIdsRange getDcuDetIds( std::string partition = "" );
306 
308  void addDcuDetIds( std::string partition, DcuDetIdsV& );
309 
311  void uploadDcuDetIds( std::string partition = "" );
312 
314  void clearDcuDetIds( std::string partition = "" );
315 
317  void printDcuDetIds( std::string partition = "" );
318 
320  static DcuDetIdsV::const_iterator findDcuDetId( DcuDetIdsV::const_iterator begin,
321  DcuDetIdsV::const_iterator end,
322  uint32_t dcu_id );
323 
325  static DcuDetIdsV::iterator findDcuDetId( DcuDetIdsV::iterator begin,
326  DcuDetIdsV::iterator end,
327  uint32_t dcu_id );
328 
329 
330  // ---------- Commissioning analyses ----------
331 
332 
335 
338 
340  void uploadAnalysisDescriptions( bool calibration_for_physics = false, std::string partition = "" );
341 
343  void clearAnalysisDescriptions( std::string partition = "" );
344 
346  void printAnalysisDescriptions( std::string partition = "" );
347 
349  DeviceAddress deviceAddress( const AnalysisDescription& ); //@@ uses temp offsets!
350 
353 
354 
355  private:
356 
357 
358  // ---------- Private methods ----------
359 
360 
362  void clearLocalCache();
363 
365  void usingDatabase();
366 
368  void usingDatabaseCache();
369 
371  void usingXmlFiles();
372 
374  void handleException( const std::string& method_name,
375  const std::string& extra_info = "" ) const;
376 
378  bool checkFileExists( const std::string& path );
379 
381  std::string deviceType( const enumDeviceType& device_type ) const;
382 
383  void clone( const DcuDetIdMap& in, DcuDetIdsV& out ) const;
384 
385  void clone( const DcuDetIdsV& in, DcuDetIdMap& out ) const;
386 
387  void clone( const DcuDetIdsV& in, DcuDetIdsV& out ) const;
388 
389 
390  // ---------- Database connection, partitions and versions ----------
391 
392 
394  DeviceFactory* factory_;
395 
397  DbClient* dbCache_;
398 
401 
402 
403  // ---------- Local cache of vectors ----------
404 
405 
408 
411 
414 
417 
420 
423 
426 
429 
432 
435 
438 
441 
444 
445 
446  // ---------- Miscellaneous ----------
447 
448 
451 
454 
456  static std::atomic<uint32_t> cntr_;
457 
458  static std::atomic<bool> allowCalibUpload_;
459 
460 
461 };
462 
463 
464 // ---------- Inline methods ----------
465 
466 
469 
471 bool SiStripConfigDb::usingDb() const { return dbParams_.usingDb(); }
472 
475 
477 void SiStripConfigDb::usingStrips( bool using_strips ) { usingStrips_ = using_strips; }
478 
479 
480 #endif // OnlineDB_SiStripConfigDb_SiStripConfigDb_h
void clone(const DcuDetIdMap &in, DcuDetIdsV &out) const
Definition: DcuDetIds.cc:368
DeviceDescriptionsV apvDevices_
bool usingStrips() const
DeviceDescriptionsV typedDevices_
DeviceDescriptionsV dohDevices_
DcuDetIds::range DcuDetIdsRange
DeviceFactory * factory_
void partitions(std::list< std::string > &) const
DeviceDescriptionsV lldDevices_
DeviceFactory *const deviceFactory(std::string method_name="") const
void addDeviceDescriptions(std::string partition, DeviceDescriptionsV &)
void uploadFedConnections(std::string partition="")
FedDescriptionsRange getFedDescriptions(std::string partition="")
void uploadAnalysisDescriptions(bool calibration_for_physics=false, std::string partition="")
void handleException(const std::string &method_name, const std::string &extra_info="") const
void addAnalysisDescriptions(std::string partition, AnalysisDescriptionsV &)
static const uint16_t FEC_RING_OFFSET
edm::MapOfVectors< std::string, DcuDetId > DcuDetIds
SiStripConfigDb(const edm::ParameterSet &, const edm::ActivityRegistry &)
AnalysisDescriptions analyses_
FedDescriptions::range FedDescriptionsRange
std::map< std::string, Runs > RunsByPartition
std::vector< uint16_t > FedIds
Constants and enumerated type for sistrip::RunType.
void runs(Runs &) const
Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map...
ConnectionDescription FedConnection
void clearDeviceDescriptions(std::string partition="")
bool checkFileExists(const std::string &path)
bool usingDb() const
void uploadDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:183
FedConnections connections_
DeviceDescriptionsV pllDevices_
void addFedDescriptions(std::string partition, FedDescriptionsV &)
friend class FedCablingHistosUsingDb
Class which reads a root file containing &quot;commissioning histograms&quot;, analyzes the histograms to extra...
FedConnections::range FedConnectionsRange
edm::MapOfVectors< std::string, FedDescription * > FedDescriptions
DeviceDescriptionsV dcuDevices_
friend class testSiStripConfigDb
bool usingDb() const
static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
Definition: DcuDetIds.cc:395
enumDeviceType DeviceType
edm::MapOfVectors< std::string, DeviceDescription * > DeviceDescriptions
CommissioningAnalysisDescription AnalysisDescription
DeviceDescriptions::range DeviceDescriptionsRange
edm::MapOfVectors< std::string, AnalysisDescription * > AnalysisDescriptions
FedConnectionsRange getFedConnections(std::string partition="")
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:338
#define end
Definition: vmac.h:37
DeviceAddress deviceAddress(const deviceDescription &)
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
void clearFedConnections(std::string partition="")
Fed9U::Fed9UDescription FedDescription
deviceDescription DeviceDescription
std::vector< Run > Runs
DbClient *const databaseCache(std::string method_name="") const
void printFedDescriptions(std::string partition="")
std::map< sistrip::RunType, Runs > RunsByType
sistrip::RunType type_
std::vector< DcuDetId > DcuDetIdsV
const SiStripDbParams & dbParams() const
AnalysisDescriptions::range AnalysisDescriptionsRange
Container class for database connection parameters.
void uploadFedDescriptions(std::string partition="")
CommissioningAnalysisDescription::commissioningType AnalysisType
edm::MapOfVectors< std::string, FedConnection * > FedConnections
std::string deviceType(const enumDeviceType &device_type) const
boost::iterator_range< FedIds::const_iterator > FedIdsRange
void printFedConnections(std::string partition="")
Sgi::hash_map< unsigned long, TkDcuInfo * > DcuDetIdMap
void addDcuDetIds(std::string partition, DcuDetIdsV &)
Definition: DcuDetIds.cc:108
DeviceDescriptionsV muxDevices_
DeviceDescriptions devices_
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:30
friend class SiStripCommissioningDbClient
std::string analysisType(AnalysisType) const
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
std::vector< FedConnection * > FedConnectionsV
DbClient * dbCache_
void addFedConnections(std::string partition, FedConnectionsV &)
void clearDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:272
void clearFedDescriptions(std::string partition="")
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
std::vector< FedDescription * > FedDescriptionsV
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
std::vector< DeviceDescription * > DeviceDescriptionsV
std::pair< uint32_t, TkDcuInfo * > DcuDetId
DcuDetIds dcuDetIds_