CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
SiStripConfigDb Class Reference

An interface class to the DeviceFactory. More...

#include <SiStripConfigDb.h>

Classes

class  DeviceAddress
 
class  Run
 

Public Member Functions

 SiStripConfigDb (const edm::ParameterSet &, const edm::ActivityRegistry &)
 
 ~SiStripConfigDb ()
 

Protected Types

typedef CommissioningAnalysisDescription AnalysisDescription
 
typedef edm::MapOfVectors< std::string, AnalysisDescription * > AnalysisDescriptions
 
typedef AnalysisDescriptions::range AnalysisDescriptionsRange
 
typedef std::vector< AnalysisDescription * > AnalysisDescriptionsV
 
typedef CommissioningAnalysisDescription::commissioningType AnalysisType
 
typedef std::pair< uint32_t, TkDcuInfo * > DcuDetId
 
typedef Sgi::hash_map< unsigned long, TkDcuInfo * > DcuDetIdMap
 
typedef edm::MapOfVectors< std::string, DcuDetIdDcuDetIds
 
typedef DcuDetIds::range DcuDetIdsRange
 
typedef std::vector< DcuDetIdDcuDetIdsV
 
typedef deviceDescription DeviceDescription
 
typedef edm::MapOfVectors< std::string, DeviceDescription * > DeviceDescriptions
 
typedef DeviceDescriptions::range DeviceDescriptionsRange
 
typedef std::vector< DeviceDescription * > DeviceDescriptionsV
 
typedef enumDeviceType DeviceType
 
typedef ConnectionDescription FedConnection
 
typedef edm::MapOfVectors< std::string, FedConnection * > FedConnections
 
typedef FedConnections::range FedConnectionsRange
 
typedef std::vector< FedConnection * > FedConnectionsV
 
typedef Fed9U::Fed9UDescription FedDescription
 
typedef edm::MapOfVectors< std::string, FedDescription * > FedDescriptions
 
typedef FedDescriptions::range FedDescriptionsRange
 
typedef std::vector< FedDescription * > FedDescriptionsV
 
typedef std::vector< uint16_t > FedIds
 
typedef boost::iterator_range< FedIds::const_iterator > FedIdsRange
 
typedef std::vector< RunRuns
 
typedef std::map< std::string, RunsRunsByPartition
 
typedef std::map< sistrip::RunType, RunsRunsByType
 

Protected Member Functions

void addAnalysisDescriptions (std::string partition, AnalysisDescriptionsV &)
 
void addDcuDetIds (std::string partition, DcuDetIdsV &)
 
void addDeviceDescriptions (std::string partition, DeviceDescriptionsV &)
 
void addFedConnections (std::string partition, FedConnectionsV &)
 
void addFedDescriptions (std::string partition, FedDescriptionsV &)
 
std::string analysisType (AnalysisType) const
 
void clearAnalysisDescriptions (std::string partition="")
 
void clearDcuDetIds (std::string partition="")
 
void clearDeviceDescriptions (std::string partition="")
 
void clearFedConnections (std::string partition="")
 
void clearFedDescriptions (std::string partition="")
 
void closeDbConnection ()
 
DbClient *const databaseCache (std::string method_name="") const
 
const SiStripDbParamsdbParams () const
 
DeviceAddress deviceAddress (const deviceDescription &)
 
DeviceAddress deviceAddress (const AnalysisDescription &)
 
DeviceFactory *const deviceFactory (std::string method_name="") const
 
AnalysisDescriptionsRange getAnalysisDescriptions (AnalysisType, std::string partition="")
 
DcuDetIdsRange getDcuDetIds (std::string partition="")
 
DeviceDescriptionsRange getDeviceDescriptions (std::string partition="")
 
DeviceDescriptionsRange getDeviceDescriptions (DeviceType, std::string partition="")
 
FedConnectionsRange getFedConnections (std::string partition="")
 
FedDescriptionsRange getFedDescriptions (std::string partition="")
 
FedIdsRange getFedIds (std::string partition="")
 
void openDbConnection ()
 
void partitions (std::list< std::string > &) const
 
void printAnalysisDescriptions (std::string partition="")
 
void printDcuDetIds (std::string partition="")
 
void printDeviceDescriptions (std::string partition="")
 
void printFedConnections (std::string partition="")
 
void printFedDescriptions (std::string partition="")
 
void runs (Runs &) const
 
void runs (const Runs &in, RunsByType &out, std::string optional_partition="") const
 
void runs (const Runs &in, RunsByPartition &out, sistrip::RunType optional_type=sistrip::UNDEFINED_RUN_TYPE) const
 
void uploadAnalysisDescriptions (bool calibration_for_physics=false, std::string partition="")
 
void uploadDcuDetIds (std::string partition="")
 
void uploadDeviceDescriptions (std::string partition="")
 
void uploadFedConnections (std::string partition="")
 
void uploadFedDescriptions (std::string partition="")
 
bool usingDb () const
 
bool usingStrips () const
 
void usingStrips (bool)
 

Static Protected Member Functions

static DcuDetIdsV::const_iterator findDcuDetId (DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
 
static DcuDetIdsV::iterator findDcuDetId (DcuDetIdsV::iterator begin, DcuDetIdsV::iterator end, uint32_t dcu_id)
 

Private Member Functions

bool checkFileExists (const std::string &path)
 
void clearLocalCache ()
 
void clone (const DcuDetIdMap &in, DcuDetIdsV &out) const
 
void clone (const DcuDetIdsV &in, DcuDetIdMap &out) const
 
void clone (const DcuDetIdsV &in, DcuDetIdsV &out) const
 
std::string deviceType (const enumDeviceType &device_type) const
 
void handleException (const std::string &method_name, const std::string &extra_info="") const
 
void usingDatabase ()
 
void usingDatabaseCache ()
 
void usingXmlFiles ()
 

Private Attributes

AnalysisDescriptions analyses_
 
DeviceDescriptionsV apvDevices_
 
FedConnections connections_
 
DbClient * dbCache_
 
SiStripDbParams dbParams_
 
DcuDetIds dcuDetIds_
 
DeviceDescriptionsV dcuDevices_
 
DeviceDescriptions devices_
 
DeviceDescriptionsV dohDevices_
 
DeviceFactory * factory_
 
FedIds fedIds_
 
FedDescriptions feds_
 
DeviceDescriptionsV lldDevices_
 
DeviceDescriptionsV muxDevices_
 
bool openConnection_
 
DeviceDescriptionsV pllDevices_
 
DeviceDescriptionsV typedDevices_
 
bool usingStrips_
 

Static Private Attributes

static std::atomic< bool > allowCalibUpload_ { false }
 
static std::atomic< uint32_t > cntr_ {0}
 

Friends

class ApvTimingHistosUsingDb
 
class CalibrationHistosUsingDb
 
class CommissioningHistosUsingDb
 
class DaqScopeModeHistosUsingDb
 
class FastFedCablingHistosUsingDb
 
class FedCablingHistosUsingDb
 
class FineDelayHistosUsingDb
 
class LatencyHistosUsingDb
 
class NoiseHistosUsingDb
 
class OptoScanHistosUsingDb
 
class PedestalsHistosUsingDb
 
class PedsFullNoiseHistosUsingDb
 
class PedsOnlyHistosUsingDb
 
class SiStripCommissioningDbClient
 
class SiStripCommissioningOfflineDbClient
 
class SiStripCondObjBuilderFromDb
 
class SiStripFedCablingBuilderFromDb
 
class SiStripNoiseBuilderFromDb
 
class SiStripPartition
 
class SiStripPedestalsBuilderFromDb
 
class SiStripPsuDetIdMap
 
class testSiStripConfigDb
 
class VpspScanHistosUsingDb
 

Detailed Description

An interface class to the DeviceFactory.

Author
R.Bainbridge

Definition at line 45 of file SiStripConfigDb.h.

Member Typedef Documentation

typedef CommissioningAnalysisDescription SiStripConfigDb::AnalysisDescription
protected

Definition at line 143 of file SiStripConfigDb.h.

Definition at line 144 of file SiStripConfigDb.h.

Definition at line 145 of file SiStripConfigDb.h.

Definition at line 146 of file SiStripConfigDb.h.

typedef CommissioningAnalysisDescription::commissioningType SiStripConfigDb::AnalysisType
protected

Definition at line 142 of file SiStripConfigDb.h.

typedef std::pair<uint32_t,TkDcuInfo*> SiStripConfigDb::DcuDetId
protected

Definition at line 135 of file SiStripConfigDb.h.

typedef Sgi::hash_map<unsigned long,TkDcuInfo*> SiStripConfigDb::DcuDetIdMap
protected

Definition at line 134 of file SiStripConfigDb.h.

typedef edm::MapOfVectors<std::string,DcuDetId> SiStripConfigDb::DcuDetIds
protected

Definition at line 136 of file SiStripConfigDb.h.

Definition at line 137 of file SiStripConfigDb.h.

typedef std::vector<DcuDetId> SiStripConfigDb::DcuDetIdsV
protected

Definition at line 138 of file SiStripConfigDb.h.

typedef deviceDescription SiStripConfigDb::DeviceDescription
protected

Definition at line 118 of file SiStripConfigDb.h.

Definition at line 119 of file SiStripConfigDb.h.

Definition at line 120 of file SiStripConfigDb.h.

Definition at line 121 of file SiStripConfigDb.h.

typedef enumDeviceType SiStripConfigDb::DeviceType
protected

Definition at line 117 of file SiStripConfigDb.h.

typedef ConnectionDescription SiStripConfigDb::FedConnection
protected

Definition at line 111 of file SiStripConfigDb.h.

Definition at line 112 of file SiStripConfigDb.h.

Definition at line 113 of file SiStripConfigDb.h.

typedef std::vector<FedConnection*> SiStripConfigDb::FedConnectionsV
protected

Definition at line 114 of file SiStripConfigDb.h.

typedef Fed9U::Fed9UDescription SiStripConfigDb::FedDescription
protected

Definition at line 124 of file SiStripConfigDb.h.

Definition at line 125 of file SiStripConfigDb.h.

Definition at line 126 of file SiStripConfigDb.h.

typedef std::vector<FedDescription*> SiStripConfigDb::FedDescriptionsV
protected

Definition at line 127 of file SiStripConfigDb.h.

typedef std::vector<uint16_t> SiStripConfigDb::FedIds
protected

Definition at line 130 of file SiStripConfigDb.h.

typedef boost::iterator_range<FedIds::const_iterator> SiStripConfigDb::FedIdsRange
protected

Definition at line 131 of file SiStripConfigDb.h.

typedef std::vector<Run> SiStripConfigDb::Runs
protected

Definition at line 204 of file SiStripConfigDb.h.

typedef std::map<std::string,Runs> SiStripConfigDb::RunsByPartition
protected

Definition at line 208 of file SiStripConfigDb.h.

typedef std::map<sistrip::RunType,Runs> SiStripConfigDb::RunsByType
protected

Definition at line 206 of file SiStripConfigDb.h.

Constructor & Destructor Documentation

SiStripConfigDb::SiStripConfigDb ( const edm::ParameterSet pset,
const edm::ActivityRegistry activity 
)

Constructor when using the "service" mode, which takes as an argument a ParameterSet (containing the database connection parameters).

Definition at line 21 of file SiStripConfigDb.cc.

References cntr_, KineDebug3::count(), dbParams_, sistrip::mlConfigDb_, openDbConnection(), SiStripDbParams::pset(), and SiStripDbParams::reset().

22  :
23  factory_(nullptr),
24  dbCache_(nullptr),
25  dbParams_(),
26  // Local cache
27  connections_(),
28  devices_(),
29  feds_(),
30  dcuDetIds_(),
31  analyses_(),
32  apvDevices_(),
33  muxDevices_(),
34  dcuDevices_(),
35  lldDevices_(),
36  pllDevices_(),
37  dohDevices_(),
38  typedDevices_(),
39  fedIds_(),
40  // Misc
41  usingStrips_(true),
42  openConnection_(false)
43 {
44  auto count = ++cntr_;
46  << "[SiStripConfigDb::" << __func__ << "]"
47  << " Constructing database service..."
48  << " (Class instance: " << count << ")";
49 
50  // Set DB connection parameters
51  dbParams_.reset();
52  dbParams_.pset( pset );
53  //edm::LogVerbatim(mlConfigDb_) << dbParams_;
54 
55  // Open connection
57 
58 }
DeviceDescriptionsV apvDevices_
DeviceDescriptionsV typedDevices_
DeviceDescriptionsV dohDevices_
DeviceFactory * factory_
DeviceDescriptionsV lldDevices_
AnalysisDescriptions analyses_
FedConnections connections_
DeviceDescriptionsV pllDevices_
static const char mlConfigDb_[]
DeviceDescriptionsV dcuDevices_
static std::atomic< uint32_t > cntr_
FedDescriptions feds_
DeviceDescriptionsV muxDevices_
DeviceDescriptions devices_
void pset(const edm::ParameterSet &)
SiStripDbParams dbParams_
DbClient * dbCache_
DcuDetIds dcuDetIds_
SiStripConfigDb::~SiStripConfigDb ( )

Default destructor.

Definition at line 62 of file SiStripConfigDb.cc.

References closeDbConnection(), cntr_, LogTrace, and sistrip::mlConfigDb_.

62  {
65  << "[SiStripConfigDb::" << __func__ << "]"
66  << " Destructing object...";
67  --cntr_;
68 }
static const char mlConfigDb_[]
static std::atomic< uint32_t > cntr_
#define LogTrace(id)

Member Function Documentation

void SiStripConfigDb::addAnalysisDescriptions ( std::string  partition,
AnalysisDescriptionsV anals 
)
protected

Adds to local cache (just for given partition if specified).

Definition at line 165 of file AnalysisDescriptions.cc.

References LogTrace, sistrip::mlConfigDb_, and tmp.

Referenced by CommissioningHistosUsingDb::uploadAnalyses().

165  {
166 
167  if ( !deviceFactory(__func__) ) { return; }
168 
169  if ( partition.empty() ) {
170  stringstream ss;
171  ss << "[SiStripConfigDb::" << __func__ << "]"
172  << " Partition string is empty,"
173  << " therefore cannot add analysis descriptions to local cache!";
174  edm::LogWarning(mlConfigDb_) << ss.str();
175  return;
176  }
177 
178  if ( anals.empty() ) {
179  stringstream ss;
180  ss << "[SiStripConfigDb::" << __func__ << "]"
181  << " Vector of analysis descriptions is empty,"
182  << " therefore cannot add analysis descriptions to local cache!";
183  edm::LogWarning(mlConfigDb_) << ss.str();
184  return;
185  }
186 
187  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
188  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
189  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
190  if ( iter == dbParams_.partitions().end() ) {
191  stringstream ss;
192  ss << "[SiStripConfigDb::" << __func__ << "]"
193  << " Partition \"" << partition
194  << "\" not found in partition list, "
195  << " therefore cannot add analysis descriptions!";
196  edm::LogWarning(mlConfigDb_) << ss.str();
197  return;
198  }
199 
200  AnalysisDescriptionsRange range = analyses_.find( partition );
201  if ( range == analyses_.emptyRange() ) {
202 
203  // Make local copy
205  CommissioningAnalysisFactory::vectorCopy( anals, tmp );
206 
207  // Add to local cache
208  analyses_.loadNext( partition, tmp );
209 
210  // Some debug
211  std::stringstream ss;
212  ss << "[SiStripConfigDb::" << __func__ << "]"
213  << " Added " << anals.size()
214  << " analysis descriptions to local cache for partition \""
215  << partition << "\"."
216  << " (Cache holds analysis descriptions for "
217  << analyses_.size() << " partitions.)";
218  LogTrace(mlConfigDb_) << ss.str();
219  } else {
220  stringstream ss;
221  ss << "[SiStripConfigDb::" << __func__ << "]"
222  << " Partition \"" << partition
223  << "\" already found in local cache, "
224  << " therefore cannot add analysis descriptions!";
225  edm::LogWarning(mlConfigDb_) << ss.str();
226  return;
227  }
228 
229 }
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
AnalysisDescriptions analyses_
static const char mlConfigDb_[]
const_iterator_range partitions() const
size_type size() const
Definition: MapOfVectors.h:106
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
AnalysisDescriptions::range AnalysisDescriptionsRange
range emptyRange() const
Definition: MapOfVectors.h:82
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SiStripDbParams dbParams_
std::vector< AnalysisDescription * > AnalysisDescriptionsV
void SiStripConfigDb::addDcuDetIds ( std::string  partition,
DcuDetIdsV dcus 
)
protected

Adds to local cache (just for given partition if specified).

Definition at line 108 of file DcuDetIds.cc.

References sistrip::mlConfigDb_.

108  {
109 
110  stringstream ss;
111  ss << "[SiStripConfigDb::" << __func__ << "]"
112  << " Cannot add to local cache! This functionality not allowed!";
113  edm::LogWarning(mlConfigDb_) << ss.str();
114 
115  // if ( !deviceFactory(__func__) ) { return; }
116 
117  // if ( partition.empty() ) {
118  // stringstream ss;
119  // ss << "[SiStripConfigDb::" << __func__ << "]"
120  // << " Partition string is empty,"
121  // << " therefore cannot add DCU-DetId map to local cache!";
122  // edm::LogWarning(mlConfigDb_) << ss.str();
123  // return;
124  // }
125 
126  // if ( dcus.empty() ) {
127  // stringstream ss;
128  // ss << "[SiStripConfigDb::" << __func__ << "]"
129  // << " Vector of DCU-DetId map is empty,"
130  // << " therefore cannot add DCU-DetId map to local cache!";
131  // edm::LogWarning(mlConfigDb_) << ss.str();
132  // return;
133  // }
134 
135  // SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
136  // SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
137  // for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
138  // if ( iter == dbParams_.partitions().end() ) {
139  // stringstream ss;
140  // ss << "[SiStripConfigDb::" << __func__ << "]"
141  // << " Partition \"" << partition
142  // << "\" not found in partition list, "
143  // << " therefore cannot add DCU-DetId map!";
144  // edm::LogWarning(mlConfigDb_) << ss.str();
145  // return;
146  // }
147 
148  // DcuDetIdsRange range = dcuDetIds_.find( partition );
149  // if ( range == dcuDetIds_.emptyRange() ) {
150 
151  // // Make local copy
152  // DcuDetIdsV dst;
153  // clone( dcus, dst );
154 
155  // // Add to local cache
156  // dcuDetIds_.loadNext( partition, dst );
157 
158  // // Some debug
159  // std::stringstream ss;
160  // ss << "[SiStripConfigDb::" << __func__ << "]"
161  // << " Added " << dst.size()
162  // << " DCU-DetId map to local cache for partition \""
163  // << partition << "\"" << std::endl;
164  // ss << "[SiStripConfigDb::" << __func__ << "]"
165  // << " Cache holds DCU-DetId map for "
166  // << dcuDetIds_.size() << " partitions.";
167  // LogTrace(mlConfigDb_) << ss.str();
168 
169  // } else {
170  // stringstream ss;
171  // ss << "[SiStripConfigDb::" << __func__ << "]"
172  // << " Partition \"" << partition
173  // << "\" already found in local cache, "
174  // << " therefore cannot add new DCU-DetId map!";
175  // edm::LogWarning(mlConfigDb_) << ss.str();
176  // return;
177  // }
178 
179 }
static const char mlConfigDb_[]
void SiStripConfigDb::addDeviceDescriptions ( std::string  partition,
DeviceDescriptionsV devs 
)
protected

Adds to local cache (just for given partition if specified).

Definition at line 199 of file DeviceDescriptions.cc.

References LogTrace, sistrip::mlConfigDb_, and tmp.

199  {
200 
201  if ( !deviceFactory(__func__) ) { return; }
202 
203  if ( partition.empty() ) {
204  stringstream ss;
205  ss << "[SiStripConfigDb::" << __func__ << "]"
206  << " Partition string is empty,"
207  << " therefore cannot add device descriptions to local cache!";
208  edm::LogWarning(mlConfigDb_) << ss.str();
209  return;
210  }
211 
212  if ( devs.empty() ) {
213  stringstream ss;
214  ss << "[SiStripConfigDb::" << __func__ << "]"
215  << " Vector of device descriptions is empty,"
216  << " therefore cannot add device descriptions to local cache!";
217  edm::LogWarning(mlConfigDb_) << ss.str();
218  return;
219  }
220 
221  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
222  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
223  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
224  if ( iter == dbParams_.partitions().end() ) {
225  stringstream ss;
226  ss << "[SiStripConfigDb::" << __func__ << "]"
227  << " Partition \"" << partition
228  << "\" not found in partition list, "
229  << " therefore cannot add device descriptions!";
230  edm::LogWarning(mlConfigDb_) << ss.str();
231  return;
232  }
233 
234  DeviceDescriptionsRange range = devices_.find( partition );
235  if ( range == devices_.emptyRange() ) {
236 
237  // Make local copy
239  FecFactory::vectorCopyI( tmp, devs, true );
240 
241  // Add to local cache
242  devices_.loadNext( partition, tmp );
243 
244  // Some debug
245  std::stringstream ss;
246  ss << "[SiStripConfigDb::" << __func__ << "]"
247  << " Added " << devs.size()
248  << " device descriptions to local cache for partition \""
249  << partition << "\"."
250  << " (Cache holds device descriptions for "
251  << devices_.size() << " partitions.)";
252  LogTrace(mlConfigDb_) << ss.str();
253 
254  } else {
255  stringstream ss;
256  ss << "[SiStripConfigDb::" << __func__ << "]"
257  << " Partition \"" << partition
258  << "\" already found in local cache, "
259  << " therefore cannot add device descriptions!";
260  edm::LogWarning(mlConfigDb_) << ss.str();
261  return;
262  }
263 
264 }
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
static const char mlConfigDb_[]
const_iterator_range partitions() const
DeviceDescriptions::range DeviceDescriptionsRange
size_type size() const
Definition: MapOfVectors.h:106
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
DeviceDescriptions devices_
SiStripDbParams dbParams_
std::vector< DeviceDescription * > DeviceDescriptionsV
void SiStripConfigDb::addFedConnections ( std::string  partition,
FedConnectionsV conns 
)
protected

Add to local cache (just for given partition if specified).

Definition at line 127 of file FedConnections.cc.

References LogTrace, sistrip::mlConfigDb_, and tmp.

Referenced by FastFedCablingHistosUsingDb::uploadConfigurations().

127  {
128 
129  if ( !deviceFactory(__func__) ) { return; }
130 
131  if ( partition.empty() ) {
132  stringstream ss;
133  ss << "[SiStripConfigDb::" << __func__ << "]"
134  << " Partition string is empty,"
135  << " therefore cannot add FED connections to local cache!";
136  edm::LogWarning(mlConfigDb_) << ss.str();
137  return;
138  }
139 
140  if ( conns.empty() ) {
141  stringstream ss;
142  ss << "[SiStripConfigDb::" << __func__ << "]"
143  << " Vector of FED connections is empty,"
144  << " therefore cannot add FED connections to local cache!";
145  edm::LogWarning(mlConfigDb_) << ss.str();
146  return;
147  }
148 
149  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
150  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
151  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
152  if ( iter == dbParams_.partitions().end() ) {
153  stringstream ss;
154  ss << "[SiStripConfigDb::" << __func__ << "]"
155  << " Partition \"" << partition
156  << "\" not found in partition list, "
157  << " therefore cannot add FED connections!";
158  edm::LogWarning(mlConfigDb_) << ss.str();
159  return;
160  }
161 
162  FedConnectionsRange range = connections_.find( partition );
163  if ( range == connections_.emptyRange() ) {
164 
165  // Make local copy
167  ConnectionFactory::vectorCopyI( tmp, conns, true );
168 
169  // Add to local cache
170  connections_.loadNext( partition, tmp );
171 
172  // Some debug
173  std::stringstream ss;
174  ss << "[SiStripConfigDb::" << __func__ << "]"
175  << " Added " << conns.size()
176  << " FED connections to local cache for partition \""
177  << partition << "\"" << std::endl;
178  ss << "[SiStripConfigDb::" << __func__ << "]"
179  << " Cache holds FED connections for "
180  << connections_.size() << " partitions.";
181  LogTrace(mlConfigDb_) << ss.str();
182 
183  } else {
184  stringstream ss;
185  ss << "[SiStripConfigDb::" << __func__ << "]"
186  << " Partition \"" << partition
187  << "\" already found in local cache, "
188  << " therefore cannot add new FED connections!";
189  edm::LogWarning(mlConfigDb_) << ss.str();
190  return;
191  }
192 
193 }
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
FedConnections connections_
FedConnections::range FedConnectionsRange
static const char mlConfigDb_[]
const_iterator_range partitions() const
size_type size() const
Definition: MapOfVectors.h:106
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SiStripDbParams dbParams_
std::vector< FedConnection * > FedConnectionsV
void SiStripConfigDb::addFedDescriptions ( std::string  partition,
FedDescriptionsV feds 
)
protected

Adds to local cache (just for given partition if specified).

Definition at line 131 of file FedDescriptions.cc.

References LogTrace, sistrip::mlConfigDb_, and tmp.

131  {
132 
133  if ( !deviceFactory(__func__) ) { return; }
134 
135  if ( partition.empty() ) {
136  stringstream ss;
137  ss << "[SiStripConfigDb::" << __func__ << "]"
138  << " Partition string is empty,"
139  << " therefore cannot add FED descriptions to local cache!";
140  edm::LogWarning(mlConfigDb_) << ss.str();
141  return;
142  }
143 
144  if ( feds.empty() ) {
145  stringstream ss;
146  ss << "[SiStripConfigDb::" << __func__ << "]"
147  << " Vector of FED descriptions is empty,"
148  << " therefore cannot add FED descriptions to local cache!";
149  edm::LogWarning(mlConfigDb_) << ss.str();
150  return;
151  }
152 
153  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
154  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
155  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
156  if ( iter == dbParams_.partitions().end() ) {
157  stringstream ss;
158  ss << "[SiStripConfigDb::" << __func__ << "]"
159  << " Partition \"" << partition
160  << "\" not found in partition list, "
161  << " therefore cannot add FED descriptions!";
162  edm::LogWarning(mlConfigDb_) << ss.str();
163  return;
164  }
165 
166  FedDescriptionsRange range = feds_.find( partition );
167  if ( range == feds_.emptyRange() ) {
168 
169  // Make local copy
171  Fed9U::Fed9UDeviceFactory::vectorCopy( tmp, feds );
172 
173  // Add to local cache
174  feds_.loadNext( partition, tmp );
175 
176  // Some debug
177  std::stringstream ss;
178  ss << "[SiStripConfigDb::" << __func__ << "]"
179  << " Added " << feds.size()
180  << " FED descriptions to local cache for partition \""
181  << iter->second.partitionName() << "\"" << std::endl;
182  ss << "[SiStripConfigDb::" << __func__ << "]"
183  << " Cache holds FED descriptions for "
184  << feds_.size() << " partitions.";
185  LogTrace(mlConfigDb_) << ss.str();
186 
187  } else {
188  stringstream ss;
189  ss << "[SiStripConfigDb::" << __func__ << "]"
190  << " Partition \"" << partition
191  << "\" already found in local cache, "
192  << " therefore cannot add new FED descriptions!";
193  edm::LogWarning(mlConfigDb_) << ss.str();
194  return;
195  }
196 
197 }
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
FedDescriptions::range FedDescriptionsRange
static const char mlConfigDb_[]
const_iterator_range partitions() const
FedDescriptions feds_
size_type size() const
Definition: MapOfVectors.h:106
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SiStripDbParams dbParams_
std::vector< FedDescription * > FedDescriptionsV
std::string SiStripConfigDb::analysisType ( AnalysisType  analysis_type) const
protected

Returns string for given analysis type.

Definition at line 531 of file AnalysisDescriptions.cc.

531  {
532  if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) { return "FAST_CABLING"; }
533  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) { return "APV_TIMING"; }
534  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) { return "OPTO_SCAN"; }
535  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) { return "PEDESTALS"; }
536  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) { return "PEDSFULLNOISE"; }
537  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) { return "APV_LATENCY"; }
538  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) { return "FINE_DELAY"; }
539  else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) { return "CALIBRATION"; }
540  else if ( analysis_type == AnalysisDescription::T_UNKNOWN ) { return "UNKNOWN ANALYSIS TYPE"; }
541  else { return "UNDEFINED ANALYSIS TYPE"; }
542 }
bool SiStripConfigDb::checkFileExists ( const std::string &  path)
private

