FairRoot/PandaRoot
PndGemStation.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndGemStation source file -----
3 // ----- Created 12/02/2009 by R. Karabowicz -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndGemStation.h"
7 
8 #include "PndGemSensor.h"
9 
10 #include "TMath.h"
11 
12 #include <iostream>
13 #include <map>
14 
15 using std::cout;
16 using std::endl;
17 using std::flush;
18 using std::map;
19 
20 
21 // ----- Default constructor -------------------------------------------
23  fDetectorId = 0;
24  fZ = 0.;
25  fSensors = new TObjArray(100);
26  fSensorMap.clear();
27 }
28 // -------------------------------------------------------------------------
29 
30 
31 
32 // ----- Standard constructor ------------------------------------------
33 PndGemStation::PndGemStation(const char* name, Int_t stationNr, Double_t z,
35  : TNamed(name, "GEM station") {
36  SetDetectorId(stationNr);
37  fZ = z;
39  fSensors = new TObjArray(100);
40  fSensorMap.clear();
41 
42  for ( Int_t isz = 0 ; isz < 10 ; isz++ )
43  fSensorZ[isz] = -666.;
44  fSensorZ[0] = z;
45 }
46 // -------------------------------------------------------------------------
47 
48 
49 
50 // ----- Destructor ----------------------------------------------------
52  if ( fSensors ) {
53  fSensors->Delete();
54  delete fSensors;
55  }
56 }
57 // -------------------------------------------------------------------------
58 
59 
60 
61 // ----- Public method GetNChannels ------------------------------------
63  Int_t nChan = 0;
64  for (Int_t iSect=0; iSect<GetNSensors(); iSect++)
65  nChan += GetSensor(iSect)->GetNChannels();
66  return nChan;
67 }
68 // -------------------------------------------------------------------------
69 
70 
71 
72 
73 // ----- Public method GetSensorByNr -----------------------------------
75  if ( fSensorMap.find(sensorNr) != fSensorMap.end() ) {
76  Int_t index = fSensorMap[sensorNr];
77  return (PndGemSensor*) fSensors->At(index);
78  }
79  else {
80  cout << "-W- PndGemStation::GetSensorByNr: sensor " << sensorNr
81  << " not found (station " << GetStationNr() << ")." << endl;
82  return NULL;
83  }
84 }
85 // -------------------------------------------------------------------------
86 
87 
88 // ----- Public method AddSensor ---------------------------------------
90 
91  Int_t iSensor = sensor->GetSensorNr();
92  Int_t nSensors = fSensors->GetEntries();
93 
94  fSensors->Add(sensor);
95 
96  fSensorMap[iSensor] = nSensors;
97 
98 }
99 // -------------------------------------------------------------------------
100 
101 // -------------------------------------------------------------------------
103 {
104  if ( fSensorZ[it] < -665. ) {
105  Int_t knownZPos = 0;
106  for ( knownZPos = 0 ; knownZPos < 10 ; knownZPos++ ) {
107  if ( fSensorZ[knownZPos] < -665. ) break;
108  }
109 
110  for (Int_t iSect=GetNSensors(); iSect > 0 ; iSect--) {
112  Bool_t knownAlready = kFALSE;
113  for ( Int_t isz = 0 ; isz < knownZPos ; isz++ )
114  if ( TMath::Abs(sensor->GetZ0()-fSensorZ[isz]) < 0.0001 ) {
115  knownAlready = kTRUE;
116  break;
117  }
118 
119  if ( knownAlready ) continue;
120 
121  fSensorZ[knownZPos] = sensor->GetZ0();
122  knownZPos++;
123  }
124  }
125  return fSensorZ[it];
126 }
127 // -------------------------------------------------------------------------
128 
129 // -------------------------------------------------------------------------
131 {
132  Int_t knownZPos = 0;
133  for ( knownZPos = 0 ; knownZPos < 10 ; knownZPos++ ) {
134  if ( fSensorZ[knownZPos] < -665. ) break;
135  }
136 
137  for (Int_t iSect=GetNSensors(); iSect > 0 ; iSect--) {
139  Bool_t knownAlready = kFALSE;
140  for ( Int_t isz = 0 ; isz < knownZPos ; isz++ )
141  if ( TMath::Abs(sensor->GetZ0()-fSensorZ[isz]) < 0.0001 ) {
142  knownAlready = kTRUE;
143  break;
144  }
145 
146  if ( knownAlready ) continue;
147 
148  fSensorZ[knownZPos] = sensor->GetZ0();
149  knownZPos++;
150  }
151  return knownZPos;
152 }
153 // -------------------------------------------------------------------------
154 
155 
156 // ----- Public method Reset -------------------------------------------
158  for (Int_t iSensor=0; iSensor<GetNSensors(); iSensor++)
159  GetSensor(iSensor)->Reset();
160 }
161 // -------------------------------------------------------------------------
162 
163 
164 
165 // ----- Public method Print -------------------------------------------
167  cout << "Station Nr. ";
168  cout.width(2);
169  cout << GetStationNr() << ", z = ";
170  cout.width(3);
171  cout << fZ << " cm, angle = ";
172  cout.width(3);
173  cout << fRotation * 180 / TMath::Pi() << " deg., sensors: ";
174  cout.width(4);
175  cout << GetNSensors() << ", channels: ";
176  cout.width(8);
177  cout << GetNChannels() << endl;
178 
179  Int_t tempSId = fDetectorId;
180  Int_t bc = 0;
181  cout << "STATION: " << flush;
182  while ( tempSId > 0 ) {
183  bc++;
184  cout << "\b" << tempSId%2 << "\b" << flush;
185  if ( bc == 27 || bc == 21 || bc == 8 || bc == 6 || bc == 5 )
186  cout << "\b|\b" << flush;
187  tempSId = tempSId/2;
188  }
189  cout << endl;
190 
191  if ( kLong )
192  for (Int_t iSec=0; iSec<GetNSensors(); iSec++)
193  GetSensor(iSec)->Print();
194 }
195 // -------------------------------------------------------------------------
196 
197 
198 
PndTransMap * map
Definition: sim_emc_apd.C:99
Int_t GetStationNr() const
Definition: PndGemStation.h:57
Double_t GetZ(Int_t it=0)
TGeoRotation rotation
TGeoVolume * sensor
void AddSensor(PndGemSensor *sensor)
PndGemSensor * GetSensor(Int_t iSensor)
Definition: PndGemStation.h:63
static T Abs(const T &x)
Definition: PndCAMath.h:39
Int_t GetNSensors() const
Definition: PndGemStation.h:60
PndGemSensor * GetSensorByNr(Int_t sensorNr)
Double32_t fRotation
Definition: PndGemStation.h:83
Double_t
Double_t fSensorZ[10]
Map from McId to index.
Definition: PndGemStation.h:88
Int_t GetNChannels()
Double_t z
TString name
TObjArray * fSensors
Definition: PndGemStation.h:84
Double32_t fZ
Definition: PndGemStation.h:82
virtual void Print(Bool_t kLong)
Int_t GetSensorNr() const
Definition: PndGemSensor.h:95
ClassImp(PndAnaContFact)
Double_t GetZ0() const
Definition: PndGemSensor.h:100
Int_t GetNChannels() const
Definition: PndGemSensor.h:110
std::map< Int_t, Int_t > fSensorMap
Definition: PndGemStation.h:85
Double_t Pi
void SetDetectorId(Int_t stationNr)
Definition: PndGemStation.h:52
virtual ~PndGemStation()