/** CbmMuchStation.cxx *@author M.Ryzhinskiy *@version 1.0 *@since 15.03.07 ** ** This class holds the transport geometry parameters ** of one MuCh tracking station necessary for digitization. **/ #include using std::cout; using std::endl; #include "CbmMuchSector.h" #include "CbmMuchSectorDigiPar.h" #include "CbmMuchStation.h" // ----- Default constructor ------------------------------------------- CbmMuchStation::CbmMuchStation() { fDetectorId = 0; fZ = fD = fRadLength = fRmin = fRmax = fRotation = 0.; fSectors = new TObjArray(100); fCosRot = TMath::Cos(fRotation); fSinRot = TMath::Sin(fRotation); } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ CbmMuchStation::CbmMuchStation(const char* name, Int_t iStation, Double_t z, Double_t d, Double_t rl, Double_t rmin, Double_t rmax, Double_t rotation) : TNamed(name, "MuCh station") { fDetectorId = 2 << 24 | iStation << 16; fZ = z; fD = d; fRadLength = rl; fRmin = rmin; fRmax = rmax; fRotation = rotation; fSectors = new TObjArray(100); fCosRot = TMath::Cos(fRotation); fSinRot = TMath::Sin(fRotation); } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmMuchStation::~CbmMuchStation() { if ( fSectors ) { fSectors->Delete(); delete fSectors; } } // ------------------------------------------------------------------------- // ----- Public method GetNChannels ------------------------------------ Int_t CbmMuchStation::GetNChannels() { Int_t nChan = 0; for (Int_t iSect=0; iSectGetNChannels(); return nChan; } // ------------------------------------------------------------------------- // ----- Public method GetSectorByNr ----------------------------------- CbmMuchSector* CbmMuchStation::GetSectorByNr(Int_t sectorNr) { if ( fSectorMap.find(sectorNr) != fSectorMap.end() ) { Int_t index = fSectorMap[sectorNr]; return (CbmMuchSector*) fSectors->At(index); } else { cout << "-W- CbmMuchStation::GetSectorByNr: sector " << sectorNr << " not found (station " << GetStationNr() << ")." << endl; return NULL; } } // ------------------------------------------------------------------------- // ----- Public method AddSector --------------------------------------- void CbmMuchStation::AddSector(CbmMuchSectorDigiPar* sectorPar) { // Get digitisation parameters Int_t iSector = sectorPar->GetSectorNr(); Int_t iType = sectorPar->GetType(); Double_t x0 = sectorPar->GetX0(); Double_t y0 = sectorPar->GetY0(); Double_t z0 = sectorPar->GetZ0(); Double_t rotRel = sectorPar->GetRotation(); Double_t lx = sectorPar->GetLx(); Double_t ly = sectorPar->GetLy(); Double_t d = sectorPar->GetD(); Double_t dx = sectorPar->GetDx(); Double_t dy = sectorPar->GetDy(); // Check for previous existence of sector if ( fSectorMap.find(iSector) != fSectorMap.end() ) { cout << "-W- " << fName << "::AddSector: Sector number " << iSector << " already exists for station " << GetStationNr() << endl; return; } // Calculate detectorId and rotation in global c.s. Int_t detId = 2 << 24 | (GetStationNr() << 16) | (iSector << 1); Double_t rotGlb = fRotation + rotRel; // Calculate sector coordinates in global c.s. Double_t x0Glb = x0*fCosRot - y0*fSinRot; Double_t y0Glb = y0*fCosRot + x0*fSinRot; // Number of existing sectors Int_t nSectors = fSectors->GetEntries(); // Create and add new sector fSectors->Add(new CbmMuchSector(Form("%ssector%i",GetName(),iSector),detId, iType, x0Glb, y0Glb, z0, rotGlb, lx, ly, d, dx, dy)); fSectorMap[iSector] = nSectors; } // ------------------------------------------------------------------------- // ----- Public method AddSector --------------------------------------- void CbmMuchStation::AddSector(CbmMuchSector* sector) { Int_t iSector = sector->GetSectorNr(); Int_t nSectors = fSectors->GetEntries(); fSectors->Add(sector); fSectorMap[iSector] = nSectors; } // ------------------------------------------------------------------------- // ----- Public method Reset ------------------------------------------- void CbmMuchStation::Reset() { for (Int_t iSector=0; iSectorReset(); } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- void CbmMuchStation::Print() { cout << "Station Nr. "; cout.width(2); cout << GetStationNr() << ", z = "; cout.width(3); cout << fZ << " cm, Rmin = "; cout.width(5); cout << fRmin << " cm, Rmax = " << fRmax << " cm, angle = "; cout.width(3); cout << fRotation * 180 / TMath::Pi() << " deg., sectors: "; cout.width(4); cout << GetNSectors() << ", channels: "; cout.width(8); cout << GetNChannels() << endl; // for (Int_t iSec=0; iSecPrint(); } // ------------------------------------------------------------------------- // ----- Public method InitGrid ----------------------------------------- void CbmMuchStation::InitGrid() { //******* Define grid sizes ********// CbmMuchSector *sector = (CbmMuchSector*) fSectors->At(0); // first sector has minimal size fGridDx = sector->GetLx(); // width of the grid cell fGridDy = sector->GetLy(); // height of the grid cell fGridL = 0.; // grid width for(int iSector = 0; iSector < GetNSectors(); iSector++){ sector = (CbmMuchSector*) fSectors->At(iSector); if(sector){ Double_t x0 = sector->GetX0(); if(x0 < 0) continue; Double_t lx = sector->GetLx(); Double_t gridL = x0 + lx/2.; if(gridL > fGridL) fGridL = gridL; } } // fGridL *=2.; // Width of the grid // DEBUG if(GetStationNr()==1) cout << "************* DEBUG *************\n" << "\t Grid width: " << fGridL << " [cm]" << endl << "\t Grid cell: " << fGridDx << "x" << fGridDy << " [cm^2]" << endl << "\t Cells:" << endl; //******* Fill in 2D-vector with sector indices ******// Int_t nColumns = (Int_t) ((fGridL+1e-7)/fGridDx)*2; Int_t nRows = (Int_t) ((fGridL+1e-7)/fGridDy)*2; cout << "\t nColumns = " << nColumns << endl << "\t nRows = " << nRows << endl; for(Int_t iColumn = 0; iColumn < nColumns; iColumn++){ Double_t xc = -fGridL + (2*iColumn+1)*fGridDx/2.; // X of a cell center std::vector inds; for(Int_t iRow = 0; iRow < nRows; iRow++){ Double_t yc = -fGridL + (2*iRow+1)*fGridDy/2.; // Y of a cell center // // DEBUG // if(GetStationNr()==1) // cout << "\t\t xc = " << xc << " [cm]\tyc = " << yc << " [cm]" << endl; // Search a sector which contains the grid cell Bool_t result = kFALSE; for(Int_t iSector = 0; iSector < GetNSectors(); iSector++){ sector = (CbmMuchSector*) GetSector(iSector); if(sector){ result = sector->Inside(xc,yc); if(result){ inds.push_back(sector->GetSectorNr()); break; } } } if(!result) inds.push_back(-1); } fGridIndices.push_back(inds); } } // ------------------------------------------------------------------------- ClassImp(CbmMuchStation)