12#include <TGeoManager.h>
26 :
CbmTrdParMod(
"CbmTrdParModDigi",
"TRD read-out definition")
29 , fAnodeWireOffset(0.375)
30 , fAnodeWireSpacing(0.25)
31 , fAnodeWireToPadPlaneDistance(0.35)
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)
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)
86 Double_t beginx, beginy, endx, endy;
87 Double_t summed_sectsize;
88 if (sectorSizeX.GetAt(0) == 2 * sizex) {
95 endy = sectorSizeY.GetAt(i);
96 summed_sectsize += sectorSizeY.GetAt(i);
99 beginy = summed_sectsize;
100 endy = summed_sectsize += sectorSizeY.GetAt(i);
106 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
107 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
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);
122 endx = sectorSizeX.GetAt(i);
123 summed_sectsize += sectorSizeX.GetAt(i);
126 beginx = summed_sectsize;
127 endx = summed_sectsize += sectorSizeX.GetAt(i);
133 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
134 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
156 printf(
" CbmTrdParModDigi @ %5d ly[%d] idLy[%3d] rotation[%3ddeg] rows[%2d] "
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"
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 ",
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;
192 Double_t ypos = local_point[1];
194 LOG(debug2) <<
"local y before projection: " << std::setprecision(5) << local_point[1] <<
" cm";
208 LOG(debug2) <<
"local y after projection: " << std::setprecision(5) << local_point[1] <<
" cm";
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]
218 LOG(error) <<
"CbmTrdParModDigi::ProjectPositionToNextAnodeWire: "
219 "fAnodeWireOffset and fAnodeWireSpacing not set. "
220 "ProjectPositionToNextAnodeWire can not be used.";
250 LOG(error) <<
"CbmTrdParModDigi::GetSector: Could not find local point [" << local_point[0] <<
" " << local_point[1]
251 <<
"] in any of the sectors";
263 if ((npady < 0) || (npady >
GetNofRows() - 1)) {
264 LOG(error) <<
"CbmTrdParModDigi::GetSector - there is no such row number: " << npady;
272 for (Int_t iSector = 0; iSector <
fNofSectors; iSector++) {
274 if (npady < nofRows + secRows) {
276 rowId = npady - nofRows;
278 LOG(debug2) <<
"npady : " << npady <<
" <= " << nofRows + secRows <<
" rowId " << rowId <<
" nRows(sec-1) "
279 << nofRows <<
" sec " << iSector;
282 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId <<
" of "
285 <<
" is out of bounds!";
292 LOG(error) <<
"CbmTrdParModDigi::GetSector: Could not find pad in any of the sectors";
304 Int_t nofColumns = 0;
355 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow sectorId " << sectorId <<
" of "
358 <<
" is out of bounds!";
362 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId <<
" of "
365 <<
" is out of bounds!";
367 Int_t moduleRowId = rowId;
370 for (Int_t iSector = 0; iSector < sectorId; iSector++) {
391 LOG(fatal) <<
"CbmTrdParModDigi::GetSectorRow rowId " << growId <<
" of "
394 <<
" is out of bounds!";
400 for (; iSector < 3; iSector++) {
402 if (rowId - nr + 1 > 0) rowId -= nr;
415 if (fabs(local_point[0]) >
fSizeX) {
416 LOG(warn) <<
"CbmTrdParModDigi::GetPadInfo - local point x must be within "
418 << std::setprecision(8) << local_point[0] <<
" fSizeX=" << std::setprecision(8) <<
fSizeX;
421 if (fabs(local_point[1]) >
fSizeY) {
422 LOG(warn) <<
"CbmTrdParModDigi::GetPadInfo - local point y must be within "
424 << std::setprecision(8) << local_point[1] <<
" fSizeY=" << std::setprecision(8) <<
fSizeY;
434 columnId = (Int_t)(posX /
fPadSizeX.At(sectorId));
435 rowId = (Int_t)(posY /
fPadSizeY.At(sectorId));
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);
456 TString curNode = gGeoManager->GetPath();
457 if (!curNode.Contains(
"gas")) {
459 LOG(warn) <<
"This point is not in the trd gas";
474 const Double_t* global_point = gGeoManager->GetCurrentPoint();
475 Double_t local_point[3];
477 gGeoManager->MasterToLocal(global_point, local_point);
480 if (fair::Logger::Logging(fair::Severity::debug2)) {
482 LOG(debug2) <<
"module orientation: " << std::setprecision(5) <<
fOrientation;
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];
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];
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];
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];
504 Double_t corner_point[3];
505 corner_point[2] = local_point[2];
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];
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;
515 LOG(debug2) <<
"size/2 x: " << std::setprecision(5) <<
fSizeX <<
" y: " << std::setprecision(5) <<
fSizeY
516 <<
" z: " << std::setprecision(5) <<
fSizeZ;
518 Double_t sector_point[3];
519 sector_point[2] = local_point[2];
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];
528 LOG(debug2) <<
"sectornr: " << std::setprecision(5) << sectorId;
530 LOG(debug2) <<
"ncol : " << std::setprecision(5) <<
GetNofColumns();
531 LOG(debug2) <<
"nrow : " << std::setprecision(5) <<
GetNofRows();
534 LOG(debug2) <<
"sec2 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(2) <<
" y: " << std::setprecision(5)
536 LOG(debug2) <<
"sec1 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(1) <<
" y: " << std::setprecision(5)
538 LOG(debug2) <<
"sec0 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(0) <<
" y: " << std::setprecision(5)
544 LOG(debug2) <<
"pad sec: " << s <<
" col: " << c <<
" row: " << r;
549 local_point, sectorId, columnId, rowId);
566 posX = local_point[0] +
fSizeX;
567 posY = local_point[1] +
fSizeY;
599 Double_t sector_point[2];
610 posX = sector_point[0] - padx;
611 posY = sector_point[1] - pady;
653 const Double_t* local_point, Int_t& sectorId, Int_t& columnId, Int_t& rowId)
const
666 columnId = (Int_t)(posX /
fPadSizeX.At(sectorId));
667 rowId = (Int_t)(posY /
fPadSizeY.At(sectorId));
673 TVector3& padPosErr)
const
683 Double_t padsizex =
fPadSizeX.At(sector);
684 Double_t padsizey =
fPadSizeY.At(sector);
688 posX = (((Double_t) col + 0.5) * padsizex);
689 posY = (((Double_t) row + 0.5) * padsizey);
703 if (fabs(posX) >
fSizeX) LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posX=" << posX <<
" is out of bounds!";
705 if (fabs(posY) >
fSizeY) LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posY=" << posY <<
" is out of bounds!";
707 padPos.SetXYZ(posX, posY, posZ);
708 padPosErr.SetXYZ(padsizex / 2., padsizey / 2., 0.);
727 return GetPadPosition(sectorId, rowId, columnId, padPos, padPosErr);
732 TVector3& padPosErr)
const
737 if (!isCbmTrdDigiAddress)
738 LOG(error) <<
"Trying to get a CbmTrd PadPosition from DigiAddress format "
739 "function without digiAddress format";
754 Int_t sectorId, Int_t columnId, Int_t rowId, TVector3& padPos, TVector3& padSize)
const
768 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition sectorId " << sectorId <<
" of "
770 <<
" is out of bounds!";
774 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition columnId " << columnId <<
" of "
777 <<
" is out of bounds!";
781 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition rowId " << rowId <<
" of "
784 <<
" is out of bounds!";
786 Double_t local_point[3];
787 Double_t padsizex =
fPadSizeX.At(sectorId);
788 Double_t padsizey =
fPadSizeY.At(sectorId);
792 local_point[0] = (((Double_t) columnId + 0.5) * padsizex);
793 local_point[1] = (((Double_t) rowId + 0.5) * padsizey);
802 if ((local_point[0] < 0) || (local_point[0] > 2 *
fSizeX))
803 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[0]="
806 <<
" is out of bounds!";
808 if ((local_point[1] < 0) || (local_point[1] > 2 *
fSizeY))
809 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[1]="
812 <<
" is out of bounds!";
821 gGeoManager->FindNode(
fX,
fY,
fZ);
828 Double_t global_point[3];
829 gGeoManager->LocalToMaster(local_point, global_point);
833 Double_t posX = global_point[0];
834 Double_t posY = global_point[1];
835 Double_t posZ = global_point[2];
837 padPos.SetXYZ(posX, posY, posZ);
838 padSize.SetXYZ(padsizex, padsizey, 0.);
849 Int_t col = channelNumber % ncols;
862 Int_t row = channelNumber / ncols;
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 §orId, 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]
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 §orId, 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 §orId, Int_t &rowId) const
Definition of generic parameters for one TRD module.
uint8_t fVersion
version of the parameter
uint16_t fConfig
configuration setup of the module
bool HasPadPlane2D(uint16_t config)
Inquire the pad-plane type of the chamber.