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;
99 std::string s1;
for(
int i=0; i<n; ++i) s1.append(
" "); s1.append(
"|");
101 std::string fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
102 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
103 "UndefinedField",
"AthenaField" ,
"?????" };
115 if(mode<0 || mode>8 ) mode = 8;
117 n = 62-fieldmode[mode].size();
118 std::string s3;
for(
int i=0; i<n; ++i) s3.append(
" "); s3.append(
"|");
120 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(Gaudi::Hive::currentContext());
123 if(!layer[0].
empty()) ++maps;
124 if(!layer[1].
empty()) ++maps;
125 if(!layer[2].
empty()) ++maps;
127 out<<
"|----------------------------------------------------------------------"
128 <<
"-------------------|"
130 out<<
"| Tool for propagation | "<<
m_proptool.type()<<s1<<std::endl;
131 out<<
"| Magnetic field mode | "<<fieldmode[mode]<<s3<<std::endl;
132 out<<
"| Width of the road (mm) | "
133 <<std::setw(12)<<std::setprecision(5)<<
m_width
135 out<<
"|----------------------------------------------------------------------"
136 <<
"-------------------|"
139 if(!maps || !
msgLvl(MSG::VERBOSE))
return out;
141 if(!layer[1].
empty()) {
142 int nl = layer[1].size();
144 for(
const auto & i : layer[1]) nc+=i.nElements();
145 out<<
"|----------------------------------------------------------------|"
147 out<<
"| Barrel map containt "
148 <<std::setw(4)<<nl<<
" layers and "
149 <<std::setw(6)<<nc<<
" elements |"
151 out<<
"|------|-----------|------------|------------|------------|------|"
153 out<<
"| n | R | Z min | Z max | max dF | nEl |"
155 out<<
"|------|-----------|------------|------------|------------|------|"
157 for(
unsigned int i=0; i!=layer[1].size(); ++i) {
158 float zmin = layer[1][i].z()-layer[1][i].dz();
159 float zmax = layer[1][i].z()+layer[1][i].dz();
161 <<std::setw(4)<<i<<
" |"
162 <<std::setw(10)<<std::setprecision(4)<< layer[1][i].r ()<<
" | "
163 <<std::setw(10)<<std::setprecision(4)<< zmin<<
" | "
164 <<std::setw(10)<<std::setprecision(4)<< zmax<<
" | "
165 <<std::setw(10)<<std::setprecision(4)<< layer[1][i].dfe()<<
" | "
166 <<std::setw(4)<<layer[1][i].nElements()<<
" | "
169 out<<
"|------|-----------|------------|------------|------------|------|"
173 if(!layer[0].
empty()) {
175 int nl = layer[0].size();
177 for(
const auto & i : layer[0]) nc+=i.nElements();
178 out<<
"|----------------------------------------------------------------|"
180 out<<
"| L.Endcap map containt "
181 <<std::setw(4)<<nl<<
" layers and "
182 <<std::setw(6)<<nc<<
" elements |"
185 out<<
"|------|-----------|------------|------------|------------|------|"
187 out<<
"| n | Z | R min | R max | max dF | nEl |"
189 out<<
"|------|-----------|------------|------------|------------|------|"
191 for(
unsigned int i=0; i!=layer[0].size(); ++i) {
192 float rmin = layer[0][i].r()-layer[0][i].dr();
193 float rmax = layer[0][i].r()+layer[0][i].dr();
195 <<std::setw(4)<<i<<
" |"
196 <<std::setw(10)<<std::setprecision(4)<< layer[0][i].z()<<
" | "
197 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
198 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
199 <<std::setw(10)<<std::setprecision(4)<<layer[0][i].dfe()<<
" | "
200 <<std::setw(4)<<layer[0][i].nElements()<<
" | "
203 out<<
"|------|-----------|------------|------------|------------|------|"
206 if(!layer[2].
empty()) {
207 int nl = layer[2].size();
209 for(
const auto & i : layer[2]) nc+=i.nElements();
210 out<<
"|----------------------------------------------------------------|"
212 out<<
"| R.Endcap map containt "
213 <<std::setw(4)<<nl<<
" layers and "
214 <<std::setw(6)<<nc<<
" elements |"
216 out<<
"|------|-----------|------------|------------|------------|------|"
218 out<<
"| n | Z | R min | R max | max dF | nEl |"
220 out<<
"|------|-----------|------------|------------|------------|------|"
222 for(
unsigned int i=0; i!=layer[2].size(); ++i) {
223 float rmin = layer[2][i].r()-layer[0][i].dr();
224 float rmax = layer[2][i].r()+layer[0][i].dr();
226 <<std::setw(4)<<i<<
" |"
227 <<std::setw(10)<<std::setprecision(4)<< layer[2][i].z()<<
" | "
228 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
229 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
230 <<std::setw(10)<<std::setprecision(4)<<layer[2][i].dfe()<<
" | "
231 <<std::setw(4)<<layer[2][i].nElements()<<
" | "
234 out<<
"|------|-----------|------------|------------|------------|------|"
246 out<<
"|--------------------------------------------------------------------|"
248 out<<
"| Road size | "<<std::setw(12)<<size_road
250 out<<
"|--------------------------------------------------------------------|"
268std::vector<const InDetDD::TRT_BaseElement*>
270(
const EventContext& ctx,
275 double qp = std::abs(500.*
Tp.parameters()[4]) ;
276 if( qp < 1.e-10 ) qp = 1.e-10;
278 if( S > 200. ) S = 200. ;
282 std::vector<const InDetDD::TRT_BaseElement*>
result;
283 if( CB.r() > rminTRT) {
287 std::deque<Amg::Vector3D>
G;
303(std::deque<Amg::Vector3D>& GP,
304 std::vector<const InDetDD::TRT_BaseElement*>& Road,
306 const EventContext& ctx)
const
311 std::deque<Amg::Vector3D>::iterator g=GP.begin(),ge=GP.end();
313 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(ctx);
315 float Po[6] = {float((*g).x()),float((*g).y()),float((*g).z()),
316 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y())),
m_width,0.};
318 for(; n0!=(int)layer[0].size(); ++n0) {
if(Po[2] > layer[0][n0].
z())
break;}
319 for(; n1!=(int)layer[1].size(); ++n1) {
if(Po[3] < layer[1][n1].
r())
break;}
320 for(; n2!=(int)layer[2].size(); ++n2) {
if(Po[2] < layer[2][n2].
z())
break;}
322 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> > lDE;
323 for (
unsigned int module_i = 0; module_i < 3; ++module_i) {
324 size_t layersSize = layer[module_i].size();
326 used[module_i].resize(layersSize);
327 for (
unsigned int layer_i = 0; layer_i < layersSize; ++layer_i) {
330 used[module_i][layer_i].clear();
332 used[module_i][layer_i].resize(layer[module_i][layer_i].nElements());
336 for(++g; g!=ge; ++g) {
338 float Pn[4] = {float((*g).x()),float((*g).y()),float((*g).z()),
339 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y()))};
341 float dx = Pn[0]-Po[0];
342 float dy = Pn[1]-Po[1];
343 float dz = Pn[2]-Po[2];
344 float st = std::sqrt(dx*dx+dy*dy+dz*dz);
345 if(st <=0.)
continue;
347 float A[3]= {dx*ds,dy*ds,dz*ds};
352 for (; n1 < (int)layer[1].size(); ++n1) {
354 if (Pn[3] < layer[1][n1].
r())
356 assert(
used.at(1).size() >
static_cast<unsigned int>(n1));
357 layer[1][n1].getBarrelDetElementsATL(Po,
A, lDE,
used[1][n1]);
360 for (--n1; n1 >= 0; --n1) {
361 if (Pn[3] > layer[1][n1].
r())
363 assert(
used.at(1).size() >
static_cast<unsigned int>(n1));
364 layer[1][n1].getBarrelDetElementsATL(Po,
A, lDE,
used[1][n1]);
373 for (; n2 < (int)layer[2].size(); ++n2) {
374 if (Pn[2] < layer[2][n2].
z())
376 assert(
used.at(2).size() >
static_cast<unsigned int>(n2));
377 layer[2][n2].getEndcapDetElements(Po,
A, lDE,
used[2][n2]);
380 for (--n2; n2 >= 0; --n2) {
381 if (Pn[2] > layer[2][n2].
z())
383 assert(
used.at(2).size() >
static_cast<unsigned int>(n2));
384 layer[2][n2].getEndcapDetElements(Po,
A, lDE,
used[2][n2]);
393 for (; n0 < (int)layer[0].size(); ++n0) {
394 if (Pn[2] > layer[0][n0].
z())
396 assert(
used.at(0).size() >
static_cast<unsigned int>(n0));
397 layer[0][n0].getEndcapDetElements(Po,
A, lDE,
used[0][n0]);
400 for (--n0; n0 >= 0; --n0) {
401 if (Pn[2] < layer[0][n0].
z())
403 assert(
used.at(0).size() >
static_cast<unsigned int>(n0));
404 layer[0][n0].getEndcapDetElements(Po,
A, lDE,
used[0][n0]);
417 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> >
::iterator l=lDE.begin(),le=lDE.end(),n,m;
424 for(++n; n!=le; ++n) {
426 if( (*m).second > (*n).second ) {
427 std::pair<const InDet::TRT_DetElementLink_xk*,float> d=(*m); (*m)=(*n); (*n)=d; nc=
true;
435 for(l=lDE.begin(); l!=le; ++l) {
436 Road.push_back((*l).first->detElement());
446(std::deque<Amg::Vector3D>& GP,
447 std::vector<const InDetDD::TRT_BaseElement*>& Road,
449 const EventContext& ctx)
const
452 std::deque<Amg::Vector3D>::iterator g=GP.begin(),ge=GP.end();
454 const TRT_DetElementsLayerVectors_xk &layer = *
getLayers(ctx);
456 float Po[6] = {float((*g).x()),float((*g).y()),float((*g).z()),
457 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y())),
m_width,0.};
459 for(; n1!=(int)layer[1].size(); ++n1) {
if(Po[3] < layer[1][n1].
r())
break;}
461 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*,float> > lDE;
462 for (
unsigned int module_i = 0; module_i < 3; ++module_i) {
463 size_t layersSize = layer[module_i].size();
465 used[module_i].resize(layersSize);
466 for (
unsigned int layer_i = 0; layer_i < layersSize; ++layer_i) {
469 used[module_i][layer_i].clear();
471 used[module_i][layer_i].resize(layer[module_i][layer_i].nElements());
475 for(++g; g!=ge; ++g) {
477 float Pn[4] = {float((*g).x()),float((*g).y()),float((*g).z()),
478 float(std::sqrt((*g).x()*(*g).x()+(*g).y()*(*g).y()))};
480 float dx = Pn[0]-Po[0];
481 float dy = Pn[1]-Po[1];
482 float dz = Pn[2]-Po[2];
483 float st = std::sqrt(dx*dx+dy*dy+dz*dz);
485 float A[3]= {dx*ds,dy*ds,dz*ds};
490 for(; n1<(int)layer[1].size(); ++n1) {
491 if(Pn[3] < layer[1][n1].
r())
break;
492 assert(
used.at(1).size() >
static_cast<unsigned int>(n1) );
493 layer[1][n1].getBarrelDetElementsCTB(Po,
A,lDE,
used[1][n1]);
497 for(--n1; n1>=0; --n1) {
498 if(Pn[3] > layer[1][n1].
r())
break;
499 layer[1][n1].getBarrelDetElementsCTB(Po,
A,lDE,
used[1][n1]);
507 std::vector<std::pair<const InDet::TRT_DetElementLink_xk*, float> >
::iterator l=lDE.begin(),le=lDE.end(),n;
514 for(++n; n!=le; ++n) {
516 if( (*l).second > (*n).second ) {
517 std::pair<const InDet::TRT_DetElementLink_xk*,float> d = (*l); (*l) = (*n); (*n) = d;
526 for(l=lDE.begin(); l!=le; ++l) {
527 Road.push_back((*l).first->detElement());
540 double D =
a.x()*
A.x()+
a.y()*
A.y()+
a.z()*
A.z();
if(D==0.)
return D;
541 return ((
A.x()*(R.x()-
r.x())+
A.y()*(R.y()-
r.y())+
A.z()*(R.z()-
r.z()))/D);
551 const double cor = 0.8;
558 zfield = 299.7925*f[2];
563 if( std::abs(zfield) < .0000001 )
return bounds;
567 double cur = zfield*Vp[4]/std::sin(Vp[3]);
569 if( std::abs(cur)*bounds.
r() < cor )
return bounds;
572 if(cor*std::abs(rad) > bounds.
r() )
return bounds;
575 double sn,cs; sincos(Vp[2],&sn,&cs);
576 double xc = Gp.x()+sn*rad ;
577 double yc = Gp.y()-cs*rad ;
578 double rm = (std::sqrt(xc*xc+yc*yc)+std::abs(rad))*cor;
579 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