ATLAS Offline Software
TBCaloPosTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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  // Incident Service:
41  IIncidentSvc* incSvc = nullptr;
42  ATH_CHECK( serviceLocator()->service("IncidentSvc", incSvc) );
43 
44  if( initHandles() ) {
45  m_init = true;
46  } else
47  { // wait for the begin run
48  //start listening to "BeginRun"
49  int PRIORITY = 100;
50  incSvc->addListener(this, "BeginRun", PRIORITY);
51  }
52 
53  return StatusCode::SUCCESS;
54 }
55 
56 
57 void TBCaloPosTool::handle(const Incident&)
58 {
59  // This should be the beginning of Run.
60 
61  ATH_MSG_DEBUG ("in handle()" );
62  if(! m_init) {
63  // not yet initialized.
64  if( initHandles() ) {
65  m_init = true;
66  } else
67  {
68  ATH_MSG_ERROR ( " unable initialize DataHandle in BeginRun Incident " );
69  }
70  }
71 
72  return;
73 }
74 
75 bool TBCaloPosTool::initHandles ATLAS_NOT_THREAD_SAFE ()
76 {
77  ATH_MSG_DEBUG ("in initHandles()" );
78 
79  const EventContext& ctx = Gaudi::Hive::currentContext();
80  int run = ctx.eventID().run_number();
81 
82  std::string etaKey,thetaKey,zKey,deltaKey;
83 
84  if(run<1000454){
85  // this is the period before July 12, folder name is under Tile
86  thetaKey = "/tile/dcs/System1:table.theta:online..value" ;
87  etaKey = "/tile/dcs/System1:table.eta:online..value" ;
88  zKey = "/tile/dcs/System1:table.z:online..value" ;
89  deltaKey = "/tile/dcs/System1:table.delta:online..value" ;
90  ATH_MSG_DEBUG ( " runs before 1000454, using Folders with System1..." );
91 
92  } else
93  { // Folder moved under System:
94  thetaKey = "/tile/dcs/Tile_LV_62:table.theta:online..value" ;
95  etaKey = "/tile/dcs/Tile_LV_62:table.eta:online..value" ;
96  zKey = "/tile/dcs/Tile_LV_62:table.z:online..value" ;
97  deltaKey = "/tile/dcs/Tile_LV_62:table.delta:online..value" ;
98  ATH_MSG_DEBUG ( " runs after 1000454, using Folders with Tile_LV_62..." );
99  }
100 
101  ATH_CHECK ( detStore()->regHandle(m_deltaTable,deltaKey), false );
102  ATH_CHECK ( detStore()->regHandle(m_thetaTable,thetaKey), false );
103  ATH_CHECK ( detStore()->regHandle(m_zTable,zKey), false );
104  ATH_CHECK ( detStore()->regHandle(m_etaTable,etaKey), false );
105 
106  ATH_MSG_DEBUG ( " eta = " << eta() );
107  ATH_MSG_DEBUG ( " theta = " << theta() );
108  ATH_MSG_DEBUG ( " z = " << z() );
109  ATH_MSG_DEBUG ( " delta = " << delta() );
110 
111  return true;
112 }
113 
114 //--------------------------------------------------------------------------
116 {
117  double e=0;
118  if(m_etaTable->getNumRows() !=1 || m_etaTable->getNumColumns()!=1) {
119  ATH_MSG_ERROR(" eta GenericDbTable has wrong dimension");
120  return 0 ;
121  }
122 
123  m_etaTable->getCell(0,0,e);
124  return e;
125 }
126 
127 
128 
130 {
131  double t=0;
132  if(m_thetaTable->getNumRows() !=1 || m_thetaTable->getNumColumns()!=1) {
133  ATH_MSG_ERROR(" theta GenericDbTable has wrong dimension");
134  return 0 ;
135  }
136 
137  m_thetaTable->getCell(0,0,t);
138  return t;
139 }
140 
141 
142 
144 {
145  double zzz=0;
146  if(m_zTable->getNumRows() !=1 || m_zTable->getNumColumns()!=1) {
147  ATH_MSG_ERROR(" z GenericDbTable has wrong dimension");
148  return 0 ;
149  }
150 
151  m_zTable->getCell(0,0,zzz);
152  return zzz;
153 }
154 
155 
156 
158 {
159  double d=0;
160  if(m_deltaTable->getNumRows() !=1 || m_deltaTable->getNumColumns()!=1) {
161  ATH_MSG_ERROR(" delta GenericDbTable has wrong dimension");
162  return 0 ;
163  }
164 
165  m_deltaTable->getCell(0,0,d);
166  return d;
167 }
168 
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:79
hist_file_dump.d
d
Definition: hist_file_dump.py:137
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:71
TBCaloPosTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TBCaloPosTool::delta
virtual double delta()
access eta value
Definition: TBCaloPosTool.cxx:157
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:75
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:192
TBCaloPosTool::theta
virtual double theta()
access eta value
Definition: TBCaloPosTool.cxx:129
TBCaloPosTool::eta
virtual double eta()
access eta value
Definition: TBCaloPosTool.cxx:115
TBCaloPosTool::finalize
virtual StatusCode finalize()
Definition: TBCaloPosTool.cxx:30
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
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:57
TBCaloPosTool::initialize
virtual StatusCode initialize()
Definition: TBCaloPosTool.cxx:36
TBCaloPosTool::z
virtual double z()
access eta value
Definition: TBCaloPosTool.cxx:143
AthAlgTool
Definition: AthAlgTool.h:26