Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignmentDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignmentDefs.cc
1 #include "AlignmentDefs.h"
2 #include <trackbase/TpcDefs.h>
3 
5 {
6  Acts::GeometryIdentifier id = surf->geometryId();
7  int group = 0;
8  switch (grp)
9  {
11  group = 0;
12  break;
14  group = 1;
15  break;
17  group = 2;
18  break;
19 
21  group = 3;
22  break;
23  }
24 
25  int label_base = getLabelBase(id, 0, group);
26  for (int i = 0; i < NGL; ++i)
27  {
28  glbl_label[i] = label_base + i;
29  }
30 }
31 
33 {
34  Acts::GeometryIdentifier id = surf->geometryId();
35  int group = 0;
36  switch (grp)
37  {
39  group = 4;
40  break;
42  group = 5;
43  break;
45  group = 6;
46  break;
48  group = 7;
49  break;
50  }
51 
52  int label_base = getLabelBase(id, 0, group);
53  for (int i = 0; i < NGL; ++i)
54  {
55  glbl_label[i] = label_base + i;
56  }
57 }
58 
60 {
61  Acts::GeometryIdentifier id = surf->geometryId();
62  int group = 0;
63  switch (grp)
64  {
66  group = 8;
67  break;
69  group = 9;
70  break;
72  group = 10;
73  break;
74  }
75 
76  int label_base = getLabelBase(id, cluskey, group);
77  for (int i = 0; i < NGL; ++i)
78  {
79  glbl_label[i] = label_base + i;
80  }
81 }
83 {
84  Acts::GeometryIdentifier id = surf->geometryId();
85  int group = 0;
86  switch (grp)
87  {
89  group = 11;
90  break;
92  group = 12;
93  break;
94  }
95 
96  int label_base = getLabelBase(id, 0, group);
97  for (int i = 0; i < NGL; ++i)
98  {
99  glbl_label[i] = label_base + i;
100  }
101 }
102 
104 {
105  int region = 0;
106  if (layer > 22 && layer < 39)
107  region = 1;
108  if (layer > 38 && layer < 55)
109  region = 2;
110 
111  return region;
112 }
113 
115 {
116  for(int istave=0;istave<nstaves_layer_mvtx[layer];++istave)
117  {
118  for(int ishell = 0; ishell < 2; ++ishell)
119  {
120  int stave_ref = clamshell_stave_list[layer][ishell][istave];
121  if(stave == stave_ref)
122  return ishell;
123  }
124  }
125 
126  std::cout << " AlignemntDefs::getMvtxClamshell: did not find stave " << stave << std::endl;
127  return 0;
128 
129 }
130 
132 {
133  unsigned int volume = id.volume();
134  unsigned int acts_layer = id.layer();
135  unsigned int layer = base_layer_map.find(volume)->second + acts_layer / 2 - 1;
136  unsigned int sensor = id.sensitive() - 1; // Acts starts at 1
137 
138  int label_base = 1; // Mille wants to start at 1
139 
140  // decide what level of grouping we want
141  if (layer < 3)
142  {
143  if (group == 0)
144  {
145  // every sensor has a different label
146  int stave = sensor / nsensors_stave[layer];
147  label_base += layer * 1000000 + stave * 10000 + sensor * 10;
148  return label_base;
149  }
150  if (group == 1)
151  {
152  // layer and stave, assign all sensors to the stave number
153  int stave = sensor / nsensors_stave[layer];
154  label_base += layer * 1000000 + stave * 10000;
155  /*
156  std::cout << id << std::endl;
157  std::cout << " label_base " << label_base << " volume " << volume << " acts_layer " << acts_layer
158  << " layer " << layer << " stave " << stave << " sensor " << sensor << std::endl;
159  */
160  return label_base;
161  }
162  if (group == 2)
163  {
164  // layer only, assign all sensors to sensor 0 in each clamshell
165  int stave = sensor / nsensors_stave[layer];
166  int clamshell = getMvtxClamshell(layer, stave);
167  label_base += layer * 1000000 + clamshell*10000;
168  // std::cout << " mvtx group 2 layer " << layer << " sensor " << sensor << " stave " << stave
169  // << " clamshell " << clamshell << " label_base " << label_base << std::endl;
170 
171  return label_base;
172  }
173  if(group == 3)
174  {
175  // group by half-barrel, or clamshell
176  // Assume for now low staves are in clamshell 0 - check!!!
177  int stave = sensor / nsensors_stave[layer];
178  int breakat = nstaves_layer_mvtx[layer] / 2;
179  int clamshell = 1;
180  if(stave < breakat) { clamshell = 0; }
181  label_base += 0 * 1000000 + clamshell * 10000;
182  // std::cout << " mvtx group 3 layer " << layer << " sensor " << sensor << " clamshell " << clamshell << " label_base " << label_base << std::endl;
183 
184  return label_base;
185  }
186  }
187  else if(layer > 2 && layer < 7)
188  {
189  // calculating the stave number from the sensor is different between the INTT and MVTX
190  // There are 4 sensors/stave, but they are mapped to staves in a strange way
191  // sensors 1-> (nstaves/layer)*2 are in staves 1->nstaves/layer in pairs
192  // sensors (nstaves/layer * 2) +1->nstaves/layer)*2 are in staves 1->nstaves/layer in pairs
193 
194  int stave;
195  unsigned int breakat = nstaves_layer_intt[layer-3] * 2;
196  if(sensor < breakat)
197  {
198  stave = sensor/2; // staves 0 -> (nstaves/layer) -1
199  }
200  else
201  {
202  stave = (sensor - breakat)/2; //staves 0 -> (nstaves/layer) -1
203  }
204 
205  if (group == 4)
206  {
207  // every sensor has a different label
208  label_base += layer * 1000000 + stave * 10000 + sensor * 10;
209  return label_base;
210  }
211  if (group == 5)
212  {
213  // layer and stave, assign all sensors to the stave number
214  label_base += layer * 1000000 + stave * 10000;
215  /*
216  std::cout << " " << id << std::endl;
217  std::cout << " label_base " << label_base << " volume " << volume << " acts_layer " << acts_layer
218  << " layer " << layer << " breakat " << breakat << " stave " << stave << " sensor " << sensor << std::endl;
219  */
220  return label_base;
221  }
222  if (group == 6)
223  {
224  // layer only, assign all sensors to sensor 0 for this layer
225  label_base += layer * 1000000 + 0;
226  return label_base;
227  }
228  if(group == 7)
229  {
230  // entire INTT
231  // assign all sensors to layer 3
232  label_base += 3 * 1000000 + 0;
233  return label_base;
234  }
235  }
236  else if (layer > 6 && layer < 55)
237  {
238  if (group == 8)
239  {
240  // want every hitset (layer, sector, side) to have a separate label
241  // each group of 12 subsurfaces (sensors) is in a single hitset
242  int hitset = sensor / 12; // 0-11 on side 0, 12-23 on side 1
243  label_base += layer * 1000000 + hitset * 10000;
244  return label_base;
245  }
246  if (group == 9)
247  {
248  // group all tpc layers in each region and sector, assign layer 7 and side and sector number to all layers and hitsets
249  int side = TpcDefs::getSide(cluskey);
250  int sector = TpcDefs::getSectorId(cluskey);;
251  int region = getTpcRegion(layer); // inner, mid, outer
252 
253  // for a given layer there are only 12 sectors x 2 sides
254  // The following gives the sectors in the inner, mid, outer regions unique group labels
255  label_base += 7 * 1000000 + (region * 24 + side * 12 + sector) * 10000;
256  /*
257  std::cout << " sensor " << sensor << " sector " << sector << " region " << region
258  << " side " << side << " label base " << label_base << std::endl;
259  std::cout << " Volume " << volume << " acts_layer " << acts_layer << " base_layer " << base_layer_map.find(volume)->second << " layer " << layer << std::endl;
260  */
261 
262  return label_base;
263  }
264  if (group == 10)
265  {
266  // all tpc layers and all sectors, assign layer 7 and sensor 0 to all layers and sensors
267  label_base += 7 * 1000000 + 0;
268  return label_base;
269  }
270  }
271  else
272  {
273  if (group == 11)
274  {
275  // every tile has different label
276  int tile = sensor;
277  label_base += layer * 1000000 + tile * 10000 + sensor * 10;
278  return label_base;
279  }
280  if (group == 12)
281  {
282  // assign layer 55 and tile 0 to all
283  label_base += 55 * 1000000 + 0;
284  return label_base;
285  }
286  }
287  return -1;
288 }
289 
290 std::vector<int> AlignmentDefs::getAllMvtxGlobalLabels(int grp)
291 {
292  std::vector<int> label_base;
293 
294  if(grp == mvtxGrp::clamshl)
295  {
296  for(int ishl=0;ishl<2;++ishl)
297  {
298  int label = 1 + 0 * 1000000 + ishl*10000;
299  label_base.push_back(label);
300  }
301  }
302  else if(grp == mvtxGrp::mvtxlyr)
303  {
304  for(int ishl=0;ishl<2;++ishl)
305  {
306  for(int ilyr = 0; ilyr < 3; ++ilyr)
307  {
308  int label = 1 + ilyr * 1000000 + ishl * 10000;
309  label_base.push_back(label);
310  }
311  }
312  }
313  else if(grp == mvtxGrp::stv)
314  {
315  for(int ilyr = 0; ilyr < 3; ++ilyr)
316  {
317  for(int istv = 0; istv < nstaves_layer_mvtx[ilyr]; ++istv)
318  {
319  int label = 1 + ilyr * 1000000 + istv * 10000;
320  label_base.push_back(label);
321  }
322  }
323  }
324  else if(grp == mvtxGrp::snsr)
325  {
326  for(int ilyr = 0; ilyr < 3; ++ilyr)
327  {
328  for(int istv = 0; istv < nstaves_layer_mvtx[ilyr]; ++istv)
329  {
330  for(int isnsr=0; isnsr<nsensors_stave[ilyr]; ++ isnsr)
331  {
332  int label = 1 + ilyr * 1000000 + istv * 10000 + isnsr * 10;
333  label_base.push_back(label);
334  }
335  }
336  }
337  }
338 
339  auto labels = makeLabelsFromBase(label_base);
340 
341  return labels;
342 }
343 
344 std::vector<int> AlignmentDefs::getAllInttGlobalLabels(int grp)
345 {
346  std::vector<int> label_base;
347 
348  if(grp == inttGrp::inttbrl)
349  {
350  int label = 1 + 3 * 1000000 + 0;
351  label_base.push_back(label);
352  }
353  else if(grp == inttGrp::inttlyr)
354  {
355  for(int ilyr = 3; ilyr < 7; ++ilyr)
356  {
357  int label = 1 + ilyr * 1000000 + 0;
358  label_base.push_back(label);
359  }
360  }
361  else if(grp == inttGrp::lad)
362  {
363  for(int ilyr = 3; ilyr < 7; ++ilyr)
364  {
365  for(int istv = 0; istv < nstaves_layer_intt[ilyr-3]; ++istv)
366  {
367  int label = 1 + ilyr * 1000000 + istv * 10000;
368  label_base.push_back(label);
369  }
370  }
371  }
372  else if(grp == inttGrp::chp)
373  {
374  for(int ilyr = 3; ilyr < 7; ++ilyr)
375  {
376  for(int istv = 0; istv < nstaves_layer_intt[ilyr-3]; ++istv)
377  {
378  for(int isnsr=0; isnsr<nsensors_stave[ilyr]; ++ isnsr)
379  {
380  int label = 1 + ilyr * 1000000 + istv * 10000 + isnsr * 10;
381  label_base.push_back(label);
382  }
383  }
384  }
385  }
386 
387  auto labels = makeLabelsFromBase(label_base);
388 
389  return labels;
390 }
391 
392 std::vector<int> AlignmentDefs::getAllTpcGlobalLabels(int grp)
393 {
394  std::vector<int> label_base;
395 
396  if(grp == tpcGrp::sctr)
397  {
398  for(int isec = 0; isec < 72; ++isec)
399  {
400  int label = 1 + 7 * 1000000 + isec * 10000;
401  label_base.push_back(label);
402  }
403  }
404 
405  auto labels = makeLabelsFromBase(label_base);
406 
407  return labels;
408 }
409 
410 std::vector<int> AlignmentDefs::makeLabelsFromBase(std::vector<int>& label_base)
411 {
412  std::vector<int> labels;
413  for(unsigned int ilbl = 0; ilbl < label_base.size(); ++ilbl)
414  {
415  for(int ipar=0; ipar < 6; ++ipar)
416  {
417  int label_plus = label_base[ilbl] + ipar;
418  labels.push_back(label_plus);
419  }
420  }
421 
422  return labels;
423 }
424 
425 void AlignmentDefs::printBuffers(int index, Acts::Vector2 residual, Acts::Vector2 clus_sigma, float lcl_derivative[], float glbl_derivative[], int glbl_label[])
426 {
427  std::cout << " float buffer: "
428  << " residual "
429  << " " << residual(index);
430  for (int il = 0; il < NLC; ++il)
431  {
432  if (lcl_derivative[il] != 0) std::cout << " lcl_deriv[" << il << "] " << lcl_derivative[il] << " ";
433  }
434  std::cout << " sigma "
435  << " " << clus_sigma(index) << " ";
436  for (int ig = 0; ig < NGL; ++ig)
437  {
438  if (glbl_derivative[ig] != 0) std::cout << " glbl_deriv[" << ig << "] " << glbl_derivative[ig] << " ";
439  }
440  std::cout << " int buffer: "
441  << " 0 "
442  << " 0 "
443  << " "; // spacer, rmeas placeholder
444  for (int il = 0; il < NLC; ++il)
445  {
446  if (lcl_derivative[il] != 0) std::cout << " lcl_label[" << il << "] " << il + 1 << " ";
447  }
448  std::cout << " 0 "
449  << " ";
450  for (int ig = 0; ig < NGL; ++ig)
451  {
452  if (glbl_derivative[ig] != 0) std::cout << " glbl_label[" << ig << "] " << glbl_label[ig] << " ";
453  }
454  std::cout << " end of meas " << std::endl;
455 }