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