Go to the documentation of this file.00001 #include "FWCore/Framework/interface/EventSetup.h"
00002 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00004
00005 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
00006 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00007
00008 #include "CondFormats/Alignment/interface/Alignments.h"
00009 #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h"
00010
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013
00014 #include "Alignment/SurveyAnalysis/plugins/SurveyMisalignmentInput.h"
00015
00016 SurveyMisalignmentInput::SurveyMisalignmentInput(const edm::ParameterSet& cfg):
00017 textFileName( cfg.getParameter<std::string>("textFileName") )
00018 {
00019 }
00020
00021 void SurveyMisalignmentInput::analyze(const edm::Event&, const edm::EventSetup& setup)
00022 {
00023 if (theFirstEvent) {
00024 edm::ESHandle<GeometricDet> geom;
00025 setup.get<IdealGeometryRecord>().get(geom);
00026 TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom);
00027 addComponent(new AlignableTracker( tracker ) );
00028
00029 edm::LogInfo("SurveyMisalignmentInput") << "Starting!";
00030
00031 setup.get<TrackerAlignmentRcd>().get( alignments );
00032
00033
00034 SurveyInputTextReader dataReader;
00035 dataReader.readFile( textFileName );
00036 uIdMap = dataReader.UniqueIdMap();
00037
00038 addSurveyInfo( detector() );
00039
00040 theFirstEvent = false;
00041 }
00042 }
00043
00044
00045 void SurveyMisalignmentInput::addSurveyInfo(Alignable* ali)
00046 {
00047
00048 const align::Alignables& comp = ali->components();
00049 unsigned int nComp = comp.size();
00050 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
00051
00052 SurveyInputTextReader::MapType::const_iterator it
00053 = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
00054
00055 align::ErrorMatrix error;
00056
00057 if (it != uIdMap.end()){
00058
00059 const align::Scalars& parameters = (it)->second;
00060
00061 double* errorData = error.Array();
00062 for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
00063
00064
00065 if (ali->alignableObjectId() == align::AlignableDetUnit){
00066
00067 ali->setSurvey( new SurveyDet(getAlignableSurface(ali->id()), error) );
00068 }
00069 else{
00070 ali->setSurvey( new SurveyDet(ali->surface(), error) );
00071 }
00072 }
00073 else{
00074
00075 error = ROOT::Math::SMatrixIdentity();
00076 ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
00077 }
00078
00079
00080
00081 }
00082
00083 AlignableSurface SurveyMisalignmentInput::getAlignableSurface(align::ID id)
00084 {
00085 std::vector<AlignTransform>::const_iterator it;
00086
00087 for (it = alignments->m_align.begin(); it != alignments->m_align.end(); ++it)
00088 {
00089 if (id == (*it).rawId())
00090 {
00091 align::PositionType position( (*it).translation().x(), (*it).translation().y(), (*it).translation().z() );
00092 CLHEP::HepRotation rot( (*it).rotation() );
00093 align::RotationType rotation( rot.xx(), rot.xy(), rot.xz(),
00094 rot.yx(), rot.yy(), rot.yz(),
00095 rot.zx(), rot.zy(), rot.zz() );
00096 return AlignableSurface(position,rotation);
00097 }
00098 }
00099
00100 return AlignableSurface();
00101 }
00102
00103
00104
00105 #include "FWCore/Framework/interface/MakerMacros.h"
00106
00107 DEFINE_FWK_MODULE(SurveyMisalignmentInput);