//* $Id: */ // ------------------------------------------------------------------------- // ----- CbmStsDigiScheme source file ----- // ----- Created 31/08/06 by V. Friese ----- // ------------------------------------------------------------------------- #include "TArrayD.h" #include "CbmGeoMedium.h" #include "CbmGeoNode.h" #include "CbmGeoTransform.h" #include "CbmGeoVector.h" #include "CbmGeoStsPar.h" #include "CbmStsDigiPar.h" #include "CbmStsDigiScheme.h" #include "CbmStsSector.h" #include "CbmStsSectorDigiPar.h" #include "CbmStsStation.h" #include "CbmStsStationDigiPar.h" // ----- Constructor --------------------------------------------------- CbmStsDigiScheme::CbmStsDigiScheme() { fStations = new TObjArray(10); fNSectors = fNChannels = 0; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmStsDigiScheme::~CbmStsDigiScheme() { if ( fStations) { fStations->Delete(); delete fStations; } } // ------------------------------------------------------------------------- // ----- Public method Init -------------------------------------------- Bool_t CbmStsDigiScheme::Init(CbmGeoStsPar* geoPar, CbmStsDigiPar* digiPar) { // Check availability of parameters if ( ! geoPar ) { cout << "-W- CbmStsDigiScheme::Init: " << "No geometry parameters available!" << endl; return kFALSE; } if ( ! digiPar ) { cout << "-W- CbmStsDigiScheme::Init: " << "No digitisation parameters available!" << endl; return kFALSE; } // Loop over stations in DigiPar Int_t nStations = digiPar->GetNStations(); CbmStsStationDigiPar* statPar = NULL; for (Int_t iStation=0; iStationGetStation(iStation); Int_t statNr = statPar->GetStationNr(); Double_t statRot = statPar->GetRotation(); Int_t nSectors = statPar->GetNSectors(); // Get geometry parameters of station char statName[100]; if ( iStation < 10 ) sprintf(statName, "stsstation0%i", statNr); else sprintf(statName, "stsstation%i", statNr); TObjArray* sensNodes = geoPar->GetGeoSensitiveNodes(); CbmGeoNode* geoStat = (CbmGeoNode*) (sensNodes->FindObject(statName)); if ( ! geoStat ) { cout << "-W- CbmStsDigiScheme::Init: " << statName << " not found among sensitive nodes " << endl; continue; } CbmGeoTransform* transform = geoStat->getLabTransform(); CbmGeoVector translat = transform->getTranslation(); CbmGeoTransform center = geoStat->getCenterPosition(); CbmGeoVector centerV = center.getTranslation(); TArrayD* params = geoStat->getParameters(); CbmGeoMedium* material = geoStat->getMedium(); material->calcRadiationLength(); Double_t statZ = translat.Z() + centerV.Z(); Double_t statRmin = params->At(0); Double_t statRmax = params->At(1); Double_t statD = 2. * params->At(2); Double_t statRL = material->getRadiationLength(); Int_t mcId = geoStat->getMCid(); // Create new station CbmStsStation* station = new CbmStsStation(statName, statNr, statZ, statD, statRL, statRmin, statRmax, statRot); fStations->Add(station); fStationMap[statNr] = station; fVolumeMap[mcId] = station; // Loop over sectors of station in DigiPar CbmStsSectorDigiPar* sectorPar = NULL; for (Int_t iSector=0; iSectorGetSector(iSector); station->AddSector(sectorPar); } fNSectors += station->GetNSectors(); fNChannels += station->GetNChannels(); } // Loop over stations return kTRUE; } // ------------------------------------------------------------------------- // ----- Public method Clear ------------------------------------------- void CbmStsDigiScheme::Clear() { fStations->Delete(); fStationMap.clear(); fNSectors = fNChannels = 0; } // ------------------------------------------------------------------------- // ----- Public method Reset ------------------------------------------- void CbmStsDigiScheme::Reset() { for (Int_t iStation=0; iStationGetEntries(); iStation++) GetStation(iStation)->Reset(); } // ------------------------------------------------------------------------- // ----- Public method GetStation -------------------------------------- CbmStsStation* CbmStsDigiScheme::GetStation(Int_t iStation) { if ( ! fStations ) return NULL; return dynamic_cast(fStations->At(iStation)); } // ------------------------------------------------------------------------- // ----- Public method GetStationByNr ---------------------------------- CbmStsStation* CbmStsDigiScheme::GetStationByNr(Int_t stationNr) { if ( ! fStations ) return NULL; if ( fStationMap.find(stationNr) == fStationMap.end() ) return NULL; return fStationMap[stationNr]; } // ------------------------------------------------------------------------- // ----- Public method GetStationByMcId -------------------------------- CbmStsStation* CbmStsDigiScheme::GetStationByMcId(Int_t iVol) { if ( ! fStations ) return NULL; if ( fVolumeMap.find(iVol) == fStationMap.end() ) return NULL; return fVolumeMap[iVol]; } // ------------------------------------------------------------------------- // ----- Public method GetSector --------------------------------------- CbmStsSector* CbmStsDigiScheme::GetSector(Int_t stationNr, Int_t sectorNr) { return ( GetStationByNr(stationNr)->GetSectorByNr(sectorNr) ); } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- void CbmStsDigiScheme::Print(Bool_t kLong) { cout << endl; cout << "=================== STS digitisation scheme =================" << endl; for (Int_t iStat=0; iStatPrint(kLong); } cout << "================================================================" << endl << endl; } // ------------------------------------------------------------------------- ClassImp(CbmStsDigiScheme)