6 #include "GeoModelKernel/GeoMaterial.h"
7 #include "GeoModelKernel/GeoBox.h"
8 #include "GeoModelKernel/GeoTube.h"
9 #include "GeoModelKernel/GeoShapeSubtraction.h"
10 #include "GeoModelKernel/GeoShapeUnion.h"
11 #include "GeoModelKernel/GeoShapeShift.h"
12 #include "GeoModelKernel/GeoLogVol.h"
13 #include "GeoModelKernel/GeoNameTag.h"
14 #include "GeoModelKernel/GeoPhysVol.h"
15 #include "GeoModelKernel/GeoDefinitions.h"
16 #include "GeoModelKernel/Units.h"
18 #include "CLHEP/Geometry/Point3D.h"
20 #include "GaudiKernel/SystemOfUnits.h"
63 m_properties(
"ForwardRegionProperties")
71 LogStream << MSG::ERROR <<
": Failed to load magnet properties" <<
endmsg;
100 matName =
"std::Vacuum";
101 const GeoMaterial *vacuum = materialManager->
getMaterial(matName);
107 GeoElement *hydrogen =
new GeoElement(
"Hydrogen",
"H",1.0, 1.010);
108 GeoElement *oxygen =
new GeoElement(
"Oxygen",
"O", 8.0, 16.0);
109 water->add(hydrogen,0.11);
110 water->add(oxygen,0.89);
115 const GeoElement*
C = materialManager->
getElement(
"Carbon");
116 const GeoElement*
N = materialManager->
getElement(
"Nitrogen");
117 const GeoElement* Si = materialManager->
getElement(
"Silicon");
118 const GeoElement*
P = materialManager->
getElement(
"Phosphorus");
119 const GeoElement*
S = materialManager->
getElement(
"Sulfur");
120 const GeoElement* Cr = materialManager->
getElement(
"Chromium");
121 const GeoElement* Mn = materialManager->
getElement(
"Manganese");
122 const GeoElement* Fe = materialManager->
getElement(
"Iron");
123 const GeoElement* Ni = materialManager->
getElement(
"Nickel");
124 const GeoElement* Mo = materialManager->
getElement(
"Molybdenum");
125 const GeoElement* Cu = materialManager->
getElement(
"Copper");
128 const GeoElement* Al = materialManager->
getElement(
"Aluminium");
129 const GeoElement*
B = materialManager->
getElement(
"Boron");
130 const GeoElement* O = materialManager->
getElement(
"Oxygen");
135 copper->add(
const_cast<GeoElement*
> (Cu),1.0);
137 m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,copper));
140 matName =
"Tungsten";
141 const GeoElement*
W = materialManager->
getElement(
"Wolfram");
143 tungsten->add(
const_cast<GeoElement*
> (
W),1.0);
145 m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,tungsten));
149 matName =
"GlidCopAL15";
152 double aCu, aAl, aO, aB, aTot;
160 glidcop->add(
const_cast<GeoElement*
> (Cu), aCu/aTot);
161 glidcop->add(
const_cast<GeoElement*
> (Al), aAl/aTot);
162 glidcop->add(
const_cast<GeoElement*
> (O), aO/aTot);
163 glidcop->add(
const_cast<GeoElement*
> (
B), aB/aTot);
165 m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,glidcop));
171 double aC,aN,aSi,aP,aS,aCr,aMn,aFe,aNi,aMo,Atot;
183 Atot=aFe+aC+aMn+aSi+aP+aS+aCr+aMo+aNi+aN;
185 steel->add(
const_cast<GeoElement*
> (Fe),aFe/Atot);
186 steel->add(
const_cast<GeoElement*
> (
C), aC/Atot);
187 steel->add(
const_cast<GeoElement*
> (Mn),aMn/Atot);
188 steel->add(
const_cast<GeoElement*
> (Si),aSi/Atot);
189 steel->add(
const_cast<GeoElement*
> (
P), aP/Atot);
190 steel->add(
const_cast<GeoElement*
> (
S), aS/Atot);
191 steel->add(
const_cast<GeoElement*
> (Cr),aCr/Atot);
192 steel->add(
const_cast<GeoElement*
> (Mo),aMo/Atot);
193 steel->add(
const_cast<GeoElement*
> (Ni),aNi/Atot);
194 steel->add(
const_cast<GeoElement*
> (
N), aN/Atot);
196 m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,steel));
202 std::ostringstream strs;
217 int name, zStart, zEnd,
type, xAperture, yAperture, xStart, xEnd, yStart, yEnd, tubeThickness;
230 int lDFSize = loadedDataFile.size();
233 for(
int i=0;
i < lDFSize;
i++)
236 HepGeom::Point3D<double> pointMagStart;
237 HepGeom::Point3D<double> pointMagEnd;
241 bool pointsDefined = !(pointMagStart.distance2() == 0 || pointMagEnd.distance2() == 0);
247 double startZ = pointMagStart[2];
248 double endZ = pointMagEnd[2];
249 double startX = pointMagStart[0];
250 double endX = pointMagEnd[0];
251 double rotationAngle = atan2(endX - startX,endZ - startZ);
258 loadedDataFile[
i][xStart] =
num2str(pointMagStart[0]/1000);
259 loadedDataFile[
i][yStart] =
num2str(pointMagStart[1]/1000);
260 loadedDataFile[
i][zStart] =
num2str(pointMagStart[2]/1000);
261 loadedDataFile[
i-1][zEnd] =
num2str(
sgn(pointMagStart[2])*(abs(pointMagStart[2])-
dL)/1000);
263 loadedDataFile[
i][xEnd] =
num2str(pointMagEnd[0]/1000);
264 loadedDataFile[
i][yEnd] =
num2str(pointMagEnd[1]/1000);
265 loadedDataFile[
i+1][zStart] =
num2str(
sgn(pointMagEnd[2])*(abs(pointMagEnd[2])+
dL)/1000);
266 loadedDataFile[
i][zEnd] =
num2str(pointMagEnd[2]/1000);
271 double x,
y,
z,halfL,rotationAngle,
r,
dL,startZ,endZ,startX,endX,startY,endY;
276 for(
int i=0;
i < lDFSize;
i++)
286 x = (startX + endX)/2;
287 y = (startY + endY)/2;
288 z = (startZ + endZ)/2;
292 rotationAngle = atan2(endX - startX,endZ - startZ);
295 halfL = sqrt((endX - startX)*(endX - startX) + (endZ - startZ)*(endZ - startZ))/2;
303 if(loadedDataFile[
i][
name].
find(
"Mag") != std::string::npos)
309 if(
atoi(loadedDataFile[
i][
type].c_str()) == 0){
311 if(loadedDataFile[
i][
name] ==
"VCDBP.7R1.B"){
313 insertCircularElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), trackEnv);
316 insertCircularElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), fwrPhys);
320 if(
atoi(loadedDataFile[
i][
type].c_str()) == 4){
321 if(loadedDataFile[
i][
name] ==
"VCTYF.A4R1.X")
323 else if(loadedDataFile[
i][
name] ==
"TCL.5R1.B1")
332 insertCircularElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), fwrPhys);
338 if(
atoi(loadedDataFile[
i][
type].c_str()) == 1) {
340 insertEllipticalElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), magEnv);
345 if(loadedDataFile[
i][
name].
find(
"Mag") != std::string::npos)
347 if(loadedDataFile[
i][
name] ==
"LQXAA.1R1MagQ1" || loadedDataFile[
i][
name] ==
"LQXAG.3R1MagQ3")
349 if(loadedDataFile[
i][
name] ==
"LQXBA.2R1MagQ2a" || loadedDataFile[
i][
name] ==
"LQXBA.2R1MagQ2b")
355 if(
atoi(loadedDataFile[
i][
type].c_str()) == 2) {
357 insertXRecticircularElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), magEnv);
361 if(
atoi(loadedDataFile[
i][
type].c_str()) == 3) {
363 insertYRecticircularElement(loadedDataFile[
i][
name],
x,
y,
z, rotationAngle,
atof(loadedDataFile[
i][xAperture].c_str()),
atof(loadedDataFile[
i][yAperture].c_str()), halfL,
dL,
atof(loadedDataFile[
i][tubeThickness].c_str()), magEnv);
376 LogStream <<
MSG::INFO <<
"Constructing forward region model" <<
endmsg;
381 std::vector<std::vector<std::string> > loadedDataFileR = this->
loadDataFile(
"ForwardRegionGeoModel/LSS1Rout.csv",11);
382 std::vector<std::vector<std::string> > loadedDataFileL = this->
loadDataFile(
"ForwardRegionGeoModel/LSS1Lout.csv",11);
394 const GeoTube *fwrTubeL =
new GeoTube(0,2*
Gaudi::Units::m,(endZ-startZ)/2);
399 const GeoShapeShift& fwrTube0 = (*fwrTubeL)<<shiftL;
400 const GeoShapeUnion& fwrTube1 = fwrTube0.add((*fwrTubeR)<<shiftR);
408 const GeoShapeSubtraction& fwrTube2 = fwrTube1.subtract((*alfa)<<shiftAlfaL1).subtract((*alfa)<<shiftAlfaL2).subtract((*alfa)<<shiftAlfaR1).subtract((*alfa)<<shiftAlfaR2);
417 const GeoShapeSubtraction& fwrTube3 = fwrTube2.subtract((*afp)<<shiftAfpL1).subtract((*afp)<<shiftAfpR1).subtract((*afp2)<<shiftAfpL2).subtract((*afp2)<<shiftAfpR2);
423 const GeoShapeSubtraction& fwrTube = fwrTube3.subtract((*zdc)<<shiftZdcL1).subtract((*zdc)<<shiftZdcR1);
426 const GeoLogVol *fwrLog =
new GeoLogVol(
"ForwardRegionGeoModel", &fwrTube,
m_MapMaterials[std::string(
"std::Vacuum")]);
427 GeoPhysVol *fwrPhys =
new GeoPhysVol(fwrLog);
428 GeoNameTag *
tag =
new GeoNameTag(
"ForwardRegionGeoModel");
436 LogStream <<
MSG::INFO <<
"Forward region model succesfully constructed." <<
endmsg;
447 std::vector<std::vector<std::string> > loadedData;
454 LogStream <<
MSG::DEBUG <<
"File " <<
fileName <<
" not found in run directory, trying to load it from DATAPATH" <<
endmsg;
463 std::vector<std::string>
row (
cols);
468 if(
c !=
'@' &&
c !=
'#' &&
c !=
'*' &&
c !=
'$' &&
c !=
'%')
475 loadedData.push_back(
row);
476 file.ignore(1024,
'\n');
479 file.ignore(1024,
'\n');