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