#include <TrackPropagation/NavGeometry/interface/NavVolume6Faces.h>
Public Member Functions | |
virtual VolumeCrossReturnType | crossToNextVolume (const TrajectoryStateOnSurface ¤tState, const Propagator &prop) const |
Cross this volume and point at the next. | |
virtual const std::vector < VolumeSide > & | faces () const |
Access to volume faces. | |
bool | inside (const GlobalPoint &gp, double tolerance) const |
bool | isIron () const |
Access to Iron/Air information:. | |
NavVolume6Faces (const MagVolume &magvol, const bool isIron=false) | |
A NavVolume6Faces that corresponds exactly to a MagVolume. | |
NavVolume6Faces (const PositionType &pos, const RotationType &rot, DDSolidShape shape, const std::vector< NavVolumeSide > &faces, const MagneticFieldProvider< float > *mfp) | |
virtual Container | nextSurface (const NavVolume::LocalPoint &pos, const NavVolume::LocalVector &mom, double charge, PropagationDirection propDir, ConstReferenceCountingPointer< Surface > NotThisSurfaceP) const |
Same, giving lowest priority to the surface we are on now (=NotThisSurface). | |
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. | |
Private Member Functions | |
Bounds * | computeBounds (int index, const std::vector< NavVolumeSide > &faces) |
Bounds * | computeBounds (int index, const std::vector< const Plane * > &bpc) |
void | computeBounds (const std::vector< NavVolumeSide > &faces) |
Private Attributes | |
bool | isThisIron |
std::vector< VolumeSide > | theFaces |
Container | theNavSurfaces |
Definition at line 13 of file NavVolume6Faces.h.
NavVolume6Faces::NavVolume6Faces | ( | const PositionType & | pos, | |
const RotationType & | rot, | |||
DDSolidShape | shape, | |||
const std::vector< NavVolumeSide > & | faces, | |||
const MagneticFieldProvider< float > * | mfp | |||
) |
Definition at line 25 of file NavVolume6Faces.cc.
References computeBounds(), i, and theFaces.
00029 : 00030 NavVolume(pos,rot,shape,mfp) 00031 { 00032 for (std::vector<NavVolumeSide>::const_iterator i=faces.begin(); 00033 i != faces.end(); i++) { 00034 theFaces.push_back( VolumeSide( const_cast<Surface*>(&(i->surface().surface())), 00035 i->globalFace(), i->surfaceSide())); 00036 // LogDebug("NavGeometry") << " or actually this is where we have side " << i->surfaceSide() << " and face " << i->globalFace() ; 00037 } 00038 00039 00040 00041 computeBounds(faces); 00042 }
A NavVolume6Faces that corresponds exactly to a MagVolume.
Definition at line 44 of file NavVolume6Faces.cc.
References computeBounds(), MagVolume::faces(), and i.
00044 : 00045 NavVolume( magvol.position(), magvol.rotation(), magvol.shapeType(), magvol.provider()), 00046 theFaces(magvol.faces()), isThisIron(isIron) 00047 { 00048 std::vector<NavVolumeSide> navSides; 00049 std::vector<VolumeSide> magSides( magvol.faces()); 00050 NavSurfaceBuilder navBuilder; 00051 00052 for (std::vector<VolumeSide>::const_iterator i=magSides.begin(); 00053 i != magSides.end(); i++) { 00054 NavSurface* navSurface = navBuilder.build( i->surface()); 00055 navSides.push_back( NavVolumeSide( navSurface, i->globalFace(), i->surfaceSide())); 00056 } 00057 computeBounds(navSides); 00058 }
Bounds * NavVolume6Faces::computeBounds | ( | int | index, | |
const std::vector< NavVolumeSide > & | faces | |||
) | [private] |
Definition at line 157 of file NavVolume6Faces.cc.
References j, NavVolumeSide::surface(), NavSurface::surface(), and NavVolumeSide::surfaceSide().
00158 { 00159 typedef GeneralNSurfaceDelimitedBounds::SurfaceAndSide SurfaceAndSide; 00160 typedef GeneralNSurfaceDelimitedBounds::SurfaceContainer SurfaceContainer; 00161 00162 // find the 4 intersecting surfaces 00163 int startIndex = 2*(1+index/2); // 2, 4, 6 00164 SurfaceContainer crossed; crossed.reserve(4); 00165 for (int j = startIndex; j < startIndex+4; j++) { 00166 const NavVolumeSide& face(faces[j%6]); 00167 crossed.push_back( SurfaceAndSide(&(face.surface().surface()), face.surfaceSide())); 00168 } 00169 return new GeneralNSurfaceDelimitedBounds( &(faces[index].surface().surface()), crossed); 00170 }
Bounds * NavVolume6Faces::computeBounds | ( | int | index, | |
const std::vector< const Plane * > & | bpc | |||
) | [private] |
Definition at line 110 of file NavVolume6Faces.cc.
References GenMuonPlsPt100GeV_cfg::cout, ThreePlaneCrossing::crossing(), e, lat::endl(), i, j, Plane::localZ(), Plane::normalVector(), SurfaceOrientation::onSurface, GloballyPositioned< T >::position(), Plane::side(), and GloballyPositioned< T >::toLocal().
00112 { 00113 const Plane* plane( bpc[index]); 00114 00115 // find the 4 intersecting planes 00116 int startIndex = 2*(1+index/2); // 2, 4, 6 00117 std::vector<const Plane*> crossed; crossed.reserve(4); 00118 for (int j = startIndex; j < startIndex+4; j++) { 00119 crossed.push_back(bpc[j%6]); 00120 } 00121 00122 // compute intersection corners of the plane triplets 00123 std::vector<GlobalPoint> corners; corners.reserve(4); 00124 ThreePlaneCrossing crossing; 00125 for ( int i=0; i<2; i++) { 00126 for ( int j=2; j<4; j++) { 00127 GlobalPoint corner( crossing.crossing( *plane, *crossed[i], *crossed[j])); 00128 corners.push_back(corner); 00129 00130 #ifdef DEBUG 00131 std::cout << "Crossing of planes is " << corner << std::endl; 00132 std::cout << "NormalVectors of the planes are " << plane->normalVector() 00133 << " " << crossed[i]->normalVector() << " " << crossed[j]->normalVector() << std::endl; 00134 std::cout << "Positions of planes are " << plane->position() 00135 << " " << crossed[i]->position() << " " << crossed[j]->position() << std::endl; 00136 if (plane->side( corner, 1.e-5) == SurfaceOrientation::onSurface && 00137 crossed[i]->side( corner, 1.e-5) == SurfaceOrientation::onSurface && 00138 crossed[j]->side( corner, 1.e-5) == SurfaceOrientation::onSurface) { 00139 std::cout << "Crossing is really on all three surfaces" << std::endl; 00140 } 00141 else { 00142 std::cout << "CROSSING IS NOT ON SURFACES!!!" << std::endl; 00143 std::cout << plane->localZ(corner) << std::endl; 00144 std::cout << crossed[i]->localZ(corner) << std::endl; 00145 std::cout << crossed[j]->localZ(corner) << std::endl; 00146 } 00147 #endif 00148 00149 } 00150 } 00151 00152 // put corners in cyclic sequence (2 and 3 swapped) 00153 return new FourPointPlaneBounds( plane->toLocal( corners[0]), plane->toLocal( corners[1]), 00154 plane->toLocal( corners[3]), plane->toLocal( corners[2])); 00155 }
void NavVolume6Faces::computeBounds | ( | const std::vector< NavVolumeSide > & | faces | ) | [private] |
Definition at line 73 of file NavVolume6Faces.cc.
References NavSurface::addVolume(), NavSurface::bounds(), i, and theNavSurfaces.
Referenced by NavVolume6Faces().
00074 { 00075 bool allPlanes = true; 00076 // bool allPlanes = false; // for TESTS ONLY!!! 00077 std::vector<const Plane*> planes; 00078 for (std::vector<NavVolumeSide>::const_iterator iface=faces.begin(); iface!=faces.end(); iface++) { 00079 const Plane* plane = dynamic_cast<const Plane*>(&(iface->surface())); 00080 if (plane != 0) { 00081 planes.push_back(plane); 00082 } 00083 else allPlanes = false; 00084 } 00085 00086 for (unsigned int i=0; i<faces.size(); i++) { 00087 00088 // FIXME: who owns the new NavSurface? memory leak??? 00089 00090 NavSurface& navSurf = faces[i].mutableSurface(); 00091 Bounds* myBounds = 0; 00092 if (allPlanes) { 00093 myBounds = computeBounds( i, planes); 00094 } 00095 else { 00096 myBounds = computeBounds( i, faces); 00097 } 00098 navSurf.addVolume( this, myBounds, faces[i].surfaceSide()); 00099 delete myBounds; // since navSurf now owns a copy 00100 00101 // this is tricky: we want to avoid multiple copies of the Bounds; the NavSurface owns 00102 // a copy of Bounds for each touching Volume (instantiated in the call to addVolume). 00103 // We would like to keep a pointer to the same Bounds in the NavVolume, so we have to ASK 00104 // the NavSurface for the Bounds* of the Bounds we just gave it! 00105 //LogDebug("NavGeometry") << "Adding a Volume Side with center " << navSurf.surface().position() << " side "<< faces[i].surfaceSide() << " and face " << faces[i].globalFace(); 00106 theNavSurfaces.push_back( SurfaceAndBounds(&navSurf, navSurf.bounds(this), faces[i].surfaceSide(), faces[i].globalFace())); 00107 } 00108 }
VolumeCrossReturnType NavVolume6Faces::crossToNextVolume | ( | const TrajectoryStateOnSurface & | currentState, | |
const Propagator & | prop | |||
) | const [virtual] |
Cross this volume and point at the next.
Implements NavVolume.
Definition at line 250 of file NavVolume6Faces.cc.
References alongMomentum, except, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), LogDebug, nextSurface(), oppositeSide(), state, TrajectoryStateOnSurface::surface(), and GloballyPositioned< float >::toLocal().
00251 { 00252 typedef TrajectoryStateOnSurface TSOS; 00253 typedef std::pair<TSOS,double> TSOSwithPath; 00254 00255 NavVolume::Container nsc = nextSurface( toLocal( startingState.globalPosition()), 00256 toLocal( startingState.globalMomentum()), -1, 00257 alongMomentum, &(startingState.surface())); 00258 int itry = 0; 00259 VolumeCrossReturnType VolumeCrossResult( 0, startingState, 0.0); 00260 00261 for (NavVolume::Container::const_iterator isur = nsc.begin(); isur!=nsc.end(); isur++) { 00262 00263 LogDebug("NavGeometry") << "crossToNextVolume: trying Surface no. " << itry ; 00264 TSOSwithPath state; 00265 00266 try { 00267 state = isur->surface().propagateWithPath( prop, startingState); 00268 } 00269 catch (MagVolumeOutsideValidity& except) { 00270 LogDebug("NavGeometry") << "Ohoh... failed to stay inside magnetic field !! skip this surface " ; 00271 ++itry; 00272 continue; 00273 } 00274 00275 if (!state.first.isValid()) { 00276 ++itry; 00277 continue; 00278 } 00279 00280 LogDebug("NavGeometry") << "crossToNextVolume: reached Valid State at Surface no. " << itry ; 00281 LogDebug("NavGeometry") << " --> local position of Valid state is " << state.first.localPosition() ; 00282 LogDebug("NavGeometry") << " --> global position of Valid state is " << state.first.globalPosition() ; 00283 00284 if (isur->bounds().inside(state.first.localPosition())) { 00285 //LogDebug("NavGeometry") << "crossToNextVolume: Surface containing destination point found at try " << itry ; 00286 // Found the exit surface !! Get pointer to next volume and save exit state: 00287 //VolumeCrossResult.first = isur->surface().nextVolume(state.localPosition(),oppositeSide(isur->side())); 00288 //VolumeCrossResult.second = state; 00289 // exitSurface = &( isur->surface().surface() ); 00290 //if(VolumeCrossResult.path() < 0.01) { 00291 // LogDebug("NavGeometry") << " Stuck at " << state.first.globalPosition() ; 00292 //} 00293 return VolumeCrossReturnType ( isur->surface().nextVolume(state.first.localPosition(), oppositeSide(isur->side())), 00294 state.first, state.second ); 00295 00296 break; 00297 } 00298 else { 00299 LogDebug("NavGeometry") << "crossToNextVolume: BUT not inside the Bounds !! " ; 00300 ++itry; 00301 } 00302 } 00303 00304 return VolumeCrossResult; 00305 }
virtual const std::vector<VolumeSide>& NavVolume6Faces::faces | ( | ) | const [inline, virtual] |
Access to volume faces.
Implements MagVolume.
Definition at line 39 of file NavVolume6Faces.h.
References theFaces.
00039 { return theFaces; }
bool NavVolume6Faces::inside | ( | const GlobalPoint & | gp, | |
double | tolerance | |||
) | const [virtual] |
Implements MagVolume.
Definition at line 61 of file NavVolume6Faces.cc.
References i, SurfaceOrientation::onSurface, and theFaces.
00062 { 00063 // check if the point is on the correct side of all delimiting surfaces 00064 for (std::vector<VolumeSide>::const_iterator i=theFaces.begin(); i!=theFaces.end(); i++) { 00065 Surface::Side side = i->surface().side( gp, tolerance); 00066 if ( side != i->surfaceSide() && side != SurfaceOrientation::onSurface) return false; 00067 } 00068 return true; 00069 }
bool NavVolume6Faces::isIron | ( | ) | const [inline, virtual] |
Access to Iron/Air information:.
Implements NavVolume.
Definition at line 42 of file NavVolume6Faces.h.
References isThisIron.
00042 { return isThisIron; }
NavVolume::Container NavVolume6Faces::nextSurface | ( | const NavVolume::LocalPoint & | pos, | |
const NavVolume::LocalVector & | mom, | |||
double | charge, | |||
PropagationDirection | propDir, | |||
ConstReferenceCountingPointer< Surface > | NotThisSurfaceP | |||
) | const [virtual] |
Same, giving lowest priority to the surface we are on now (=NotThisSurface).
Definition at line 208 of file NavVolume6Faces.cc.
References alongMomentum, dist(), geometryDiff::epsilon, i, HLT_VtxMuL3::result, theNavSurfaces, and GloballyPositioned< float >::toGlobal().
00212 { 00213 typedef std::map<double,SurfaceAndBounds> SortedContainer; 00214 00215 GlobalPoint gpos( toGlobal(pos)); 00216 GlobalVector gmom( toGlobal(mom)); 00217 GlobalVector gdir = (propDir == alongMomentum ? gmom : -gmom); 00218 00219 SortedContainer sortedSurfaces; 00220 Container verycloseSurfaces; // reachable surface with dist < epsilon (if 6-surface check fails) 00221 Container unreachableSurfaces; 00222 00223 double epsilon = 0.01; // should epsilon be hard-coded or a variable in NavVolume? 00224 bool surfaceMatched = false; 00225 00226 for (Container::const_iterator i=theNavSurfaces.begin(); i!=theNavSurfaces.end(); i++) { 00227 if (&(i->surface().surface()) == NotThisSurfaceP) surfaceMatched = true; 00228 } 00229 00230 for (Container::const_iterator i=theNavSurfaces.begin(); i!=theNavSurfaces.end(); i++) { 00231 std::pair<bool,double> dist = i->surface().distanceAlongLine( gpos, gdir); 00232 if (dist.first) { 00233 if ( &(i->surface().surface()) == NotThisSurfaceP || !surfaceMatched && dist.second < epsilon) 00234 verycloseSurfaces.push_back(*i); 00235 else sortedSurfaces[dist.second] = *i; 00236 } 00237 else unreachableSurfaces.push_back(*i); 00238 } 00239 00240 NavVolume::Container result; 00241 for (SortedContainer::const_iterator i=sortedSurfaces.begin(); i!=sortedSurfaces.end(); ++i) { 00242 result.push_back(i->second); 00243 } 00244 result.insert( result.end(), unreachableSurfaces.begin(), unreachableSurfaces.end()); 00245 result.insert( result.end(), verycloseSurfaces.begin(), verycloseSurfaces.end()); 00246 return result; 00247 }
NavVolume::Container NavVolume6Faces::nextSurface | ( | const NavVolume::LocalPoint & | pos, | |
const NavVolume::LocalVector & | mom, | |||
double | charge, | |||
PropagationDirection | propDir = alongMomentum | |||
) | const [virtual] |
Give a sorted list of possible surfaces to propagate to.
Definition at line 174 of file NavVolume6Faces.cc.
References alongMomentum, dist(), geometryDiff::epsilon, i, HLT_VtxMuL3::result, theNavSurfaces, and GloballyPositioned< float >::toGlobal().
Referenced by crossToNextVolume().
00177 { 00178 typedef std::map<double,SurfaceAndBounds> SortedContainer; 00179 00180 GlobalPoint gpos( toGlobal(pos)); 00181 GlobalVector gmom( toGlobal(mom)); 00182 GlobalVector gdir = (propDir == alongMomentum ? gmom : -gmom); 00183 00184 SortedContainer sortedSurfaces; 00185 Container verycloseSurfaces; // reachable surface with dist < epsilon !! 00186 Container unreachableSurfaces; 00187 00188 double epsilon = 0.01; // should epsilon be hard-coded or a variable in NavVolume? 00189 00190 for (Container::const_iterator i=theNavSurfaces.begin(); i!=theNavSurfaces.end(); i++) { 00191 std::pair<bool,double> dist = i->surface().distanceAlongLine( gpos, gdir); 00192 if (dist.first) { 00193 if (dist.second > epsilon) sortedSurfaces[dist.second] = *i; 00194 else verycloseSurfaces.push_back(*i); 00195 } 00196 else unreachableSurfaces.push_back(*i); 00197 } 00198 NavVolume::Container result; 00199 for (SortedContainer::const_iterator i=sortedSurfaces.begin(); i!=sortedSurfaces.end(); ++i) { 00200 result.push_back(i->second); 00201 } 00202 result.insert( result.end(), unreachableSurfaces.begin(), unreachableSurfaces.end()); 00203 result.insert( result.end(), verycloseSurfaces.begin(), verycloseSurfaces.end()); 00204 return result; 00205 }
bool NavVolume6Faces::isThisIron [private] |
std::vector<VolumeSide> NavVolume6Faces::theFaces [private] |
Definition at line 49 of file NavVolume6Faces.h.
Referenced by faces(), inside(), and NavVolume6Faces().
Container NavVolume6Faces::theNavSurfaces [private] |