ATLAS Offline Software
ForwardRegionGeoModelFactory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GeoModelKernel/GeoMaterial.h"
7 #include "GeoModelKernel/GeoBox.h"
8 #include "GeoModelKernel/GeoTube.h"
9 #include "GeoModelKernel/GeoPcon.h"
10 #include "GeoModelKernel/GeoEllipticalTube.h"
11 #include "GeoModelKernel/GeoShapeSubtraction.h"
12 #include "GeoModelKernel/GeoShapeIntersection.h"
13 #include "GeoModelKernel/GeoShapeUnion.h"
14 #include "GeoModelKernel/GeoShapeShift.h"
15 #include "GeoModelKernel/GeoLogVol.h"
16 #include "GeoModelKernel/GeoNameTag.h"
17 #include "GeoModelKernel/GeoPhysVol.h"
18 #include "GeoModelKernel/GeoFullPhysVol.h"
19 #include "GeoModelKernel/GeoDefinitions.h"
20 #include "GeoModelKernel/Units.h"
21 #include "GeoGenericFunctions/AbsFunction.h"
22 #include "GeoGenericFunctions/Variable.h"
23 #include "GeoGenericFunctions/Sin.h"
24 #include "GeoGenericFunctions/Cos.h"
25 #include "CLHEP/Geometry/Point3D.h"
26 #include "StoreGate/StoreGateSvc.h"
27 #include "GaudiKernel/SystemOfUnits.h"
28 
30 
32 
33 #include <iostream>
34 #include <fstream>
35 #include <string>
36 #include <vector>
37 
38 #include <math.h>
39 #include <algorithm>
40 
41 // #include <stdio.h> // FILENAME_MAX
42 // #include <unistd.h> // getcwd()
43 
44 #include <stdlib.h>
45 
46 
48 {
61  vp1Compatibility = false;
62  buildTCL4 = false;
63  buildTCL6 = false;
64  ALFAInNewPosition = false;
65  newPosB7L1 = 245656.77*Gaudi::Units::mm;
66  newPosB7R1 = -245656.11*Gaudi::Units::mm;
67  posAFPL1 = 204500*Gaudi::Units::mm;
68  posAFPL2 = 212675*Gaudi::Units::mm;
69  posAFPR1 = -204500*Gaudi::Units::mm;
70  posAFPL2 = -212675*Gaudi::Units::mm;
71  posZDC1 = 141580*Gaudi::Units::mm;
72  posZDC2 = -141580*Gaudi::Units::mm;
73 }
74 
75 
77  :m_detectorStore(detStore),
78  m_properties("ForwardRegionProperties")
79 {
80  m_detectorManager = NULL;
81  MsgStream LogStream(Athena::getMessageSvc(), "ForwardRegionGeoModel::ForwardRegionGeoModel()");
82 
83  m_Config = *pConfig;
84 
85  if(m_properties.retrieve().isFailure()){
86  LogStream << MSG::ERROR << ": Failed to load magnet properties" << endmsg;
87  return;
88  }
89 
90  m_MagConfig = *(m_properties->getConf());
91 }
92 
93 
95 {
96 
97 }
98 
99 
101 {
102  std::string matName;
103 
104  StoredMaterialManager* materialManager = nullptr;
105  if (StatusCode::SUCCESS != m_detectorStore->retrieve(materialManager, std::string("MATERIALS"))) {
106  return;
107  }
108 
109 
110  //-----------------------------------------------------------------------------------//
111  // Get the materials that we shall use. //
112  // ----------------------------------------------------------------------------------//
113 
114  // vacuum
115  matName = "std::Vacuum";
116  const GeoMaterial *vacuum = materialManager->getMaterial(matName);
117  m_MapMaterials.emplace(matName,vacuum);
118 
119  // water
120  matName = "water";
121  GeoMaterial *water = new GeoMaterial("H20", 1.0*GeoModelKernelUnits::gram/Gaudi::Units::cm3);
122  GeoElement *hydrogen = new GeoElement("Hydrogen","H",1.0, 1.010);
123  GeoElement *oxygen = new GeoElement("Oxygen", "O", 8.0, 16.0);
124  water->add(hydrogen,0.11);
125  water->add(oxygen,0.89);
126  water->lock();
127  m_MapMaterials.emplace(matName,water);
128 
129  // elements
130  const GeoElement* C = materialManager->getElement("Carbon");
131  const GeoElement* N = materialManager->getElement("Nitrogen");
132  const GeoElement* Si = materialManager->getElement("Silicon");
133  const GeoElement* P = materialManager->getElement("Phosphorus");
134  const GeoElement* S = materialManager->getElement("Sulfur");
135  const GeoElement* Cr = materialManager->getElement("Chromium");
136  const GeoElement* Mn = materialManager->getElement("Manganese");
137  const GeoElement* Fe = materialManager->getElement("Iron");
138  const GeoElement* Ni = materialManager->getElement("Nickel");
139  const GeoElement* Mo = materialManager->getElement("Molybdenum");
140  const GeoElement* Cu = materialManager->getElement("Copper");
141 
142 
143  const GeoElement* Al = materialManager->getElement("Aluminium");
144  const GeoElement* B = materialManager->getElement("Boron");
145  const GeoElement* O = materialManager->getElement("Oxygen");
146 
147  // Copper for beam screens
148  matName = "Copper";
149  GeoMaterial *copper = new GeoMaterial("Copper", 8.94*GeoModelKernelUnits::g/Gaudi::Units::cm3);
150  copper->add(const_cast<GeoElement*> (Cu),1.0);
151  copper->lock();
152  m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,copper));
153 
154  // Tungsten for TCL6
155  matName = "Tungsten";
156  const GeoElement* W = materialManager->getElement("Wolfram");
157  GeoMaterial *tungsten = new GeoMaterial("Tungsten", 19.25*GeoModelKernelUnits::g/Gaudi::Units::cm3);
158  tungsten->add(const_cast<GeoElement*> (W),1.0);
159  tungsten->lock();
160  m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,tungsten));
161 
162  // GlidCop AL15 copper -- aproximate composition (trace impurities (< 0.01 wt. %) not included)
163  // source: http://www-ferp.ucsd.edu/LIB/PROPS/compcu15.html
164  matName = "GlidCopAL15";
165  GeoMaterial *glidcop=new GeoMaterial("GlidCopAL15", 8.90*GeoModelKernelUnits::g/Gaudi::Units::cm3);
166 
167  double aCu, aAl, aO, aB, aTot;
168 
169  aCu=99.7*Cu->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
170  aAl=0.15*Al->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
171  aO=0.13*O->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
172  aB=0.02*B->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
173  aTot=aCu+aAl+aO+aB;
174 
175  glidcop->add(const_cast<GeoElement*> (Cu), aCu/aTot);
176  glidcop->add(const_cast<GeoElement*> (Al), aAl/aTot);
177  glidcop->add(const_cast<GeoElement*> (O), aO/aTot);
178  glidcop->add(const_cast<GeoElement*> (B), aB/aTot);
179  glidcop->lock();
180  m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,glidcop));
181 
182  // Steel Grade 316L (Roman Pot)
183  matName = "Steel";
184  GeoMaterial *steel=new GeoMaterial("Steel", 8*GeoModelKernelUnits::g/Gaudi::Units::cm3);
185 
186  double aC,aN,aSi,aP,aS,aCr,aMn,aFe,aNi,aMo,Atot;
187 
188  aFe=62.045*Fe->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
189  aC =0.03*C ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
190  aMn=2.0*Mn ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
191  aSi=0.75*Si->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
192  aP =0.045*P->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
193  aS =0.03*S ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
194  aCr=18.0*Cr->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
195  aMo=3.0*Mo ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
196  aNi=14.0*Ni->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
197  aN =0.10*N ->getA()/(GeoModelKernelUnits::g/Gaudi::Units::mole);
198  Atot=aFe+aC+aMn+aSi+aP+aS+aCr+aMo+aNi+aN;
199 
200  steel->add(const_cast<GeoElement*> (Fe),aFe/Atot);
201  steel->add(const_cast<GeoElement*> (C), aC/Atot);
202  steel->add(const_cast<GeoElement*> (Mn),aMn/Atot);
203  steel->add(const_cast<GeoElement*> (Si),aSi/Atot);
204  steel->add(const_cast<GeoElement*> (P), aP/Atot);
205  steel->add(const_cast<GeoElement*> (S), aS/Atot);
206  steel->add(const_cast<GeoElement*> (Cr),aCr/Atot);
207  steel->add(const_cast<GeoElement*> (Mo),aMo/Atot);
208  steel->add(const_cast<GeoElement*> (Ni),aNi/Atot);
209  steel->add(const_cast<GeoElement*> (N), aN/Atot);
210  steel->lock();
211  m_MapMaterials.insert(std::pair<std::string,GeoMaterial*>(matName,steel));
212 }
213 
214 template <class T>
216 {
217  std::ostringstream strs;
218  strs << num;
219  return strs.str();
220 }
221 
222 template <typename T> int ForwardRegionGeoModelFactory::sgn(T val) {
223  return (T(0) < val) - (val < T(0));
224 }
225 
226 void ForwardRegionGeoModelFactory::constructElements(GeoPhysVol *fwrPhys,std::vector<std::vector<std::string> > loadedDataFile, int beam)
227 {
228  //-------------------------------------------------------------------------------------
229  // Construction of geometry from geometry file
230 
231  // indexes
232  int name, zStart, zEnd, type, xAperture, yAperture, xStart, xEnd, yStart, yEnd, tubeThickness;
233  name = 0;
234  type = 1;
235  zStart = 4;
236  zEnd = 5;
237  xAperture = 2;
238  yAperture = 3;
239  xStart = 6;
240  xEnd = 7;
241  yStart = 8;
242  yEnd = 9;
243  tubeThickness = 10;
244 
245  int lDFSize = loadedDataFile.size();
246 
247  // apply shifts of magnets defined by magnets properties in JO
248  for(int i=0; i < lDFSize; i++)
249  {
250  // get start and end points defined in JO
251  HepGeom::Point3D<double> pointMagStart;
252  HepGeom::Point3D<double> pointMagEnd;
253  if(m_properties.retrieve().isSuccess()) m_properties->getMagTransforms(loadedDataFile[i][name],beam,pointMagStart,pointMagEnd);
254 
255  // are points defined (non-zero)? If not, shifts will not apply
256  bool pointsDefined = !(pointMagStart.distance2() == 0 || pointMagEnd.distance2() == 0);
257 
258  if(pointsDefined)
259  {
260 
261  // overlap correction for x rotation
262  double startZ = pointMagStart[2];
263  double endZ = pointMagEnd[2];
264  double startX = pointMagStart[0];
265  double endX = pointMagEnd[0];
266  double rotationAngle = atan2(endX - startX,endZ - startZ);
267  double r = atof(loadedDataFile[i][xAperture].c_str())*Gaudi::Units::mm/2;
268  double dL = abs(r*tan(rotationAngle))+0.2*Gaudi::Units::mm;
269 
270 
271  // move start and end points of the magnet element and neighbour elemens accordingly
272  // move (resize) neighbours only in z (needed to avoid overlaps)
273  loadedDataFile[i][xStart] = num2str(pointMagStart[0]/1000);
274  loadedDataFile[i][yStart] = num2str(pointMagStart[1]/1000);
275  loadedDataFile[i][zStart] = num2str(pointMagStart[2]/1000);
276  loadedDataFile[i-1][zEnd] = num2str(sgn(pointMagStart[2])*(abs(pointMagStart[2])-dL)/1000);
277 
278  loadedDataFile[i][xEnd] = num2str(pointMagEnd[0]/1000);
279  loadedDataFile[i][yEnd] = num2str(pointMagEnd[1]/1000);
280  loadedDataFile[i+1][zStart] = num2str(sgn(pointMagEnd[2])*(abs(pointMagEnd[2])+dL)/1000);
281  loadedDataFile[i][zEnd] = num2str(pointMagEnd[2]/1000);
282 
283  }
284  }
285 
286  double x,y,z,halfL,rotationAngle,r,dL,startZ,endZ,startX,endX,startY,endY;
287 
288  // ################ ELEMENTS ############################
289 
290  // --------------- elements cycle -----------------
291  for(int i=0; i < lDFSize; i++)
292  {
293  startZ = atof(loadedDataFile[i][zStart].c_str())*Gaudi::Units::m;
294  endZ = atof(loadedDataFile[i][zEnd].c_str())*Gaudi::Units::m;
295  startX = atof(loadedDataFile[i][xStart].c_str())*Gaudi::Units::m;
296  endX = atof(loadedDataFile[i][xEnd].c_str())*Gaudi::Units::m;
297  startY = atof(loadedDataFile[i][yStart].c_str())*Gaudi::Units::m;
298  endY = atof(loadedDataFile[i][yEnd].c_str())*Gaudi::Units::m;
299 
300  // translation of element
301  x = (startX + endX)/2;
302  y = (startY + endY)/2;
303  z = (startZ + endZ)/2;
304 
305  // absolute rotation of element
306  //rotationAngle_old = rotationAngle;
307  rotationAngle = atan2(endX - startX,endZ - startZ);
308 
309  // half-length of element
310  halfL = sqrt((endX - startX)*(endX - startX) + (endZ - startZ)*(endZ - startZ))/2;
311 
312  r = atof(loadedDataFile[i][xAperture].c_str())*Gaudi::Units::mm/2;
313 
314  // overlap correction
315  dL = abs(r*tan(rotationAngle))+0.2*Gaudi::Units::mm;
316 
317  // do not shorten magnetic volumes
318  if(loadedDataFile[i][name].find("Mag") != std::string::npos)
319  dL = 0;
320 
321  // construction of element
322 
323  // circular aperture
324  if(atoi(loadedDataFile[i][type].c_str()) == 0){
325  // envelope to allow tracking with G4TrackAction
326  if(loadedDataFile[i][name] == "VCDBP.7R1.B"){
327  GeoPhysVol* trackEnv = insertMagnetEnvelope(loadedDataFile[i][name], x, y, z, rotationAngle, 100*Gaudi::Units::mm, halfL, dL, fwrPhys);
328  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);
329  }
330  else
331  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);
332  }
333 
334  // special volumes
335  if(atoi(loadedDataFile[i][type].c_str()) == 4){
336  if(loadedDataFile[i][name] == "VCTYF.A4R1.X") // Trousers -- transition from 1 to 2 beampipes
337  insertTrousersElement(loadedDataFile[i][name], x, y, z, rotationAngle, fwrPhys);
338  else if(loadedDataFile[i][name] == "TCL.5R1.B1") // TCL5 collimator
340  else if(m_Config.buildTCL4 && loadedDataFile[i][name] == "VCDSS.4R1.B") // TCL4 collimator
342  else if(m_Config.buildTCL6 && loadedDataFile[i][name] == "TCL6") // TCL6 collimator
343  insertTCLElement(loadedDataFile[i][name], x, y, z, fwrPhys, (beam == 1 ? m_Config.TCL6JawDistB1O : m_Config.TCL6JawDistB2O), (beam == 1 ? m_Config.TCL6JawDistB1I : m_Config.TCL6JawDistB2I), true);
344 
345  // aproximate rest by circular apperture
346  else
347  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);
348  }
349 
350  GeoPhysVol* magEnv;
351 
352  // elliptical aperture
353  if(atoi(loadedDataFile[i][type].c_str()) == 1) {
354  magEnv = insertMagnetEnvelope(loadedDataFile[i][name], x, y, z, rotationAngle, 20*Gaudi::Units::cm, halfL, dL, fwrPhys);
355  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);
356  }
357 
358 
359  double magDiam = 19.4*Gaudi::Units::cm;
360  if(loadedDataFile[i][name].find("Mag") != std::string::npos)
361  magDiam= 19.4*Gaudi::Units::cm;
362  if(loadedDataFile[i][name] == "LQXAA.1R1MagQ1" || loadedDataFile[i][name] == "LQXAG.3R1MagQ3")
363  magDiam = 48*Gaudi::Units::cm;
364  if(loadedDataFile[i][name] == "LQXBA.2R1MagQ2a" || loadedDataFile[i][name] == "LQXBA.2R1MagQ2b")
365  magDiam = 52*Gaudi::Units::cm;
366  //else magDiam = std::max(atof(loadedDataFile[i][xAperture].c_str()), atof(loadedDataFile[i][yAperture].c_str()))+2*atof(loadedDataFile[i][tubeThickness].c_str());
367  //else magDiam = 19.4*Gaudi::Units::cm;
368 
369  // rectcircular aperture with flats in x
370  if(atoi(loadedDataFile[i][type].c_str()) == 2) {
371  magEnv = insertMagnetEnvelope(loadedDataFile[i][name], x, y, z, rotationAngle, magDiam, halfL, dL, fwrPhys);
372  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);
373  }
374 
375  // rectcircular aperture with flats in y
376  if(atoi(loadedDataFile[i][type].c_str()) == 3) {
377  magEnv = insertMagnetEnvelope(loadedDataFile[i][name], x, y, z, rotationAngle, magDiam, halfL, dL, fwrPhys);
378  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);
379  }
380  }
381  // ################ ELEMENTS - end ########################
382 }
383 
384 
386 {
388 
389  MsgStream LogStream(Athena::getMessageSvc(), "ForwardRegionGeoModel::create()");
390 
391  LogStream << MSG::INFO << "Constructing forward region model" << endmsg;
392 
393  DefineMaterials();
394 
395  // Load "geometry" files
396  std::vector<std::vector<std::string> > loadedDataFileR = this->loadDataFile((char*)"LSS1Rout.csv",11);
397  std::vector<std::vector<std::string> > loadedDataFileL = this->loadDataFile((char*)"LSS1Lout.csv",11);
398 
399  double startZ,endZ;
400 
401  if(m_Config.vp1Compatibility) startZ = 19.0*Gaudi::Units::m;
402  else startZ = 22.0*Gaudi::Units::m;
403  endZ = 268.904*Gaudi::Units::m;
404 
405  //rotationAngle_old = 0;
406 
407  // mother volume -- union of tubes, one for each side
408  //const GeoBox *fwrBox = new GeoBox(2*Gaudi::Units::m,0.5*Gaudi::Units::m,(endZ-startZ)/2);
409  const GeoTube *fwrTubeL = new GeoTube(0,2*Gaudi::Units::m,(endZ-startZ)/2);
410  GeoTube *fwrTubeR = new GeoTube(0,2*Gaudi::Units::m,(endZ-startZ)/2);
411  GeoTrf::Transform3D shiftL = GeoTrf::Translate3D(0,0,(endZ+startZ)/2);
412  GeoTrf::Transform3D shiftR = GeoTrf::Translate3D(0,0,-(endZ+startZ)/2);
413 
414  const GeoShapeShift& fwrTube0 = (*fwrTubeL)<<shiftL;
415  const GeoShapeUnion& fwrTube1 = fwrTube0.add((*fwrTubeR)<<shiftR);
416 
417  // cut out slots for ALFA
418  const GeoTube *alfa = new GeoTube(0, 2*Gaudi::Units::m, 500*Gaudi::Units::mm);
419  GeoTrf::Transform3D shiftAlfaL1 = GeoTrf::Translate3D(0,0,237388*Gaudi::Units::mm);
420  GeoTrf::Transform3D shiftAlfaR1 = GeoTrf::Translate3D(0,0,-237408*Gaudi::Units::mm);
421  GeoTrf::Transform3D shiftAlfaL2 = GeoTrf::Translate3D(0,0,(m_Config.ALFAInNewPosition ? m_Config.newPosB7L1 : 241528*Gaudi::Units::mm));
422  GeoTrf::Transform3D shiftAlfaR2 = GeoTrf::Translate3D(0,0,(m_Config.ALFAInNewPosition ? m_Config.newPosB7R1 :-241548*Gaudi::Units::mm));
423  const GeoShapeSubtraction& fwrTube2 = fwrTube1.subtract((*alfa)<<shiftAlfaL1).subtract((*alfa)<<shiftAlfaL2).subtract((*alfa)<<shiftAlfaR1).subtract((*alfa)<<shiftAlfaR2);
424 
425  // cut out slots for AFP
426  const GeoTube *afp = new GeoTube(0, 2.5*Gaudi::Units::m, 280*Gaudi::Units::mm);
427  const GeoTube *afp2 = new GeoTube(0, 2.5*Gaudi::Units::m, 580*Gaudi::Units::mm);
428  GeoTrf::Transform3D shiftAfpL1 = GeoTrf::Translate3D(0,0,m_Config.posAFPL1);
429  GeoTrf::Transform3D shiftAfpR1 = GeoTrf::Translate3D(0,0,m_Config.posAFPR1);
430  GeoTrf::Transform3D shiftAfpL2 = GeoTrf::Translate3D(0,0,m_Config.posAFPL2);
431  GeoTrf::Transform3D shiftAfpR2 = GeoTrf::Translate3D(0,0,m_Config.posAFPR2);
432  const GeoShapeSubtraction& fwrTube3 = fwrTube2.subtract((*afp)<<shiftAfpL1).subtract((*afp)<<shiftAfpR1).subtract((*afp2)<<shiftAfpL2).subtract((*afp2)<<shiftAfpR2);
433 
434  // cut out slots for ZDC
435  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);
436  GeoTrf::Transform3D shiftZdcL1 = GeoTrf::Translate3D(0,0, m_Config.posZDC1);
437  GeoTrf::Transform3D shiftZdcR1 = GeoTrf::Translate3D(0,0, m_Config.posZDC2);
438  const GeoShapeSubtraction& fwrTube = fwrTube3.subtract((*zdc)<<shiftZdcL1).subtract((*zdc)<<shiftZdcR1);
439 
440 
441  const GeoLogVol *fwrLog = new GeoLogVol("ForwardRegionGeoModel", &fwrTube, m_MapMaterials[std::string("std::Vacuum")]);
442  GeoPhysVol *fwrPhys = new GeoPhysVol(fwrLog);
443  GeoNameTag *tag = new GeoNameTag("ForwardRegionGeoModel");
444  world->add(tag);
445  world->add(fwrPhys);
446  m_detectorManager->addTreeTop(fwrPhys);
447 
448  constructElements(fwrPhys,loadedDataFileR,1);
449  constructElements(fwrPhys,loadedDataFileL,2);
450 
451  LogStream << MSG::INFO << "Forward region model succesfully constructed." << endmsg;
452 }
453 
455 {
456  return m_detectorManager;
457 }
458 
459 // Load data from file into 2D array of strings. Input is filename and wanted numbestd::stringof columns
460 std::vector<std::vector<std::string> > ForwardRegionGeoModelFactory::loadDataFile(char* fileName, int cols)
461 {
462  std::vector<std::vector<std::string> > loadedData;
463 
464  MsgStream LogStream(Athena::getMessageSvc(), "ForwardRegionGeoModel::loadDataFile()");
465 
466  std::ifstream file (fileName);
467  if(!file){
469  LogStream << MSG::DEBUG << "File " << fileName << " not found in run directory, trying to load it from DATAPATH" << endmsg;
470  file.open(datapath.c_str());
471  }
472 
473  if(!file)
474  LogStream << MSG::FATAL << "Unable to load " << fileName << endmsg;
475 
476  if(file.is_open())
477  {
478  std::vector<std::string> row (cols);
479  char c;
480 
481  while(file.get(c))
482  {
483  if(c != '@' && c != '#' && c != '*' && c != '$' && c != '%')
484  {
485  file.unget();
486  for(int i = 0; i<cols; i++) // load desired columns
487  {
488  file >> row[i];
489  }
490  loadedData.push_back(row); //store them
491  file.ignore(1024,'\n'); // discard rest of line
492  }
493  else
494  file.ignore(1024, '\n'); // discard commented lines
495  }
496  LogStream << MSG::INFO << "File " << fileName << " succesfully loaded." << endmsg;
497  file.close();
498  }
499  return loadedData;
500 }
_FWD_CONFIGURATION::TCL5JawDistB2I
double TCL5JawDistB2I
Definition: ForwardRegionGeoModelFactory.h:28
ForwardRegionGeoModelFactory::m_detectorManager
ForwardRegionGeoModelManager * m_detectorManager
Definition: ForwardRegionGeoModelFactory.h:108
ForwardRegionGeoModelFactory::getDetectorManager
virtual const ForwardRegionGeoModelManager * getDetectorManager() const
Definition: ForwardRegionGeoModelFactory.cxx:454
query_example.row
row
Definition: query_example.py:24
beamspotman.r
def r
Definition: beamspotman.py:676
_FWD_CONFIGURATION::posZDC2
double posZDC2
Definition: ForwardRegionGeoModelFactory.h:44
_FWD_CONFIGURATION::TCL6JawDistB2I
double TCL6JawDistB2I
Definition: ForwardRegionGeoModelFactory.h:29
PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:28
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
_FWD_CONFIGURATION::TCL6JawDistB2O
double TCL6JawDistB2O
Definition: ForwardRegionGeoModelFactory.h:32
ForwardRegionGeoModelManager
Definition: ForwardRegionGeoModelManager.h:10
ForwardRegionGeoModelFactory::insertYRecticircularElement
void insertYRecticircularElement(const std::string &name, double x, double y, double z, double rotationAngle, double xAperture, double yAperture, double halfL, double dL, double tubeThickness, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:206
ForwardRegionGeoModelFactory::num2str
std::string num2str(T)
Definition: ForwardRegionGeoModelFactory.cxx:215
_FWD_CONFIGURATION::newPosB7R1
double newPosB7R1
Definition: ForwardRegionGeoModelFactory.h:38
_FWD_CONFIGURATION::TCL5JawDistB1O
double TCL5JawDistB1O
Definition: ForwardRegionGeoModelFactory.h:25
JetTiledMap::W
@ W
Definition: TiledEtaPhiMap.h:44
DMTest::P
P_v1 P
Definition: P.h:23
_FWD_CONFIGURATION::TCL5JawDistB1I
double TCL5JawDistB1I
Definition: ForwardRegionGeoModelFactory.h:22
_FWD_CONFIGURATION::TCL4JawDistB2I
double TCL4JawDistB2I
Definition: ForwardRegionGeoModelFactory.h:27
DMTest::C
C_v1 C
Definition: C.h:26
_FWD_CONFIGURATION::posAFPL1
double posAFPL1
Definition: ForwardRegionGeoModelFactory.h:39
StoredMaterialManager::getElement
virtual const GeoElement * getElement(const std::string &name)=0
cm3
#define cm3
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
ForwardRegionGeoModelFactory::m_MapMaterials
std::map< std::string, const GeoMaterial * > m_MapMaterials
Definition: ForwardRegionGeoModelFactory.h:70
ForwardRegionGeoModelFactory::ForwardRegionGeoModelFactory
ForwardRegionGeoModelFactory(StoreGateSvc *pDetStore, const PFWD_CONFIGURATION pConfig)
Definition: ForwardRegionGeoModelFactory.cxx:76
python.SystemOfUnits.gram
int gram
Definition: SystemOfUnits.py:165
ForwardRegionGeoModelFactory::insertTCLElement
void insertTCLElement(const std::string &name, double x, double y, double z, GeoPhysVol *fwrPhys, double TCLJawDistO, double TCLJawDistI, bool tungstenInsteadOfCopper=false)
Definition: ForwardRegionGeoModelElements.cxx:393
x
#define x
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
ForwardRegionGeoModelFactory::constructElements
void constructElements(GeoPhysVol *fwrPhys, std::vector< std::vector< std::string > > loadedDataFile, int beam)
Definition: ForwardRegionGeoModelFactory.cxx:226
_FWD_CONFIGURATION::posAFPL2
double posAFPL2
Definition: ForwardRegionGeoModelFactory.h:40
ForwardRegionGeoModelFactory::insertTrousersElement
void insertTrousersElement(const std::string &name, double x, double y, double z, double rotationAngle, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:285
_FWD_CONFIGURATION::vp1Compatibility
bool vp1Compatibility
Definition: ForwardRegionGeoModelFactory.h:35
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
_FWD_CONFIGURATION::ALFAInNewPosition
bool ALFAInNewPosition
Definition: ForwardRegionGeoModelFactory.h:36
beamspotnt.cols
list cols
Definition: bin/beamspotnt.py:1114
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ForwardRegionGeoModelFactory::insertCircularElement
void insertCircularElement(const std::string &name, double x, double y, double z, double rotationAngle, double xAperture, double yAperture, double halfL, double dL, double tubeThickness, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:49
ForwardRegionGeoModelFactory::insertMagnetEnvelope
GeoPhysVol * insertMagnetEnvelope(const std::string &name, double x, double y, double z, double rotationAngle, double diameter, double halfL, double dL, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
python.html.AtlRunQueryDQSummary.datapath
datapath
Definition: AtlRunQueryDQSummary.py:1205
_FWD_CONFIGURATION::TCL4JawDistB1I
double TCL4JawDistB1I
Definition: ForwardRegionGeoModelFactory.h:21
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
_FWD_CONFIGURATION::buildTCL6
bool buildTCL6
Definition: ForwardRegionGeoModelFactory.h:34
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
_FWD_CONFIGURATION::posAFPR2
double posAFPR2
Definition: ForwardRegionGeoModelFactory.h:42
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
_FWD_CONFIGURATION::newPosB7L1
double newPosB7L1
Definition: ForwardRegionGeoModelFactory.h:37
file
TFile * file
Definition: tile_monitor.h:29
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
ForwardRegionGeoModelFactory::insertXRecticircularElement
void insertXRecticircularElement(const std::string &name, double x, double y, double z, double rotationAngle, double xAperture, double yAperture, double halfL, double dL, double tubeThickness, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:125
ForwardRegionGeoModelFactory::create
virtual void create(GeoPhysVol *world)
Definition: ForwardRegionGeoModelFactory.cxx:385
jobOptions.beam
beam
Definition: jobOptions.SuperChic_ALP2.py:16
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
ForwardRegionGeoModelFactory::loadDataFile
std::vector< std::vector< std::string > > loadDataFile(char *fileName, int cols)
Definition: ForwardRegionGeoModelFactory.cxx:460
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
PathResolver.h
_FWD_CONFIGURATION::TCL6JawDistB1O
double TCL6JawDistB1O
Definition: ForwardRegionGeoModelFactory.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
StoredMaterialManager.h
_FWD_CONFIGURATION::clear
void clear()
Definition: ForwardRegionGeoModelFactory.cxx:47
ForwardRegionGeoModelFactory::m_Config
FWD_CONFIGURATION m_Config
Definition: ForwardRegionGeoModelFactory.h:73
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
ForwardRegionGeoModelFactory::m_MagConfig
FWDMg_CONFIGURATION m_MagConfig
Definition: ForwardRegionGeoModelFactory.h:74
_FWD_CONFIGURATION::TCL6JawDistB1I
double TCL6JawDistB1I
Definition: ForwardRegionGeoModelFactory.h:23
ForwardRegionGeoModelFactory::m_properties
ToolHandle< IForwardRegionProperties > m_properties
Definition: ForwardRegionGeoModelFactory.h:76
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
_FWD_CONFIGURATION::posAFPR1
double posAFPR1
Definition: ForwardRegionGeoModelFactory.h:41
_FWD_CONFIGURATION::TCL5JawDistB2O
double TCL5JawDistB2O
Definition: ForwardRegionGeoModelFactory.h:31
_FWD_CONFIGURATION::posZDC1
double posZDC1
Definition: ForwardRegionGeoModelFactory.h:43
_FWD_CONFIGURATION::TCL4JawDistB1O
double TCL4JawDistB1O
Definition: ForwardRegionGeoModelFactory.h:24
y
#define y
ForwardRegionGeoModelFactory.h
ForwardRegionGeoModelFactory::m_detectorStore
StoreGateSvc * m_detectorStore
Definition: ForwardRegionGeoModelFactory.h:67
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ForwardRegionGeoModelFactory::insertEllipticalElement
void insertEllipticalElement(const std::string &name, double x, double y, double z, double rotationAngle, double xAperture, double yAperture, double halfL, double dL, double tubeThickness, GeoPhysVol *fwrPhys)
Definition: ForwardRegionGeoModelElements.cxx:82
ForwardRegionGeoModelFactory::sgn
int sgn(T val)
Definition: ForwardRegionGeoModelFactory.cxx:222
DEBUG
#define DEBUG
Definition: page_access.h:11
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
ForwardRegionGeoModelFactory::DefineMaterials
void DefineMaterials()
Definition: ForwardRegionGeoModelFactory.cxx:100
ForwardRegionGeoModelManager::addTreeTop
void addTreeTop(PVLink)
Definition: ForwardRegionGeoModelManager.cxx:27
mole
#define mole
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
ForwardRegionGeoModelFactory::~ForwardRegionGeoModelFactory
~ForwardRegionGeoModelFactory()
Definition: ForwardRegionGeoModelFactory.cxx:94
_FWD_CONFIGURATION::buildTCL4
bool buildTCL4
Definition: ForwardRegionGeoModelFactory.h:33
StoreGateSvc.h
python.compressB64.c
def c
Definition: compressB64.py:93
_FWD_CONFIGURATION
Definition: ForwardRegionGeoModelFactory.h:20
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
_FWD_CONFIGURATION::TCL4JawDistB2O
double TCL4JawDistB2O
Definition: ForwardRegionGeoModelFactory.h:30