Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alignmentTransformationContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file alignmentTransformationContainer.cc
1 
9 
10 #include <Eigen/Dense>
11 #include <Eigen/Geometry>
12 
13 #include <algorithm>
14 #include <ostream>
15 
17 
19 {
20  for ( uint8_t layer = 0; layer < 57; layer++)
21  {
22  m_misalignmentFactor.insert(std::make_pair(layer, 1.));
23  }
24 }
26 {
27  auto it = m_misalignmentFactor.find(layer);
28  if(it != m_misalignmentFactor.end())
29  {
30  it->second = factor;
31  return;
32  }
33  std::cout << "You provided a nonexistent layer in alignmentTransformationContainer::setMisalignmentFactor..."
34  << std::endl;
35 }
37 {
38  if(transformVec.size() == 0) return;
39 
40  // loop over the transformVec
41  for(unsigned int i=0; i< transformVec.size(); ++i)
42  {
43  transformVec[i].clear();
44  std::vector<Acts::Transform3> emptyLayerVec;
45  transformVec[i].swap(emptyLayerVec);
46  }
47 
48  transformVec.clear();
49  std::vector<std::vector<Acts::Transform3>> emptyVec;
50  transformVec.swap(emptyVec);
51 }
52 
54 {
55 
56  os << "-----alignmentTransformationContainer-----" << std::endl;
57  for(unsigned int i=0; i< transformVec.size(); ++i)
58  {
59  auto& layerVec = transformVec[i];
60  if(layerVec.size() == 0) continue;
61 
62  os << " Layer: " << i << std::endl;
63 
64  for(unsigned int il=0; il< layerVec.size(); ++il)
65  {
66  os << " Sensor Id: " << il+1
67  << " Transform: " << layerVec[il].matrix()
68  << std::endl;
69  }
70  }
71  os << "------------------------------" << std::endl;
72 
73  return;
74 }
75 
77 {
78  unsigned int sphlayer = getsphlayer(id);
79  unsigned int sensor = id.sensitive() - 1; // Acts sensor numbering starts at 1
80 
81  // We are filling a super-vector of layer-vectors
82  // first check that the layer-vector for sphlayer is present
83 
84  if(sphlayer < transformVec.size())
85  {
86  // There will be a layer-vector, it may be empty
87  auto& layerVec = transformVec[sphlayer];
88 
89  if(sensor < layerVec.size())
90  {
91  layerVec[sensor] = transform;
92  }
93  else if (sensor == layerVec.size())
94  {
95  layerVec.push_back(transform);
96  }
97  else
98  {
99  layerVec.resize(sensor+1, transform);
100  }
101  }
102  else if(sphlayer == transformVec.size())
103  {
104  // add new layer-vector to transformVec and put transform in it
105  std::vector<Acts::Transform3> newVec;
106  newVec.resize(sensor + 1, transform);
107  transformVec.push_back(newVec);
108  }
109  else
110  {
111  transformVec.resize(sphlayer+1); // pad the missing layers with empty vectors
112  // Add this transform to the last layer
113  std::vector<Acts::Transform3> newVec;
114  newVec.resize(sensor + 1, transform);
115  transformVec[sphlayer] = newVec;
116  }
117 }
118 
120 {
121  unsigned int sphlayer = getsphlayer(id);
122  unsigned int sensor = id.sensitive() - 1; // Acts sensor numbering starts at 1
123 
124  auto& layerVec = transformVec[sphlayer];
125  if(layerVec.size() > sensor)
126  {
127  return layerVec[sensor];
128  }
129 
130  std::cout << "Unable to find Acts Id: "<< id<< " in alignmentTransformationContainer" << std::endl;
131  exit(1);
132 }
133 
135 {
136  unsigned int sphlayer = getsphlayer(id);
137  unsigned int sensor = id.sensitive() - 1; // Acts sensor numbering starts at 1
138 
139  auto& layerVec = transformVec[sphlayer];
140  if(layerVec.size() > sensor)
141  {
142  layerVec[sensor] = transform;
143  return;
144  }
145 
146  std::cout << "Unable to find Acts Id: "<< id<< " in alignmentTransformationContainer" << std::endl;
147  exit(1);
148 }
149 
150 const std::vector<std::vector<Acts::Transform3>>& alignmentTransformationContainer::getMap() const
151 {
152  return transformVec;
153 }
154 
156 {
157  unsigned int layer = id.layer();
158  unsigned int volume = id.volume();
159  unsigned int sphlayer = base_layer_map.find(volume)->second + layer / 2 -1;
160 
161  return sphlayer;
162 }