CMS 3D CMS Logo

SurveyDataReader Class Reference

#include <Alignment/SurveyAnalysis/interface/SurveyDataReader.h>

List of all members.

Public Types

typedef std::map< align::ID,
align::Scalars
MapType
typedef std::map< std::vector
< int >, align::Scalars
MapTypeOr
typedef std::pair< align::ID,
align::Scalars
PairType
typedef std::pair< std::vector
< int >, align::Scalars
PairTypeOr

Public Member Functions

align::Scalars convertToAlignableCoord (const align::Scalars &align_params)
const MapTypedetIdMap () const
void readFile (const std::string &textFileName, const std::string &fileType)
 Read given text file.
const MapTypeOrsurveyMap () const

Private Attributes

MapType theMap
MapTypeOr theOriginalMap


Detailed Description

Definition at line 13 of file SurveyDataReader.h.


Member Typedef Documentation

typedef std::map<align::ID, align::Scalars > SurveyDataReader::MapType

Definition at line 18 of file SurveyDataReader.h.

typedef std::map< std::vector<int>, align::Scalars > SurveyDataReader::MapTypeOr

Definition at line 20 of file SurveyDataReader.h.

typedef std::pair<align::ID,align::Scalars > SurveyDataReader::PairType

Definition at line 19 of file SurveyDataReader.h.

typedef std::pair< std::vector<int>, align::Scalars > SurveyDataReader::PairTypeOr

Definition at line 21 of file SurveyDataReader.h.


Member Function Documentation

align::Scalars SurveyDataReader::convertToAlignableCoord ( const align::Scalars align_params  ) 

Definition at line 96 of file SurveyDataReader.cc.

Referenced by readFile().

00097 {
00098       align::Scalars align_outputs;
00099 
00100       // Convert to coordinates that TrackerAlignment can read in
00101      
00102       // Center of sensor 
00103       AlgebraicVector geomCent(3);
00104       AlgebraicVector surCent(3);
00105       for (int ii = 0; ii < 3; ii++) {
00106         geomCent[ii] = align_params[ii];
00107         surCent[ii] = align_params[ii+15];
00108       }
00109       surCent -= geomCent;
00110                  
00111       align_outputs.push_back( surCent[0] ); 
00112       align_outputs.push_back( surCent[1] );   
00113       align_outputs.push_back( surCent[2] );   
00114       
00115       // Rotation matrices
00116       for (int ii = 3; ii < 12; ii++) { 
00117           align_outputs.push_back( align_params[ii] );
00118       }
00119       for (int ii = 18; ii < 27; ii++) { 
00120           align_outputs.push_back( align_params[ii] );
00121       } 
00122            
00123       return align_outputs; 
00124 }

const MapType& SurveyDataReader::detIdMap (  )  const [inline]

Definition at line 28 of file SurveyDataReader.h.

References theMap.

Referenced by SurveyDataConverter::analyze().

00028 { return theMap; }

void SurveyDataReader::readFile ( const std::string &  textFileName,
const std::string &  fileType 
)

Read given text file.

Definition at line 17 of file SurveyDataReader.cc.

References funct::abs(), convertToAlignableCoord(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, int, j, DetId::rawId(), theMap, theOriginalMap, StripSubdetector::TIB, and StripSubdetector::TID.

Referenced by SurveyDataConverter::analyze().

00018 {
00019   
00020   std::ifstream myfile( textFileName.c_str() );
00021   if ( !myfile.is_open() ) 
00022     throw cms::Exception("FileAccess") << "Unable to open input text file for " << fileType.c_str();
00023 
00024   int nErrors = 0;
00025   align::ID m_detId;
00026   int NINPUTS_align = 30;
00027   int NINPUTS_detId = 6;
00028   if (fileType == "TID") NINPUTS_detId++;
00029 
00030   std::vector<int> d_inputs;
00031   align::Scalars a_inputs;
00032   align::Scalars a_outputs;
00033   int itmpInput;
00034   float tmpInput; 
00035 
00036   while ( !myfile.eof() && myfile.good() )
00037         {
00038           d_inputs.clear();
00039           a_inputs.clear();
00040           a_outputs.clear();
00041 
00042           if (fileType == "TIB") {
00043             itmpInput = int(StripSubdetector::TIB) ; 
00044           } else {
00045             itmpInput = int(StripSubdetector::TID) ;
00046           }
00047 
00048           d_inputs.push_back( itmpInput );
00049 
00050           for ( int i=0; i<NINPUTS_detId; i++ )
00051                 {
00052                   myfile >> itmpInput;
00053                   d_inputs.push_back( itmpInput );
00054                 }
00055             
00056           // Calculate DetId(s)
00057           int ster = 0;  // if module is single-sided, take the module
00058                          // if double-sided get the glued module
00059 
00060           if (fileType == "TID") {
00061             TIDDetId *myTDI; 
00062             myTDI = new TIDDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
00063             m_detId = myTDI->rawId();
00064           }
00065           else if (fileType == "TIB") {
00066             TIBDetId *myTBI = new TIBDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster); 
00067             m_detId = myTBI->rawId();
00068           }
00069 
00070           if (abs(int(m_detId) - int(d_inputs[1])) > 2) {  // Check DetId calculation ...
00071             std::cout << "ERROR : DetId - detector position mismatch! Found " << nErrors << std::endl;
00072             nErrors++;
00073           }
00074 
00075           // std::cout << m_detId << " " << d_inputs[1] << std::endl;
00076           // m_detId = d_inputs[1];
00077           for ( int j=0; j<NINPUTS_align; j++ )
00078                 {
00079                   myfile >> tmpInput;
00080                   a_inputs.push_back( tmpInput );
00081                 }
00082 
00083           // Check if read succeeded (otherwise, we are at eof)
00084           if ( myfile.fail() ) break;
00085 
00086           a_outputs = convertToAlignableCoord( a_inputs );
00087 
00088           theOriginalMap.insert( PairTypeOr( d_inputs, a_inputs ));
00089           theMap.insert( PairType( m_detId, a_outputs ));
00090          
00091         }
00092 
00093 }

const MapTypeOr& SurveyDataReader::surveyMap (  )  const [inline]

Definition at line 29 of file SurveyDataReader.h.

References theOriginalMap.

00029 { return theOriginalMap; }


Member Data Documentation

MapType SurveyDataReader::theMap [private]

Definition at line 33 of file SurveyDataReader.h.

Referenced by detIdMap(), and readFile().

MapTypeOr SurveyDataReader::theOriginalMap [private]

Definition at line 34 of file SurveyDataReader.h.

Referenced by readFile(), and surveyMap().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:00 2009 for CMSSW by  doxygen 1.5.4