CMS 3D CMS Logo

SiStripCommissioningOfflineDbClient.cc

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripCommissioningOfflineDbClient.cc,v 1.18 2008/07/09 16:27:48 bainbrid Exp $
00002 
00003 #include "DQM/SiStripCommissioningDbClients/plugins/SiStripCommissioningOfflineDbClient.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00005 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00006 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
00007 #include "DQM/SiStripCommissioningDbClients/interface/FastFedCablingHistosUsingDb.h"
00008 #include "DQM/SiStripCommissioningDbClients/interface/ApvTimingHistosUsingDb.h"
00009 #include "DQM/SiStripCommissioningDbClients/interface/OptoScanHistosUsingDb.h"
00010 #include "DQM/SiStripCommissioningDbClients/interface/VpspScanHistosUsingDb.h"
00011 #include "DQM/SiStripCommissioningDbClients/interface/PedestalsHistosUsingDb.h"
00012 #include "DQM/SiStripCommissioningDbClients/interface/PedsOnlyHistosUsingDb.h"
00013 #include "DQM/SiStripCommissioningDbClients/interface/NoiseHistosUsingDb.h"
00014 #include "DQM/SiStripCommissioningDbClients/interface/LatencyHistosUsingDb.h"
00015 #include "DQM/SiStripCommissioningDbClients/interface/FineDelayHistosUsingDb.h"
00016 #include "DQM/SiStripCommissioningDbClients/interface/CalibrationHistosUsingDb.h"
00017 #include "DQMServices/Core/interface/DQMStore.h"
00018 #include "DQMServices/Core/interface/DQMOldReceiver.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
00022 
00023 using namespace sistrip;
00024 
00025 // -----------------------------------------------------------------------------
00026 // 
00027 SiStripCommissioningOfflineDbClient::SiStripCommissioningOfflineDbClient( const edm::ParameterSet& pset ) 
00028   : SiStripCommissioningOfflineClient(pset),
00029     uploadAnal_( pset.getUntrackedParameter<bool>("UploadAnalyses",false) ),
00030     uploadConf_( pset.getUntrackedParameter<bool>("UploadHwConfig",false) ),
00031     uploadFecSettings_( pset.getUntrackedParameter<bool>("UploadFecSettings",true) ),
00032     uploadFedSettings_( pset.getUntrackedParameter<bool>("UploadFedSettings",true) ),
00033     disableDevices_( pset.getUntrackedParameter<bool>("DisableDevices",false) )
00034 {
00035   LogTrace(mlDqmClient_)
00036     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00037     << " Constructing object...";
00038   if ( !uploadConf_ ) {
00039     edm::LogWarning(mlDqmClient_) 
00040       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00041       << " ===> TEST only! No hardware configurations"
00042       << " will be uploaded to the DB...";
00043   }
00044   if ( !uploadAnal_ ) {
00045     edm::LogWarning(mlDqmClient_) 
00046       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00047       << " ===> TEST only! No analysis descriptions"
00048       << " will be uploaded to the DB...";
00049   }
00050   
00051 }
00052 
00053 // -----------------------------------------------------------------------------
00054 // 
00055 SiStripCommissioningOfflineDbClient::~SiStripCommissioningOfflineDbClient() {
00056   LogTrace(mlDqmClient_)
00057     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00058     << " Destructing object...";
00059 }
00060 
00061 // -----------------------------------------------------------------------------
00062 // 
00063 void SiStripCommissioningOfflineDbClient::createHistos( const edm::ParameterSet& pset, const edm::EventSetup& setup) {
00064 
00065   // Check pointer
00066   if ( histos_ ) {
00067     edm::LogError(mlDqmClient_)
00068       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00069       << " CommissioningHistogram object already exists!"
00070       << " Aborting...";
00071     return;
00072   } 
00073 
00074   // Check pointer to MUI
00075   if ( !mui_ ) {
00076     edm::LogError(mlDqmClient_)
00077       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00078       << " NULL pointer to DQMOldReceiver!";
00079     return;
00080   }
00081 
00082   // Check pointer to BEI
00083   DQMStore* bei = mui_->getBEInterface();
00084   if ( !bei ) {
00085     edm::LogError(mlDqmClient_)
00086       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00087       << " NULL pointer to DQMStore!";
00088     return;
00089   }
00090 
00091   // Create DB connection
00092   SiStripConfigDb* db = edm::Service<SiStripConfigDb>().operator->(); //@@ NOT GUARANTEED TO BE THREAD SAFE! 
00093   LogTrace(mlCabling_) 
00094     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00095     << " Nota bene: using the SiStripConfigDb API"
00096     << " as a \"service\" does not presently guarantee"
00097     << " thread-safe behaviour!...";
00098   
00099   // Check DB connection
00100   if ( !db ) {
00101     edm::LogError(mlCabling_) 
00102       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00103       << " NULL pointer to SiStripConfigDb!"
00104       << " Aborting...";
00105     return;
00106   } 
00107   
00108   // Create corresponding "commissioning histograms" object 
00109   if      ( runType_ == sistrip::FAST_CABLING ) { histos_ = new FastFedCablingHistosUsingDb( mui_, db ); }
00110   else if ( runType_ == sistrip::APV_TIMING )   { histos_ = new ApvTimingHistosUsingDb( mui_, db ); }
00111   else if ( runType_ == sistrip::OPTO_SCAN )    { histos_ = new OptoScanHistosUsingDb( mui_, db ); }
00112   else if ( runType_ == sistrip::VPSP_SCAN )    { histos_ = new VpspScanHistosUsingDb( mui_, db ); }
00113   else if ( runType_ == sistrip::PEDESTALS )    { histos_ = new PedestalsHistosUsingDb( mui_, db ); }
00114   else if ( runType_ == sistrip::PEDS_ONLY )    { histos_ = new PedsOnlyHistosUsingDb( mui_, db ); }
00115   else if ( runType_ == sistrip::NOISE )        { histos_ = new NoiseHistosUsingDb( mui_, db ); }
00116   else if ( runType_ == sistrip::APV_LATENCY )  { histos_ = new LatencyHistosUsingDb( mui_, db ); }
00117   else if ( runType_ == sistrip::FINE_DELAY )   { histos_ = new FineDelayHistosUsingDb( mui_, db ); }
00118   else if ( runType_ == sistrip::CALIBRATION ||
00119             runType_ == sistrip::CALIBRATION_DECO ||
00120             runType_ == sistrip::CALIBRATION_SCAN ||
00121             runType_ == sistrip::CALIBRATION_SCAN_DECO)
00122                                                 { histos_ = new CalibrationHistosUsingDb( mui_, db, runType_ ); }
00123   else if ( runType_ == sistrip::UNDEFINED_RUN_TYPE ) { 
00124     histos_ = 0; 
00125     edm::LogError(mlDqmClient_)
00126       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00127       << " Undefined run type!";
00128     return;
00129   } else if ( runType_ == sistrip::UNKNOWN_RUN_TYPE ) {
00130     histos_ = 0;
00131     edm::LogError(mlDqmClient_)
00132       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00133       << " Unknown run type!";
00134     return;
00135   }
00136   histos_->configure(pset,setup);
00137 
00138   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
00139   if ( tmp ) { 
00140     tmp->doUploadConf( uploadConf_ ); 
00141     tmp->doUploadAnal( uploadAnal_ ); 
00142     tmp->disableDevices( disableDevices_ );
00143     std::stringstream ss;
00144     ss << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]" 
00145        << std::endl
00146        << " Uploading hardware configurations?    : " 
00147        << ( tmp->doUploadConf() ? "true" : "false" )
00148        << std::endl
00149        << " Uploading calibrations from analysis? : " 
00150        << ( tmp->doUploadAnal() ? "true" : "false" )
00151        << std::endl
00152        << " Disable problematic devices?          : " 
00153        << ( tmp->disableDevices() ? "true" : "false" );
00154     edm::LogVerbatim(mlDqmClient_) << ss.str();
00155   } else {
00156     edm::LogError(mlDqmClient_) 
00157       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00158       << " NULL pointer to CommissioningHistosUsingDb!";
00159   }
00160   
00161   // Flags specific to APV timing task 
00162   ApvTimingHistosUsingDb* temp = dynamic_cast<ApvTimingHistosUsingDb*>(histos_);
00163   if ( temp ) { 
00164     temp->uploadPllSettings( uploadFecSettings_ );
00165     temp->uploadFedSettings( uploadFedSettings_ );
00166   }
00167   
00168 }
00169 
00170 // -----------------------------------------------------------------------------
00171 // 
00172 void SiStripCommissioningOfflineDbClient::uploadToConfigDb() {
00173   edm::LogVerbatim(mlDqmClient_)
00174     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00175     << " Uploading parameters to database...";
00176   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
00177   if ( tmp ) { 
00178     tmp->uploadToConfigDb(); 
00179     edm::LogVerbatim(mlDqmClient_)
00180       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00181       << " Uploaded parameters to database!";
00182   } else {
00183     edm::LogError(mlDqmClient_)
00184       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00185       << " NULL pointer to CommissioningHistosUsingDb object!"
00186       << " Upload aborted!...";
00187   }
00188 }

Generated on Tue Jun 9 17:33:29 2009 for CMSSW by  doxygen 1.5.4