9#include "BmnVSPStationSet.h"
19#include "FairGeoMedium.h"
20#include "FairGeoNode.h"
21#include "FairGeoTransform.h"
22#include "FairGeoVector.h"
23#include "FairLogger.h"
24#include "FairRunAna.h"
25#include "FairRuntimeDb.h"
28#include "TGeoManager.h"
29#include "TGeoMatrix.h"
42int CbmStsDigiScheme::fVersion = -1;
46CbmStsDigiScheme::CbmStsDigiScheme()
47 : fStations(new TObjArray(10))
51 , fIsNewGeometry(kFALSE)
58 if (fgInstance == NULL)
71 if (fgInstance == NULL)
93 FairRuntimeDb* rtdb = FairRuntimeDb::instance();
102 Init(geoPar, digiPar);
113 if (fStations->GetEntries())
123 cout <<
"-W- CbmStsDigiScheme::Init: "
124 <<
"No digitisation parameters available!" << endl;
128 TGeoVolume* test = NULL;
131 if (gGeoManager ==
nullptr) {
132 LOG(error) <<
"gGeoManager has null pointer";
135 TGeoNode* top = gGeoManager->GetTopNode();
136 for (Int_t iNode = 0; iNode < top->GetNdaughters(); iNode++) {
137 TString nodeName = top->GetDaughter(iNode)->GetName();
138 if (nodeName.Contains(
"GEMS")) {
139 test = top->GetDaughter(iNode)->GetVolume();
146 fIsNewGeometry = kTRUE;
149 return InitNewNew(NULL, digiPar);
152 return InitNew(NULL, digiPar);
157 cout <<
"-E- CbmStsDigiScheme::Init: unknown geometry version" << endl;
169 fDetIdByName.clear();
170 fSensorByName.clear();
171 fNSectors = fNSensors = fNChannels = 0;
178 for (Int_t iStation = 0; iStation < fStations->GetEntries(); iStation++)
188 return dynamic_cast<CbmStsStation*
>(fStations->At(iStation));
197 if (fStationMap.find(stationNr) == fStationMap.end())
199 return fStationMap[stationNr];
213 return (
GetStationByNr(stationNr)->GetSectorByNr(sectorNr)->GetSensorByNr(sensorNr));
220 map<TString, Int_t>::iterator p;
221 p = fDetIdByName.find(sensorName);
223 if (p != fDetIdByName.end()) {
226 cout <<
" -E- StsDigiScheme::GetDetectorIdByName \"" << sensorName.Data() <<
"\" not found " << endl;
235 map<TString, CbmStsSensor*>::iterator p;
236 p = fSensorByName.find(sensorName);
238 if (p != fSensorByName.end()) {
241 LOG(debug) <<
"StsDigiScheme: sensor " << sensorName.Data() <<
" not found ";
251 cout <<
"=================== STS digitisation scheme =================" << endl;
252 for (Int_t iStat = 0; iStat <
GetNStations(); iStat++) {
254 station->
Print(kLong);
256 cout <<
"================================================================" << endl << endl;
265 Double_t statD = 0.03;
266 Double_t statRadLength = 9.34953;
273 Double_t statRmin = 0.;
274 Double_t statRmax = 6;
277 TString gPathConfig = gSystem->Getenv(
"VMCWORKDIR");
279 TString gemSet =
"GemRun8.xml";
280 TString silSet =
"SiliconRun8.xml";
283 silSet =
"SiliconRun9.xml";
284 gemSet =
"GemRun9.xml";
285 vspSet =
"VSP_Run9.xml";
295 SilStationSet =
new BmnSiliconStationSet(gPathConfig +
"/parameters/silicon/XMLConfigs/" + silSet);
296 fVspStationSet =
nullptr;
298 fVspStationSet =
new BmnVSPStationSet(gPathConfig +
"/parameters/vsp/XMLConfigs/" + vspSet);
301 int nVspStat = (fVspStationSet) ? fVspStationSet->
GetNStations() : 0;
303 for (Int_t iSt = 0; iSt < nVspStat; ++iSt) {
309 statRadLength, 0, statRmax, 0);
310 Double_t zmean = 0.0;
312 for (Int_t iMod = 0; iMod < siStation->
GetNModules(); ++iMod) {
314 Int_t detId =
kVSP << 24 | (iSt + 1) << 16 | (iMod + 1) << 4 | 1 << 1;
324 new CbmStsSensor(
"", detId, 2, x0, y0,
z0, 0, siModule->
GetXSize(), siModule->
GetYSize(), d0, 0.01, 0.0,
331 fStations->Add(station);
333 fStationMap[iSt + 1] = station;
341 for (Int_t iSt = 0; iSt < nSiStat; ++iSt) {
350 statD, statRadLength, 0, statRmax, 0);
352 for (Int_t iMod = 0; iMod < siStation->
GetNModules(); ++iMod) {
354 Int_t detId =
kSILICON << 24 | (iSt + 1) << 16 | (iMod + 1) << 4 | 1 << 1;
368 fStations->Add(station);
370 fStationMap[iSt + nVspStat + 1] = station;
374 for (Int_t iSt = 0; iSt < GemStationSet->
GetNStations(); ++iSt) {
384 Form(
"stat%02d", iSt + 1 + nSiStat + nVspStat), iSt + 1 + nSiStat + nVspStat,
385 gemStation->
GetZPosition(), statD, statRadLength, statRmin, statRmax, 0);
387 for (Int_t iMod = 0; iMod < gemStation->
GetNModules(); ++iMod) {
405 int sect = (iMod % 2) * 2 + (iMod / 2 * 4) + 1 + iL / 2;
406 Int_t detId =
kGEM << 24 | (iSt + 1 + nSiStat) << 16 | sect << 4 | sens << 1;
415 CbmStsSensor* sensor =
new CbmStsSensor(
"", detId, 2, x0, y0,
z0, 0, xSize, ySize, d0, 0.08, 0.0, 0.0,
421 fStations->Add(station);
423 fStationMap[iSt + nSiStat + nVspStat + 1] = station;
610 TGeoNode* sts = NULL;
611 gGeoManager->CdTop();
612 TGeoNode* cave = gGeoManager->GetCurrentNode();
613 Int_t statNr = 0, stNr = 0;
615 for (Int_t iNode0 = 0; iNode0 < cave->GetNdaughters(); iNode0++) {
616 gGeoManager->CdTop();
617 TGeoNode* node = cave->GetDaughter(iNode0);
618 TString
name = node->GetName();
619 cout <<
"NODE: " <<
name << endl;
628 if (!(
name.Contains(
"GEMS_0") ||
name.Contains(
"Silicon_0")))
631 cout <<
" xxxxxxxxx " <<
name << endl;
633 gGeoManager->CdDown(iNode0);
636 cout <<
"-E- CbmStsDigiScheme::InitNew: Cannot find top GEM node" << endl;
640 cout <<
"stations: " << sts->GetNdaughters() << endl;
646 for (Int_t iNode = 0; iNode < sts->GetNdaughters(); iNode++) {
649 gGeoManager->CdDown(iNode);
650 TGeoNode* stationNode = gGeoManager->GetCurrentNode();
651 TString statName = stationNode->GetName();
652 if (!statName.Contains(
"station")) {
656 cout <<
"station: " << iNode <<
" " << sts->GetNdaughters() <<
" " << statName << endl;
671 for (Int_t iStation = 0; iStation < digiPar->
GetNStations(); iStation++) {
674 stationPar = partest1;
679 cout <<
"-E- CbmStsDigiScheme::InitNew: No parameters for station " << statNr << endl;
685 TGeoBBox* shape = (TGeoBBox*)(stationNode->GetVolume()->GetShape());
686 statName = Form(
"stat%02d", statNr);
687 Double_t* statTrans = gGeoManager->GetCurrentMatrix()->GetTranslation();
688 Double_t statZ = statTrans[2];
690 Double_t statD = 0.03;
691 Double_t statRadLength = 9.34953;
704 Double_t statRmin = 0.;
705 Double_t statRmax = 2. * TMath::Max(shape->GetDX(), shape->GetDY());
708 new CbmStsStation(statName, statNr, statZ, statD, statRadLength, statRmin, statRmax, statRot);
713 fStations->Add(station);
714 fStationMap[statNr] = station;
719 Int_t nModules = stationNode->GetNdaughters();
721 for (Int_t iModule = 0; iModule < nModules; iModule++) {
723 gGeoManager->CdDown(iModule);
725 TGeoNode* moduleNode = gGeoManager->GetCurrentNode();
726 TString moduleName = moduleNode->GetName();
727 cout <<
"moduleName: " << moduleName << endl;
728 if (!(moduleName.Contains(
"module") || moduleName.Contains(
"adder") || moduleName.Contains(
"ensor"))) {
733 if (moduleName.Contains(
"adder")) {
735 Int_t nsens = SetSensorsCbm(moduleNr, statNr, station, stationPar);
741 }
else if (sts->GetNdaughters() > 7 && statNr <= 3) {
744 fNSensors += SetSensor(moduleNr, statNr, station, stationPar)->
GetNSensors();
747 }
else if (sts->GetNdaughters() < 5) {
750 fNSensors += SetSensor(moduleNr, statNr, station, stationPar)->
GetNSensors();
756 cout << nModules <<
" " << gGeoManager->GetCurrentNode()->GetName() <<
" "
757 << gGeoManager->GetCurrentMatrix()->GetTranslation()[2] << endl;
759 fNSensors += SetSensor(moduleNr, statNr, station, stationPar)->
GetNSensors();
765 AddHotZone(++moduleNr, statNr, station, stationPar);
769 Int_t nSensors = moduleNode->GetNdaughters();
771 for (Int_t iSensor = 0; iSensor < nSensors; iSensor++) {
774 gGeoManager->CdDown(iSensor);
776 TGeoNode* sensorNode = gGeoManager->GetCurrentNode();
778 if (!TString(sensorNode->GetName()).Contains(
"Sensor")) {
784 fNSensors += SetSensor(moduleNr, statNr, station, stationPar)->
GetNSensors();
810 cout <<
"-E- CbmStsDigiScheme::GetCurrentPath:: No TGeoManager" << endl;
814 TGeoNode* cNode = gGeoManager->GetCurrentNode();
816 TString nodeName = cNode->GetName();
817 path =
"/" + nodeName + path;
818 if (cNode == gGeoManager->GetTopNode())
821 cNode = gGeoManager->GetCurrentNode();
824 gGeoManager->cd(path.Data());
830CbmStsSector* CbmStsDigiScheme::SetSensor(Int_t moduleNr,
840 for (Int_t iSector = 0; iSector < stationPar->
GetNSectors(); iSector++) {
843 sectorPar = partest2;
848 cout <<
"-E- CbmStsDigiScheme::SetSensor: No parameters for module " << moduleNr <<
", station " << statNr
854 TString sectName = Form(
"stat%02dsect%d", statNr, moduleNr);
855 Int_t sectId = 2 << 24 | statNr << 16 | moduleNr << 4;
864 for (Int_t iPar = 0; iPar < sectorPar->
GetNSensors(); iPar++) {
867 sensorPar = partest3;
872 cout <<
"-E- CbmStsDigiScheme::SetSensor: No parameters for sensor " << sensNr <<
", module " << moduleNr
873 <<
", station " << statNr << endl;
877 Double_t* sensTrans = gGeoManager->GetCurrentMatrix()->GetTranslation();
878 TString sensName = gGeoManager->GetPath();
879 Int_t sensId = 2 << 24 | statNr << 16 | moduleNr << 4 | sensNr << 1;
880 Int_t sensType = sensorPar->
GetType();
881 Double_t sensX = sensTrans[0];
882 Double_t sensY = sensTrans[1];
884 Double_t sensZ = sensTrans[2];
886 Double_t sensLx = sensorPar->
GetLx();
887 Double_t sensLy = sensorPar->
GetLy();
888 Double_t sensD = sensorPar->
GetD();
890 Double_t sensDx = sensorPar->
GetDx();
891 Double_t sensDy = sensorPar->
GetDy();
894 Double_t zShift = 0.3;
899 Double_t sensStereoF = sensorPar->
GetStereoF();
900 Double_t sensStereoB = sensorPar->
GetStereoB();
902 sensD, sensDx, sensDy, sensStereoF, sensStereoB);
904 if (fDetIdByName.find(sensName) != fDetIdByName.end()) {
905 cout <<
"-E- CbmStsDigiScheme: Duplicate sensor name " << sensName << endl;
909 fDetIdByName[sensName] = sensId;
910 if (fSensorByName.find(sensName) != fSensorByName.end()) {
911 cout <<
"-E- CbmStsDigiScheme: Duplicate sensor name " << sensName << endl;
914 fSensorByName[sensName] = sensor;
923Int_t CbmStsDigiScheme::SetSensorsCbm(Int_t moduleNr,
930 TGeoManager* geoMan = gGeoManager;
931 TGeoNode* ladder = geoMan->GetCurrentNode();
932 Int_t nD = ladder->GetNdaughters();
933 Int_t modNr0 = moduleNr;
936 for (Int_t i2 = 0; i2 < nD; i2++) {
937 if (!TString(ladder->GetDaughter(i2)->GetName()).Contains(
"HalfLadder"))
942 TGeoNode* halflad = geoMan->GetCurrentNode();
943 Int_t nHalfLadD = halflad->GetNdaughters();
946 for (Int_t imod = 0; imod < nHalfLadD; imod++) {
949 geoMan->CdDown(imod);
952 SetSensor(moduleNr, statNr, statCBM, stationPar);
961 return moduleNr - modNr0;
966Int_t CbmStsDigiScheme::AddHotZone(Int_t moduleNr,
977 for (Int_t iSector = 0; iSector < stationPar->
GetNSectors(); iSector++) {
980 sectorPar = partest2;
985 cout <<
"-E- CbmStsDigiScheme::SetSensor: No parameters for module " << moduleNr <<
", station " << statNr
989 cout <<
" mod, sectors: " << moduleNr <<
" " << stationPar->
GetNSectors() <<
" " << sectorPar->
GetNSensors()
993 TString sectName = Form(
"stat%02dsect%d", statNr, moduleNr);
994 Int_t sectId = 2 << 24 | statNr << 16 | moduleNr << 4;
1003 for (Int_t iPar = 0; iPar < sectorPar->
GetNSensors(); iPar++) {
1006 sensorPar = partest3;
1011 cout <<
"-E- CbmStsDigiScheme::SetSensor: No parameters for sensor " << sensNr <<
", module " << moduleNr
1012 <<
", station " << statNr << endl;
1017 Double_t sensTrans[3] = {sensorPar->
GetX0(), sensorPar->
GetY0(), sensorPar->
GetZ0()};
1018 TString sensName = gGeoManager->GetPath();
1019 sensName +=
"/hotZone";
1020 Int_t sensId = 2 << 24 | statNr << 16 | moduleNr << 4 | sensNr << 1;
1021 Int_t sensType = sensorPar->
GetType();
1022 Double_t sensX = sensTrans[0];
1023 Double_t sensY = sensTrans[1];
1025 Double_t sensZ = sensTrans[2];
1027 Double_t sensLx = sensorPar->
GetLx();
1028 Double_t sensLy = sensorPar->
GetLy();
1029 Double_t sensD = sensorPar->
GetD();
1031 Double_t sensDx = sensorPar->
GetDx();
1032 Double_t sensDy = sensorPar->
GetDy();
1034 if (sensDx > 0.02) {
1035 Double_t zShift = 0.3;
1036 if (statNr % 2 == 1)
1040 Double_t sensStereoF = sensorPar->
GetStereoF();
1041 Double_t sensStereoB = sensorPar->
GetStereoB();
1043 sensD, sensDx, sensDy, sensStereoF, sensStereoB);
1045 if (fDetIdByName.find(sensName) != fDetIdByName.end()) {
1046 cout <<
"-E- CbmStsDigiScheme: Duplicate sensor name " << sensName << endl;
1050 fDetIdByName[sensName] = sensId;
1051 if (fSensorByName.find(sensName) != fSensorByName.end()) {
1052 cout <<
"-E- CbmStsDigiScheme: Duplicate sensor name " << sensName << endl;
1055 fSensorByName[sensName] = sensor;
1064void CbmStsDigiScheme::AddHotZones()
1068 cout <<
" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " << endl;
1070 TGeoNode* sts = NULL;
1071 gGeoManager->CdTop();
1072 TGeoNode* cave = gGeoManager->GetCurrentNode();
1073 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
1074 TGeoNode* node = cave->GetDaughter(iNode);
1075 TString
name = node->GetName();
1076 cout <<
"NODE: " <<
name << endl;
1077 if (
name.Contains(
"GEMS_0")) {
1079 gGeoManager->CdDown(iNode);
1084 cout <<
"-E- CbmStsDigiScheme::AddHotZones: Cannot find top GEM node" << endl;
1088 cout <<
"stations: " << sts->GetNdaughters() << endl;
1094 for (Int_t iNode = 0; iNode < sts->GetNdaughters(); iNode++) {
1096 gGeoManager->CdDown(iNode);
1097 TGeoNode* stationNode = gGeoManager->GetCurrentNode();
1098 TString statName = stationNode->GetName();
1099 if (!statName.Contains(
"station")) {
1100 gGeoManager->CdUp();
1103 cout <<
" Station: " << iNode <<
" " << sts->GetNdaughters() <<
" " << statName << endl;
1108 Int_t nModules = stationNode->GetNdaughters();
1110 for (Int_t iModule = 0; iModule < nModules; iModule++) {
1111 gGeoManager->CdDown(iModule);
1112 TGeoNode* moduleNode = gGeoManager->GetCurrentNode();
1113 TString moduleName = moduleNode->GetName();
1114 cout <<
" ModuleName: " << moduleName << endl;
1115 if (!(moduleName.Contains(
"Sensor_module"))) {
1116 gGeoManager->CdUp();
1120 Double_t hzone[3] = {20, 15.0 / 2, 0};
1121 TGeoVolume* hotVol =
nullptr ;
1122 const Double_t* tr = moduleNode->GetMatrix()->GetTranslation();
1123 TGeoVolume* mod = moduleNode->GetVolume();
1124 TGeoCompositeShape* shape = (TGeoCompositeShape*)mod->GetShape();
1125 Double_t wxyzMain[3] = {shape->GetDX(), shape->GetDY(), shape->GetDZ()};
1126 cout << wxyzMain[0] <<
" " << wxyzMain[1] <<
" " << wxyzMain[2] << endl;
1127 cout << tr[0] <<
" " << tr[1] <<
" " << tr[2] << endl;
1128 Double_t dxyzHot[3] = {0};
1129 TGeoBBox* hZone =
new TGeoBBox(
"hotZone", hzone[0], hzone[1], wxyzMain[2]);
1130 hotVol =
new TGeoVolume(
"Sensor_hot", hZone);
1131 hotVol->SetMedium(mod->GetMedium());
1132 if (tr[0] > 0 && tr[1] > 0) {
1133 dxyzHot[0] = -wxyzMain[0] + hzone[0];
1134 dxyzHot[1] = -wxyzMain[1] + hzone[1];
1135 }
else if (tr[0] > 0 && tr[1] < 0) {
1136 dxyzHot[0] = -wxyzMain[0] + hzone[0];
1137 dxyzHot[1] = -wxyzMain[1] + hzone[1];
1138 }
else if (tr[0] < 0 && tr[1] < 0) {
1139 dxyzHot[0] = -wxyzMain[0] + hzone[0];
1140 dxyzHot[1] = -wxyzMain[1] + hzone[1];
1141 }
else if (tr[0] < 0 && tr[1] > 0) {
1142 dxyzHot[0] = -wxyzMain[0] + hzone[0];
1143 dxyzHot[1] = -wxyzMain[1] + hzone[1];
1145 TString transName =
"stat";
1148 transName += iModule;
1149 TGeoTranslation* hot =
new TGeoTranslation(transName, dxyzHot[0], dxyzHot[1], 0.0);
1150 hot->RegisterYourself();
1151 mod->AddNode(hotVol, 0, hot);
1152 gGeoManager->CdUp();
1155 gGeoManager->CdUp();
Double_t GetModuleThickness()
BmnGemStripLayer & GetStripLayer(Int_t num)
Double_t GetZPositionRegistered()
BmnGemStripStation * GetStation(Int_t station_num)
BmnGemStripModule * GetModule(Int_t module_num)
Double_t GetZPositionRegistered()
Double_t GetModuleThickness()
BmnSiliconLayer & GetStripLayer(Int_t num)
BmnSiliconStation * GetStation(Int_t station_num)
BmnSiliconModule * GetModule(Int_t module_num)
Double_t GetZPositionRegistered()
BmnVSPLayer & GetStripLayer(Int_t num)
Double_t GetModuleThickness()
BmnVSPStation * GetStation(Int_t station_num)
BmnVSPModule * GetModule(Int_t module_num)
CbmStsStationDigiPar * GetStation(Int_t iStation)
void Print(Bool_t kLong=kFALSE)
static CbmStsDigiScheme * Instance(int version=1)
CbmStsSensor * GetSensor(Int_t stationNr, Int_t sectorNr, Int_t sensorNr)
virtual ~CbmStsDigiScheme()
CbmStsSensor * GetSensorByName(TString sensorName)
CbmStsStation * GetStationByNr(Int_t stationNr)
CbmStsSector * GetSector(Int_t stationNr, Int_t sectorNr)
CbmStsStation * GetStation(Int_t iStation)
Int_t GetDetectorIdByName(TString sensorName)
Int_t GetSectorNr() const
CbmStsSensorDigiPar * GetSensor(Int_t iSensor)
void AddSensor(CbmStsSensorDigiPar *sensorPar)
Int_t GetNSensors() const
Int_t GetSensorNr() const
Double_t GetRotation() const
Double_t GetStereoB() const
Double_t GetStereoF() const
CbmStsSectorDigiPar * GetSector(Int_t iSector)
virtual void Print(Bool_t kLong)
Int_t GetNSectors() const
void AddSector(CbmStsSectorDigiPar *sectorPar)