BmnRoot
Loading...
Searching...
No Matches
CbmStsSector.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsStripSector source file -----
3// ----- Created 02/03/05 by V. Friese -----
4// -------------------------------------------------------------------------
5
6#include "CbmStsSector.h"
7
8#include "CbmStsSensor.h"
10#include "FairLogger.h"
11#include "TMath.h"
12
13#include <iostream>
14#include <list>
15#include <vector>
16
17using std::cout;
18using std::endl;
19using std::pair;
20using std::vector;
21
22// ----- Default constructor -------------------------------------------
24 : TNamed()
25 , fDetectorId(0)
26 , fSensors(new TObjArray(100))
27 , fType(-666)
28 , fRotation(-666.)
29 , fDx(-666.)
30 , fDy(-666.)
31 , fStereoF(-666.)
32 , fStereoB(-666.)
33 , fSigmaX(0.)
34 , fSigmaY(0.)
35 , fSigmaXY(0.)
36 , fNChannelsFront(0)
37 , fNChannelsBack(0)
38 , fFrontActive()
39 , fBackActive()
40 , fSensorMap()
41 , fTrueHits()
42{
43 cout << "-W- CbmStsSector: Do not use this constructor! " << endl;
44 fSensorMap.clear();
45}
46
47// ----- Standard constructor ------------------------------------------
48CbmStsSector::CbmStsSector(TString tempName, Int_t detId)
49 : TNamed(tempName.Data(), "")
50 , fDetectorId(detId)
51 , fSensors(new TObjArray(100))
52 , fType(-1)
53 , fRotation(-666.)
54 , fDx(-666.)
55 , fDy(-666.)
56 , fStereoF(-666.)
57 , fStereoB(-666.)
58 , fSigmaX(0.)
59 , fSigmaY(0.)
60 , fSigmaXY(0.)
61 , fNChannelsFront(0)
62 , fNChannelsBack(0)
63 , fFrontActive()
64 , fBackActive()
65 , fSensorMap()
66 , fTrueHits()
67{
68 fSensorMap.clear();
69}
70
71// ----- Destructor ----------------------------------------------------
73{
74 if (fSensors) {
75 fSensors->Delete();
76 delete fSensors;
77 }
78}
79// -------------------------------------------------------------------------
80
81// ----- Public method PointIndex --------------------------------------
82Int_t CbmStsSector::PointIndex(Int_t iFStrip, Int_t iBStrip)
83{
84 pair<Int_t, Int_t> a(iFStrip, iBStrip);
85 if (fTrueHits.find(a) == fTrueHits.end())
86 return -1;
87 return fTrueHits[a];
88}
89// -------------------------------------------------------------------------
90
91// ----- Public method Reset -------------------------------------------
93{
94 fFrontActive.clear();
95 fBackActive.clear();
96 fTrueHits.clear();
97}
98// -------------------------------------------------------------------------
99
100// ----- Public method Print -------------------------------------------
102{
103 cout << " Sector Nr. ";
104 cout.width(3);
105 cout << GetSectorNr() << ", Type ";
106 cout << GetNChannels() << endl;
107}
108// -------------------------------------------------------------------------
109
110// ----- Public method GetSectorByNr -----------------------------------
112{
113 if (fSensorMap.find(sensorNr) != fSensorMap.end()) {
114 Int_t index = fSensorMap[sensorNr];
115 return (CbmStsSensor*)fSensors->At(index);
116 } else {
117 cout << "-W- CbmStsSector::GetSensorByNr: sensor " << sensorNr << " not found (sector " << GetSectorNr() << ")."
118 << endl;
119 return NULL;
120 }
121}
122// -------------------------------------------------------------------------
123
124// ----- Public method AddSensor ---------------------------------------
126{
127
128 // Get digitisation parameters
129 Int_t iSensor = sensorPar->GetSensorNr();
130 Int_t iType = sensorPar->GetType();
131 Double_t x0 = sensorPar->GetX0();
132 Double_t y0 = sensorPar->GetY0();
133 Double_t z0 = sensorPar->GetZ0();
134 Double_t rotRel = sensorPar->GetRotation();
135 Double_t lx = sensorPar->GetLx();
136 Double_t ly = sensorPar->GetLy();
137 Double_t d = sensorPar->GetD();
138 Double_t dx = sensorPar->GetDx();
139 Double_t dy = sensorPar->GetDy();
140 Double_t stereoF = sensorPar->GetStereoF();
141 Double_t stereoB = sensorPar->GetStereoB();
142
143 // Check for previous existence of sensor
144 if (fSensorMap.find(iSensor) != fSensorMap.end()) {
145 cout << "-W- " << fName << "::AddSensor: Sensor number " << iSensor << " already existing for sector "
146 << GetSectorNr() << endl;
147 return;
148 }
149
150 // Calculate detectorId
151 Int_t sensorId = fDetectorId | iSensor << 1;
152
153 // Number of existing sensors
154 Int_t nSensors = fSensors->GetEntries();
155
156 // Create and add new sensor
157 CbmStsSensor* tempSens = new CbmStsSensor(Form("%ssens%d", fName.Data(), iSensor), sensorId, iType, x0, y0, z0,
158 rotRel, lx, ly, d, dx, dy, stereoF, stereoB);
159 fSensors->Add(tempSens);
160
161 Double_t sigmaX = tempSens->GetSigmaX();
162 Double_t sigmaY = tempSens->GetSigmaY();
163 Double_t sigmaXY = tempSens->GetSigmaXY();
164 Int_t nofChF = tempSens->GetNChannelsFront();
165 Int_t nofChB = tempSens->GetNChannelsBack();
166 if (nSensors == 0) {
167 fType = iType;
168 fRotation = rotRel;
169 fDx = dx;
170 fDy = dy;
171 fStereoF = stereoF;
172 fStereoB = stereoB;
173 fSigmaX = sigmaX;
174 fSigmaY = sigmaY;
175 fSigmaXY = sigmaXY;
176 fNChannelsFront = nofChF;
177 fNChannelsBack = nofChB;
178 } else {
179 if (fType != iType)
180 LOG(fatal) << "Sensor types do not match: " << fType << " vs " << iType;
181 if (fRotation != rotRel)
182 LOG(fatal) << "Sensor rotation do not match";
183 if (fDx != dx)
184 LOG(fatal) << "Sensor dx do not match";
185 if (fDy != dy)
186 LOG(fatal) << "Sensor dy do not match";
187 if (fStereoF != stereoF)
188 LOG(fatal) << "Sensor stereoF do not match";
189 if (fStereoB != stereoB)
190 LOG(fatal) << "Sensor stereoB do not match";
191 if (fSigmaX != sigmaX)
192 LOG(fatal) << "Sensor sigmaX do not match";
193
194 if (fSigmaY != sigmaY)
195 LOG(fatal) << "Sensor sigmaY do not match";
196 if (fSigmaXY != sigmaXY)
197 LOG(fatal) << "Sensor sigmaXY do not match";
198 if (fNChannelsFront != nofChF)
199 LOG(fatal) << "Sensor nofChanF do not match";
200 if (fNChannelsBack != nofChB)
201 LOG(fatal) << "Sensor nofChanB do not match";
202 }
203
204 fSensorMap[iSensor] = nSensors;
205}
206// -------------------------------------------------------------------------
207
208// ----- Public method AddSensor ---------------------------------------
210{
211
212 Int_t iSensor = sensor->GetSensorNr();
213 Int_t nSensors = fSensors->GetEntries();
214
215 Int_t iType = sensor->GetType();
216 Double_t rotRel = sensor->GetRotation();
217 Double_t dx = sensor->GetDx();
218 Double_t dy = sensor->GetDy();
219 Double_t stereoF = sensor->GetStereoF();
220 Double_t stereoB = sensor->GetStereoB();
221 Double_t sigmaX = sensor->GetSigmaX();
222 Double_t sigmaY = sensor->GetSigmaY();
223 Double_t sigmaXY = sensor->GetSigmaXY();
224 Int_t nofChF = sensor->GetNChannelsFront();
225 Int_t nofChB = sensor->GetNChannelsBack();
226 if (nSensors == 0) {
227 fType = iType;
228 fRotation = rotRel;
229 fDx = dx;
230 fDy = dy;
231 fStereoF = stereoF;
232 fStereoB = stereoB;
233 fSigmaX = sigmaX;
234 fSigmaY = sigmaY;
235 fSigmaXY = sigmaXY;
236 fNChannelsFront = nofChF;
237 fNChannelsBack = nofChB;
238 } else {
239 if (fType != iType)
240 LOG(fatal) << "Sensor types do not match: " << fType << " vs " << iType;
241 if (fRotation != rotRel)
242 LOG(fatal) << "Sensor rotation do not match";
243 if (fDx != dx)
244 LOG(fatal) << "Sensor dx do not match";
245 if (fDy != dy)
246 LOG(fatal) << "Sensor dy do not match";
247 if (fStereoF != stereoF)
248 LOG(fatal) << "Sensor stereoF do not match";
249 if (fStereoB != stereoB)
250 LOG(fatal) << "Sensor stereoB do not match";
251 if (fSigmaX != sigmaX)
252 LOG(fatal) << "Sensor sigmaX do not match";
253
254 if (fSigmaY != sigmaY)
255 LOG(fatal) << "Sensor sigmaY do not match";
256 if (fSigmaXY != sigmaXY)
257 LOG(fatal) << "Sensor sigmaXY do not match";
258
259 if (fNChannelsFront != nofChF)
260 LOG(fatal) << "Sensor nofChanF do not match";
261 if (fNChannelsBack != nofChB)
262 LOG(fatal) << "Sensor nofChanB do not match";
263 }
264
265 fSensors->Add(sensor);
266
267 fSensorMap[iSensor] = nSensors;
268}
269// -------------------------------------------------------------------------
270
271// ----- Public method Intersect ---------------------------------------
272Int_t CbmStsSector::Intersect(Int_t iFStrip, Int_t iBStrip, Double_t& xCross, Double_t& yCross, Double_t& zCross)
273{
274
275 Double_t xPoint = xCross, yPoint = yCross; // AZ
276 xCross = 0.;
277 yCross = 0.;
278 zCross = 0.;
279
280 // AZ Double_t xTemp, yTemp, zTemp=0.;
281 Double_t xTemp = xPoint, yTemp = yPoint, zTemp = 0.; // AZ
282
283 Int_t tempDetId = -1;
284 Int_t returnDetId = -1;
285
286 CbmStsSensor* sensor;
287 for (Int_t iSens = 0; iSens < GetNSensors(); iSens++) {
288 sensor = (CbmStsSensor*)GetSensor(iSens);
289
290 tempDetId = sensor->Intersect(iFStrip, iBStrip, xTemp, yTemp, zTemp);
291
292 if (tempDetId == -1)
293 continue; // not in the sensor
294 // AZ - pixel simulation
295 if (TMath::Abs(TMath::Abs(fStereoF - fStereoB) * TMath::RadToDeg() - 90) < 0.1) {
296 // if (TMath::Abs(xTemp-xPoint) > 0.5 || TMath::Abs(yTemp-yPoint) > 0.5) continue;
297 } //
298
299 if (zCross > 0.001) {
300 LOG(fatal) << "Software do not cope with two strips intersecting in different regions";
301 }
302
303 xCross = xTemp;
304 yCross = yTemp;
305 zCross = zTemp;
306 returnDetId = tempDetId;
307 }
308
309 return returnDetId;
310}
311// -------------------------------------------------------------------------
312
313// ----- Public method Intersect ---------------------------------------
315 Double_t bChan,
316 Double_t& xCross,
317 Double_t& yCross,
318 Double_t& zCross)
319{
320
321 xCross = 0.;
322 yCross = 0.;
323 zCross = 0.;
324
325 Double_t xTemp, yTemp, zTemp = 0.;
326
327 Int_t tempDetId = -1;
328 Int_t returnDetId = -1;
329
330 CbmStsSensor* sensor;
331 for (Int_t iSens = 0; iSens < GetNSensors(); iSens++) {
332 sensor = (CbmStsSensor*)GetSensor(iSens);
333
334 tempDetId = sensor->IntersectClusters(fChan, bChan, xTemp, yTemp, zTemp);
335
336 if (tempDetId == -1)
337 continue; // not in the sensor
338
339 if (zCross > 0.001)
340 LOG(fatal) << "Software do not cope with two strips intersecting in different regions";
341
342 xCross = xTemp;
343 yCross = yTemp;
344 zCross = zTemp;
345 returnDetId = tempDetId;
346 }
347
348 return returnDetId;
349}
350// -------------------------------------------------------------------------
const Float_t d
Z-ccordinate of the first GEM-station.
Definition BmnMwpcHit.cxx:7
const Float_t z0
Definition BmnMwpcHit.cxx:6
void AddSensor(CbmStsSensorDigiPar *sensorPar)
Int_t GetSectorNr() const
CbmStsSensor * GetSensorByNr(Int_t sensorNr)
virtual ~CbmStsSector()
Int_t IntersectClusters(Double_t fChan, Double_t bChan, Double_t &xCross, Double_t &yCross, Double_t &zCross)
Int_t PointIndex(Int_t iFStrip, Int_t IBStrip)
Int_t GetNChannels() const
Int_t Intersect(Int_t iFStrip, Int_t iBStrip, Double_t &xCross, Double_t &yCross, Double_t &zCross)
CbmStsSensor * GetSensor(Int_t iSensor)
Int_t GetNSensors() const
Double_t GetRotation() const
Double_t GetStereoB() const
Double_t GetStereoF() const
Double_t GetStereoF() const
Double_t GetSigmaXY() const
Double_t GetSigmaY() const
Double_t GetRotation() const
Int_t GetNChannelsFront() const
Int_t IntersectClusters(Double_t fChan, Double_t bChan, Double_t &xCross, Double_t &yCross, Double_t &zCross)
Double_t GetDy() const
Int_t GetType() const
Int_t GetNChannelsBack() const
Int_t Intersect(Int_t iFStrip, Int_t iBStrip, std::vector< Double_t > &xCross, std::vector< Double_t > &yCross)
Double_t GetDx() const
Double_t GetSigmaX() const
Double_t GetStereoB() const
Int_t GetSensorNr() const