Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:32

0001 
0002 #include "DQM/SiStripCommissioningDbClients/plugins/SiStripCommissioningOfflineDbClient.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0005 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0006 #include "DQM/SiStripCommissioningDbClients/interface/FastFedCablingHistosUsingDb.h"
0007 #include "DQM/SiStripCommissioningDbClients/interface/ApvTimingHistosUsingDb.h"
0008 #include "DQM/SiStripCommissioningDbClients/interface/OptoScanHistosUsingDb.h"
0009 #include "DQM/SiStripCommissioningDbClients/interface/VpspScanHistosUsingDb.h"
0010 #include "DQM/SiStripCommissioningDbClients/interface/PedestalsHistosUsingDb.h"
0011 #include "DQM/SiStripCommissioningDbClients/interface/PedsOnlyHistosUsingDb.h"
0012 #include "DQM/SiStripCommissioningDbClients/interface/NoiseHistosUsingDb.h"
0013 #include "DQM/SiStripCommissioningDbClients/interface/PedsFullNoiseHistosUsingDb.h"
0014 #include "DQM/SiStripCommissioningDbClients/interface/DaqScopeModeHistosUsingDb.h"
0015 #include "DQM/SiStripCommissioningDbClients/interface/LatencyHistosUsingDb.h"
0016 #include "DQM/SiStripCommissioningDbClients/interface/FineDelayHistosUsingDb.h"
0017 #include "DQM/SiStripCommissioningDbClients/interface/CalibrationHistosUsingDb.h"
0018 #include "FWCore/ServiceRegistry/interface/Service.h"
0019 #include "DQMServices/Core/interface/DQMStore.h"
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
0022 
0023 using namespace sistrip;
0024 
0025 // -----------------------------------------------------------------------------
0026 //
0027 SiStripCommissioningOfflineDbClient::SiStripCommissioningOfflineDbClient(const edm::ParameterSet& pset)
0028     : SiStripCommissioningOfflineClient(pset),
0029       uploadAnal_(pset.getUntrackedParameter<bool>("UploadAnalyses", false)),
0030       uploadConf_(pset.getUntrackedParameter<bool>("UploadHwConfig", false)),
0031       tTopoToken_{esConsumes<edm::Transition::BeginRun>()},
0032       tkGeomToken_{esConsumes<edm::Transition::BeginRun>()} {
0033   LogTrace(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0034                          << " Constructing object...";
0035   if (!uploadConf_) {
0036     edm::LogWarning(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0037                                   << " ===> TEST only! No hardware configurations"
0038                                   << " will be uploaded to the DB...";
0039   }
0040   if (!uploadAnal_) {
0041     edm::LogWarning(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0042                                   << " ===> TEST only! No analysis descriptions"
0043                                   << " will be uploaded to the DB...";
0044   }
0045 }
0046 
0047 // -----------------------------------------------------------------------------
0048 //
0049 SiStripCommissioningOfflineDbClient::~SiStripCommissioningOfflineDbClient() {
0050   LogTrace(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0051                          << " Destructing object...";
0052 }
0053 
0054 // -----------------------------------------------------------------------------
0055 //
0056 void SiStripCommissioningOfflineDbClient::createHistos(const edm::ParameterSet& pset, const edm::EventSetup& setup) {
0057   // Check pointer
0058   if (histos_) {
0059     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0060                                 << " CommissioningHistogram object already exists!"
0061                                 << " Aborting...";
0062     return;
0063   }
0064 
0065   // Check pointer to BEI
0066   // is this needed here? bei_ = edm::Service<DQMStore>().operator->();
0067   if (!bei_) {
0068     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0069                                 << " NULL pointer to DQMStore!";
0070     return;
0071   }
0072 
0073   // Create DB connection
0074   SiStripConfigDb* db = edm::Service<SiStripConfigDb>().operator->();  //@@ NOT GUARANTEED TO BE THREAD SAFE!
0075   LogTrace(mlCabling_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0076                        << " Nota bene: using the SiStripConfigDb API"
0077                        << " as a \"service\" does not presently guarantee"
0078                        << " thread-safe behaviour!...";
0079 
0080   // Check DB connection
0081   if (!db) {
0082     edm::LogError(mlCabling_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0083                               << " NULL pointer to SiStripConfigDb!"
0084                               << " Aborting...";
0085     return;
0086   }
0087 
0088   // Create corresponding "commissioning histograms" object
0089   if (runType_ == sistrip::FAST_CABLING) {
0090     histos_ = new FastFedCablingHistosUsingDb(pset, bei_, db, tTopoToken_);
0091   } else if (runType_ == sistrip::APV_TIMING) {
0092     histos_ = new ApvTimingHistosUsingDb(pset, bei_, db, tTopoToken_);
0093   } else if (runType_ == sistrip::OPTO_SCAN) {
0094     histos_ = new OptoScanHistosUsingDb(pset, bei_, db, tTopoToken_);
0095   } else if (runType_ == sistrip::VPSP_SCAN) {
0096     histos_ = new VpspScanHistosUsingDb(pset, bei_, db, tTopoToken_);
0097   } else if (runType_ == sistrip::PEDESTALS) {
0098     histos_ = new PedestalsHistosUsingDb(pset, bei_, db, tTopoToken_);
0099   } else if (runType_ == sistrip::PEDS_ONLY) {
0100     histos_ = new PedsOnlyHistosUsingDb(pset, bei_, db, tTopoToken_);
0101   } else if (runType_ == sistrip::PEDS_FULL_NOISE) {
0102     histos_ = new PedsFullNoiseHistosUsingDb(pset, bei_, db, tTopoToken_);
0103   } else if (runType_ == sistrip::NOISE) {
0104     histos_ = new NoiseHistosUsingDb(pset, bei_, db, tTopoToken_);
0105   } else if (runType_ == sistrip::APV_LATENCY) {
0106     histos_ = new LatencyHistosUsingDb(pset, bei_, db, tTopoToken_);
0107   } else if (runType_ == sistrip::FINE_DELAY) {
0108     histos_ = new FineDelayHistosUsingDb(pset, bei_, db, tTopoToken_, tkGeomToken_);
0109   } else if (runType_ == sistrip::CALIBRATION || runType_ == sistrip::CALIBRATION_DECO ||
0110              runType_ == sistrip::CALIBRATION_SCAN || runType_ == sistrip::CALIBRATION_SCAN_DECO) {
0111     histos_ = new CalibrationHistosUsingDb(pset, bei_, db, tTopoToken_, runType_);
0112   } else if (runType_ == sistrip::DAQ_SCOPE_MODE) {
0113     histos_ = new DaqScopeModeHistosUsingDb(pset, bei_, db, tTopoToken_);
0114   } else if (runType_ == sistrip::UNDEFINED_RUN_TYPE) {
0115     histos_ = nullptr;
0116     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0117                                 << " Undefined run type!";
0118     return;
0119   } else if (runType_ == sistrip::UNKNOWN_RUN_TYPE) {
0120     histos_ = nullptr;
0121     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0122                                 << " Unknown run type!";
0123     return;
0124   }
0125   histos_->configure(pset, setup);
0126 
0127   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
0128   if (tmp) {
0129     tmp->doUploadConf(uploadConf_);
0130     tmp->doUploadAnal(uploadAnal_);
0131     std::stringstream ss;
0132     ss << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]" << std::endl
0133        << " Uploading hardware configurations?    : " << (tmp->doUploadConf() ? "true" : "false") << std::endl
0134        << " Uploading calibrations from analysis? : " << (tmp->doUploadAnal() ? "true" : "false") << std::endl;
0135     edm::LogVerbatim(mlDqmClient_) << ss.str();
0136   } else {
0137     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0138                                 << " NULL pointer to CommissioningHistosUsingDb!";
0139   }
0140 }
0141 
0142 // -----------------------------------------------------------------------------
0143 //
0144 void SiStripCommissioningOfflineDbClient::uploadToConfigDb() {
0145   edm::LogVerbatim(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0146                                  << " Uploading parameters to database...";
0147   CommissioningHistosUsingDb* tmp = dynamic_cast<CommissioningHistosUsingDb*>(histos_);
0148   if (tmp) {
0149     tmp->uploadToConfigDb();
0150     edm::LogVerbatim(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0151                                    << " Uploaded parameters to database!";
0152   } else {
0153     edm::LogError(mlDqmClient_) << "[SiStripCommissioningOfflineDbClient::" << __func__ << "]"
0154                                 << " NULL pointer to CommissioningHistosUsingDb object!"
0155                                 << " Upload aborted!...";
0156   }
0157 }