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 
29 #include "DbClient.h"
30 
31 namespace sistrip {
32  static const uint16_t FEC_CRATE_OFFSET = 0; //@@ temporary
33  static const uint16_t FEC_RING_OFFSET = 0; //@@ temporary
34 }
35 
36 // Friend class
37 namespace cms { class SiStripO2O; }
38 
45 
46  public:
47 
48 
49  // ---------- Constructors, destructors ----------
50 
51 
56  const edm::ActivityRegistry& );
57 
60 
61 
62  // ---------- PROTECTED INTERFACE ----------
63 
64 
65  protected:
66 
67  /*
68  Access to the configuration database is reserved solely for the
69  commissioning (database) client and the online-to-offline transfer
70  tool. If you wish to use this interface to the configuration
71  database, then please contact one of the package administrators.
72  */
73 
74  // ESSources and O2O
79  friend class SiStripPsuDetIdMap;
80 
81 
82  // Commissioning clients
88  friend class ApvTimingHistosUsingDb;
89  friend class OptoScanHistosUsingDb;
90  friend class PedestalsHistosUsingDb;
92  friend class PedsOnlyHistosUsingDb;
93  friend class NoiseHistosUsingDb;
94  friend class VpspScanHistosUsingDb;
95  friend class LatencyHistosUsingDb;
96  friend class FineDelayHistosUsingDb;
98 
99  // Utility and tests
100  friend class SiStripPartition;
101  friend class testSiStripConfigDb;
102 
103 
104 
105  // ---------- Typedefs ----------
106 
107 
108  // FED connections
109  typedef ConnectionDescription FedConnection;
112  typedef std::vector<FedConnection*> FedConnectionsV;
113 
114  // Device descriptions
115  typedef enumDeviceType DeviceType;
116  typedef deviceDescription DeviceDescription;
119  typedef std::vector<DeviceDescription*> DeviceDescriptionsV;
120 
121  // FED descriptions
122  typedef Fed9U::Fed9UDescription FedDescription;
125  typedef std::vector<FedDescription*> FedDescriptionsV;
126 
127  // FED ids
128  typedef std::vector<uint16_t> FedIds;
129  typedef boost::iterator_range<FedIds::const_iterator> FedIdsRange;
130 
131  // DCU-DetId map
132  typedef Sgi::hash_map<unsigned long,TkDcuInfo*> DcuDetIdMap;
133  typedef std::pair<uint32_t,TkDcuInfo*> DcuDetId;
136  typedef std::vector<DcuDetId> DcuDetIdsV;
137 
138 
139  // Analysis descriptions
140  typedef CommissioningAnalysisDescription::commissioningType AnalysisType;
141  typedef CommissioningAnalysisDescription AnalysisDescription;
144  typedef std::vector<AnalysisDescription*> AnalysisDescriptionsV;
145 
146 
147  // ---------- Useful structs ----------
148 
149 
152  class DeviceAddress {
153  public:
154  DeviceAddress();
155  void reset();
156  uint16_t fecCrate_;
157  uint16_t fecSlot_;
158  uint16_t fecRing_;
159  uint16_t ccuAddr_;
160  uint16_t ccuChan_;
161  uint16_t lldChan_;
162  uint16_t i2cAddr_;
163  uint16_t fedId_;
164  uint16_t feUnit_;
165  uint16_t feChan_;
166  };
167 
168 
169  // ---------- Connection and useful methods ----------
170 
171 
173  void openDbConnection();
174 
176  void closeDbConnection();
177 
179  inline const SiStripDbParams& dbParams() const;
180 
182  inline bool usingDb() const;
183 
185  DeviceFactory* const deviceFactory( std::string method_name = "" ) const;
186 
188  DbClient* const databaseCache( std::string method_name = "" ) const;
189 
190 
191  // ---------- Run numbers for partitions and run types ----------
192 
193 
194  class Run {
195  public:
198  uint16_t number_;
199  Run() : type_(sistrip::UNDEFINED_RUN_TYPE), partition_(""), number_(0) {;}
200  };
201 
202  typedef std::vector<Run> Runs;
203 
204  typedef std::map<sistrip::RunType,Runs> RunsByType;
205 
206  typedef std::map<std::string,Runs> RunsByPartition;
207 
209  void runs( Runs& ) const;
210 
212  void runs( const Runs& in,
213  RunsByType& out,
214  std::string optional_partition = "" ) const;
215 
217  void runs( const Runs& in,
219  sistrip::RunType optional_type = sistrip::UNDEFINED_RUN_TYPE ) const;
220 
222  void partitions( std::list<std::string>& ) const;
223 
224  //@@ SiStripPartition::Versions ???
225 
226 
227  // ---------- FED connections ----------
228 
229 
232 
234  void addFedConnections( std::string partition, FedConnectionsV& );
235 
237  void uploadFedConnections( std::string partition = "" );
238 
240  void clearFedConnections( std::string partition = "" );
241 
243  void printFedConnections( std::string partition = "" );
244 
245 
246  // ---------- FEC / Front-End devices ----------
247 
248 
251 
255 
258 
260  void uploadDeviceDescriptions( std::string partition = "" );
261 
263  void clearDeviceDescriptions( std::string partition = "" );
264 
266  void printDeviceDescriptions( std::string partition = "" );
267 
269  DeviceAddress deviceAddress( const deviceDescription& ); //@@ uses temp offsets!
270 
271 
272  // ---------- FED descriptions ----------
273 
274 
277 
279  void addFedDescriptions( std::string partition, FedDescriptionsV& );
280 
282  void uploadFedDescriptions( std::string partition = "" );
283 
285  void clearFedDescriptions( std::string partition = "" );
286 
288  void printFedDescriptions( std::string partition = "" );
289 
291  FedIdsRange getFedIds( std::string partition = "" );
292 
294  inline bool usingStrips() const;
295 
297  inline void usingStrips( bool );
298 
299 
300  // ---------- DCU-DetId info ----------
301 
302 
304  DcuDetIdsRange getDcuDetIds( std::string partition = "" );
305 
307  void addDcuDetIds( std::string partition, DcuDetIdsV& );
308 
310  void uploadDcuDetIds( std::string partition = "" );
311 
313  void clearDcuDetIds( std::string partition = "" );
314 
316  void printDcuDetIds( std::string partition = "" );
317 
319  static DcuDetIdsV::const_iterator findDcuDetId( DcuDetIdsV::const_iterator begin,
320  DcuDetIdsV::const_iterator end,
321  uint32_t dcu_id );
322 
324  static DcuDetIdsV::iterator findDcuDetId( DcuDetIdsV::iterator begin,
325  DcuDetIdsV::iterator end,
326  uint32_t dcu_id );
327 
328 
329  // ---------- Commissioning analyses ----------
330 
331 
334 
337 
339  void uploadAnalysisDescriptions( bool calibration_for_physics = false, std::string partition = "" );
340 
342  void clearAnalysisDescriptions( std::string partition = "" );
343 
345  void printAnalysisDescriptions( std::string partition = "" );
346 
348  DeviceAddress deviceAddress( const AnalysisDescription& ); //@@ uses temp offsets!
349 
352 
353 
354  private:
355 
356 
357  // ---------- Private methods ----------
358 
359 
361  void clearLocalCache();
362 
364  void usingDatabase();
365 
367  void usingDatabaseCache();
368 
370  void usingXmlFiles();
371 
373  void handleException( const std::string& method_name,
374  const std::string& extra_info = "" ) const;
375 
377  bool checkFileExists( const std::string& path );
378 
380  std::string deviceType( const enumDeviceType& device_type ) const;
381 
382  void clone( const DcuDetIdMap& in, DcuDetIdsV& out ) const;
383 
384  void clone( const DcuDetIdsV& in, DcuDetIdMap& out ) const;
385 
386  void clone( const DcuDetIdsV& in, DcuDetIdsV& out ) const;
387 
388 
389  // ---------- Database connection, partitions and versions ----------
390 
391 
393  DeviceFactory* factory_;
394 
396  DbClient* dbCache_;
397 
400 
401 
402  // ---------- Local cache of vectors ----------
403 
404 
407 
410 
413 
416 
419 
422 
425 
428 
431 
434 
437 
440 
443 
444 
445  // ---------- Miscellaneous ----------
446 
447 
450 
453 
455  static uint32_t cntr_;
456 
457  static bool allowCalibUpload_;
458 
459 
460 };
461 
462 
463 // ---------- Inline methods ----------
464 
465 
468 
470 bool SiStripConfigDb::usingDb() const { return dbParams_.usingDb(); }
471 
474 
476 void SiStripConfigDb::usingStrips( bool using_strips ) { usingStrips_ = using_strips; }
477 
478 
479 #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
tuple path
else: Piece not in the list, fine.
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.
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 &)
static uint32_t cntr_
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
tuple out
Definition: dbtoconf.py:99
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
static bool allowCalibUpload_
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
void printAnalysisDescriptions(std::string partition="")
boost::iterator_range< data_iterator > range
Definition: MapOfVectors.h:32
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_