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
00028 if (theFirstEvent) {
00029
00030
00031
00032
00033 edm::ESHandle<TrackerTopology> tTopoHandle;
00034 setup.get<IdealGeometryRecord>().get(tTopoHandle);
00035 const TrackerTopology* const tTopo = tTopoHandle.product();
00036
00037
00038 SurveyInputTextReader dataReader;
00039 dataReader.readFile( textFileName );
00040 uIdMap = dataReader.UniqueIdMap();
00041
00042 edm::ESHandle<GeometricDet> geom;
00043 setup.get<IdealGeometryRecord>().get(geom);
00044 TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom, theParameterSet);
00045
00046 addComponent( new AlignableTracker( tracker, tTopo ) );
00047 addSurveyInfo( detector() );
00048
00049
00050 Alignments* myAlignments = detector()->alignments();
00051 AlignmentErrors* myAlignmentErrors = detector()->alignmentErrors();
00052
00053
00054 edm::Service<cond::service::PoolDBOutputService> poolDbService;
00055
00056
00057 if( !poolDbService.isAvailable() )
00058 throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
00059
00060 poolDbService->writeOne<Alignments>( myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd" );
00061 poolDbService->writeOne<AlignmentErrors>( myAlignmentErrors, poolDbService->beginOfTime(), "TrackerAlignmentErrorRcd" );
00062
00063 theFirstEvent = false;
00064 }
00065 }
00066
00067 void SurveyInputTrackerFromDB::addSurveyInfo(Alignable* ali)
00068 {
00069 const align::Alignables& comp = ali->components();
00070 unsigned int nComp = comp.size();
00071
00072 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
00073
00074 align::ErrorMatrix error;
00075
00076 SurveyInputTextReader::MapType::const_iterator it
00077 = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
00078
00079 if (it != uIdMap.end()){
00080
00081 const align::Scalars& parameters = (it)->second;
00082
00083
00084
00085 align::LocalVector lvector (parameters[0], parameters[1], parameters[2]);
00086 align::GlobalVector gvector = ali->surface().toGlobal(lvector);
00087 ali->move(gvector);
00088
00089 Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
00090 align::RotationType rotation(rot_aa, rot_aa.mag());
00091 ali->rotateInLocalFrame(rotation);
00092
00093
00094 double* errorData = error.Array();
00095 for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
00096
00097 ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
00098 }
00099 else {
00100 error = ROOT::Math::SMatrixIdentity();
00101 ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) );
00102 }
00103
00104 }
00105
00106
00107 #include "FWCore/Framework/interface/MakerMacros.h"
00108
00109
00110 DEFINE_FWK_MODULE(SurveyInputTrackerFromDB);