leave this commented here since this is where it should really be, but we had to move it up in the code to handle the flawed conditions handling in the serial athena use case
72{
73
75
76 SG::WriteCondHandle<IRegSelLUTCondData> lutCondData(
m_tableKey, ctx );
77 if (lutCondData.isValid()) {
83 ATH_MSG_DEBUG(
"CondHandle " << lutCondData.fullKey() <<
" is already valid." );
84 return StatusCode::SUCCESS;
85 }
86
87
88
89 SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(
m_trtDetEleContKey,ctx);
90 const InDetDD::TRT_DetElementContainer* elements(*trtDetEleHandle);
91 if (not trtDetEleHandle.isValid() or elements==nullptr) {
93 return StatusCode::FAILURE;
94 }
95
97
98
99
100 ServiceHandle<ITRT_CablingSvc>
mapping(
"TRT_CablingSvc",
name() );
101
102 if (
mapping.retrieve().isFailure() ) {
103 msg(MSG::ERROR) <<
" Can't get TRT CablingSvc " <<
endmsg;
104 return StatusCode::FAILURE;
105 }
106
107
108
109 const TRT_ID* idHelper = nullptr;
111 msg(MSG::FATAL) <<
"Could not get TRT ID helper" <<
endmsg;
112 return StatusCode::FAILURE;
113 }
114
115 EventIDRange id_range;
116
117 if( !trtDetEleHandle.range( id_range ) ) {
118 ATH_MSG_ERROR(
"Failed to retrieve validity range for " << trtDetEleHandle.key());
119 return StatusCode::FAILURE;
120 }
121
122
123
124
125
127
128
129
130 std::unique_ptr<RegSelSiLUT> rd = std::make_unique<RegSelSiLUT>(
RegSelSiLUT::TRT);
131
132 constexpr double twoPi=2.*
M_PI;
133 constexpr double InnerRadiusOfStraw = 2.;
134
135 for (
unsigned int index = 0;
index < maxHash;
index++) {
136 IdentifierHash idHash =
index;
137 Identifier
id = idHelper->
layer_id(idHash);
138 int idBarrelEndcap = idHelper->
barrel_ec(
id);
139 int idSide = (idBarrelEndcap > 0);
143 const InDetDD::TRT_BarrelElement* Belement = nullptr;
144 const InDetDD::TRT_EndcapElement* Eelement = nullptr;
145 Identifier idelement;
146 double phiMin,phiMax,rz;
148 Belement = elements->getBarrelDetElement(idSide, idLayerWheel, idPhiModule, idStrawLayer);
150 int Nstraws = Belement->
nStraws();
151 const int theLastStraw=Nstraws-1;
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);
172 rd->addModule(smod);
173 }
174 } else {
175 Eelement = elements->getEndcapDetElement(idSide, idLayerWheel, idStrawLayer, idPhiModule);
182
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;
191 rz = center.z();
192
193
194
195
196 double zmin = rz-InnerRadiusOfStraw;
197 double zmax = rz+InnerRadiusOfStraw;
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);
203 rd->addModule(smod);
204 }
205 }
206 }
207
208
209
210
212
213 rd->initialise();
214
215
217
219
220 try {
224
225 if( lutCondData.record( id_range, rcd ).isFailure() ) {
227 << " " << lutCondData.key()
228 << " with range " << id_range );
229 return StatusCode::FAILURE;
230 }
232 }
233 catch (...) {
235 return StatusCode::FAILURE;
236 }
237
238
240
241 return StatusCode::SUCCESS;
242}
RegSelCondData< IRegSelLUT > IRegSelLUTCondData
const ServiceHandle< StoreGateSvc > & detStore() const
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.
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:
const TRT_EndcapDescriptor * getDescriptor() const
Returns a pointer to a descriptor, giving common information on module construction.
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
SG::WriteCondHandleKey< IRegSelLUTCondData > m_tableKey
Output conditions object.
Eigen::Matrix< double, 3, 1 > Vector3D
const double r0
electron radius{cm}
retrieve(aClass, aKey=None)