15#include "GaudiKernel/EventIDRange.h"
22#include "GaudiKernel/MsgStream.h"
29#include "Identifier/Identifier.h"
52 ATH_MSG_DEBUG(
"TRT_RegSelCondAlg::TRT_RegSelCondAlg() " << this->name() );
65 return StatusCode::SUCCESS;
84 return StatusCode::SUCCESS;
91 if (not trtDetEleHandle.
isValid() or elements==
nullptr) {
93 return StatusCode::FAILURE;
102 if ( mapping.retrieve().isFailure() ) {
103 msg(MSG::ERROR) <<
" Can't get TRT CablingSvc " <<
endmsg;
104 return StatusCode::FAILURE;
109 const TRT_ID* idHelper =
nullptr;
110 if (
detStore()->retrieve( idHelper,
"TRT_ID" ).isFailure() ) {
111 msg(MSG::FATAL) <<
"Could not get TRT ID helper" <<
endmsg;
112 return StatusCode::FAILURE;
115 EventIDRange id_range;
117 if( !trtDetEleHandle.
range( id_range ) ) {
118 ATH_MSG_ERROR(
"Failed to retrieve validity range for " << trtDetEleHandle.
key());
119 return StatusCode::FAILURE;
130 std::unique_ptr<RegSelSiLUT> rd = std::make_unique<RegSelSiLUT>(
RegSelSiLUT::TRT);
132 constexpr double twoPi=2.*
M_PI;
133 constexpr double InnerRadiusOfStraw = 2.;
138 int idBarrelEndcap = idHelper->
barrel_ec(
id);
139 int idSide = (idBarrelEndcap > 0);
146 double phiMin,phiMax,
rz;
150 int Nstraws = Belement->
nStraws();
151 const int theLastStraw=Nstraws-1;
154 double x1 = Belement->
strawXPos(theLastStraw);
156 double y1 = Belement->
strawYPos(theLastStraw);
157 double r0 = sqrt(x0*x0 + y0*y0);
158 double r1 = sqrt(x1*x1 + y1*y1);
159 phiMin = std::atan2(y0,x0) - std::atan2(InnerRadiusOfStraw,r0);
160 while (phiMin >
M_PI) phiMin -= twoPi;
161 while (phiMin < -
M_PI) phiMin += twoPi;
162 phiMax = std::atan2(y1,x1) + std::atan2(InnerRadiusOfStraw,r1);
163 while (phiMax >
M_PI) phiMax -= twoPi;
164 while (phiMax < -
M_PI) phiMax += twoPi;
165 double zmin = Belement->
strawZPos(theLastStraw) - Length*0.5;
166 double zmax = Belement->
strawZPos(theLastStraw) + Length*0.5;
167 double rmin = ( r0<r1 ? r0 : r1 ) - InnerRadiusOfStraw;
168 double rmax = ( r1>r0 ? r1 : r0 ) + InnerRadiusOfStraw;
169 std::vector<uint32_t> vrob = mapping->getRobID(idelement);
170 for (
unsigned int ii=0 ; ii < vrob.size(); ++ii) {
171 RegSelModule smod( zmin, zmax, rmin, rmax, phiMin, phiMax, idLayerWheel, idSide, vrob[ii], idHash);
184 double dphi = std::atan2(InnerRadiusOfStraw, radius );
185 phiMin = phi0 - dphi;
186 while (phiMin >
M_PI) phiMin -= twoPi;
187 while (phiMin < -
M_PI) phiMin += twoPi;
188 phiMax = phi0 + pitch * (Nstraws-1) + dphi;
189 while (phiMax >
M_PI) phiMax -= twoPi;
190 while (phiMax < -
M_PI) phiMax += twoPi;
196 double zmin =
rz-InnerRadiusOfStraw;
197 double zmax =
rz+InnerRadiusOfStraw;
198 double rmin = radius;
199 double rmax = radius+
length;
200 std::vector<uint32_t> vrob = mapping->getRobID(idelement);
201 for (
unsigned int ii=0 ; ii < vrob.size(); ++ii) {
202 RegSelModule smod( zmin, zmax, rmin, rmax, phiMin, phiMax, idLayerWheel, idSide+2, vrob[ii], idHash);
225 if( lutCondData.
record( id_range, rcd ).isFailure() ) {
227 <<
" " << lutCondData.
key()
228 <<
" with range " << id_range );
229 return StatusCode::FAILURE;
235 return StatusCode::FAILURE;
241 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
RegSelCondData< IRegSelLUT > IRegSelLUTCondData
emacs: this is -*- c++ -*-
This is an Identifier helper class for the TRT subdetector.
emacs: this is -*- c++ -*-
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This is a "hash" representation of an Identifier.
Extended TRT_BaseElement to describe a TRT readout element, this is a planar layer with n ( order of ...
double strawXPos(unsigned int i) const
Get X Position: DEPRECATED.
double strawZPos(unsigned int i) const
Get Z Position: (active center) DEPRECATED.
virtual const double & strawLength() const override final
Get the length of the straws (active length):
double strawYPos(unsigned int i) const
Get Y Position: DEPRECATED.
unsigned int nStraws() const
Number of straws in the element.
virtual Identifier identify() const override final
identifier of this detector element:
virtual const Amg::Transform3D & transform() const override final
Element Surface: Get Transform of element in Tracking frame: Amg.
Class to hold different TRT detector elements structures.
const TRT_EndcapElement * getEndcapDetElement(unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex) const
const TRT_BarrelElement * getBarrelDetElement(unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex) const
double & strawPitch()
The straw pitch (angular!
double & startPhi()
The starting phi (angular!
unsigned int & nStraws()
The number of straws in a module:
double & innerRadius()
The inner radius:
Extended class of a TRT_BaseElement to describe a readout elment in the endcap.
const TRT_EndcapDescriptor * getDescriptor() const
Returns a pointer to a descriptor, giving common information on module construction.
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
This is an Identifier helper class for the TRT subdetector.
int phi_module(const Identifier &id) const
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
size_type straw_layer_hash_max() const
bool is_barrel(const Identifier &id) const
Test for barrel.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
int layer_or_wheel(const Identifier &id) const
int straw_layer(const Identifier &id) const
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey
TRT_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< IRegSelLUTCondData > m_tableKey
Output conditions object.
virtual StatusCode initialize() override
Eigen::Matrix< double, 3, 1 > Vector3D