Go to the documentation of this file.00001
00002 #include <fstream>
00003 #include <iostream>
00004
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00008 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00009
00010
00011 #include "Alignment/SurveyAnalysis/interface/SurveyDataReader.h"
00012
00013 using namespace std;
00014 using namespace edm;
00015
00016
00017 void SurveyDataReader::readFile( const std::string& textFileName, const std::string& fileType, const TrackerTopology* tTopo) {
00018
00019 std::ifstream myfile( textFileName.c_str() );
00020 if ( !myfile.is_open() )
00021 throw cms::Exception("FileAccess") << "Unable to open input text file for " << fileType.c_str();
00022
00023 int nErrors = 0;
00024 align::ID m_detId = 0;
00025 int NINPUTS_align = 30;
00026 int NINPUTS_detId = 6;
00027 if (fileType == "TID") NINPUTS_detId++;
00028
00029 std::vector<int> d_inputs;
00030 align::Scalars a_inputs;
00031 align::Scalars a_outputs;
00032 int itmpInput;
00033 float tmpInput;
00034
00035 while ( !myfile.eof() && myfile.good() )
00036 {
00037 d_inputs.clear();
00038 a_inputs.clear();
00039 a_outputs.clear();
00040
00041 if (fileType == "TIB") {
00042 itmpInput = int(StripSubdetector::TIB) ;
00043 } else {
00044 itmpInput = int(StripSubdetector::TID) ;
00045 }
00046
00047 d_inputs.push_back( itmpInput );
00048
00049 for ( int i=0; i<NINPUTS_detId; i++ )
00050 {
00051 myfile >> itmpInput;
00052 d_inputs.push_back( itmpInput );
00053 }
00054
00055
00056 int ster = 0;
00057
00058
00059 if (fileType == "TID") {
00060
00061 m_detId = tTopo->tidDetId(d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
00062 }
00063 else if (fileType == "TIB") {
00064
00065 m_detId = tTopo->tibDetId(d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
00066 }
00067
00068 if (abs(int(m_detId) - int(d_inputs[1])) > 2) {
00069 std::cout << "ERROR : DetId - detector position mismatch! Found " << nErrors << std::endl;
00070 nErrors++;
00071 }
00072
00073
00074
00075 for ( int j=0; j<NINPUTS_align; j++ )
00076 {
00077 myfile >> tmpInput;
00078 a_inputs.push_back( tmpInput );
00079 }
00080
00081
00082 if ( myfile.fail() ) break;
00083
00084 a_outputs = convertToAlignableCoord( a_inputs );
00085
00086 theOriginalMap.insert( PairTypeOr( d_inputs, a_inputs ));
00087 theMap.insert( PairType( m_detId, a_outputs ));
00088
00089 }
00090
00091 }
00092
00093 align::Scalars
00094 SurveyDataReader::convertToAlignableCoord( const align::Scalars& align_params )
00095 {
00096 align::Scalars align_outputs;
00097
00098
00099
00100
00101 AlgebraicVector geomCent(3);
00102 AlgebraicVector surCent(3);
00103 for (int ii = 0; ii < 3; ii++) {
00104 geomCent[ii] = align_params[ii];
00105 surCent[ii] = align_params[ii+15];
00106 }
00107 surCent -= geomCent;
00108
00109 align_outputs.push_back( surCent[0] );
00110 align_outputs.push_back( surCent[1] );
00111 align_outputs.push_back( surCent[2] );
00112
00113
00114 for (int ii = 3; ii < 12; ii++) {
00115 align_outputs.push_back( align_params[ii] );
00116 }
00117 for (int ii = 18; ii < 27; ii++) {
00118 align_outputs.push_back( align_params[ii] );
00119 }
00120
00121 return align_outputs;
00122 }