![]() |
![]() |
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 #include "Alignment/SurveyAnalysis/plugins/SurveyInputTrackerFromDB.h" 00010 00011 SurveyInputTrackerFromDB::SurveyInputTrackerFromDB(const edm::ParameterSet& cfg): 00012 textFileName( cfg.getParameter<std::string>("textFileName") ) 00013 { 00014 } 00015 00016 void SurveyInputTrackerFromDB::beginJob(const edm::EventSetup& setup ) 00017 { 00018 00019 // std::cout << "***************ENTERING BEGIN JOB******************" << std::endl; 00020 00021 //Get map from textreader 00022 SurveyInputTextReader dataReader; 00023 dataReader.readFile( textFileName ); 00024 uIdMap = dataReader.UniqueIdMap(); 00025 00026 edm::ESHandle<GeometricDet> geom; 00027 setup.get<IdealGeometryRecord>().get(geom); 00028 TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(&*geom); 00029 00030 addComponent( new AlignableTracker( tracker ) ); 00031 addSurveyInfo( detector() ); 00032 // std::cout << "*************END BEGIN JOB***************" << std::endl; 00033 } 00034 00035 void SurveyInputTrackerFromDB::addSurveyInfo(Alignable* ali) 00036 { 00037 const align::Alignables& comp = ali->components(); 00038 //std::cout << "in addSurveyInfo" << std::endl; 00039 unsigned int nComp = comp.size(); 00040 //std::cout << "alOjbId: " << ali->alignableObjectId(); 00041 //std::cout << " , detId: " << ali->geomDetId().rawId() << std::endl; 00042 00043 for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]); 00044 00045 align::ErrorMatrix error; 00046 00047 //if (ali->alignableObjectId() != AlignableObjectId::AlignableDetUnit){ 00048 00049 // std::cout << "UniqueId: " << id.first << ", " << id.second << std::endl; 00050 SurveyInputTextReader::MapType::const_iterator it 00051 = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId())); 00052 // std::cout << "itID: " << it->first.first << ", " << it->first.second << std::endl; 00053 if (it != uIdMap.end()){ 00054 00055 const align::Scalars& parameters = (it)->second; 00056 00057 //move the surface 00058 //displacement 00059 align::LocalVector lvector (parameters[0], parameters[1], parameters[2]); 00060 align::GlobalVector gvector = ali->surface().toGlobal(lvector); 00061 ali->move(gvector); 00062 //rotation 00063 Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]); 00064 align::RotationType rotation(rot_aa, rot_aa.mag()); 00065 ali->rotateInLocalFrame(rotation); 00066 00067 //sets the errors for the hierarchy level 00068 double* errorData = error.Array(); 00069 for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];} 00070 00071 ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) ); 00072 } 00073 else { 00074 error = ROOT::Math::SMatrixIdentity(); 00075 ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) ); 00076 } 00077 00078 } 00079 // Plug in to framework 00080 00081 #include "FWCore/Framework/interface/MakerMacros.h" 00082 00083 00084 DEFINE_FWK_MODULE(SurveyInputTrackerFromDB);