Checks whether file at "path" exists or not.

Definition at line 810 of file SiStripConfigDb.cc.

References recoMuon::in.

Referenced by usingXmlFiles().

810  {
811  fstream fs;
812  fs.open( path.c_str(), ios::in );
813  if( !fs.is_open() ) { return false; }
814  fs.close();
815  return true;
816 }
void SiStripConfigDb::clearAnalysisDescriptions ( std::string  partition = "")
protected

Clears local cache (just for given partition if specified).

Definition at line 345 of file AnalysisDescriptions.cc.

References begin, end, edm::MapOfVectors< K, T >::loadNext(), LogTrace, and sistrip::mlConfigDb_.

Referenced by clearLocalCache(), and CommissioningHistosUsingDb::uploadAnalyses().

345  {
346  LogTrace(mlConfigDb_) << "[SiStripConfigDb::" << __func__ << "]";
347 
348  if ( analyses_.empty() ) {
349  stringstream ss;
350  ss << "[SiStripConfigDb::" << __func__ << "]"
351  << " Found no cached analysis descriptions!";
352  //edm::LogWarning(mlConfigDb_) << ss.str();
353  return;
354  }
355 
356  // Reproduce temporary cache for "all partitions except specified one" (or clear all if none specified)
357  AnalysisDescriptions temporary_cache;
358  if ( partition.empty() ) { temporary_cache = AnalysisDescriptions(); }
359  else {
360  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
361  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
362  for ( ; iter != jter; ++iter ) {
363  if ( partition != iter->second.partitionName() ) {
364  AnalysisDescriptionsRange range = analyses_.find( iter->second.partitionName() );
365  if ( range != analyses_.emptyRange() ) {
366  temporary_cache.loadNext( partition, AnalysisDescriptionsV( range.begin(), range.end() ) );
367  } else {
368  // stringstream ss;
369  // ss << "[SiStripConfigDb::" << __func__ << "]"
370  // << " Cannot find partition \"" << iter->second.partitionName()
371  // << "\" in local cache!";
372  // edm::LogWarning(mlConfigDb_) << ss.str();
373  }
374  }
375  }
376  }
377 
378  // Delete objects in local cache for specified partition (or all if not specified)
380  if ( partition.empty() ) {
381  if ( !analyses_.empty() ) {
382  anals = AnalysisDescriptionsRange( analyses_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
383  analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
384  } else { anals = analyses_.emptyRange(); }
385  } else {
386  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
387  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
388  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
389  anals = analyses_.find( iter->second.partitionName() );
390  }
391 
392  if ( anals != analyses_.emptyRange() ) {
393  AnalysisDescriptionsV::const_iterator ianal = anals.begin();
394  AnalysisDescriptionsV::const_iterator janal = anals.end();
395  for ( ; ianal != janal; ++ianal ) { if ( *ianal ) { delete *ianal; } }
396  } else {
397  stringstream ss;
398  ss << "[SiStripConfigDb::" << __func__ << "]";
399  if ( partition.empty() ) { ss << " Found no analysis descriptions in local cache!"; }
400  else { ss << " Found no analysis descriptions in local cache for partition \"" << partition << "\"!"; }
401  edm::LogWarning(mlConfigDb_) << ss.str();
402  }
403 
404  // Overwrite local cache with temporary cache
405  analyses_ = temporary_cache;
406 
407 }
AnalysisDescriptions analyses_
static const char mlConfigDb_[]
const_iterator_range partitions() const
edm::MapOfVectors< std::string, AnalysisDescription * > AnalysisDescriptions
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
AnalysisDescriptions::range AnalysisDescriptionsRange
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
std::vector< AnalysisDescription * > AnalysisDescriptionsV
void SiStripConfigDb::clearDcuDetIds ( std::string  partition = "")
protected

Clears local cache (just for given partition if specified).

Definition at line 272 of file DcuDetIds.cc.

References begin, end, edm::MapOfVectors< K, T >::loadNext(), LogTrace, and sistrip::mlConfigDb_.

Referenced by clearLocalCache().

272  {
273  LogTrace(mlConfigDb_) << "[SiStripConfigDb::" << __func__ << "]";
274 
275  if ( dcuDetIds_.empty() ) {
276  stringstream ss;
277  ss << "[SiStripConfigDb::" << __func__ << "]"
278  << " Found no cached DCU-DetId map!";
279  //edm::LogWarning(mlConfigDb_) << ss.str();
280  return;
281  }
282 
283  // Reproduce temporary cache for "all partitions except specified one" (or clear all if none specified)
284  DcuDetIds temporary_cache;
285  if ( partition == "" ) { temporary_cache = DcuDetIds(); }
286  else {
287  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
288  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
289  for ( ; iter != jter; ++iter ) {
290  if ( partition != iter->second.partitionName() ) {
291  DcuDetIdsRange range = dcuDetIds_.find( iter->second.partitionName() );
292  if ( range != dcuDetIds_.emptyRange() ) {
293  temporary_cache.loadNext( partition, DcuDetIdsV( range.begin(), range.end() ) );
294  } else {
295  // stringstream ss;
296  // ss << "[SiStripConfigDb::" << __func__ << "]"
297  // << " Cannot find partition \"" << iter->second.partitionName()
298  // << "\" in local cache!";
299  // edm::LogWarning(mlConfigDb_) << ss.str();
300  }
301  }
302  }
303  }
304 
305  // Delete objects in local cache for specified partition (or all if not specified)
306  DcuDetIdsRange dcus;
307  if ( partition == "" ) {
308  if ( !dcuDetIds_.empty() ) {
309  dcus = DcuDetIdsRange( dcuDetIds_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
310  dcuDetIds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
311  } else { dcus = dcuDetIds_.emptyRange(); }
312  } else {
313  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
314  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
315  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
316  dcus = dcuDetIds_.find( iter->second.partitionName() );
317  }
318 
319  if ( dcus != dcuDetIds_.emptyRange() ) {
320  DcuDetIdsV::const_iterator ifed = dcus.begin();
321  DcuDetIdsV::const_iterator jfed = dcus.end();
322  for ( ; ifed != jfed; ++ifed ) { if ( ifed->second ) { delete ifed->second; } }
323  } else {
324  stringstream ss;
325  ss << "[SiStripConfigDb::" << __func__ << "]";
326  if ( partition == "" ) { ss << " Found no DCU-DetId map in local cache!"; }
327  else { ss << " Found no DCU-DetId map in local cache for partition \"" << partition << "\"!"; }
328  edm::LogWarning(mlConfigDb_) << ss.str();
329  }
330 
331  // Overwrite local cache with temporary cache
332  dcuDetIds_ = temporary_cache;
333 
334 }
DcuDetIds::range DcuDetIdsRange
edm::MapOfVectors< std::string, DcuDetId > DcuDetIds
static const char mlConfigDb_[]
const_iterator_range partitions() const
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
std::vector< DcuDetId > DcuDetIdsV
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
DcuDetIds dcuDetIds_
void SiStripConfigDb::clearDeviceDescriptions ( std::string  partition = "")
protected

Clears local cache (just for given partition if specified).

Definition at line 345 of file DeviceDescriptions.cc.

References begin, end, edm::MapOfVectors< K, T >::loadNext(), LogTrace, and sistrip::mlConfigDb_.

Referenced by clearLocalCache(), and FineDelayHistosUsingDb::uploadConfigurations().

345  {
346  LogTrace(mlConfigDb_) << "[SiStripConfigDb::" << __func__ << "]";
347 
348  if ( devices_.empty() ) {
349  stringstream ss;
350  ss << "[SiStripConfigDb::" << __func__ << "]"
351  << " Found no cached device descriptions!";
352  //edm::LogWarning(mlConfigDb_) << ss.str();
353  return;
354  }
355 
356  // Reproduce temporary cache for "all partitions except specified one" (or clear all if none specified)
357  DeviceDescriptions temporary_cache;
358  if ( partition == "" ) { temporary_cache = DeviceDescriptions(); }
359  else {
360  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
361  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
362  for ( ; iter != jter; ++iter ) {
363  if ( partition != iter->second.partitionName() ) {
364  DeviceDescriptionsRange range = devices_.find( iter->second.partitionName() );
365  if ( range != devices_.emptyRange() ) {
366  temporary_cache.loadNext( partition, DeviceDescriptionsV( range.begin(), range.end() ) );
367  } else {
368  // stringstream ss;
369  // ss << "[SiStripConfigDb::" << __func__ << "]"
370  // << " Cannot find partition \"" << iter->second.partitionName()
371  // << "\" in local cache!";
372  // edm::LogWarning(mlConfigDb_) << ss.str();
373  }
374  }
375  }
376  }
377 
378  // Delete objects in local cache for specified partition (or all if not specified)
380  if ( partition == "" ) {
381  if ( !devices_.empty() ) {
382  devs = DeviceDescriptionsRange( devices_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
383  devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
384  } else { devs = devices_.emptyRange(); }
385  } else {
386  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
387  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
388  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
389  devs = devices_.find( iter->second.partitionName() );
390  }
391 
392  if ( devs != devices_.emptyRange() ) {
393  DeviceDescriptionsV::const_iterator ifed = devs.begin();
394  DeviceDescriptionsV::const_iterator jfed = devs.end();
395  for ( ; ifed != jfed; ++ifed ) { if ( *ifed ) { delete *ifed; } }
396  } else {
397  stringstream ss;
398  ss << "[SiStripConfigDb::" << __func__ << "]";
399  if ( partition == "" ) { ss << " Found no device descriptions in local cache!"; }
400  else { ss << " Found no device descriptions in local cache for partition \"" << partition << "\"!"; }
401  edm::LogWarning(mlConfigDb_) << ss.str();
402  }
403 
404  // Overwrite local cache with temporary cache
405  devices_ = temporary_cache;
406 
407 }
static const char mlConfigDb_[]
const_iterator_range partitions() const
edm::MapOfVectors< std::string, DeviceDescription * > DeviceDescriptions
DeviceDescriptions::range DeviceDescriptionsRange
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
DeviceDescriptions devices_
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
std::vector< DeviceDescription * > DeviceDescriptionsV
void SiStripConfigDb::clearFedConnections ( std::string  partition = "")
protected

Clears local cache (just for given partition if specified).

Definition at line 278 of file FedConnections.cc.

References begin, end, edm::MapOfVectors< K, T >::loadNext(), LogTrace, and sistrip::mlConfigDb_.

Referenced by clearLocalCache(), and FastFedCablingHistosUsingDb::uploadConfigurations().

278  {
279  LogTrace(mlConfigDb_) << "[SiStripConfigDb::" << __func__ << "]";
280 
281  if ( connections_.empty() ) {
282  stringstream ss;
283  ss << "[SiStripConfigDb::" << __func__ << "]"
284  << " Found no cached FED connections!";
285  //edm::LogWarning(mlConfigDb_) << ss.str();
286  return;
287  }
288 
289  // Reproduce temporary cache for "all partitions except specified one" (or clear all if none specified)
290  FedConnections temporary_cache;
291  if ( partition == "" ) { temporary_cache = FedConnections(); }
292  else {
293  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
294  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
295  for ( ; iter != jter; ++iter ) {
296  if ( partition != iter->second.partitionName() ) {
297  FedConnectionsRange range = connections_.find( iter->second.partitionName() );
298  if ( range != connections_.emptyRange() ) {
299  temporary_cache.loadNext( partition, FedConnectionsV( range.begin(), range.end() ) );
300  } else {
301  // stringstream ss;
302  // ss << "[SiStripConfigDb::" << __func__ << "]"
303  // << " Cannot find partition \"" << iter->second.partitionName()
304  // << "\" in local cache!";
305  // edm::LogWarning(mlConfigDb_) << ss.str();
306  }
307  }
308  }
309  }
310 
311  // Delete objects in local cache for specified partition (or all if not specified)
312  FedConnectionsRange conns;
313  if ( partition == "" ) {
314  if ( !connections_.empty() ) {
315  conns = FedConnectionsRange( connections_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
316  connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
317  } else { conns = connections_.emptyRange(); }
318  } else {
319  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
320  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
321  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
322  conns = connections_.find( iter->second.partitionName() );
323  }
324 
325  if ( conns != connections_.emptyRange() ) {
326  FedConnectionsV::const_iterator ifed = conns.begin();
327  FedConnectionsV::const_iterator jfed = conns.end();
328  for ( ; ifed != jfed; ++ifed ) { if ( *ifed ) { delete *ifed; } }
329  } else {
330  stringstream ss;
331  ss << "[SiStripConfigDb::" << __func__ << "]";
332  if ( partition == "" ) { ss << " Found no FED connections in local cache!"; }
333  else { ss << " Found no FED connections in local cache for partition \"" << partition << "\"!"; }
334  edm::LogWarning(mlConfigDb_) << ss.str();
335  }
336 
337  // Overwrite local cache with temporary cache
338  connections_ = temporary_cache;
339 
340 }
FedConnections connections_
FedConnections::range FedConnectionsRange
static const char mlConfigDb_[]
const_iterator_range partitions() const
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
edm::MapOfVectors< std::string, FedConnection * > FedConnections
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
std::vector< FedConnection * > FedConnectionsV
void SiStripConfigDb::clearFedDescriptions ( std::string  partition = "")
protected

Clears local cache (just for given partition if specified).

Definition at line 278 of file FedDescriptions.cc.

References begin, end, edm::MapOfVectors< K, T >::loadNext(), LogTrace, and sistrip::mlConfigDb_.

Referenced by clearLocalCache(), and FineDelayHistosUsingDb::uploadConfigurations().

278  {
279  LogTrace(mlConfigDb_) << "[SiStripConfigDb::" << __func__ << "]";
280 
281  if ( feds_.empty() ) {
282  stringstream ss;
283  ss << "[SiStripConfigDb::" << __func__ << "]"
284  << " Found no cached FED descriptions!";
285  //edm::LogWarning(mlConfigDb_) << ss.str();
286  return;
287  }
288 
289  // Reproduce temporary cache for "all partitions except specified one" (or clear all if none specified)
290  FedDescriptions temporary_cache;
291  if ( partition == "" ) { temporary_cache = FedDescriptions(); }
292  else {
293  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
294  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
295  for ( ; iter != jter; ++iter ) {
296  if ( partition != iter->second.partitionName() ) {
297  FedDescriptionsRange range = feds_.find( iter->second.partitionName() );
298  if ( range != feds_.emptyRange() ) {
299  temporary_cache.loadNext( partition, FedDescriptionsV( range.begin(), range.end() ) );
300  }
301  } else {
302  FedDescriptionsRange range = feds_.find( iter->second.partitionName() );
303  if ( range != feds_.emptyRange() ) {
305  << "[SiStripConfigDb::" << __func__ << "]"
306  << " Deleting FED descriptions for partition \""
307  << iter->second.partitionName()
308  << "\" from local cache...";
309  }
310  }
311  }
312  }
313 
314  // Delete objects in local cache for specified partition (or all if not specified)
316  if ( partition == "" ) {
317  if ( !feds_.empty() ) {
318  feds = FedDescriptionsRange( feds_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
319  feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
320  } else { feds = feds_.emptyRange(); }
321  } else {
322  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
323  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
324  for ( ; iter != jter; ++iter ) { if ( partition == iter->second.partitionName() ) { break; } }
325  feds = feds_.find( iter->second.partitionName() );
326  }
327 
328  if ( feds != feds_.emptyRange() ) {
329  FedDescriptionsV::const_iterator ifed = feds.begin();
330  FedDescriptionsV::const_iterator jfed = feds.end();
331  for ( ; ifed != jfed; ++ifed ) { if ( *ifed ) { delete *ifed; } }
332  } else {
333  stringstream ss;
334  ss << "[SiStripConfigDb::" << __func__ << "]";
335  if ( partition == "" ) { ss << " Found no FED descriptions in local cache!"; }
336  else { ss << " Found no FED descriptions in local cache for partition \"" << partition << "\"!"; }
337  edm::LogWarning(mlConfigDb_) << ss.str();
338  }
339 
340  // Overwrite local cache with temporary cache
341  feds_ = temporary_cache;
342 
343 }
FedDescriptions::range FedDescriptionsRange
static const char mlConfigDb_[]
edm::MapOfVectors< std::string, FedDescription * > FedDescriptions
const_iterator_range partitions() const
FedDescriptions feds_
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
std::vector< FedDescription * > FedDescriptionsV
void SiStripConfigDb::clearLocalCache ( )
private

Definition at line 176 of file SiStripConfigDb.cc.

References clearAnalysisDescriptions(), clearDcuDetIds(), clearDeviceDescriptions(), clearFedConnections(), clearFedDescriptions(), fedIds_, LogTrace, sistrip::mlConfigDb_, and typedDevices_.

Referenced by closeDbConnection(), and openDbConnection().

176  {
177 
179  << "[SiStripConfigDb::" << __func__ << "]"
180  << " Clearing local caches...";
181 
185  clearDcuDetIds();
187 
188  typedDevices_.clear();
189  fedIds_.clear();
190 
191 }
DeviceDescriptionsV typedDevices_
void clearDeviceDescriptions(std::string partition="")
static const char mlConfigDb_[]
void clearAnalysisDescriptions(std::string partition="")
#define LogTrace(id)
void clearFedConnections(std::string partition="")
void clearDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:272
void clearFedDescriptions(std::string partition="")
void SiStripConfigDb::clone ( const DcuDetIdMap in,
DcuDetIdsV out 
) const
private

Definition at line 368 of file DcuDetIds.cc.

References cuy::ii, and findQualityFiles::jj.

368  {
369  output.clear();
370  DcuDetIdMap::const_iterator ii = input.begin();
371  DcuDetIdMap::const_iterator jj = input.end();
372  for ( ; ii != jj; ++ii ) { if ( ii->second ) { output.push_back( std::make_pair( ii->first, new TkDcuInfo( *(ii->second) ) ) ); } }
373 }
static std::string const input
Definition: EdmProvDump.cc:48
ii
Definition: cuy.py:590
void SiStripConfigDb::clone ( const DcuDetIdsV in,
DcuDetIdMap out 
) const
private

Definition at line 377 of file DcuDetIds.cc.

References cuy::ii, and findQualityFiles::jj.

377  {
378  output.clear();
379  DcuDetIdsV::const_iterator ii = input.begin();
380  DcuDetIdsV::const_iterator jj = input.end();
381  for ( ; ii != jj; ++ii ) { if ( ii->second ) { output[ii->first] = new TkDcuInfo( *(ii->second) ); } }
382 }
static std::string const input
Definition: EdmProvDump.cc:48
ii
Definition: cuy.py:590
void SiStripConfigDb::clone ( const DcuDetIdsV in,
DcuDetIdsV out 
) const
private

Definition at line 386 of file DcuDetIds.cc.

References cuy::ii, and findQualityFiles::jj.

386  {
387  output.clear();
388  DcuDetIdsV::const_iterator ii = input.begin();
389  DcuDetIdsV::const_iterator jj = input.end();
390  for ( ; ii != jj; ++ii ) { if ( ii->second ) { output.push_back( std::make_pair( ii->first, new TkDcuInfo( *(ii->second) ) ) ); } }
391 }
static std::string const input
Definition: EdmProvDump.cc:48
ii
Definition: cuy.py:590
void SiStripConfigDb::closeDbConnection ( )
protected

Closes connection to DeviceFactory API.

Definition at line 140 of file SiStripConfigDb.cc.

References clearLocalCache(), dbCache_, factory_, handleException(), LogTrace, sistrip::mlConfigDb_, and openConnection_.

Referenced by ~SiStripConfigDb().

140  {
141 
143  << "[SiStripConfigDb::" << __func__ << "]"
144  << " Closing connection to database...";
145 
146  // Check if connection exists
147  if ( !openConnection_ ) {
149  << "[SiStripConfigDb::" << __func__ << "]"
150  << " No connection open!";
151  return;
152  }
153  openConnection_ = false;
154 
155  // Clear local caches
156  clearLocalCache();
157 
158  try {
159  if ( factory_ ) { delete factory_; }
160  } catch (...) { handleException( __func__, "Attempting to delete DeviceFactory object..." ); }
161  factory_ = nullptr;
162 
163  try {
164  if ( dbCache_ ) { delete dbCache_; }
165  } catch (...) { handleException( __func__, "Attempting to delete DbClient object..." ); }
166  dbCache_ = nullptr;
167 
169  << "[SiStripConfigDb::" << __func__ << "]"
170  << " Closed connection to database...";
171 
172 }
DeviceFactory * factory_
void handleException(const std::string &method_name, const std::string &extra_info="") const
static const char mlConfigDb_[]
#define LogTrace(id)
DbClient * dbCache_
DbClient *const SiStripConfigDb::databaseCache ( std::string  method_name = "") const
protected

Returns pointer to DeviceFactory API, with check if NULL.

Definition at line 211 of file SiStripConfigDb.cc.

References dbCache_, and sistrip::mlConfigDb_.

Referenced by SiStripCondObjBuilderFromDb::buildCondObj(), SiStripFedCablingBuilderFromDb::make(), and usingDatabaseCache().

211  {
212  if ( dbCache_ ) { return dbCache_; }
213  else {
214  if ( method_name != "" ) {
215  stringstream ss;
216  ss << "[SiStripConfigDb::" << __func__ << "]"
217  << " NULL pointer to DbClient requested by"
218  << " method SiStripConfigDb::" << method_name << "()!";
219  edm::LogWarning(mlConfigDb_) << ss.str();
220  }
221  return nullptr;
222  }
223 }
static const char mlConfigDb_[]
DbClient * dbCache_
const SiStripDbParams & SiStripConfigDb::dbParams ( ) const
inlineprotected
SiStripConfigDb::DeviceAddress SiStripConfigDb::deviceAddress ( const deviceDescription &  description)
protected

Extracts unique hardware address of device from description.

Definition at line 513 of file DeviceDescriptions.cc.

References SiStripConfigDb::DeviceAddress::ccuAddr_, SiStripConfigDb::DeviceAddress::ccuChan_, heppy_report::description, sistrip::FEC_CRATE_OFFSET, sistrip::FEC_RING_OFFSET, SiStripConfigDb::DeviceAddress::fecCrate_, SiStripConfigDb::DeviceAddress::fecRing_, SiStripConfigDb::DeviceAddress::fecSlot_, SiStripConfigDb::DeviceAddress::i2cAddr_, SiStripFecKey::lldChan(), and SiStripConfigDb::DeviceAddress::lldChan_.

Referenced by FastFedCablingHistosUsingDb::addDcuDetIds(), CommissioningHistosUsingDb::buildDetInfo(), SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices(), CalibrationHistosUsingDb::CalibrationHistosUsingDb(), FastFedCablingHistosUsingDb::connections(), OptoScanHistosUsingDb::update(), ApvTimingHistosUsingDb::update(), VpspScanHistosUsingDb::update(), LatencyHistosUsingDb::update(), CalibrationHistosUsingDb::update(), and FineDelayHistosUsingDb::update().

513  {
514 
515  deviceDescription& desc = const_cast<deviceDescription&>(description);
516 
517  DeviceAddress addr;
518  try {
519  addr.fecCrate_ = static_cast<uint16_t>( desc.getCrateId() + sistrip::FEC_CRATE_OFFSET ); //@@ temporary offset?
520  addr.fecSlot_ = static_cast<uint16_t>( desc.getFecSlot() );
521  addr.fecRing_ = static_cast<uint16_t>( desc.getRingSlot() + sistrip::FEC_RING_OFFSET ); //@@ temporary offset?
522  addr.ccuAddr_ = static_cast<uint16_t>( desc.getCcuAddress() );
523  addr.ccuChan_ = static_cast<uint16_t>( desc.getChannel() );
524  addr.lldChan_ = static_cast<uint16_t>( SiStripFecKey::lldChan( desc.getAddress() ) );
525  addr.i2cAddr_ = static_cast<uint16_t>( desc.getAddress() );
526  } catch (...) { handleException( __func__ ); }
527 
528  return addr;
529 }
void handleException(const std::string &method_name, const std::string &extra_info="") const
static const uint16_t FEC_RING_OFFSET
const uint16_t & lldChan() const
static const uint16_t FEC_CRATE_OFFSET
SiStripConfigDb::DeviceAddress SiStripConfigDb::deviceAddress ( const AnalysisDescription desc)
protected

Extracts unique hardware address of device from description.

Definition at line 510 of file AnalysisDescriptions.cc.

References SiStripConfigDb::DeviceAddress::ccuAddr_, SiStripConfigDb::DeviceAddress::ccuChan_, sistrip::FEC_CRATE_OFFSET, sistrip::FEC_RING_OFFSET, SiStripConfigDb::DeviceAddress::fecCrate_, SiStripConfigDb::DeviceAddress::feChan_, SiStripConfigDb::DeviceAddress::fecRing_, SiStripConfigDb::DeviceAddress::fecSlot_, SiStripConfigDb::DeviceAddress::fedId_, SiStripConfigDb::DeviceAddress::feUnit_, SiStripConfigDb::DeviceAddress::i2cAddr_, SiStripFecKey::lldChan(), and SiStripConfigDb::DeviceAddress::lldChan_.

510  {
511 
512  DeviceAddress addr;
513  try {
514  addr.fecCrate_ = static_cast<uint16_t>( desc.getCrate() + sistrip::FEC_CRATE_OFFSET );
515  addr.fecSlot_ = static_cast<uint16_t>( desc.getSlot() );
516  addr.fecRing_ = static_cast<uint16_t>( desc.getRing() + sistrip::FEC_RING_OFFSET );
517  addr.ccuAddr_ = static_cast<uint16_t>( desc.getCcuAdr() );
518  addr.ccuChan_ = static_cast<uint16_t>( desc.getCcuChan() );
519  addr.lldChan_ = static_cast<uint16_t>( SiStripFecKey::lldChan( desc.getI2cAddr() ) );
520  addr.i2cAddr_ = static_cast<uint16_t>( desc.getI2cAddr() );
521  addr.fedId_ = static_cast<uint16_t>( desc.getFedId() ); //@@ offset required? crate/slot needed?
522  addr.feUnit_ = static_cast<uint16_t>( desc.getFeUnit() );
523  addr.feChan_ = static_cast<uint16_t>( desc.getFeChan() );
524  } catch (...) { handleException( __func__ ); }
525 
526  return addr;
527 }
void handleException(const std::string &method_name, const std::string &extra_info="") const
static const uint16_t FEC_RING_OFFSET
const uint16_t & lldChan() const
static const uint16_t FEC_CRATE_OFFSET
DeviceFactory *const SiStripConfigDb::deviceFactory ( std::string  method_name = "") const
protected

Returns pointer to DeviceFactory API, with check if NULL.

Definition at line 195 of file SiStripConfigDb.cc.

References factory_, and sistrip::mlConfigDb_.

Referenced by SiStripCondObjBuilderFromDb::buildCondObj(), SiStripFedCablingBuilderFromDb::make(), partitions(), runs(), SiStripPartition::update(), CommissioningHistosUsingDb::uploadAnalyses(), usingDatabase(), and usingXmlFiles().

195  {
196  if ( factory_ ) { return factory_; }
197  else {
198  if ( method_name != "" ) {
199  stringstream ss;
200  ss << "[SiStripConfigDb::" << __func__ << "]"
201  << " NULL pointer to DeviceFactory requested by"
202  << " method SiStripConfigDb::" << method_name << "()!";
203  edm::LogWarning(mlConfigDb_) << ss.str();
204  }
205  return nullptr;
206  }
207 }
DeviceFactory * factory_
static const char mlConfigDb_[]
string SiStripConfigDb::deviceType ( const enumDeviceType &  device_type) const
private

Returns device identifier based on device type.

Definition at line 533 of file DeviceDescriptions.cc.

533  {
534  if ( device_type == PLL ) { return "PLL"; }
535  else if ( device_type == LASERDRIVER ) { return "LLD"; }
536  else if ( device_type == DOH ) { return "DOH"; }
537  else if ( device_type == APVMUX ) { return "MUX"; }
538  else if ( device_type == APV25 ) { return "APV"; }
539  else if ( device_type == DCU ) { return "DCU"; }
540  else if ( device_type == GOH ) { return "GOH"; }
541  else { return "UNKNOWN DEVICE!"; }
542 }
SiStripConfigDb::DcuDetIdsV::const_iterator SiStripConfigDb::findDcuDetId ( DcuDetIdsV::const_iterator  begin,
DcuDetIdsV::const_iterator  end,
uint32_t  dcu_id 
)
staticprotected

Utility method.

Definition at line 395 of file DcuDetIds.cc.

References begin, and end.

Referenced by FastFedCablingHistosUsingDb::addDcuDetIds(), SiStripFedCablingBuilderFromDb::assignDcuAndDetIds(), CommissioningHistosUsingDb::buildDetInfo(), and FastFedCablingHistosUsingDb::connections().

397  {
398  DcuDetIdsV::const_iterator iter = begin;
399  DcuDetIdsV::const_iterator jter = end;
400  for ( ; iter != jter; ++iter ) {
401  if ( iter->second && iter->second->getDcuHardId() == dcu_id ) { return iter; }
402  }
403  return end;
404 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
SiStripConfigDb::DcuDetIdsV::iterator SiStripConfigDb::findDcuDetId ( DcuDetIdsV::iterator  begin,
DcuDetIdsV::iterator  end,
uint32_t  dcu_id 
)
staticprotected

Utility method.

Definition at line 408 of file DcuDetIds.cc.

References begin, and end.

410  {
411  DcuDetIdsV::iterator iter = begin;
412  DcuDetIdsV::iterator jter = end;
413  for ( ; iter != jter; ++iter ) {
414  if ( iter->second && iter->second->getDcuHardId() == dcu_id ) { return iter; }
415  }
416  return end;
417 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
SiStripConfigDb::AnalysisDescriptionsRange SiStripConfigDb::getAnalysisDescriptions ( AnalysisType  analysis_type,
std::string  partition = "" 
)
protected

Returns local cache (just for given partition if specified).

T_UNKNOWN, T_ANALYSIS_FASTFEDCABLING, T_ANALYSIS_TIMING, T_ANALYSIS_OPTOSCAN, T_ANALYSIS_VPSPSCAN, T_ANALYSIS_PEDESTAL, T_ANALYSIS_APVLATENCY, T_ANALYSIS_FINEDELAY, T_ANALYSIS_CALIBRATION.

Definition at line 20 of file AnalysisDescriptions.cc.

References begin, SiStripPartition::defaultPartitionName_, end, LogTrace, sistrip::mlConfigDb_, and np.

Referenced by SiStripCondObjBuilderFromDb::retrieveTimingAnalysisDescriptions(), and SiStripCondObjBuilderFromDb::setValuesApvTiming().

21  {
22 
23  // Check
24  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
25  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
26  return analyses_.emptyRange();
27  }
28 
29  try {
30 
31  if ( !dbParams_.usingDbCache() ) {
32 
33  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
34  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
35  for ( ; iter != jter; ++iter ) {
36 
37  if ( partition.empty() || partition == iter->second.partitionName() ) {
38 
39  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
40 
41  AnalysisDescriptionsRange range = analyses_.find( iter->second.partitionName() );
42  if ( range == analyses_.emptyRange() ) {
43 
45  if ( analysis_type == AnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
46  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
47  iter->second.fastCablingVersion().first,
48  iter->second.fastCablingVersion().second,
49  analysis_type );
50  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_TIMING ) {
51  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
52  iter->second.apvTimingVersion().first,
53  iter->second.apvTimingVersion().second,
54  analysis_type );
55  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
56  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
57  iter->second.optoScanVersion().first,
58  iter->second.optoScanVersion().second,
59  analysis_type );
60  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
61  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
62  iter->second.vpspScanVersion().first,
63  iter->second.vpspScanVersion().second,
64  analysis_type );
65  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_CALIBRATION ) {
66  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
67  iter->second.apvCalibVersion().first,
68  iter->second.apvCalibVersion().second,
69  analysis_type );
70  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDESTALS ) {
71  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
72  iter->second.pedestalsVersion().first,
73  iter->second.pedestalsVersion().second,
74  analysis_type );
75  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
76  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
77  iter->second.pedestalsVersion().first,
78  iter->second.pedestalsVersion().second,
79  analysis_type );
80  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_APVLATENCY ) {
81  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
82  iter->second.apvLatencyVersion().first,
83  iter->second.apvLatencyVersion().second,
84  analysis_type );
85  } else if ( analysis_type == AnalysisDescription::T_ANALYSIS_FINEDELAY ) {
86  tmp1 = deviceFactory(__func__)->getAnalysisHistory( iter->second.partitionName(),
87  iter->second.fineDelayVersion().first,
88  iter->second.fineDelayVersion().second,
89  analysis_type );
90  } else {
91  std::stringstream ss;
92  ss << "[SiStripConfigDb::" << __func__ << "]"
93  << " Unexpected analysis type \""
94  << analysisType( analysis_type )
95  << "\"! Aborting download...";
96  edm::LogWarning(mlConfigDb_) << ss.str();
97  return analyses_.emptyRange();
98  }
99 
100  // Make local copy
102  CommissioningAnalysisFactory::vectorCopy( tmp1, tmp2 );
103 
104  // Add to cache
105  analyses_.loadNext( iter->second.partitionName(), tmp2 );
106 
107  // Some debug
108  AnalysisDescriptionsRange anals = analyses_.find( iter->second.partitionName() );
109  std::stringstream ss;
110  ss << "[SiStripConfigDb::" << __func__ << "]"
111  << " Downloaded " << anals.size()
112  << " analysis descriptions of type \""
113  << analysisType( analysis_type )
114  << "\" to local cache for partition \""
115  << iter->second.partitionName() << "\"" << std::endl;
116  ss << "[SiStripConfigDb::" << __func__ << "]"
117  << " Cache holds analysis descriptions for "
118  << analyses_.size() << " partitions.";
119  LogTrace(mlConfigDb_) << ss.str();
120 
121  }
122  }
123  }
124 
125  } else { // Use database cache
126  std::stringstream ss;
127  ss << "[SiStripConfigDb::" << __func__ << "]"
128  << " No database cache for analysis objects!";
129  edm::LogWarning(mlConfigDb_) << ss.str();
130  }
131 
132  } catch (...) { handleException( __func__ ); }
133 
134  // Create range object
135  uint16_t np = 0;
136  uint16_t nc = 0;
138  if ( !partition.empty() ) {
139  anals = analyses_.find( partition );
140  np = 1;
141  nc = anals.size();
142  } else {
143  if ( !analyses_.empty() ) {
144  anals = AnalysisDescriptionsRange( analyses_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
145  analyses_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
146  } else { anals = analyses_.emptyRange(); }
147  np = analyses_.size();
148  nc = anals.size();
149  }
150 
151  stringstream ss;
152  ss << "[SiStripConfigDb::" << __func__ << "]"
153  << " Found " << nc << " analysis descriptions";
154  if ( !dbParams_.usingDbCache() ) { ss << " in " << np << " database partition(s)"; }
155  else { ss << " from shared memory name '" << dbParams_.sharedMemory() << "'"; }
156  if ( analyses_.empty() ) { edm::LogWarning(mlConfigDb_) << ss.str(); }
157  else { LogTrace(mlConfigDb_) << ss.str(); }
158 
159  return anals;
160 
161 }
static const std::string defaultPartitionName_
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
AnalysisDescriptions analyses_
static const char mlConfigDb_[]
const_iterator_range partitions() const
int np
Definition: AMPTWrapper.h:33
std::string sharedMemory() const
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
AnalysisDescriptions::range AnalysisDescriptionsRange
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
std::string analysisType(AnalysisType) const
bool usingDbCache() const
std::vector< AnalysisDescription * > AnalysisDescriptionsV
SiStripConfigDb::DcuDetIdsRange SiStripConfigDb::getDcuDetIds ( std::string  partition = "")
protected

