12#include <TGeoManager.h>
25 :
CbmTrdParMod(
"CbmTrdParModDigi",
"TRD read-out definition")
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")
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);
98 beginy = summed_sectsize;
99 endy = summed_sectsize += sectorSizeY.GetAt(i);
105 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
106 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
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);
121 endx = sectorSizeX.GetAt(i);
122 summed_sectsize += sectorSizeX.GetAt(i);
125 beginx = summed_sectsize;
126 endx = summed_sectsize += sectorSizeX.GetAt(i);
132 fSectorX.AddAt(beginx + (sectorSizeX.GetAt(i) / 2.), i);
133 fSectorY.AddAt(beginy + (sectorSizeY.GetAt(i) / 2.), i);
155 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"
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 ",
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;
191 Double_t ypos = local_point[1];
193 LOG(debug2) <<
"local y before projection: " << std::setprecision(5) << local_point[1] <<
" cm";
207 LOG(debug2) <<
"local y after projection: " << std::setprecision(5) << local_point[1] <<
" cm";
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]
217 LOG(error) <<
"CbmTrdParModDigi::ProjectPositionToNextAnodeWire: "
218 "fAnodeWireOffset and fAnodeWireSpacing not set. "
219 "ProjectPositionToNextAnodeWire can not be used.";
249 LOG(error) <<
"CbmTrdParModDigi::GetSector: Could not find local point [" << local_point[0] <<
" " << local_point[1]
250 <<
"] in any of the sectors";
262 if ((npady < 0) || (npady >
GetNofRows() - 1)) {
263 LOG(error) <<
"CbmTrdParModDigi::GetSector - there is no such row number: " << npady;
273 if (npady < nofRows + secRows) {
275 rowId = npady - nofRows;
277 LOG(debug2) <<
"npady : " << npady <<
" <= " << nofRows + secRows <<
" rowId " << rowId <<
" nRows(sec-1) "
278 << nofRows <<
" sec " << iSector;
281 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId <<
" of "
284 <<
" is out of bounds!";
291 LOG(error) <<
"CbmTrdParModDigi::GetSector: Could not find pad in any of the sectors";
303 Int_t nofColumns = 0;
354 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow sectorId " << sectorId <<
" of "
357 <<
" is out of bounds!";
361 LOG(fatal) <<
"CbmTrdParModDigi::GetModuleRow rowId " << rowId <<
" of "
364 <<
" is out of bounds!";
366 Int_t moduleRowId = rowId;
369 for (
Int_t iSector = 0; iSector < sectorId; iSector++) {
390 LOG(fatal) <<
"CbmTrdParModDigi::GetSectorRow rowId " << growId <<
" of "
393 <<
" is out of bounds!";
399 for (; iSector < 3; iSector++) {
401 if (rowId - nr + 1 > 0) rowId -= nr;
414 if (fabs(local_point[0]) >
fSizeX) {
415 LOG(warn) <<
"CbmTrdParModDigi::GetPadInfo - local point x must be within "
417 << std::setprecision(8) << local_point[0] <<
" fSizeX=" << std::setprecision(8) <<
fSizeX;
420 if (fabs(local_point[1]) >
fSizeY) {
421 LOG(warn) <<
"CbmTrdParModDigi::GetPadInfo - local point y must be within "
423 << std::setprecision(8) << local_point[1] <<
" fSizeY=" << std::setprecision(8) <<
fSizeY;
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);
455 TString curNode = gGeoManager->GetPath();
456 if (!curNode.Contains(
"gas")) {
458 LOG(warn) <<
"This point is not in the trd gas";
473 const Double_t* global_point = gGeoManager->GetCurrentPoint();
474 Double_t local_point[3];
476 gGeoManager->MasterToLocal(global_point, local_point);
479 if (fair::Logger::Logging(fair::Severity::debug2)) {
481 LOG(debug2) <<
"module orientation: " << std::setprecision(5) <<
fOrientation;
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];
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];
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];
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];
503 Double_t corner_point[3];
504 corner_point[2] = local_point[2];
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];
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;
514 LOG(debug2) <<
"size/2 x: " << std::setprecision(5) <<
fSizeX <<
" y: " << std::setprecision(5) <<
fSizeY
515 <<
" z: " << std::setprecision(5) <<
fSizeZ;
517 Double_t sector_point[3];
518 sector_point[2] = local_point[2];
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];
527 LOG(debug2) <<
"sectornr: " << std::setprecision(5) << sectorId;
529 LOG(debug2) <<
"ncol : " << std::setprecision(5) <<
GetNofColumns();
530 LOG(debug2) <<
"nrow : " << std::setprecision(5) <<
GetNofRows();
533 LOG(debug2) <<
"sec2 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(2) <<
" y: " << std::setprecision(5)
535 LOG(debug2) <<
"sec1 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(1) <<
" y: " << std::setprecision(5)
537 LOG(debug2) <<
"sec0 x: " << std::setprecision(5) <<
fSectorBeginX.GetAt(0) <<
" y: " << std::setprecision(5)
543 LOG(debug2) <<
"pad sec: " << s <<
" col: " << c <<
" row: " << r;
548 local_point, sectorId, columnId, rowId);
565 posX = local_point[0] +
fSizeX;
566 posY = local_point[1] +
fSizeY;
598 Double_t sector_point[2];
609 posX = sector_point[0] - padx;
610 posY = sector_point[1] - pady;
652 const Double_t* local_point,
Int_t& sectorId,
Int_t& columnId,
Int_t& rowId)
const
672 TVector3& padPosErr)
const
682 Double_t padsizex =
fPadSizeX.At(sector);
683 Double_t padsizey =
fPadSizeY.At(sector);
687 posX = (((Double_t) col + 0.5) * padsizex);
688 posY = (((Double_t) row + 0.5) * padsizey);
702 if (fabs(posX) >
fSizeX) LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posX=" << posX <<
" is out of bounds!";
704 if (fabs(posY) >
fSizeY) LOG(fatal) <<
"CbmTrdParModDigi::GetPadPosition posY=" << posY <<
" is out of bounds!";
706 padPos.SetXYZ(posX, posY, posZ);
707 padPosErr.SetXYZ(padsizex / 2., padsizey / 2., 0.);
726 return GetPadPosition(sectorId, rowId, columnId, padPos, padPosErr);
731 TVector3& padPosErr)
const
736 if (!isCbmTrdDigiAddress)
737 LOG(error) <<
"Trying to get a CbmTrd PadPosition from DigiAddress format "
738 "function without digiAddress format";
753 Int_t sectorId,
Int_t columnId,
Int_t rowId, TVector3& padPos, TVector3& padSize)
const
767 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition sectorId " << sectorId <<
" of "
769 <<
" is out of bounds!";
773 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition columnId " << columnId <<
" of "
776 <<
" is out of bounds!";
780 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition rowId " << rowId <<
" of "
783 <<
" is out of bounds!";
785 Double_t local_point[3];
786 Double_t padsizex =
fPadSizeX.At(sectorId);
787 Double_t padsizey =
fPadSizeY.At(sectorId);
791 local_point[0] = (((Double_t) columnId + 0.5) * padsizex);
792 local_point[1] = (((Double_t) rowId + 0.5) * padsizey);
801 if ((local_point[0] < 0) || (local_point[0] > 2 *
fSizeX))
802 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[0]="
805 <<
" is out of bounds!";
807 if ((local_point[1] < 0) || (local_point[1] > 2 *
fSizeY))
808 LOG(fatal) <<
"CbmTrdParModDigi::GetPosition local_point[1]="
811 <<
" is out of bounds!";
820 gGeoManager->FindNode(
fX,
fY,
fZ);
827 Double_t global_point[3];
828 gGeoManager->LocalToMaster(local_point, global_point);
832 Double_t posX = global_point[0];
833 Double_t posY = global_point[1];
834 Double_t posZ = global_point[2];
836 padPos.SetXYZ(posX, posY, posZ);
837 padSize.SetXYZ(padsizex, padsizey, 0.);
848 Int_t col = channelNumber % ncols;
861 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
CbmTrdParMod(const char *name="CbmTrdParMod", const char *title="TRD generic module definition")
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.