ATLAS Offline Software
Loading...
Searching...
No Matches
RegSelCondAlg_Tile.cxx
Go to the documentation of this file.
1
13
14
15#include "RegSelCondAlg_Tile.h"
16
17#include "GaudiKernel/EventIDRange.h"
19
21
23
24#include "eformat/SourceIdentifier.h"
25
31#include "CaloDetDescr/CaloDetDescrElement.h"
32
33#include <cmath>
34#include <iostream>
35#include <string>
36#include <memory>
37
38
39RegSelCondAlg_Tile::RegSelCondAlg_Tile(const std::string& name, ISvcLocator* pSvcLocator):
40 AthCondAlgorithm( name, pSvcLocator ),
41 m_managerName(""),
42 m_printTable(false)
43{
44 declareProperty( "ManagerName", m_managerName );
45 declareProperty( "PrintTable", m_printTable=false );
46}
47
48
49
50
52 ATH_MSG_DEBUG("RegSelCondAlg_Tile::initialize() ");
53 ATH_CHECK(m_hid2RESrcIDKey.initialize());
54 ATH_CHECK(m_tableKey.initialize());
55 ATH_MSG_INFO("RegSelCondAlg_Tile::initialize() " << m_tableKey );
56 return StatusCode::SUCCESS;
57}
58
59
60
61StatusCode RegSelCondAlg_Tile::execute(const EventContext& ctx) const {
62
63 ATH_MSG_DEBUG("RegSelCondAlg_Tile::execute() -- enter -- ");
64
66 ATH_MSG_DEBUG( "Creating region selector table " << m_tableKey );
67
68
70 if (lutCondData.isValid()) {
76 ATH_MSG_DEBUG("CondHandle " << lutCondData.fullKey() << " is already valid." );
77 return StatusCode::SUCCESS;
78 }
79
81 if(!hid2RESrcID.isValid()) {
82 ATH_MSG_ERROR( "Do not have TileHid2RESrcID from key " << m_hid2RESrcIDKey.key() );
83 return StatusCode::FAILURE;
84 }
85
86 EventIDRange id_range;
87
88 if( !hid2RESrcID.range( id_range ) ) {
89 ATH_MSG_ERROR("Failed to retrieve validity range for " << hid2RESrcID.key());
90 return StatusCode::FAILURE;
91 }
92
93
94 ATH_MSG_INFO( "creating new Tile table" );
95
97
98 std::unique_ptr<IRegSelLUT> rd = createTable(*hid2RESrcID);
99
100 if ( !rd ) return StatusCode::FAILURE;
101
102 ATH_MSG_INFO( "Storing the new look up table " << m_tableKey );
103
105
106 IRegSelLUTCondData* rcd = new IRegSelLUTCondData( std::move(rd) );
107
108 try {
113 if( lutCondData.record( id_range, rcd ).isFailure() ) {
114 ATH_MSG_ERROR( "Could not record " << m_tableKey
115 << " " << lutCondData.key()
116 << " with range " << id_range );
117 return StatusCode::FAILURE;
118 }
119 ATH_MSG_INFO( "RegSelCondAlg LUT recorded: " << m_tableKey);
120 }
121 catch (...) {
122 ATH_MSG_ERROR("RegSelCondAlg_Tile::execute() failed to record table: " << m_tableKey);
123 return StatusCode::FAILURE;
124 }
125
126
127 ATH_MSG_DEBUG("RegSelCondAlg_Tile::execute() -- exit -- ");
128
129 return StatusCode::SUCCESS;
130}
131
132
133
134
135std::unique_ptr<RegSelectorMap> RegSelCondAlg_Tile::createTable(const TileHid2RESrcID* hid2re) const {
136
137 std::unique_ptr<RegSelectorMap> lut(nullptr);
138
141
142
143 // Get the TileID helper from the detector store
144 const TileID* tileID;
145 if (detStore()->retrieve(tileID, "TileID").isFailure()) {
146 ATH_MSG_ERROR( "Could not get TileID helper !");
147 return lut;
148 }
149
150 // Get the TileHWID helper from the detector store
151 const TileHWID* tileHWID;
152 if (detStore()->retrieve(tileHWID, "TileHWID").isFailure()) {
153 ATH_MSG_ERROR( "Could not get TileHWID helper !");
154 return lut;
155 }
156
157 // Get pointer to TileDetDescrManager
158 const TileDetDescrManager* tileMgr;
159 if (detStore()->retrieve(tileMgr).isFailure()) {
160 ATH_MSG_ERROR( "Unable to retrieve TileDetDescrManager from DetectorStore" );
161 return lut;
162 }
163
164 std::unique_ptr<RegionSelectorLUT> ttLut = std::make_unique<RegionSelectorLUT>(256);
165
166 enum Partition { Ancillary = 0, LBA = 1, LBC = 2, EBA = 3, EBC = 4 };
167
168 // hard-coded etamin/etamax - ignoring slightly different positions of EBA end ENC partitions
169 // FIXME: this is very poor - the actual positions should come from the geometry, not be hard
171
172 std::vector<double> etamin(TileCalibUtils::MAX_ROS);
173 etamin[LBA]=-0.1;
174 etamin[LBC]=-1.0;
175 etamin[EBA]=+0.708779;
176 etamin[EBC]=-1.60943;
177 std::vector<double> etamax(TileCalibUtils::MAX_ROS);
178 etamax[LBA]=+1.0;
179 etamax[LBC]=+0.1;
180 etamax[EBA]=+1.60943;
181 etamax[EBC]=-0.708779;
182
183 // so presumably USE_CELL_PHI is not definied, so we don't want
185
186# if (defined USE_MODULE_PHI)
187# else
188 double dphi = 2 * M_PI / TileCalibUtils::MAX_DRAWER; // 0.09817477;
189# endif
190
191 int sam = 0; // ?
192 int layer = 0; //?
193 int firstone = tileHWID->drawerIdx( tileHWID->drawer_id(LBA,0) ); // hash index of first real drawer (LBA01)
194 for (unsigned int ros = 0; ros < TileCalibUtils::MAX_ROS; ++ros) {
195 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
196
197 int hash = tileHWID->drawerIdx( tileHWID->drawer_id(ros,drawer) ) - firstone;
198 if (hash<0) continue;
199
200 int coll = tileHWID->frag(ros, drawer);
201 int rod = hid2re->getRodID(coll);
202
203 double etami = etamin[ros];
204 double etama = etamax[ros];
205
206# if (defined USE_MODULE_PHI)
207 // alternative approach
208 int section = (ros==LBA || ros==LBC) ? TileID::BARREL : TileID::EXTBAR;
209 int side = (ros==LBA || ros==EBA) ? TileID::POSITIVE : TileID::NEGATIVE;
210 Identifier moduleID = tileID->module_id(section,side,drawer);
211 CaloDetDescriptor *moduleDDE = tileMgr->get_module_element(moduleID);
212 double phimin = moduleDDE->calo_phi_min();
213 double phimax = moduleDDE->calo_phi_max();
214 if ( phimin < 0.0 ) {
215 phimin+=2*M_PI;
216 if ( phimax < phimin ) phimax+=2*M_PI;
217 }
218# else
219 // OLD method - we can predict phi boundaries from module number
220 double phimin = drawer * dphi;
221 double phimax = (drawer+1) * dphi;
222# endif
223
224 ttLut->additem(etami,etama,phimin,phimax,sam,layer,hash,rod);
225
226 }
227 }
228
229
235
236 lut = std::make_unique<RegSelectorMap>();
237 lut->addLut( ttLut.get() );
238 lut->mountDataStruct();
239
240 return lut;
241}
242
#define M_PI
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
RegSelCondData< IRegSelLUT > IRegSelLUTCondData
emacs: this is -*- c++ -*-
void section(const std::string &sec)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
double calo_phi_max() const
'ideal' geometry: phi maximal
double calo_phi_min() const
'ideal' geometry: phi minimal
virtual StatusCode execute(const EventContext &ctx) const override
virtual std::unique_ptr< RegSelectorMap > createTable(const TileHid2RESrcID *hid2re) const
SG::ReadCondHandleKey< TileHid2RESrcID > m_hid2RESrcIDKey
SG::WriteCondHandleKey< IRegSelLUTCondData > m_tableKey
Output conditions object.
RegSelCondAlg_Tile(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
bool range(EventIDRange &r)
const std::string & key() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
CaloDetDescriptor * get_module_element(const IdentifierHash module_hash) const
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition TileHWID.h:181
int drawerIdx(const HWIdentifier &id) const
construct drawer index from HW identifier
Definition TileHWID.h:175
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition TileHWID.cxx:187
This class provides conversion between fragment ID and RESrcID.
uint32_t getRodID(int frag_id) const
make a ROD SrcID for a fragment ID
Helper class for TileCal offline identifiers.
Definition TileID.h:67
Identifier module_id(int section, int side, int module) const