BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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#include "CbmStsSensor.h"
11#include "TMath.h"
12
13#include <iostream>
14#include <map>
15
16using std::cout;
17using std::endl;
18using std::map;
19
20// ----- Default constructor -------------------------------------------
22 : fName()
23 , fDetectorId(0)
24 , fZ(0.)
25 , fD(0.)
26 , fRadLength()
27 , fRmin(0.)
28 , fRmax(0.)
29 , fRotation(0.)
30 , fSectors()
31 , fSectorMap()
32 , fMcIdMap()
33{
34 fSectors = new TObjArray(100);
35 fSectorMap.clear();
36}
37
38// ----- Standard constructor ------------------------------------------
40 Int_t iStation,
41 Double_t z,
42 Double_t d,
43 Double_t rl,
44 Double_t rmin,
45 Double_t rmax,
46 Double_t rotation)
47 : TNamed(name, "STS station")
48 , fName()
49 , fDetectorId(0)
50 , fZ(0.)
51 , fD(0.)
52 , fRadLength()
53 , fRmin(0.)
54 , fRmax(0.)
55 , fRotation(0.)
56 , fSectors()
57 , fSectorMap()
58 , fMcIdMap()
59{
60 fDetectorId = 2 << 24 | iStation << 16;
61 fZ = z;
62 fD = d;
63 fRadLength = rl;
64 fRmin = rmin;
65 fRmax = rmax;
66 fRotation = rotation;
67 fSectors = new TObjArray(100);
68 fSectorMap.clear();
69
70 for (Int_t isz = 0; isz < 10; isz++)
71 fSensorZ[isz] = -666.;
72 fSensorZ[0] = z;
73}
74
75// ----- Destructor ----------------------------------------------------
77{
78 if (fSectors) {
79 fSectors->Delete();
80 delete fSectors;
81 }
82}
83// -------------------------------------------------------------------------
84
85// ----- Public method GetNChannels ------------------------------------
87{
88 Int_t nChan = 0;
89 for (Int_t iSect = 0; iSect < GetNSectors(); iSect++)
90 if (GetSector(iSect)->GetNChannels() > 0)
91 nChan += GetSector(iSect)->GetNChannels();
92 return nChan;
93}
94// -------------------------------------------------------------------------
95
96// ----- Public method GetSectorByNr -----------------------------------
98{
99 if (fSectorMap.find(sectorNr) != fSectorMap.end()) {
100 Int_t index = fSectorMap[sectorNr];
101 return (CbmStsSector*)fSectors->At(index);
102 } else {
103 cout << "-W- CbmStsStation::GetSectorByNr: sector " << sectorNr << " not found (station " << GetStationNr()
104 << ")." << endl;
105 return NULL;
106 }
107}
108// -------------------------------------------------------------------------
109
110// ----- Public method AddSector ---------------------------------------
112{
113
114 // Get digitisation parameters
115 Int_t iSector = sectorPar->GetSectorNr();
116
117 // Check for previous existence of sector
118 if (fSectorMap.find(iSector) != fSectorMap.end()) {
119 cout << "-W- " << fName << "::AddSector: Sector number " << iSector << " already existing for station "
120 << GetStationNr() << endl;
121 return;
122 }
123
124 // Calculate detectorId and rotation in global c.s.
125 Int_t detId = 2 << 24 | (GetStationNr() << 16) | (iSector << 4);
126
127 // Number of existing sectors
128 Int_t nSectors = fSectors->GetEntries();
129
130 // Create and add new sector
131 fSectors->Add(new CbmStsSector(Form("%ssect%d", fName.Data(), iSector), detId));
132
133 fSectorMap[iSector] = nSectors;
134}
135// -------------------------------------------------------------------------
136
137// ----- Public method AddSector ---------------------------------------
139{
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// -------------------------------------------------------------------------
152{
153 if (fSensorZ[it] < -665.) {
154 Int_t knownZPos = 0;
155 for (knownZPos = 0; knownZPos < 10; knownZPos++) {
156 if (fSensorZ[knownZPos] < -665.)
157 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)
172 continue;
173
174 fSensorZ[knownZPos] = sensor->GetZ0();
175 knownZPos++;
176 }
177 }
178 }
179 return fSensorZ[it];
180}
181// -------------------------------------------------------------------------
182
183// -------------------------------------------------------------------------
185{
186 Int_t knownZPos = 0;
187 for (knownZPos = 0; knownZPos < 10; knownZPos++) {
188 if (fSensorZ[knownZPos] < -665.)
189 break;
190 }
191
192 for (Int_t iSect = GetNSectors(); iSect > 0; iSect--) {
193 CbmStsSector* sector = (CbmStsSector*)GetSector(iSect - 1);
194 for (Int_t iSens = sector->GetNSensors(); iSens > 0; iSens--) {
195 CbmStsSensor* sensor = (CbmStsSensor*)sector->GetSensor(iSens - 1);
196 Bool_t knownAlready = kFALSE;
197 for (Int_t isz = 0; isz < knownZPos; isz++)
198 if (TMath::Abs(sensor->GetZ0() - fSensorZ[isz]) < 0.0001) {
199 knownAlready = kTRUE;
200 break;
201 }
202
203 if (knownAlready)
204 continue;
205
206 fSensorZ[knownZPos] = sensor->GetZ0();
207 knownZPos++;
208 }
209 }
210 return knownZPos;
211}
212// -------------------------------------------------------------------------
213
214// ----- Public method Reset -------------------------------------------
216{
217 for (Int_t iSector = 0; iSector < GetNSectors(); iSector++)
218 GetSector(iSector)->Reset();
219}
220// -------------------------------------------------------------------------
221
222// ----- Public method Print -------------------------------------------
224{
225 cout << "Station Nr. ";
226 cout.width(2);
227 cout << GetStationNr() << ", z = ";
228 cout.width(3);
229 cout << fZ << " cm, Rmin = ";
230 cout.width(5);
231 cout << fRmin << " cm, Rmax = " << fRmax << " cm, angle = ";
232 cout.width(3);
233 cout << fRotation * 180 / TMath::Pi() << " deg., sectors: ";
234 cout.width(4);
235 cout << GetNSectors() << ", channels: ";
236 cout.width(8);
237 cout << GetNChannels() << endl;
238 if (kLong)
239 for (Int_t iSec = 0; iSec < GetNSectors(); iSec++)
240 GetSector(iSec)->Print();
241}
242// -------------------------------------------------------------------------
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
CbmStsSectorDigiPar.h.
Int_t GetSectorNr() const
Accessors.
void Reset()
Clear the maps of fired strips.
Int_t GetSectorNr() const
Int_t GetNChannels() const
void Print()
Screen output.
CbmStsSensor * GetSensor(Int_t iSensor)
Int_t GetNSensors() const
Double_t GetZ0() const
Double32_t fRadLength
CbmStsStation()
Default constructor.
virtual void Print(Bool_t kLong)
Output to screen.
Double32_t fRmin
Int_t GetNSectors() const
std::map< Int_t, Int_t > fSectorMap
std::map< Int_t, Int_t > fMcIdMap
Map from sector number to index.
Double32_t fRotation
Double32_t fD
Double32_t fZ
void AddSector(CbmStsSectorDigiPar *sectorPar)
Add one sector to the array.
TObjArray * fSectors
void Reset()
Reset all eventwise counters.
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()
Destructor.
Double_t fSensorZ[30]
Map from McId to index.
constexpr Double_t Pi()
Double_t Abs(Double_t d)