//* $Id: */ // ------------------------------------------------------------------------- // ----- CbmMvdStripsDigiScheme source file ----- // ----- Created 31/08/06 by V. Friese ----- // ------------------------------------------------------------------------- #include "CbmMvdStripsDigiScheme.h" #include "CbmGeoMvdStripsPar.h" #include "CbmMvdStripsDigiPar.h" #include "CbmMvdStripsSensor.h" #include "CbmMvdStripsSensorDigiPar.h" #include "CbmMvdStripsSector.h" #include "CbmMvdStripsSectorDigiPar.h" #include "CbmMvdStripsStation.h" #include "CbmMvdStripsStationDigiPar.h" #include "FairGeoMedium.h" #include "FairGeoNode.h" #include "FairGeoTransform.h" #include "FairGeoVector.h" #include "TArrayD.h" #include #include using std::flush; using std::map; using std::cout; using std::endl; using std::pair; // ----- Constructor --------------------------------------------------- CbmMvdStripsDigiScheme::CbmMvdStripsDigiScheme() { fStations = new TObjArray(10); fNSectors = fNSensors = fNChannels = 0; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmMvdStripsDigiScheme::~CbmMvdStripsDigiScheme() { if ( fStations) { fStations->Delete(); delete fStations; } } // ------------------------------------------------------------------------- // ----- Public method Init -------------------------------------------- Bool_t CbmMvdStripsDigiScheme::Init(CbmGeoMvdStripsPar* geoPar, CbmMvdStripsDigiPar* digiPar) { // Check availability of parameters if ( ! geoPar ) { cout << "-W- CbmMvdStripsDigiScheme::Init: " << "No geometry parameters available!" << endl; return kFALSE; } if ( ! digiPar ) { cout << "-W- CbmMvdStripsDigiScheme::Init: " << "No digitisation parameters available!" << endl; return kFALSE; } // Loop over stations in DigiPar Int_t nStations = digiPar->GetNStations(); CbmMvdStripsStationDigiPar* statPar = NULL; CbmMvdStripsSectorDigiPar* sectorPar = NULL; CbmMvdStripsSensorDigiPar* sensorPar = NULL; TObjArray* passNodes = geoPar->GetGeoPassiveNodes(); TObjArray* sensNodes = geoPar->GetGeoSensitiveNodes(); for (Int_t iStation=0; iStationGetStation(iStation); Int_t statNr = statPar->GetStationNr(); Double_t statRot = statPar->GetRotation(); Int_t nSectors = statPar->GetNSectors(); Double_t statZPos = -666.;// = statPar->GetZPosition(); CbmMvdStripsStation* station; TString stationName = Form("stat%02d",iStation+1); TString statVolName = Form("mvdstripsstation%02ikeepvol",statNr); FairGeoNode* statKeepVol = (FairGeoNode*) (passNodes->FindObject(statVolName)); if ( statKeepVol ) { FairGeoTransform* transform = statKeepVol->getLabTransform(); FairGeoVector translat = transform->getTranslation(); FairGeoTransform center = statKeepVol->getCenterPosition(); FairGeoVector centerV = center.getTranslation(); statZPos = translat.Z() + centerV.Z(); } Int_t sensorByIndex = 0; for (Int_t iSector=0; iSectorGetSector(iSector); Int_t sectorNr = iSector+1; Int_t sectorDetId = 2 << 24 | statNr << 16 | sectorNr << 4; sectorPar = (CbmMvdStripsSectorDigiPar*) statPar->GetSector(iSector); Int_t nSensors = sectorPar->GetNSensors(); CbmMvdStripsSector* sector; TString sectorName = Form("stat%02dsect%d",iStation+1,iSector+1); for (Int_t iSensor=0; iSensorAt(sensorByIndex++)); else { Int_t nofNodes = sensNodes->GetEntries(); TString tempLookName = Form("mvdstripsstation%02isensor1#1",statNr); for (Int_t it=0; itAt(it)); TString tempNodeName = geoSensor->getName(); if ( tempNodeName.Contains(tempLookName.Data()) ) { sensorByIndex = it+1; break; } } } fDetIdByName.insert(pair (geoSensor->GetName(), detId)); sensorPar = (CbmMvdStripsSensorDigiPar*) sectorPar->GetSensor(iSensor); Int_t sensorType = sensorPar->GetType(); Double_t sensorX = sensorPar->GetX0(); Double_t sensorY = sensorPar->GetY0(); Double_t sensorZ = sensorPar->GetZ0(); Double_t sensorRot = sensorPar->GetRotation(); Double_t sensorXDim = sensorPar->GetLx(); Double_t sensorYDim = sensorPar->GetLy(); Double_t sensorZDim = sensorPar->GetD(); Double_t sensorDX = sensorPar->GetDx(); Double_t sensorDY = sensorPar->GetDy(); Double_t sensorStereoF = sensorPar->GetStereoF(); Double_t sensorStereoB = sensorPar->GetStereoB(); TString sensorName = geoSensor->GetName(); sensorName.ReplaceAll("#","_"); CbmMvdStripsSensor* sensor = new CbmMvdStripsSensor(sensorName.Data(), detId, sensorType, sensorX, sensorY, sensorZ, sensorRot, sensorXDim, sensorYDim, sensorZDim, sensorDX, sensorDY, sensorStereoF, sensorStereoB); // create sector that will keep the sensor if ( iSensor == 0 ) { sector = new CbmMvdStripsSector(sectorName.Data(), sectorDetId); // create station that will keep the sector if ( iSector == 0 ) { FairGeoMedium* material = geoSensor->getMedium(); Double_t sensorRL = material->getRadiationLength(); station = new CbmMvdStripsStation(stationName.Data(), statNr, statZPos, sensorZDim, sensorRL, 0., 100., statRot); fStations->Add(station); fStationMap[statNr] = station; } station->AddSector(sector); } sector->AddSensor(sensor); // put sensor into name/sensor map map < TString, CbmMvdStripsSensor*>::iterator p; p=fSensorByName.find(sensorName); if(p!=fSensorByName.end()){ cout << " -E- Sensor \"" << sensorName.Data() << "\" is already inserted " << endl; }else{ fSensorByName.insert(pair (sensorName, sensor)); } } // Loop over sensors fNSensors += sector->GetNSensors(); } // Loop over sectors fNSectors += station->GetNSectors(); fNChannels += station->GetNChannels(); } // Loop over stations return kTRUE; } // ------------------------------------------------------------------------- // ----- Public method Clear ------------------------------------------- void CbmMvdStripsDigiScheme::Clear() { fStations->Delete(); fStationMap.clear(); fDetIdByName.clear(); fNSectors = fNSensors = fNChannels = 0; } // ------------------------------------------------------------------------- // ----- Public method Reset ------------------------------------------- void CbmMvdStripsDigiScheme::Reset() { for (Int_t iStation=0; iStationGetEntries(); iStation++) GetStation(iStation)->Reset(); } // ------------------------------------------------------------------------- // ----- Public method GetStation -------------------------------------- CbmMvdStripsStation* CbmMvdStripsDigiScheme::GetStation(Int_t iStation) { if ( ! fStations ) return NULL; return dynamic_cast(fStations->At(iStation)); } // ------------------------------------------------------------------------- // ----- Public method GetStationByNr ---------------------------------- CbmMvdStripsStation* CbmMvdStripsDigiScheme::GetStationByNr(Int_t stationNr) { if ( ! fStations ) return NULL; if ( fStationMap.find(stationNr) == fStationMap.end() ) return NULL; return fStationMap[stationNr]; } // ------------------------------------------------------------------------- // ----- Public method GetSector --------------------------------------- CbmMvdStripsSector* CbmMvdStripsDigiScheme::GetSector(Int_t stationNr, Int_t sectorNr) { return ( GetStationByNr(stationNr)->GetSectorByNr(sectorNr) ); } // ------------------------------------------------------------------------- // ----- Public method GetSensor --------------------------------------- CbmMvdStripsSensor* CbmMvdStripsDigiScheme::GetSensor(Int_t stationNr, Int_t sectorNr, Int_t sensorNr) { return ( GetStationByNr(stationNr)->GetSectorByNr(sectorNr)->GetSensorByNr(sensorNr) ); } // ------------------------------------------------------------------------- // ----- Public method GetDetectorIdByName ------------------------------ Int_t CbmMvdStripsDigiScheme::GetDetectorIdByName(TString sensorName) { map < TString, Int_t>::iterator p; p=fDetIdByName.find(sensorName); if(p!=fDetIdByName.end()){ return p->second; }else{ cout << " -E- MvdStripsDigiScheme::GetDetectorIdByName \"" << sensorName.Data() << "\" not found " << endl; return -1; } } // ------------------------------------------------------------------------- // ----- Public method GetSensorIdByName -------------------------------- CbmMvdStripsSensor* CbmMvdStripsDigiScheme::GetSensorByName(TString sensorName) { map < TString, CbmMvdStripsSensor*>::iterator p; p=fSensorByName.find(sensorName); if(p!=fSensorByName.end()){ return p->second; }else{ cout << " -E- MvdStripsDigiScheme::GetDetectorIdByName \"" << sensorName.Data() << "\" not found " << endl; return 0; } } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- void CbmMvdStripsDigiScheme::Print(Bool_t kLong) { cout << endl; cout << "=================== MVDSTRIPS digitisation scheme =================" << endl; for (Int_t iStat=0; iStatPrint(kLong); } cout << "================================================================" << endl << endl; } // ------------------------------------------------------------------------- ClassImp(CbmMvdStripsDigiScheme)