ATLAS Offline Software
ToyDetectorFactory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ToyDetectorFactory.h"
6 #include "CentralScrutinizer.h"
7 
8 #ifndef BUILDVP1LIGHT
9  #include "StoreGate/StoreGateSvc.h"
10  #include "StoreGate/DataHandle.h"
12 #endif
13 
14 #include "GeoModelKernel/GeoDefinitions.h"
15 #include "GeoModelKernel/GeoMaterial.h"
16 #include "GeoModelKernel/GeoBox.h"
17 #include "GeoModelKernel/GeoTube.h"
18 #include "GeoModelKernel/GeoLogVol.h"
19 #include "GeoModelKernel/GeoNameTag.h"
20 #include "GeoModelKernel/GeoPhysVol.h"
21 #include "GeoModelKernel/GeoFullPhysVol.h"
22 #include "GeoModelKernel/GeoTransform.h"
23 #include "GeoModelKernel/GeoSerialDenominator.h"
24 #include "GeoModelKernel/GeoAlignableTransform.h"
25 #include "GeoModelKernel/GeoSerialTransformer.h"
26 
27 #include "GeoGenericFunctions/AbsFunction.h"
28 #include "GeoGenericFunctions/Variable.h"
29 #include "GeoGenericFunctions/Sin.h"
30 #include "GeoGenericFunctions/Cos.h"
31 
32 // System of units
33 #ifdef BUILDVP1LIGHT
34  #include "GeoModelKernel/Units.h"
35  #define SYSTEM_OF_UNITS GeoModelKernelUnits // --> 'GeoModelKernelUnits::cm'
36 #else
37  #include "GaudiKernel/SystemOfUnits.h"
38  #define SYSTEM_OF_UNITS Gaudi::Units // --> 'Gaudi::Units::cm'
39 #endif
40 
41 
42 
43 using namespace GeoGenfun;
44 using namespace GeoXF;
45 
46 
48  :m_detectorManager(NULL),
49  m_detectorStore(detStore)
50 {
51 }
52 
53 
55 {
56 
57 }
58 
59 
60 
61 //## Other Operations (implementation)
62 void ToyDetectorFactory::create(GeoPhysVol *world)
63 {
65 
66  #ifndef BUILDVP1LIGHT
67  StoredMaterialManager* materialManager = nullptr;
68  if (StatusCode::SUCCESS != m_detectorStore->retrieve(materialManager, std::string("MATERIALS"))) {
69  return;
70  }
71  #endif
72 
73  //-----------------------------------------------------------------------------------//
74  // Get the materials that we shall use. //
75  // ----------------------------------------------------------------------------------//
76 
77  #if defined BUILDVP1LIGHT
78  // Bogus densities.
79  double densityOfAir=0.1, densityOfPolystyrene=0.2;
80  const GeoMaterial *air = new GeoMaterial("Air Toy",densityOfAir);
81  const GeoMaterial *poly = new GeoMaterial("std::Polystyrene",densityOfPolystyrene);
82  #else
83  // Read from database.
84  const GeoMaterial *air = materialManager->getMaterial("std::Air");
85  const GeoMaterial *poly = materialManager->getMaterial("std::Polystyrene");
86  #endif
87 
88  //-----------------------------------------------------------------------------------//
89  // Next make the box that describes the shape of the toy volume: //
90  // //
91  const GeoBox *toyBox = new GeoBox(800*SYSTEM_OF_UNITS::cm,800*SYSTEM_OF_UNITS::cm, 1000*SYSTEM_OF_UNITS::cm); //
92  // //
93  // Bundle this with a material into a logical volume: //
94  // //
95  const GeoLogVol *toyLog = new GeoLogVol("ToyLog", toyBox, air); //
96  // //
97  // ..And create a physical volume: //
98  // //
99  GeoPhysVol *toyPhys = new GeoPhysVol(toyLog); //
100  // //
101  // Add this to the list of top level physical volumes: //
102  // //
103  m_detectorManager->addTreeTop(toyPhys); //
104  //-----------------------------------------------------------------------------------//
105 
106  //-----------------------------------------------------------------------------------//
107  // Daughters //
108  // //
109  // //
110  const GeoTube *ringTube = new GeoTube(500*SYSTEM_OF_UNITS::cm, 1000*SYSTEM_OF_UNITS::cm, 5.0*SYSTEM_OF_UNITS::cm); //
111  // //
112  // Bundle this with a material into a logical volume: //
113  // //
114  const GeoLogVol *ringLog = new GeoLogVol("RingLog", ringTube, air); //
115  // //
116  // Make 100 of these within the volume of the toy: //
117  // //
118  GeoSerialDenominator *ringName = new GeoSerialDenominator("RING"); //
119  toyPhys->add(ringName); //
120  for (int i=0;i<100;i++) { //
121  GeoFullPhysVol *ringPhys = new GeoFullPhysVol(ringLog); //
122  GeoAlignableTransform *xform = new GeoAlignableTransform(GeoTrf::TranslateZ3D((i-50)*20*SYSTEM_OF_UNITS::cm));
123  toyPhys->add(xform); //
124  toyPhys->add(ringPhys); //
126  } //
127  //-----------------------------------------------------------------------------------//
128 
129 
130  //-----------------------------------------------------------------------------------//
131  // Now, in addition to active daughters add some passive material. This is done //
132  // here using the "SerialTransformer," our way of parameterizing volumes. It //
133  // does not need to be done this way.. but we want to provide an example of //
134  // parametrizations in the Toy //
135  //-----------------------------------------------------------------------------------//
136 
137  GeoBox *sPass = new GeoBox(5.0*SYSTEM_OF_UNITS::cm, 30*SYSTEM_OF_UNITS::cm, 30*SYSTEM_OF_UNITS::cm);
138  GeoLogVol *lPass = new GeoLogVol("Passive", sPass, poly);
139  GeoPhysVol *pPass = new GeoPhysVol(lPass);
140 
141  GeoBox *sIPass = new GeoBox(4*SYSTEM_OF_UNITS::cm, 25*SYSTEM_OF_UNITS::cm, 25*SYSTEM_OF_UNITS::cm);
142  GeoLogVol *lIPass = new GeoLogVol("InnerPassive", sIPass, air);
143  GeoPhysVol *pIPass = new GeoPhysVol(lIPass);
144 
145  pPass->add(pIPass);
146 
147  const unsigned int NPLATES=100;
148  Variable i;
149  Sin sin;
150  GENFUNCTION f = 360*SYSTEM_OF_UNITS::deg/NPLATES*i;
151  GENFUNCTION g = sin(4*f);
152  GENFUNCTION h = -g;
153  TRANSFUNCTION t1 = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(1100*SYSTEM_OF_UNITS::cm)*Pow(GeoTrf::TranslateZ3D(800*SYSTEM_OF_UNITS::cm),g);
154  TRANSFUNCTION t2 = Pow(GeoTrf::RotateZ3D(1.0),f)*GeoTrf::TranslateX3D(1100*SYSTEM_OF_UNITS::cm)*Pow(GeoTrf::TranslateZ3D(800*SYSTEM_OF_UNITS::cm),h);
155 
156  //-----------------------------------------------------------------------------------//
157  // Inside, by the way, the serial transformer will evaluate the functions: //
158  // HepTransform3D xf = t1(i), for i=1,NPLATES.... //
159  //-----------------------------------------------------------------------------------//
160 
161  GeoSerialDenominator *pass1Name = new GeoSerialDenominator("PASSIVE-1-");
162  GeoSerialTransformer *s1 = new GeoSerialTransformer(pPass,&t1, NPLATES);
163  toyPhys->add(pass1Name);
164  toyPhys->add(s1);
165 
166  GeoSerialDenominator *pass2Name = new GeoSerialDenominator("PASSIVE-2-");
167  GeoSerialTransformer *s2 = new GeoSerialTransformer(pPass,&t2, NPLATES);
168  toyPhys->add(pass2Name);
169  toyPhys->add(s2);
170 
171 
172  //------------------------------------------------------------------------------------//
173  // Now insert all of this into the world... //
174  GeoNameTag *tag = new GeoNameTag("Toy"); //
175  world->add(tag); //
176  world->add(toyPhys); //
177  //------------------------------------------------------------------------------------//
178 }
179 
181 {
182  return m_detectorManager;
183 }
184 
185 
186 
187 
188 
ToyDetectorFactory::m_detectorStore
StoreGateSvc * m_detectorStore
Definition: ToyDetectorFactory.h:35
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
deg
#define deg
Definition: SbPolyhedron.cxx:17
ToyDetectorFactory::m_detectorManager
ToyDetectorManager * m_detectorManager
Definition: ToyDetectorFactory.h:33
ToyDetectorFactory::ToyDetectorFactory
ToyDetectorFactory(StoreGateSvc *pDetStore)
Definition: ToyDetectorFactory.cxx:47
DataHandle.h
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
h
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
Atlas.StoreGateSvc
StoreGateSvc
Definition: Atlas.UnixStandardJob.py:25
CentralScrutinizer.h
ToyDetectorFactory::getDetectorManager
virtual const ToyDetectorManager * getDetectorManager() const
Definition: ToyDetectorFactory.cxx:180
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
ToyDetectorFactory.h
StoredMaterialManager.h
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
ToyDetectorManager::addCentralScrutinizer
void addCentralScrutinizer(const CentralScrutinizer *)
Definition: ToyDetectorManager.cxx:58
GeoGenfun
Definition: ArrayFunction.cxx:7
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
ToyDetectorManager
Definition: ToyDetectorManager.h:13
CentralScrutinizer
Definition: CentralScrutinizer.h:14
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
StoreGateSvc.h
ToyDetectorManager::addTreeTop
void addTreeTop(PVLink)
Definition: ToyDetectorManager.cxx:53
ToyDetectorFactory::create
virtual void create(GeoPhysVol *world)
Definition: ToyDetectorFactory.cxx:62
ToyDetectorFactory::~ToyDetectorFactory
~ToyDetectorFactory()
Definition: ToyDetectorFactory.cxx:54