ATLAS Offline Software
BLM_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 
11 
12 #include "GeoModelKernel/GeoNameTag.h"
13 #include "GeoModelKernel/GeoIdentifierTag.h"
14 #include "GeoModelKernel/GeoTransform.h"
15 #include "GeoModelKernel/GeoVPhysVol.h"
16 #include "GeoModelKernel/GeoPhysVol.h"
17 
18 #include "GeoModelKernel/GeoFullPhysVol.h"
19 
23 
24 #include "GaudiKernel/SystemOfUnits.h"
25 
26 //================ Constructor =================================================
27 
29  const std::string& n,
30  const IInterface* p )
31  :
32  base_class(t,n,p)
33 {
34  //default settings
35  // Z R PHI ROT_X ROT_Y ROT_Z DIAM_TRANS_X DIAM_TRANS_Y DIAM_TRANS_Z
36  m_module0.push_back(3383.5); m_module0.push_back(62.825); m_module0.push_back(17); m_module0.push_back(180); m_module0.push_back(0); m_module0.push_back(287); m_module0.push_back(0); m_module0.push_back(0); m_module0.push_back(0);
37  m_moduleI.push_back(3383.5); m_moduleI.push_back(62.825); m_moduleI.push_back(45); m_moduleI.push_back(180); m_moduleI.push_back(0); m_moduleI.push_back(315); m_moduleI.push_back(0); m_moduleI.push_back(0); m_moduleI.push_back(0);
38  m_moduleII.push_back(3383.5); m_moduleII.push_back(62.825); m_moduleII.push_back(73); m_moduleII.push_back(180); m_moduleII.push_back(0); m_moduleII.push_back(343); m_moduleII.push_back(0); m_moduleII.push_back(0); m_moduleII.push_back(0);
39  m_moduleIII.push_back(3383.5); m_moduleIII.push_back(62.825); m_moduleIII.push_back(197); m_moduleIII.push_back(180); m_moduleIII.push_back(0); m_moduleIII.push_back(107); m_moduleIII.push_back(0); m_moduleIII.push_back(0); m_moduleIII.push_back(0);
40  m_moduleIV.push_back(3383.5); m_moduleIV.push_back(62.825); m_moduleIV.push_back(225); m_moduleIV.push_back(180); m_moduleIV.push_back(0); m_moduleIV.push_back(135); m_moduleIV.push_back(0); m_moduleIV.push_back(0); m_moduleIV.push_back(0);
41  m_moduleV.push_back(3383.5); m_moduleV.push_back(62.825); m_moduleV.push_back(253); m_moduleV.push_back(180); m_moduleV.push_back(0); m_moduleV.push_back(163); m_moduleV.push_back(0); m_moduleV.push_back(0); m_moduleV.push_back(0);
42  m_moduleVI.push_back(-3383.5); m_moduleVI.push_back(62.825); m_moduleVI.push_back(17); m_moduleVI.push_back(0); m_moduleVI.push_back(0); m_moduleVI.push_back(107); m_moduleVI.push_back(0); m_moduleVI.push_back(0); m_moduleVI.push_back(0);
43  m_moduleVII.push_back(-3383.5); m_moduleVII.push_back(62.825); m_moduleVII.push_back(45); m_moduleVII.push_back(0); m_moduleVII.push_back(0); m_moduleVII.push_back(135); m_moduleVII.push_back(0); m_moduleVII.push_back(0); m_moduleVII.push_back(0);
44  m_moduleVIII.push_back(-3383.5); m_moduleVIII.push_back(62.825); m_moduleVIII.push_back(73); m_moduleVIII.push_back(0); m_moduleVIII.push_back(0); m_moduleVIII.push_back(163); m_moduleVIII.push_back(0); m_moduleVIII.push_back(0); m_moduleVIII.push_back(0);
45  m_moduleIX.push_back(-3383.5); m_moduleIX.push_back(62.825); m_moduleIX.push_back(197); m_moduleIX.push_back(0); m_moduleIX.push_back(0); m_moduleIX.push_back(287); m_moduleIX.push_back(0); m_moduleIX.push_back(0); m_moduleIX.push_back(0);
46  m_moduleX.push_back(-3383.5); m_moduleX.push_back(62.825); m_moduleX.push_back(225); m_moduleX.push_back(0); m_moduleX.push_back(0); m_moduleX.push_back(315); m_moduleX.push_back(0); m_moduleX.push_back(0); m_moduleX.push_back(0);
47  m_moduleXI.push_back(-3383.5); m_moduleXI.push_back(62.825); m_moduleXI.push_back(253); m_moduleXI.push_back(0); m_moduleXI.push_back(0); m_moduleXI.push_back(343); m_moduleXI.push_back(0); m_moduleXI.push_back(0); m_moduleXI.push_back(0);
48 
49  // template for property declaration
50  declareProperty("Modul0", m_module0);
51  declareProperty("ModulI", m_moduleI);
52  declareProperty("ModulII", m_moduleII);
53  declareProperty("ModulIII", m_moduleIII);
54  declareProperty("ModulIV", m_moduleIV);
55  declareProperty("ModulV", m_moduleV);
56  declareProperty("ModulVI", m_moduleVI);
57  declareProperty("ModulVII", m_moduleVII);
58  declareProperty("ModulVIII", m_moduleVIII);
59  declareProperty("ModulIX", m_moduleIX);
60  declareProperty("ModulX", m_moduleX);
61  declareProperty("ModulXI", m_moduleXI);
62  declareProperty("ModulesOn", m_moduleon=0xFFFF);
63  declareProperty("BLMon", m_blmon=true);
64  declareProperty("DBparameters", m_BDparameters=true);
65 }
66 
67 //================ Initialisation =================================================
68 
70 {
71 
73  if (sc.isFailure()) return sc;
74 
75  ATH_MSG_INFO("BLMBuilder initialize() successful in " << name());
76  return StatusCode::SUCCESS;
77 }
78 
79 //================ Finalisation =================================================
80 
82 {
84  return sc;
85 }
86 
87 //================ Actual Work =================================================
88 
90 {
91  if(!m_blmon) {
92  ATH_MSG_INFO("BLM disabled.");
93  return StatusCode::SUCCESS;
94  }
95 
96  // Unfortunately add is not part of the abstract interface of GeoVPhysVol so we have to dynamic cast
97  // to the concrete class.
98  GeoFullPhysVol* Phys = dynamic_cast<GeoFullPhysVol *>(pv);
99  if (!Phys) {
100  ATH_MSG_ERROR("Parent volume is not a GeoFullPhysVol as expected.");
101  return StatusCode::FAILURE;
102  }
103 
104 // ATH_MSG_INFO("BLMBuilder building..."); //commented out by D.Dobos on request by M.Elsing
105 
106  StoredMaterialManager * materialManager;
107  if (StatusCode::SUCCESS != detStore()->retrieve(materialManager, std::string("MATERIALS"))) {
108  ATH_MSG_ERROR("Failed to retrieve Material Manager");
109  return StatusCode::FAILURE;
110  }
111 
112  //create geometry manager
114 
115  StatusCode sc;
116  if(m_BDparameters)
117  {
118  DecodeVersionKey versionKey("InnerDetector");
119 
120  // Issue error if AUTO.
121  if (versionKey.tag() == "AUTO")
122  {
123  ATH_MSG_ERROR("AUTO Atlas version. Please select a version.");
124  }
125 
126  ATH_MSG_INFO("Building BLM with Version Tag: "<< versionKey.tag() << " at Node: " << versionKey.node());
127 
128  IRDBAccessSvc *accessSvc;
129  sc = service("RDBAccessSvc",accessSvc);
130  if (sc.isFailure())
131  {
132  ATH_MSG_FATAL("Could not locate RDBAccessSvc");
133  delete manager;
134  return StatusCode::FAILURE;
135  }
136 
137  // Print the BLM version tag:
138  std::string BLMVersionTag;
139  BLMVersionTag = accessSvc->getChildTag("BLM", versionKey.tag(), versionKey.node());
140  ATH_MSG_INFO("BLM Version: " << BLMVersionTag);
141 
142  // Check if version is empty. If so, then the BLM cannot be built. This may or may not be intentional. We just issue an INFO message.
143  if (BLMVersionTag.empty())
144  {
145  ATH_MSG_INFO("No BLM Version. BLM will not be built.");
146  delete manager;
147  return StatusCode::SUCCESS;
148  }
149 
150  IRDBRecordset_ptr DBmodul = accessSvc->getRecordsetPtr("BLMModule", versionKey.tag(), versionKey.node());
151  //DBmodul = accessSvc->getRecordset("BLMModule", "InnerDetector-DC3-Dev", "InnerDetector");
152 
153  ATH_MSG_DEBUG(" --> Number of records fetched = " << DBmodul->size());
154 
155  //loop over all the records and putting them in module_property
156 
157  unsigned int ind;
158  long moduleNo;
159  //std::vector<double>* module_property = NULL;
160  for(ind = 0; ind < DBmodul->size(); ind++)
161  {
162  const IRDBRecord* rec = (*DBmodul)[ind];
163  //temp
164  moduleNo = rec->getLong("MODULE_ID");
165  //check if this module is suposed to be builded
166 
167  unsigned int mask = (1 << moduleNo);
168  if((mask & m_moduleon) != mask)
169  {
170  //this module is not sopoused to be built
171  continue;
172  }
173 
174  std::vector<double> module_property;
175  module_property.push_back(rec->getFloat("Z"));
176  module_property.push_back(rec->getFloat("R"));
177  module_property.push_back(rec->getFloat("PHI"));
178  module_property.push_back(rec->getFloat("ROT_X"));
179  module_property.push_back(rec->getFloat("ROT_Y"));
180  module_property.push_back(rec->getFloat("ROT_Z"));
181  module_property.push_back(rec->getFloat("DIAM_X"));
182  module_property.push_back(rec->getFloat("DIAM_Y"));
183  module_property.push_back(rec->getFloat("DIAM_Z"));
184 
185  //set the BCM_GeometryManeger
186  manager->ModuleOn(moduleNo);
187  manager->Module(moduleNo)->Set(moduleNo, &module_property);
188  }
189  ATH_MSG_DEBUG(" --> Number succesfully read from DB");
190  }
191  else
192  {
193  ATH_MSG_DEBUG(" --> BLM parameters via jobOptions or default");
194  //parameters via jobOptions
195  int moduleNo;
196  const std::vector<double>* module_property = nullptr;
197  for(moduleNo = 0; moduleNo < 12; moduleNo++)
198  {
199  unsigned int mask = (1 << moduleNo);
200  if((mask & m_moduleon) != mask)
201  {
202  //this module is not sopoused to be built
203  continue;
204  }
205  if(moduleNo == 0) module_property = &m_module0;
206  else if(moduleNo == 1) module_property = &m_moduleI;
207  else if(moduleNo == 2) module_property = &m_moduleII;
208  else if(moduleNo == 3) module_property = &m_moduleIII;
209  else if(moduleNo == 4) module_property = &m_moduleIV;
210  else if(moduleNo == 5) module_property = &m_moduleV;
211  else if(moduleNo == 6) module_property = &m_moduleVI;
212  else if(moduleNo == 7) module_property = &m_moduleVII;
213  else if(moduleNo == 8) module_property = &m_moduleVIII;
214  else if(moduleNo == 9) module_property = &m_moduleIX;
215  else if(moduleNo == 10) module_property = &m_moduleX;
216  else if(moduleNo == 11) module_property = &m_moduleXI;
217 
218  //set the BLM_GeometryManeger
219  manager->ModuleOn(moduleNo);
220  if (module_property){
221  manager->Module(moduleNo)->Set(moduleNo, module_property);
222  } else {
223  ATH_MSG_ERROR("module_property is null in BLM_Builder.cxx");
224  }
225  }
226  }
227 
228  //we are now adding eight BLM modules
229  BLM_Module blm;
230 
231  for(int i=0; i<12; i++)
232  {
233  //see if this module is to be built
234  if(!(manager->IsModuleOn(i)))
235  continue;
236 
237  //the module should be build
239 
240  //setting transformation
242  GeoTrf::Transform3D rm = GeoTrf::RotateZ3D(parameters->Rotation_Z()*Gaudi::Units::deg)
243  * GeoTrf::RotateY3D(parameters->Rotation_Y()*Gaudi::Units::deg)
244  * GeoTrf::RotateX3D(parameters->Rotation_X()*Gaudi::Units::deg);
245  GeoIntrusivePtr<GeoTransform> xform{new GeoTransform(GeoTrf::Transform3D(pos*rm))};
246  //building module
247  int k=i+222;
248 
249  GeoIntrusivePtr<GeoNameTag> tag{new GeoNameTag("BLM Module")};
250  if (materialManager){
251  GeoVPhysVol* blmModPhys = blm.Build(materialManager, parameters, (msgLvl(MSG::INFO) ? &msg(MSG::INFO) : nullptr));
252  Phys->add(tag);
253  Phys->add(new GeoIdentifierTag(k));
254  Phys->add(xform);
255  Phys->add(blmModPhys);
256  ATH_MSG_DEBUG(" --> BUILD MODULE: " << i);
257  }
258  }
259 
260  //save Geometry_manager in storegate
261  ATH_MSG_DEBUG("Registering BLM_GeometryManager.");
262  sc = detStore()->record(manager, "BLMParameters");
263 
264  if (sc.isFailure())
265  {
266  ATH_MSG_INFO("Could not register BLM_GeometryManager");
267  return StatusCode::FAILURE;
268  }
269  return StatusCode::SUCCESS;
270 }
271 
272 // Register callback function on ConDB object
273 // Empty for now
275 {
276  return StatusCode::SUCCESS;
277 }
278 
279 // Callback function itself
280 // Empty for now
282 {
283  // Return Failure since no function has been registered
284  return StatusCode::FAILURE;
285 }
286 
287 //============================================================================================
288 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDetDD::BLM_Builder::BLM_Builder
BLM_Builder(const std::string &, const std::string &, const IInterface *)
Definition: BLM_Builder.cxx:28
InDetDD::BLM_Builder::m_moduleIX
std::vector< double > m_moduleIX
Definition: BLM_Builder.h:61
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDetDD::BLM_Builder::m_moduleV
std::vector< double > m_moduleV
Definition: BLM_Builder.h:57
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IRDBAccessSvc::getRecordsetPtr
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
InDetDD::BLM_Builder::registerCallback
virtual StatusCode registerCallback(StoreGateSvc *detStore)
For alignment.
Definition: BLM_Builder.cxx:274
initialize
void initialize()
Definition: run_EoverP.cxx:894
InDetDD::BLM_Builder::m_moduleXI
std::vector< double > m_moduleXI
Definition: BLM_Builder.h:63
InDetDD::BLM_Builder::m_moduleVII
std::vector< double > m_moduleVII
Definition: BLM_Builder.h:59
InDetDD::BLM_Builder::m_moduleon
unsigned int m_moduleon
Definition: BLM_Builder.h:64
deg
#define deg
Definition: SbPolyhedron.cxx:17
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:99
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
InDetDD::BLM_Builder::m_module0
std::vector< double > m_module0
member variables for algorithm properties:
Definition: BLM_Builder.h:52
IOVSVC_CALLBACK_ARGS
#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
InDetDD::BLM_Builder::build
virtual StatusCode build(GeoVPhysVol *parent)
build the BCM geometry
Definition: BLM_Builder.cxx:89
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDetDD::BLM_Builder::m_moduleVI
std::vector< double > m_moduleVI
Definition: BLM_Builder.h:58
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IRDBAccessSvc::getChildTag
virtual std::string getChildTag(const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName="ATLASDD")=0
Gets the tag name for the node by giving its parent node tag.
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:45
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetDD::BLM_Builder::initialize
virtual StatusCode initialize()
standard Athena-Algorithm method
Definition: BLM_Builder.cxx:69
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:93
IRDBRecord::getLong
virtual long getLong(const std::string &fieldName) const =0
Get long field value.
BLM_GeometryManager.h
BLM_ModuleParameters
Definition: BLM_ModuleParameters.h:20
InDetDD::BLM_Builder::m_moduleVIII
std::vector< double > m_moduleVIII
Definition: BLM_Builder.h:60
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
InDetDD::BLM_Builder::m_moduleIV
std::vector< double > m_moduleIV
Definition: BLM_Builder.h:56
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
StoredMaterialManager.h
DecodeVersionKey.h
InDetDD::BLM_Builder::m_BDparameters
bool m_BDparameters
Definition: BLM_Builder.h:66
InDetDD::BLM_Builder::m_moduleX
std::vector< double > m_moduleX
Definition: BLM_Builder.h:62
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
BLM_GeometryManager
Definition: BLM_GeometryManager.h:20
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
InDetDD::BLM_Builder::m_moduleII
std::vector< double > m_moduleII
Definition: BLM_Builder.h:54
InDetDD::BLM_Builder::m_moduleIII
std::vector< double > m_moduleIII
Definition: BLM_Builder.h:55
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
python.changerun.pv
pv
Definition: changerun.py:81
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
BLM_Module
Beam Loss Monitor module builder.
Definition: BLM_Module.h:22
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
BLM_Builder.h
InDetDD::BLM_Builder::m_blmon
bool m_blmon
Definition: BLM_Builder.h:65
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
BLM_Module.h
IRDBRecord::getFloat
virtual float getFloat(const std::string &fieldName) const =0
Get float field value.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
InDetDD::BLM_Builder::m_moduleI
std::vector< double > m_moduleI
Definition: BLM_Builder.h:53
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
InDetDD::BLM_Builder::finalize
virtual StatusCode finalize()
standard Athena-Algorithm method
Definition: BLM_Builder.cxx:81
fitman.k
k
Definition: fitman.py:528
InDetDD::BLM_Builder::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS)
Definition: BLM_Builder.cxx:281
BLM_Module::Build
GeoPhysVol * Build(StoredMaterialManager *mat_mgr, const BLM_ModuleParameters *parameters, MsgStream *msg)
Definition: BLM_Module.cxx:22