FairRoot/PandaRoot
PndSttTubeMapCreatorRoot.cxx
Go to the documentation of this file.
1 /*
2  * PndSttTubeMapIdCreatorRoot.cpp
3  *
4  * Created on: 02.08.2018
5  * Author: tstockmanns
6  */
7 
8 #include <PndSttTubeIdMap.h>
10 #include "PndGeoHandling.h"
11 #include "PndStringSeparator.h"
12 #include "PndSttTubeCreator.h"
14 #include "PndSttTubeIdMap.h"
15 
16 #include <vector>
17 #include <string>
18 #include <algorithm>
19 #include <iostream>
20 
22 
24  // TODO Auto-generated constructor stub
25 
26 }
27 
29  // TODO Auto-generated destructor stubPndSttTubeIdMapeMap* PndSttTubeMapCreatorRoot::CreateTubeMap()
30 }
31 
33 
34  //create limitation map
35  for (int sector = 0; sector < 6; sector++) {
36  for (int row = 0; row < 29; row++) {
37  int MaxCpyNum = 0;
38  std::vector<int> vecRow = PndSttTubeIdMap::Instance()->GetRowInSector(sector, row);
39 // std::cout<<" vecRow size = "<<vecRow.size()<<std::endl;
40 
41  for (int j = 0; j < vecRow.size(); j++) {
42 // std::cout << "Id = " << vecRow[j] << " pos in row = " << j
43 // << std::endl;
44 // std::cout << PndGeoHandling::Instance()->GetPath(vecRow[j])
45 // << std::endl;
46 
47  TString path = PndGeoHandling::Instance()->GetPath(vecRow[j]);
48  std::string nameString(path.Data());
49  PndStringSeparator sep(nameString, "/-_");
50  std::vector < std::string > stringVector =
51  sep.GetStringVector();
52  auto i =
53  std::find_if(stringVector.begin(), stringVector.end(),
54  [&](const std::string& val) {auto found = val.find("tubestt02"); return found != std::string::npos;});
55  int pos = std::distance(stringVector.begin(), i);
56  int tubeType = std::stoi(stringVector[pos + 1]);
57  int cpyNum = std::stoi(stringVector[pos + 2]);
58 // std::cout << "cpyNum = " << cpyNum << std::endl;
59 
60  if (tubeType != 0) {
61  if (cpyNum == 0)
62  additionalSkewedTubeMap[vecRow[j]] = 1;
63  else
64  additionalSkewedTubeMap[vecRow[j]] = 2;
65 // std::cout << "additionalSkewedTubeMap ID =" << vecRow[j] << std::endl;
66  } else {
67  additionalSkewedTubeMap[vecRow[j]] = 0;
68  if (cpyNum == 0)
69  sRowTubeID[sector][row] = vecRow[j];
70  if (cpyNum > MaxCpyNum) {
71  MaxCpyNum = cpyNum;
72  eRowTubeID[sector][row] = vecRow[j];
73  }
74  }
75  //std::cout<<IsEdgeStraw(tubeId)<<IsSectorBorderStraw(tubeId)<<std::endl;
76  }
77 // std::cout<<sRowTubeID[sector][row]<<":"<<eRowTubeID[sector][row]<<std::endl;
78  }
79  }
80 
82  PndSttTubeCreator tubeCreator;
83  std::vector<TString> nodeNames = PndGeoHandling::Instance()->GetSensorNamesWithString("ArCO2Sensitive");
84 // std::cout << "-I- PndSttTubeMapCreatorRoot::CreateTubeMap Nodes: " << nodeNames.size() << std::endl;
85  for (auto name : nodeNames){
86 // std::cout << "Node: " << name.Data() << std::endl;
87  int tubeId = PndGeoHandling::Instance()->GetShortID(name);
88  PndSttTube* myTube = tubeCreator.GetTube(tubeId);
89  myTube->SetSectorLimitFlag(IsEdgeStraw(tubeId));
90  myTube->SetLayerLimitFlag(IsSectorBorderStraw(tubeId));
91  result->AddTube(tubeId, myTube);
92 // std::cout << *myTube << std::endl;
93 // std::cout << "GeoHandling Matrix: " << std::endl;
94 // TGeoHMatrix* mat = PndGeoHandling::Instance()->GetMatrixPath(name);
95 // mat->Print();
96  }
97 
98  std::map<int, PndSttTube*> tubeMap = result->GetMap();
99  for (auto tubePair : tubeMap){
100  AssignNeighbors(tubePair.second);
101  }
102 // std::cout<<"tubeId = "<<176 << " IsEdgeStraw = "<<IsEdgeStraw(176)<<std::endl;
103 // for_each(tubeMap.begin(), tubeMap.end(), [](std::pair<int, PndSttTube*> pair){ std::cout << *pair.second << std::endl;});
104 
105  return result;
106 }
107 
110  std::vector<int> neighbors = creator.FindNeighbors(tube);
111 // std::cout << "PndSttTubeMapCreatorRoot::AssignNeighbors size vector " << neighbors.size();
112  TArrayI neighborArray;
113  for_each(neighbors.begin(), neighbors.end(), [&neighborArray](int& id){int size = neighborArray.GetSize(); neighborArray.Set(size + 1); neighborArray.AddAt(id, size);});
114  tube->SetNeighborings(neighborArray);
115 // std::cout << " size of Array: " << neighborArray.GetSize() << std::endl;
116 }
117 
119 
120  std::pair<int, int> sectorRow = PndSttTubeIdMap::Instance()->GetSectorRowFromTubeId(tubeId);
121  //std::cout << "sector: " << sectorRow.first << " row:" << sectorRow.second << std::endl;
122 
123  // if (row == 0) return true;
124  if(additionalSkewedTubeMap[tubeId]>0 && sectorRow.first != 1 && sectorRow.first != 4){
125  if (sectorRow.first == 0 || sectorRow.first == 3) {
126  if (additionalSkewedTubeMap[tubeId] == 1)
127  return true;
128  else
129  return false;
130  } else if (sectorRow.first == 2 || sectorRow.first == 5) {
131  if (additionalSkewedTubeMap[tubeId] == 2)
132  return true;
133  else
134  return false;
135  }
136  }
137  int endstraw = 0;
138  switch (sectorRow.first) {
139  case 0:
140  endstraw = sRowTubeID[sectorRow.first][sectorRow.second];
141  break;
142  case 2:
143  endstraw = eRowTubeID[sectorRow.first][sectorRow.second];
144  break;
145  case 3:
146  endstraw = sRowTubeID[sectorRow.first][sectorRow.second];
147  break;
148  case 5:
149  endstraw = eRowTubeID[sectorRow.first][sectorRow.second];
150  break;
151  default:
152  return false;
153  };
154  return (tubeId == endstraw);
155 }
157 
158  std::pair<int, int> sectorRow = PndSttTubeIdMap::Instance()->GetSectorRowFromTubeId(tubeId);
159 
160  if(additionalSkewedTubeMap[tubeId]>0){
161  if (additionalSkewedTubeMap[tubeId] == 1)
162  return 1;
163  if (additionalSkewedTubeMap[tubeId] == 2)
164  return -1;
165  }
166  else {
167  int endstrawcw = sRowTubeID[sectorRow.first][sectorRow.second];
168  int endstrawccw = eRowTubeID[sectorRow.first][sectorRow.second];
169  if ( tubeId == endstrawcw) return -1;
170  if ( tubeId == endstrawccw) return 1;
171  }
172 
173  return 0;
174 }
vector< int > GetRowInSector(int sector, int row)
int row
Definition: anaLmdDigi.C:67
TVector3 pos
PndSttTube * GetTube(int tubeId)
std::pair< int, int > GetSectorRowFromTubeId(int tubeId)
Int_t i
Definition: run_full.C:25
std::map< int, PndSttTube * > GetMap()
Definition: PndSttTubeMap.h:27
void SetLayerLimitFlag(Bool_t flag=kTRUE)
Definition: PndSttTube.h:62
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
std::vector< int > FindNeighbors(PndSttTube *tube)
void SetSectorLimitFlag(Int_t flag)
Definition: PndSttTube.h:61
std::vector< TString > GetSensorNamesWithString(TString value)
TString GetPath(Int_t shortID)
for a given shortID the path is returned
void SetNeighborings(TArrayI neighborings)
Definition: PndSttTube.cxx:133
static PndSttTubeMap * Instance()
bool IsEdgeStraw(int tubeId) const
static PndSttTubeIdMap * Instance()
Int_t GetShortID(TString path)
for a given path the (unique) position of the sensor path in the fSensorNamePar-List is given...
static PndGeoHandling * Instance()
TString name
PndMvdCreateDefaultApvMap * creator
ClassImp(PndAnaContFact)
int IsSectorBorderStraw(int tubeId) const
void AssignNeighbors(PndSttTube *tube)
void AddTube(int tubeId, PndSttTube *tube)
Definition: PndSttTubeMap.h:21