Returns local cache (just for given partition if specified).

Definition at line 10 of file DcuDetIds.cc.

References begin, clone(), SiStripPartition::defaultPartitionName_, end, LogTrace, sistrip::mlConfigDb_, np, and TrackRefitter_38T_cff::src.

Referenced by FastFedCablingHistosUsingDb::addDcuDetIds(), CommissioningHistosUsingDb::buildDetInfo(), SiStripFedCablingBuilderFromDb::buildFecCabling(), SiStripFedCablingBuilderFromDb::buildFecCablingFromDetIds(), SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices(), SiStripFedCablingBuilderFromDb::buildFecCablingFromFedConnections(), and FastFedCablingHistosUsingDb::uploadConfigurations().

10  {
11 
12  // Check
13  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
14  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
15  return dcuDetIds_.emptyRange();
16  }
17 
18  try {
19 
20  if ( !dbParams_.usingDbCache() ) {
21 
22  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
23  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
24  for ( ; iter != jter; ++iter ) {
25 
26  if ( partition == "" || partition == iter->second.partitionName() ) {
27 
28  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
29 
30  DcuDetIdsRange range = dcuDetIds_.find( iter->second.partitionName() );
31  if ( range == dcuDetIds_.emptyRange() ) {
32 
33  deviceFactory(__func__)->addDetIdPartition( iter->second.partitionName(),
34  iter->second.dcuVersion().first,
35  iter->second.dcuVersion().second );
36 
37  // Retrieve DCU-DetId map
38  DcuDetIdMap src = deviceFactory(__func__)->getInfos();
39 
40  // Make local copy
41  DcuDetIdsV dst;
42  clone( src, dst );
43 
44  // Add to cache
45  dcuDetIds_.loadNext( iter->second.partitionName(), dst );
46 
47  }
48 
49  }
50 
51  }
52 
53  } else { // Using database cache
54 
55  // Retrieve DCU-DetId map
56  DcuDetIdMap* src = databaseCache(__func__)->getInfos();
57 
58  if ( src ) {
59 
60  // Make local copy
61  DcuDetIdsV dst;
62  clone( *src, dst );
63 
64  // Add to cache
66 
67  } else {
69  << "[SiStripConfigDb::" << __func__ << "]"
70  << " NULL pointer to Dcu-DetId map!";
71  }
72 
73  }
74 
75  } catch (... ) { handleException( __func__ ); }
76 
77  // Create range object
78  uint16_t np = 0;
79  uint16_t nc = 0;
80  DcuDetIdsRange range;
81  if ( partition != "" ) {
82  range = dcuDetIds_.find( partition );
83  np = 1;
84  nc = range.size();
85  } else {
86  if ( !dcuDetIds_.empty() ) {
87  range = DcuDetIdsRange( dcuDetIds_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
88  dcuDetIds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
89  } else { range = dcuDetIds_.emptyRange(); }
90  np = dcuDetIds_.size();
91  nc = range.size();
92  }
93 
94  stringstream ss;
95  ss << "[SiStripConfigDb::" << __func__ << "]"
96  << " Found " << nc << " entries in DCU-DetId map";
97  if ( !dbParams_.usingDb() ) { ss << " in " << dbParams_.inputDcuInfoXmlFiles().size() << " 'module.xml' file(s)"; }
98  else { if ( !dbParams_.usingDbCache() ) { ss << " in " << np << " database partition(s)"; }
99  else { ss << " from shared memory name '" << dbParams_.sharedMemory() << "'"; } }
100  if ( dcuDetIds_.empty() ) { edm::LogWarning(mlConfigDb_) << ss.str(); }
101  else { LogTrace(mlConfigDb_) << ss.str(); }
102 
103  return range;
104 }
void clone(const DcuDetIdMap &in, DcuDetIdsV &out) const
Definition: DcuDetIds.cc:368
static const std::string defaultPartitionName_
DcuDetIds::range DcuDetIdsRange
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
std::vector< std::string > inputDcuInfoXmlFiles() const
bool usingDb() const
static const char mlConfigDb_[]
const_iterator_range partitions() const
int np
Definition: AMPTWrapper.h:33
std::string sharedMemory() const
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
std::vector< DcuDetId > DcuDetIdsV
range emptyRange() const
Definition: MapOfVectors.h:82
Sgi::hash_map< unsigned long, TkDcuInfo * > DcuDetIdMap
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
bool usingDbCache() const
DcuDetIds dcuDetIds_
SiStripConfigDb::DeviceDescriptionsRange SiStripConfigDb::getDeviceDescriptions ( std::string  partition = "")
protected

