FairRoot/PandaRoot
PndSttStrawMap.cxx
Go to the documentation of this file.
1 /*
2  * PndSTTStrawMap.cxx
3  *
4  * Created on: Apr 16, 2013
5  * Author: mertens
6  */
7 
8 
9 #include "PndSttStrawMap.h"
10 #include "TClonesArray.h"
11 #include "PndSttTube.h"
12 #include "TMath.h"
13 
14 #include <iostream>
15 #include <vector>
16 
17 using std::cout;
18 using std::endl;
19 using std::vector;
20 
22 : fStrawMapInitialized(false), fTubeArray(0)
23 {
25 }
26 
27 PndSttStrawMap::PndSttStrawMap(TClonesArray* const stt_tube_array)
28 : fStrawMapInitialized(false), fTubeArray(0)
29 {
31  GenerateStrawMap(stt_tube_array);
32 }
33 
35 {
36  fSectorStart.push_back(1.57);
37  fSectorEnd.push_back(2.62);
38  fSectorStart.push_back(2.62);
39  fSectorEnd.push_back(-2.62+2*TMath::Pi());
40  fSectorStart.push_back(-2.62+2*TMath::Pi());
41  fSectorEnd.push_back(-1.57+2*TMath::Pi());
42  fSectorStart.push_back(-1.57+2*TMath::Pi());
43  fSectorEnd.push_back(-0.52+2*TMath::Pi());
44  fSectorStart.push_back(-0.52+2*TMath::Pi());
45  fSectorEnd.push_back(0.52);
46  fSectorStart.push_back(0.52);
47  fSectorEnd.push_back(1.57);
48 }
49 
50 void PndSttStrawMap::GenerateStrawMap(TClonesArray* const stt_tube_array)
51 {
52  fTubeArray = stt_tube_array;
53 
54  vector<int> currentRow;
55  int sector = 0;
56  int lastsector = 0;
57  int row = 0;
58  fSectorOfStraw.push_back(-1);
59  fRowOfStraw.push_back(-1);
60  fAxialStraw.push_back(false);
61  // cout << "Generating straw map for " << fTubeArray->GetEntriesFast() << " straws." << endl;
62  for (int i = 1; i < fTubeArray->GetEntriesFast(); i++) {
63  // cout << "Finding tube." << endl;
64  PndSttTube* tube = GetTube(i);
65  // cout << "Tube address: " << tube << endl;
66  bool isaxial = (tube->GetWireDirection().Theta() < 0.001);
67  // cout << "Axial Straw: " << isaxial << endl;
68  // cout << "Wire Direction: ";
69 // tube->GetWireDirection().Print();
70  double phi = tube->GetPosition().Phi();
71  // cout << "Phi: " << phi << endl;
72  if (phi < 0) phi += 2*TMath::Pi();
73  // cout << "Checking sector." << endl;
74  while ( !( (phi > fSectorStart.at(sector)) && (phi < fSectorEnd.at(sector)) )
75  && !( (sector == 4) && ( (phi > fSectorStart.at(4)) || (phi < fSectorEnd.at(4)) ) ) ) {
76  sector++;
77  sector %= 6;
78  }
79  if (sector != lastsector) {
80  fStrawIndex[lastsector].push_back(currentRow);
81  currentRow.clear();
82  // cout << "SECTOR COMPLETE: Row " << row << " added to sector " << lastsector << endl;
83  }
84  if (sector < lastsector) row++;
85  lastsector = sector;
86  currentRow.push_back(i);
87  fSectorOfStraw.push_back(sector);
88  fRowOfStraw.push_back(row);
89  fAxialStraw.push_back(isaxial);
90  // cout << "Straw " << i << " added to " << sector << ", " << row << endl;
91  }
92  fStrawIndex[lastsector].push_back(currentRow);
93  // cout << "STT COMPLETE. SECTOR COMPLETE: Row " << row << " added to sector " << lastsector << endl;
94 
95  fStrawMapInitialized = true;
96 }
97 
99 {
100  int sector = 0;
101  if (phi < 0) phi += 2*TMath::Pi();
102  while ( !( (phi > fSectorStart.at(sector)) && (phi < fSectorEnd.at(sector)) )
103  && !( (sector == 4) && ( (phi > fSectorStart.at(4)) || (phi < fSectorEnd.at(4)) ) ) ) {
104  sector++;
105  sector %= 6;
106  }
107  return sector;
108 }
109 
110 bool PndSttStrawMap::IsEdgeStraw(int strawindex) const
111 {
112  if (GetRow(strawindex) == 0) return true;
113  int endstraw = 0; //there is no straw index 0
114  switch (GetSector(strawindex)) {
115  case 0: endstraw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).front();
116  break;
117  case 2: endstraw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).back();
118  break;
119  case 3: endstraw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).front();
120  break;
121  case 5: endstraw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).back();
122  break;
123  default: return false;
124  };
125  return (strawindex == endstraw);
126 }
127 
128 int PndSttStrawMap::IsSectorBorderStraw(int strawindex) const
129 {
130  int endstrawcw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).front();
131  int endstrawccw = GetStrawRow(GetSector(strawindex), GetRow(strawindex)).back();
132  if (strawindex == endstrawcw) return -1;
133  if (strawindex == endstrawccw) return 1;
134  return 0;
135 }
136 
137 bool PndSttStrawMap::IsAxialRow(int rowindex) const
138 {
139  //only works if all straws in one row are of the same type
140  //which is the case for the current geometry
141  return IsAxialStraw(GetStrawRow(0, rowindex).at(0));
142 }
143 
144 bool PndSttStrawMap::IsSkewedRow(int rowindex) const
145 {
146  //only works if all straws in one row are of the same type
147  //which is the case for the current geometry
148  return IsSkewedStraw(GetStrawRow(0, rowindex).at(0));
149 }
150 
151 
153 
int row
Definition: anaLmdDigi.C:67
vector< double > fSectorStart
Int_t i
Definition: run_full.C:25
int IsSectorBorderStraw(int strawindex) const
int GetSector(int strawindex) const
vector< int > fSectorOfStraw
vector< bool > fAxialStraw
PndSttTube * GetTube(int strawindex) const
const vector< int > & GetStrawRow(int sector, int row) const
bool IsSkewedRow(int rowindex) const
bool IsAxialStraw(int strawindex) const
map< int, vector< vector< int > > > fStrawIndex
bool IsSkewedStraw(int strawindex) const
TVector3 GetPosition()
Definition: PndSttTube.cxx:87
void GenerateStrawMap(TClonesArray *const stt_tube_array)
bool IsEdgeStraw(int strawindex) const
int FindPhiSector(double phi) const
bool fStrawMapInitialized
bool IsAxialRow(int rowindex) const
ClassImp(PndAnaContFact)
vector< int > fRowOfStraw
int GetRow(int strawindex) const
Double_t Pi
TVector3 GetWireDirection()
Definition: PndSttTube.cxx:107
vector< double > fSectorEnd
TClonesArray * fTubeArray