CbmRoot
Loading...
Searching...
No Matches
CbmTrdParModDigi.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer], Alexandru Bercuci */
4
5#include "CbmTrdParModDigi.h"
6
7#include "CbmTrdAddress.h" // for CbmTrdAddress
8#include "CbmTrdPoint.h" // for CbmTrdPoint
9
10#include <Logger.h> // for LOG, Severity, Severity::debug2
11
12#include <TGeoManager.h> // for TGeoManager, gGeoManager
13#include <TString.h> // for TString
14#include <TVector3.h> // for TVector3
15
16#include <cmath> // for fabs
17#include <cstdio> // for printf
18#include <cstring> // for strcmp
19#include <iomanip> // for setprecision, __iom_t5
20
21using namespace cbm::trd;
22
23//___________________________________________________________________
25 : CbmTrdParMod("CbmTrdParModDigi", "TRD read-out definition")
26 , fNofSectors(1)
27 , fOrientation(0)
28 , fAnodeWireOffset(0.375)
29 , fAnodeWireSpacing(0.25)
31 , fX(0.)
32 , fY(0.)
33 , fZ(0.)
34 , fSizeX(0)
35 , fSizeY(0)
36 , fSizeZ(0)
37 , fSectorX()
38 , fSectorY()
39 , fSectorZ()
42 , fSectorEndX()
43 , fSectorEndY()
44 , fSectorSizeX()
45 , fSectorSizeY()
46 , fPadSizeX()
47 , fPadSizeY()
48{
49}
50//___________________________________________________________________
51CbmTrdParModDigi::CbmTrdParModDigi(Double_t x, Double_t y, Double_t z, Double_t sizex, Double_t sizey, Double_t sizez,
52 Int_t nofSectors, Int_t orientation, const TArrayD& sectorSizeX,
53 const TArrayD& sectorSizeY, const TArrayD& padSizeX, const TArrayD& padSizeY)
54 : CbmTrdParMod("CbmTrdParModDigi", "TRD read-out definition")
55 , fNofSectors(nofSectors)
56 , fOrientation(orientation)
57 , fAnodeWireOffset(0.375)
58 , fAnodeWireSpacing(0.25)
60 , fX(x)
61 , fY(y)
62 , fZ(z)
63 , fSizeX(sizex)
64 , fSizeY(sizey)
65 , fSizeZ(sizez)
66 , fSectorX(nofSectors)
67 , fSectorY(nofSectors)
68 , fSectorZ(nofSectors)
69 , fSectorBeginX(nofSectors)
70 , fSectorBeginY(nofSectors)
71 , fSectorEndX(nofSectors)
72 , fSectorEndY(nofSectors)
73 , fSectorSizeX(sectorSizeX)
74 , fSectorSizeY(sectorSizeY)
75 , fPadSizeX(padSizeX)
76 , fPadSizeY(padSizeY)
77{
84 if (nofSectors > 1) {
85 Double_t beginx, beginy, endx, endy;
86 Double_t summed_sectsize;
87 if (sectorSizeX.GetAt(0) == 2 * sizex) { //substructure only in y-direction
88 beginx = 0;
89 endx = 2 * sizex;
90 summed_sectsize = 0;
91 for (Int_t i = 0; i < fNofSectors; i++) {
92 if (0 == i) {
93 beginy = 0.;
94 endy = sectorSizeY.GetAt(i);
95 summed_sectsize += sectorSizeY.GetAt(i);
96 }
97 else {
98 beginy = summed_sectsize;
99 endy = summed_sectsize += sectorSizeY.GetAt(i);
100 }
101 fSectorBeginX.AddAt(beginx, i);
102 fSectorBeginY.AddAt(beginy, i);
103 fSectorEndX.AddAt(endx, i);
104 fSectorEndY.AddAt(endy, i);
105 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
106 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
107 fSectorZ.AddAt(fZ, i);
108 }
109 }
110 else {
111 LOG(warn) << GetName()
112 << "::CbmTrdParModDigi - detect different information on "
113 "module size x : geometry="
114 << std::setprecision(5) << 2 * sizex << " CbmTrdPads.h=" << sectorSizeX.GetAt(0);
115 beginy = 0;
116 endy = 2 * sizey;
117 summed_sectsize = 0;
118 for (Int_t i = 0; i < fNofSectors; i++) {
119 if (0 == i) {
120 beginx = 0.;
121 endx = sectorSizeX.GetAt(i);
122 summed_sectsize += sectorSizeX.GetAt(i);
123 }
124 else {
125 beginx = summed_sectsize;
126 endx = summed_sectsize += sectorSizeX.GetAt(i);
127 }
128 fSectorBeginX.AddAt(beginx, i);
129 fSectorBeginY.AddAt(beginy, i);
130 fSectorEndX.AddAt(endx, i);
131 fSectorEndY.AddAt(endy, i);
132 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
133 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
134 fSectorZ.AddAt(fZ, i);
135 }
136 }
137 }
138 else {
139 fSectorBeginX.AddAt(0., 0);
140 fSectorBeginY.AddAt(0., 0);
141 fSectorEndX.AddAt(sectorSizeX.GetAt(0), 0);
142 fSectorEndY.AddAt(sectorSizeY.GetAt(0), 0);
143 fSectorX.AddAt(x, 0);
144 fSectorY.AddAt(y, 0);
145 fSectorZ.AddAt(z, 0);
146 }
147}
148
149//___________________________________________________________________________
150void CbmTrdParModDigi::Print(Option_t* opt) const
151{
155 printf(" CbmTrdParModDigi @ %5d ly[%d] idLy[%3d] rotation[%3ddeg] rows[%2d] "
156 "cols[%3d]\n",
159 if (strcmp(opt, "all") != 0) return;
160 printf(" center [%7.2f %7.2f %7.2f]\n"
161 " size [%7.2f %7.2f %7.2f]\n"
162 " anode pitch[%5.3f] d2PP[%5.3f] off[%5.3f]\n"
163 " pads ",
165 for (Int_t isec(0); isec < fNofSectors; isec++)
166 printf(" [c(%3d) r(%2d)]x[w(%4.2f) h(%5.2f)] area[%5.2fx%5.2f] limits "
167 "x[%5.2f %5.2f] y[%5.2f %5.2f]\n ",
168 GetNofColumnsInSector(isec), GetNofRowsInSector(isec), fPadSizeX.At(isec), fPadSizeY.At(isec),
169 fSectorSizeX[isec], fSectorSizeY[isec], fSectorBeginX[isec], fSectorEndX[isec], fSectorBeginY[isec],
170 fSectorEndY[isec]);
171 printf("\n");
172}
173
174//___________________________________________________________________________
176{
182
183 if (/*fAnodeWireOffset > 0.0 && */ fAnodeWireSpacing > 0.0) { // wires must be defined defined
184
185 // check, if the input is within the allowed range
186 if (fabs(local_point[1]) - fSizeY > 1.e-3)
187 LOG(error) << "CbmTrdParModDigi::ProjectPositionToNextAnodeWire - local "
188 "point must be within gas volume, y="
189 << std::setprecision(5) << local_point[1] << " module size " << fSizeY;
190
191 Double_t ypos = local_point[1];
192
193 LOG(debug2) << "local y before projection: " << std::setprecision(5) << local_point[1] << " cm";
194
195 // make sure, local_point[1] is not negative (due to module center coordinate)
196 // therefore transform to local corner first and then back at the end of operation
197 local_point[1] += fSizeY; // transform to module corner coordinates
198
199 local_point[1] = Int_t(((local_point[1] - fAnodeWireOffset) / fAnodeWireSpacing) + 0.5) * fAnodeWireSpacing
200 + fAnodeWireOffset; // find closest anode wire
201
202 if (local_point[1] > 2 * fSizeY - fAnodeWireOffset)
203 local_point[1] = 2 * fSizeY - fAnodeWireOffset; // move inwards to the last anode wire
204
205 local_point[1] -= fSizeY; // transform back to module center coordinates
206
207 LOG(debug2) << "local y after projection: " << std::setprecision(5) << local_point[1] << " cm";
208
209 // check, if we have left the anode wire grid
210 if (fabs(local_point[1]) > fSizeY - fAnodeWireOffset)
211 LOG(error) << "CbmTrdParModDigi::ProjectPositionToNextAnodeWire - local "
212 "point projected outside anode wire plane, from "
213 << std::setprecision(5) << ypos << " to " << std::setprecision(5) << local_point[1]
214 << " - last anode wire at " << std::setprecision(5) << fSizeY - fAnodeWireOffset;
215 }
216 else {
217 LOG(error) << "CbmTrdParModDigi::ProjectPositionToNextAnodeWire: "
218 "fAnodeWireOffset and fAnodeWireSpacing not set. "
219 "ProjectPositionToNextAnodeWire can not be used.";
220 }
221}
222
223//___________________________________________________________________________
225{
226 if (fVersion == 0) return -1; // legacy parameters
227 return int(HasPadPlane2D(fConfig));
228}
229
230//___________________________________________________________________________
231Int_t CbmTrdParModDigi::GetSector(const Double_t* local_point) const
232{
239
240 Double_t posx, posy;
241
242 TransformToLocalCorner(local_point, posx, posy);
243 for (Int_t i = 0; i < fNofSectors; i++) {
244 if (posx >= fSectorBeginX[i] && posx <= fSectorEndX[i] && posy >= fSectorBeginY[i] && posy <= fSectorEndY[i]) {
245 return i;
246 }
247 }
248
249 LOG(error) << "CbmTrdParModDigi::GetSector: Could not find local point [" << local_point[0] << " " << local_point[1]
250 << "] in any of the sectors";
251 Print("all");
252 return -1; // This should be never reached
253}
254
255//___________________________________________________________________________
257{
261
262 if ((npady < 0) || (npady > GetNofRows() - 1)) {
263 LOG(error) << "CbmTrdParModDigi::GetSector - there is no such row number: " << npady;
264 return -1;
265 }
266
267 Int_t secRows = 0; // number of rows in sector
268 Int_t nofRows = 0; // number of rows in total
269
270 if (fSectorSizeY.At(0) < fSizeY) { // if there are sectors in y direction
271 for (Int_t iSector = 0; iSector < fNofSectors; iSector++) { // for each sector
272 secRows = (Int_t)(fSectorSizeY.At(iSector) / fPadSizeY.At(iSector) + 0.5); // need to round for correct result
273 if (npady < nofRows + secRows) { // if we are in the sector containing the pad
274 // note nypad = 12 is not in sector 0, with rowIds 0..11
275 rowId = npady - nofRows;
276
277 LOG(debug2) << "npady : " << npady << " <= " << nofRows + secRows << " rowId " << rowId << " nRows(sec-1) "
278 << nofRows << " sec " << iSector;
279
280 if ((rowId < 0) || (rowId > GetNofRowsInSector(iSector) - 1))
281 LOG(fatal) << "CbmTrdParModDigi::GetModuleRow rowId " << rowId << " of "
282 << GetNofRowsInSector(iSector) - 1
283 //<< " in moduleAddress " << fModuleAddress
284 << " is out of bounds!";
285
286 return iSector; // return sector
287 }
288 nofRows += secRows; // sum up new total number of rows
289 }
290 }
291 LOG(error) << "CbmTrdParModDigi::GetSector: Could not find pad in any of the sectors";
292 return -1; // This should be never reached
293}
294
295
296//___________________________________________________________________________
298{
302
303 Int_t nofColumns = 0;
304 if (fSectorSizeX.At(0) < fSizeX) {
305 for (Int_t i = 0; i < fNofSectors; i++) {
306 nofColumns += (Int_t)(fSectorSizeX.At(i) / fPadSizeX.At(i) + 0.5); // need to round for correct result
307 }
308 }
309 else {
310 nofColumns = (Int_t)(fSectorSizeX.At(0) / fPadSizeX.At(0) + 0.5); // need to round for correct result
311 }
312 return nofColumns;
313}
314
315//___________________________________________________________________________
317{
321 Int_t nofRows = 0;
322 if (fSectorSizeY.At(0) < fSizeY) {
323 for (Int_t i = 0; i < fNofSectors; i++) {
324 nofRows += (Int_t)(fSectorSizeY.At(i) / fPadSizeY.At(i) + 0.5); // need to round for correct result
325 }
326 }
327 else {
328 nofRows = (Int_t)(fSectorSizeY.At(0) / fPadSizeY.At(0) + 0.5); // need to round for correct result
329 }
330 return nofRows;
331}
332
333
334//___________________________________________________________________________
336{
337 return (Int_t)(fSectorSizeX.At(i) / fPadSizeX.At(i) + 0.5); // need to round for correct result
338}
339
340
341//___________________________________________________________________________
343{
344 return (Int_t)(fSectorSizeY.At(i) / fPadSizeY.At(i) + 0.5); // need to round for correct result
345}
346
347
348//___________________________________________________________________________
350{
351
352 // check limits
353 if ((sectorId < 0) || (sectorId > GetNofSectors() - 1))
354 LOG(fatal) << "CbmTrdParModDigi::GetModuleRow sectorId " << sectorId << " of "
355 << GetNofSectors() - 1
356 //<< " in moduleAddress " << fModuleAddress
357 << " is out of bounds!";
358
359 // check limits
360 if ((rowId < 0) || (rowId > GetNofRowsInSector(sectorId) - 1))
361 LOG(fatal) << "CbmTrdParModDigi::GetModuleRow rowId " << rowId << " of "
362 << GetNofRowsInSector(sectorId) - 1
363 //<< " in moduleAddress " << fModuleAddress
364 << " is out of bounds!";
365
366 Int_t moduleRowId = rowId;
367
368 // calculate row number within module
369 for (Int_t iSector = 0; iSector < sectorId; iSector++) {
370 moduleRowId += (Int_t)(fSectorSizeY.At(iSector) / fPadSizeY.At(iSector) + 0.5);
371 // LOG(info) << "adding sector " << iSector << " of " << sectorId;
372 }
373
374 // if (sectorId == 0)
375 // // do nothing
376 // if (sectorId >= 1)
377 // moduleRowId += (Int_t)(fSectorSizeY.At(0) / fPadSizeY.At(0) + 0.5);
378 // if (sectorId >= 2)
379 // moduleRowId += (Int_t)(fSectorSizeY.At(1) / fPadSizeY.At(1) + 0.5);
380
381 return moduleRowId;
382}
383
384
385//___________________________________________________________________________
387{
388 // check limits
389 if ((growId < 0) || (growId >= GetNofRows()))
390 LOG(fatal) << "CbmTrdParModDigi::GetSectorRow rowId " << growId << " of "
391 << GetNofRows()
392 //<< " in moduleAddress " << fModuleAddress
393 << " is out of bounds!";
394
395 rowId = growId;
396
397 // calculate row number within sector
398 Int_t iSector(0);
399 for (; iSector < 3; iSector++) {
400 Int_t nr(GetNofRowsInSector(iSector));
401 if (rowId - nr + 1 > 0) rowId -= nr;
402 else
403 break;
404 }
405
406 return iSector;
407}
408
409
410//___________________________________________________________________________
411Bool_t CbmTrdParModDigi::GetPadInfo(const Double_t* local_point, Int_t& sectorId, Int_t& columnId, Int_t& rowId) const
412{
413 // check, if the input is within the allowed range
414 if (fabs(local_point[0]) > fSizeX) {
415 LOG(warn) << "CbmTrdParModDigi::GetPadInfo - local point x must be within "
416 "gas volume, x="
417 << std::setprecision(8) << local_point[0] << " fSizeX=" << std::setprecision(8) << fSizeX;
418 return kFALSE;
419 }
420 if (fabs(local_point[1]) > fSizeY) {
421 LOG(warn) << "CbmTrdParModDigi::GetPadInfo - local point y must be within "
422 "gas volume, y="
423 << std::setprecision(8) << local_point[1] << " fSizeY=" << std::setprecision(8) << fSizeY;
424 return kFALSE;
425 }
426
427 Double_t posX, posY;
428 TransformToLocalSector(local_point, posX, posY);
429
430 // calculate in which sector the point is
431 sectorId = GetSector(local_point);
432
433 columnId = (Int_t)(posX / fPadSizeX.At(sectorId));
434 rowId = (Int_t)(posY / fPadSizeY.At(sectorId));
435
436 return kTRUE;
437}
438
439//___________________________________________________________________________
440void CbmTrdParModDigi::GetPadInfo(const CbmTrdPoint* trdPoint, Int_t& sectorId, Int_t& columnId, Int_t& rowId) const
441{
450 Double_t x_mean = 0.5 * (trdPoint->GetXIn() + trdPoint->GetXOut());
451 Double_t y_mean = 0.5 * (trdPoint->GetYIn() + trdPoint->GetYOut());
452 Double_t z_mean = 0.5 * (trdPoint->GetZIn() + trdPoint->GetZOut());
453 gGeoManager->FindNode(x_mean, y_mean, z_mean);
454
455 TString curNode = gGeoManager->GetPath();
456 if (!curNode.Contains("gas")) {
457 // if the point is not in the gas volume print warning
458 LOG(warn) << "This point is not in the trd gas";
459 /*
460 LOG(warn) << "x: " << std::setprecision(7) << trdPoint->GetXIn() << ", " << trdPoint->GetXOut();
461 LOG(warn) << "y: " << std::setprecision(7) << trdPoint->GetYIn() << ", " << trdPoint->GetYOut();
462 LOG(warn) << "z: " << std::setprecision(7) << trdPoint->GetZIn() << ", " << trdPoint->GetZOut();
463 */
464 sectorId = -1;
465 return;
466 }
467
468 // Get the local point in local MC coordinates from
469 // the geomanager. This coordinate system is rotated
470 // if the chamber is rotated. This is corrected in
471 // GetModuleInformation to have a
472 // the same local coordinate system in all the chambers
473 const Double_t* global_point = gGeoManager->GetCurrentPoint();
474 Double_t local_point[3];
475
476 gGeoManager->MasterToLocal(global_point, local_point);
477
478 // 20131009 - DE - debuging output to check module orientation 0,1,2,3 with box generator
479 if (fair::Logger::Logging(fair::Severity::debug2)) {
480 // print module orientation
481 LOG(debug2) << "module orientation: " << std::setprecision(5) << fOrientation;
482
483 // print global coordinate
484 LOG(debug2) << "global x: " << std::setprecision(5) << global_point[0] << " y: " << std::setprecision(5)
485 << global_point[1] << " z: " << std::setprecision(5) << global_point[2];
486
487 // print local coordinate - relative to module center
488 LOG(debug2) << "local x: " << std::setprecision(5) << local_point[0] << " y: " << std::setprecision(5)
489 << local_point[1] << " z: " << std::setprecision(5) << local_point[2];
490
491 // test projection to next anode wire
492 Double_t proj_point[3];
493 proj_point[0] = local_point[0];
494 proj_point[1] = local_point[1];
495 proj_point[2] = local_point[2];
496
498
499 // print local coordinate - relative to module center
500 LOG(debug2) << "proj x: " << std::setprecision(5) << proj_point[0] << " y: " << std::setprecision(5)
501 << proj_point[1] << " z: " << std::setprecision(5) << proj_point[2];
502
503 Double_t corner_point[3];
504 corner_point[2] = local_point[2];
505 TransformToLocalCorner(local_point, corner_point[0], corner_point[1]);
506
507 // print local coordinate - relative to module corner
508 LOG(debug2) << "corner x: " << std::setprecision(5) << corner_point[0] << " y: " << std::setprecision(5)
509 << corner_point[1] << " z: " << std::setprecision(5) << corner_point[2];
510
511 LOG(debug2) << "pos x: " << std::setprecision(5) << fX << " y: " << std::setprecision(5) << fY
512 << " z: " << std::setprecision(5) << fZ << " ori: " << std::setprecision(5) << fOrientation;
513
514 LOG(debug2) << "size/2 x: " << std::setprecision(5) << fSizeX << " y: " << std::setprecision(5) << fSizeY
515 << " z: " << std::setprecision(5) << fSizeZ;
516
517 Double_t sector_point[3];
518 sector_point[2] = local_point[2];
519 TransformToLocalSector(local_point, sector_point[0], sector_point[1]);
520
521 // print local coordinate - relative to module sector
522 LOG(debug2) << "sector x: " << std::setprecision(5) << sector_point[0] << " y: " << std::setprecision(5)
523 << sector_point[1] << " z: " << std::setprecision(5) << sector_point[2];
524
525 // calculate in which sector the point is
526 sectorId = GetSector(local_point);
527 LOG(debug2) << "sectornr: " << std::setprecision(5) << sectorId;
528
529 LOG(debug2) << "ncol : " << std::setprecision(5) << GetNofColumns();
530 LOG(debug2) << "nrow : " << std::setprecision(5) << GetNofRows();
531
532 // print local coordinate - relative to module sector
533 LOG(debug2) << "sec2 x: " << std::setprecision(5) << fSectorBeginX.GetAt(2) << " y: " << std::setprecision(5)
534 << fSectorBeginY.GetAt(2);
535 LOG(debug2) << "sec1 x: " << std::setprecision(5) << fSectorBeginX.GetAt(1) << " y: " << std::setprecision(5)
536 << fSectorBeginY.GetAt(1);
537 LOG(debug2) << "sec0 x: " << std::setprecision(5) << fSectorBeginX.GetAt(0) << " y: " << std::setprecision(5)
538 << fSectorBeginY.GetAt(0);
539
540 // get pad information
541 Int_t s, c, r;
542 GetPadInfo(local_point, s, c, r);
543 LOG(debug2) << "pad sec: " << s << " col: " << c << " row: " << r;
544 } // debug2
545
546 // Int_t moduleAddress = CbmTrdAddress::GetModuleAddress(trdPoint->GetDetectorID());
548 /*moduleAddress, */ local_point, sectorId, columnId, rowId);
549}
550
551
552//___________________________________________________________________________
553void CbmTrdParModDigi::TransformToLocalCorner(const Double_t* local_point, Double_t& posX, Double_t& posY) const
554{
565 posX = local_point[0] + fSizeX;
566 posY = local_point[1] + fSizeY;
567}
568
569//___________________________________________________________________________
570void CbmTrdParModDigi::TransformToLocalSector(const Double_t* local_point, Double_t& posX, Double_t& posY) const
571{
581 TransformToLocalCorner(local_point, posX, posY);
582 Int_t sector = GetSector(local_point);
583 posX -= fSectorBeginX.GetAt(sector);
584 posY -= fSectorBeginY.GetAt(sector);
585}
586
587
588//___________________________________________________________________________
589void CbmTrdParModDigi::TransformToLocalPad(const Double_t* local_point, Double_t& posX, Double_t& posY) const
590{
598 Double_t sector_point[2];
599 TransformToLocalSector(local_point, sector_point[0], sector_point[1]);
600
601 // TransformToLocalCorner(local_point, posX, posY);
602 Int_t sectorId = GetSector(local_point);
603
604 Double_t padx =
605 (Int_t(sector_point[0] / fPadSizeX.At(sectorId)) + 0.5) * fPadSizeX.At(sectorId); // x position of pad center
606 Double_t pady =
607 (Int_t(sector_point[1] / fPadSizeY.At(sectorId)) + 0.5) * fPadSizeY.At(sectorId); // y position of pad center
608
609 posX = sector_point[0] - padx;
610 posY = sector_point[1] - pady;
611
612 /*
613 // print debug info
614 LOG(info) << "sector x: " << std::setprecision(5) << sector_point[0]
615 << " y: " << std::setprecision(5) << sector_point[1];
616
617 LOG(info) << "pad x: " << std::setprecision(5) << padx
618 << " y: " << std::setprecision(5) << pady;
619
620 LOG(info) << "diff x: " << std::setprecision(5) << posX
621 << " y: " << std::setprecision(5) << posY;
622
623 LOG(info) << "npad x: " << std::setprecision(5) << padx / fPadSizeX.At(sectorId)
624 << " y: " << std::setprecision(5) << pady / fPadSizeY.At(sectorId);
625 */
626}
627
628
629//___________________________________________________________________________
630void CbmTrdParModDigi::TransformHitError(TVector3& hitErr) const
631{
632 Double_t x, y; // ,z;
633 x = hitErr.X();
634 y = hitErr.Y();
635 // z = hitErr.Z();
636
637 //LOG(info) << "ori : " << fOrientation;
638
639 if ((fOrientation == 1) || (fOrientation == 3)) { // for orientations 1 or 3
640 hitErr.SetX(y); // swap errors
641 hitErr.SetY(x); // swap errors
642
643 // LOG(info) << " swapped x and y error";
644 // LOG(info) << "ori : " << fOrientation << " swapped x and y error";
645 }
646}
647
648
649//___________________________________________________________________________
651 //Int_t moduleAddress,
652 const Double_t* local_point, Int_t& sectorId, Int_t& columnId, Int_t& rowId) const
653{
654 // safety check. Up to now always correct, so could be removed.
655 // if (fModuleAddress != moduleAddress) {
656 // LOG(error) << "CbmTrdParModDigi::GetModuleInformation: This is wrong!";
657 // }
658
659 Double_t posX, posY;
660 TransformToLocalSector(local_point, posX, posY);
661
662 // calculate in which sector the point is
663 sectorId = GetSector(local_point);
664
665 columnId = (Int_t)(posX / fPadSizeX.At(sectorId));
666 rowId = (Int_t)(posY / fPadSizeY.At(sectorId));
667}
668
669
670//___________________________________________________________________________
671void CbmTrdParModDigi::GetPadPosition(const Int_t sector, const Int_t col, const Int_t row, TVector3& padPos,
672 TVector3& padPosErr) const
673{
677
678 Double_t posX = 0;
679 Double_t posY = 0;
680 Double_t posZ = 0;
681
682 Double_t padsizex = fPadSizeX.At(sector);
683 Double_t padsizey = fPadSizeY.At(sector);
684
685 // calculate position in sector coordinate system
686 // with the origin in the lower left corner (looking upstream)
687 posX = (((Double_t) col + 0.5) * padsizex);
688 posY = (((Double_t) row + 0.5) * padsizey);
689
690 // calculate position in module coordinate system
691 // with the origin in the lower left corner (looking upstream)
692 posX += fSectorBeginX.GetAt(sector);
693 posY += fSectorBeginY.GetAt(sector);
694
695 // calculate position in the module coordinate system
696 // with origin in the middle of the module
697 posX -= fSizeX;
698 posY -= fSizeY;
699 posZ = 0;
700
701 // check limits
702 if (fabs(posX) > fSizeX) LOG(fatal) << "CbmTrdParModDigi::GetPadPosition posX=" << posX << " is out of bounds!";
703 // check limits
704 if (fabs(posY) > fSizeY) LOG(fatal) << "CbmTrdParModDigi::GetPadPosition posY=" << posY << " is out of bounds!";
705
706 padPos.SetXYZ(posX, posY, posZ);
707 padPosErr.SetXYZ(padsizex / 2., padsizey / 2., 0.);
708}
709
710
711//___________________________________________________________________________
712void CbmTrdParModDigi::GetPadPosition(const Int_t padAddress, TVector3& padPos, TVector3& padPosErr) const
713{
717
718 // Double_t posX = 0;
719 // Double_t posY = 0;
720 // Double_t posZ = 0;
721
722 Int_t sectorId = CbmTrdAddress::GetSectorId(padAddress);
723 Int_t rowId = CbmTrdAddress::GetRowId(padAddress);
724 Int_t columnId = CbmTrdAddress::GetColumnId(padAddress);
725
726 return GetPadPosition(sectorId, rowId, columnId, padPos, padPosErr);
727}
728
729//___________________________________________________________________________
730void CbmTrdParModDigi::GetPadPosition(const Int_t padAddress, bool isCbmTrdDigiAddress, TVector3& padPos,
731 TVector3& padPosErr) const
732{
736 if (!isCbmTrdDigiAddress)
737 LOG(error) << "Trying to get a CbmTrd PadPosition from DigiAddress format "
738 "function without digiAddress format";
739
740
741 Int_t row = GetPadRow(padAddress);
742 Int_t col = GetPadColumn(padAddress);
743
744 Int_t srow(-1);
745 Int_t sector = GetSectorRow(row, srow);
746
747 return GetPadPosition(sector, col, srow, padPos, padPosErr);
748}
749
750//___________________________________________________________________________
752 // Int_t moduleAddress,
753 Int_t sectorId, Int_t columnId, Int_t rowId, TVector3& padPos, TVector3& padSize) const
754{
761 // if (fModuleAddress != moduleAddress) {
762 // LOG(error) << "CbmTrdParModDigi::GetPosition This is wrong!";
763 // }
764
765 // check limits
766 if ((sectorId < 0) || (sectorId > GetNofSectors() - 1))
767 LOG(fatal) << "CbmTrdParModDigi::GetPosition sectorId " << sectorId << " of "
768 << GetNofSectors() - 1 //<< " in moduleAddress " << moduleAddress
769 << " is out of bounds!";
770
771 // check limits
772 if ((columnId < 0) || (columnId > GetNofColumnsInSector(sectorId) - 1))
773 LOG(fatal) << "CbmTrdParModDigi::GetPosition columnId " << columnId << " of "
774 << GetNofColumnsInSector(sectorId) - 1
775 //<< " in moduleAddress " << moduleAddress
776 << " is out of bounds!";
777
778 // check limits
779 if ((rowId < 0) || (rowId > GetNofRowsInSector(sectorId) - 1))
780 LOG(fatal) << "CbmTrdParModDigi::GetPosition rowId " << rowId << " of "
781 << GetNofRowsInSector(sectorId) - 1
782 //<< " in moduleAddress " << moduleAddress
783 << " is out of bounds!";
784
785 Double_t local_point[3];
786 Double_t padsizex = fPadSizeX.At(sectorId);
787 Double_t padsizey = fPadSizeY.At(sectorId);
788
789 // calculate position in sector coordinate system
790 // with the origin in the lower left corner (looking upstream)
791 local_point[0] = (((Double_t) columnId + 0.5) * padsizex);
792 local_point[1] = (((Double_t) rowId + 0.5) * padsizey);
793
794 // calculate position in module coordinate system
795 // with the origin in the lower left corner (looking upstream)
796 local_point[0] += fSectorBeginX.GetAt(sectorId);
797 local_point[1] += fSectorBeginY.GetAt(sectorId);
798 // local_point[i] must be >= 0 at this point
799
800 // check limits
801 if ((local_point[0] < 0) || (local_point[0] > 2 * fSizeX))
802 LOG(fatal) << "CbmTrdParModDigi::GetPosition local_point[0]="
803 << local_point[0]
804 //<< " in moduleAddress " << moduleAddress
805 << " is out of bounds!";
806 // check limits
807 if ((local_point[1] < 0) || (local_point[1] > 2 * fSizeY))
808 LOG(fatal) << "CbmTrdParModDigi::GetPosition local_point[1]="
809 << local_point[1]
810 //<< " in moduleAddress " << moduleAddress
811 << " is out of bounds!";
812
813 // calculate position in the module coordinate system
814 // with origin in the middle of the module
815 local_point[0] -= fSizeX;
816 local_point[1] -= fSizeY;
817 local_point[2] = fSizeZ;
818
819 // navigate to the correct module. (fX,fY,fZ)
820 gGeoManager->FindNode(fX, fY, fZ);
821
822 // get the local point in local MC coordinates from
823 // the geomanager. This coordinate system is rotated,
824 // if the chamber is rotated. This is corrected in
825 // GetModuleInformation to have the same
826 // local coordinate system in all the chambers
827 Double_t global_point[3]; // global_point[3];
828 gGeoManager->LocalToMaster(local_point, global_point);
829
830 // calculate the position in the global coordinate system
831 // with the origin in target
832 Double_t posX = global_point[0];
833 Double_t posY = global_point[1];
834 Double_t posZ = global_point[2];
835
836 padPos.SetXYZ(posX, posY, posZ);
837 padSize.SetXYZ(padsizex, padsizey, 0.);
838}
839
840//___________________________________________________________________________
842{
843 // calculate the pad column based on
844 // the channeNumber as defined in the
845 // CbmTrdDigi
846
847 Int_t ncols = GetNofColumns();
848 Int_t col = channelNumber % ncols;
849
850 return col;
851}
852
853//___________________________________________________________________________
854Int_t CbmTrdParModDigi::GetPadRow(const Int_t channelNumber) const
855{
856 // calculate the pad row based on
857 // the channeNumber as defined in the
858 // CbmTrdDigi
859
860 Int_t ncols = GetNofColumns();
861 Int_t row = channelNumber / ncols;
862
863 return row;
864}
865
866
ClassImp(CbmConverterManager)
Helper class to convert unique channel ID back and forth.
int Int_t
bool Bool_t
static uint32_t GetModuleId(uint32_t address)
Return module ID from address.
static uint32_t GetSectorId(uint32_t address)
Return sector ID from address.
static uint32_t GetColumnId(uint32_t address)
Return column ID from address.
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
static uint32_t GetRowId(uint32_t address)
Return row ID from address.
Definition of chamber gain conversion for one TRD module.
void Print(Option_t *opt="") const
TArrayD fSectorZ
center of sectors local c.s. [cm]
TArrayD fSectorBeginX
begin of sector [cm]
Bool_t GetPadInfo(const Double_t *local_point, Int_t &sectorId, Int_t &columnId, Int_t &rowId) const
TArrayD fSectorY
center of sectors local c.s. [cm]
Double_t fAnodeWireOffset
Anode Wire Offset [cm].
TArrayD fSectorSizeY
sector size in y [cm]
Int_t GetNofSectors() const
Int_t GetPadRow(const Int_t channelNumber) const
void GetPosition(Int_t sectorId, Int_t columnId, Int_t rowId, TVector3 &padPos, TVector3 &padSize) const
int GetPadPlaneType() const
Access the basic type of pad plane topology. For convenience also specific accessors are added for ea...
TArrayD fSectorBeginY
begin of sector [cm]
Double_t fZ
center of module in global c.s. [cm]
void TransformHitError(TVector3 &hitErr) const
Int_t GetNofColumnsInSector(Int_t i) const
Double_t fSizeX
module half size in x [cm]
Int_t GetSectorRow(Int_t growId, Int_t &srowId) const
Find the sector wise row given the module row. Inverse of GetModuleRow()
TArrayD fSectorEndX
end of sector [cm]
TArrayD fPadSizeY
size of the readout pad in y [cm]
TArrayD fSectorX
center of sectors local c.s. [cm]
Int_t GetNofRows() const
void TransformToLocalSector(const Double_t *local_point, Double_t &posX, Double_t &posY) const
Int_t fNofSectors
number sectors for this module
void GetPadPosition(const Int_t sector, const Int_t col, const Int_t row, TVector3 &padPos, TVector3 &padPosErr) const
Double_t fSizeY
module half size in y [cm]
Int_t GetNofRowsInSector(Int_t i) const
Int_t GetPadColumn(const Int_t channelNumber) const
Int_t GetSector(Int_t npady, Int_t &rowId) const
void ProjectPositionToNextAnodeWire(Double_t *local_point) const
Double_t fAnodeWireToPadPlaneDistance
Anode Wire to PadPlane Distance [cm].
void TransformToLocalCorner(const Double_t *local_point, Double_t &posX, Double_t &posY) const
Double_t fY
center of module in global c.s. [cm]
Double_t fX
center of module in global c.s. [cm]
TArrayD fSectorEndY
end of sector [cm]
Int_t GetNofColumns() const
void GetModuleInformation(const Double_t *local_point, Int_t &sectorId, Int_t &columnId, Int_t &rowId) const
TArrayD fPadSizeX
size of the readout pad in x [cm]
Double_t fSizeZ
module half size in z [cm]
void TransformToLocalPad(const Double_t *local_point, Double_t &posX, Double_t &posY) const
TArrayD fSectorSizeX
sector size in x [cm]
Double_t fAnodeWireSpacing
anode wire pitch [cm]
Int_t GetModuleRow(Int_t &sectorId, Int_t &rowId) const
CbmTrdParMod(const char *name="CbmTrdParMod", const char *title="TRD generic module definition")
uint8_t fVersion
version of the parameter
int fModuleId
module id
uint16_t fConfig
configuration setup of the module
double GetYOut() const
Definition CbmTrdPoint.h:69
double GetXIn() const
Definition CbmTrdPoint.h:65
double GetZIn() const
Definition CbmTrdPoint.h:67
double GetXOut() const
Definition CbmTrdPoint.h:68
double GetYIn() const
Definition CbmTrdPoint.h:66
double GetZOut() const
Definition CbmTrdPoint.h:70
bool HasPadPlane2D(uint16_t config)
Inquire the pad-plane type of the chamber.