Returns local cache (just for given partition if specified).

Definition at line 11 of file DeviceDescriptions.cc.

References begin, SiStripPartition::defaultPartitionName_, end, funct::false, LogTrace, sistrip::mlConfigDb_, and np.

Referenced by FastFedCablingHistosUsingDb::addDcuDetIds(), CommissioningHistosUsingDb::buildDetInfo(), SiStripFedCablingBuilderFromDb::buildFecCabling(), SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices(), SiStripCondObjBuilderFromDb::buildFECRelatedObjects(), CalibrationHistosUsingDb::CalibrationHistosUsingDb(), FastFedCablingHistosUsingDb::connections(), getDeviceDescriptions(), VpspScanHistosUsingDb::uploadConfigurations(), ApvTimingHistosUsingDb::uploadConfigurations(), OptoScanHistosUsingDb::uploadConfigurations(), FastFedCablingHistosUsingDb::uploadConfigurations(), LatencyHistosUsingDb::uploadConfigurations(), CalibrationHistosUsingDb::uploadConfigurations(), and FineDelayHistosUsingDb::uploadConfigurations().

11  {
12 
13  // Check
14  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
15  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
16  return devices_.emptyRange();
17  }
18 
19  try {
20 
21  if ( !dbParams_.usingDbCache() ) {
22 
23  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
24  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
25  for ( ; iter != jter; ++iter ) {
26 
27  if ( partition == "" || partition == iter->second.partitionName() ) {
28 
29  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
30 
31  DeviceDescriptionsRange range = devices_.find( iter->second.partitionName() );
32  if ( range == devices_.emptyRange() ) {
33 
34  // Retrieve conections
36  deviceFactory(__func__)->getFecDeviceDescriptions( iter->second.partitionName(),
37  tmp1,
38  iter->second.fecVersion().first,
39  iter->second.fecVersion().second,
40  //#ifdef USING_DATABASE_MASKING
41  iter->second.maskVersion().first,
42  iter->second.maskVersion().second,
43  //#endif
44  false ); //@@ do not get DISABLED devices
45 
46  // Make local copy
48  FecFactory::vectorCopyI( tmp2, tmp1, true );
49 
50  // Add to cache
51  devices_.loadNext( iter->second.partitionName(), tmp2 );
52 
53  // Some debug
54  DeviceDescriptionsRange range = devices_.find( iter->second.partitionName() );
55  std::stringstream ss;
56  ss << "[SiStripConfigDb::" << __func__ << "]"
57  << " Downloaded " << range.size()
58  << " device descriptions to local cache for partition \""
59  << iter->second.partitionName() << "\"" << std::endl;
60  ss << "[SiStripConfigDb::" << __func__ << "]"
61  << " Cache holds device descriptions for "
62  << devices_.size() << " partitions.";
63  LogTrace(mlConfigDb_) << ss.str();
64 
65  }
66 
67  }
68 
69  }
70 
71  } else { // Using database cache
72 
73  DeviceDescriptionsV* tmp1 = databaseCache(__func__)->getDevices();
74 
75  if ( tmp1 ) {
76 
77  // Make local copy
79  FecFactory::vectorCopyI( tmp2, *tmp1, true );
80 
81  // Add to cache
83 
84  } else {
86  << "[SiStripConfigDb::" << __func__ << "]"
87  << " NULL pointer to DeviceDescriptions vector!";
88  }
89 
90  }
91 
92  } catch (...) { handleException( __func__ ); }
93 
94  // Create range object
95  uint16_t np = 0;
96  uint16_t nc = 0;
98  if ( partition != "" ) {
99  devs = devices_.find( partition );
100  np = 1;
101  nc = devs.size();
102  } else {
103  if ( !devices_.empty() ) {
104  devs = DeviceDescriptionsRange( devices_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
105  devices_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
106  } else { devs = devices_.emptyRange(); }
107  np = devices_.size();
108  nc = devs.size();
109  }
110 
111  stringstream ss;
112  ss << "[SiStripConfigDb::" << __func__ << "]"
113  << " Found " << nc << " device descriptions";
114  if ( !dbParams_.usingDb() ) { ss << " in " << dbParams_.inputFecXmlFiles().size() << " 'fec.xml' file(s)"; }
115  else { if ( !dbParams_.usingDbCache() ) { ss << " in " << np << " database partition(s)"; }
116  else { ss << " from shared memory name '" << dbParams_.sharedMemory() << "'"; } }
117  if ( devices_.empty() ) { edm::LogWarning(mlConfigDb_) << ss.str(); }
118  else { LogTrace(mlConfigDb_) << ss.str(); }
119 
120  return devs;
121 
122 }
static const std::string defaultPartitionName_
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool usingDb() const
static const char mlConfigDb_[]
const_iterator_range partitions() const
int np
Definition: AMPTWrapper.h:33
DeviceDescriptions::range DeviceDescriptionsRange
std::string sharedMemory() const
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
std::vector< std::string > inputFecXmlFiles() const
DeviceDescriptions devices_
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
bool usingDbCache() const
std::vector< DeviceDescription * > DeviceDescriptionsV
SiStripConfigDb::DeviceDescriptionsRange SiStripConfigDb::getDeviceDescriptions ( DeviceType  device_type,
std::string  partition = "" 
)
protected

Returns (pair of iterators to) descriptions of given type. (APV25, APVMUX, DCU, LASERDRIVER, PLL, DOH).

Definition at line 126 of file DeviceDescriptions.cc.

References getDeviceDescriptions(), LogTrace, sistrip::mlConfigDb_, and tmp.

127  {
128 
129  typedDevices_.clear();
130  apvDevices_.clear();
131  muxDevices_.clear();
132  dcuDevices_.clear();
133  lldDevices_.clear();
134  pllDevices_.clear();
135  dohDevices_.clear();
136 
138 
139  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
140  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
141  return tmp;
142  }
143 
144  try {
146  if ( !devs.empty() ) {
147  DeviceDescriptionsV tmp( devs.begin(), devs.end() );
148  typedDevices_ = FecFactory::getDeviceFromDeviceVector( tmp, device_type );
149  }
150  } catch (...) { handleException( __func__ ); }
151 
152  if ( device_type == APV25 ) {
153  apvDevices_.swap( typedDevices_ );
155  } else if ( device_type == APVMUX ) {
156  muxDevices_.swap( typedDevices_ );
158  } else if ( device_type == DCU ) {
159  dcuDevices_.swap( typedDevices_ );
161  } else if ( device_type == LASERDRIVER ) {
162  lldDevices_.swap( typedDevices_ );
164  } else if ( device_type == PLL ) {
165  pllDevices_.swap( typedDevices_ );
167  } else if ( device_type == DOH ) {
168  dohDevices_.swap( typedDevices_ );
170  } else {
172  }
173 
174 // stringstream sss;
175 // sss << " Number of devices:"
176 // << " TYP: " << typedDevices_.size()
177 // << " APV: " << apvDevices_.size()
178 // << " MUX: " << muxDevices_.size()
179 // << " DCU: " << dcuDevices_.size()
180 // << " LLD: " << lldDevices_.size()
181 // << " PLL: " << pllDevices_.size()
182 // << " DOH: " << dohDevices_.size()
183 // << " tmp: " << tmp.size();
184 // LogTrace(mlConfigDb_) << sss.str();
185 
186  stringstream ss;
187  ss << "[SiStripConfigDb::" << __func__ << "]"
188  << " Extracted " << tmp.size()
189  << " device descriptions (for devices of type "
190  << deviceType( device_type ) << ")";
191  LogTrace(mlConfigDb_) << ss.str();
192 
193  return tmp;
194 
195 }
DeviceDescriptionsV apvDevices_
DeviceDescriptionsV typedDevices_
DeviceDescriptionsV dohDevices_
DeviceDescriptionsV lldDevices_
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
DeviceDescriptionsV pllDevices_
static const char mlConfigDb_[]
DeviceDescriptionsV dcuDevices_
DeviceDescriptions::range DeviceDescriptionsRange
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
std::string deviceType(const enumDeviceType &device_type) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
DeviceDescriptionsV muxDevices_
SiStripDbParams dbParams_
bool usingDbCache() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
std::vector< DeviceDescription * > DeviceDescriptionsV
SiStripConfigDb::FedConnectionsRange SiStripConfigDb::getFedConnections ( std::string  partition = "")
protected

Returns local cache (just for given partition if specified).

Definition at line 11 of file FedConnections.cc.

References begin, SiStripPartition::defaultPartitionName_, end, funct::false, LogTrace, sistrip::mlConfigDb_, and np.

Referenced by SiStripFedCablingBuilderFromDb::buildFecCabling(), and SiStripFedCablingBuilderFromDb::buildFecCablingFromFedConnections().

11  {
12 
13  // Check
14  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
15  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
16  return connections_.emptyRange();
17  }
18 
19  try {
20 
21  if ( !dbParams_.usingDbCache() ) {
22 
23  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
24  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
25  for ( ; iter != jter; ++iter ) {
26 
27  if ( partition == "" || partition == iter->second.partitionName() ) {
28 
29  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
30 
31  FedConnectionsRange range = connections_.find( iter->second.partitionName() );
32  if ( range == connections_.emptyRange() ) {
33 
34  FedConnectionsV tmp2;
35 
36  // Retrieve connections
37  FedConnectionsV tmp1;
38  deviceFactory(__func__)->getConnectionDescriptions( iter->second.partitionName(),
39  tmp1,
40  iter->second.cabVersion().first,
41  iter->second.cabVersion().second,
42  //#ifdef USING_DATABASE_MASKING
43  iter->second.maskVersion().first,
44  iter->second.maskVersion().second,
45  //#endif
46  false ); //@@ do not get DISABLED connections
47 
48  // Make local copy
49  ConnectionFactory::vectorCopyI( tmp2, tmp1, true );
50 
51  // Add to cache
52  connections_.loadNext( iter->second.partitionName(), tmp2 );
53 
54  // Some debug
55  FedConnectionsRange conns = connections_.find( iter->second.partitionName() );
56  std::stringstream ss;
57  ss << "[SiStripConfigDb::" << __func__ << "]"
58  << " Downloaded " << conns.size()
59  << " FED connections to local cache for partition \""
60  << iter->second.partitionName() << "\"" << std::endl;
61  ss << "[SiStripConfigDb::" << __func__ << "]"
62  << " Cache holds FED connections for "
63  << connections_.size() << " partitions.";
64  LogTrace(mlConfigDb_) << ss.str();
65 
66  }
67 
68  }
69 
70  }
71 
72  } else { // Use database cache
73 
74  FedConnectionsV* tmp1 = databaseCache(__func__)->getConnections();
75 
76  if ( tmp1 ) {
77 
78  // Make local copy
79  FedConnectionsV tmp2;
80  ConnectionFactory::vectorCopyI( tmp2, *tmp1, true );
81 
82  // Add to cache
84 
85  } else {
87  << "[SiStripConfigDb::" << __func__ << "]"
88  << " NULL pointer to FedConnections vector!";
89  }
90 
91  }
92 
93  } catch (...) { handleException( __func__ ); }
94 
95  // Create range object
96  uint16_t np = 0;
97  uint16_t nc = 0;
98  FedConnectionsRange conns;
99  if ( partition != "" ) {
100  conns = connections_.find( partition );
101  np = 1;
102  nc = conns.size();
103  } else {
104  if ( !connections_.empty() ) {
105  conns = FedConnectionsRange( connections_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
106  connections_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
107  } else { conns = connections_.emptyRange(); }
108  np = connections_.size();
109  nc = conns.size();
110  }
111 
112  stringstream ss;
113  ss << "[SiStripConfigDb::" << __func__ << "]"
114  << " Found " << nc << " FED connections";
115  if ( !dbParams_.usingDb() ) { ss << " in " << dbParams_.inputModuleXmlFiles().size() << " 'module.xml' file(s)"; }
116  else { if ( !dbParams_.usingDbCache() ) { ss << " in " << np << " database partition(s)"; }
117  else { ss << " from shared memory name '" << dbParams_.sharedMemory() << "'"; } }
118  if ( connections_.empty() ) { edm::LogWarning(mlConfigDb_) << ss.str(); }
119  else { LogTrace(mlConfigDb_) << ss.str(); }
120 
121  return conns;
122 
123 }
static const std::string defaultPartitionName_
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool usingDb() const
FedConnections connections_
FedConnections::range FedConnectionsRange
static const char mlConfigDb_[]
const_iterator_range partitions() const
int np
Definition: AMPTWrapper.h:33
std::string sharedMemory() const
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
std::vector< std::string > inputModuleXmlFiles() const
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
bool usingDbCache() const
std::vector< FedConnection * > FedConnectionsV
SiStripConfigDb::FedDescriptionsRange SiStripConfigDb::getFedDescriptions ( std::string  partition = "")
protected

Returns local cache (just for given partition if specified).

Definition at line 12 of file FedDescriptions.cc.

References begin, SiStripPartition::defaultPartitionName_, end, LogTrace, sistrip::mlConfigDb_, and np.

Referenced by SiStripCondObjBuilderFromDb::buildFEDRelatedObjects(), SiStripCondObjBuilderFromDb::retrieveFedDescriptions(), DaqScopeModeHistosUsingDb::uploadConfigurations(), PedsFullNoiseHistosUsingDb::uploadConfigurations(), PedsOnlyHistosUsingDb::uploadConfigurations(), PedestalsHistosUsingDb::uploadConfigurations(), ApvTimingHistosUsingDb::uploadConfigurations(), NoiseHistosUsingDb::uploadConfigurations(), FastFedCablingHistosUsingDb::uploadConfigurations(), LatencyHistosUsingDb::uploadConfigurations(), and FineDelayHistosUsingDb::uploadConfigurations().

12  {
13 
14  // Check
15  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
16  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
17  return feds_.emptyRange();
18  }
19 
20  try {
21 
22  if ( !dbParams_.usingDbCache() ) {
23 
24  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
25  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
26  for ( ; iter != jter; ++iter ) {
27 
28  if ( partition == "" || partition == iter->second.partitionName() ) {
29 
30  if ( iter->second.partitionName() == SiStripPartition::defaultPartitionName_ ) { continue; }
31 
32  FedDescriptionsRange range = feds_.find( iter->second.partitionName() );
33  if ( range == feds_.emptyRange() ) {
34 
35  // Extract versions
36  deviceFactory(__func__)->setUsingStrips( usingStrips_ );
37  int16_t major = iter->second.fedVersion().first;
38  int16_t minor = iter->second.fedVersion().second;
39  if ( iter->second.fedVersion().first == 0 &&
40  iter->second.fedVersion().second == 0 ) {
41  major = -1; //@@ "current state" for fed factory!
42  minor = -1; //@@ "current state" for fed factory!
43  }
44 
45  // Retrive FED descriptions
46  FedDescriptionsV tmp1;
47  tmp1 = *( deviceFactory(__func__)->getFed9UDescriptions( iter->second.partitionName(),
48  major,
49  minor ) );
50 
51  // Make local copy
52  FedDescriptionsV tmp2;
53  Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, tmp1 );
54 
55  // Add to cache
56  feds_.loadNext( iter->second.partitionName(), tmp2 );
57 
58  // Some debug
59  FedDescriptionsRange feds = feds_.find( iter->second.partitionName() );
60  std::stringstream ss;
61  ss << "[SiStripConfigDb::" << __func__ << "]"
62  << " Downloaded " << feds.size()
63  << " FED descriptions to local cache for partition \""
64  << iter->second.partitionName() << "\"" << std::endl;
65  ss << "[SiStripConfigDb::" << __func__ << "]"
66  << " Cache holds FED descriptions for "
67  << feds_.size() << " partitions.";
68  LogTrace(mlConfigDb_) << ss.str();
69 
70  }
71 
72  }
73 
74  }
75 
76  } else { // Using database cache
77 
78  FedDescriptionsV* tmp1 = databaseCache(__func__)->getFed9UDescriptions();
79 
80  if ( tmp1 ) {
81 
82  // Make local copy
83  FedDescriptionsV tmp2;
84  Fed9U::Fed9UDeviceFactory::vectorCopy( tmp2, *tmp1 );
85 
86  // Add to cache
88 
89  } else {
91  << "[SiStripConfigDb::" << __func__ << "]"
92  << " NULL pointer to FED descriptions vector!";
93  }
94 
95  }
96 
97  } catch (... ) { handleException( __func__ ); }
98 
99  // Create range object
100  uint16_t np = 0;
101  uint16_t nc = 0;
103  if ( partition != "" ) {
104  feds = feds_.find( partition );
105  np = 1;
106  nc = feds.size();
107  } else {
108  if ( !feds_.empty() ) {
109  feds = FedDescriptionsRange( feds_.find( dbParams_.partitions().begin()->second.partitionName() ).begin(),
110  feds_.find( (--(dbParams_.partitions().end()))->second.partitionName() ).end() );
111  } else { feds = feds_.emptyRange(); }
112  np = feds_.size();
113  nc = feds.size();
114  }
115 
116  stringstream ss;
117  ss << "[SiStripConfigDb::" << __func__ << "]"
118  << " Found " << nc << " FED descriptions";
119  if ( !dbParams_.usingDb() ) { ss << " in " << dbParams_.inputFedXmlFiles().size() << " 'fed.xml' file(s)"; }
120  else { if ( !dbParams_.usingDbCache() ) { ss << " in " << np << " database partition(s)"; }
121  else { ss << " from shared memory name '" << dbParams_.sharedMemory() << "'"; } }
122  if ( feds_.empty() ) { edm::LogWarning(mlConfigDb_) << ss.str(); }
123  else { LogTrace(mlConfigDb_) << ss.str(); }
124 
125  return feds;
126 
127 }
static const std::string defaultPartitionName_
std::vector< std::string > inputFedXmlFiles() const
void loadNext(K const &k, std::vector< T > const &v)
Definition: MapOfVectors.h:99
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
FedDescriptions::range FedDescriptionsRange
bool usingDb() const
static const char mlConfigDb_[]
const_iterator_range partitions() const
int np
Definition: AMPTWrapper.h:33
FedDescriptions feds_
std::string sharedMemory() const
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
#define begin
Definition: vmac.h:32
bool usingDbCache() const
std::vector< FedDescription * > FedDescriptionsV
SiStripConfigDb::FedIdsRange SiStripConfigDb::getFedIds ( std::string  partition = "")
protected

