6 #include <FairLogger.h>
8 #include <TGeoManager.h>
19 :
CbmTrdParMod(
"CbmTrdParModDigi",
"TRD read-out definition")
22 , fAnodeWireOffset(0.375)
23 , fAnodeWireSpacing(0.25)
24 , fAnodeWireToPadPlaneDistance(0.35)
51 const TArrayD& sectorSizeX,
52 const TArrayD& sectorSizeY,
53 const TArrayD& padSizeX,
54 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)
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)
77 , fPadSizeY(padSizeY) {
85 Double_t beginx, beginy, endx, endy;
86 Double_t summed_sectsize;
87 if (sectorSizeX.GetAt(0) == 2 * sizex) {
94 endy = sectorSizeY.GetAt(
i);
95 summed_sectsize += sectorSizeY.GetAt(
i);
97 beginy = summed_sectsize;
98 endy = summed_sectsize += sectorSizeY.GetAt(
i);
104 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(
i) / 2.),
i);
105 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(
i) / 2.),
i);
109 LOG(warn) << GetName()
110 <<
"::CbmTrdParModDigi - detect different information on "
111 "module size x : geometry="
112 << std::setprecision(5) << 2 * sizex
113 <<
" CbmTrdPads.h=" << sectorSizeX.GetAt(0);
120 endx = sectorSizeX.GetAt(
i);
121 summed_sectsize += sectorSizeX.GetAt(
i);
123 beginx = summed_sectsize;
124 endx = summed_sectsize += sectorSizeX.GetAt(
i);
130 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(
i) / 2.),
i);
131 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(
i) / 2.),
i);
151 printf(
" CbmTrdParModDigi @ %5d ly[%d] idLy[%3d] rotation[%3ddeg] rows[%2d] "
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"
174 printf(
" [c(%3d) r(%2d)]x[w(%4.2f) h(%5.2f)] area[%5.2fx%5.2f] limits "
175 "x[%5.2f %5.2f] y[%5.2f %5.2f]\n ",
191 Double_t* local_point)
const {
203 LOG(error) <<
"CbmTrdParModDigi::ProjectPositionToNextAnodeWire - local "
204 "point must be within gas volume, y="
205 << std::setprecision(5) << local_point[1] <<
" module size "
208 Double_t ypos = local_point[1];
210 LOG(debug2) <<
"local y before projection: " << std::setprecision(5)
211 << local_point[1] <<
" cm";
228 LOG(debug2) <<
"local y after projection: " << std::setprecision(5)
229 << local_point[1] <<
" cm";
233 LOG(error) <<
"CbmTrdParModDigi::ProjectPositionToNextAnodeWire - local "
234 "point projected outside anode wire plane, from "
235 << std::setprecision(5) << ypos <<
" to "
236 << std::setprecision(5) << local_point[1]
237 <<
" - last anode wire at " << std::setprecision(5)
241 LOG(error) <<
"CbmTrdParModDigi::ProjectPositionToNextAnodeWire: "
242 "fAnodeWireOffset and fAnodeWireSpacing not set. "
243 "ProjectPositionToNextAnodeWire can not be used.";
266 LOG(error) <<
"CbmTrdParModDigi::GetSector: Could not find local point ["
267 << local_point[0] <<
" " << local_point[1]
268 <<
"] in any of the sectors";
279 if ((npady < 0) || (npady >
GetNofRows() - 1)) {
280 LOG(error) <<
"CbmTrdParModDigi::GetSector - there is no such row number: "
294 < nofRows + secRows) {
296 rowId = npady - nofRows;
298 LOG(debug2) <<
"npady : " << npady <<
" <= " << nofRows + secRows
299 <<
" rowId " << rowId <<
" nRows(sec-1) " << nofRows
300 <<
" sec " << iSector;
303 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId
307 <<
" is out of bounds!";
315 <<
"CbmTrdParModDigi::GetSector: Could not find pad in any of the sectors";
326 Int_t nofColumns = 0;
377 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow sectorId " << sectorId
381 <<
" is out of bounds!";
385 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId <<
" of "
388 <<
" is out of bounds!";
390 Int_t moduleRowId = rowId;
393 for (Int_t iSector = 0; iSector < sectorId; iSector++) {
414 LOG(fatal) <<
"CbmTrdParModDigi::GetSectorRow rowId " << growId <<
" of "
417 <<
" is out of bounds!";
423 for (; iSector < 3; iSector++) {
425 if (rowId - nr + 1 > 0)
439 Int_t& rowId)
const {
442 LOG(error) <<
"CbmTrdParModDigi::GetPadInfo - local point x must be within "
444 << std::setprecision(8) << local_point[0]
445 <<
" fSizeX=" << std::setprecision(8) <<
fSizeX;
449 LOG(error) <<
"CbmTrdParModDigi::GetPadInfo - local point y must be within "
451 << std::setprecision(8) << local_point[1]
452 <<
" fSizeY=" << std::setprecision(8) <<
fSizeY;
462 columnId = (Int_t)(posX /
fPadSizeX.At(sectorId));
463 rowId = (Int_t)(posY /
fPadSizeY.At(sectorId));
472 Int_t& rowId)
const {
481 Double_t x_mean = 0.5 * (trdPoint->
GetXIn() + trdPoint->
GetXOut());
482 Double_t y_mean = 0.5 * (trdPoint->
GetYIn() + trdPoint->
GetYOut());
483 Double_t z_mean = 0.5 * (trdPoint->
GetZIn() + trdPoint->
GetZOut());
484 gGeoManager->FindNode(x_mean, y_mean, z_mean);
486 TString curNode = gGeoManager->GetPath();
487 if (!curNode.Contains(
"gas")) {
489 LOG(warn) <<
"This point is not in the trd gas";
504 const Double_t* global_point = gGeoManager->GetCurrentPoint();
505 Double_t local_point[3];
507 gGeoManager->MasterToLocal(global_point, local_point);
510 if (gLogger->IsLogNeeded(fair::Severity::debug2)) {
512 LOG(debug2) <<
"module orientation: " << std::setprecision(5)
516 LOG(debug2) <<
"global x: " << std::setprecision(5) << global_point[0]
517 <<
" y: " << std::setprecision(5) << global_point[1]
518 <<
" z: " << std::setprecision(5) << global_point[2];
521 LOG(debug2) <<
"local x: " << std::setprecision(5) << local_point[0]
522 <<
" y: " << std::setprecision(5) << local_point[1]
523 <<
" z: " << std::setprecision(5) << local_point[2];
526 Double_t proj_point[3];
527 proj_point[0] = local_point[0];
528 proj_point[1] = local_point[1];
529 proj_point[2] = local_point[2];
534 LOG(debug2) <<
"proj x: " << std::setprecision(5) << proj_point[0]
535 <<
" y: " << std::setprecision(5) << proj_point[1]
536 <<
" z: " << std::setprecision(5) << proj_point[2];
538 Double_t corner_point[3];
539 corner_point[2] = local_point[2];
543 LOG(debug2) <<
"corner x: " << std::setprecision(5) << corner_point[0]
544 <<
" y: " << std::setprecision(5) << corner_point[1]
545 <<
" z: " << std::setprecision(5) << corner_point[2];
547 LOG(debug2) <<
"pos x: " << std::setprecision(5) <<
fX
548 <<
" y: " << std::setprecision(5) <<
fY
549 <<
" z: " << std::setprecision(5) <<
fZ
552 LOG(debug2) <<
"size/2 x: " << std::setprecision(5) <<
fSizeX
553 <<
" y: " << std::setprecision(5) <<
fSizeY
554 <<
" z: " << std::setprecision(5) <<
fSizeZ;
556 Double_t sector_point[3];
557 sector_point[2] = local_point[2];
561 LOG(debug2) <<
"sector x: " << std::setprecision(5) << sector_point[0]
562 <<
" y: " << std::setprecision(5) << sector_point[1]
563 <<
" z: " << std::setprecision(5) << sector_point[2];
567 LOG(debug2) <<
"sectornr: " << std::setprecision(5) << sectorId;
569 LOG(debug2) <<
"ncol : " << std::setprecision(5) <<
GetNofColumns();
570 LOG(debug2) <<
"nrow : " << std::setprecision(5) <<
GetNofRows();
573 LOG(debug2) <<
"sec2 x: " << std::setprecision(5)
576 LOG(debug2) <<
"sec1 x: " << std::setprecision(5)
579 LOG(debug2) <<
"sec0 x: " << std::setprecision(5)
586 LOG(debug2) <<
"pad sec: " << s <<
" col: " << c <<
" row: " << r;
591 local_point, sectorId, columnId, rowId);
598 Double_t& posY)
const {
609 posX = local_point[0] +
fSizeX;
610 posY = local_point[1] +
fSizeY;
616 Double_t& posY)
const {
636 Double_t& posY)
const {
644 Double_t sector_point[2];
650 Double_t padx = (Int_t(sector_point[0] /
fPadSizeX.At(sectorId)) + 0.5)
652 Double_t pady = (Int_t(sector_point[1] /
fPadSizeY.At(sectorId)) + 0.5)
655 posX = sector_point[0] - padx;
656 posY = sector_point[1] - pady;
697 const Double_t* local_point,
700 Int_t& rowId)
const {
712 columnId = (Int_t)(posX /
fPadSizeX.At(sectorId));
713 rowId = (Int_t)(posY /
fPadSizeY.At(sectorId));
722 TVector3& padPosErr)
const {
731 Double_t padsizex =
fPadSizeX.At(sector);
732 Double_t padsizey =
fPadSizeY.At(sector);
736 posX = (((Double_t) col + 0.5) * padsizex);
737 posY = (((Double_t) row + 0.5) * padsizey);
752 LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posX=" << posX
753 <<
" is out of bounds!";
756 LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posY=" << posY
757 <<
" is out of bounds!";
759 padPos.SetXYZ(posX, posY, posZ);
760 padPosErr.SetXYZ(padsizex / 2., padsizey / 2., 0.);
767 TVector3& padPosErr)
const {
780 return GetPadPosition(sectorId, rowId, columnId, padPos, padPosErr);
785 bool isCbmTrdDigiAddress,
787 TVector3& padPosErr)
const {
791 if (!isCbmTrdDigiAddress)
792 LOG(error) <<
"Trying to get a CbmTrd PadPosition from DigiAddress format "
793 "function without digiAddress format";
812 TVector3& padSize)
const {
825 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition sectorId " << sectorId
829 <<
" is out of bounds!";
833 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition columnId " << columnId
837 <<
" is out of bounds!";
841 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition rowId " << rowId <<
" of "
844 <<
" is out of bounds!";
846 Double_t local_point[3];
847 Double_t padsizex =
fPadSizeX.At(sectorId);
848 Double_t padsizey =
fPadSizeY.At(sectorId);
852 local_point[0] = (((Double_t) columnId + 0.5) * padsizex);
853 local_point[1] = (((Double_t) rowId + 0.5) * padsizey);
862 if ((local_point[0] < 0) || (local_point[0] > 2 *
fSizeX))
863 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[0]="
866 <<
" is out of bounds!";
868 if ((local_point[1] < 0) || (local_point[1] > 2 *
fSizeY))
869 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[1]="
872 <<
" is out of bounds!";
881 gGeoManager->FindNode(
fX,
fY,
fZ);
888 Double_t global_point[3];
889 gGeoManager->LocalToMaster(local_point, global_point);
893 Double_t posX = global_point[0];
894 Double_t posY = global_point[1];
895 Double_t posZ = global_point[2];
897 padPos.SetXYZ(posX, posY, posZ);
898 padSize.SetXYZ(padsizex, padsizey, 0.);
908 Int_t col = channelNumber % ncols;
920 Int_t row = channelNumber / ncols;