19 #include "GaudiKernel/ContextSpecificPtr.h"
35 (
const std::string&
t,
const std::string&
n,
const IInterface*
p)
55 ATH_MSG_FATAL(
"Please don't call this tool if usePixel and useSCT are false");
56 return StatusCode::FAILURE;
76 return StatusCode::SUCCESS;
85 return StatusCode::SUCCESS;
107 for (
int i=0;
i<
n; ++
i) s1.append(
" ");
110 std::string fieldmode[9] = {
"NoField" ,
"ConstantField",
"SolenoidalField",
111 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
112 "UndefinedField",
"AthenaField" ,
"?????" };
127 if (mode<0 || mode>8)
mode = 8;
129 n = 62-fieldmode[
mode].size();
131 for (
int i=0;
i<
n; ++
i)
s3.append(
" ");
136 for (
int i=0;
i<
n; ++
i) s5.append(
" ");
141 for (
int i=0;
i<
n; ++
i) s6.append(
" ");
144 const EventContext& ctx = Gaudi::Hive::currentContext();
152 out<<
"|----------------------------------------------------------------------"
153 <<
"-------------------|"
156 out<<
"| SCT detector manager | "<<
m_sct <<s5<<
"\n";
159 out<<
"| Pixel detector manager | "<<
m_pix <<s6<<
"\n";
161 out<<
"| Tool for propagation | "<<
m_proptool.type() <<s1<<
"\n";
162 out<<
"| Magnetic field mode | "<<fieldmode[
mode] <<
s3<<
"\n";
163 out<<
"| Width of the road (mm) | "
164 <<std::setw(12)<<std::setprecision(5)<<
m_width
166 out<<
"|----------------------------------------------------------------------"
167 <<
"-------------------|"
173 int nl =
layer[1].size();
175 for (
const auto &
i :
layer[1])
nc+=
i.nElements();
176 out<<
"|----------------------------------------------------------------|"
178 out<<
"| Barrel map containt "
179 <<std::setw(3)<<nl<<
" layers and"
180 <<std::setw(5)<<
nc<<
" elements |"
182 out<<
"|------|-----------|------------|------------|------------|------|"
184 out<<
"| n | R | Z min | Z max | max dF | nEl |"
186 out<<
"|------|-----------|------------|------------|------------|------|"
188 for (
unsigned int i=0;
i!=
layer[1].size(); ++
i) {
192 <<std::setw(4)<<
i<<
" |"
193 <<std::setw(10)<<std::setprecision(4)<<
layer[1].at(
i).r ()<<
" | "
194 <<std::setw(10)<<std::setprecision(4)<<
zmin<<
" | "
195 <<std::setw(10)<<std::setprecision(4)<<
zmax<<
" | "
196 <<std::setw(10)<<std::setprecision(4)<<
layer[1].at(
i).dfe()<<
" | "
197 <<std::setw(4)<<
layer[1].at(
i).nElements()<<
" | "
200 out<<
"|------|-----------|------------|------------|------------|------|"
205 int nl =
layer[0].size();
207 for (
const auto &
i :
layer[0])
nc+=
i.nElements();
208 out<<
"|----------------------------------------------------------------|"
210 out<<
"| L.Endcap map containt"
211 <<std::setw(3)<<nl<<
" layers and"
212 <<std::setw(5)<<
nc<<
" elements |"
215 out<<
"|------|-----------|------------|------------|------------|------|"
217 out<<
"| n | Z | R min | R max | max dF | nEl |"
219 out<<
"|------|-----------|------------|------------|------------|------|"
221 for (
unsigned int i=0;
i!=
layer[0].size(); ++
i) {
225 <<std::setw(4)<<
i<<
" |"
226 <<std::setw(10)<<std::setprecision(4)<<
layer[0].at(
i).z()<<
" | "
227 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
228 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
229 <<std::setw(10)<<std::setprecision(4)<<
layer[0].at(
i).dfe()<<
" | "
230 <<std::setw(4)<<
layer[0].at(
i).nElements()<<
" | "
233 out<<
"|------|-----------|------------|------------|------------|------|"
237 int nl =
layer[2].size();
239 for (
const auto &
i :
layer[2])
nc+=
i.nElements();
240 out<<
"|----------------------------------------------------------------|"
242 out<<
"| R.Endcap map containt"
243 <<std::setw(3)<<nl<<
" layers and"
244 <<std::setw(5)<<
nc<<
" elements |"
246 out<<
"|------|-----------|------------|------------|------------|------|"
248 out<<
"| n | Z | R min | R max | max dF | nEl |"
250 out<<
"|------|-----------|------------|------------|------------|------|"
252 for (
unsigned int i=0;
i!=
layer[2].size(); ++
i) {
256 <<std::setw(4)<<
i<<
" |"
257 <<std::setw(10)<<std::setprecision(4)<<
layer[2].at(
i).z()<<
" | "
258 <<std::setw(10)<<std::setprecision(4)<< rmin<<
" | "
259 <<std::setw(10)<<std::setprecision(4)<< rmax<<
" | "
260 <<std::setw(10)<<std::setprecision(4)<<
layer[2].at(
i).dfe()<<
" | "
261 <<std::setw(4)<<
layer[2].at(
i).nElements()<<
" | "
264 out<<
"|------|-----------|------------|------------|------------|------|"
284 MsgStream& InDet::operator <<
294 std::ostream& InDet::operator <<
306 (std::deque<Amg::Vector3D>& globalPositions,
307 std::vector<const InDetDD::SiDetectorElement*>& Road,
310 const EventContext& ctx)
const
332 std::array<float,6> par_startingPoint{
static_cast<float>((*currentPosition).x()),
333 static_cast<float>((*currentPosition).y()),
334 static_cast<float>((*currentPosition).z()),
335 static_cast<float>(sqrt((*currentPosition).x()*(*currentPosition).x()+(*currentPosition).y()*(*currentPosition).y())),
343 for (; n0!=
static_cast<int>(
layer[0].size()); ++n0) {
344 if (par_startingPoint[2] >
layer[0][n0].
z())
break;
351 for (;
n1!=
static_cast<int>(
layer[1].size()); ++
n1) {
352 if (par_startingPoint[3] <
layer[1][
n1].
r())
break;
357 for (; n2!=
static_cast<int>(
layer[2].size()); ++n2) {
358 if (par_startingPoint[2] <
layer[2][n2].
z())
break;
375 std::vector<InDet::SiDetElementLink_xk::ElementWay> lDE;
379 while (currentPosition!=endPositions) {
381 std::array<float,4> par_targetPoint{
static_cast<float>((*currentPosition).x()),
382 static_cast<float>((*currentPosition).y()),
383 static_cast<float>((*currentPosition).z()),
384 static_cast<float>(sqrt((*currentPosition).x()*(*currentPosition).x()+(*currentPosition).y()*(*currentPosition).y()))
388 float dx = par_targetPoint[0]-par_startingPoint[0];
389 float dy = par_targetPoint[1]-par_startingPoint[1];
390 float dz = par_targetPoint[2]-par_startingPoint[2];
391 float dist3D = std::sqrt(
dx*
dx+
dy*
dy+dz*dz);
396 float inverseDistance = 1./dist3D;
397 std::array<float,3> searchDirection{
dx*inverseDistance,
dy*inverseDistance, dz*inverseDistance};
403 float unitSepTransverseComp = searchDirection[0]*searchDirection[0]+searchDirection[1]*searchDirection[1];
405 if (unitSepTransverseComp!=0.) {
408 float sm = -( searchDirection[0]*par_startingPoint[0] +
409 searchDirection[1]*par_startingPoint[1])
410 /unitSepTransverseComp;
417 if (sm > 1. && sm < dist3D) {
418 par_targetPoint[0] = par_startingPoint[0]+searchDirection[0]*sm;
419 par_targetPoint[1] = par_startingPoint[1]+searchDirection[1]*sm;
420 par_targetPoint[2] = par_startingPoint[2]+searchDirection[2]*sm;
421 par_targetPoint[3] = std::sqrt(par_targetPoint[0]*par_targetPoint[0]+par_targetPoint[1]*par_targetPoint[1]);
437 if (par_targetPoint[3]>par_startingPoint[3]) {
439 for (; n1<static_cast<int>(
layer[1].
size()); ++
n1) {
441 if (par_targetPoint[3] <
layer[1][
n1].
r())
break;
451 if (par_targetPoint[3] >
layer[1][
n1].
r()+
dr)
break;
463 if (par_targetPoint[2]>par_startingPoint[2]) {
464 for (; n2<static_cast<int>(
layer[2].
size()); ++n2) {
465 if (par_targetPoint[2] <
layer[2][n2].
z())
break;
469 else layer[2][n2].getEndcapDetElements(par_startingPoint, searchDirection, lDE,roadMakerData.
elementUsageTracker[2][n2]);
472 for (--n2; n2>=0; --n2) {
473 if (par_targetPoint[2] >
layer[2][n2].
z())
break;
477 else layer[2][n2].getEndcapDetElements(par_startingPoint, searchDirection, lDE, roadMakerData.
elementUsageTracker[2][n2]);
484 if (par_targetPoint[2]<par_startingPoint[2]) {
485 for (; n0<static_cast<int>(
layer[0].
size()); ++n0) {
486 if (par_targetPoint[2] >
layer[0][n0].
z())
break;
490 else layer[0][n0].getEndcapDetElements(par_startingPoint, searchDirection, lDE,roadMakerData.
elementUsageTracker[0][n0]);
493 for (--n0; n0>=0; --n0) {
494 if (par_targetPoint[2] <
layer[0][n0].
z())
break;
498 else layer[0][n0].getEndcapDetElements(par_startingPoint, searchDirection, lDE,roadMakerData.
elementUsageTracker[0][n0]);
503 par_startingPoint[0] = par_targetPoint[0];
504 par_startingPoint[1] = par_targetPoint[1];
505 par_startingPoint[2] = par_targetPoint[2];
506 par_startingPoint[3] = par_targetPoint[3];
508 par_startingPoint[5]+= dist3D;
513 Road.reserve(lDE.size());
514 for (
auto &
d : lDE){
515 if (testDirection &&
d.way() < 0) {
continue;}
516 Road.push_back(
d.link()->detElement());
525 for (
unsigned int side_i=0; side_i<3; ++side_i) {
527 for (
unsigned int layer_i=0; layer_i <
layers[side_i].size(); ++layer_i) {
529 data.elementUsageTracker[side_i][layer_i].resize(
layers[side_i][layer_i].nElements() );
532 data.isInitialized=
true;
540 (
const EventContext& ctx,
544 std::vector<const InDetDD::SiDetectorElement*>& Road,
549 double qp = fabs(500.*Tp.parameters()[4]);
551 if (qp < 1.
e-10) qp = 1.e-10;
555 if (
S > 1000. )
S = 1000. ;
557 bool testDirection =
true;
559 testDirection =
false;
569 std::deque<Amg::Vector3D>
G;
575 if (
G.size()<2)
return;
581 float r0 = (*currentPosition).x()*(*currentPosition).x()+(*currentPosition).y()*(*currentPosition).y();
583 while (currentPosition!=endPositions) {
584 nextPosition = currentPosition;
585 if (++nextPosition == endPositions)
break;
587 float r = (*nextPosition).x()*(*nextPosition).x()+(*nextPosition).y()*(*nextPosition).y();
591 currentPosition =
G.erase(currentPosition);
616 if (
sc.isFailure() || !pixmgr) {
627 if (
sc.isFailure() || !sctmgr) {
634 const SCT_ID* IDs =
nullptr;
645 if (!IDs && !IDp)
return;
647 InDetDD::SiDetectorElementCollection::const_iterator
s,
se;
648 std::vector<InDetDD::SiDetectorElement*> pW[3];
657 if ((*s)->isBarrel() ) pW[1].push_back((*
s));
658 else if ((*s)->center().z() > 0.) pW[2].push_back((*
s));
659 else pW[0].push_back((*
s));
670 if ((*s)->isBarrel() ) pW[1].push_back((*
s));
671 else if ((*s)->center().z() > 0.) pW[2].push_back((*
s));
672 else pW[0].push_back((*
s));
676 int nel = pW[0].size()+pW[1].size()+pW[2].size();
687 bool has[3] {
false,
false,
false};
689 for (
int N=0;
N!=3; ++
N) {
691 int im =
static_cast<int>(pW[
N].size()-1);
700 for (
int i = 0;
i<=
im; ++
i) {
703 if (
P[ 9] < mrmin[
N]) mrmin[
N] =
P[ 9];
704 if (
P[10] > mrmax[
N]) mrmax[
N] =
P[10];
705 if (
P[11] < mzmin[
N]) mzmin[
N] =
P[11];
706 if (
P[12] > mzmax[
N]) mzmax[
N] =
P[12];
712 if (fabs(
r-r0) > 10.) {
717 if (fabs(
z-
z0) > 10.) {
738 double zmi = +100000;
739 double zma = -100000;
740 double rma = -100000;
741 for (
int i=0;
i!=3; ++
i) {
743 if (mzmin[
i]<zmi) zmi=mzmin[
i];
744 if (mzmax[
i]>zma) zma=mzmax[
i];
745 if (mrmax[
i]>rma) rma=mrmax[
i];
749 double hz = fabs(zma);
750 if (
hz<fabs(zmi))
hz = fabs(zmi);
765 double D =
a.x()*
A.x()+
a.y()*
A.y()+
a.z()*
A.z();
766 if (D==0.)
return static_cast<float>(D);
767 return static_cast<float>((
A.x()*(R.x()-
r.x())+
A.y()*(R.y()-
r.y())+
A.z()*(R.z()-
r.z()))/D);
778 const double cor = 1.;
787 zfield = 299.7925*
f[2];
790 if (fabs(zfield) < .0000001)
return m_bounds;
792 const AmgVector(5)& Vp = Tp.parameters();
794 double cur = zfield*Vp[4]/
sin(Vp[3]);
804 sincos(Vp[2], &
S, &C);
806 double xc = Gp.x()+
S*
rad;
807 double yc = Gp.y()-C*
rad;
808 double rm = (sqrt(xc*xc+yc*yc)+fabs(
rad))*cor;