28 const std::vector<NavVolumeSide>& faces,
32 for (std::vector<NavVolumeSide>::const_iterator
i=faces.begin();
33 i != faces.end();
i++) {
35 i->globalFace(),
i->surfaceSide()));
46 theFaces(magvol.faces()), isThisIron(isIron)
48 std::vector<NavVolumeSide> navSides;
49 std::vector<VolumeSide> magSides( magvol.
faces());
52 for (std::vector<VolumeSide>::const_iterator
i=magSides.begin();
53 i != magSides.end();
i++) {
54 NavSurface* navSurface = navBuilder.build(
i->surface());
55 navSides.push_back(
NavVolumeSide( navSurface,
i->globalFace(),
i->surfaceSide()));
75 bool allPlanes =
true;
77 std::vector<const Plane*> planes;
78 for (std::vector<NavVolumeSide>::const_iterator iface=faces.begin(); iface!=faces.end(); iface++) {
79 const Plane* plane =
dynamic_cast<const Plane*
>(&(iface->surface()));
81 planes.push_back(plane);
83 else allPlanes =
false;
86 for (
unsigned int i=0;
i<faces.size();
i++) {
98 navSurf.
addVolume(
this, myBounds, faces[
i].surfaceSide());
111 const std::vector<const Plane*>& bpc)
113 const Plane* plane( bpc[index]);
116 int startIndex = 2*(1+index/2);
117 std::vector<const Plane*> crossed; crossed.reserve(4);
118 for (
int j = startIndex;
j < startIndex+4;
j++) {
119 crossed.push_back(bpc[
j%6]);
123 std::vector<GlobalPoint> corners; corners.reserve(4);
125 for (
int i=0;
i<2;
i++) {
126 for (
int j=2;
j<4;
j++) {
128 corners.push_back(corner);
131 std::cout <<
"Crossing of planes is " << corner << std::endl;
133 <<
" " << crossed[
i]->normalVector() <<
" " << crossed[
j]->normalVector() << std::endl;
135 <<
" " << crossed[
i]->position() <<
" " << crossed[
j]->position() << std::endl;
139 std::cout <<
"Crossing is really on all three surfaces" << std::endl;
142 std::cout <<
"CROSSING IS NOT ON SURFACES!!!" << std::endl;
144 std::cout << crossed[
i]->localZ(corner) << std::endl;
145 std::cout << crossed[
j]->localZ(corner) << std::endl;
163 int startIndex = 2*(1+index/2);
164 SurfaceContainer crossed; crossed.reserve(4);
165 for (
int j = startIndex;
j < startIndex+4;
j++) {
178 typedef std::map<double,SurfaceAndBounds> SortedContainer;
184 SortedContainer sortedSurfaces;
191 std::pair<bool,double> dist =
i->surface().distanceAlongLine( gpos, gdir);
193 if (dist.second > epsilon) sortedSurfaces[dist.second] = *
i;
194 else verycloseSurfaces.push_back(*
i);
196 else unreachableSurfaces.push_back(*
i);
199 for (SortedContainer::const_iterator
i=sortedSurfaces.begin();
i!=sortedSurfaces.end(); ++
i) {
200 result.push_back(
i->second);
202 result.insert( result.end(), unreachableSurfaces.begin(), unreachableSurfaces.end());
203 result.insert( result.end(), verycloseSurfaces.begin(), verycloseSurfaces.end());
213 typedef std::map<double,SurfaceAndBounds> SortedContainer;
219 SortedContainer sortedSurfaces;
224 bool surfaceMatched =
false;
227 if (&(
i->surface().surface()) == NotThisSurfaceP) surfaceMatched =
true;
231 std::pair<bool,double> dist =
i->surface().distanceAlongLine( gpos, gdir);
233 if ( &(
i->surface().surface()) == NotThisSurfaceP || (!surfaceMatched && dist.second < epsilon))
234 verycloseSurfaces.push_back(*
i);
235 else sortedSurfaces[dist.second] = *
i;
237 else unreachableSurfaces.push_back(*
i);
241 for (SortedContainer::const_iterator
i=sortedSurfaces.begin();
i!=sortedSurfaces.end(); ++
i) {
242 result.push_back(
i->second);
244 result.insert( result.end(), unreachableSurfaces.begin(), unreachableSurfaces.end());
245 result.insert( result.end(), verycloseSurfaces.begin(), verycloseSurfaces.end());
253 typedef std::pair<TSOS,double> TSOSwithPath;
261 for (NavVolume::Container::const_iterator isur = nsc.begin(); isur!=nsc.end(); isur++) {
263 LogDebug(
"NavGeometry") <<
"crossToNextVolume: trying Surface no. " << itry ;
267 state = isur->surface().propagateWithPath( prop, startingState);
270 LogDebug(
"NavGeometry") <<
"Ohoh... failed to stay inside magnetic field !! skip this surface " ;
275 if (!state.first.isValid()) {
280 LogDebug(
"NavGeometry") <<
"crossToNextVolume: reached Valid State at Surface no. " << itry ;
281 LogDebug(
"NavGeometry") <<
" --> local position of Valid state is " << state.first.localPosition() ;
282 LogDebug(
"NavGeometry") <<
" --> global position of Valid state is " << state.first.globalPosition() ;
284 if (isur->bounds().inside(state.first.localPosition())) {
294 state.first, state.second );
299 LogDebug(
"NavGeometry") <<
"crossToNextVolume: BUT not inside the Bounds !! " ;
304 return VolumeCrossResult;
virtual const Surface & surface() const =0
Access to actual surface.
bool inside(const GlobalPoint &gp, double tolerance) const
virtual Container nextSurface(const NavVolume::LocalPoint &pos, const NavVolume::LocalVector &mom, double charge, PropagationDirection propDir=alongMomentum) const
Give a sorted list of possible surfaces to propagate to.
GloballyPositioned< float >::GlobalPoint GlobalPoint
GlobalVector normalVector() const
float localZ(const GlobalPoint &gp) const
GlobalPoint globalPosition() const
const NavSurface & surface() const
helper: builde a NavSurface for a Surface
std::pair< const Surface *, SurfaceOrientation::Side > SurfaceAndSide
Plane::GlobalPoint crossing(const Plane &a, const Plane &b, const Plane &c) const
std::vector< SurfaceAndBounds > Container
virtual VolumeCrossReturnType crossToNextVolume(const TrajectoryStateOnSurface ¤tState, const Propagator &prop) const
Cross this volume and point at the next.
GloballyPositioned< float >::LocalPoint LocalPoint
GloballyPositioned< float >::LocalVector LocalVector
const SurfaceType & surface() const
LocalPoint toLocal(const GlobalPoint &gp) const
SurfaceOrientation::Side oppositeSide(SurfaceOrientation::Side side=SurfaceOrientation::onSurface)
NavVolume6Faces(const PositionType &pos, const RotationType &rot, DDSolidShape shape, const std::vector< NavVolumeSide > &faces, const MagneticFieldProvider< float > *mfp)
std::vector< SurfaceAndSide > SurfaceContainer
GlobalPoint toGlobal(const LocalPoint &lp) const
TrajectoryStateOnSurface TSOS
virtual const Bounds * bounds(const NavVolume *vol)=0
Bounds corresponding to a NavVolume if present.
virtual const std::vector< VolumeSide > & faces() const =0
Access to volume faces.
GloballyPositioned< float >::GlobalVector GlobalVector
virtual void addVolume(const NavVolume *vol, const Bounds *bounds, SurfaceOrientation::Side side)=0
NavVolumes are supposed to call this method to "register" with the NavSurface.
GlobalVector globalMomentum() const
static int position[264][3]
virtual SurfaceOrientation::Side side(const LocalPoint &p, Scalar toler) const
std::vector< VolumeSide > theFaces
const PositionType & position() const
void computeBounds(const std::vector< NavVolumeSide > &faces)