CMS 3D CMS Logo

SurveyMisalignmentInput.cc

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::beginJob(const edm::EventSetup& setup)
00022 {
00023 
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   // Retrieve alignment[Error]s from DBase
00031   setup.get<TrackerAlignmentRcd>().get( alignments );
00032 
00033   //Get map from textreader
00034   SurveyInputTextReader dataReader;
00035   dataReader.readFile( textFileName );
00036   uIdMap = dataReader.UniqueIdMap();
00037 
00038   addSurveyInfo( detector() );
00039 }
00040 
00041 
00042 void SurveyMisalignmentInput::addSurveyInfo(Alignable* ali)
00043 {
00044 
00045   const align::Alignables& comp = ali->components();
00046   unsigned int nComp = comp.size();
00047   for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
00048         
00049   SurveyInputTextReader::MapType::const_iterator it
00050     = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
00051 
00052   align::ErrorMatrix error;
00053 
00054   if (it != uIdMap.end()){
00055     //survey error values
00056     const align::Scalars& parameters = (it)->second;
00057     //sets the errors for the hierarchy level
00058     double* errorData = error.Array();
00059     for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
00060                 
00061     //because record only needs global value of modules
00062     if (ali->alignableObjectId() == align::AlignableDetUnit){
00063       // fill survey values
00064       ali->setSurvey( new SurveyDet(getAlignableSurface(ali->id()), error) );
00065     }
00066     else{
00067       ali->setSurvey( new SurveyDet(ali->surface(), error) );
00068     }
00069   }
00070   else{
00071     //fill
00072     error = ROOT::Math::SMatrixIdentity();
00073     ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
00074   }
00075   //std::cout << "UniqueId: " << id.first << ", " << id.second << std::endl;
00076   //std::cout << error << std::endl;
00077         
00078 }
00079 
00080 AlignableSurface SurveyMisalignmentInput::getAlignableSurface(align::ID id)
00081 {
00082   std::vector<AlignTransform>::const_iterator it;
00083 
00084   for (it = alignments->m_align.begin(); it != alignments->m_align.end(); ++it)
00085   {
00086     if (id == (*it).rawId())
00087     {
00088       align::PositionType position( (*it).translation().x(), (*it).translation().y(), (*it).translation().z() );
00089       CLHEP::HepRotation rot( (*it).rotation() );
00090       align::RotationType rotation( rot.xx(), rot.xy(), rot.xz(),
00091                                     rot.yx(), rot.yy(), rot.yz(),
00092                                     rot.zx(), rot.zy(), rot.zz() );
00093       return AlignableSurface(position,rotation);
00094     }
00095   }
00096         
00097   return AlignableSurface();
00098 }
00099 
00100 // Plug in to framework
00101 
00102 #include "FWCore/Framework/interface/MakerMacros.h"
00103 
00104 DEFINE_FWK_MODULE(SurveyMisalignmentInput);

Generated on Tue Jun 9 17:25:00 2009 for CMSSW by  doxygen 1.5.4