68 PtrVectorWrapper<Trk::CylinderLayer> barrelLayers;
74 const TRT_ID* trtIdHelper =
nullptr;
82 double layerPhiStep = 2*
M_PI/nBarrelPhiSectors;
84 int nTotalBarrelLayers = 0;
90 double layerZmax = 0.;
91 double layerZmin = 10e10;
94 for (
int ring=0; ring < nBarrelRings; ring++) {
97 nTotalBarrelLayers += nBarrelLayers;
100 for (
int phisec=0; phisec <nBarrelPhiSectors; ++phisec)
102 for (
int iposneg=0; iposneg<2; ++iposneg){
108 if (!elementSurface) {
109 ATH_MSG_WARNING(
"elementSurface: dynamic_cast to Trk::PlaneSurface failed - skipping ... ring/layer/phisec/iposneg = " << ring <<
"/" <<
layer <<
"/" << phisec <<
"/" << iposneg );
113 if (!elementBounds) {
114 ATH_MSG_WARNING(
"elementBounds: dynamic_cast to Trk::RectangleBounds failed - skipping ... ring/layer/phisec/iposneg = " << ring <<
"/" <<
layer <<
"/" << phisec <<
"/" << iposneg );
117 double elementZcenter = (elementSurface->
center()).
z();
118 double elementZmin = std::abs(elementZcenter - elementBounds->
halflengthY());
119 double elementZmax = std::abs(elementZcenter + elementBounds->
halflengthY());
123 double currentR = trtbar->
center().perp();
130 if (nTotalBarrelLayers==0) {
131 ATH_MSG_WARNING(
"nTotalBarrelLayers = 0 ... aborting and returning 0 !" );
136 double rDiff = std::abs(rMax-rMin);
138 double layerHalflength = layerZmax;
141 if ( std::abs(rDiff) <= 0.1 ) {
146 std::vector<double> layerRadii;
151 auto layerRadiusIter = layerRadii.begin();
152 auto layerRadiusIterEnd = layerRadii.end();
157 ATH_MSG_VERBOSE(
" -> " << layerRadii.size() <<
" cylindrical barrel layers between " << rMin <<
" and " << rMax <<
" ( at step "<< rStep <<
" )");
160 for ( ; layerRadiusIter != layerRadiusIterEnd; ++layerRadiusIter ) {
170 -(*layerRadiusIter)*
M_PI,
171 (*layerRadiusIter)*
M_PI,
174 layerBinUtility2DRPhiZ += layerBinUtility1DZ;
178 barrelLayers->push_back(
180 *layerRadiusIter, layerHalflength),
182 ATH_MSG_VERBOSE(
" --> Creating a layer at radius : " << *layerRadiusIter);
183 delete layerMaterial;
190 unsigned int cMaterialLayerCount = 0;
192 unsigned int cLayer=0;
197 for (
int ring=0; ring < nBarrelRings; ring++){
200 ATH_MSG_VERBOSE(
"-> Ring " << ring <<
" has " << nBarrelLayers <<
" barrel layers.");
205 ATH_MSG_VERBOSE(
"--> Layer " <<
layer <<
" is being built with " << nBarrelPhiSectors <<
" secors in phi.");
211 double layerRadius = 0.;
212 double layerRadiusMin = 10e10;
213 double layerRadiusMax = 0.;
214 double layerPhiMin = 10.;
215 double layerPhiMax = -10;
218 std::vector< std::pair<Trk::BinnedArray2D<Trk::Surface>,
Amg::Vector3D > > layerSectorArrays;
222 std::vector< std::pair< std::shared_ptr<const Trk::ApproachSurfaces>,
Amg::Vector3D > > layerApproachSurfaces;
225 for (
int phisec=0; phisec < nBarrelPhiSectors; phisec++){
227 ATH_MSG_VERBOSE(
"---> Sector " << phisec <<
" gahtering the details.");
231 std::vector< Trk::SurfaceOrderPosition > strawsPerPhiSecLayer;
234 double phiMax = -10.;
236 int sectorStraws = 0;
238 for (
int posneg=0; posneg<2; ++posneg){
243 if (!elementSurface) {
244 ATH_MSG_WARNING(
"elementSurface: dynamic_cast to Trk::PlaneSurface failed - skipping ... ring/layer/phisec/posneg = " << ring <<
"/" <<
layer <<
"/" << phisec <<
"/" << posneg );
260 layerSectorPosition = elementSurface->
center();
267 layerApproachSurfaces.emplace_back( std::shared_ptr<const Trk::ApproachSurfaces>(aSurfaces),elementCenter);
269 ATH_MSG_VERBOSE(
"---> Sector " << phisec <<
" - posneg - " << posneg <<
" - with central phi = " << elementSurface->
center().phi() );
274 for (
unsigned int istraw=0; istraw<currentElement->
nStraws(); ++istraw)
279 double currentPhi = currentStraw->
center().phi();
281 currentPhi =
M_PI + currentPhi;
305 std::shared_ptr<Trk::Surface> sharedSurface(
const_cast<Trk::Surface*
>(currentStraw),
306 Trk::do_not_delete<Trk::Surface>);
307 strawsPerPhiSecLayer.emplace_back(sharedSurface, strawOrderPos);
319 double phiStep =
deltaPhi/(0.5*sectorStraws-1);
320 ATH_MSG_VERBOSE(
"---> Sector " << phisec <<
" - with " << 0.5*sectorStraws <<
" straws - straw phiMin/phiMax (step) = " << phiMin <<
" / " << phiMax <<
" (" << phiStep <<
")");
322 phiMin -= 0.5*phiStep;
323 phiMax += 0.5*phiStep;
330 ATH_MSG_VERBOSE(
"---> Sector " << phisec <<
" - BinnedArray for straws prepared for " << strawsPerPhiSecLayer.size() <<
" straws.");
332 layerSectorArrays.emplace_back(std::move(layerStrawPhiSector), layerSectorPosition);
339 bool assignMaterial =
false;
340 if (cLayer==(
unsigned)
int((cMaterialLayerCount+1)*nMaterialLayerStep)) {
341 assignMaterial =
true;
342 ++cMaterialLayerCount;
343 ATH_MSG_VERBOSE(
"--> Creating a material+straw layer at radius : " << layerRadius );
345 ATH_MSG_VERBOSE(
"--> Creating a straw layer at radius : " << layerRadius );
348 auto barrelLayerBounds = std::make_shared<Trk::CylinderBounds>(layerRadius, layerHalflength);
351 ATH_MSG_VERBOSE(
" prepare approach description with " << nBarrelPhiSectors <<
" barrel sectors.");
352 ATH_MSG_VERBOSE(
" min phi / max phi detected : " << layerPhiMin <<
" / " << layerPhiMax );
353 double layerPhiMinCorrected = layerPhiMin-0.5*layerPhiStep;
354 double layerPhiMaxCorrected = layerPhiMax+0.5*layerPhiStep;
356 if (layerPhiMinCorrected < -
M_PI){
357 layerPhiMinCorrected += layerPhiStep;
358 layerPhiMaxCorrected += layerPhiStep;
360 ATH_MSG_VERBOSE(
" min phi / max phi corrected : " << layerPhiMinCorrected <<
" / " << layerPhiMaxCorrected );
364 auto strawArray = std::make_unique<Trk::BinnedArrayArray2D<Trk::Surface>>(std::move(layerSectorArrays), layerSectorBinUtility );
366 ATH_MSG_VERBOSE(
"--> Layer " <<
layer <<
" has been built with " << strawArray->arrayObjects().size() <<
" straws.");
373 auto aDescriptorBinnedArray = std::make_unique<Trk::BinnedArray2D<const Trk::ApproachSurfaces>> (layerApproachSurfaces, aDescriptorBinUtility);
376 auto approachSurface = std::make_unique<Trk::CylinderSurface>(
377 std::make_shared<Trk::CylinderBounds>(*barrelLayerBounds));
379 std::move(aDescriptorBinnedArray), std::move(approachSurface));
382 if (assignMaterial) {
391 -layerRadius*
M_PI, layerRadius*
M_PI,
394 layerBinUtilityRPhiZ += layerBinUtilityZ;
399 std::move(strawArray),
402 std::make_unique<InDet::TRT_OverlapDescriptor>(trtIdHelper),
404 delete layerMaterial;
408 std::move(strawArray),
410 std::make_unique<InDet::TRT_OverlapDescriptor>(trtIdHelper),
415 ATH_MSG_VERBOSE(
" Built number of TRT barrel material layers: " << cMaterialLayerCount);
420 ATH_MSG_WARNING(
" Complex geo built incorrect # of TRT barrel material layers: "
426 return std::unique_ptr<const std::vector<Trk::CylinderLayer*> > (barrelLayers.release());