CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/Alignment/SurveyAnalysis/plugins/SurveyDBUploader.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignment/interface/Alignable.h"
00002 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00003 #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h"
00004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00005 #include "CondFormats/Alignment/interface/Alignments.h"
00006 #include "CondFormats/Alignment/interface/SurveyErrors.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 
00010 #include "Alignment/SurveyAnalysis/plugins/SurveyDBUploader.h"
00011 
00012 SurveyDBUploader::SurveyDBUploader(const edm::ParameterSet& cfg):
00013   theValueRcd( cfg.getParameter<std::string>("valueRcd") ),
00014   theErrorRcd( cfg.getParameter<std::string>("errorRcd") ),
00015   theValues(0),
00016   theErrors(0)
00017 {
00018 }
00019 
00020 void SurveyDBUploader::endJob()
00021 {
00022   theValues = new SurveyValues;
00023   theErrors = new SurveyErrors;
00024 
00025   theValues->m_align.reserve(65536);
00026   theErrors->m_surveyErrors.reserve(65536);
00027 
00028   getSurveyInfo( SurveyInputBase::detector() );
00029 
00030   edm::Service<cond::service::PoolDBOutputService> poolDbService;
00031 
00032   if( poolDbService.isAvailable() )
00033   {
00034     poolDbService->writeOne<SurveyValues>
00035       (theValues, poolDbService->currentTime(), theValueRcd);
00036     poolDbService->writeOne<SurveyErrors>
00037       (theErrors, poolDbService->currentTime(), theErrorRcd);
00038   }
00039   else
00040     throw cms::Exception("ConfigError")
00041       << "PoolDBOutputService is not available";
00042 }
00043 
00044 void SurveyDBUploader::getSurveyInfo(const Alignable* ali)
00045 {
00046   const std::vector<Alignable*>& comp = ali->components();
00047 
00048   unsigned int nComp = comp.size();
00049 
00050   for (unsigned int i = 0; i < nComp; ++i) getSurveyInfo(comp[i]);
00051 
00052   const SurveyDet* survey = ali->survey();
00053 
00054   const align::PositionType& pos = survey->position();
00055   const align::RotationType& rot = survey->rotation();
00056 
00057   SurveyValue value( CLHEP::Hep3Vector( pos.x(), pos.y(), pos.z() ),
00058                      CLHEP::HepRotation
00059                      ( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
00060                                          rot.yx(), rot.yy(), rot.yz(),
00061                                          rot.zx(), rot.zy(), rot.zz() ) ),
00062                      ali->id() );
00063 
00064   SurveyError error( ali->alignableObjectId(),
00065                      ali->id(),
00066                      survey->errors() );
00067 
00068   theValues->m_align.push_back(value);
00069   theErrors->m_surveyErrors.push_back(error);
00070 }
00071 
00072 // Plug in to framework
00073 
00074 #include "FWCore/Framework/interface/MakerMacros.h"
00075 
00076 DEFINE_FWK_MODULE(SurveyDBUploader);