CMS 3D CMS Logo

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::ScalarsMapType
 
typedef std::map< std::vector< int >, align::ScalarsMapTypeOr
 
typedef std::pair< align::ID, align::ScalarsPairType
 
typedef std::pair< std::vector< int >, align::ScalarsPairTypeOr
 

Public Member Functions

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

Private Attributes

MapType theMap
 
MapTypeOr theOriginalMap
 

Detailed Description

Definition at line 15 of file SurveyDataReader.h.

Member Typedef Documentation

◆ MapType

Definition at line 17 of file SurveyDataReader.h.

◆ MapTypeOr

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

Definition at line 19 of file SurveyDataReader.h.

◆ PairType

Definition at line 18 of file SurveyDataReader.h.

◆ PairTypeOr

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

Definition at line 20 of file SurveyDataReader.h.

Member Function Documentation

◆ convertToAlignableCoord()

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

Definition at line 88 of file SurveyDataReader.cc.

88  {
89  align::Scalars align_outputs;
90 
91  // Convert to coordinates that TrackerAlignment can read in
92 
93  // Center of sensor
94  AlgebraicVector geomCent(3);
95  AlgebraicVector surCent(3);
96  for (int ii = 0; ii < 3; ii++) {
97  geomCent[ii] = align_params[ii];
98  surCent[ii] = align_params[ii + 15];
99  }
100  surCent -= geomCent;
101 
102  align_outputs.push_back(surCent[0]);
103  align_outputs.push_back(surCent[1]);
104  align_outputs.push_back(surCent[2]);
105 
106  // Rotation matrices
107  for (int ii = 3; ii < 12; ii++) {
108  align_outputs.push_back(align_params[ii]);
109  }
110  for (int ii = 18; ii < 27; ii++) {
111  align_outputs.push_back(align_params[ii]);
112  }
113 
114  return align_outputs;
115 }

References cuy::ii.

◆ detIdMap()

const MapType& SurveyDataReader::detIdMap ( ) const
inline

Definition at line 27 of file SurveyDataReader.h.

27 { return theMap; }

References theMap.

Referenced by SurveyDataConverter::analyze().

◆ readFile()

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

Read given text file.

Definition at line 17 of file SurveyDataReader.cc.

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")
29  NINPUTS_detId++;
30 
31  std::vector<int> d_inputs;
32  align::Scalars a_inputs;
33  align::Scalars a_outputs;
34  int itmpInput;
35  float tmpInput;
36 
37  while (!myfile.eof() && myfile.good()) {
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  myfile >> itmpInput;
52  d_inputs.push_back(itmpInput);
53  }
54 
55  // Calculate DetId(s)
56  int ster = 0; // if module is single-sided, take the module
57  // if double-sided get the glued module
58 
59  if (fileType == "TID") {
60  m_detId = tTopo->tidDetId(d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
61  } else if (fileType == "TIB") {
62  m_detId = tTopo->tibDetId(d_inputs[2], d_inputs[3], d_inputs[4], d_inputs[5], d_inputs[6], ster);
63  }
64 
65  if (abs(int(m_detId) - int(d_inputs[1])) > 2) { // Check DetId calculation ...
66  std::cout << "ERROR : DetId - detector position mismatch! Found " << nErrors << std::endl;
67  nErrors++;
68  }
69 
70  // std::cout << m_detId << " " << d_inputs[1] << std::endl;
71  // m_detId = d_inputs[1];
72  for (int j = 0; j < NINPUTS_align; j++) {
73  myfile >> tmpInput;
74  a_inputs.push_back(tmpInput);
75  }
76 
77  // Check if read succeeded (otherwise, we are at eof)
78  if (myfile.fail())
79  break;
80 
81  a_outputs = convertToAlignableCoord(a_inputs);
82 
83  theOriginalMap.insert(PairTypeOr(d_inputs, a_inputs));
84  theMap.insert(PairType(m_detId, a_outputs));
85  }
86 }

References funct::abs(), gather_cfg::cout, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, StripSubdetector::TIB, TrackerTopology::tibDetId(), StripSubdetector::TID, and TrackerTopology::tidDetId().

Referenced by SurveyDataConverter::analyze().

◆ surveyMap()

const MapTypeOr& SurveyDataReader::surveyMap ( ) const
inline

Definition at line 28 of file SurveyDataReader.h.

28 { return theOriginalMap; }

References theOriginalMap.

Member Data Documentation

◆ theMap

MapType SurveyDataReader::theMap
private

Definition at line 31 of file SurveyDataReader.h.

Referenced by detIdMap().

◆ theOriginalMap

MapTypeOr SurveyDataReader::theOriginalMap
private

Definition at line 32 of file SurveyDataReader.h.

Referenced by surveyMap().

mps_fire.i
i
Definition: mps_fire.py:355
align::Scalars
std::vector< Scalar > Scalars
Definition: Utilities.h:26
SurveyDataReader::convertToAlignableCoord
align::Scalars convertToAlignableCoord(const align::Scalars &align_params)
Definition: SurveyDataReader.cc:88
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SurveyDataReader::PairTypeOr
std::pair< std::vector< int >, align::Scalars > PairTypeOr
Definition: SurveyDataReader.h:20
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
TrackerTopology::tibDetId
DetId tibDetId(uint32_t layer, uint32_t str_fw_bw, uint32_t str_int_ext, uint32_t str, uint32_t module, uint32_t ster) const
Definition: TrackerTopology.h:495
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
SurveyDataReader::theMap
MapType theMap
Definition: SurveyDataReader.h:31
align::ID
uint32_t ID
Definition: Definitions.h:24
createfilelist.int
int
Definition: createfilelist.py:10
TrackerTopology::tidDetId
DetId tidDetId(uint32_t side, uint32_t wheel, uint32_t ring, uint32_t module_fw_bw, uint32_t module, uint32_t ster) const
Definition: TrackerTopology.h:508
SurveyDataReader::PairType
std::pair< align::ID, align::Scalars > PairType
Definition: SurveyDataReader.h:18
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cuy.ii
ii
Definition: cuy.py:590
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
SurveyDataReader::theOriginalMap
MapTypeOr theOriginalMap
Definition: SurveyDataReader.h:32