17 #include <FairField.h>
18 #include <FairLogger.h>
21 #include <TCollection.h>
23 #include <TGeoManager.h>
24 #include <TGeoMatrix.h>
26 #include <TGeoPhysicalNode.h>
27 #include <TGeoVolume.h>
64 TString name = Form(
"STS_S%02i", stationId + 1);
65 TString title = Form(
"STS Station %i", stationId + 1);
86 Int_t nodeNumber = ladder->
GetPnode()->GetNode()->GetNumber();
87 Int_t stationId = nodeNumber / 100 - 1;
91 TString name = Form(
"STS_S%02i", stationId + 1);
92 TString title = Form(
"STS Station %i", stationId + 1);
115 Double_t zPrevious = -999999;
116 for (UInt_t iStation = 0; iStation <
fStations.size(); iStation++) {
118 LOG(error) << GetName() <<
": Number of stations is " <<
fStations.size()
119 <<
", but station " << iStation <<
"is not present!";
122 if (
fStations[iStation]->GetZ() <= zPrevious) {
123 LOG(error) << GetName() <<
": Disordered stations. Station " << iStation
124 <<
" is at z = " <<
fStations[iStation]->GetZ()
125 <<
"cm , previous is at z = " << zPrevious <<
" cm.";
129 if (!isOk) LOG(fatal) << GetName() <<
": Error in creation of stations.";
140 if (!
fAddress) LOG(fatal) << fName <<
": not initialised!";
144 LOG(warn) << fName <<
": No STS address " << address;
150 LOG(warn) << fName <<
": Illegal level " << level;
155 for (Int_t iLevel = 1; iLevel <= level; iLevel++) {
174 case kStsUnit:
return "unit";
break;
179 case kStsSide:
return "side";
break;
180 default:
return "";
break;
195 return ladder->
GetPnode()->GetNode()->GetNumber() / 100 - 1;
207 LOG(info) <<
"==========================================================";
208 LOG(info) <<
"Initialising STS Setup \n";
223 LOG(info) << fName <<
": Elements in setup: ";
224 for (Int_t iLevel = 1; iLevel <=
kStsSensor; iLevel++) {
227 LOG(info) <<
" " << setw(12) << name << setw(5) << right
243 assert(!
fModules.count(moduleAddress));
258 LOG(info) <<
"Sensor in map: " <<
fSensors.size() <<
" in vector "
264 LOG(info) << GetName() <<
": Setup contains " << nStations
265 <<
" stations objects.";
266 if (FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug)) {
269 LOG(debug) <<
" " << it->second->ToString();
276 LOG(fatal) << GetName() <<
": inconsistent number of sensors! "
279 LOG(fatal) << GetName() <<
": inconsistent number of modules! "
282 LOG(info) <<
"=========================================================="
303 LOG(info) << it->second->ToString();
313 LOG(info) << fName <<
": Reading geometry from TGeoManager "
318 TGeoNode* cave = geo->GetCurrentNode();
321 TGeoNode* sts =
nullptr;
322 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
323 TString name = cave->GetDaughter(iNode)->GetName();
324 if (name.Contains(
"STS", TString::kIgnoreCase)) {
325 sts = cave->GetDaughter(iNode);
326 LOG(info) << fName <<
": STS top node is " << sts->GetName();
331 LOG(error) << fName <<
": No top STS node found in geometry!";
336 TString path = cave->GetName();
337 path = path +
"/" + sts->GetName();
338 fNode =
new TGeoPhysicalNode(path);
341 Bool_t hasStation = kFALSE;
342 Bool_t hasUnit = kFALSE;
343 for (Int_t iDaughter = 0; iDaughter <
fNode->GetNode()->GetNdaughters();
345 TString dName =
fNode->GetNode()->GetDaughter(iDaughter)->GetName();
346 if (dName.Contains(
"station", TString::kIgnoreCase)) hasStation = kTRUE;
347 if (dName.Contains(
"unit", TString::kIgnoreCase)) hasUnit = kTRUE;
349 if (hasUnit && (!hasStation))
351 else if ((!hasUnit) && hasStation)
353 else if (hasUnit && hasStation)
354 LOG(fatal) << GetName() <<
": geometry contains both units and stations!";
356 LOG(fatal) << GetName()
357 <<
": geometry contains neither units nor stations!";
360 LOG(warn) << GetName() <<
": using old geometry (with stations)";
373 LOG(info) << fName <<
": Reading geometry from file " << fileName;
376 assert(!gGeoManager);
379 TFile geoFile(fileName);
380 if (!geoFile.IsOpen()) {
381 LOG(fatal) << GetName() <<
": Could not open geometry file " << fileName;
386 TGeoManager* stsGeometry =
387 new TGeoManager(
"StsGeo",
"STS stand-alone geometry");
390 TGeoVolume* topVolume =
nullptr;
391 TList* keyList = geoFile.GetListOfKeys();
393 TIter keyIter(keyList);
394 while ((key = (TKey*) keyIter())) {
395 if (strcmp(key->GetClassName(),
"TGeoVolumeAssembly") == 0) {
396 TGeoVolume* volume = (TGeoVolume*) key->ReadObj();
397 if (strcmp(volume->GetName(),
"TOP") == 0) {
404 LOG(fatal) << GetName() <<
": No TOP volume in file!";
407 stsGeometry->SetTopVolume(topVolume);
410 stsGeometry->CdTop();
411 TGeoNode* cave = stsGeometry->GetCurrentNode();
414 TGeoNode* sts =
nullptr;
415 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
416 TString name = cave->GetDaughter(iNode)->GetName();
417 if (name.Contains(
"STS", TString::kIgnoreCase)) {
418 sts = cave->GetDaughter(iNode);
419 stsGeometry->CdDown(iNode);
420 LOG(info) << fName <<
": STS top node is " << sts->GetName();
425 LOG(error) << fName <<
": No top STS node found in geometry!";
430 TString path = cave->GetName();
431 path = path +
"/" + sts->GetName();
432 fNode =
new TGeoPhysicalNode(path);
435 TString dName =
fNode->GetNode()->GetDaughter(0)->GetName();
436 if (dName.Contains(
"station", TString::kIgnoreCase))
438 else if (dName.Contains(
"unit", TString::kIgnoreCase))
441 LOG(fatal) << GetName() <<
": unknown geometry type; first level name is "
444 LOG(warn) << GetName() <<
": using old geometry (with stations)";
458 UInt_t address = moduleIt.first;
459 moduleIt.second->SetParameters(params->
GetParModule(address));
462 LOG(info) << GetName() <<
": Set parameters for " << nModules <<
" modules";
474 UInt_t address = sensorIt.first;
475 sensorIt.second->SetConditions(&(conds->
GetParSensor(address)));
478 LOG(info) << GetName() <<
": Set conditions for " << nSensors <<
" sensors";
489 UInt_t address = sensorIt.first;
490 sensorIt.second->SetParameters(&(parSet->
GetParSensor(address)));
493 LOG(info) << GetName() <<
": Set parameters for " << nSensors <<
" sensors";