8 #include "TGeoManager.h"
9 #include "TGeoMatrix.h"
12 #define RESET "\033[0m"
13 #define RED "\033[1m\033[31m"
14 #define GREEN "\033[32m"
19 : FairModule(
"Target",
"CBM target")
29 , fBuildFromFile(kFALSE) {}
35 : FairModule(
"Target",
"CBM target")
45 , fBuildFromFile(kTRUE) {
56 : FairModule(
"Target",
"CBM target")
58 , fThickness(thickness)
66 , fBuildFromFile(kFALSE) {}
75 : FairModule(
"Target",
"CBM target")
77 , fThickness(thickness)
85 , fBuildFromFile(kFALSE) {}
92 std::cout << std::endl;
96 if (!fgeoName.EndsWith(
".geo.root")) {
97 LOG(INFO) << GetName() <<
": geometry file is " << fgeoName;
98 LOG(FATAL) << GetName() <<
": only ROOT geometry files are supported!";
101 LOG(INFO) << GetName() <<
": Constructing geometry from " << fgeoName;
102 ConstructRootGeometry();
106 LOG(INFO) << GetName() <<
": Constructing geometry...";
109 TGeoManager* geoMan = gGeoManager;
113 TGeoElement* targElem = NULL;
115 targElem = geoMan->GetElementTable()->GetElement(
fZ);
117 LOG(FATAL) << GetName() <<
": Unknown element " <<
fZ;
122 targElem = geoMan->GetElementTable()->FindElement(
fMaterial.Data());
124 LOG(FATAL) << GetName() <<
": Unknown element " <<
fMaterial;
128 LOG(FATAL) << GetName() <<
": Target material not specified!";
131 LOG(INFO) << GetName() <<
": Use material " <<
fMaterial <<
", z = " <<
fZ;
136 LOG(FATAL) << GetName() <<
": No standard density for element " <<
fMaterial
137 <<
" available: density must be set explicitly.";
142 TGeoMaterial* targMat =
143 new TGeoMaterial(
"targetMaterial", targElem,
fDensity);
144 if (fair::Logger::Logging(
"DEBUG")) targMat->Print();
146 TGeoMedium* targMedium =
new TGeoMedium(
"targetMedium", 9999, targMat);
147 targMedium->SetParam(0, 1.);
148 targMedium->SetParam(1, 1.);
149 targMedium->SetParam(2, 20.);
150 targMedium->SetParam(6, 0.001);
155 LOG(FATAL) << GetName() <<
": No mother node found at target position!";
158 LOG(INFO) << GetName() <<
": Mother node is " << motherNode->GetName();
165 TGeoHMatrix r1 = geoMan->GetCurrentMatrix()->Inverse();
167 TGeoRotation* target_rotation =
new TGeoRotation();
168 target_rotation->RotateY(
fRotY * TMath::RadToDeg());
169 TGeoHMatrix* targetMatrix =
new TGeoHMatrix(
"targetToGlobal");
170 *targetMatrix = r1 * r2 * *target_rotation;
175 motherNode->GetVolume()->AddNode(target, 0, targetMatrix);
179 LOG(
DEBUG) << GetName() <<
": Test node is " << testNode->GetName();
180 TGeoHMatrix* testMatrix = geoMan->GetCurrentMatrix();
181 if (fair::Logger::Logging(
"DEBUG")) testMatrix->Print();
183 std::cout << std::endl;
190 return TVector3(TMath::Sin(
fRotY), 0., TMath::Cos(
fRotY));
201 case 4:
return 1.848;
break;
202 case 6:
return 2.260;
break;
203 case 28:
return 8.908;
break;
204 case 47:
return 10.490;
break;
205 case 49:
return 7.310;
break;
206 case 79:
return 19.320;
break;
207 case 82:
return 11.342;
break;
208 default:
return -1.;
break;
237 LOG(INFO) <<
"Using target file name " << name;
238 return FairModule::SetGeometryFileName(name, version);
246 std::stringstream ss;
249 ss << GetName() <<
": Geometry file " << fgeoName;
252 ss << GetName() <<
": Material " <<
fMaterial;
254 ss <<
", density " <<
fDensity <<
" g/cm^3, ";
256 ss <<
", standard density, ";
259 <<
") cm, rotation (y) " <<
fRotY <<
" rad";