er  dev
ERGeoSubAssembly.cxx
1 /********************************************************************************
2  * Copyright (C) Joint Institute for Nuclear Research *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #include "ERGeoSubAssembly.h"
10 
11 #include "FairLogger.h"
12 //--------------------------------------------------------------------------------------------------
13 void ERGeoSubAssembly::AddComponent(ERGeoComponent* component) {
14  component->SetVolumeNamePrefix(TString(this->GetName()) + "_");
15  LOG(DEBUG) << "Component " << component->GetVolumeName() << " added to " << fName << FairLogger::endl;
16  fComponents[component->GetVolumeName()] = component;
17 }
18 //--------------------------------------------------------------------------------------------------
19 void ERGeoSubAssembly::AddComponent(ERGeoComponent* component, const TVector3& position,
20  const TVector3& rotation) {
21  component->SetPosition(position);
22  component->SetRotation(rotation);
23  AddComponent(component);
24 }
25 //--------------------------------------------------------------------------------------------------
26 void ERGeoSubAssembly::ConstructGeometryVolume() {
27  fVolume = new TGeoVolumeAssembly(fName);
28  for (auto componentPair : fComponents) {
29  auto* component = componentPair.second;
30  component->ConstructGeometryVolume();
31  const auto* translation = component->GetPosition();
32  auto* rotation = const_cast<TGeoRotation*>(component->GetRotation());
33  fVolume->AddNode(component->GetVolume(), 0,
34  new TGeoCombiTrans(translation->X() ,translation->Y(), translation->Z(),
35  rotation));
36  }
37 }
38 //--------------------------------------------------------------------------------------------------
39 std::list<TString> ERGeoSubAssembly::GetComponentNames() const {
40  std::list<TString> names;
41  for (auto componentPair : fComponents) {
42  names.push_back(componentPair.first);
43  }
44  return names;
45 }
46 //--------------------------------------------------------------------------------------------------
47 ClassImp(ERGeoSubAssembly)
48