Extracts FED ids from FED descriptions.

Definition at line 430 of file FedDescriptions.cc.

References sistrip::mlCabling_, and sistrip::mlConfigDb_.

Referenced by SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices().

430  {
431 
432  fedIds_.clear();
433 
434  if ( ( !dbParams_.usingDbCache() && !deviceFactory(__func__) ) ||
435  ( dbParams_.usingDbCache() && !databaseCache(__func__) ) ) {
436  return FedIdsRange( fedIds_.end(), fedIds_.end() );
437  }
438 
439  try {
440 
441  // Inhibit download of strip info
442  bool using_strips = usingStrips_;
443  if ( factory_ ) { factory_->setUsingStrips( false ); }
444  FedDescriptionsRange feds = getFedDescriptions( partition );
445  if ( factory_ ) { factory_->setUsingStrips( using_strips ); }
446 
447  if ( !feds.empty() ) {
448  FedDescriptionsV::const_iterator ifed = feds.begin();
449  FedDescriptionsV::const_iterator jfed = feds.end();
450  for ( ; ifed != jfed; ++ifed ) {
451  if ( *ifed ) { fedIds_.push_back( (*ifed)->getFedId() ); }
452  else {
454  << "[SiStripConfigDb::" << __func__ << "]"
455  << " NULL pointer to FedDescription!";
456  continue;
457  }
458  }
459  }
460 
461  } catch (...) { handleException( __func__ ); }
462 
463  if ( fedIds_.empty() ) {
465  << "[SiStripConfigDb::" << __func__ << "]"
466  << " No FED ids found!";
467  }
468 
469  return FedIdsRange( fedIds_.begin(), fedIds_.end() );
470 
471 }
DeviceFactory * factory_
DeviceFactory *const deviceFactory(std::string method_name="") const
FedDescriptionsRange getFedDescriptions(std::string partition="")
void handleException(const std::string &method_name, const std::string &extra_info="") const
FedDescriptions::range FedDescriptionsRange
static const char mlConfigDb_[]
static const char mlCabling_[]
DbClient *const databaseCache(std::string method_name="") const
boost::iterator_range< FedIds::const_iterator > FedIdsRange
SiStripDbParams dbParams_
bool usingDbCache() const
void SiStripConfigDb::handleException ( const std::string &  method_name,
const std::string &  extra_info = "" 
) const
private

Handles exceptions thrown by software.

Definition at line 740 of file SiStripConfigDb.cc.

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, sistrip::mlConfigDb_, and cms::Exception::what().

Referenced by closeDbConnection(), SiStripPartition::update(), usingDatabase(), usingDatabaseCache(), and usingXmlFiles().

741  {
742 
743  std::stringstream ss;
744  try {
745  throw; // rethrow caught exception to be dealt with below
746  }
747 
748  catch ( const cms::Exception& e ) {
749  ss << " Caught cms::Exception in method "
750  << method_name << " with message: " << std::endl
751  << e.what();
752  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
753  //throw e; // rethrow cms::Exception
754  }
755 
756  catch ( const oracle::occi::SQLException& e ) {
757  ss << " Caught oracle::occi::SQLException in method "
758  << method_name << " with message: " << std::endl
759  << e.getMessage();
760  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
761  //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
762  }
763 
764  catch ( const FecExceptionHandler& e ) {
765  ss << " Caught FecExceptionHandler exception in method "
766  << method_name << " with message: " << std::endl
767  << const_cast<FecExceptionHandler&>(e).what();
768  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
769  //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
770  }
771 
772 // catch ( const Fed9UDeviceFactoryException& e ) {
773 // ss << " Caught Fed9UDeviceFactoryException exception in method "
774 // << method_name << " with message: " << std::endl
775 // << e.what();
776 // if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
777 // //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
778 // }
779 
780  catch ( const ICUtils::ICException& e ) {
781  ss << " Caught ICUtils::ICException in method "
782  << method_name << " with message: " << std::endl
783  << e.what();
784  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
785  //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
786  }
787 
788  catch ( const exception& e ) {
789  ss << " Caught std::exception in method "
790  << method_name << " with message: " << std::endl
791  << e.what();
792  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
793  //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
794  }
795 
796  catch (...) {
797  ss << " Caught unknown exception in method "
798  << method_name << " (No message) " << std::endl;
799  if ( extra_info != "" ) { ss << "Additional info: " << extra_info << std::endl; }
800  //throw cms::Exception(mlConfigDb_) << ss.str() << std::endl;
801  }
802 
803  // Message
804  edm::LogError(mlConfigDb_) << ss.str();
805 
806 }
char const * what() const override
Definition: Exception.cc:103
static const char mlConfigDb_[]
void SiStripConfigDb::openDbConnection ( )
protected

Establishes connection to DeviceFactory API.

Definition at line 102 of file SiStripConfigDb.cc.

References clearLocalCache(), dbParams_, LogTrace, sistrip::mlConfigDb_, openConnection_, usingDatabase(), usingDatabaseCache(), SiStripDbParams::usingDb(), SiStripDbParams::usingDbCache(), and usingXmlFiles().

Referenced by SiStripConfigDb().

102  {
103 
105  << "[SiStripConfigDb::" << __func__ << "]"
106  << " Opening connection to database...";
107 
108  // Check if connection already exists
109  if ( openConnection_ ) {
111  << "[SiStripConfigDb::" << __func__ << "]"
112  << " Connection already open!";
113  return;
114  }
115  openConnection_ = true;
116 
117  // Establish database connection
118  if ( dbParams_.usingDb() ) {
120  else { usingDatabase(); }
121  } else { usingXmlFiles(); }
122 
123  std::stringstream ss;
124  ss << "[SiStripConfigDb::" << __func__ << "]"
125  << " Database connection parameters: "
126  << std::endl << dbParams_;
127  edm::LogVerbatim(mlConfigDb_) << ss.str();
128 
129  // Clear local caches
130  clearLocalCache();
131 
133  << "[SiStripConfigDb::" << __func__ << "]"
134  << " Opened connection to database!";
135 
136 }
bool usingDb() const
static const char mlConfigDb_[]
#define LogTrace(id)
SiStripDbParams dbParams_
bool usingDbCache() const
void SiStripConfigDb::partitions ( std::list< std::string > &  partitions) const
protected

Retrieves all partitions names from database.

Definition at line 1012 of file SiStripConfigDb.cc.

References deviceFactory(), and sistrip::mlConfigDb_.

Referenced by usingDatabase().

1012  {
1013 
1014  partitions.clear();
1015 
1016  // Check DF pointer
1017  DeviceFactory* const df = deviceFactory(__func__);
1018  if ( !df ) {
1020  << "[SiStripPartition::" << __func__ << "]"
1021  << " NULL pointer to DeviceFactory object!";
1022  return;
1023  }
1024 
1025  partitions = df->getAllPartitionNames();
1026 
1027 }
void partitions(std::list< std::string > &) const
DeviceFactory *const deviceFactory(std::string method_name="") const
static const char mlConfigDb_[]
void SiStripConfigDb::printAnalysisDescriptions ( std::string  partition = "")
protected

Prints local cache (just for given partition if specified).

Definition at line 411 of file AnalysisDescriptions.cc.

References begin, SiStripConfigDb::DeviceAddress::ccuAddr_, SiStripConfigDb::DeviceAddress::ccuChan_, data, end, SiStripFecKey::fecCrate(), SiStripConfigDb::DeviceAddress::fecCrate_, SiStripFecKey::fecRing(), SiStripConfigDb::DeviceAddress::fecRing_, SiStripFecKey::fecSlot(), SiStripConfigDb::DeviceAddress::fecSlot_, spr::find(), SiStripConfigDb::DeviceAddress::i2cAddr_, cuy::ii, findQualityFiles::jj, crabWrapper::key, SiStripKey::key(), SiStripConfigDb::DeviceAddress::lldChan_, LogTrace, sistrip::mlConfigDb_, jetUpdater_cfi::sort, groupFilesInBlocks::temp, and tmp.

411  {
412 
413  std::stringstream ss;
414  ss << "[SiStripConfigDb::" << __func__ << "]"
415  << " Contents of AnalysisDescriptions container:" << std::endl;
416  ss << " Number of partitions: " << analyses_.size() << std::endl;
417 
418  // Loop through partitions
419  uint16_t cntr = 0;
422  for ( ; ianal != janal; ++ianal ) {
423 
424  cntr++;
425  if ( partition.empty() || partition == ianal->first ) {
426 
427  ss << " Partition number : " << cntr << " (out of " << analyses_.size() << ")" << std::endl;
428  ss << " Partition name : \"" << ianal->first << "\"" << std::endl;
429  ss << " Num of analyses : " << ianal->second.size() << std::endl;
430 
431  // Extract FEC crate, slot, etc
432  std::map< uint32_t, vector<uint32_t> > analyses;
433  AnalysisDescriptionsV::const_iterator iter = ianal->second.begin();
434  AnalysisDescriptionsV::const_iterator jter = ianal->second.end();
435  for ( ; iter != jter; ++iter ) {
436  if ( *iter ) {
437  DeviceAddress addr = deviceAddress( **iter );
438  uint32_t key = SiStripFecKey( addr.fecCrate_,
439  addr.fecSlot_,
440  addr.fecRing_,
441  0,
442  0,
443  0,
444  0 ).key();
445  uint32_t data = SiStripFecKey( addr.fecCrate_,
446  addr.fecSlot_,
447  addr.fecRing_,
448  addr.ccuAddr_,
449  addr.ccuChan_,
450  addr.lldChan_,
451  addr.i2cAddr_ ).key();
452  if ( find( analyses[key].begin(), analyses[key].end(), data ) == analyses[key].end() ) {
453  analyses[key].push_back( data );
454  }
455  }
456  }
457 
458  // Sort contents
459  std::map< uint32_t, std::vector<uint32_t> > tmp;
460  std::map< uint32_t, std::vector<uint32_t> >::const_iterator ii = analyses.begin();
461  std::map< uint32_t, std::vector<uint32_t> >::const_iterator jj = analyses.end();
462  for ( ; ii != jj; ++ii ) {
463  std::vector<uint32_t> temp = ii->second;
464  std::sort( temp.begin(), temp.end() );
465  std::vector<uint32_t>::const_iterator iii = temp.begin();
466  std::vector<uint32_t>::const_iterator jjj = temp.end();
467  for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
468  }
469  analyses.clear();
470  analyses = tmp;
471 
472  // Print FEC crate, slot, etc...
473  std::map< uint32_t, std::vector<uint32_t> >::const_iterator ianal = analyses.begin();
474  std::map< uint32_t, std::vector<uint32_t> >::const_iterator janal = analyses.end();
475  for ( ; ianal != janal; ++ianal ) {
476  SiStripFecKey key(ianal->first);
477  ss << " Found " << std::setw(3) << ianal->second.size()
478  << " analyses for FEC crate/slot/ring "
479  << key.fecCrate() << "/"
480  << key.fecSlot() << "/"
481  << key.fecRing();
482  //<< " (ccu/module/lld/i2c): ";
483  // if ( !ianal->second.empty() ) {
484  // uint16_t first = ianal->second.front();
485  // uint16_t last = ianal->second.front();
486  // std::vector<uint32_t>::const_iterator chan = ianal->second.begin();
487  // for ( ; chan != ianal->second.end(); chan++ ) {
488  // if ( chan != ianal->second.begin() ) {
489  // if ( *chan != last+1 ) {
490  // ss << std::setw(2) << first << "->" << std::setw(2) << last << ", ";
491  // if ( chan != ianal->second.end() ) { first = *(chan+1); }
492  // }
493  // }
494  // last = *chan;
495  // }
496  // if ( first != last ) { ss << std::setw(2) << first << "->" << std::setw(2) << last; }
497  ss << std::endl;
498  }
499 
500  }
501 
502  }
503 
504  LogTrace(mlConfigDb_) << ss.str();
505 
506 }
AnalysisDescriptions analyses_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const uint32_t & key() const
Definition: SiStripKey.h:125
static const char mlConfigDb_[]
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const_iterator begin() const
Definition: MapOfVectors.h:131
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
DeviceAddress deviceAddress(const deviceDescription &)
#define LogTrace(id)
ii
Definition: cuy.py:590
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const_iterator end() const
Definition: MapOfVectors.h:135
void SiStripConfigDb::printDcuDetIds ( std::string  partition = "")
protected

Prints local cache (just for given partition if specified).

Definition at line 338 of file DcuDetIds.cc.

References LogTrace, and sistrip::mlConfigDb_.

338  {
339 
340  std::stringstream ss;
341  ss << "[SiStripConfigDb::" << __func__ << "]"
342  << " Contents of DcuDetIds container:" << std::endl;
343  ss << " Number of partitions: " << dcuDetIds_.size() << std::endl;
344 
345  // Loop through partitions
346  uint16_t cntr = 0;
349  for ( ; idcu != jdcu; ++idcu ) {
350 
351  cntr++;
352  if ( partition == "" || partition == idcu->first ) {
353 
354  ss << " Partition number : " << cntr << " (out of " << dcuDetIds_.size() << ")" << std::endl;
355  ss << " Partition name : \"" << idcu->first << "\"" << std::endl;
356  ss << " Size of DCU-DetId map : " << idcu->second.size() << std::endl;
357 
358  }
359 
360  }
361 
362  LogTrace(mlConfigDb_) << ss.str();
363 
364 }
static const char mlConfigDb_[]
const_iterator begin() const
Definition: MapOfVectors.h:131
size_type size() const
Definition: MapOfVectors.h:106
#define LogTrace(id)
const_iterator end() const
Definition: MapOfVectors.h:135
DcuDetIds dcuDetIds_
void SiStripConfigDb::printDeviceDescriptions ( std::string  partition = "")
protected

Prints local cache (just for given partition if specified).

Definition at line 411 of file DeviceDescriptions.cc.

References begin, SiStripConfigDb::DeviceAddress::ccuAddr_, SiStripConfigDb::DeviceAddress::ccuChan_, data, end, SiStripFecKey::fecCrate(), SiStripConfigDb::DeviceAddress::fecCrate_, SiStripFecKey::fecRing(), SiStripConfigDb::DeviceAddress::fecRing_, SiStripFecKey::fecSlot(), SiStripConfigDb::DeviceAddress::fecSlot_, spr::find(), SiStripConfigDb::DeviceAddress::i2cAddr_, cuy::ii, findQualityFiles::jj, crabWrapper::key, SiStripKey::key(), SiStripConfigDb::DeviceAddress::lldChan_, LogTrace, sistrip::mlConfigDb_, jetUpdater_cfi::sort, groupFilesInBlocks::temp, and tmp.

