ATLAS Offline Software
TBCaloPosTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TBCaloPosTool.h"
6 
7 
8 // Gaudi includes
9 #include "GaudiKernel/MsgStream.h"
10 #include "GaudiKernel/IIncidentSvc.h"
11 
12 
13 TBCaloPosTool::TBCaloPosTool(const std::string& type,
14  const std::string& name,
15  const IInterface* parent)
16  :
17  AthAlgTool(type, name, parent),m_init(0)
18 {
19 
20  // Declare additional interface
21  declareInterface<ITBCaloPosTool>(this);
22 
23 }
24 
25 //--------------------------------------------------------------------------
27 {}
28 
29 //--------------------------------------------------------------------------
31 {
32  return StatusCode::SUCCESS ;
33 }
34 
35 //--------------------------------------------------------------------------
37 {
38  ATH_MSG_DEBUG ("in initialize()" );
39 
40  if( initHandles() ) {
41  m_init = true;
42  } else
43  { // wait for the begin run
44  // start listening to "BeginRun"
45  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
46  ATH_CHECK( incSvc.retrieve() );
47  int PRIORITY = 100;
48  incSvc->addListener(this, "BeginRun", PRIORITY);
49  }
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 
55 void TBCaloPosTool::handle(const Incident&)
56 {
57  // This should be the beginning of Run.
58 
59  ATH_MSG_DEBUG ("in handle()" );
60  if(! m_init) {
61  // not yet initialized.
62  if( initHandles() ) {
63  m_init = true;
64  } else
65  {
66  ATH_MSG_ERROR ( " unable initialize DataHandle in BeginRun Incident " );
67  }
68  }
69 
70  return;
71 }
72 
73 bool TBCaloPosTool::initHandles ATLAS_NOT_THREAD_SAFE ()
74 {
75  ATH_MSG_DEBUG ("in initHandles()" );
76 
77  const EventContext& ctx = Gaudi::Hive::currentContext();
78  int run = ctx.eventID().run_number();
79 
80  std::string etaKey,thetaKey,zKey,deltaKey;
81 
82  if(run<1000454){
83  // this is the period before July 12, folder name is under Tile
84  thetaKey = "/tile/dcs/System1:table.theta:online..value" ;
85  etaKey = "/tile/dcs/System1:table.eta:online..value" ;
86  zKey = "/tile/dcs/System1:table.z:online..value" ;
87  deltaKey = "/tile/dcs/System1:table.delta:online..value" ;
88  ATH_MSG_DEBUG ( " runs before 1000454, using Folders with System1..." );
89 
90  } else
91  { // Folder moved under System:
92  thetaKey = "/tile/dcs/Tile_LV_62:table.theta:online..value" ;
93  etaKey = "/tile/dcs/Tile_LV_62:table.eta:online..value" ;
94  zKey = "/tile/dcs/Tile_LV_62:table.z:online..value" ;
95  deltaKey = "/tile/dcs/Tile_LV_62:table.delta:online..value" ;
96  ATH_MSG_DEBUG ( " runs after 1000454, using Folders with Tile_LV_62..." );
97  }
98 
99  ATH_CHECK ( detStore()->regHandle(m_deltaTable,deltaKey), false );
100  ATH_CHECK ( detStore()->regHandle(m_thetaTable,thetaKey), false );
101  ATH_CHECK ( detStore()->regHandle(m_zTable,zKey), false );
102  ATH_CHECK ( detStore()->regHandle(m_etaTable,etaKey), false );
103 
104  ATH_MSG_DEBUG ( " eta = " << eta() );
105  ATH_MSG_DEBUG ( " theta = " << theta() );
106  ATH_MSG_DEBUG ( " z = " << z() );
107  ATH_MSG_DEBUG ( " delta = " << delta() );
108 
109  return true;
110 }
111 
112 //--------------------------------------------------------------------------
114 {
115  double e=0;
116  if(m_etaTable->getNumRows() !=1 || m_etaTable->getNumColumns()!=1) {
117  ATH_MSG_ERROR(" eta GenericDbTable has wrong dimension");
118  return 0 ;
119  }
120 
121  m_etaTable->getCell(0,0,e);
122  return e;
123 }
124 
125 
126 
128 {
129  double t=0;
130  if(m_thetaTable->getNumRows() !=1 || m_thetaTable->getNumColumns()!=1) {
131  ATH_MSG_ERROR(" theta GenericDbTable has wrong dimension");
132  return 0 ;
133  }
134 
135  m_thetaTable->getCell(0,0,t);
136  return t;
137 }
138 
139 
140 
142 {
143  double zzz=0;
144  if(m_zTable->getNumRows() !=1 || m_zTable->getNumColumns()!=1) {
145  ATH_MSG_ERROR(" z GenericDbTable has wrong dimension");
146  return 0 ;
147  }
148 
149  m_zTable->getCell(0,0,zzz);
150  return zzz;
151 }
152 
153 
154 
156 {
157  double d=0;
158  if(m_deltaTable->getNumRows() !=1 || m_deltaTable->getNumColumns()!=1) {
159  ATH_MSG_ERROR(" delta GenericDbTable has wrong dimension");
160  return 0 ;
161  }
162 
163  m_deltaTable->getCell(0,0,d);
164  return d;
165 }
166 
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TBCaloPosTool::m_deltaTable
const DataHandle< GenericDbTable > m_deltaTable
Definition: TBCaloPosTool.h:62
TBCaloPosTool::TBCaloPosTool
TBCaloPosTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TBCaloPosTool.cxx:13
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
hist_file_dump.d
d
Definition: hist_file_dump.py:137
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
TBCaloPosTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TBCaloPosTool::delta
virtual double delta()
access eta value
Definition: TBCaloPosTool.cxx:155
TBCaloPosTool::m_zTable
const DataHandle< GenericDbTable > m_zTable
Definition: TBCaloPosTool.h:61
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
z
#define z
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
TBCaloPosTool::m_etaTable
const DataHandle< GenericDbTable > m_etaTable
Definition: TBCaloPosTool.h:59
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
run
Definition: run.py:1
ATLAS_NOT_THREAD_SAFE
bool TBCaloPosTool::initHandles ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: TBCaloPosTool.cxx:73
GenericDbTable::getNumRows
unsigned getNumRows() const
Returns the number of rows RESERVED in the table.
Definition: GenericDbTable.h:571
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
GenericDbTable::getCell
int getCell(unsigned n_column, unsigned n_row, short int &ndata) const
This method gets a value from a cell in a column of long ints (int in MySQL)
Definition: GenericDbTable.cxx:706
TBCaloPosTool::m_thetaTable
const DataHandle< GenericDbTable > m_thetaTable
Definition: TBCaloPosTool.h:60
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TBCaloPosTool::theta
virtual double theta()
access eta value
Definition: TBCaloPosTool.cxx:127
TBCaloPosTool::eta
virtual double eta()
access eta value
Definition: TBCaloPosTool.cxx:113
TBCaloPosTool::finalize
virtual StatusCode finalize()
Definition: TBCaloPosTool.cxx:30
TBCaloPosTool::m_init
bool m_init
Definition: TBCaloPosTool.h:64
TBCaloPosTool::~TBCaloPosTool
virtual ~TBCaloPosTool()
Definition: TBCaloPosTool.cxx:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GenericDbTable::getNumColumns
unsigned getNumColumns() const
Returns the number of columns in the table.
Definition: GenericDbTable.h:579
TBCaloPosTool::handle
virtual void handle(const Incident &)
Definition: TBCaloPosTool.cxx:55
TBCaloPosTool::initialize
virtual StatusCode initialize()
Definition: TBCaloPosTool.cxx:36
TBCaloPosTool::z
virtual double z()
access eta value
Definition: TBCaloPosTool.cxx:141
AthAlgTool
Definition: AthAlgTool.h:26
ServiceHandle< IIncidentSvc >