ATLAS Offline Software
Loading...
Searching...
No Matches
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
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//--------------------------------------------------------------------------
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
55void 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
73bool 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
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
bool TBCaloPosTool::initHandles ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode initialize()
virtual void handle(const Incident &)
const DataHandle< GenericDbTable > m_etaTable
virtual double z()
access eta value
virtual ~TBCaloPosTool()
TBCaloPosTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode finalize()
const DataHandle< GenericDbTable > m_thetaTable
virtual double theta()
access eta value
const DataHandle< GenericDbTable > m_zTable
const DataHandle< GenericDbTable > m_deltaTable
virtual double eta()
access eta value
virtual double delta()
access eta value
int run(int argc, char *argv[])