ATLAS Offline Software
Loading...
Searching...
No Matches
BCM_Builder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include "GeoModelKernel/GeoFullPhysVol.h"
10#include "GeoModelKernel/GeoTransform.h"
11#include "GeoModelKernel/GeoNameTag.h"
12#include "GeoModelKernel/GeoIdentifierTag.h"
13
16
20
21#include "GaudiKernel/SystemOfUnits.h"
22
23//================ Constructor =================================================
24
26 const std::string& n,
27 const IInterface* p )
28 : base_class(t,n,p)
29{
30
31 //default settings
32 // TRANS_X TRANS_Y TRANS_Z ROT_X ROT_Y ROT_Z DIMENSION_Z DIAM_TRANS_Y DIAM_TRANS_Z DIAM_DIAM_X DIAM_DIAM_Y DIAM_DIAM_Z LAMEL_OFFSET_H LAMEL_OFFSET_I LAMEL_OFFSET_J
33 m_module0.push_back(95.744); m_module0.push_back(0); m_module0.push_back(1882.4); m_module0.push_back(0); m_module0.push_back(45); m_module0.push_back(0); m_module0.push_back(0.4); m_module0.push_back(0); m_module0.push_back(-59.785); m_module0.push_back(0.2); m_module0.push_back(0); m_module0.push_back(-0.4); m_module0.push_back(34.860); m_module0.push_back(29.509); m_module0.push_back(20.205); //F410
34 m_moduleI.push_back(0); m_moduleI.push_back(95.744); m_moduleI.push_back(1882.4); m_moduleI.push_back(0); m_moduleI.push_back(45); m_moduleI.push_back(90); m_moduleI.push_back(0.4); m_moduleI.push_back(0); m_moduleI.push_back(-59.785); m_moduleI.push_back(0.2); m_moduleI.push_back(0); m_moduleI.push_back(-0.4); m_moduleI.push_back(34.860); m_moduleI.push_back(29.509); m_moduleI.push_back(20.205); //F405
35 m_moduleII.push_back(-95.744); m_moduleII.push_back(0); m_moduleII.push_back(1882.4); m_moduleII.push_back(0); m_moduleII.push_back(45); m_moduleII.push_back(180); m_moduleII.push_back(0.4); m_moduleII.push_back(0); m_moduleII.push_back(-59.785); m_moduleII.push_back(0.2); m_moduleII.push_back(0); m_moduleII.push_back(-0.4); m_moduleII.push_back(34.860); m_moduleII.push_back(29.509); m_moduleII.push_back(20.205); //F413
36 m_moduleIII.push_back(0); m_moduleIII.push_back(-95.744); m_moduleIII.push_back(1882.4); m_moduleIII.push_back(0); m_moduleIII.push_back(45); m_moduleIII.push_back(270); m_moduleIII.push_back(0.4); m_moduleIII.push_back(0); m_moduleIII.push_back(-59.785); m_moduleIII.push_back(0.2); m_moduleIII.push_back(0); m_moduleIII.push_back(-0.4); m_moduleIII.push_back(34.860); m_moduleIII.push_back(29.509); m_moduleIII.push_back(20.205); //F404
37 m_moduleIV.push_back(95.744); m_moduleIV.push_back(0); m_moduleIV.push_back(-1882.4); m_moduleIV.push_back(180); m_moduleIV.push_back(-45); m_moduleIV.push_back(0); m_moduleIV.push_back(1.4); m_moduleIV.push_back(0); m_moduleIV.push_back(-59.785); m_moduleIV.push_back(0.2); m_moduleIV.push_back(0); m_moduleIV.push_back(-0.4); m_moduleIV.push_back(34.860); m_moduleIV.push_back(29.509); m_moduleIV.push_back(20.205); //F424
38 m_moduleV.push_back(0); m_moduleV.push_back(95.744); m_moduleV.push_back(-1882.4); m_moduleV.push_back(180); m_moduleV.push_back(-45); m_moduleV.push_back(90); m_moduleV.push_back(1.4); m_moduleV.push_back(0); m_moduleV.push_back(-59.785); m_moduleV.push_back(0.2); m_moduleV.push_back(0); m_moduleV.push_back(-0.4); m_moduleV.push_back(34.860); m_moduleV.push_back(29.509); m_moduleV.push_back(20.205); //F420
39 m_moduleVI.push_back(-95.744); m_moduleVI.push_back(0); m_moduleVI.push_back(-1882.4); m_moduleVI.push_back(180); m_moduleVI.push_back(-45); m_moduleVI.push_back(180); m_moduleVI.push_back(1.4); m_moduleVI.push_back(0); m_moduleVI.push_back(-59.785); m_moduleVI.push_back(0.2); m_moduleVI.push_back(0); m_moduleVI.push_back(-0.4); m_moduleVI.push_back(34.860); m_moduleVI.push_back(29.509); m_moduleVI.push_back(20.205); //F422
40 m_moduleVII.push_back(0); m_moduleVII.push_back(-95.744); m_moduleVII.push_back(-1882.4); m_moduleVII.push_back(180); m_moduleVII.push_back(-45); m_moduleVII.push_back(270); m_moduleVII.push_back(0.4); m_moduleVII.push_back(0); m_moduleVII.push_back(-59.785); m_moduleVII.push_back(0.2); m_moduleVII.push_back(0); m_moduleVII.push_back(-0.4); m_moduleVII.push_back(34.860); m_moduleVII.push_back(29.509); m_moduleVII.push_back(20.205); //F408
41
42 // template for property decalration
43 declareProperty("Modul0", m_module0);
44 declareProperty("ModulI", m_moduleI);
45 declareProperty("ModulII", m_moduleII);
46 declareProperty("ModulIII", m_moduleIII);
47 declareProperty("ModulIV", m_moduleIV);
48 declareProperty("ModulV", m_moduleV);
49 declareProperty("ModulVI", m_moduleVI);
50 declareProperty("ModulVII", m_moduleVII);
51 declareProperty("ModulesOn", m_moduleon=255);
52 declareProperty("BCMon", m_bcmon=true);
53 declareProperty("DBparameters", m_BDparameters=true);
54}
55
56//================ Initialisation =================================================
57
59{
60
61 StatusCode sc = AthAlgTool::initialize();
62 if (sc.isFailure()) return sc;
63
64 ATH_MSG_INFO("BCMBuilder initialize() successful in " << name());
65 return StatusCode::SUCCESS;
66}
67
68//================ Finalisation =================================================
69
71{
72 StatusCode sc = AthAlgTool::finalize();
73 return sc;
74}
75
76//================ Actual Work =================================================
77
78StatusCode InDetDD::BCM_Builder::build(GeoVPhysVol* pv)
79{
80 if(!m_bcmon) {
81 ATH_MSG_INFO("BCM disabled.");
82 return StatusCode::SUCCESS;
83 }
84
85 // Unfortunately add is not part of the abstract interface of GeoVPhysVol so we have to dynamic cast
86 // to the concrete class.
87 GeoFullPhysVol* Phys = dynamic_cast<GeoFullPhysVol *>(pv);
88 if (!Phys) {
89 ATH_MSG_ERROR("Parent volume is not a GeoFullPhysVol as expected.");
90 return StatusCode::FAILURE;
91 }
92
93 StoredMaterialManager * materialManager{nullptr};
94 ATH_CHECK(detStore()->retrieve(materialManager, std::string("MATERIALS")));
95
96 //create geometry manager
97 std::unique_ptr<BCM_GeometryManager> manager = std::make_unique<BCM_GeometryManager>();
98
99 StatusCode sc;
100
102 {
103 DecodeVersionKey versionKey("InnerDetector");
104
105 // Issue error if AUTO.
106 if (versionKey.tag() == "AUTO") {
107 ATH_MSG_ERROR("AUTO Atlas version. Please select a version.");
108 return StatusCode::FAILURE;
109 }
110
111 ATH_MSG_INFO("Building BCM with Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node());
112 SmartIF<IRDBAccessSvc> accessSvc{Gaudi::svcLocator()->service("RDBAccessSvc")};
113 ATH_CHECK(accessSvc.isValid());
114
115 // Print the BCM version tag:
116 std::string BCMVersionTag;
117 BCMVersionTag = accessSvc->getChildTag("BCM", versionKey.tag(), versionKey.node());
118 ATH_MSG_INFO("BCM Version: " << BCMVersionTag);
119
120 // Check if version is empty. If so, then the BCM cannot be built. This may or may not be intentional. We just issue an INFO message.
121 if (BCMVersionTag.empty()) {
122 ATH_MSG_INFO("No BCM Version. BCM will not be built.");
123 return StatusCode::SUCCESS;
124 }
125
126 IRDBRecordset_ptr DBmodul = accessSvc->getRecordsetPtr("BCMModule", versionKey.tag(), versionKey.node());
127 ATH_MSG_DEBUG(" --> Number of records fetched = " << DBmodul->size());
128
129 unsigned int ind;
130 long moduleNo;
131
132 for(ind = 0; ind < DBmodul->size(); ind++) {
133 const IRDBRecord* rec = (*DBmodul)[ind];
134 moduleNo = rec->getLong("MODULE_ID");
135
136 //check if this module is suposed to be builded
137 unsigned int mask = (1 << moduleNo);
138 if((mask & m_moduleon) != mask) {
139 //this module is not sopoused to be built
140 continue;
141 }
142
143 std::vector<double> module_property;
144 module_property.push_back(rec->getFloat("TRANS_X"));
145 module_property.push_back(rec->getFloat("TRANS_Y"));
146 module_property.push_back(rec->getFloat("TRANS_Z"));
147 module_property.push_back(rec->getFloat("ROT_X"));
148 module_property.push_back(rec->getFloat("ROT_Y"));
149 module_property.push_back(rec->getFloat("ROT_Z"));
150 module_property.push_back(rec->getFloat("DIMESION_Z"));
151 module_property.push_back(rec->getFloat("DIAM_TRANS_Y"));
152 module_property.push_back(rec->getFloat("DIAM_TRANS_Z"));
153 module_property.push_back(rec->getFloat("DIAM_DIAM_X"));
154 module_property.push_back(rec->getFloat("DIAM_DAIM_Y"));
155 module_property.push_back(rec->getFloat("DIAM_DIAM_Z"));
156 module_property.push_back(rec->getFloat("OFF_H"));
157 module_property.push_back(rec->getFloat("OFF_I"));
158 module_property.push_back(rec->getFloat("OFF_J"));
159
160 //set the BCM_GeometryManeger
161 manager->ModuleOn(moduleNo);
162 manager->Module(moduleNo)->Set(moduleNo, &module_property);
163 }
164 ATH_MSG_DEBUG(" --> Number succesfully read from DB");
165 }
166 else
167 {
168 //parameters via jobOptions
169 int moduleNo;
170 const std::vector<double>* module_property = nullptr;
171 for(moduleNo = 0; moduleNo < 8; moduleNo++)
172 {
173 unsigned int mask = (1 << moduleNo);
174 if((mask & m_moduleon) != mask)
175 {
176 //this module is not sopoused to be built
177 continue;
178 }
179 if(moduleNo == 0) module_property = &m_module0;
180 else if(moduleNo == 1) module_property = &m_moduleI;
181 else if(moduleNo == 2) module_property = &m_moduleII;
182 else if(moduleNo == 3) module_property = &m_moduleIII;
183 else if(moduleNo == 4) module_property = &m_moduleIV;
184 else if(moduleNo == 5) module_property = &m_moduleV;
185 else if(moduleNo == 6) module_property = &m_moduleVI;
186 else if(moduleNo == 7) module_property = &m_moduleVII;
187
188 //set the BCM_GeometryManeger
189 manager->ModuleOn(moduleNo);
190 if (module_property){
191 manager->Module(moduleNo)->Set(moduleNo, module_property);
192 } else {
193 ATH_MSG_ERROR("module_property pointer is null in BCM_Builder.cxx");
194 }
195 }
196 }
197
198 //we are now adding eight BCM modules
199 BCM_Module bcm;
200
201 for(int i=0; i<8; i++)
202 {
203 //see if this module is to be built
204 if(!(manager->IsModuleOn(i)))
205 continue;
206
207 //the module should be build
208 BCM_ModuleParameters* parameters = manager->Module(i);
209
210 //setting transformation
211 GeoTrf::Translation3D pos(parameters->Position_X(), parameters->Position_Y(), parameters->Position_Z());
212 GeoTrf::Transform3D rm = GeoTrf::RotateZ3D(parameters->Rotation_Z()*Gaudi::Units::deg)
213 * GeoTrf::RotateY3D(parameters->Rotation_Y()*Gaudi::Units::deg)
214 * GeoTrf::RotateX3D(parameters->Rotation_X()*Gaudi::Units::deg)
215 * GeoTrf::RotateZ3D(-90.*Gaudi::Units::deg)
216 * GeoTrf::RotateY3D(-90.*Gaudi::Units::deg);
217 GeoIntrusivePtr<GeoTransform> xform{new GeoTransform(GeoTrf::Transform3D(pos*rm))};
218 ATH_MSG_DEBUG(" --> Module " << i << " build!");
219
220 //building module
221 int k=i+951;
222
223 GeoIntrusivePtr<GeoNameTag> tag{new GeoNameTag("BCM Module")};
224 if (materialManager){
225 GeoVPhysVol* bcmModPhys = bcm.Build(materialManager, parameters, (msgLvl(MSG::INFO) ? &msg(MSG::INFO) : nullptr));
226 Phys->add(tag);
227 Phys->add(new GeoIdentifierTag(k));
228 Phys->add(xform);
229 Phys->add(bcmModPhys);
230 }
231 }
232
233 ATH_MSG_DEBUG("Registering BCM_GeometryManager.");
234 ATH_CHECK(detStore()->record(std::move(manager), "BCMParameters"));
235
236 return StatusCode::SUCCESS;
237}
238
239
240// Register callback function on ConDB object
241// Empty for now
243{
244 return StatusCode::SUCCESS;
245}
246
247// Callback function itself
248// Empty for now
250{
251 // Return Failure since no function has been registered
252 return StatusCode::FAILURE;
253}
254//============================================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define IOVSVC_CALLBACK_ARGS
short hand for IOVSvc call back argument list, to be used when no access to formal arguments is neede...
Definition IOVSvcDefs.h:24
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
static Double_t sc
Beam Condition Monitor module parameters.
Beam Condition Monitor module builder.
Definition BCM_Module.h:25
GeoPhysVol * Build(StoredMaterialManager *mat_mgr, const BCM_ModuleParameters *parameters, MsgStream *msg)
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual long getLong(const std::string &fieldName) const =0
Get long field value.
virtual float getFloat(const std::string &fieldName) const =0
Get float field value.
virtual unsigned int size() const =0
std::vector< double > m_moduleIV
Definition BCM_Builder.h:54
std::vector< double > m_module0
member variables for algorithm properties:
Definition BCM_Builder.h:50
std::vector< double > m_moduleVI
Definition BCM_Builder.h:56
unsigned int m_moduleon
Definition BCM_Builder.h:58
std::vector< double > m_moduleV
Definition BCM_Builder.h:55
std::vector< double > m_moduleII
Definition BCM_Builder.h:52
BCM_Builder(const std::string &, const std::string &, const IInterface *)
virtual StatusCode build(GeoVPhysVol *parent) override
build the BCM geometry
std::vector< double > m_moduleIII
Definition BCM_Builder.h:53
std::vector< double > m_moduleI
Definition BCM_Builder.h:51
std::vector< double > m_moduleVII
Definition BCM_Builder.h:57
virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override
virtual StatusCode registerCallback(StoreGateSvc *detStore) override
For alignment.
virtual StatusCode finalize() override
standard Athena-Algorithm method
virtual StatusCode initialize() override
standard Athena-Algorithm method
The Athena Transient Store API.
This class holds one or more material managers and makes them storeable, under StoreGate.
MsgStream & msg
Definition testRead.cxx:32