30 #include "FairGeoNode.h"
31 #include "FairGeoTransform.h"
32 #include "FairGeoVector.h"
33 #include "FairGeoRotation.h"
34 #include "FairGeoTube.h"
40 #include "TObjArray.h"
42 #include "TGeoVolume.h"
44 #include "TClonesArray.h"
45 #include "TGeoManager.h"
46 #include "TGeoVolume.h"
57 if(
fGeoType != 1) cout <<
"ERROR PndSttGeometryMap: fGeoType " <<
fGeoType <<
" not supported" << endl;
108 for (
int itube = 1; itube <
fTubeArray->GetEntriesFast(); itube++) {
115 if(!found) cout <<
"ERROR IN FINDIN NEIGHBORING " << endl;
121 double tolerance0 = 1.2;
122 double tolerance1 = 1.3;
123 double tolerance2 = 1.5;;
124 double tolerance = 1.5;
136 int possible_lay_sec[9][2] = { { ilayer, isector }, { ilayer, isector + 1 }, { ilayer, isector - 1 }, { ilayer + 1, isector },
137 { ilayer + 1, isector + 1 }, { ilayer + 1, isector - 1 }, { ilayer - 1, isector },
138 { ilayer - 1, isector + 1 }, { ilayer - 1, isector - 1 } };
140 std::vector<int> neigh_candidates;
141 for (
int itest = 0; itest < 9; itest++) {
147 if (possible_lay_sec[itest][0] < 0 || possible_lay_sec[itest][0] >=
fNLayers)
149 if (possible_lay_sec[itest][1] < 0 || possible_lay_sec[itest][1] >=
fNSectors)
152 if ((isector == 0 && possible_lay_sec[itest][1] == 5)
153 || (isector == 5 && possible_lay_sec[itest][1] == 0)
154 || (isector == 2 && possible_lay_sec[itest][1] == 3)
155 || (isector == 3 && possible_lay_sec[itest][1] == 2))
162 neigh_candidates =
GetStrawRow(possible_lay_sec[itest][1], possible_lay_sec[itest][0]);
164 for (
size_t itube = 0; itube < neigh_candidates.size(); itube++) {
165 tubeid = neigh_candidates.at(itube);
170 double distance = 1000;
173 if (tube2->
IsSkew() == kTRUE && tube->
IsSkew() == kTRUE)
174 tolerance = tolerance1;
176 tolerance = tolerance0;
179 tolerance = tolerance1;
181 tolerance = tolerance2;
183 if (distance < tolerance) {
184 int size = neighboring.GetSize();
185 neighboring.Set(size + 1);
186 neighboring.AddAt(tubeid, size);
206 TVector3 pos1, pos2, direction;
210 direction = pos2 - pos1;
212 double phi = direction.Phi();
230 }
else if (diff < 0.01) {
254 TVector3
p1(hit1->GetX(), hit1->GetY(), hit1->GetZ());
255 TVector3
p2(hit2->GetX(), hit2->GetY(), hit2->GetZ());
261 TVector3 u1(tube1->GetWireDirection());
265 std::cout <<
"PndSttGeometryMap::CalculateStrawPoca Hit1 center: (" << hit1->GetX() <<
"/" << hit1->GetY() <<
"/" << hit1->GetZ()
266 <<
") Dir: (" << u1.x() <<
"/" << u1.y() <<
"/" << u1.z() <<
") HL: " << tube1->GetHalfLength() << std::endl;
268 std::cout <<
"PndSttGeometryMap::CalculateStrawPoca Hit2 center: (" << hit2->GetX() <<
"/" << hit2->GetY() <<
"/" << hit2->GetZ()
269 <<
") Dir: (" << u2.x() <<
"/" << u2.y() <<
"/" << u2.z() <<
") HL: " << tube2->
GetHalfLength() << std::endl;
271 TVector3 p21 =
p2 -
p1;
272 if (p21.Mag() < 0.000001) {
274 if (
fVerbose > 1) std::cout <<
"Poca: " << poca.x() <<
"/" << poca.y() <<
"/" << poca.z() << std::endl;
278 TVector3
m = u2.Cross(u1);
279 if (m.Mag() < 0.000001) {
281 if (
fVerbose > 1) std::cout <<
"Poca: " << poca.x() <<
"/" << poca.y() <<
"/" << poca.z() << std::endl;
285 TVector3 mnorm = (1.0/m.Mag2())*m;
286 TVector3
r = p21.Cross(mnorm);
290 if (t1 > tube1->GetHalfLength()){
291 t1 = tube1->GetHalfLength();
292 }
else if (t1 < (-1)*tube1->GetHalfLength()) {
293 t1 = (-1)*tube1->GetHalfLength();
299 t2 = (-1)*tube1->GetHalfLength();
302 TVector3 q1 = p1+t1*u1;
303 TVector3 q2 =
p2+t2*u2;
304 TVector3 q21 = q2 - q1;
307 if (
fVerbose > 1) std::cout <<
"q1: " << q1.x() <<
"/" << q1.y() <<
"/" << q1.z() <<
" t1: " << t1 << std::endl;
308 if (
fVerbose > 1) std::cout <<
"q2: " << q2.x() <<
"/" << q2.y() <<
"/" << q2.z() <<
" t2: " << t2 << std::endl;
310 if (
fVerbose > 1) std::cout <<
"Poca: " << poca.x() <<
"/" << poca.y() <<
"/" << poca.z() << std::endl;
352 vector<int> currentRow;
359 if(
fVerbose > 0) cout <<
"Generating straw map for " <<
fTubeArray->GetEntriesFast() <<
" straws." << endl;
361 if(
fVerbose > 0) cout <<
"Finding tube." << endl;
363 if(
fVerbose > 0) cout <<
"Tube address: " << tube << endl;
366 cout <<
"Axial Straw: " << isaxial << endl;
367 cout <<
"Wire Direction: ";
371 if(
fVerbose > 0) cout <<
"Phi: " << phi << endl;
373 if(
fVerbose > 0) cout <<
"Checking sector." << endl;
379 if (sector != lastsector) {
382 if(
fVerbose > 0) cout <<
"SECTOR COMPLETE: Row " << row <<
" added to sector " << lastsector << endl;
384 if (sector < lastsector) row++;
386 currentRow.push_back(
i);
390 if(
fVerbose > 0) cout <<
"Straw " <<
i <<
" added to " << sector <<
", " << row << endl;
398 if(
fVerbose > 0) cout <<
"STT COMPLETE. SECTOR COMPLETE: Row " << row <<
" added to sector " << lastsector << endl;
411 const int size = 26* 6;
412 int shift_list[size] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 7, 11, 16,
413 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19,
414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19,
415 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 7, 11, 16,
416 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19,
417 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19};
418 const int sizeskew = 8*6;
419 int shift_list_skew[sizeskew] = {16, 19, 16, 16, 19, 16,
420 17, 20, 17, 17, 20, 17,
421 19, 21, 19, 19, 21, 19,
422 20, 22, 20, 20, 22, 20,
423 21, 24, 21, 21, 24, 21,
424 22, 25, 22, 22, 25, 22,
425 24, 26, 24, 24, 26, 24,
426 25, 27, 25, 25, 27, 25};
444 for(
int irow = 0; irow <
fNSectors; irow++) {
445 for(
int icol = 0; icol <
fNLayers; icol++) {
451 for(
int irow = 0; irow <
fNSectors; irow++) {
452 for(
int icol = 0; icol <
fNLayers; icol++) {
453 cout <<
" " <<
fEndTube[irow][icol];
458 for(
int irow = 0; irow <
fNSectors; irow++) {
459 for(
int icol = 0; icol <
fNLayers; icol++) {
460 cout <<
" " <<
fShift[irow][icol];
472 if (
GetRow(strawindex) == 0)
return true;
483 default:
return false;
485 return (strawindex == endstraw);
494 if (strawindex == endstrawcw)
return -1;
495 if (strawindex == endstrawccw)
return 1;
501 int endstrawccw = endstrawscw -1;
503 if (strawindex == endstrawcw)
return -1;
504 if (strawindex == endstrawccw)
return 1;
508 if (strawindex==endstrawccw+1 || strawindex==endstrawccw+3 || strawindex==endstrawccw+5 ||
509 strawindex==endstrawccw+7 || strawindex==endstrawccw+9 || strawindex==endstrawccw+11 ||
510 strawindex==endstrawccw+13 || strawindex==endstrawccw+15)
512 else if (strawindex==endstrawscw +1 || strawindex==endstrawscw+3 || strawindex==endstrawscw+5 ||
513 strawindex==endstrawscw+7 || strawindex==endstrawscw+9 || strawindex==endstrawscw+11 ||
514 strawindex==endstrawscw+13 || strawindex==endstrawscw+15)
540 vector<int> currentRow;
541 int isector = 0, ilayer = 0;
546 if(
fVerbose > 0) cout <<
"Generating straw map for " <<
fTubeArray->GetEntriesFast() <<
" straws." << endl;
547 for (
int itube = 1; itube <
fTubeArray->GetEntriesFast(); itube++) {
548 if(
fVerbose > 0) cout <<
"Finding tube." << endl;
552 cout <<
"Axial Straw: " << isaxial << endl;
553 cout <<
"Wire Direction: ";
562 while(!(itube >=
fStartTube[isector][ilayer] && itube <=
fEndTube[isector][ilayer])) {
567 if (isector != lastsector) {
570 if(
fVerbose > 0) cout <<
"SECTOR COMPLETE: Row " << ilayer <<
" added to sector " << lastsector << endl;
573 lastsector = isector;
574 currentRow.push_back(itube);
581 if(
fVerbose > 0) cout <<
"Straw " << itube <<
" added to " << isector <<
", " << ilayer << endl;
584 if(
fVerbose > 0) cout <<
"SECTOR COMPLETE: Row " << ilayer <<
" added to sector " << lastsector << endl;
const vector< int > & GetStrawRow(int sector, int row) const
map< int, vector< vector< int > > > fStrawIndex
Int_t fNTubes_outer_parallel
vector< int > fLayerOfStraw
void SetLayerLimitFlag(Bool_t flag=kTRUE)
bool IsAxialStraw(int strawindex) const
void GenerateStrawMapTubeIDGeoType1()
map< int, TArrayI > fStrawNeighbors
void SetGeneralParametersGeoType1()
void SetGeneralParameters()
TClonesArray * fTubeArray
bool IsEdgeStraw(int strawindex) const
void FillStrawNeighborsMap()
void SetSectorLimitFlag(Int_t flag)
Double_t GetDistance(PndSttTube *tube)
bool InStraightLine(int tube1, int tube2, int tube3) const
Int_t fNTubes_fillup_parallel
void GenerateStrawMap(Int_t map)
void SetNeighborings(TArrayI neighborings)
vector< int > fSectorOfStraw
int IsSectorBorderStraw(int strawindex) const
void GenerateStrawMapAngleGeoType1()
Double_t CalculateStrawPoca(PndSttHit *hit1, PndSttHit *hit2, TVector3 &poca)
Bool_t FillGeometryParameters()
vector< double > fSectorStart
bool fStrawMapInitialized
bool IsSkewedStraw(int strawindex) const
Int_t fNLayers_inner_parallel
bool IsAxialRow(int rowindex) const
Int_t fNTubes_inner_parallel
int GetRow(int strawindex) const
int GetSector(int strawindex) const
double GetAngleBetweenTubes(int tubeID1, int tubeID2) const
void GenerateStrawMapGeoType1(Int_t map)
vector< double > fSectorEnd
Bool_t FillGeometryParametersGeoType1()
Int_t fNLayers_fillup_parallel
TArrayI FindNeighborings(PndSttTube *tube)
TVector3 GetWireDirection()
bool IsSkewedRow(int rowindex) const
Int_t fNLayers_outer_parallel
TArrayI GetNeighboringsByMap(int tubeId)
vector< bool > fAxialStraw