ATLAS Offline Software
AFP_GeoModelTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/IService.h"
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/MsgStream.h"
12 
13 #include "AFP_GeoModelTool.h"
14 #include "AFP_GeoModelFactory.h"
15 #include "AFP_GeoModelManager.h"
17 
21 AFP_GeoModelTool::AFP_GeoModelTool( const std::string& type, const std::string& name, const IInterface* parent )
22  : GeoModelTool( type, name, parent ), m_iovSvc( "IOVDbSvc", name )
23 {
25  m_pGeometry=nullptr;
26 
28 
37 
38  //Properties of SID
39  declareProperty("SID_AddVacuumSensors",m_defsidcfg.bAddVacuumSensors=false);
40 
41 
42  //Properties of TD
43 
44 
45  //Properties of stations
50 
55 
60 
65 }
66 
71 {
72  // This will need to be modified once we register the DetectorNode in
73  // the Transient Detector Store
74  if(m_detector!=nullptr) {
75  delete m_detector;
76  m_detector=nullptr;
77  }
78 
79  if(m_pGeometry!=nullptr){
80  delete m_pGeometry;
81  m_pGeometry=nullptr;
82  }
83 }
84 
86 {
87  bool bRes=true;
88 
89  MsgStream LogStream(Athena::getMessageSvc(), "AFP_GeoModelTool::CheckPropertiesSettings");
90 
91  if(!m_vecAFP00XStaggering.empty()){
92  if(m_vecAFP00XStaggering.size()==m_CfgParams.sidcfg[EAS_AFP00].fLayerCount){
94  }
95  else{
96  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP01XStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
97  bRes=false;
98  }
99  }
100  if(!m_vecAFP00YStaggering.empty()){
101  if(m_vecAFP00YStaggering.size()==m_CfgParams.sidcfg[EAS_AFP00].fLayerCount){
103  }
104  else{
105  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP00YStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
106  bRes=false;
107  }
108  }
109 
110  if(!m_vecAFP01XStaggering.empty()){
111  if(m_vecAFP01XStaggering.size()==m_CfgParams.sidcfg[EAS_AFP01].fLayerCount){
113  }
114  else{
115  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP01XStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
116  bRes=false;
117  }
118  }
119  if(!m_vecAFP01YStaggering.empty()){
120  if(m_vecAFP01YStaggering.size()==m_CfgParams.sidcfg[EAS_AFP01].fLayerCount){
122  }
123  else{
124  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP01YStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
125  bRes=false;
126  }
127  }
128 
129  if(!m_vecAFP02XStaggering.empty()){
130  if(m_vecAFP02XStaggering.size()==m_CfgParams.sidcfg[EAS_AFP02].fLayerCount){
132  }
133  else{
134  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP02XStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
135  bRes=false;
136  }
137  }
138  if(!m_vecAFP02YStaggering.empty()){
139  if(m_vecAFP02YStaggering.size()==m_CfgParams.sidcfg[EAS_AFP02].fLayerCount){
141  }
142  else{
143  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP02YStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
144  bRes=false;
145  }
146  }
147 
148  if(!m_vecAFP03XStaggering.empty()){
149  if(m_vecAFP03XStaggering.size()==m_CfgParams.sidcfg[EAS_AFP03].fLayerCount){
151  }
152  else{
153  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP03XStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
154  bRes=false;
155  }
156  }
157  if(!m_vecAFP03YStaggering.empty()){
158  if(m_vecAFP03YStaggering.size()==m_CfgParams.sidcfg[EAS_AFP03].fLayerCount){
160  }
161  else{
162  LogStream<<MSG::ERROR<<"Mismatch between SID_AFP03YStaggering and number of plates (SID_NumberOfLayers)"<<endmsg;
163  bRes=false;
164  }
165  }
166 
167  return bRes? StatusCode::SUCCESS:StatusCode::FAILURE;
168 }
169 
171 {
172  MsgStream log(msgSvc(), name());
173  //CHECK(m_iovSvc.retrieve()); //-- REMOVE THIS WHEN IOVSVC IS TO BE USED
174 
175  GeoModelExperiment * theExpt = nullptr;
176  StatusCode sc = detStore()->retrieve( theExpt, "ATLAS" );
177  if (StatusCode::SUCCESS != sc)
178  {
179  log << MSG::ERROR<< "Could not find GeoModelExperiment ATLAS"<< endmsg;
180  return (StatusCode::FAILURE);
181  }
182 
184 
186  m_pAFPDetectorFactory=std::make_unique<AFP_GeoModelFactory>(detStore().operator->(), m_pGeometry);
187 
188  if (m_detector==nullptr)
189  {
190  try
191  {
192  GeoPhysVol *world=&*theExpt->getPhysVol();
193  m_pAFPDetectorFactory->create(world);
194  }
195  catch (std::bad_alloc const&)
196  {
197  log << MSG::FATAL << "Could not create new DetectorNode!" << endmsg;
198  return StatusCode::FAILURE;
199  }
200 
201  // Register the DetectorNode instance with the Transient Detector Store
202  theExpt->addManager(m_pAFPDetectorFactory->getDetectorManager());
203  sc = detStore()->record(m_pAFPDetectorFactory->getDetectorManager(),m_pAFPDetectorFactory->getDetectorManager()->getName());
204 
205  if (StatusCode::SUCCESS != sc)
206  {
207  log << MSG::ERROR << "Could not register DetectorNode" << endmsg;
208  return (StatusCode::FAILURE);
209  }
210 
211  return StatusCode::SUCCESS;
212  }
213 
214  return StatusCode::FAILURE;
215 }
216 
217 /*
218 StatusCode AFP_GeoModelTool::registerCallback(StoreGateSvc* )
219 {
220 
221  StatusCode sc=StatusCode::FAILURE;
222 
223 
224  const DataHandle<CondAttrListCollection> DataPtr;
225  sc=detStore->regFcn(&IGeoModelTool::align,dynamic_cast<IGeoModelTool*>(this), DataPtr, COOLFOLDER_BPM, true);
226  if(sc!=StatusCode::SUCCESS){
227  msg(MSG::ERROR) << "Cannot register COOL callback for folder '"<< COOLFOLDER_BPM <<"'" << endmsg;
228  }
229  else{
230  msg(MSG::INFO) << "Call-back to ALFA_DetectorTool::align() against folder "<< COOLFOLDER_BPM <<" registered "<<endmsg;
231  }
232 
233  return sc;
234 
235  return StatusCode::FAILURE;
236 }*/
237 
238 /*
239 StatusCode AFP_GeoModelTool::align(IOVSVC_CALLBACK_ARGS)
240 {
241  StatusCode sc=StatusCode::SUCCESS;
242  AFP_BPMCOOLPARAMS BpmParams;
243  const AthenaAttributeList* pAttrList=NULL;
244  //const CondAttrListCollection* listAttrColl;
245  //CondAttrListCollection::const_iterator iterAttr;
246 
247  if(detStore()->retrieve(pAttrList,COOLFOLDER_BPM )==StatusCode::SUCCESS)
248  {
249  BpmParams.fBpmMRRX=(*pAttrList)["bpmr_r_x_pos"].data<float>();
250  BpmParams.fBpmMRRY=(*pAttrList)["bpmr_r_y_pos"].data<float>();
251  BpmParams.fBpmMRLX=(*pAttrList)["bpmr_l_x_pos"].data<float>();
252  BpmParams.fBpmMRLY=(*pAttrList)["bpmr_l_y_pos"].data<float>();
253  BpmParams.fBpmSARX=(*pAttrList)["bpmsa_r_x_pos"].data<float>();
254  BpmParams.fBpmSARY=(*pAttrList)["bpmsa_r_y_pos"].data<float>();
255  BpmParams.fBpmSALX=(*pAttrList)["bpmsa_l_x_pos"].data<float>();
256  BpmParams.fBpmSALY=(*pAttrList)["bpmsa_l_y_pos"].data<float>();
257  BpmParams.fBpmWBRX=(*pAttrList)["bpmwb_r_x_pos"].data<float>();
258  BpmParams.fBpmWBRY=(*pAttrList)["bpmwb_r_y_pos"].data<float>();
259  BpmParams.fBpmYALX=(*pAttrList)["bpmya_l_x_pos"].data<float>();
260  BpmParams.fBpmYALY=(*pAttrList)["bpmya_l_y_pos"].data<float>();
261 
262  m_pAFPDetectorFactory->UpdatePositions(&BpmParams);
263  }
264  else{
265  msg(MSG::ERROR) << "Folder '"<<"/FWD/ALFA/position_calibration"<<"' not found" << endmsg;
266  sc=StatusCode::FAILURE;
267  }
268 
269  return sc;
270 }
271 */
EAS_AFP02
@ EAS_AFP02
Definition: AFP_ConfigParams.h:18
AFP_CONSTANTS::Stat_ShiftInYAxis
static constexpr double Stat_ShiftInYAxis
Definition: AFP_constants.h:88
AFP_CONSTANTS::Stat_InnerZDistance
static constexpr double Stat_InnerZDistance
Definition: AFP_constants.h:86
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
AFP_GeoModelTool::m_vecAFP02XStaggering
std::vector< double > m_vecAFP02XStaggering
Definition: AFP_GeoModelTool.h:33
AFP_GeoModelTool::~AFP_GeoModelTool
virtual ~AFP_GeoModelTool() override final
Destructor.
Definition: AFP_GeoModelTool.cxx:70
AFP_GeoModelTool::m_defsidcfg
AFP_SIDCONFIGURATION m_defsidcfg
Definition: AFP_GeoModelTool.h:30
AFP_GeoModelTool::m_vecAFP03XStaggering
std::vector< double > m_vecAFP03XStaggering
Definition: AFP_GeoModelTool.h:34
AFP_CONSTANTS::SiT_NearDistanceToFloor
static constexpr double SiT_NearDistanceToFloor
Definition: AFP_constants.h:20
AFP_GeoModelTool::create
virtual StatusCode create() override final
Definition: AFP_GeoModelTool.cxx:170
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
AFP_CONFIGURATION::sidcfg
std::map< eAFPStation, AFP_SIDCONFIGURATION > sidcfg
Definition: AFP_ConfigParams.h:136
AFP_CONSTANTS::SiT_FarDistanceToFloor
static constexpr double SiT_FarDistanceToFloor
Definition: AFP_constants.h:21
EAS_AFP00
@ EAS_AFP00
Definition: AFP_ConfigParams.h:18
AFP_constants.h
EAS_AFP01
@ EAS_AFP01
Definition: AFP_ConfigParams.h:18
GeoModelExperiment
Definition: GeoModelExperiment.h:32
AFP_GeoModelTool.h
AFP_GeoModelTool::checkPropertiesSettings
StatusCode checkPropertiesSettings()
Definition: AFP_GeoModelTool.cxx:85
AFP_CONSTANTS::SiT_Plate_amount
static constexpr double SiT_Plate_amount
Definition: AFP_constants.h:18
AthenaAttributeList.h
AFP_CONFIGURATION::vecRPotFloorDistance
std::vector< double > vecRPotFloorDistance
Definition: AFP_ConfigParams.h:139
AFP_GeoModelFactory.h
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AFP_GeoModelTool::m_vecAFP02YStaggering
std::vector< double > m_vecAFP02YStaggering
Definition: AFP_GeoModelTool.h:33
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AFP_CONSTANTS::Stat_OuterZDistance
static constexpr double Stat_OuterZDistance
Definition: AFP_constants.h:87
GeoModelExperiment.h
AFP_GeoModelTool::m_pAFPDetectorFactory
std::unique_ptr< AFP_GeoModelFactory > m_pAFPDetectorFactory
Definition: AFP_GeoModelTool.h:28
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
AFP_SIDCONFIGURATION::bAddVacuumSensors
bool bAddVacuumSensors
Definition: AFP_ConfigParams.h:110
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AFP_CONSTANTS::Stat_RPotFloorDistance
static constexpr double Stat_RPotFloorDistance
Definition: AFP_constants.h:89
AFP_GeoModelTool::AFP_GeoModelTool
AFP_GeoModelTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor(s)
Definition: AFP_GeoModelTool.cxx:21
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoModelTool
Definition: GeoModelTool.h:17
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AFP_CONFIGURATION::vecStatNominalZPos
std::vector< double > vecStatNominalZPos
Definition: AFP_ConfigParams.h:141
EAS_AFP03
@ EAS_AFP03
Definition: AFP_ConfigParams.h:18
AFP_Geometry
Definition: AFP_Geometry.h:20
AFP_GeoModelTool::m_vecAFP03YStaggering
std::vector< double > m_vecAFP03YStaggering
Definition: AFP_GeoModelTool.h:34
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
AFP_GeoModelTool::m_vecAFP01XStaggering
std::vector< double > m_vecAFP01XStaggering
Definition: AFP_GeoModelTool.h:32
AFP_GeoModelTool::m_vecAFP01YStaggering
std::vector< double > m_vecAFP01YStaggering
Definition: AFP_GeoModelTool.h:32
GeoModelTool::m_detector
GeoVDetectorManager * m_detector
Definition: GeoModelTool.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AFP_GeoModelTool::m_vecAFP00XStaggering
std::vector< double > m_vecAFP00XStaggering
Definition: AFP_GeoModelTool.h:31
AFP_GeoModelManager.h
AFP_GeoModelTool::m_vecAFP00YStaggering
std::vector< double > m_vecAFP00YStaggering
Definition: AFP_GeoModelTool.h:31
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
AFP_CONFIGURATION::clear
void clear()
Definition: AFP_ConfigParams.cxx:9
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
AFP_SIDCONFIGURATION::clear
void clear()
Definition: AFP_ConfigParams.cxx:45
AFP_GeoModelTool::m_CfgParams
AFP_CONFIGURATION m_CfgParams
Definition: AFP_GeoModelTool.h:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
AFP_GeoModelTool::m_pGeometry
AFP_Geometry * m_pGeometry
Definition: AFP_GeoModelTool.h:27
AFP_CONFIGURATION::vecRPotYPos
std::vector< double > vecRPotYPos
Definition: AFP_ConfigParams.h:140
StoreGateSvc.h