22 #include "CLHEP/Units/SystemOfUnits.h"
23 #define SYSTEM_OF_UNITS CLHEP
25 #include "GaudiKernel/SystemOfUnits.h"
26 #define SYSTEM_OF_UNITS Gaudi::Units
91 InDetProjFlags::InDetProjPartsFlags
parts;
116 double & u1,
double& u2 )
const;
123 const double& rmin,
const double& rmax,
127 const double& rmin,
const double& rmax,
128 const double&
zmin,
const double&
zmax,
134 const double& rmin,
const double& rmax,
135 const double&
zmin,
const double&
zmax )
const;
138 const double& rmin,
const double& rmax,
139 const double&
zmin,
const double&
zmax )
const;
152 double data_disttosurface_epsilon,
153 double barrel_inner_radius,
154 double barrel_outer_radius,
155 double barrel_posneg_z,
156 double endcap_surface_z,
157 double endcap_surface_length,
158 double endcap_inner_radius,
159 double endcap_outer_radius,
160 double endcap_zasr_innerradius,
161 double endcap_zasr_endcapz_begin,
162 double endcap_zasr_squeezefact,
200 InDetProjFlags::InDetProjPartsFlags oldparts =
m_d->
parts;
257 message(
"Unforeseen execution path encountered.");
277 clipPath(
path,resulting_subpaths,resulting_subpaths,resulting_subpaths,resulting_subpaths);
290 resulting_subpaths_barrelA.clear();
291 resulting_subpaths_barrelC.clear();
292 resulting_subpaths_endcapA.clear();
293 resulting_subpaths_endcapC.clear();
301 if (
path.size()<2 ) {
316 if (paths_clipped.empty()) {
328 if ( ( (enabled_brlA?1:0) + (enabled_brlC?1:0) + (enabled_ecA?1:0) + (enabled_ecC?1:0) ) == 1 ) {
330 resulting_subpaths_barrelA = paths_clipped;
336 resulting_subpaths_barrelC = paths_clipped;
342 resulting_subpaths_endcapA = paths_clipped;
348 resulting_subpaths_endcapC = paths_clipped;
359 Amg::SetVectorVector3D::const_iterator
it,
itE(paths_clipped.end());
360 for (
it = paths_clipped.begin();
it!=
itE;++
it) {
382 theclass->
message(
"movePoint1ToZPlaneAndPoint2 Error: Points have same z!!");
385 double s( (
z-
p1.z())/dz );
392 const double&
zmin,
const double&
zmax )
const
398 movePoint1ToZPlaneAndPoint2(
a,
b,
zmin);
400 movePoint1ToZPlaneAndPoint2(
b,
a,
zmax);
405 movePoint1ToZPlaneAndPoint2(
b,
a,
zmin);
407 movePoint1ToZPlaneAndPoint2(
a,
b,
zmax);
414 movePoint1ToZPlaneAndPoint2(
a,
b,
zmax);
419 movePoint1ToZPlaneAndPoint2(
b,
a,
zmax);
440 theclass->message(
"movePoint1ToInfiniteCylinderAndPoint2 Error: Points have same r!!");
443 double s((
r-p1r)/
dr);
451 double & u1,
double& u2 )
const
453 const double dx =
b.x()-
a.x();
454 const double dy =
b.y()-
a.y();
458 u1 = u2 = (
a.x()*
a.x()+
a.y()*
a.y() ==
r*
r ? 0.0 : 1.0e99 );
461 double B = 2.0*(
a.x()*
dx +
a.y()*
dy );
462 double C =
a.x()*
a.x()+
a.y()*
a.y() -
r*
r;
463 double D =
B*
B-4*
A*
C;
467 double sqrtD = sqrt(D);
468 u1 = 0.5 * ( -
B - sqrtD) /
A;
469 u2 = 0.5 * ( -
B + sqrtD) /
A;
482 const double& rmin,
const double& rmax,
500 const double ar2 =
a.x()*
a.x()+
a.y()*
a.y();
501 const double br2 =
b.x()*
b.x()+
b.y()*
b.y();
502 const double rmin2 = rmin*rmin;
504 if (ar2 <= rmin2 && br2 <= rmin2 ) {
511 if ( (
a.x()<=-rmax&&
b.x()<=-rmax) || (
a.x()>=rmax&&
b.x()>=rmax) || (
a.y()<=-rmax&&
b.y()<=-rmax)|| (
a.y()>=rmax&&
b.y()>=rmax) ) {
519 const double dx =
b.x()-
a.x();
520 const double dy =
b.y()-
a.y();
521 const double rmax2 = rmax*rmax;
522 if (
dx==0.0&&
dy==0.0) {
530 const double px = (
u <= 0 ?
a.x() : (
u >= 1 ?
b.x() :
a.x()+
u*
dx ) );
531 const double py = (
u <= 0 ?
a.y() : (
u >= 1 ?
b.y() :
a.y()+
u*
dy ) );
544 if (pr2>=rmin2&&ar2<=rmax2&&br2<=rmax2) {
554 if (ar2>rmax2||br2>rmax2) {
558 lineCircleIntersection(
a,
b,rmax,u1,u2);
561 theclass->message(
"This should never happen(1).");
574 b = asave+u2*(
b-asave);
587 lineCircleIntersection(
a,
b,rmin,u1,u2);
596 seg2_a=
a+u2*(seg2_b-
a);
615 const double& rmin,
const double& rmax,
616 const double&
zmin,
const double&
zmax,
644 if (!clipSegmentToInfiniteHollowCylinder(
a,
b,rmin,rmax,seg2_a,seg2_b)) {
670 const double& rmin,
const double& rmax,
671 const double&
zmin,
const double&
zmax )
const
682 if (rmin>=rmax||rmin<0||zmin>=
zmax) {
683 theclass->message(
"clipPathToHollowCylinder Error: Non-sensical cylinder parameters!");
686 const unsigned n=in.size();
692 std::vector<Amg::Vector3D >
v;
693 for (
unsigned i = 1;
i<
n; ++
i) {
698 if ( clipSegmentToHollowCylinder(
a,
b,rmin,rmax,
zmin,
zmax,seg2_a,seg2_b ) ) {
702 if (seg2_a!=seg2_b) {
711 if (
v.back() !=
a ) {
712 theclass->messageDebug(
"ERROR: Inconsistency found while building clip part");
718 if (seg2_a!=seg2_b) {
744 std::vector<Amg::Vector3D >
out(in);
748 if (
it->x()==0.0 &&
it->y()==0.0 ) {
749 theclass->message(
"ERROR: Point has x==0 and y==0. Ambiguous projection of point.");
754 s =
r / sqrt(
it->x()*
it->x()+
it->y()*
it->y() );
769 std::vector<Amg::Vector3D >
out(in);
781 const double& planeZ,
782 const double& planeRBegin,
783 const double& endcapZBegin,
784 const double& squeezeFactor )
786 if (
p.x()==0.0 &&
p.y()==0.0 ) {
787 VP1Msg::message(
"InDetProjHelper::transformECPointToZPlane_specialZtoR ERROR: "
788 "Point has x==0 and y==0. Ambiguous projection of point.");
792 const double r = planeRBegin + (fabs(
p.z())-endcapZBegin)/squeezeFactor;
793 const double s =
r / sqrt(
p.x()*
p.x()+
p.y()*
p.y() );
805 const double&
z )
const
807 std::vector<Amg::Vector3D >
out(in);
812 endcap_zasr_innerradius,
813 endcap_zasr_endcapz_begin,
814 endcap_zasr_squeezefact);
822 projectPath(
path,resulting_projs,resulting_projs,resulting_projs,resulting_projs);
835 resulting_projections_barrelA.clear();
836 resulting_projections_barrelC.clear();
837 resulting_projections_endcapA.clear();
838 resulting_projections_endcapC.clear();
846 if (
path.size()<2 ) {
855 clipPath(
path,paths_brlA, paths_brlC, paths_ecA,paths_ecC);
864 Amg::SetVectorVector3D::const_iterator
it,
itE;
867 itE = paths_brlA.end();
869 for (
it = paths_brlA.begin();
it!=
itE; ++
it )
872 for (
it = paths_brlA.begin();
it!=
itE; ++
it )
876 itE = paths_brlC.end();
878 for (
it = paths_brlC.begin();
it!=
itE; ++
it )
881 for (
it = paths_brlC.begin();
it!=
itE; ++
it )
885 itE = paths_ecA.end();
887 for (
it = paths_ecA.begin();
it!=
itE; ++
it )
890 for (
it = paths_ecA.begin();
it!=
itE; ++
it )
894 for (
it = paths_ecA.begin();
it!=
itE; ++
it )
899 for (
it = paths_ecA.begin();
it!=
itE; ++
it )
904 itE = paths_ecC.end();
906 for (
it = paths_ecC.begin();
it!=
itE; ++
it )
909 for (
it = paths_ecC.begin();
it!=
itE; ++
it )
913 for (
it = paths_ecC.begin();
it!=
itE; ++
it )
918 for (
it = paths_ecC.begin();
it!=
itE; ++
it )
930 PartsFlags touchedparts =
NoParts;
946 const double& rmin,
const double& rmax,
947 const double&
zmin,
const double&
zmax )
const
949 const double rmin2(rmin*rmin), rmax2(rmax*rmax);
951 std::vector<Amg::Vector3D >::const_iterator
it(
path.begin()),
itE(
path.end());
957 r2 =
it->x()*
it->x()+
it->y()*
it->y();