411  {
412 
413  std::stringstream ss;
414  ss << "[SiStripConfigDb::" << __func__ << "]"
415  << " Contents of DeviceDescriptions container:" << std::endl;
416  ss << " Number of partitions: " << devices_.size() << std::endl;
417 
418  // Loop through partitions
419  uint16_t cntr = 0;
422  for ( ; idev != jdev; ++idev ) {
423 
424  cntr++;
425  if ( partition == "" || partition == idev->first ) {
426 
427  ss << " Partition number : " << cntr << " (out of " << devices_.size() << ")" << std::endl;
428  ss << " Partition name : \"" << idev->first << "\"" << std::endl;
429  ss << " Num of devices : " << idev->second.size() << std::endl;
430 
431  // Extract FEC crate, slot, etc
432  std::map< uint32_t, vector<std::string> > devices;
433  DeviceDescriptionsV::const_iterator iter = idev->second.begin();
434  DeviceDescriptionsV::const_iterator jter = idev->second.end();
435  for ( ; iter != jter; ++iter ) {
436  if ( *iter ) {
437  DeviceAddress addr = deviceAddress( **iter );
438  uint32_t key = SiStripFecKey( addr.fecCrate_,
439  addr.fecSlot_,
440  addr.fecRing_,
441  0,
442  0,
443  0,
444  0 ).key();
445  std::stringstream data;
446  data << (*iter)->getDeviceType()
447  << "_"
448  << SiStripFecKey( addr.fecCrate_,
449  addr.fecSlot_,
450  addr.fecRing_,
451  addr.ccuAddr_,
452  addr.ccuChan_,
453  addr.lldChan_,
454  addr.i2cAddr_ ).key();
455  if ( find( devices[key].begin(), devices[key].end(), data.str() ) == devices[key].end() ) {
456  devices[key].push_back( data.str() );
457  }
458  }
459  }
460 
461  // Sort contents
462  std::map< uint32_t, std::vector<std::string> > tmp;
463  std::map< uint32_t, std::vector<std::string> >::const_iterator ii = devices.begin();
464  std::map< uint32_t, std::vector<std::string> >::const_iterator jj = devices.end();
465  for ( ; ii != jj; ++ii ) {
466  std::vector<std::string> temp = ii->second;
467  std::sort( temp.begin(), temp.end() );
468  std::vector<std::string>::const_iterator iii = temp.begin();
469  std::vector<std::string>::const_iterator jjj = temp.end();
470  for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
471  }
472  devices.clear();
473  devices = tmp;
474 
475  // Print FEC crate, slot, etc...
476  std::map< uint32_t, std::vector<std::string> >::const_iterator idev = devices.begin();
477  std::map< uint32_t, std::vector<std::string> >::const_iterator jdev = devices.end();
478  for ( ; idev != jdev; ++idev ) {
479  SiStripFecKey key(idev->first);
480  ss << " Found " << std::setw(3) << idev->second.size()
481  << " devices for FEC crate/slot/ring "
482  << key.fecCrate() << "/"
483  << key.fecSlot() << "/"
484  << key.fecRing();
485  //<< " (ccu/module/lld/i2c): ";
486  // if ( !idev->second.empty() ) {
487  // uint16_t first = idev->second.front();
488  // uint16_t last = idev->second.front();
489  // std::vector<std::string>::const_iterator chan = idev->second.begin();
490  // for ( ; chan != idev->second.end(); chan++ ) {
491  // if ( chan != idev->second.begin() ) {
492  // if ( *chan != last+1 ) {
493  // ss << std::setw(2) << first << "->" << std::setw(2) << last << ", ";
494  // if ( chan != idev->second.end() ) { first = *(chan+1); }
495  // }
496  // }
497  // last = *chan;
498  // }
499  // if ( first != last ) { ss << std::setw(2) << first << "->" << std::setw(2) << last; }
500  ss << std::endl;
501  }
502 
503  }
504 
505  }
506 
507  LogTrace(mlConfigDb_) << ss.str();
508 
509 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const uint32_t & key() const
Definition: SiStripKey.h:125
static const char mlConfigDb_[]
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const_iterator begin() const
Definition: MapOfVectors.h:131
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
DeviceAddress deviceAddress(const deviceDescription &)
#define LogTrace(id)
ii
Definition: cuy.py:590
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
DeviceDescriptions devices_
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const_iterator end() const
Definition: MapOfVectors.h:135
void SiStripConfigDb::printFedConnections ( std::string  partition = "")
protected

Prints local cache (just for given partition if specified).

Definition at line 344 of file FedConnections.cc.

References begin, end, spr::find(), plotBeamSpotDB::first, cuy::ii, findQualityFiles::jj, plotBeamSpotDB::last, LogTrace, sistrip::mlConfigDb_, jetUpdater_cfi::sort, groupFilesInBlocks::temp, and tmp.

344  {
345 
346  std::stringstream ss;
347  ss << "[SiStripConfigDb::" << __func__ << "]"
348  << " Contents of FedConnections container:" << std::endl;
349  ss << " Number of partitions: " << connections_.size() << std::endl;
350 
351  // Loop through partitions
352  uint16_t cntr = 0;
355  for ( ; iconn != jconn; ++iconn ) {
356 
357  cntr++;
358  if ( partition == "" || partition == iconn->first ) {
359 
360  ss << " Partition number : " << cntr << " (out of " << connections_.size() << ")" << std::endl;
361  ss << " Partition name : \"" << iconn->first << "\"" << std::endl;
362  ss << " Num of connections : " << iconn->second.size() << std::endl;
363 
364  // Extract FED ids and channels
365  std::map< uint16_t, vector<uint16_t> > feds;
366  FedConnectionsV::const_iterator iter = iconn->second.begin();
367  FedConnectionsV::const_iterator jter = iconn->second.end();
368  for ( ; iter != jter; ++iter ) {
369  if ( *iter ) {
370  uint16_t fed_id = (*iter)->getFedId();
371  uint16_t fed_ch = (*iter)->getFedChannel();
372  if ( find( feds[fed_id].begin(), feds[fed_id].end(), fed_ch ) == feds[fed_id].end() ) {
373  feds[fed_id].push_back( fed_ch );
374  }
375  }
376  }
377 
378  // Sort contents
379  std::map< uint16_t, std::vector<uint16_t> > tmp;
380  std::map< uint16_t, std::vector<uint16_t> >::const_iterator ii = feds.begin();
381  std::map< uint16_t, std::vector<uint16_t> >::const_iterator jj = feds.end();
382  for ( ; ii != jj; ++ii ) {
383  std::vector<uint16_t> temp = ii->second;
384  std::sort( temp.begin(), temp.end() );
385  std::vector<uint16_t>::const_iterator iii = temp.begin();
386  std::vector<uint16_t>::const_iterator jjj = temp.end();
387  for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
388  }
389  feds.clear();
390  feds = tmp;
391 
392  // Print FED ids and channels
393  std::map< uint16_t, std::vector<uint16_t> >::const_iterator ifed = feds.begin();
394  std::map< uint16_t, std::vector<uint16_t> >::const_iterator jfed = feds.end();
395  for ( ; ifed != jfed; ++ifed ) {
396  ss << " Found " << std::setw(2) << ifed->second.size()
397  << " channels for FED id " << std::setw(3) << ifed->first << " : ";
398  if ( !ifed->second.empty() ) {
399  uint16_t first = ifed->second.front();
400  uint16_t last = ifed->second.front();
401  std::vector<uint16_t>::const_iterator ichan = ifed->second.begin();
402  std::vector<uint16_t>::const_iterator jchan = ifed->second.end();
403  for ( ; ichan != jchan; ++ichan ) {
404  if ( ichan != ifed->second.begin() ) {
405  if ( *ichan != last+1 ) {
406  ss << std::setw(2) << first << "->" << std::setw(2) << last << ", ";
407  if ( ichan != ifed->second.end() ) { first = *(ichan+1); }
408  }
409  }
410  last = *ichan;
411  }
412  if ( first != last ) { ss << std::setw(2) << first << "->" << std::setw(2) << last; }
413  ss << std::endl;
414  }
415  }
416 
417  }
418 
419  }
420 
421  LogTrace(mlConfigDb_) << ss.str();
422 
423 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
FedConnections connections_
static const char mlConfigDb_[]
const_iterator begin() const
Definition: MapOfVectors.h:131
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
#define LogTrace(id)
ii
Definition: cuy.py:590
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:32
const_iterator end() const
Definition: MapOfVectors.h:135
void SiStripConfigDb::printFedDescriptions ( std::string  partition = "")
protected

Prints local cache (just for given partition if specified).

Definition at line 347 of file FedDescriptions.cc.

References begin, data, end, spr::find(), plotBeamSpotDB::first, cuy::ii, findQualityFiles::jj, crabWrapper::key, plotBeamSpotDB::last, LogTrace, sistrip::mlConfigDb_, jetUpdater_cfi::sort, groupFilesInBlocks::temp, and tmp.

347  {
348 
349  std::stringstream ss;
350  ss << "[SiStripConfigDb::" << __func__ << "]"
351  << " Contents of FedDescriptions container:" << std::endl;
352  ss << " Number of partitions: " << feds_.size() << std::endl;
353 
354  // Loop through partitions
355  uint16_t cntr = 0;
358  for ( ; iconn != jconn; ++iconn ) {
359 
360  cntr++;
361  if ( partition == "" || partition == iconn->first ) {
362 
363  ss << " Partition number : " << cntr << " (out of " << feds_.size() << ")" << std::endl;
364  ss << " Partition name : \"" << iconn->first << "\"" << std::endl;
365  ss << " Num of FED ids : " << iconn->second.size() << std::endl;
366 
367  // Extract FED crates and ids
368  std::map< uint16_t, vector<uint16_t> > feds;
369  FedDescriptionsV::const_iterator iter = iconn->second.begin();
370  FedDescriptionsV::const_iterator jter = iconn->second.end();
371  for ( ; iter != jter; ++iter ) {
372  if ( *iter ) {
373  uint16_t key = (*iter)->getCrateNumber();
374  uint16_t data = (*iter)->getFedId();
375  if ( find( feds[key].begin(), feds[key].end(), data ) == feds[key].end() ) {
376  feds[key].push_back( data );
377  }
378  }
379  }
380 
381  // Sort contents
382  std::map< uint16_t, std::vector<uint16_t> > tmp;
383  std::map< uint16_t, std::vector<uint16_t> >::const_iterator ii = feds.begin();
384  std::map< uint16_t, std::vector<uint16_t> >::const_iterator jj = feds.end();
385  for ( ; ii != jj; ++ii ) {
386  std::vector<uint16_t> temp = ii->second;
387  std::sort( temp.begin(), temp.end() );
388  std::vector<uint16_t>::const_iterator iii = temp.begin();
389  std::vector<uint16_t>::const_iterator jjj = temp.end();
390  for ( ; iii != jjj; ++iii ) { tmp[ii->first].push_back( *iii ); }
391  }
392  feds.clear();
393  feds = tmp;
394 
395  // Print FED crates and ids
396  std::map< uint16_t, std::vector<uint16_t> >::const_iterator ifed = feds.begin();
397  std::map< uint16_t, std::vector<uint16_t> >::const_iterator jfed = feds.end();
398  for ( ; ifed != jfed; ++ifed ) {
399  ss << " Found " << std::setw(2) << ifed->second.size()
400  << " FED ids for crate number " << std::setw(2) << ifed->first << " : ";
401  if ( !ifed->second.empty() ) {
402  uint16_t first = ifed->second.front();
403  uint16_t last = ifed->second.front();
404  std::vector<uint16_t>::const_iterator icrate = ifed->second.begin();
405  std::vector<uint16_t>::const_iterator jcrate = ifed->second.end();
406  for ( ; icrate != jcrate; ++icrate ) {
407  if ( icrate != ifed->second.begin() ) {
408  if ( *icrate != last+1 ) {
409  ss << std::setw(2) << first << "->" << std::setw(2) << last << ", ";
410  if ( icrate != ifed->second.end() ) { first = *(icrate+1); }
411  }
412  }
413  last = *icrate;
414  }
415  if ( first != last ) { ss << std::setw(2) << first << "->" << std::setw(2) << last; }
416  ss << std::endl;
417  }
418  }
419 
420  }
421 
422  }
423 
424  LogTrace(mlConfigDb_) << ss.str();
425 
426 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
static const char mlConfigDb_[]
const_iterator begin() const
Definition: MapOfVectors.h:131
FedDescriptions feds_
size_type size() const
Definition: MapOfVectors.h:106
#define end
Definition: vmac.h:39
#define LogTrace(id)
ii
Definition: cuy.py:590
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const_iterator end() const
Definition: MapOfVectors.h:135
void SiStripConfigDb::runs ( SiStripConfigDb::Runs runs) const
protected

Retrieves all runs from database.

Definition at line 820 of file SiStripConfigDb.cc.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), sistrip::APV_LATENCY, sistrip::APV_TIMING, sistrip::CALIBRATION, sistrip::CALIBRATION_DECO, sistrip::CALIBRATION_SCAN, sistrip::CALIBRATION_SCAN_DECO, sistrip::DAQ_SCOPE_MODE, deviceFactory(), sistrip::FAST_CABLING, sistrip::FED_CABLING, sistrip::FED_TIMING, sistrip::FINE_DELAY, sistrip::FINE_DELAY_PLL, sistrip::FINE_DELAY_TTC, cuy::ii, findQualityFiles::jj, sistrip::mlConfigDb_, sistrip::MULTI_MODE, SiStripConfigDb::Run::number_, sistrip::OPTO_SCAN, SiStripConfigDb::Run::partition_, sistrip::PEDESTALS, sistrip::PHYSICS, sistrip::PHYSICS_ZS, sistrip::QUITE_FAST_CABLING, alignCSCRings::r, groupFilesInBlocks::temp, SiStripConfigDb::Run::type_, sistrip::UNDEFINED_RUN_TYPE, sistrip::UNKNOWN_RUN_TYPE, and sistrip::VPSP_SCAN.

Referenced by inputFilesetParser.inputFilesetParser::selectedRunsWithoutresult(), and inputFilesetParser.inputFilesetParser::selectedRunsWithresult().

820  {
821 
822  runs.clear();
823 
824  // Check DF pointer
825  DeviceFactory* const df = deviceFactory(__func__);
826  if ( !df ) {
828  << "[SiStripPartition::" << __func__ << "]"
829  << " NULL pointer to DeviceFactory object!";
830  return;
831  }
832 
833  // Retrieve runs
834  tkRunVector all;
835  all = df->getAllRuns();
836 
837  // Iterate through tkRunVector
838  tkRunVector::const_iterator ii = all.begin();
839  tkRunVector::const_iterator jj = all.end();
840  for ( ; ii != jj; ++ii ) {
841 
842  // Check TkRun pointer
843  if ( *ii ) {
844 
845  // Retrieve run type
846  uint16_t type = (*ii)->getModeId( (*ii)->getMode() );
848  if ( type == 1 ) { temp = sistrip::PHYSICS; }
849  else if ( type == 2 ) { temp = sistrip::PEDESTALS; }
850  else if ( type == 3 ) { temp = sistrip::CALIBRATION; }
851  else if ( type == 33 ) { temp = sistrip::CALIBRATION_DECO; }
852  else if ( type == 4 ) { temp = sistrip::OPTO_SCAN; }
853  else if ( type == 5 ) { temp = sistrip::APV_TIMING; }
854  else if ( type == 6 ) { temp = sistrip::APV_LATENCY; }
855  else if ( type == 7 ) { temp = sistrip::FINE_DELAY_PLL; }
856  else if ( type == 10 ) { temp = sistrip::MULTI_MODE; }
857  else if ( type == 8 ) { temp = sistrip::FINE_DELAY_TTC; }
858  else if ( type == 12 ) { temp = sistrip::FED_TIMING; }
859  else if ( type == 13 ) { temp = sistrip::FED_CABLING; }
860  else if ( type == 14 ) { temp = sistrip::VPSP_SCAN; }
861  else if ( type == 15 ) { temp = sistrip::DAQ_SCOPE_MODE; }
862  else if ( type == 16 ) { temp = sistrip::QUITE_FAST_CABLING; }
863  else if ( type == 17 ) { temp = sistrip::FINE_DELAY; }
864  else if ( type == 18 ) { temp = sistrip::PHYSICS_ZS; }
865  else if ( type == 19 ) { temp = sistrip::CALIBRATION_SCAN; }
866  else if ( type == 20 ) { temp = sistrip::CALIBRATION_SCAN_DECO; }
867  else if ( type == 21 ) { temp = sistrip::FAST_CABLING; }
868  else if ( type == 0 ) { temp = sistrip::UNDEFINED_RUN_TYPE; }
869  else { temp = sistrip::UNKNOWN_RUN_TYPE; }
870 
871  // Store run details
872  Run r;
873  r.type_ = temp;
874  r.partition_ = (*ii)->getPartitionName();
875  r.number_ = (*ii)->getRunNumber();
876  runs.push_back(r);
877 
878  } else {
880  << "[SiStripPartition::" << __func__ << "]"
881  << " NULL pointer to TkRun object!";
882  }
883 
884  }
885 
886 }
type
Definition: HCALResponse.h:21
DeviceFactory *const deviceFactory(std::string method_name="") const
void runs(Runs &) const
static const char mlConfigDb_[]
ii
Definition: cuy.py:590
void SiStripConfigDb::runs ( const Runs in,
SiStripConfigDb::RunsByType out,
std::string  optional_partition = "" 
) const
protected

Runs organsed by type, optionally for given partition.

Definition at line 890 of file SiStripConfigDb.cc.

References dbParams_, runEdmFileComparison::found, cuy::ii, findQualityFiles::jj, sistrip::mlConfigDb_, SiStripDbParams::partition(), SiStripDbParams::partitions(), sistrip::UNDEFINED_RUN_TYPE, and sistrip::UNKNOWN_RUN_TYPE.

Referenced by inputFilesetParser.inputFilesetParser::selectedRunsWithoutresult(), and inputFilesetParser.inputFilesetParser::selectedRunsWithresult().

892  {
893 
894  out.clear();
895 
896  // Check partition name (if not empty string)
897  if ( !optional_partition.empty() ) {
898  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partition( optional_partition );
899  if ( iter == dbParams_.partitions().end() ) {
901  << "[SiStripPartition::" << __func__ << "]"
902  << " Partition name not found!";
903  return;
904  }
905  }
906 
907  // Iterate through runs
908  Runs::const_iterator ii = in.begin();
909  Runs::const_iterator jj = in.end();
910  for ( ; ii != jj; ++ii ) {
911  // Check partition name
912  if ( ii->partition_ == optional_partition || optional_partition == "" ) {
913  // Check run type
914  if ( ii->type_ != sistrip::UNKNOWN_RUN_TYPE &&
915  ii->type_ != sistrip::UNDEFINED_RUN_TYPE ) {
916  // Check run number
917  if ( ii->number_ ) {
918  bool found = false;
919  if ( out.find( ii->type_ ) != out.end() ) {
920  Runs::const_iterator irun = out[ ii->type_ ].begin();
921  Runs::const_iterator jrun = out[ ii->type_ ].end();
922  while ( !found && irun != jrun ) {
923  if ( irun->number_ == ii->number_ ) { found = true; }
924  ++irun;
925  }
926  }
927  // Check if run number already found
928  if ( !found ) {
929  out[ ii->type_ ].push_back( *ii );
930  } else {
931  // edm::LogWarning(mlConfigDb_)
932  // << "[SiStripPartition::" << __func__ << "]"
933  // << " Run number already found!";
934  }
935  } else {
936  // edm::LogWarning(mlConfigDb_)
937  // << "[SiStripPartition::" << __func__ << "]"
938  // << " NULL run number!";
939  }
940  } else {
941  // edm::LogWarning(mlConfigDb_)
942  // << "[SiStripPartition::" << __func__ << "]"
943  // << " Unexpected run type!";
944  }
945  } else {
946  // edm::LogWarning(mlConfigDb_)
947  // << "[SiStripPartition::" << __func__ << "]"
948  // << " Partition name does not match!";
949  }
950 
951  }
952 
953 }
static const char mlConfigDb_[]
const_iterator_range partitions() const
ii
Definition: cuy.py:590
SiStripPartitions::const_iterator partition(std::string partition_name) const
SiStripDbParams dbParams_
void SiStripConfigDb::runs ( const Runs in,
SiStripConfigDb::RunsByPartition out,
sistrip::RunType  optional_type = sistrip::UNDEFINED_RUN_TYPE 
) const
protected

Runs organsed by partition, optionally for given type.

Definition at line 957 of file SiStripConfigDb.cc.

References runEdmFileComparison::found, cuy::ii, findQualityFiles::jj, and sistrip::UNDEFINED_RUN_TYPE.

Referenced by inputFilesetParser.inputFilesetParser::selectedRunsWithoutresult(), and inputFilesetParser.inputFilesetParser::selectedRunsWithresult().

959  {
960 
961  out.clear();
962 
963  // Iterate through runs
964  Runs::const_iterator ii = in.begin();
965  Runs::const_iterator jj = in.end();
966  for ( ; ii != jj; ++ii ) {
967  // Check partition name
968  if ( ii->partition_ != "" ) {
969  // Check run type
970  if ( ii->type_ == optional_type || optional_type == sistrip::UNDEFINED_RUN_TYPE ) {
971  // Check run number
972  if ( ii->number_ ) {
973  bool found = false;
974  if ( out.find( ii->partition_ ) != out.end() ) {
975  Runs::const_iterator irun = out[ ii->partition_ ].begin();
976  Runs::const_iterator jrun = out[ ii->partition_ ].end();
977  while ( !found && irun != jrun ) {
978  if ( irun->number_ == ii->number_ ) { found = true; }
979  ++irun;
980  }
981  }
982  // Check if run number already found
983  if ( !found ) {
984  out[ ii->partition_ ].push_back( *ii );
985  } else {
986  // edm::LogWarning(mlConfigDb_)
987  // << "[SiStripPartition::" << __func__ << "]"
988  // << " Run number already found!";
989  }
990  } else {
991  // edm::LogWarning(mlConfigDb_)
992  // << "[SiStripPartition::" << __func__ << "]"
993  // << " NULL run number!";
994  }
995  } else {
996  // edm::LogWarning(mlConfigDb_)
997  // << "[SiStripPartition::" << __func__ << "]"
998  // << " Run type does not match!";
999  }
1000  } else {
1001  // edm::LogWarning(mlConfigDb_)
1002  // << "[SiStripPartition::" << __func__ << "]"
1003  // << " NULL value for partition!";
1004  }
1005 
1006  }
1007 
1008 }
ii
Definition: cuy.py:590
void SiStripConfigDb::uploadAnalysisDescriptions ( bool  calibration_for_physics = false,
std::string  partition = "" 
)
protected

Uploads to database (just for given partition if specified).

list of all analysis type

Definition at line 233 of file AnalysisDescriptions.cc.

References spr::find(), LogTrace, sistrip::mlConfigDb_, and jets_cff::version.

Referenced by CommissioningHistosUsingDb::uploadAnalyses().

234  {
235 
236  if ( dbParams_.usingDbCache() ) {
238  << "[SiStripConfigDb::" << __func__ << "]"
239  << " Using database cache! No uploads allowed!";
240  return;
241  }
242 
243  if ( !deviceFactory(__func__) ) { return; }
244 
245  if ( analyses_.empty() ) {
247  << "[SiStripConfigDb::" << __func__ << "]"
248  << " Found no cached analysis descriptions, therefore no upload!";
249  return;
250  }
251 
252  if ( calibration_for_physics && !allowCalibUpload_ ) {
254  << "[SiStripConfigDb::" << __func__ << "]"
255  << " Attempting to upload calibration constants"
256  << " without uploading any hardware descriptions!"
257  << " Aborting upload...";
258  return;
259  } else { allowCalibUpload_ = false; }
260 
261  try {
262 
263  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
264  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
265  for ( ; iter != jter; ++iter ) {
266 
267  if ( partition.empty() || partition == iter->second.partitionName() ) {
268 
269  AnalysisDescriptionsRange range = analyses_.find( iter->second.partitionName() );
270  if ( range != analyses_.emptyRange() ) {
271 
272  AnalysisDescriptionsV anals( range.begin(), range.end() );
273 
274  vector<AnalysisType> analysis_type; // check how many different analysis type we have --> more than one analysis table could be uploaded in the same job
275  for(auto element : anals){
276  if(std::find(analysis_type.begin(),analysis_type.end(),element->getType()) == analysis_type.end() and element->getType() != AnalysisDescription::T_UNKNOWN){
277  analysis_type.push_back(element->getType());
278  }
279  else if(element->getType() == AnalysisDescription::T_UNKNOWN){
281  << "[SiStripConfigDb::" << __func__ << "]"
282  << " Analysis type is UNKNOWN. Aborting upload!";
283  return;
284  }
285  }
286 
287  vector<AnalysisDescriptionsV> analysisToUpload; // in case there are more than one analysis type to be uploaded
288  for(auto type : analysis_type){
289  AnalysisDescriptionsV ana_temp;
290  for(auto element : anals){
291  if(element->getType() == type)
292  ana_temp.push_back(element);
293  }
294  analysisToUpload.push_back(ana_temp);
295  }
296 
297  // perform the upload
298  for(auto analysis : analysisToUpload){
299 
300  uint32_t version = deviceFactory(__func__)->uploadAnalysis( iter->second.runNumber(),
301  iter->second.partitionName(),
302  analysis.front()->getType(),
303  analysis,
304  calibration_for_physics);
305  // Update current state with analysis descriptions
306  if ( calibration_for_physics ) { deviceFactory(__func__)->uploadAnalysisState( version );}
307  }
308 
309  // Some debug
310  std::stringstream ss;
311  ss << "[SiStripConfigDb::" << __func__ << "]"
312  << " Uploaded " << anals.size()
313  << " device descriptions to database for partition \""
314  << iter->second.partitionName() << "\".";
315  LogTrace(mlConfigDb_) << ss.str();
316 
317  } else {
318  stringstream ss;
319  ss << "[SiStripConfigDb::" << __func__ << "]"
320  << " Vector of device descriptions is empty for partition \""
321  << iter->second.partitionName()
322  << "\", therefore aborting upload for this partition!";
323  edm::LogWarning(mlConfigDb_) << ss.str();
324  continue;
325  }
326 
327  }else {
328  // stringstream ss;
329  // ss << "[SiStripConfigDb::" << __func__ << "]"
330  // << " Cannot find partition \"" << partition
331  // << "\" in cached partitions list: \""
332  // << dbParams_.partitionNames( dbParams_.partitionNames() )
333  // << "\", therefore aborting upload for this partition!";
334  // edm::LogWarning(mlConfigDb_) << ss.str();
335  }
336  }
337  } catch (...) { handleException( __func__ ); }
338 
339  allowCalibUpload_ = true;
340 
341 }
type
Definition: HCALResponse.h:21
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
AnalysisDescriptions analyses_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
static const char mlConfigDb_[]
const_iterator_range partitions() const
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
AnalysisDescriptions::range AnalysisDescriptionsRange
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
bool usingDbCache() const
std::vector< AnalysisDescription * > AnalysisDescriptionsV
static std::atomic< bool > allowCalibUpload_
void SiStripConfigDb::uploadDcuDetIds ( std::string  partition = "")
protected

Uploads to database (just for given partition if specified).

Definition at line 183 of file DcuDetIds.cc.

References sistrip::mlConfigDb_.

183  {
184 
185  stringstream ss;
186  ss << "[SiStripConfigDb::" << __func__ << "]"
187  << " Cannot upload to database! This functionality not allowed!";
188  edm::LogWarning(mlConfigDb_) << ss.str();
189 
190  /*
191  addAllDetId => all detids
192  addAllDetId => to download (up to you)
193  change in the detids
194  setTkDcuInfo
195  getCurrentStates
196  setCurrentState
197  addDetIpartiton
198  AddAllDetId
199  */
200 
201  // if ( dbParams_.usingDbCache() ) {
202  // edm::LogWarning(mlConfigDb_)
203  // << "[SiStripConfigDb::" << __func__ << "]"
204  // << " Using database cache! No uploads allowed!";
205  // return;
206  // }
207 
208  // if ( !deviceFactory(__func__) ) { return; }
209 
210  // if ( dcuDetIds_.empty() ) {
211  // stringstream ss;
212  // ss << "[SiStripConfigDb::" << __func__ << "]"
213  // << " Found no cached DCU-DetId map, therefore no upload!";
214  // edm::LogWarning(mlConfigDb_) << ss.str();
215  // return;
216  // }
217 
218  // try {
219 
220  // SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
221  // SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
222  // for ( ; iter != jter; ++iter ) {
223 
224  // if ( partition == "" || partition == iter->second.partitionName() ) {
225 
226  // DcuDetIdsRange range = dcuDetIds_.find( iter->second.partitionName() );
227  // if ( range != dcuDetIds_.emptyRange() ) {
228 
229  // // Extract
230  // DcuDetIdMap dst;
231  // clone( DcuDetIdsV( range.begin(), range.end() ), dst );
232  // deviceFactory(__func__)->setTkDcuInfo( dst );
233  // getcurrentstate
234  // deviceFactory(__func__)->addAllDetId();
235 
236  // // Some debug
237  // std::stringstream ss;
238  // ss << "[SiStripConfigDb::" << __func__ << "]"
239  // << " Uploaded " << dst.size()
240  // << " DCU-DetId map to DB/xml for partition \""
241  // << iter->second.partitionName() << "\".";
242  // LogTrace(mlConfigDb_) << ss.str();
243 
244  // } else {
245  // stringstream ss;
246  // ss << "[SiStripConfigDb::" << __func__ << "]"
247  // << " Vector of DCU-DetId map is empty for partition \""
248  // << iter->second.partitionName()
249  // << "\", therefore aborting upload for this partition!";
250  // edm::LogWarning(mlConfigDb_) << ss.str();
251  // continue;
252  // }
253 
254  // } else {
255  // // stringstream ss;
256  // // ss << "[SiStripConfigDb::" << __func__ << "]"
257  // // << " Cannot find partition \"" << partition
258  // // << "\" in cached partitions list: \""
259  // // << dbParams_.partitionNames( dbParams_.partitionNames() )
260  // // << "\", therefore aborting upload for this partition!";
261  // // edm::LogWarning(mlConfigDb_) << ss.str();
262  // }
263 
264  // }
265 
266  // } catch (... ) { handleException( __func__, "Problems updating objects in TkDcuInfoFactory!" ); }
267 
268 }
static const char mlConfigDb_[]
void SiStripConfigDb::uploadDeviceDescriptions ( std::string  partition = "")
protected

Uploads to database (just for given partition if specified).

Definition at line 268 of file DeviceDescriptions.cc.

References LogTrace, sistrip::mlConfigDb_, and funct::true.

Referenced by ApvTimingHistosUsingDb::uploadConfigurations(), OptoScanHistosUsingDb::uploadConfigurations(), VpspScanHistosUsingDb::uploadConfigurations(), LatencyHistosUsingDb::uploadConfigurations(), CalibrationHistosUsingDb::uploadConfigurations(), and FineDelayHistosUsingDb::uploadConfigurations().

268  {
269 
270  if ( dbParams_.usingDbCache() ) {
272  << "[SiStripConfigDb::" << __func__ << "]"
273  << " Using database cache! No uploads allowed!";
274  return;
275  }
276 
277  if ( !deviceFactory(__func__) ) { return; }
278 
279  if ( devices_.empty() ) {
280  stringstream ss;
281  ss << "[SiStripConfigDb::" << __func__ << "]"
282  << " Found no cached device descriptions, therefore no upload!";
283  edm::LogWarning(mlConfigDb_) << ss.str();
284  return;
285  }
286 
287  try {
288 
289  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
290  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
291  for ( ; iter != jter; ++iter ) {
292 
293  if ( partition == "" || partition == iter->second.partitionName() ) {
294 
295  DeviceDescriptionsRange range = devices_.find( iter->second.partitionName() );
296  if ( range != devices_.emptyRange() ) {
297 
298  DeviceDescriptionsV devs( range.begin(), range.end() );
299 
300  SiStripPartition::Versions fecVersion = iter->second.fecVersion();
301  deviceFactory(__func__)->setFecDeviceDescriptions( devs,
302  iter->second.partitionName(),
303  &(fecVersion.first),
304  &(fecVersion.second),
305  true ); // new major version
306 
307  // Some debug
308  std::stringstream ss;
309  ss << "[SiStripConfigDb::" << __func__ << "]"
310  << " Uploaded " << devs.size()
311  << " device descriptions to database for partition \""
312  << iter->second.partitionName() << "\".";
313  LogTrace(mlConfigDb_) << ss.str();
314 
315  } else {
316  stringstream ss;
317  ss << "[SiStripConfigDb::" << __func__ << "]"
318  << " Vector of device descriptions is empty for partition \""
319  << iter->second.partitionName()
320  << "\", therefore aborting upload for this partition!";
321  edm::LogWarning(mlConfigDb_) << ss.str();
322  continue;
323  }
324 
325  } else {
326  // stringstream ss;
327  // ss << "[SiStripConfigDb::" << __func__ << "]"
328  // << " Cannot find partition \"" << partition
329  // << "\" in cached partitions list: \""
330  // << dbParams_.partitionNames( dbParams_.partitionNames() )
331  // << "\", therefore aborting upload for this partition!";
332  // edm::LogWarning(mlConfigDb_) << ss.str();
333  }
334 
335  }
336 
337  } catch (...) { handleException( __func__ ); }
338 
339  allowCalibUpload_ = true;
340 
341 }
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
std::pair< uint32_t, uint32_t > Versions
static const char mlConfigDb_[]
const_iterator_range partitions() const
DeviceDescriptions::range DeviceDescriptionsRange
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
DeviceDescriptions devices_
SiStripDbParams dbParams_
bool usingDbCache() const
static std::atomic< bool > allowCalibUpload_
std::vector< DeviceDescription * > DeviceDescriptionsV
void SiStripConfigDb::uploadFedConnections ( std::string  partition = "")
protected

Uploads to database (just for given partition if specified).

Definition at line 197 of file FedConnections.cc.

References LogTrace, sistrip::mlConfigDb_, and funct::true.

Referenced by FastFedCablingHistosUsingDb::uploadConfigurations().

197  {
198 
199  if ( dbParams_.usingDbCache() ) {
201  << "[SiStripConfigDb::" << __func__ << "]"
202  << " Using database cache! No uploads allowed!";
203  return;
204  }
205 
206  if ( !deviceFactory(__func__) ) { return; }
207 
208  if ( connections_.empty() ) {
209  stringstream ss;
210  ss << "[SiStripConfigDb::" << __func__ << "]"
211  << " Found no cached FED connections, therefore no upload!";
212  edm::LogWarning(mlConfigDb_) << ss.str();
213  return;
214  }
215 
216  if ( dbParams_.usingDb() ) {
217 
218  try {
219 
220  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
221  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
222  for ( ; iter != jter; ++iter ) {
223 
224  if ( partition == "" || partition == iter->second.partitionName() ) {
225 
226  FedConnectionsRange range = connections_.find( iter->second.partitionName() );
227  if ( range != connections_.emptyRange() ) {
228 
229  FedConnectionsV conns( range.begin(), range.end() );
230 
231  SiStripPartition::Versions cabVersion = iter->second.cabVersion();
232  deviceFactory(__func__)->setConnectionDescriptions( conns,
233  iter->second.partitionName(),
234  &(cabVersion.first),
235  &(cabVersion.second),
236  true ); // new major version
237 
238  // Some debug
239  std::stringstream ss;
240  ss << "[SiStripConfigDb::" << __func__ << "]"
241  << " Uploaded " << conns.size()
242  << " FED connections to database for partition \""
243  << iter->second.partitionName() << "\".";
244  LogTrace(mlConfigDb_) << ss.str();
245 
246  } else {
247  stringstream ss;
248  ss << "[SiStripConfigDb::" << __func__ << "]"
249  << " Vector of FED connections is empty for partition \""
250  << iter->second.partitionName()
251  << "\", therefore aborting upload for this partition!";
252  edm::LogWarning(mlConfigDb_) << ss.str();
253  continue;
254  }
255 
256  } else {
257  // stringstream ss;
258  // ss << "[SiStripConfigDb::" << __func__ << "]"
259  // << " Cannot find partition \"" << partition
260  // << "\" in cached partitions list: \""
261  // << dbParams_.partitionNames( dbParams_.partitionNames() )
262  // << "\", therefore aborting upload for this partition!";
263  // edm::LogWarning(mlConfigDb_) << ss.str();
264  }
265 
266  }
267 
268  } catch (...) { handleException( __func__ ); }
269 
270  }
271 
272  allowCalibUpload_ = true;
273 
274 }
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool usingDb() const
std::pair< uint32_t, uint32_t > Versions
FedConnections connections_
FedConnections::range FedConnectionsRange
static const char mlConfigDb_[]
const_iterator_range partitions() const
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
bool usingDbCache() const
static std::atomic< bool > allowCalibUpload_
std::vector< FedConnection * > FedConnectionsV
void SiStripConfigDb::uploadFedDescriptions ( std::string  partition = "")
protected

Uploads to database (just for given partition if specified).

Definition at line 201 of file FedDescriptions.cc.

References LogTrace, and sistrip::mlConfigDb_.

Referenced by DaqScopeModeHistosUsingDb::uploadConfigurations(), PedsOnlyHistosUsingDb::uploadConfigurations(), ApvTimingHistosUsingDb::uploadConfigurations(), PedestalsHistosUsingDb::uploadConfigurations(), PedsFullNoiseHistosUsingDb::uploadConfigurations(), NoiseHistosUsingDb::uploadConfigurations(), FastFedCablingHistosUsingDb::uploadConfigurations(), LatencyHistosUsingDb::uploadConfigurations(), and FineDelayHistosUsingDb::uploadConfigurations().

201  {
202 
203  if ( dbParams_.usingDbCache() ) {
205  << "[SiStripConfigDb::" << __func__ << "]"
206  << " Using database cache! No uploads allowed!";
207  return;
208  }
209 
210  if ( !deviceFactory(__func__) ) { return; }
211 
212  if ( feds_.empty() ) {
213  stringstream ss;
214  ss << "[SiStripConfigDb::" << __func__ << "]"
215  << " Found no cached FED descriptions, therefore no upload!";
216  edm::LogWarning(mlConfigDb_) << ss.str();
217  return;
218  }
219 
220  try {
221 
222  SiStripDbParams::SiStripPartitions::const_iterator iter = dbParams_.partitions().begin();
223  SiStripDbParams::SiStripPartitions::const_iterator jter = dbParams_.partitions().end();
224  for ( ; iter != jter; ++iter ) {
225 
226  if ( partition == "" || partition == iter->second.partitionName() ) {
227 
228  FedDescriptionsRange range = feds_.find( iter->second.partitionName() );
229  if ( range != feds_.emptyRange() ) {
230 
231  FedDescriptionsV feds( range.begin(), range.end() );
232 
233  SiStripPartition::Versions fedVersion = iter->second.fedVersion();
234  deviceFactory(__func__)->setFed9UDescriptions( feds,
235  iter->second.partitionName(),
236  (uint16_t*)(&(fedVersion.first)),
237  (uint16_t*)(&(fedVersion.second)),
238  1 ); // new major version
239 
240  // Some debug
241  std::stringstream ss;
242  ss << "[SiStripConfigDb::" << __func__ << "]"
243  << " Uploaded " << feds.size()
244  << " FED descriptions to database for partition \""
245  << iter->second.partitionName() << "\"";
246  LogTrace(mlConfigDb_) << ss.str();
247 
248  } else {
249  stringstream ss;
250  ss << "[SiStripConfigDb::" << __func__ << "]"
251  << " Vector of FED descriptions is empty for partition \""
252  << iter->second.partitionName()
253  << "\", therefore aborting upload for this partition!";
254  edm::LogWarning(mlConfigDb_) << ss.str();
255  continue;
256  }
257 
258  } else {
259  // stringstream ss;
260  // ss << "[SiStripConfigDb::" << __func__ << "]"
261  // << " Cannot find partition \"" << partition
262  // << "\" in cached partitions list: \""
263  // << dbParams_.partitionNames( dbParams_.partitionNames() )
264  // << "\", therefore aborting upload for this partition!";
265  // edm::LogWarning(mlConfigDb_) << ss.str();
266  }
267 
268  }
269 
270  } catch (...) { handleException( __func__ ); }
271 
272  allowCalibUpload_ = true;
273 
274 }
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
FedDescriptions::range FedDescriptionsRange
std::pair< uint32_t, uint32_t > Versions
static const char mlConfigDb_[]
const_iterator_range partitions() const
FedDescriptions feds_
range find(K const &k) const
Definition: MapOfVectors.h:122
#define LogTrace(id)
range emptyRange() const
Definition: MapOfVectors.h:82
bool empty() const
Definition: MapOfVectors.h:108
SiStripDbParams dbParams_
bool usingDbCache() const
static std::atomic< bool > allowCalibUpload_
std::vector< FedDescription * > FedDescriptionsV
void SiStripConfigDb::usingDatabase ( )
private

Definition at line 227 of file SiStripConfigDb.cc.

References SiStripDbParams::addPartition(), SiStripDbParams::clearPartitions(), SiStripDbParams::confdb(), dbParams_, TauDecayModes::dec, deviceFactory(), sistrip::dir_, factory_, corrVsCorr::filename, handleException(), cuy::ii, findQualityFiles::jj, mps_splice::line, LogTrace, sistrip::mlConfigDb_, sistrip::null_, convertSQLiteXML::ok, SiStripDbParams::partitionNames(), SiStripDbParams::partitions(), partitions(), SiStripDbParams::passwd(), callgraph::path, SiStripDbParams::path(), listBenchmarks::pattern, pickleFileParser::slash, AlCaHLTBitMon_QueryRunRegistry::string, SiStripDbParams::tnsAdmin(), dataset::user, SiStripDbParams::user(), and SiStripDbParams::usingDb().

Referenced by openDbConnection().

227  {
228 
229  // Retrieve connection params from CONFDB env. var. and override .cfg values
230  std::string user = "";
231  std::string passwd = "";
232  std::string pToPrint = "******";
233  std::string path = "";
234  DbAccess::getDbConfiguration( user, passwd, path );
235  if ( user != "" && passwd != "" && path != "" ) {
236 
237  std::stringstream ss;
238  ss << "[SiStripConfigDb::" << __func__ << "]"
239  << " Setting \"user/passwd@path\" to \""
240  << user << "/" << pToPrint << "@" << path
241  << "\" using 'CONFDB' environmental variable";
242  if ( dbParams_.user() != null_ ||
243  dbParams_.passwd() != null_ ||
244  dbParams_.path() != null_ ) {
245  ss << " (Overwriting existing value of \""
246  << dbParams_.user() << "/"
247  << pToPrint << "@"
248  << dbParams_.path()
249  << "\" read from .cfg file)";
250  }
251  edm::LogVerbatim(mlConfigDb_) << ss.str() << std::endl;
252  dbParams_.confdb( user, passwd, path );
253 
254  } else if ( dbParams_.user() != null_ &&
255  dbParams_.passwd() != null_ &&
256  dbParams_.path() != null_ ) {
257 
258  std::stringstream ss;
259  ss << "[SiStripConfigDb::" << __func__ << "]"
260  << " Setting \"user/passwd@path\" to \""
261  << dbParams_.user() << "/"
262  << pToPrint << "@"
263  << dbParams_.path()
264  << "\" using 'ConfDb' configurable read from .cfg file";
265  edm::LogVerbatim(mlConfigDb_) << ss.str();
266 
267  } else {
269  << "[SiStripConfigDb::" << __func__ << "]"
270  << " Unable to retrieve 'user/passwd@path' parameters"
271  << " from 'CONFDB' environmental variable or .cfg file"
272  << " (present value is \""
273  << user << "/"
274  << pToPrint << "@"
275  << path
276  << "\"). Aborting connection to database...";
277  return;
278  }
279 
280  // Check TNS_ADMIN environmental variable
281  std::string pattern = "TNS_ADMIN";
282  std::string tns_admin = "/afs/cern.ch/project/oracle/admin";
283  if ( getenv( pattern.c_str() ) != nullptr ) {
284  tns_admin = getenv( pattern.c_str() );
286  << "[SiStripConfigDb::" << __func__ << "]"
287  << " TNS_ADMIN is set to: \""
288  << tns_admin << "\"";
289  } else {
291  << "[SiStripConfigDb::" << __func__ << "]"
292  << " TNS_ADMIN is not set!"
293  << " Trying to use /afs and setting to: \""
294  << tns_admin << "\"";
295  }
296 
297  // Retrieve TNS_ADMIN from .cfg file and override
298  if ( !dbParams_.tnsAdmin().empty() ) {
299  std::stringstream ss;
300  ss << "[SiStripConfigDb::" << __func__ << "]"
301  << " Overriding TNS_ADMIN value using cfg file!" << std::endl
302  << " Original value : \"" << tns_admin << "\"!" << std::endl
303  << " New value : \"" << dbParams_.tnsAdmin() << "\"!";
304  tns_admin = dbParams_.tnsAdmin();
305  edm::LogVerbatim(mlConfigDb_) << ss.str();
306  }
307 
308  // Remove trailing slash and set TNS_ADMIN
309  if ( tns_admin.empty() ) { tns_admin = "."; }
310  std::string slash = tns_admin.substr( tns_admin.size()-1, 1 );
311  if ( slash == sistrip::dir_ ) { tns_admin = tns_admin.substr( 0, tns_admin.size()-1 ); }
312  setenv( pattern.c_str(), tns_admin.c_str(), 1 );
313 
314  // Check if database is found in tnsnames.ora file
315  std::string filename( tns_admin + "/tnsnames.ora" );
316  std::ifstream tnsnames_ora( filename.c_str() );
317  bool ok = false;
318  if ( tnsnames_ora.is_open() ) {
320  while ( !tnsnames_ora.eof() ) {
321  getline( tnsnames_ora, line );
322  if ( !dbParams_.path().empty() &&
323  line.find( dbParams_.path() ) != std::string::npos ) { ok = true; }
324  }
325  } else {
327  << "[SiStripConfigDb::" << __func__ << "]"
328  << " Cannot open file \""
329  << filename << "\"";
330  }
331 
332  if ( ok ) {
334  << "[SiStripConfigDb::" << __func__ << "]"
335  << " Found database account \""
336  << dbParams_.path() << "\" in file \""
337  << filename << "\"!";
338  } else {
340  << "[SiStripConfigDb::" << __func__ << "]"
341  << " Cannot find database account \""
342  << dbParams_.path() << "\" in file \""
343  << filename << "\""
344  << " Aborting connection to database...";
345  return;
346  }
347 
348  // Create device factory object
349  try {
351  << "[SiStripConfigDb::" << __func__ << "]"
352  << " Creating DeviceFactory object...";
353  factory_ = new DeviceFactory( dbParams_.user(),
354  dbParams_.passwd(),
355  dbParams_.path() );
357  << "[SiStripConfigDb::" << __func__ << "]"
358  << " Created DeviceFactory object!";
359  } catch (...) {
360  std::stringstream ss;
361  ss << "Failed to connect to database using parameters '"
362  << dbParams_.user() << "/"
363  << pToPrint << "@"
364  << dbParams_.path()
365  << "' and partitions '"
367  handleException( __func__, ss.str() );
368  return;
369  }
370 
371  // Check for valid pointer to DeviceFactory
372  if ( deviceFactory(__func__) ) {
373  std::stringstream ss;
374  ss << "[SiStripConfigDb::" << __func__ << "]"
375  << " DeviceFactory created at address 0x"
376  << std::hex << std::setw(8) << std::setfill('0') << factory_ << std::dec
377  << ", using database account with parameters '"
378  << dbParams_.user() << "/"
379  << pToPrint << "@"
380  << dbParams_.path();
381  LogTrace(mlConfigDb_) << ss.str();
382  } else {
384  << "[SiStripConfigDb::" << __func__ << "]"
385  << " NULL pointer to DeviceFactory!"
386  << " Unable to connect to database using connection parameters '"
387  << dbParams_.user() << "/"
388  << pToPrint << "@"
389  << dbParams_.path()
390  << "' and partitions '"
392  return;
393  }
394 
395  try {
396  deviceFactory(__func__)->setUsingDb( dbParams_.usingDb() );
397  } catch (...) {
398  handleException( __func__, "Attempted to 'setUsingDb'" );
399  }
400 
401  // Retrieve partition name from ENV_CMS_TK_PARTITION env. var. and override .cfg value
402  std::string partition = "ENV_CMS_TK_PARTITION";
403  if ( getenv(partition.c_str()) != nullptr ) {
404 
405  std::stringstream ss;
406  ss << "[SiStripConfigDb::" << __func__ << "]"
407  << " Setting \"partitions\" to \""
408  << getenv( partition.c_str() )
409  << "\" using 'ENV_CMS_TK_PARTITION' environmental variable";
410  if ( !dbParams_.partitionNames().empty() ) {
411  ss << " (Overwriting existing value of \""
413  << "\" read from .cfg file)";
414  }
415  edm::LogVerbatim(mlConfigDb_) << ss.str() << std::endl;
416 
417  // Build partitions from env. var.
418  std::vector<std::string> partitions = dbParams_.partitionNames( getenv( partition.c_str() ) );
419  if ( !partitions.empty() ) {
421  std::vector<std::string>::iterator ii = partitions.begin();
422  std::vector<std::string>::iterator jj = partitions.end();
423  for ( ; ii != jj; ++ii ) {
424  SiStripPartition partition( *ii );
425  dbParams_.addPartition( partition );
426  }
427  }
428 
429  } else if ( !dbParams_.partitionNames().empty() ) {
430  std::stringstream ss;
431  ss << "[SiStripConfigDb::" << __func__ << "]"
432  << " Setting \"partitions\" to \""
434  << "\" using 'PartitionName' configurables read from .cfg file";
435  edm::LogVerbatim(mlConfigDb_) << ss.str();
436  } else {
438  << "[SiStripConfigDb::" << __func__ << "]"
439  << " Unable to retrieve 'partition' parameter"
440  << " from 'CONFDB' environmental variable or .cfg file!"
441  << " Aborting connection to database...";
442  return;
443  }
444 
445  // Check if should use current state, run number or versions
446  SiStripDbParams::SiStripPartitions::iterator ip = dbParams_.partitions().begin();
447  SiStripDbParams::SiStripPartitions::iterator jp = dbParams_.partitions().end();
448  for ( ; ip != jp; ++ip ) { ip->second.update( this ); }
449 
450 }
std::string passwd() const
DeviceFactory * factory_
void partitions(std::list< std::string > &) const
static const char dir_[]
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool usingDb() const
static const char mlConfigDb_[]
const_iterator_range partitions() const
std::vector< std::string > partitionNames() const
std::string tnsAdmin() const
Container class for database partition parameters.
std::string user() const
#define LogTrace(id)
ii
Definition: cuy.py:590
std::string confdb() const
std::string path() const
SiStripDbParams dbParams_
void addPartition(const SiStripPartition &)
static const char null_[]
Definition: Constants.h:22
void SiStripConfigDb::usingDatabaseCache ( )
private

Definition at line 454 of file SiStripConfigDb.cc.

References SiStripDbParams::addPartition(), databaseCache(), dbCache_, dbParams_, TauDecayModes::dec, SiStripPartition::defaultPartitionName_, handleException(), LogTrace, sistrip::mlConfigDb_, SiStripDbParams::reset(), SiStripDbParams::sharedMemory(), SiStripPartition, groupFilesInBlocks::temp, SiStripDbParams::usingDb(), and SiStripDbParams::usingDbCache().

Referenced by openDbConnection().

454  {
455 
456  // Reset all DbParams except for those concerning database cache
458  temp = dbParams_;
459  dbParams_.reset();
460  dbParams_.usingDb( temp.usingDb() );
463 
464  // Add default partition
466 
467  // Check shared memory name from .cfg file
468  if ( dbParams_.sharedMemory().empty() ) {
469  std::stringstream ss;
470  ss << "[SiStripConfigDb::" << __func__ << "]"
471  << " Empty string for shared memory name!"
472  << " Cannot accept shared memory!";
473  edm::LogError(mlConfigDb_) << ss.str();
474  return;
475  }
476 
477  // Create database cache object
478  try {
480  << "[SiStripConfigDb::" << __func__ << "]"
481  << " Creating DbClient object...";
482  dbCache_ = new DbClient( dbParams_.sharedMemory() );
484  << "[SiStripConfigDb::" << __func__ << "]"
485  << " Created DbClient object...";
486  } catch (...) {
487  std::stringstream ss;
488  ss << "Failed to connect to database cache using shared memory name: '"
489  << dbParams_.sharedMemory() << "'!";
490  handleException( __func__, ss.str() );
491  return;
492  }
493 
494  // Check for valid pointer to DbClient object
495  if ( databaseCache(__func__) ) {
496  std::stringstream ss;
497  ss << "[SiStripConfigDb::" << __func__ << "]"
498  << " DbClient object created at address 0x"
499  << std::hex << std::setw(8) << std::setfill('0') << dbCache_ << std::dec
500  << " using shared memory name '"
501  << dbParams_.sharedMemory() << "'";
502  LogTrace(mlConfigDb_) << ss.str();
503  } else {
505  << "[SiStripConfigDb::" << __func__ << "]"
506  << " NULL pointer to DbClient object!"
507  << " Unable to connect to database cache using shared memory name '"
508  << dbParams_.sharedMemory() << "'";
509  return;
510  }
511 
512  // Try retrieve descriptions from Database Client
513  try {
514  databaseCache(__func__)->parse();
515  } catch (...) {
516  handleException( __func__, "Attempted to called DbClient::parse() method" );
517  }
518 
519 }
static const std::string defaultPartitionName_
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool usingDb() const
static const char mlConfigDb_[]
std::string sharedMemory() const
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
Container class for database connection parameters.
SiStripDbParams dbParams_
bool usingDbCache() const
DbClient * dbCache_
friend class SiStripPartition
void addPartition(const SiStripPartition &)
bool SiStripConfigDb::usingDb ( ) const
inlineprotected

Returns whether using database or xml files.

Indicates whether DB (true) or XML files (false) are used.

Definition at line 472 of file SiStripConfigDb.h.

472 { return dbParams_.usingDb(); }
bool usingDb() const
SiStripDbParams dbParams_
bool SiStripConfigDb::usingStrips ( ) const
inlineprotected

Strip-level info enabled/disabled within FED descriptions.

Indicates whether FED strip info is uploaded/downloaded.

Definition at line 475 of file SiStripConfigDb.h.

475 { return usingStrips_; }
void SiStripConfigDb::usingStrips ( bool  using_strips)
inlineprotected

Enables/disables strip-level info within FED descriptions.

Switches on/off of upload/download for FED strip info.

Definition at line 478 of file SiStripConfigDb.h.

478 { usingStrips_ = using_strips; }
void SiStripConfigDb::usingXmlFiles ( )
private

Definition at line 523 of file SiStripConfigDb.cc.

References checkFileExists(), dbParams_, TauDecayModes::dec, deviceFactory(), factory_, handleException(), LogTrace, sistrip::mlConfigDb_, SiStripDbParams::outputDcuInfoXml(), SiStripDbParams::outputFecXml(), SiStripDbParams::outputFedXml(), SiStripDbParams::outputModuleXml(), SiStripDbParams::partitions(), and SiStripDbParams::usingDb().

Referenced by openDbConnection().

523  {
525  << "[SiStripConfigDb::" << __func__ << "]"
526  << " Using XML description files...";
527 
528  // Create device factory object
529  try {
530  factory_ = new DeviceFactory();
531  } catch (...) {
532  handleException( __func__, "Attempting to create DeviceFactory for use with xml files" );
533  }
534 
535  // Check for valid pointer to DeviceFactory
536  if ( deviceFactory(__func__) ) {
537  std::stringstream ss;
538  ss << "[SiStripConfigDb::" << __func__ << "]"
539  << " DeviceFactory created at address 0x"
540  << std::hex << std::setw(8) << std::setfill('0') << factory_ << std::dec
541  << ", using XML description files";
542  LogTrace(mlConfigDb_) << ss.str();
543  } else {
545  << "[SiStripConfigDb::" << __func__ << "]"
546  << " NULL pointer to DeviceFactory!"
547  << " Unable to connect to database!";
548  return;
549  }
550 
551  try {
552  deviceFactory(__func__)->setUsingDb( dbParams_.usingDb() );
553  } catch (...) {
554  handleException( __func__, "Attempted to 'setUsingDb'" );
555  }
556 
557  // Iterate through partitions
558  SiStripDbParams::SiStripPartitions::const_iterator ip = dbParams_.partitions().begin();
559  SiStripDbParams::SiStripPartitions::const_iterator jp = dbParams_.partitions().end();
560  for ( ; ip != jp; ++ip ) {
561 
562  // Input module.xml file
563  if ( ip->second.inputModuleXml() == "" ) {
565  << "[SiStripConfigDb::" << __func__ << "]"
566  << " NULL path to input 'module.xml' file!";
567  } else {
568  if ( checkFileExists( ip->second.inputModuleXml() ) ) {
569  try {
570  deviceFactory(__func__)->addConnectionFileName( ip->second.inputModuleXml() );
571  } catch (...) {
572  handleException( __func__ );
573  }
575  << "[SiStripConfigDb::" << __func__ << "]"
576  << " Added input 'module.xml' file: " << ip->second.inputModuleXml();
577  } else {
579  << "[SiStripConfigDb::" << __func__ << "]"
580  << " No 'module.xml' file found at " << ip->second.inputModuleXml();
581  ip->second.inputModuleXml() = "";
582  }
583  }
584 
585  // Input dcuinfo.xml file
586  if ( ip->second.inputDcuInfoXml() == "" ) {
588  << "[SiStripConfigDb::" << __func__ << "]"
589  << " NULL path to input 'dcuinfo.xml' file!";
590  } else {
591  if ( checkFileExists( ip->second.inputDcuInfoXml() ) ) {
592  try {
593  deviceFactory(__func__)->addTkDcuInfoFileName( ip->second.inputDcuInfoXml() );
594  } catch (...) {
595  handleException( __func__ );
596  }
598  << "[SiStripConfigDb::" << __func__ << "]"
599  << " Added 'dcuinfo.xml' file: " << ip->second.inputDcuInfoXml();
600  } else {
602  << "[SiStripConfigDb::" << __func__ << "]"
603  << " No 'dcuinfo.xml' file found at " << ip->second.inputDcuInfoXml();
604  ip->second.inputDcuInfoXml() = "";
605  }
606  }
607 
608  // Input FEC xml files
609  if ( ip->second.inputFecXml().empty() ) {
611  << "[SiStripConfigDb::" << __func__ << "]"
612  << " NULL paths to input 'fec.xml' files!";
613  } else {
614  std::vector<std::string>::iterator iter = ip->second.inputFecXml().begin();
615  for ( ; iter != ip->second.inputFecXml().end(); iter++ ) {
616  if ( *iter == "" ) {
618  << "[SiStripConfigDb::" << __func__ << "]"
619  << " NULL path to input 'fec.xml' file!";
620  } else {
621  if ( checkFileExists( *iter ) ) {
622  try {
623  deviceFactory(__func__)->addFecFileName( *iter );
624  } catch (...) { handleException( __func__ ); }
626  << "[SiStripConfigDb::" << __func__ << "]"
627  << " Added 'fec.xml' file: " << *iter;
628  } else {
630  << "[SiStripConfigDb::" << __func__ << "]"
631  << " No 'fec.xml' file found at " << *iter;
632  *iter = "";
633  }
634  }
635  }
636  }
637 
638  // Input FED xml files
639  if ( ip->second.inputFedXml().empty() ) {
641  << "[SiStripConfigDb::" << __func__ << "]"
642  << " NULL paths to input 'fed.xml' files!";
643  } else {
644  std::vector<std::string>::iterator iter = ip->second.inputFedXml().begin();
645  for ( ; iter != ip->second.inputFedXml().end(); iter++ ) {
646  if ( *iter == "" ) {
648  << "[SiStripConfigDb::" << __func__ << "]"
649  << " NULL path to input 'fed.xml' file!";
650  } else {
651  if ( checkFileExists( *iter ) ) {
652  try {
653  deviceFactory(__func__)->addFedFileName( *iter );
654  } catch (...) {
655  handleException( __func__ );
656  }
658  << "[SiStripConfigDb::" << __func__ << "]"
659  << " Added 'fed.xml' file: " << *iter;
660  } else {
662  << "[SiStripConfigDb::" << __func__ << "]"
663  << " No 'fed.xml' file found at " << *iter;
664  *iter = "";
665  }
666  }
667  }
668  }
669 
670  }
671 
672  // Output module.xml file
673  if ( dbParams_.outputModuleXml() == "" ) {
675  << "[SiStripConfigDb::" << __func__ << "]"
676  << " NULL path to output 'module.xml' file!"
677  << " Setting to '/tmp/module.xml'...";
678  dbParams_.outputModuleXml() = "/tmp/module.xml";
679  } else {
680  try {
681  ConnectionFactory* factory = deviceFactory(__func__);
682  factory->setOutputFileName( dbParams_.outputModuleXml() );
683  } catch (...) {
684  handleException( __func__, "Problems setting output 'module.xml' file!" );
685  }
686  }
687 
688  // Output dcuinfo.xml file
689  if ( dbParams_.outputDcuInfoXml() == "" ) {
691  << "[SiStripConfigDb::" << __func__ << "]"
692  << " NULL path to output 'dcuinfo.xml' file!"
693  << " Setting to '/tmp/dcuinfo.xml'...";
694  dbParams_.outputModuleXml() = "/tmp/dcuinfo.xml";
695  } else {
696  try {
697  TkDcuInfoFactory* factory = deviceFactory(__func__);
698  factory->setOutputFileName( dbParams_.outputDcuInfoXml() );
699  } catch (...) {
700  handleException( __func__, "Problems setting output 'dcuinfo.xml' file!" );
701  }
702  }
703 
704  // Output fec.xml file
705  if ( dbParams_.outputFecXml() == "" ) {
707  << "[SiStripConfigDb::" << __func__ << "]"
708  << " NULL path to output 'fec.xml' file!"
709  << " Setting to '/tmp/fec.xml'...";
710  dbParams_.outputFecXml() = "/tmp/fec.xml";
711  } else {
712  try {
713  FecDeviceFactory* factory = deviceFactory(__func__);
714  factory->setOutputFileName( dbParams_.outputFecXml() );
715  } catch (...) {
716  handleException( __func__, "Problems setting output 'fec.xml' file!" );
717  }
718  }
719 
720  // Output fed.xml file
721  if ( dbParams_.outputFedXml() == "" ) {
723  << "[SiStripConfigDb::" << __func__ << "]"
724  << " NULL path to output 'fed.xml' file!"
725  << " Setting to '/tmp/fed.xml'...";
726  dbParams_.outputFedXml() = "/tmp/fed.xml";
727  } else {
728  try {
729  Fed9U::Fed9UDeviceFactory* factory = deviceFactory(__func__);
730  factory->setOutputFileName( dbParams_.outputFedXml() );
731  } catch (...) {
732  handleException( __func__, "Problems setting output 'fed.xml' file!" );
733  }
734  }
735 
736 }
DeviceFactory * factory_
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool checkFileExists(const std::string &path)
bool usingDb() const
static const char mlConfigDb_[]
const_iterator_range partitions() const
std::string outputModuleXml() const
#define LogTrace(id)
std::string outputFedXml() const
SiStripDbParams dbParams_
std::string outputFecXml() const
std::string outputDcuInfoXml() const

Friends And Related Function Documentation

friend class ApvTimingHistosUsingDb
friend

Definition at line 89 of file SiStripConfigDb.h.

friend class CalibrationHistosUsingDb
friend

Definition at line 98 of file SiStripConfigDb.h.

friend class CommissioningHistosUsingDb
friend

Definition at line 86 of file SiStripConfigDb.h.

friend class DaqScopeModeHistosUsingDb
friend

Definition at line 99 of file SiStripConfigDb.h.

friend class FastFedCablingHistosUsingDb
friend

Definition at line 87 of file SiStripConfigDb.h.

friend class FedCablingHistosUsingDb
friend

Definition at line 88 of file SiStripConfigDb.h.

friend class FineDelayHistosUsingDb
friend

Definition at line 97 of file SiStripConfigDb.h.

friend class LatencyHistosUsingDb
friend

Definition at line 96 of file SiStripConfigDb.h.

friend class NoiseHistosUsingDb
friend

Definition at line 94 of file SiStripConfigDb.h.

friend class OptoScanHistosUsingDb
friend

Definition at line 90 of file SiStripConfigDb.h.

friend class PedestalsHistosUsingDb
friend

Definition at line 91 of file SiStripConfigDb.h.

friend class PedsFullNoiseHistosUsingDb
friend

Definition at line 92 of file SiStripConfigDb.h.

friend class PedsOnlyHistosUsingDb
friend

Definition at line 93 of file SiStripConfigDb.h.

friend class SiStripCommissioningDbClient
friend

Definition at line 84 of file SiStripConfigDb.h.

Definition at line 85 of file SiStripConfigDb.h.

friend class SiStripCondObjBuilderFromDb
friend

Definition at line 79 of file SiStripConfigDb.h.

friend class SiStripFedCablingBuilderFromDb
friend

Definition at line 76 of file SiStripConfigDb.h.

friend class SiStripNoiseBuilderFromDb
friend

Definition at line 78 of file SiStripConfigDb.h.

friend class SiStripPartition
friend

Definition at line 102 of file SiStripConfigDb.h.

Referenced by usingDatabaseCache().

friend class SiStripPedestalsBuilderFromDb
friend

Definition at line 77 of file SiStripConfigDb.h.

friend class SiStripPsuDetIdMap
friend

Definition at line 80 of file SiStripConfigDb.h.

friend class testSiStripConfigDb
friend

Definition at line 103 of file SiStripConfigDb.h.

friend class VpspScanHistosUsingDb
friend

Definition at line 95 of file SiStripConfigDb.h.

Member Data Documentation

std::atomic< bool > SiStripConfigDb::allowCalibUpload_ { false }
staticprivate

Definition at line 459 of file SiStripConfigDb.h.

AnalysisDescriptions SiStripConfigDb::analyses_
private

Analysis descriptions for given commissioning run.

Definition at line 420 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::apvDevices_
private

Cache for devices of given type.

Definition at line 423 of file SiStripConfigDb.h.

std::atomic< uint32_t > SiStripConfigDb::cntr_ {0}
staticprivate

Static counter of instances of this class.

Definition at line 457 of file SiStripConfigDb.h.

Referenced by SiStripConfigDb(), and ~SiStripConfigDb().

FedConnections SiStripConfigDb::connections_
private

FED-FEC connection descriptions.

Definition at line 408 of file SiStripConfigDb.h.

DbClient* SiStripConfigDb::dbCache_
private

Pointer to the DbClient class.

Definition at line 398 of file SiStripConfigDb.h.

Referenced by closeDbConnection(), databaseCache(), and usingDatabaseCache().

SiStripDbParams SiStripConfigDb::dbParams_
private

Instance of struct that holds all DB connection parameters.

Definition at line 401 of file SiStripConfigDb.h.

Referenced by openDbConnection(), runs(), SiStripConfigDb(), usingDatabase(), usingDatabaseCache(), and usingXmlFiles().

DcuDetIds SiStripConfigDb::dcuDetIds_
private

DcuId-DetId map (map of TkDcuInfo objects).

Definition at line 417 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::dcuDevices_
private

Cache for devices of given type.

Definition at line 429 of file SiStripConfigDb.h.

DeviceDescriptions SiStripConfigDb::devices_
private

Device descriptions (including DCUs).

Definition at line 411 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::dohDevices_
private

Cache for devices of given type.

Definition at line 438 of file SiStripConfigDb.h.

DeviceFactory* SiStripConfigDb::factory_
private

Pointer to the DeviceFactory API.

Definition at line 395 of file SiStripConfigDb.h.

Referenced by closeDbConnection(), deviceFactory(), usingDatabase(), and usingXmlFiles().

FedIds SiStripConfigDb::fedIds_
private

FED ids.

Definition at line 444 of file SiStripConfigDb.h.

Referenced by clearLocalCache().

FedDescriptions SiStripConfigDb::feds_
private

Fed9U descriptions.

Definition at line 414 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::lldDevices_
private

Cache for devices of given type.

Definition at line 432 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::muxDevices_
private

Cache for devices of given type.

Definition at line 426 of file SiStripConfigDb.h.

bool SiStripConfigDb::openConnection_
private

Definition at line 454 of file SiStripConfigDb.h.

Referenced by closeDbConnection(), and openDbConnection().

DeviceDescriptionsV SiStripConfigDb::pllDevices_
private

Cache for devices of given type.

Definition at line 435 of file SiStripConfigDb.h.

DeviceDescriptionsV SiStripConfigDb::typedDevices_
private

Cache for devices of given type.

Definition at line 441 of file SiStripConfigDb.h.

Referenced by clearLocalCache().

bool SiStripConfigDb::usingStrips_
private

Switch to enable/disable transfer of strip information.

Definition at line 451 of file SiStripConfigDb.h.