CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

SurveyDataReader Class Reference

#include <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

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.

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.

{
      align::Scalars align_outputs;

      // Convert to coordinates that TrackerAlignment can read in
     
      // Center of sensor 
      AlgebraicVector geomCent(3);
      AlgebraicVector surCent(3);
      for (int ii = 0; ii < 3; ii++) {
        geomCent[ii] = align_params[ii];
        surCent[ii] = align_params[ii+15];
      }
      surCent -= geomCent;
                 
      align_outputs.push_back( surCent[0] ); 
      align_outputs.push_back( surCent[1] );   
      align_outputs.push_back( surCent[2] );   
      
      // Rotation matrices
      for (int ii = 3; ii < 12; ii++) { 
          align_outputs.push_back( align_params[ii] );
      }
      for (int ii = 18; ii < 27; ii++) { 
          align_outputs.push_back( align_params[ii] );
      } 
           
      return align_outputs; 
}
const MapType& SurveyDataReader::detIdMap ( ) const [inline]

Definition at line 28 of file SurveyDataReader.h.

References theMap.

Referenced by SurveyDataConverter::analyze().

{ 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 abs, gather_cfg::cout, i, j, DetId::rawId(), StripSubdetector::TIB, and StripSubdetector::TID.

Referenced by SurveyDataConverter::analyze().

{
  
  std::ifstream myfile( textFileName.c_str() );
  if ( !myfile.is_open() ) 
    throw cms::Exception("FileAccess") << "Unable to open input text file for " << fileType.c_str();

  int nErrors = 0;
  align::ID m_detId = 0;
  int NINPUTS_align = 30;
  int NINPUTS_detId = 6;
  if (fileType == "TID") NINPUTS_detId++;

  std::vector<int> d_inputs;
  align::Scalars a_inputs;
  align::Scalars a_outputs;
  int itmpInput;
  float tmpInput; 

  while ( !myfile.eof() && myfile.good() )
        {
          d_inputs.clear();
          a_inputs.clear();
          a_outputs.clear();

          if (fileType == "TIB") {
            itmpInput = int(StripSubdetector::TIB) ; 
          } else {
            itmpInput = int(StripSubdetector::TID) ;
          }

          d_inputs.push_back( itmpInput );

          for ( int i=0; i<NINPUTS_detId; i++ )
                {
                  myfile >> itmpInput;
                  d_inputs.push_back( itmpInput );
                }
            
          // Calculate DetId(s)
          int ster = 0;  // if module is single-sided, take the module
                         // if double-sided get the glued module

          if (fileType == "TID") {
            TIDDetId *myTDI; 
            myTDI = new TIDDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
            m_detId = myTDI->rawId();
          }
          else if (fileType == "TIB") {
            TIBDetId *myTBI = new TIBDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster); 
            m_detId = myTBI->rawId();
          }

          if (abs(int(m_detId) - int(d_inputs[1])) > 2) {  // Check DetId calculation ...
            std::cout << "ERROR : DetId - detector position mismatch! Found " << nErrors << std::endl;
            nErrors++;
          }

          // std::cout << m_detId << " " << d_inputs[1] << std::endl;
          // m_detId = d_inputs[1];
          for ( int j=0; j<NINPUTS_align; j++ )
                {
                  myfile >> tmpInput;
                  a_inputs.push_back( tmpInput );
                }

          // Check if read succeeded (otherwise, we are at eof)
          if ( myfile.fail() ) break;

          a_outputs = convertToAlignableCoord( a_inputs );

          theOriginalMap.insert( PairTypeOr( d_inputs, a_inputs ));
          theMap.insert( PairType( m_detId, a_outputs ));
         
        }

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

Definition at line 29 of file SurveyDataReader.h.

References theOriginalMap.

{ return theOriginalMap; }

Member Data Documentation

Definition at line 33 of file SurveyDataReader.h.

Referenced by detIdMap().

Definition at line 34 of file SurveyDataReader.h.

Referenced by surveyMap().