CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQM/SiStripCommissioningDbClients/plugins/SiStripCommissioningOfflineDbClient.cc

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripCommissioningOfflineDbClient.cc,v 1.26 2010/04/21 14:26:18 dstrom 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/PedsFullNoiseHistosUsingDb.h"
00015 #include "DQM/SiStripCommissioningDbClients/interface/LatencyHistosUsingDb.h"
00016 #include "DQM/SiStripCommissioningDbClients/interface/FineDelayHistosUsingDb.h"
00017 #include "DQM/SiStripCommissioningDbClients/interface/CalibrationHistosUsingDb.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.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 {
00032   LogTrace(mlDqmClient_)
00033     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00034     << " Constructing object...";
00035   if ( !uploadConf_ ) {
00036     edm::LogWarning(mlDqmClient_) 
00037       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00038       << " ===> TEST only! No hardware configurations"
00039       << " will be uploaded to the DB...";
00040   }
00041   if ( !uploadAnal_ ) {
00042     edm::LogWarning(mlDqmClient_) 
00043       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00044       << " ===> TEST only! No analysis descriptions"
00045       << " will be uploaded to the DB...";
00046   }
00047   
00048 }
00049 
00050 // -----------------------------------------------------------------------------
00051 // 
00052 SiStripCommissioningOfflineDbClient::~SiStripCommissioningOfflineDbClient() {
00053   LogTrace(mlDqmClient_)
00054     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00055     << " Destructing object...";
00056 }
00057 
00058 // -----------------------------------------------------------------------------
00059 // 
00060 void SiStripCommissioningOfflineDbClient::createHistos( const edm::ParameterSet& pset, const edm::EventSetup& setup) {
00061 
00062   // Check pointer
00063   if ( histos_ ) {
00064     edm::LogError(mlDqmClient_)
00065       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00066       << " CommissioningHistogram object already exists!"
00067       << " Aborting...";
00068     return;
00069   } 
00070 
00071   // Check pointer to BEI
00072   // is this needed here? bei_ = edm::Service<DQMStore>().operator->();
00073   if ( !bei_ ) {
00074     edm::LogError(mlDqmClient_)
00075       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00076       << " NULL pointer to DQMStore!";
00077     return;
00078   }
00079 
00080   // Create DB connection
00081   SiStripConfigDb* db = edm::Service<SiStripConfigDb>().operator->(); //@@ NOT GUARANTEED TO BE THREAD SAFE! 
00082   LogTrace(mlCabling_) 
00083     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00084     << " Nota bene: using the SiStripConfigDb API"
00085     << " as a \"service\" does not presently guarantee"
00086     << " thread-safe behaviour!...";
00087   
00088   // Check DB connection
00089   if ( !db ) {
00090     edm::LogError(mlCabling_) 
00091       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00092       << " NULL pointer to SiStripConfigDb!"
00093       << " Aborting...";
00094     return;
00095   } 
00096   
00097   // Create corresponding "commissioning histograms" object 
00098   if      ( runType_ == sistrip::FAST_CABLING ) { histos_ = new FastFedCablingHistosUsingDb( pset, bei_, db ); }
00099   else if ( runType_ == sistrip::APV_TIMING )   { histos_ = new ApvTimingHistosUsingDb( pset, bei_, db ); }
00100   else if ( runType_ == sistrip::OPTO_SCAN )    { histos_ = new OptoScanHistosUsingDb( pset, bei_, db ); }
00101   else if ( runType_ == sistrip::VPSP_SCAN )    { histos_ = new VpspScanHistosUsingDb( pset, bei_, db ); }
00102   else if ( runType_ == sistrip::PEDESTALS )    { histos_ = new PedestalsHistosUsingDb( pset, bei_, db ); }
00103   else if ( runType_ == sistrip::PEDS_ONLY )    { histos_ = new PedsOnlyHistosUsingDb( pset, bei_, db ); }
00104   else if ( runType_ == sistrip::PEDS_FULL_NOISE ) { histos_ = new PedsFullNoiseHistosUsingDb( pset, bei_, db ); }
00105   else if ( runType_ == sistrip::NOISE )        { histos_ = new NoiseHistosUsingDb( pset, bei_, db ); }
00106   else if ( runType_ == sistrip::APV_LATENCY )  { histos_ = new LatencyHistosUsingDb( pset, bei_, db ); }
00107   else if ( runType_ == sistrip::FINE_DELAY )   { histos_ = new FineDelayHistosUsingDb( pset, bei_, db ); }
00108   else if ( runType_ == sistrip::CALIBRATION ||
00109             runType_ == sistrip::CALIBRATION_DECO ||
00110             runType_ == sistrip::CALIBRATION_SCAN ||
00111             runType_ == sistrip::CALIBRATION_SCAN_DECO)
00112                                                 { histos_ = new CalibrationHistosUsingDb( pset, bei_, db, runType_ ); }
00113   else if ( runType_ == sistrip::UNDEFINED_RUN_TYPE ) { 
00114     histos_ = 0; 
00115     edm::LogError(mlDqmClient_)
00116       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00117       << " Undefined run type!";
00118     return;
00119   } else if ( runType_ == sistrip::UNKNOWN_RUN_TYPE ) {
00120     histos_ = 0;
00121     edm::LogError(mlDqmClient_)
00122       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00123       << " Unknown run type!";
00124     return;
00125   }
00126   histos_->configure(pset,setup);
00127 
00128   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
00129   if ( tmp ) { 
00130     tmp->doUploadConf( uploadConf_ ); 
00131     tmp->doUploadAnal( uploadAnal_ ); 
00132     std::stringstream ss;
00133     ss << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]" 
00134        << std::endl
00135        << " Uploading hardware configurations?    : " 
00136        << ( tmp->doUploadConf() ? "true" : "false" )
00137        << std::endl
00138        << " Uploading calibrations from analysis? : " 
00139        << ( tmp->doUploadAnal() ? "true" : "false" )
00140        << std::endl;
00141     edm::LogVerbatim(mlDqmClient_) << ss.str();
00142   } else {
00143     edm::LogError(mlDqmClient_) 
00144       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00145       << " NULL pointer to CommissioningHistosUsingDb!";
00146   }
00147 
00148 }
00149 
00150 // -----------------------------------------------------------------------------
00151 // 
00152 void SiStripCommissioningOfflineDbClient::uploadToConfigDb() {
00153   edm::LogVerbatim(mlDqmClient_)
00154     << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00155     << " Uploading parameters to database...";
00156   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
00157   if ( tmp ) { 
00158     tmp->uploadToConfigDb(); 
00159     edm::LogVerbatim(mlDqmClient_)
00160       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00161       << " Uploaded parameters to database!";
00162   } else {
00163     edm::LogError(mlDqmClient_)
00164       << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
00165       << " NULL pointer to CommissioningHistosUsingDb object!"
00166       << " Upload aborted!...";
00167   }
00168 }