90 if (StatusCode::SUCCESS !=
m_detectorStore->retrieve(materialManager, std::string(
"MATERIALS"))) {
100 matName =
"std::Vacuum";
101 const GeoMaterial *vacuum = materialManager->
getMaterial(matName);
106 GeoMaterial *water =
new GeoMaterial(
"H20", 1.0*GeoModelKernelUnits::gram/Gaudi::Units::cm3);
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");
134 GeoMaterial *copper =
new GeoMaterial(
"Copper", 8.94*GeoModelKernelUnits::g/Gaudi::Units::cm3);
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");
142 GeoMaterial *tungsten =
new GeoMaterial(
"Tungsten", 19.25*GeoModelKernelUnits::g/Gaudi::Units::cm3);
143 tungsten->add(
const_cast<GeoElement*
> (W),1.0);
145 m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,tungsten));
149 matName =
"GlidCopAL15";
150 GeoMaterial *glidcop=
new GeoMaterial(
"GlidCopAL15", 8.90*GeoModelKernelUnits::g/Gaudi::Units::cm3);
152 double aCu, aAl, aO, aB, aTot;
154 aCu=99.7*Cu->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
155 aAl=0.15*Al->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
156 aO=0.13*O->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
157 aB=0.02*B->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
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));
169 GeoMaterial *steel=
new GeoMaterial(
"Steel", 8*GeoModelKernelUnits::g/Gaudi::Units::cm3);
171 double aC,aN,aSi,aP,aS,aCr,aMn,aFe,aNi,aMo,Atot;
173 aFe=62.045*Fe->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
174 aC =0.03*
C ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
175 aMn=2.0*Mn ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
176 aSi=0.75*Si->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
177 aP =0.045*
P->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
178 aS =0.03*S ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
179 aCr=18.0*Cr->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
180 aMo=3.0*Mo ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
181 aNi=14.0*Ni->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
182 aN =0.10*N ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
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));
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;
238 if(
m_properties.retrieve().isSuccess())
m_properties->getMagTransforms(loadedDataFile[i][name],beam,pointMagStart,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);
252 double r = atof(loadedDataFile[i][xAperture].c_str())*Gaudi::Units::mm/2;
253 double dL = abs(
r*tan(rotationAngle))+0.2*Gaudi::Units::mm;
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++)
278 startZ = atof(loadedDataFile[i][zStart].c_str())*Gaudi::Units::m;
279 endZ = atof(loadedDataFile[i][zEnd].c_str())*Gaudi::Units::m;
280 startX = atof(loadedDataFile[i][xStart].c_str())*Gaudi::Units::m;
281 endX = atof(loadedDataFile[i][xEnd].c_str())*Gaudi::Units::m;
282 startY = atof(loadedDataFile[i][yStart].c_str())*Gaudi::Units::m;
283 endY = atof(loadedDataFile[i][yEnd].c_str())*Gaudi::Units::m;
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;
297 r = atof(loadedDataFile[i][xAperture].c_str())*Gaudi::Units::mm/2;
300 dL = abs(
r*tan(rotationAngle))+0.2*Gaudi::Units::mm;
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"){
312 GeoPhysVol* trackEnv =
insertMagnetEnvelope(loadedDataFile[i][name],
x,
y,
z, rotationAngle, 100*Gaudi::Units::mm, halfL, dL, fwrPhys);
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")
325 else if(
m_Config.buildTCL4 && loadedDataFile[i][name] ==
"VCDSS.4R1.B")
327 else if(
m_Config.buildTCL6 && loadedDataFile[i][name] ==
"TCL6")
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) {
339 magEnv =
insertMagnetEnvelope(loadedDataFile[i][name],
x,
y,
z, rotationAngle, 20*Gaudi::Units::cm, halfL, dL, fwrPhys);
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);
344 double magDiam = 19.4*Gaudi::Units::cm;
345 if(loadedDataFile[i][name].
find(
"Mag") != std::string::npos)
346 magDiam= 19.4*Gaudi::Units::cm;
347 if(loadedDataFile[i][name] ==
"LQXAA.1R1MagQ1" || loadedDataFile[i][name] ==
"LQXAG.3R1MagQ3")
348 magDiam = 48*Gaudi::Units::cm;
349 if(loadedDataFile[i][name] ==
"LQXBA.2R1MagQ2a" || loadedDataFile[i][name] ==
"LQXBA.2R1MagQ2b")
350 magDiam = 52*Gaudi::Units::cm;
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);
386 if(
m_Config.vp1Compatibility) startZ = 19.0*Gaudi::Units::m;
387 else startZ = 22.0*Gaudi::Units::m;
388 endZ = 268.904*Gaudi::Units::m;
394 const GeoTube *fwrTubeL =
new GeoTube(0,2*Gaudi::Units::m,(endZ-startZ)/2);
395 GeoTube *fwrTubeR =
new GeoTube(0,2*Gaudi::Units::m,(endZ-startZ)/2);
396 GeoTrf::Transform3D shiftL = GeoTrf::Translate3D(0,0,(endZ+startZ)/2);
397 GeoTrf::Transform3D shiftR = GeoTrf::Translate3D(0,0,-(endZ+startZ)/2);
399 const GeoShapeShift& fwrTube0 = (*fwrTubeL)<<shiftL;
400 const GeoShapeUnion& fwrTube1 = fwrTube0.add((*fwrTubeR)<<shiftR);
403 const GeoTube *alfa =
new GeoTube(0, 2*Gaudi::Units::m, 500*Gaudi::Units::mm);
404 GeoTrf::Transform3D shiftAlfaL1 = GeoTrf::Translate3D(0,0,237388*Gaudi::Units::mm);
405 GeoTrf::Transform3D shiftAlfaR1 = GeoTrf::Translate3D(0,0,-237408*Gaudi::Units::mm);
406 GeoTrf::Transform3D shiftAlfaL2 = GeoTrf::Translate3D(0,0,(
m_Config.ALFAInNewPosition ?
m_Config.newPosB7L1 : 241528*Gaudi::Units::mm));
407 GeoTrf::Transform3D shiftAlfaR2 = GeoTrf::Translate3D(0,0,(
m_Config.ALFAInNewPosition ?
m_Config.newPosB7R1 :-241548*Gaudi::Units::mm));
408 const GeoShapeSubtraction& fwrTube2 = fwrTube1.subtract((*alfa)<<shiftAlfaL1).subtract((*alfa)<<shiftAlfaL2).subtract((*alfa)<<shiftAlfaR1).subtract((*alfa)<<shiftAlfaR2);
411 const GeoTube *afp =
new GeoTube(0, 2.5*Gaudi::Units::m, 280*Gaudi::Units::mm);
412 const GeoTube *afp2 =
new GeoTube(0, 2.5*Gaudi::Units::m, 580*Gaudi::Units::mm);
413 GeoTrf::Transform3D shiftAfpL1 = GeoTrf::Translate3D(0,0,
m_Config.posAFPL1);
414 GeoTrf::Transform3D shiftAfpR1 = GeoTrf::Translate3D(0,0,
m_Config.posAFPR1);
415 GeoTrf::Transform3D shiftAfpL2 = GeoTrf::Translate3D(0,0,
m_Config.posAFPL2);
416 GeoTrf::Transform3D shiftAfpR2 = GeoTrf::Translate3D(0,0,
m_Config.posAFPR2);
417 const GeoShapeSubtraction& fwrTube3 = fwrTube2.subtract((*afp)<<shiftAfpL1).subtract((*afp)<<shiftAfpR1).subtract((*afp2)<<shiftAfpL2).subtract((*afp2)<<shiftAfpR2);
420 const GeoBox *zdc =
new GeoBox( 9.1*Gaudi::Units::cm/2.0 ,18.1*Gaudi::Units::cm/2.0 , 94.4*Gaudi::Units::cm/2.0);
421 GeoTrf::Transform3D shiftZdcL1 = GeoTrf::Translate3D(0,0,
m_Config.posZDC1);
422 GeoTrf::Transform3D shiftZdcR1 = GeoTrf::Translate3D(0,0,
m_Config.posZDC2);
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;