42(
const std::string& t,
const std::string& n,
const IInterface* p)
45 declareInterface<ITRT_DetElementsRoadMaker>(
this);
61 StatusCode
sc = AlgTool::initialize();
80 StatusCode
sc = AlgTool::finalize();
return sc;
98 auto precision = out.precision();
100 std::string s1;
for(
int i=0; i<n; ++i) s1.append(
" "); s1.append(
"|");
102 std::string fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
103 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
104 "UndefinedField",
"AthenaField" ,
"?????" };
116 if(mode<0 || mode>8 ) mode = 8;
118 n = 62-fieldmode[mode].size();
119 std::string s3;
for(
int i=0; i<n; ++i) s3.append(
" "); s3.append(
"|");
121 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(Gaudi::Hive::currentContext());
124 if(!layer[0].
empty()) ++maps;
125 if(!layer[1].
empty()) ++maps;
126 if(!layer[2].
empty()) ++maps;
128 out<<
"|----------------------------------------------------------------------"
129 <<
"-------------------|"
131 out<<
"| Tool for propagation | "<<
m_proptool.type()<<s1<<std::endl;
132 out<<
"| Magnetic field mode | "<<fieldmode[mode]<<s3<<std::endl;
133 out<<
"| Width of the road (mm) | "
134 <<std::setw(12)<<std::setprecision(5)<<
m_width
136 out<<
"|----------------------------------------------------------------------"
137 <<
"-------------------|"
140 if(!maps || !
msgLvl(MSG::VERBOSE))
return out;
142 if(!layer[1].
empty()) {
143 int nl = layer[1].size();
145 for(
const auto & i : layer[1]) nc+=i.nElements();
146 out<<
"|----------------------------------------------------------------|"
148 out<<
"| Barrel map containt "
149 <<std::setw(4)<<nl<<
" layers and "
150 <<std::setw(6)<<nc<<
" elements |"
152 out<<
"|------|-----------|------------|------------|------------|------|"
154 out<<
"| n | R | Z min | Z max | max dF | nEl |"
156 out<<
"|------|-----------|------------|------------|------------|------|"
158 for(
unsigned int i=0; i!=layer[1].size(); ++i) {
159 float zmin = layer[1][i].z()-layer[1][i].dz();
160 float zmax = layer[1][i].z()+layer[1][i].dz();
162 <<std::setw(4)<<i<<
" |"
163 <<std::setw(10)<<std::setprecision(4)<< layer[1][i].r ()<<
" | "
164 <<std::setw(10)<<std::setprecision(4)<< zmin<<
" | "
165 <<std::setw(10)<<std::setprecision(4)<< zmax<<
" | "
166 <<std::setw(10)<<std::setprecision(4)<< layer[1][i].dfe()<<
" | "
167 <<std::setw(4)<<layer[1][i].nElements()<<
" | "
170 out<<
"|------|-----------|------------|------------|------------|------|"
174 if(!layer[0].
empty()) {
176 int nl = layer[0].size();
178 for(
const auto & i : layer[0]) nc+=i.nElements();
179 out<<
"|----------------------------------------------------------------|"
181 out<<
"| L.Endcap map containt "
182 <<std::setw(4)<<nl<<
" layers and "
183 <<std::setw(6)<<nc<<
" elements |"
186 out<<
"|------|-----------|------------|------------|------------|------|"
188 out<<
"| n | Z | R min | R max | max dF | nEl |"
190 out<<
"|------|-----------|------------|------------|------------|------|"
192 for(
unsigned int i=0; i!=layer[0].size(); ++i) {
193 float rmin = layer[0][i].r()-layer[0][i].dr();
194 float rmax = layer[0][i].r()+layer[0][i].dr();
196 <<std::setw(4)<<i<<
" |"
197 <<std::setw(10)<<std::setprecision(4)<< layer[0][i].z()<<
" | "
198 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
199 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
200 <<std::setw(10)<<std::setprecision(4)<<layer[0][i].dfe()<<
" | "
201 <<std::setw(4)<<layer[0][i].nElements()<<
" | "
204 out<<
"|------|-----------|------------|------------|------------|------|"
207 if(!layer[2].
empty()) {
208 int nl = layer[2].size();
210 for(
const auto & i : layer[2]) nc+=i.nElements();
211 out<<
"|----------------------------------------------------------------|"
213 out<<
"| R.Endcap map containt "
214 <<std::setw(4)<<nl<<
" layers and "
215 <<std::setw(6)<<nc<<
" elements |"
217 out<<
"|------|-----------|------------|------------|------------|------|"
219 out<<
"| n | Z | R min | R max | max dF | nEl |"
221 out<<
"|------|-----------|------------|------------|------------|------|"
223 for(
unsigned int i=0; i!=layer[2].size(); ++i) {
224 float rmin = layer[2][i].r()-layer[0][i].dr();
225 float rmax = layer[2][i].r()+layer[0][i].dr();
227 <<std::setw(4)<<i<<
" |"
228 <<std::setw(10)<<std::setprecision(4)<< layer[2][i].z()<<
" | "
229 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
230 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
231 <<std::setw(10)<<std::setprecision(4)<<layer[2][i].dfe()<<
" | "
232 <<std::setw(4)<<layer[2][i].nElements()<<
" | "
235 out<<
"|------|-----------|------------|------------|------------|------|"
238 out.precision(precision);
248 out<<
"|--------------------------------------------------------------------|"
250 out<<
"| Road size | "<<std::setw(12)<<size_road
252 out<<
"|--------------------------------------------------------------------|"
271std::vector<const InDetDD::TRT_BaseElement*>
273(
const EventContext& ctx,
278 double qp = std::abs(500.*
Tp.parameters()[4]) ;
279 if( qp < 1.e-10 ) qp = 1.e-10;
281 if( S > 200. ) S = 200. ;
285 std::vector<const InDetDD::TRT_BaseElement*> result;
286 if( CB.r() > rminTRT) {
290 std::deque<Amg::Vector3D>
G;
306(std::deque<Amg::Vector3D>& GP,
307 std::vector<const InDetDD::TRT_BaseElement*>& Road,
309 const EventContext& ctx)
const
314 std::deque<Amg::Vector3D>::iterator g=GP.begin(),ge=GP.end();
316 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(ctx);
318 float Po[6] = {float((*g).x()),float((*g).y()),float((*g).z()),
319 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y())),
m_width,0.};
321 for(; n0!=(int)layer[0].size(); ++n0) {
if(Po[2] > layer[0][n0].
z())
break;}
322 for(; n1!=(int)layer[1].size(); ++n1) {
if(Po[3] < layer[1][n1].
r())
break;}
323 for(; n2!=(int)layer[2].size(); ++n2) {
if(Po[2] < layer[2][n2].
z())
break;}
325 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> > lDE;
326 for (
unsigned int module_i = 0; module_i < 3; ++module_i) {
327 size_t layersSize = layer[module_i].size();
329 used[module_i].resize(layersSize);
330 for (
unsigned int layer_i = 0; layer_i < layersSize; ++layer_i) {
333 used[module_i][layer_i].clear();
335 used[module_i][layer_i].resize(layer[module_i][layer_i].nElements());
339 for(++g; g!=ge; ++g) {
341 float Pn[4] = {float((*g).x()),float((*g).y()),float((*g).z()),
342 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y()))};
344 float dx = Pn[0]-Po[0];
345 float dy = Pn[1]-Po[1];
346 float dz = Pn[2]-Po[2];
347 float st = std::sqrt(dx*dx+dy*dy+dz*dz);
348 if(st <=0.)
continue;
350 float A[3]= {dx*ds,dy*ds,dz*ds};
355 for (; n1 < (int)layer[1].size(); ++n1) {
357 if (Pn[3] < layer[1][n1].
r())
359 assert(
used.at(1).size() >
static_cast<unsigned int>(n1));
360 layer[1][n1].getBarrelDetElementsATL(Po,
A, lDE,
used[1][n1]);
363 for (--n1; n1 >= 0; --n1) {
364 if (Pn[3] > layer[1][n1].
r())
366 assert(
used.at(1).size() >
static_cast<unsigned int>(n1));
367 layer[1][n1].getBarrelDetElementsATL(Po,
A, lDE,
used[1][n1]);
376 for (; n2 < (int)layer[2].size(); ++n2) {
377 if (Pn[2] < layer[2][n2].
z())
379 assert(
used.at(2).size() >
static_cast<unsigned int>(n2));
380 layer[2][n2].getEndcapDetElements(Po,
A, lDE,
used[2][n2]);
383 for (--n2; n2 >= 0; --n2) {
384 if (Pn[2] > layer[2][n2].
z())
386 assert(
used.at(2).size() >
static_cast<unsigned int>(n2));
387 layer[2][n2].getEndcapDetElements(Po,
A, lDE,
used[2][n2]);
396 for (; n0 < (int)layer[0].size(); ++n0) {
397 if (Pn[2] > layer[0][n0].
z())
399 assert(
used.at(0).size() >
static_cast<unsigned int>(n0));
400 layer[0][n0].getEndcapDetElements(Po,
A, lDE,
used[0][n0]);
403 for (--n0; n0 >= 0; --n0) {
404 if (Pn[2] < layer[0][n0].
z())
406 assert(
used.at(0).size() >
static_cast<unsigned int>(n0));
407 layer[0][n0].getEndcapDetElements(Po,
A, lDE,
used[0][n0]);
420 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> >
::iterator l=lDE.begin(),le=lDE.end(),n,m;
427 for(++n; n!=le; ++n) {
429 if( (*m).second > (*n).second ) {
430 std::pair<const InDet::TRT_DetElementLink_xk*,float> d=(*m); (*m)=(*n); (*n)=d; nc=
true;
438 for(l=lDE.begin(); l!=le; ++l) {
439 Road.push_back((*l).first->detElement());
449(std::deque<Amg::Vector3D>& GP,
450 std::vector<const InDetDD::TRT_BaseElement*>& Road,
452 const EventContext& ctx)
const
455 std::deque<Amg::Vector3D>::iterator g=GP.begin(),ge=GP.end();
457 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(ctx);
459 float Po[6] = {float((*g).x()),float((*g).y()),float((*g).z()),
460 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y())),
m_width,0.};
462 for(; n1!=(int)layer[1].size(); ++n1) {
if(Po[3] < layer[1][n1].
r())
break;}
464 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> > lDE;
465 for (
unsigned int module_i = 0; module_i < 3; ++module_i) {
466 size_t layersSize = layer[module_i].size();
468 used[module_i].resize(layersSize);
469 for (
unsigned int layer_i = 0; layer_i < layersSize; ++layer_i) {
472 used[module_i][layer_i].clear();
474 used[module_i][layer_i].resize(layer[module_i][layer_i].nElements());
478 for(++g; g!=ge; ++g) {
480 float Pn[4] = {float((*g).x()),float((*g).y()),float((*g).z()),
481 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y()))};
483 float dx = Pn[0]-Po[0];
484 float dy = Pn[1]-Po[1];
485 float dz = Pn[2]-Po[2];
486 float st = std::sqrt(dx*dx+dy*dy+dz*dz);
488 float A[3]= {dx*ds,dy*ds,dz*ds};
493 for(; n1<(int)layer[1].size(); ++n1) {
494 if(Pn[3] < layer[1][n1].
r())
break;
495 assert(
used.at(1).size() >
static_cast<unsigned int>(n1) );
496 layer[1][n1].getBarrelDetElementsCTB(Po,
A,lDE,
used[1][n1]);
500 for(--n1; n1>=0; --n1) {
501 if(Pn[3] > layer[1][n1].
r())
break;
502 layer[1][n1].getBarrelDetElementsCTB(Po,
A,lDE,
used[1][n1]);
510 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*, float> >
::iterator l=lDE.begin(),le=lDE.end(),n;
517 for(++n; n!=le; ++n) {
519 if( (*l).second > (*n).second ) {
520 std::pair<const InDet::TRT_DetElementLink_xk*,float> d = (*l); (*l) = (*n); (*n) = d;
529 for(l=lDE.begin(); l!=le; ++l) {
530 Road.push_back((*l).first->detElement());
543 double D =
a.x()*
A.x()+
a.y()*
A.y()+
a.z()*
A.z();
if(D==0.)
return D;
544 return ((
A.x()*(R.x()-
r.x())+
A.y()*(R.y()-
r.y())+
A.z()*(R.z()-
r.z()))/D);
554 const double cor = 0.8;
561 zfield = 299.7925*f[2];
566 if( std::abs(zfield) < .0000001 )
return bounds;
570 double cur = zfield*Vp[4]/std::sin(Vp[3]);
572 if( std::abs(cur)*bounds.
r() < cor )
return bounds;
575 if(cor*std::abs(rad) > bounds.
r() )
return bounds;
578 double sn,cs; sincos(Vp[2],&sn,&cs);
579 double xc = Gp.x()+sn*rad ;
580 double yc = Gp.y()-cs*rad ;
581 double rm = (std::sqrt(xc*xc+yc*yc)+std::abs(rad))*cor;
582 if( rm > bounds.
r() )
return bounds;
#define ATH_CHECK
Evaluate an expression and check for errors.
static const Attributes_t empty
bool msgLvl(const MSG::Level lvl) const
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Virtual base class of TRT readout elements.
virtual const Amg::Vector3D & normal() const override final
Element Surface: normal of a straw layer.
virtual const Amg::Vector3D & center() const override final
Element Surface: center of a straw layer.
std::array< std::vector< std::vector< Used_t > >, 3 > TRT_DetElemUsedMap
static double stepToDetElement(const InDetDD::TRT_BaseElement *&, Amg::Vector3D &, Amg::Vector3D &)
double getTRTMinR(const EventContext &ctx) const
virtual StatusCode finalize() override
static MsgStream & dumpEvent(MsgStream &out, int size_road)
void detElementsRoadATL(std::deque< Amg::Vector3D > &, std::vector< const InDetDD::TRT_BaseElement * > &, InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap &used, const EventContext &ctx) const
MsgStream & dumpConditions(MsgStream &out) const
virtual ~TRT_DetElementsRoadMaker_xk()
Trk::MagneticFieldMode m_fieldModeEnum
TRT_DetElementsRoadMaker_xk(const std::string &, const std::string &, const IInterface *)
StringProperty m_fieldmode
virtual MsgStream & dump(MsgStream &out) const override
SG::ReadCondHandleKey< TRT_DetElementsRoadData_xk > m_roadDataKey
Trk::CylinderBounds getBound(MagField::AtlasFieldCache &fieldCache, const Trk::TrackParameters &, const EventContext &ctx) const
void detElementsRoadCTB(std::deque< Amg::Vector3D > &, std::vector< const InDetDD::TRT_BaseElement * > &, InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap &used, const EventContext &ctx) const
virtual StatusCode initialize() override
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
PublicToolHandle< Trk::IPropagator > m_proptool
const TRT_DetElementsLayerVectors_xk * getLayers(const EventContext &ctx) const
virtual std::vector< const InDetDD::TRT_BaseElement * > detElementsRoad(const EventContext &ctx, MagField::AtlasFieldCache &fieldCache, const Trk::TrackParameters &Tp, Trk::PropDirection D, InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap &used) const override
const Trk::CylinderBounds get_bounds(const EventContext &ctx) const
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
bool solenoidOn() const
status of the magnets
void getFieldZR(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field valaue on the z-r plane at given position works only inside the solenoid.
Bounds for a cylindrical Surface.
virtual double r() const override final
This method returns the radius.
double halflengthZ() const
This method returns the halflengthZ.
magnetic field properties to steer the behavior of the extrapolation
MagneticFieldMode magneticFieldMode() const
Returns the MagneticFieldMode as specified.
holding In fact this class is here in order to allow STL container for all features This class is sho...
Eigen::Matrix< double, 3, 1 > Vector3D
PropDirection
PropDirection, enum for direction of the propagation.
MagneticFieldMode
MagneticFieldMode describing the field setup within a volume.
@ FastField
call the fast field access method of the FieldSvc
@ NoField
Field is set to 0., 0., 0.,.
@ FullField
Field is set to be realistic, but within a given Volume.
ParametersBase< TrackParametersDim, Charged > TrackParameters
hold the test vectors and ease the comparison