BmnRoot
Loading...
Searching...
No Matches
CbmStsStation.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsStation source file -----
3// ----- Created 31/03/05 by V. Friese -----
4// -------------------------------------------------------------------------
5
6#include "CbmStsStation.h"
7
8#include "CbmStsSector.h"
10
11#include "CbmStsSensor.h"
12
13#include "TMath.h"
14
15#include <iostream>
16#include <map>
17
18using std::cout;
19using std::endl;
20using std::map;
21
22
23// ----- Default constructor -------------------------------------------
25: fName(),
26 fDetectorId(0),
27 fZ(0.),
28 fD(0.),
29 fRadLength(),
30 fRmin(0.),
31 fRmax(0.),
32 fRotation(0.),
33 fSectors(),
34 fSectorMap(),
35 fMcIdMap()
36{
37 fSectors = new TObjArray(100);
38 fSectorMap.clear();
39}
40
41// ----- Standard constructor ------------------------------------------
42CbmStsStation::CbmStsStation(const char* name, Int_t iStation, Double_t z,
43 Double_t d, Double_t rl, Double_t rmin,
44 Double_t rmax, Double_t rotation)
45: TNamed(name, "STS station"),
46 fName(),
47 fDetectorId(0),
48 fZ(0.),
49 fD(0.),
50 fRadLength(),
51 fRmin(0.),
52 fRmax(0.),
53 fRotation(0.),
54 fSectors(),
55 fSectorMap(),
56 fMcIdMap()
57{
58 fDetectorId = 2 << 24 | iStation << 16;
59 fZ = z;
60 fD = d;
61 fRadLength = rl;
62 fRmin = rmin;
63 fRmax = rmax;
64 fRotation = rotation;
65 fSectors = new TObjArray(100);
66 fSectorMap.clear();
67
68 for ( Int_t isz = 0 ; isz < 10 ; isz++ )
69 fSensorZ[isz] = -666.;
70 fSensorZ[0] = z;
71}
72
73// ----- Destructor ----------------------------------------------------
75 if ( fSectors ) {
76 fSectors->Delete();
77 delete fSectors;
78 }
79}
80// -------------------------------------------------------------------------
81
82
83// ----- Public method GetNChannels ------------------------------------
85 Int_t nChan = 0;
86 for (Int_t iSect=0; iSect<GetNSectors(); iSect++)
87 if ( GetSector(iSect)->GetNChannels() > 0 )
88 nChan += GetSector(iSect)->GetNChannels();
89 return nChan;
90}
91// -------------------------------------------------------------------------
92
93
94
95
96// ----- Public method GetSectorByNr -----------------------------------
98 if ( fSectorMap.find(sectorNr) != fSectorMap.end() ) {
99 Int_t index = fSectorMap[sectorNr];
100 return (CbmStsSector*) fSectors->At(index);
101 }
102 else {
103 cout << "-W- CbmStsStation::GetSectorByNr: sector " << sectorNr
104 << " not found (station " << GetStationNr() << ")." << endl;
105 return NULL;
106 }
107}
108// -------------------------------------------------------------------------
109
110
111
112// ----- Public method AddSector ---------------------------------------
114
115 // Get digitisation parameters
116 Int_t iSector = sectorPar->GetSectorNr();
117
118 // Check for previous existence of sector
119 if ( fSectorMap.find(iSector) != fSectorMap.end() ) {
120 cout << "-W- " << fName << "::AddSector: Sector number " << iSector
121 << " already existing for station " << GetStationNr() << endl;
122 return;
123 }
124
125 // Calculate detectorId and rotation in global c.s.
126 Int_t detId = 2 << 24 | (GetStationNr() << 16) | (iSector << 4);
127
128 // Number of existing sectors
129 Int_t nSectors = fSectors->GetEntries();
130
131 // Create and add new sector
132 fSectors->Add(new CbmStsSector(Form("%ssect%d",fName.Data(),iSector),detId));
133
134 fSectorMap[iSector] = nSectors;
135}
136// -------------------------------------------------------------------------
137
138// ----- Public method AddSector ---------------------------------------
140
141 Int_t iSector = sector->GetSectorNr();
142 Int_t nSectors = fSectors->GetEntries();
143
144 fSectors->Add(sector);
145
146 fSectorMap[iSector] = nSectors;
147
148}
149// -------------------------------------------------------------------------
150
151// -------------------------------------------------------------------------
152Double_t CbmStsStation::GetZ(Int_t it)
153{
154 if ( fSensorZ[it] < -665. ) {
155 Int_t knownZPos = 0;
156 for ( knownZPos = 0 ; knownZPos < 10 ; knownZPos++ ) {
157 if ( fSensorZ[knownZPos] < -665. ) break;
158 }
159
160 for (Int_t iSect=GetNSectors(); iSect > 0 ; iSect--) {
161 CbmStsSector* sector = (CbmStsSector*)GetSector(iSect-1);
162 for (Int_t iSens=sector->GetNSensors() ; iSens > 0 ; iSens--) {
163 CbmStsSensor* sensor = (CbmStsSensor*)sector->GetSensor(iSens-1);
164 Bool_t knownAlready = kFALSE;
165 for ( Int_t isz = 0 ; isz < knownZPos ; isz++ )
166 if ( TMath::Abs(sensor->GetZ0()-fSensorZ[isz]) < 0.0001 ) {
167 knownAlready = kTRUE;
168 break;
169 }
170
171 if ( knownAlready ) continue;
172
173 fSensorZ[knownZPos] = sensor->GetZ0();
174 knownZPos++;
175 }
176 }
177 }
178 return fSensorZ[it];
179}
180// -------------------------------------------------------------------------
181
182// -------------------------------------------------------------------------
184{
185 Int_t knownZPos = 0;
186 for ( knownZPos = 0 ; knownZPos < 10 ; knownZPos++ ) {
187 if ( fSensorZ[knownZPos] < -665. ) break;
188 }
189
190 for (Int_t iSect=GetNSectors(); iSect > 0 ; iSect--) {
191 CbmStsSector* sector = (CbmStsSector*)GetSector(iSect-1);
192 for (Int_t iSens=sector->GetNSensors() ; iSens > 0 ; iSens--) {
193 CbmStsSensor* sensor = (CbmStsSensor*)sector->GetSensor(iSens-1);
194 Bool_t knownAlready = kFALSE;
195 for ( Int_t isz = 0 ; isz < knownZPos ; isz++ )
196 if ( TMath::Abs(sensor->GetZ0()-fSensorZ[isz]) < 0.0001 ) {
197 knownAlready = kTRUE;
198 break;
199 }
200
201 if ( knownAlready ) continue;
202
203 fSensorZ[knownZPos] = sensor->GetZ0();
204 knownZPos++;
205 }
206 }
207 return knownZPos;
208}
209// -------------------------------------------------------------------------
210
211
212// ----- Public method Reset -------------------------------------------
214 for (Int_t iSector=0; iSector<GetNSectors(); iSector++)
215 GetSector(iSector)->Reset();
216}
217// -------------------------------------------------------------------------
218
219
220
221// ----- Public method Print -------------------------------------------
222void CbmStsStation::Print(Bool_t kLong) {
223 cout << "Station Nr. ";
224 cout.width(2);
225 cout << GetStationNr() << ", z = ";
226 cout.width(3);
227 cout << fZ << " cm, Rmin = ";
228 cout.width(5);
229 cout << fRmin << " cm, Rmax = " << fRmax << " cm, angle = ";
230 cout.width(3);
231 cout << fRotation * 180 / TMath::Pi() << " deg., sectors: ";
232 cout.width(4);
233 cout << GetNSectors() << ", channels: ";
234 cout.width(8);
235 cout << GetNChannels() << endl;
236 if ( kLong )
237 for (Int_t iSec=0; iSec<GetNSectors(); iSec++)
238 GetSector(iSec)->Print();
239}
240// -------------------------------------------------------------------------
const Float_t d
Z-ccordinate of the first GEM-station.
Definition BmnMwpcHit.cxx:7
Int_t GetSectorNr() const
Int_t GetNChannels() const
CbmStsSensor * GetSensor(Int_t iSensor)
Int_t GetNSensors() const
Double_t GetZ0() const
Double32_t fRadLength
virtual void Print(Bool_t kLong)
Double32_t fRmin
Int_t GetNSectors() const
std::map< Int_t, Int_t > fSectorMap
Double32_t fRotation
Double32_t fD
Double32_t fZ
void AddSector(CbmStsSectorDigiPar *sectorPar)
TObjArray * fSectors
Double_t GetZ(Int_t it=0)
Double32_t fRmax
CbmStsSector * GetSectorByNr(Int_t sectorNr)
Int_t GetStationNr() const
CbmStsSector * GetSector(Int_t iSector)
virtual ~CbmStsStation()
Double_t fSensorZ[30]
Map from McId to index.