CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
SurveyDataReader Class Reference

#include <SurveyDataReader.h>

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. More...
 
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.

97 {
98  align::Scalars align_outputs;
99 
100  // Convert to coordinates that TrackerAlignment can read in
101 
102  // Center of sensor
103  AlgebraicVector geomCent(3);
104  AlgebraicVector surCent(3);
105  for (int ii = 0; ii < 3; ii++) {
106  geomCent[ii] = align_params[ii];
107  surCent[ii] = align_params[ii+15];
108  }
109  surCent -= geomCent;
110 
111  align_outputs.push_back( surCent[0] );
112  align_outputs.push_back( surCent[1] );
113  align_outputs.push_back( surCent[2] );
114 
115  // Rotation matrices
116  for (int ii = 3; ii < 12; ii++) {
117  align_outputs.push_back( align_params[ii] );
118  }
119  for (int ii = 18; ii < 27; ii++) {
120  align_outputs.push_back( align_params[ii] );
121  }
122 
123  return align_outputs;
124 }
std::vector< Scalar > Scalars
Definition: Utilities.h:22
CLHEP::HepVector AlgebraicVector
const MapType& SurveyDataReader::detIdMap ( ) const
inline

Definition at line 28 of file SurveyDataReader.h.

References theMap.

Referenced by SurveyDataConverter::analyze().

28 { 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(), python.Vispa.Plugins.EventBrowser.EventBrowserTabController.EventBrowserTabController::navigate(), python.Vispa.Main.TabController.TabController::open(), and python.Vispa.Main.TabController.TabController::refresh().

18 {
19 
20  std::ifstream myfile( textFileName.c_str() );
21  if ( !myfile.is_open() )
22  throw cms::Exception("FileAccess") << "Unable to open input text file for " << fileType.c_str();
23 
24  int nErrors = 0;
25  align::ID m_detId = 0;
26  int NINPUTS_align = 30;
27  int NINPUTS_detId = 6;
28  if (fileType == "TID") NINPUTS_detId++;
29 
30  std::vector<int> d_inputs;
31  align::Scalars a_inputs;
32  align::Scalars a_outputs;
33  int itmpInput;
34  float tmpInput;
35 
36  while ( !myfile.eof() && myfile.good() )
37  {
38  d_inputs.clear();
39  a_inputs.clear();
40  a_outputs.clear();
41 
42  if (fileType == "TIB") {
43  itmpInput = int(StripSubdetector::TIB) ;
44  } else {
45  itmpInput = int(StripSubdetector::TID) ;
46  }
47 
48  d_inputs.push_back( itmpInput );
49 
50  for ( int i=0; i<NINPUTS_detId; i++ )
51  {
52  myfile >> itmpInput;
53  d_inputs.push_back( itmpInput );
54  }
55 
56  // Calculate DetId(s)
57  int ster = 0; // if module is single-sided, take the module
58  // if double-sided get the glued module
59 
60  if (fileType == "TID") {
61  TIDDetId *myTDI;
62  myTDI = new TIDDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
63  m_detId = myTDI->rawId();
64  }
65  else if (fileType == "TIB") {
66  TIBDetId *myTBI = new TIBDetId( d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
67  m_detId = myTBI->rawId();
68  }
69 
70  if (abs(int(m_detId) - int(d_inputs[1])) > 2) { // Check DetId calculation ...
71  std::cout << "ERROR : DetId - detector position mismatch! Found " << nErrors << std::endl;
72  nErrors++;
73  }
74 
75  // std::cout << m_detId << " " << d_inputs[1] << std::endl;
76  // m_detId = d_inputs[1];
77  for ( int j=0; j<NINPUTS_align; j++ )
78  {
79  myfile >> tmpInput;
80  a_inputs.push_back( tmpInput );
81  }
82 
83  // Check if read succeeded (otherwise, we are at eof)
84  if ( myfile.fail() ) break;
85 
86  a_outputs = convertToAlignableCoord( a_inputs );
87 
88  theOriginalMap.insert( PairTypeOr( d_inputs, a_inputs ));
89  theMap.insert( PairType( m_detId, a_outputs ));
90 
91  }
92 
93 }
int i
Definition: DBlmapReader.cc:9
uint32_t ID
Definition: Definitions.h:26
#define abs(x)
Definition: mlp_lapack.h:159
std::pair< align::ID, align::Scalars > PairType
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::vector< Scalar > Scalars
Definition: Utilities.h:22
std::pair< std::vector< int >, align::Scalars > PairTypeOr
int j
Definition: DBlmapReader.cc:9
MapTypeOr theOriginalMap
align::Scalars convertToAlignableCoord(const align::Scalars &align_params)
tuple cout
Definition: gather_cfg.py:41
const MapTypeOr& SurveyDataReader::surveyMap ( ) const
inline

Definition at line 29 of file SurveyDataReader.h.

References theOriginalMap.

29 { return theOriginalMap; }
MapTypeOr theOriginalMap

Member Data Documentation

MapType SurveyDataReader::theMap
private

Definition at line 33 of file SurveyDataReader.h.

Referenced by detIdMap().

MapTypeOr SurveyDataReader::theOriginalMap
private

Definition at line 34 of file SurveyDataReader.h.

Referenced by surveyMap().