Go to the documentation of this file.00001 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00002 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00007 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00008
00009
00010 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
00013 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h"
00014 #include "CondFormats/Alignment/interface/Alignments.h"
00015 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00016
00017
00018 #include "Alignment/SurveyAnalysis/plugins/SurveyInputTrackerFromDB.h"
00019
00020 SurveyInputTrackerFromDB::SurveyInputTrackerFromDB(const edm::ParameterSet& cfg)
00021 : textFileName( cfg.getParameter<std::string>("textFileName") ),
00022 theParameterSet( cfg )
00023 {}
00024
00025 void SurveyInputTrackerFromDB::analyze(const edm::Event&, const edm::EventSetup& setup)
00026 {
00027 if (theFirstEvent) {
00028
00029
00030
00031
00032 SurveyInputTextReader dataReader;
00033 dataReader.readFile( textFileName );
00034 uIdMap = dataReader.UniqueIdMap();
00035
00036 edm::ESHandle<GeometricDet> geom;
00037 setup.get<IdealGeometryRecord>().get(geom);
00038 TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom, theParameterSet);
00039
00040 addComponent( new AlignableTracker( tracker ) );
00041 addSurveyInfo( detector() );
00042
00043
00044 Alignments* myAlignments = detector()->alignments();
00045 AlignmentErrors* myAlignmentErrors = detector()->alignmentErrors();
00046
00047
00048 edm::Service<cond::service::PoolDBOutputService> poolDbService;
00049
00050
00051 if( !poolDbService.isAvailable() )
00052 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
00053
00054 poolDbService->writeOne<Alignments>( myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd" );
00055 poolDbService->writeOne<AlignmentErrors>( myAlignmentErrors, poolDbService->beginOfTime(), "TrackerAlignmentErrorRcd" );
00056
00057 theFirstEvent = false;
00058 }
00059 }
00060
00061 void SurveyInputTrackerFromDB::addSurveyInfo(Alignable* ali)
00062 {
00063 const align::Alignables& comp = ali->components();
00064 unsigned int nComp = comp.size();
00065
00066 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
00067
00068 align::ErrorMatrix error;
00069
00070 SurveyInputTextReader::MapType::const_iterator it
00071 = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
00072
00073 if (it != uIdMap.end()){
00074
00075 const align::Scalars& parameters = (it)->second;
00076
00077
00078
00079 align::LocalVector lvector (parameters[0], parameters[1], parameters[2]);
00080 align::GlobalVector gvector = ali->surface().toGlobal(lvector);
00081 ali->move(gvector);
00082
00083 Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
00084 align::RotationType rotation(rot_aa, rot_aa.mag());
00085 ali->rotateInLocalFrame(rotation);
00086
00087
00088 double* errorData = error.Array();
00089 for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
00090
00091 ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
00092 }
00093 else {
00094 error = ROOT::Math::SMatrixIdentity();
00095 ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) );
00096 }
00097
00098 }
00099
00100
00101 #include "FWCore/Framework/interface/MakerMacros.h"
00102
00103
00104 DEFINE_FWK_MODULE(SurveyInputTrackerFromDB);