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,
166 m_d->theclass =
this;
168 m_d->surfacethickness = surfacethickness;
169 m_d->data_disttosurface_epsilon = data_disttosurface_epsilon;
170 m_d->barrel_inner_radius = barrel_inner_radius;
171 m_d->barrel_outer_radius = barrel_outer_radius;
172 m_d->barrel_posneg_z = barrel_posneg_z;
173 m_d->endcap_surface_z = endcap_surface_z;
174 m_d->endcap_surface_length = endcap_surface_length;
175 m_d->endcap_inner_radius = endcap_inner_radius;
176 m_d->endcap_outer_radius = endcap_outer_radius;
177 m_d->endcap_zasr_innerradius = endcap_zasr_innerradius;
178 m_d->endcap_zasr_endcapz_begin = endcap_zasr_endcapz_begin;
179 m_d->endcap_zasr_squeezefact = endcap_zasr_squeezefact;
182 m_d->covercyl_zmin = 0.0;
183 m_d->covercyl_zmax = 0.0;
184 m_d->covercyl_rmin = 0.0;
185 m_d->covercyl_rmax = 0.0;
198 if (
m_d->parts==newparts )
200 InDetProjFlags::InDetProjPartsFlags oldparts =
m_d->parts;
201 m_d->parts = newparts;
205 m_d->covercyl_zmin = 0.0;
206 m_d->covercyl_zmax = 0.0;
207 m_d->covercyl_rmin = 0.0;
208 m_d->covercyl_rmax = 0.0;
219 m_d->covercyl_zmin = -
m_d->endcap_surface_z - 0.5*
m_d->endcap_surface_length;
221 m_d->covercyl_zmin = -
m_d->barrel_posneg_z;
223 m_d->covercyl_zmin = 0.0;
225 m_d->covercyl_zmin =
m_d->barrel_posneg_z;
227 m_d->covercyl_zmin =
m_d->endcap_surface_z + 0.5*
m_d->endcap_surface_length + 1.0e99;
231 m_d->covercyl_zmax =
m_d->endcap_surface_z + 0.5*
m_d->endcap_surface_length;
233 m_d->covercyl_zmax =
m_d->barrel_posneg_z;
235 m_d->covercyl_zmax = 0.0;
237 m_d->covercyl_zmax = -
m_d->barrel_posneg_z;
239 m_d->covercyl_zmax = -
m_d->endcap_surface_z - 0.5*
m_d->endcap_surface_length - 1.0e99;
243 if (
m_d->covercyl_zmin >=
m_d->covercyl_zmax )
244 m_d->covercyl_zmin =
m_d->covercyl_zmax = 0;
247 m_d->covercyl_rmin = std::min(
m_d->barrel_inner_radius,
m_d->endcap_inner_radius);
248 m_d->covercyl_rmax = std::max(
m_d->barrel_outer_radius,
m_d->endcap_outer_radius);
251 m_d->covercyl_rmin =
m_d->barrel_inner_radius;
252 m_d->covercyl_rmax =
m_d->barrel_outer_radius;
254 m_d->covercyl_rmin =
m_d->endcap_inner_radius;
255 m_d->covercyl_rmax =
m_d->endcap_outer_radius;
257 message(
"Unforeseen execution path encountered.");
258 m_d->covercyl_rmin = 0;
259 m_d->covercyl_rmax = 0;
262 if (
m_d->covercyl_rmin >=
m_d->covercyl_rmax )
263 m_d->covercyl_rmin =
m_d->covercyl_rmax = 0;
277 clipPath(path,resulting_subpaths,resulting_subpaths,resulting_subpaths,resulting_subpaths);
288 messageVerbose(
"clipPath(..) called. Input path has "+QString::number(path.size())+
" points.");
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 ) {
312 m_d->clipPathToHollowCylinder( path, paths_clipped,
313 m_d->covercyl_rmin,
m_d->covercyl_rmax,
314 m_d->covercyl_zmin,
m_d->covercyl_zmax );
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) {
362 m_d->clipPathToHollowCylinder( *it, resulting_subpaths_barrelA,
m_d->barrel_inner_radius,
m_d->barrel_outer_radius, 0,
m_d->barrel_posneg_z );
364 m_d->clipPathToHollowCylinder( *it, resulting_subpaths_barrelC,
m_d->barrel_inner_radius,
m_d->barrel_outer_radius, -
m_d->barrel_posneg_z, 0 );
366 m_d->clipPathToHollowCylinder( *it, resulting_subpaths_endcapA,
m_d->endcap_inner_radius,
m_d->endcap_outer_radius,
367 m_d->endcap_surface_z -
m_d->endcap_surface_length * 0.5,
m_d->endcap_surface_z +
m_d->endcap_surface_length * 0.5 );
369 m_d->clipPathToHollowCylinder( *it, resulting_subpaths_endcapC,
m_d->endcap_inner_radius,
m_d->endcap_outer_radius,
370 -
m_d->endcap_surface_z -
m_d->endcap_surface_length * 0.5, -
m_d->endcap_surface_z +
m_d->endcap_surface_length * 0.5 );
380 double dx(p2.x()-p1.x()), dy(p2.y()-p1.y()), dz(p2.z()-p1.z());
382 theclass->message(
"movePoint1ToZPlaneAndPoint2 Error: Points have same z!!");
385 double s( (
z-p1.z())/dz );
392 const double& zmin,
const double& zmax )
const
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();
455 double A = dx*dx+dy*dy;
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) {
529 const double u = - (
a.y()*dy+
a.x()*dx)/(dx*dx+dy*dy);
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 ) );
532 const double pr2 = px*px+py*py;
544 if (pr2>=rmin2&&ar2<=rmax2&&br2<=rmax2) {
554 if (ar2>rmax2||br2>rmax2) {
561 theclass->message(
"This should never happen(1).");
574 b = asave+u2*(b-asave);
596 seg2_a=
a+u2*(seg2_b-
a);
615 const double& rmin,
const double& rmax,
616 const double& zmin,
const double& zmax,
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) {
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);
745 std::vector<Amg::Vector3D >::iterator it(out.begin()), itE(out.end());
747 for (;it!=itE;++it) {
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);
770 std::vector<Amg::Vector3D >::iterator it(out.begin()), itE(out.end());
771 for (;it!=itE;++it) {
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);
808 std::vector<Amg::Vector3D >::iterator it(out.begin()), itE(out.end());
822 projectPath(path,resulting_projs,resulting_projs,resulting_projs,resulting_projs);
833 messageVerbose(
"projectPath(..) called. Input path has "+QString::number(path.size())+
" points.");
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);
861 const double eps =
m_d->data_disttosurface_epsilon;
862 const double endcapeps(-5*SYSTEM_OF_UNITS::mm);
864 Amg::SetVectorVector3D::const_iterator it,itE;
867 itE = paths_brlA.end();
869 for ( it = paths_brlA.begin(); it!=itE; ++it )
870 m_d->projectPathToZPlane( *it, resulting_projections_barrelA, 0.5*
m_d->surfacethickness+eps );
872 for ( it = paths_brlA.begin(); it!=itE; ++it )
873 m_d->projectPathToZPlane( *it, resulting_projections_barrelA,
m_d->barrel_posneg_z - eps );
876 itE = paths_brlC.end();
878 for ( it = paths_brlC.begin(); it!=itE; ++it )
879 m_d->projectPathToZPlane( *it, resulting_projections_barrelC, - 0.5*
m_d->surfacethickness - eps);
881 for ( it = paths_brlC.begin(); it!=itE; ++it )
882 m_d->projectPathToZPlane( *it, resulting_projections_barrelC, -
m_d->barrel_posneg_z );
885 itE = paths_ecA.end();
887 for ( it = paths_ecA.begin(); it!=itE; ++it )
888 m_d->projectPathToInfiniteCylinder( *it, resulting_projections_endcapA,
m_d->endcap_inner_radius + eps+endcapeps );
890 for ( it = paths_ecA.begin(); it!=itE; ++it )
891 m_d->projectPathToInfiniteCylinder( *it, resulting_projections_endcapA,
m_d->endcap_outer_radius + eps+endcapeps );
894 for ( it = paths_ecA.begin(); it!=itE; ++it )
895 m_d->projectPathToZPlane_specialZtoR( *it, resulting_projections_endcapA,
896 0.5*
m_d->surfacethickness + eps );
899 for ( it = paths_ecA.begin(); it!=itE; ++it )
900 m_d->projectPathToZPlane_specialZtoR( *it, resulting_projections_endcapA,
901 m_d->barrel_posneg_z - 0.5*
m_d->surfacethickness - eps );
904 itE = paths_ecC.end();
906 for ( it = paths_ecC.begin(); it!=itE; ++it )
907 m_d->projectPathToInfiniteCylinder( *it, resulting_projections_endcapC,
m_d->endcap_inner_radius + eps+endcapeps );
909 for ( it = paths_ecC.begin(); it!=itE; ++it )
910 m_d->projectPathToInfiniteCylinder( *it, resulting_projections_endcapC,
m_d->endcap_outer_radius + eps+endcapeps );
913 for ( it = paths_ecC.begin(); it!=itE; ++it )
914 m_d->projectPathToZPlane_specialZtoR( *it, resulting_projections_endcapC,
915 - 0.5*
m_d->surfacethickness - eps );
918 for ( it = paths_ecC.begin(); it!=itE; ++it )
919 m_d->projectPathToZPlane_specialZtoR( *it, resulting_projections_endcapC,
920 -
m_d->barrel_posneg_z + 0.5*
m_d->surfacethickness + eps );
929 messageVerbose(
"touchedParts(..) called. Input path has "+QString::number(path.size())+
" points.");
930 PartsFlags touchedparts =
NoParts;
931 if (
m_d->touchesHollowCylinder(path,
m_d->barrel_inner_radius,
m_d->barrel_outer_radius, 0,
m_d->barrel_posneg_z) )
933 if (
m_d->touchesHollowCylinder(path,
m_d->barrel_inner_radius,
m_d->barrel_outer_radius, -
m_d->barrel_posneg_z, 0) )
935 if (
m_d->touchesHollowCylinder(path,
m_d->endcap_inner_radius,
m_d->endcap_outer_radius,
936 m_d->endcap_surface_z -
m_d->endcap_surface_length * 0.5,
m_d->endcap_surface_z +
m_d->endcap_surface_length * 0.5 ) )
938 if (
m_d->touchesHollowCylinder(path,
m_d->endcap_inner_radius,
m_d->endcap_outer_radius,
939 -
m_d->endcap_surface_z -
m_d->endcap_surface_length * 0.5, -
m_d->endcap_surface_z +
m_d->endcap_surface_length * 0.5) )
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());
952 for (;it!=itE;++it) {
957 r2 = it->x()*it->x()+it->y()*it->y();
void clipPathToHollowCylinder(const std::vector< Amg::Vector3D > &in, Amg::SetVectorVector3D &out, const double &rmin, const double &rmax, const double &zmin, const double &zmax) const
bool clipSegmentToInfiniteHollowCylinder(Amg::Vector3D &a, Amg::Vector3D &b, const double &rmin, const double &rmax, Amg::Vector3D &seg2_a, Amg::Vector3D &seg2_b) const
bool clipSegmentToZInterval(Amg::Vector3D &a, Amg::Vector3D &b, const double &zmin, const double &zmax) const
InDetProjFlags::InDetProjPartsFlags parts
void movePoint1ToZPlaneAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &z) const
double endcap_inner_radius
bool clipSegmentToHollowCylinder(Amg::Vector3D &a, Amg::Vector3D &b, const double &rmin, const double &rmax, const double &zmin, const double &zmax, Amg::Vector3D &seg2_a, Amg::Vector3D &seg2_b) const
void projectPathToInfiniteCylinder(const std::vector< Amg::Vector3D > &in, Amg::SetVectorVector3D &outset, const double &r) const
double endcap_zasr_endcapz_begin
double endcap_zasr_squeezefact
double data_disttosurface_epsilon
bool touchesHollowCylinder(const std::vector< Amg::Vector3D > &path, const double &rmin, const double &rmax, const double &zmin, const double &zmax) const
void projectPathToZPlane_specialZtoR(const std::vector< Amg::Vector3D > &in, Amg::SetVectorVector3D &outset, const double &z) const
double barrel_inner_radius
void movePoint1ToInfiniteCylinderAndPoint2(Amg::Vector3D &p1, const Amg::Vector3D &p2, const double &r) const
double barrel_outer_radius
void lineCircleIntersection(const Amg::Vector3D &a, const Amg::Vector3D &b, const double &r, double &u1, double &u2) const
double endcap_outer_radius
double endcap_surface_length
InDetProjHelper * theclass
double endcap_zasr_innerradius
void projectPathToZPlane(const std::vector< Amg::Vector3D > &in, Amg::SetVectorVector3D &outset, const double &z) const
static InDetProjHelper * createTRTHelper(IVP1System *sys=0)
static InDetProjHelper * createPixelHelper(IVP1System *sys=0)
static void transformECPointToZPlane_specialZtoR(Amg::Vector3D &p, const double &planeZ, const double &planeRBegin, const double &endcapZBegin, const double &squeezeFactor)
InDetProjFlags::InDetProjPartsFlags setParts(InDetProjFlags::InDetProjPartsFlags)
InDetProjFlags::InDetProjPartsFlags parts() const
static InDetProjHelper * createSCTHelper(IVP1System *sys=0)
virtual ~InDetProjHelper()
PartsFlags touchedParts(const std::vector< Amg::Vector3D > &path) const
InDetProjHelper(double surfacethickness, double data_disttosurface_epsilon, double barrel_inner_radius, double barrel_outer_radius, double barrel_posneg_z, double endcap_surface_z, double endcap_surface_length, double endcap_inner_radius, double endcap_outer_radius, double endcap_zasr_innerradius, double endcap_zasr_endcapz_begin, double endcap_zasr_squeezefact, IVP1System *sys)
void clipPath(const std::vector< Amg::Vector3D > &path, Amg::SetVectorVector3D &resulting_subpaths) const
void projectPath(const std::vector< Amg::Vector3D > &path, Amg::SetVectorVector3D &resulting_projections) const
static double sct_barrel_inner_radius()
static double trt_endcap_surface_z()
static double sct_endcap_zasr_squeezefact()
static double trt_barrel_posneg_z()
static double sct_endcap_surface_z()
static double sct_endcap_zasr_innerradius()
static double pixel_endcap_outer_radius()
static double trt_endcap_inner_radius()
static double trt_endcap_surface_length()
static double sct_endcap_surface_length()
static double sct_endcap_outer_radius()
static double trt_endcap_zasr_squeezefact()
static double pixel_barrel_outer_radius()
static double sct_barrel_posneg_z()
static double surfacethickness()
static double pixel_data_disttosurface_epsilon()
static double pixel_barrel_posneg_z()
static double pixel_endcap_inner_radius()
static double trt_barrel_outer_radius()
static double pixel_endcap_zasr_endcapz_begin()
static double trt_endcap_zasr_endcapz_begin()
static double trt_data_disttosurface_epsilon()
static double trt_endcap_outer_radius()
static double pixel_endcap_zasr_squeezefact()
static double pixel_barrel_inner_radius()
static double pixel_endcap_surface_length()
static double pixel_endcap_surface_z()
static double sct_data_disttosurface_epsilon()
static double sct_endcap_zasr_endcapz_begin()
static double sct_endcap_inner_radius()
static double pixel_endcap_zasr_innerradius()
static double sct_barrel_outer_radius()
static double trt_endcap_zasr_innerradius()
static double trt_barrel_inner_radius()
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
void messageVerbose(const QString &) const
void message(const QString &) const
static void message(const QString &, IVP1System *sys=0)
void setVector3DCartesian(Amg::Vector3D &v1, double x1, double y1, double z1)
Sets components in cartesian coordinate system.
double rVector3D(const Amg::Vector3D &v1)
Gets r-component in spherical coordinate system.
std::set< std::vector< Amg::Vector3D >, VectorVector3DComparer > SetVectorVector3D
Eigen::Matrix< double, 3, 1 > Vector3D
hold the test vectors and ease the comparison