Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:23

0001 #include "Alignment/CommonAlignment/interface/Alignable.h"
0002 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
0003 #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h"
0004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0005 #include "CondFormats/Alignment/interface/Alignments.h"
0006 #include "CondFormats/Alignment/interface/SurveyErrors.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 
0010 #include "Alignment/SurveyAnalysis/plugins/SurveyDBUploader.h"
0011 
0012 SurveyDBUploader::SurveyDBUploader(const edm::ParameterSet& cfg)
0013     : theValueRcd(cfg.getParameter<std::string>("valueRcd")),
0014       theErrorExtendedRcd(cfg.getParameter<std::string>("errorRcd")),
0015       theValues(nullptr),
0016       theErrors(nullptr) {}
0017 
0018 void SurveyDBUploader::endJob() {
0019   SurveyValues theValues;
0020   SurveyErrors theErrors;
0021 
0022   theValues.m_align.reserve(65536);
0023   theErrors.m_surveyErrors.reserve(65536);
0024 
0025   getSurveyInfo(SurveyInputBase::detector());
0026 
0027   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0028 
0029   if (poolDbService.isAvailable()) {
0030     poolDbService->writeOneIOV<SurveyValues>(theValues, poolDbService->currentTime(), theValueRcd);
0031     poolDbService->writeOneIOV<SurveyErrors>(theErrors, poolDbService->currentTime(), theErrorExtendedRcd);
0032   } else
0033     throw cms::Exception("ConfigError") << "PoolDBOutputService is not available";
0034 }
0035 
0036 void SurveyDBUploader::getSurveyInfo(const Alignable* ali) {
0037   const auto& comp = ali->components();
0038 
0039   unsigned int nComp = comp.size();
0040 
0041   for (unsigned int i = 0; i < nComp; ++i)
0042     getSurveyInfo(comp[i]);
0043 
0044   const SurveyDet* survey = ali->survey();
0045 
0046   const align::PositionType& pos = survey->position();
0047   const align::RotationType& rot = survey->rotation();
0048 
0049   SurveyValue value(CLHEP::Hep3Vector(pos.x(), pos.y(), pos.z()),
0050                     CLHEP::HepRotation(CLHEP::HepRep3x3(
0051                         rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz())),
0052                     ali->id());
0053 
0054   SurveyError error(ali->alignableObjectId(), ali->id(), survey->errors());
0055 
0056   theValues->m_align.push_back(value);
0057   theErrors->m_surveyErrors.push_back(error);
0058 }
0059 
0060 // Plug in to framework
0061 
0062 #include "FWCore/Framework/interface/MakerMacros.h"
0063 
0064 DEFINE_FWK_MODULE(SurveyDBUploader);