ATLAS Offline Software
TBCaloCoolPosTool.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 "TBCaloCoolPosTool.h"
6 
7 
8 // Gaudi includes
9 #include "GaudiKernel/MsgStream.h"
10 #include "GaudiKernel/IIncidentSvc.h"
11 #include "GaudiKernel/ServiceHandle.h"
12 
13 
15  const std::string& name,
16  const IInterface* parent)
17  :
18  base_class(type, name, parent),m_init(0)
19 {
20 }
21 
22 //--------------------------------------------------------------------------
24 {}
25 
26 //--------------------------------------------------------------------------
28 {
29  return StatusCode::SUCCESS ;
30 }
31 
32 //--------------------------------------------------------------------------
34 {
35  ATH_MSG_DEBUG ("in initialize()" );
36 
37  if( initHandles() ) {
38  m_init = true;
39  } else
40  { // wait for the begin run
41  // start listening to "BeginRun"
42  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
43  ATH_CHECK( incSvc.retrieve() );
44  const int PRIORITY = 100;
45  incSvc->addListener(this, "BeginRun", PRIORITY);
46  }
47 
48  return StatusCode::SUCCESS;
49 }
50 
51 
52 void TBCaloCoolPosTool::handle(const Incident&)
53 {
54  // This should be the beginning of Run.
55 
56  ATH_MSG_DEBUG ("in handle()" );
57  if(! m_init) {
58  // not yet initialized.
59  if( initHandles() ) {
60  m_init = true;
61  } else
62  {
63  ATH_MSG_ERROR ( " unable initialize DataHandle in BeginRun Incident " );
64  }
65  }
66 
67  return;
68 }
69 
70 bool TBCaloCoolPosTool::initHandles ATLAS_NOT_THREAD_SAFE ()
71 {
72  ATH_MSG_DEBUG ("in initHandles()" );
73 
74  const EventContext& ctx = Gaudi::Hive::currentContext();
75  int run = ctx.eventID().run_number();
76 
77  std::string etaKey,thetaKey,zKey,deltaKey;
78 
79  if(run<1000454){
80  // this is the period before July 12, folder name is under Tile
81  thetaKey = "/TILE/DCS/SYSTEM1/TABLE/THETA" ;
82  etaKey = "/TILE/DCS/SYSTEM1/TABLE/ETA" ;
83  zKey = "/TILE/DCS/SYSTEM1/TABLE/Z" ;
84  deltaKey = "/TILE/DCS/SYSTEM1/TABLE/DELTA" ;
85  ATH_MSG_DEBUG ( " runs before 1000454, using Folders with SYSTEM1..." );
86 
87  } else
88  { // Folder moved under System:
89  thetaKey = "/TILE/DCS/TILE_LV_62/TABLE/THETA" ;
90  etaKey = "/TILE/DCS/TILE_LV_62/TABLE/ETA" ;
91  zKey = "/TILE/DCS/TILE_LV_62/TABLE/Z" ;
92  deltaKey = "/TILE/DCS/TILE_LV_62/TABLE/DELTA" ;
93  ATH_MSG_DEBUG ( " runs after 1000454, using Folders with TILE_LV_62..." );
94  }
95 
96  ATH_CHECK(detStore()->regHandle(m_deltaTable,deltaKey),false);
97  ATH_CHECK(detStore()->regHandle(m_thetaTable,thetaKey),false);
98  ATH_CHECK(detStore()->regHandle(m_zTable,zKey),false);
99  ATH_CHECK(detStore()->regHandle(m_etaTable,etaKey),false);
100 
101  ATH_MSG_DEBUG ( " eta = " << eta() );
102  ATH_MSG_DEBUG ( " theta = " << theta() );
103  ATH_MSG_DEBUG ( " z = " << z() );
104  ATH_MSG_DEBUG ( " delta = " << delta() );
105 
106  return true;
107 }
108 
109 //--------------------------------------------------------------------------
111 {
112  float e=0;
113  try {
114  e=(* m_etaTable)["eta"].data<float>();
115  }
116  catch (const std::exception& ex) {
117  ATH_MSG_ERROR("eta AttributeList access failed");
118  return 0 ;
119  }
120  return e;
121 }
122 
124 {
125  float t=0;
126  try {
127  t=(* m_thetaTable)["theta"].data<float>();
128  }
129  catch (const std::exception& ex) {
130  ATH_MSG_ERROR("theta AttributeList access failed");
131  return 0 ;
132  }
133  return t;
134 }
135 
137 {
138  float z=0;
139  try {
140  z=(* m_zTable)["z"].data<float>();
141  }
142  catch (const std::exception& ex) {
143  ATH_MSG_ERROR("z AttributeList access failed");
144  return 0 ;
145  }
146  return z;
147 }
148 
150 {
151  float d=0;
152  try {
153  d=(* m_deltaTable)["delta"].data<float>();
154  }
155  catch (const std::exception& ex) {
156  ATH_MSG_ERROR("delta AttributeList access failed");
157  return 0 ;
158  }
159  return d;
160 }
161 
TBCaloCoolPosTool::eta
virtual double eta()
access eta value
Definition: TBCaloCoolPosTool.cxx:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TBCaloCoolPosTool::handle
virtual void handle(const Incident &)
Definition: TBCaloCoolPosTool.cxx:52
hist_file_dump.d
d
Definition: hist_file_dump.py:137
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TBCaloCoolPosTool.h
TBCaloCoolPosTool::TBCaloCoolPosTool
TBCaloCoolPosTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TBCaloCoolPosTool.cxx:14
TBCaloCoolPosTool::theta
virtual double theta()
access eta value
Definition: TBCaloCoolPosTool.cxx:123
TBCaloCoolPosTool::initialize
virtual StatusCode initialize()
Definition: TBCaloCoolPosTool.cxx:33
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
calibdata.exception
exception
Definition: calibdata.py:496
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
run
Definition: run.py:1
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
ATLAS_NOT_THREAD_SAFE
bool TBCaloCoolPosTool::initHandles ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: TBCaloCoolPosTool.cxx:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TBCaloCoolPosTool::m_init
bool m_init
Definition: TBCaloCoolPosTool.h:64
TBCaloCoolPosTool::~TBCaloCoolPosTool
virtual ~TBCaloCoolPosTool()
Definition: TBCaloCoolPosTool.cxx:23
TBCaloCoolPosTool::z
virtual double z()
access eta value
Definition: TBCaloCoolPosTool.cxx:136
TBCaloCoolPosTool::finalize
virtual StatusCode finalize()
Definition: TBCaloCoolPosTool.cxx:27
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TBCaloCoolPosTool::delta
virtual double delta()
access eta value
Definition: TBCaloCoolPosTool.cxx:149
ServiceHandle< IIncidentSvc >