#include "CbmTrdModule.h" #include "CbmTrdPoint.h" #include "TGeoManager.h" #include "TMath.h" #include using std::cout; using std::endl; // ----- Default constructor ------------------------------------------- CbmTrdModule::CbmTrdModule() : fDetectorId(0), fX(-666.), fY(-666.), fZ(-666.), fSizex(-666.), fSizey(-66.), fNoSectors(0), fSectorX(0), fSectorY(0), fSectorZ(0), fSectorBeginX(0), fSectorBeginY(0), fSectorSizex(0), fSectorSizey(0), fPadSizex(0), fPadSizey(0), fIsRotated(kFALSE) { } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ CbmTrdModule::CbmTrdModule(Int_t detId, Double_t x, Double_t y, Double_t z, Double_t sizex, Double_t sizey, Bool_t rotated) : fDetectorId(detId), fX(x), fY(y), fZ(z), fSizex(sizex), fSizey(sizey), fNoSectors(0), fSectorX(0), fSectorY(0), fSectorZ(0), fSectorBeginX(0), fSectorBeginY(0), fSectorSizex(0), fSectorSizey(0), fPadSizex(0), fPadSizey(0), fIsRotated(rotated) { } // ----- Standard constructor ------------------------------------------ CbmTrdModule::CbmTrdModule(Int_t detId, Double_t x, Double_t y, Double_t z, Double_t sizex, Double_t sizey, Int_t nSectors, TArrayD sectorX, TArrayD sectorY, TArrayD sectorZ, TArrayD sectorSizeX, TArrayD sectorSizeY, TArrayD padSizeX, TArrayD padSizeY, Bool_t rotated) : fDetectorId(detId), fX(x), fY(y), fZ(z), fSizex(sizex), fSizey(sizey), fNoSectors(nSectors), fSectorX(sectorX), fSectorY(sectorY), fSectorZ(sectorZ), fSectorSizex(sectorSizeX), fSectorSizey(sectorSizeY), fPadSizex(padSizeX), fPadSizey(padSizeY), fIsRotated(rotated) { } // ------------------------------------------------------------------------- CbmTrdModule::CbmTrdModule(Int_t detId, Double_t x, Double_t y, Double_t z, Double_t sizex, Double_t sizey, Int_t nSectors, TArrayD sectorSizeX, TArrayD sectorSizeY, TArrayD padSizeX, TArrayD padSizeY, Bool_t rotated) : fDetectorId(detId), fX(x), fY(y), fZ(z), fSizex(sizex), fSizey(sizey), fNoSectors(nSectors), fSectorX(nSectors), fSectorY(nSectors), fSectorZ(nSectors), fSectorBeginX(nSectors), fSectorBeginY(nSectors), fSectorEndX(nSectors), fSectorEndY(nSectors), fSectorSizex(sectorSizeX), fSectorSizey(sectorSizeY), fPadSizex(padSizeX), fPadSizey(padSizeY), fIsRotated(rotated) { // Calculate the coordinates of the begin and the end of each sector // as well as the cordinates of the center of the sector // In the moment it is assumed that there are sectors which have either // in x- or y-direction the size of the chamber. if(nSectors>1) { Double_t beginx, beginy, endx, endy; Double_t summed_sectsize; if ( sectorSizeX.GetAt(0) == 2*sizex ) { //substructure only in y-direction beginx = 0; endx = 2*sizex; summed_sectsize=0; for( Int_t i=0; i= fSectorBeginX.GetAt(i) && posx < fSectorEndX.GetAt(i) && posy >= fSectorBeginY.GetAt(i) && posy < fSectorEndY.GetAt(i) ) { return i; } } Error("CbmTrdModule::GetSector","Could not find local point in any of the sectors"); return -1; //This should be never reached } void CbmTrdModule::GetPadInfo(CbmTrdPoint *trdPoint, Int_t &Col, Int_t &Row, Int_t &Sector) { // Calculate point in the middle of the detector. This is // for safety reasons, because the point at exit is slightly // outside of the active volume. If one does not use a point // in the detector one will get a wrong volume from the // geomanager. Navigate to the correct volume to get all // necessary information about this volume Double_t x_mean = (trdPoint->GetXIn()+trdPoint->GetXOut())/2.; Double_t y_mean = (trdPoint->GetYIn()+trdPoint->GetYOut())/2.; Double_t z_mean = (trdPoint->GetZIn()+trdPoint->GetZOut())/2.; gGeoManager->FindNode(x_mean, y_mean, z_mean); // Get the local point in local MC coordinates from // the geomanager. This coordinate system is rotated // if the chamber is rotated. This is corrected in // GetModuleInformation to have a // the same local coordinate system in all the chambers const Double_t *global_point = gGeoManager->GetCurrentPoint(); Double_t local_point[3]; // global_point[3]; gGeoManager->MasterToLocal(global_point, local_point); Int_t ModuleID = trdPoint->GetDetectorID(); GetModuleInformation(ModuleID, local_point, Col, Row, Sector); } // -------------------------------------------------------------------- void CbmTrdModule::TransformToLocalCorner(Double_t *local_point, Double_t &posX, Double_t &posY) { // Transformation from local coordinate system with origin in // the middle of the module into a system with origin in the // lower right corner of the module. Since for both coordinate // systems the orientation is the same this is only a shift by // the half size of the module in x- and y-direction posX=local_point[0]+fSizex; posY=local_point[1]+fSizey; } void CbmTrdModule::TransformToLocalSector(Double_t *local_point, const Int_t §or, Double_t &posX, Double_t &posY) { // Transformation of the module coordinate system with origin // in the middle of the chamber into a system with // the origin in the lower right corner of the sector the point // is in. First transform in a system with origin in the lower // right corner. TransformToLocalCorner(local_point, posX, posY); posX-=fSectorBeginX.GetAt(sector); posY-=fSectorBeginY.GetAt(sector); } void CbmTrdModule::GetModuleInformation(Int_t VolumeID, Double_t *local_point, Int_t &Col, Int_t &Row, Int_t §or) { // safety check. Up to now allways correct, so could be removed. if (fDetectorId != VolumeID ){ cout<<" -E- This is wrong!!!!!!!!!!!!!!!!!!!!!"<