#include <Geometry.h>
Public Member Functions | |
| ~Geometry () | |
| const PlaneGeo & | Plane (unsigned int i) const |
| const std::set< unsigned int > & | GetPlanesByView (View_t v=kXorY) const |
| const unsigned int | NextPlaneInView (unsigned int p, int d=+1) const |
| const unsigned int | NextPlaneOtherView (unsigned int p, int d=+1) const |
| const CellGeo & | IdToCell (const CellUniqueId &id, int *iplane=0, int *icell=0) const |
| double | DetHalfWidth () const |
| double | DetHalfHeight () const |
| double | DetLength () const |
| double | SurfaceY () const |
| void | WorldBox (double *xlo, double *xhi, double *ylo, double *yhi, double *zlo, double *zhi) const |
| int | CurrentCell (int *ip, int *ic) const |
| const CellUniqueId | CurrentCellId () const |
| const TGeoMaterial * | Material (double x, double y, double z) const |
Static Public Member Functions | |
| Geometry & | Instance (int runnum, short detId) |
Private Types | |
| typedef std::pair< unsigned short, unsigned short > | PlaneCellPair |
| typedef std::map< CellUniqueId, PlaneCellPair > | UIDMap |
Private Member Functions | |
| Geometry (const char *gdmlfile) | |
| void | FindPlanes (std::vector< const TGeoNode * > &n, unsigned int depth) |
| void | MakePlane (std::vector< const TGeoNode * > &n, unsigned int depth) |
| void | SetDrawOptions () |
| void | BuildMaps () |
| void | SetDetectorSize () |
Private Attributes | |
| int | fRunNumber |
| Run number of configuration. | |
| int | fDetId |
| Id number of detector geometry. | |
| std::vector< PlaneGeo * > | fPlanes |
| The detector planes. | |
| UIDMap | fIdMap |
| Unique ID -> Plane,Cell. | |
| std::set< unsigned int > | fAllPlanes |
| List of all planes. | |
| std::set< unsigned int > | fXplanes |
| List of X measuring planes. | |
| std::set< unsigned int > | fYplanes |
| List of Y measuring planes. | |
| double | fDetLength |
| Detector 1/2 length (cm). | |
| double | fDetHalfHeight |
| Detector 1/2 height (cm). | |
| double | fDetHalfWidth |
| Detector 1/2 width (cm). | |
Static Private Attributes | |
| Geometry * | fInstance = 0 |
| Instance of geometry. | |
Definition at line 29 of file Geometry.h.
|
|
Definition at line 68 of file Geometry.h. Referenced by BuildMaps(). |
|
|
Definition at line 69 of file Geometry.h. |
|
|
Definition at line 130 of file Geometry.cxx. References fPlanes.
|
|
|
Definition at line 83 of file Geometry.cxx. References BuildMaps(), FindPlanes(), fPlanes, plane_sort(), SetDetectorSize(), and SetDrawOptions(). Referenced by Instance().
00084 {
00085 std::string fname;
00086
00087 // Test if the gdml file can be openned using exactly the name we've
00088 // been passed
00089 while (1) {
00090 struct stat sb;
00091 fname = gdmlfile;
00092 if (stat(fname.c_str(), &sb)==0) break;
00093
00094 const char* srt_private = getenv("SRT_PRIVATE_CONTEXT");
00095 if (srt_private!=0) {
00096 fname = srt_private;
00097 fname += "/Geometry/gdml/";
00098 fname += gdmlfile;
00099 if (stat(fname.c_str(), &sb)==0) break;
00100 }
00101
00102 const char* srt_public = getenv("SRT_PUBLIC_CONTEXT");
00103 if (srt_public!=0) {
00104 fname = srt_public;
00105 fname += "/Geometry/gdml/";
00106 fname += gdmlfile;
00107 if (stat(fname.c_str(), &sb)==0) break;
00108 }
00109
00110 // Failed to resolve the file name
00111 throw Exception(__FILE__, __LINE__, Exception::FILE_NOT_FOUND,
00112 "GDML file not found.");
00113 }
00114
00115 // Open the GDML file
00116 TGeoManager::Import(fname.c_str());
00117 this->SetDrawOptions();
00118
00119 std::vector<const TGeoNode*> n(16);
00120 n[0] = gGeoManager->GetTopNode();
00121 this->FindPlanes(n, 0);
00122 sort(fPlanes.begin(), fPlanes.end(), plane_sort);
00123
00124 this->SetDetectorSize();
00125 this->BuildMaps();
00126 }
|
|
|
Build maps used for quick access to the geometry Definition at line 410 of file Geometry.cxx. References geo::PlaneGeo::Cell(), fAllPlanes, fIdMap, fPlanes, fXplanes, fYplanes, geo::CellGeo::Id(), geo::kX, geo::kY, geo::PlaneGeo::Ncells(), Plane(), and PlaneCellPair. Referenced by Geometry().
00411 {
00412 // Sets which list planes by view
00413 for (unsigned int i=0; i<fPlanes.size(); ++i) {
00414 fAllPlanes.insert(i);
00415 if (fPlanes[i]->View()==kX) fXplanes.insert(i);
00416 else if (fPlanes[i]->View()==kY) fYplanes.insert(i);
00417 else {
00418 throw Exception(__FILE__,__LINE__,Exception::BAD_GEO_CONFIG,
00419 "Bad plane view!");
00420 }
00421 }
00422
00423 // Unique Id -> cell map
00424 for (unsigned int i=0; i<fPlanes.size(); ++i) {
00425 const PlaneGeo* p = fPlanes[i];
00426 for (int j=0; j<p->Ncells(); ++j) {
00427 // Assert that the cell ids are in fact unique
00428 if (fIdMap.find(this->Plane(i).Cell(j).Id())!=fIdMap.end()) {
00429 throw Exception(__FILE__,__LINE__,Exception::BAD_CELL_UNIQUE_ID,
00430 "Duplicate Cell UIDs");
00431 }
00432 PlaneCellPair p(i,j);
00433 fIdMap[this->Plane(i).Cell(j).Id()] = p;
00434 }
00435 }
00436 }
|
|
||||||||||||
|
Return the plane and cell number for the current tracking position held by the gGeoManager
Definition at line 146 of file Geometry.cxx. References IdToCell(). Referenced by testFindCell().
|
|
|
Return the unique cell Id# (well, #'s) for the current cell Definition at line 163 of file Geometry.cxx. References geo::CellUniqueId, and geo::PathToUniqueId().
00164 {
00165 return PathToUniqueId(gGeoManager->GetPath());
00166 }
|
|
|
Definition at line 185 of file Geometry.cxx. References fDetHalfHeight. Referenced by evd::Display3D::Draw(), and main().
00186 {
00187 return fDetHalfHeight;
00188 }
|
|
|
Definition at line 178 of file Geometry.cxx. Referenced by evd::Display3D::Draw(), and main().
00179 {
00180 return fDetHalfWidth;
00181 }
|
|
|
Definition at line 192 of file Geometry.cxx. References fDetLength. Referenced by mcchk::CosmicAna::Ana(), evd::Display3D::Draw(), main(), and evgen::CRYGen::Sample().
00193 {
00194 return fDetLength;
00195 }
|
|
||||||||||||
|
Recursively search for planes in the geometry
Definition at line 267 of file Geometry.cxx. References MakePlane(). Referenced by Geometry().
00269 {
00270 const char* nm = n[depth]->GetName();
00271 if (strncmp(nm,"vPlane", 6)==0) {
00272 this->MakePlane(n, depth);
00273 return;
00274 }
00275
00276 // Explore the next layer down
00277 unsigned int deeper = depth+1;
00278 if (deeper>=n.size()) {
00279 throw Exception(__FILE__,__LINE__,Exception::BAD_NODE,
00280 "Exceeded maximum depth.");
00281 }
00282 const TGeoVolume* v = n[depth]->GetVolume();
00283 int nd = v->GetNdaughters();
00284 for (int i=0; i<nd; ++i) {
00285 n[deeper] = v->GetNode(i);
00286 this->FindPlanes(n, deeper);
00287 }
00288 }
|
|
|
Return list of planes which measure the requested projection
Definition at line 347 of file Geometry.cxx. References fAllPlanes, fXplanes, fYplanes, geo::kX, geo::kY, and geo::View_t. Referenced by subshower::RecoSubShower::FindMaxWindow(), and testFindPlanes().
00348 {
00349 // Return the user's choice, fall back on all planes
00350 if (v==kX) return fXplanes;
00351 else if (v==kY) return fYplanes;
00352 return fAllPlanes;
00353 }
|
|
||||||||||||||||
|
Given a unique cell identifier, look up the plane and cell numbers.
Definition at line 327 of file Geometry.cxx. References geo::PlaneGeo::Cell(), geo::CellUniqueId, fIdMap, and Plane(). Referenced by CurrentCell(), novamc::MCApplication::Stepping(), and testUniqueId().
|
|
||||||||||||
|
Build a detector geometry
Definition at line 48 of file Geometry.cxx. References fDetId, fInstance, fRunNumber, and Geometry(). Referenced by mcchk::CosmicAna::Ana(), evd::Display3D::Draw(), evd::DetectorView::Draw(), evd::PlaneView::DrawMCHits(), evd::Display3D::DrawMCHits(), evd::PlaneView::DrawPlaneClusters(), evd::Display3D::DrawRawData(), evd::PlaneView::DrawRawDigit(), evd::PlaneView::DrawShowers(), evd::PlaneView::DrawTrackCandidates(), evd::PlaneView::DrawTracks(), subshower::RecoSubShower::FormStripList(), main(), novamc::MCApplication::MCApplication(), calhit::CalHit::Raw(), rpr::TrackReco::Reco(), spider::SpiderWeb::Reco(), photrans::SimpleTransport::Reco(), subshower::RecoSubShower::Reco(), rpr::FindTrackSeg::Reco(), cluster::Clusterer::Reco(), and rsim::Simulator::SetGeom().
00049 {
00050 // If our current geometry doesn't match request, get rid of it
00051 if (fInstance!=0) {
00052 if (fInstance->fRunNumber != runnum || fInstance->fDetId != detId) {
00053 delete fInstance;
00054 fInstance = 0;
00055 gGeoManager->Clear();
00056 }
00057 }
00058
00059 // Build a new geometry if we need to
00060 if (fInstance==0) {
00061 static char* fname[3] = {"neardet.gdml","fardet.gdml","ipnddet.gdml"};
00062 if (detId!=rawdata::kNear &&
00063 detId!=rawdata::kFar &&
00064 detId!=rawdata::kIPND) {
00065 char msg[256];
00066 sprintf(msg,"Unknown detector id number: %d",(int)detId);
00067 throw Exception(__FILE__,__LINE__,Exception::BAD_GEO_CONFIG,msg);
00068 }
00069 if (runnum<0) {
00070 char msg[256];
00071 std::sprintf(msg,"Bad run number: %d",runnum);
00072 throw Exception(__FILE__,__LINE__,Exception::BAD_GEO_CONFIG,msg);
00073 }
00074 fInstance = new Geometry(fname[detId]);
00075 fInstance->fDetId = detId;
00076 fInstance->fRunNumber = runnum;
00077 }
00078 return *fInstance;
00079 }
|
|
||||||||||||
|
Definition at line 292 of file Geometry.cxx. References fPlanes. Referenced by FindPlanes().
|
|
||||||||||||||||
|
Definition at line 170 of file Geometry.cxx. Referenced by proto_evgen::TargetVolume::RandomVertex().
00171 {
00172 const TGeoNode* node = gGeoManager->FindNode(x,y,z);
00173 return node->GetMedium()->GetMaterial();
00174 }
|
|
||||||||||||
|
Return the index of the next plane in a particular view
Definition at line 366 of file Geometry.cxx. References fPlanes, and geo::kPLANE_NOT_FOUND. Referenced by subshower::RecoSubShower::LinkedBlobs(), testFindPlanes(), and subshower::RecoSubShower::TransCluster().
00367 {
00368 assert(p1<fPlanes.size());
00369
00370 // March along from p1 in the direction d until we find a match
00371 int s = (d>0 ? 1 : -1);
00372 if (s<0 && p1==0) return kPLANE_NOT_FOUND;
00373 if (s>0 && p1==fPlanes.size()-1) return kPLANE_NOT_FOUND;
00374 for (unsigned int p2=p1+d; 1; p2+=s) {
00375 if (fPlanes[p1]->View() == fPlanes[p2]->View()) return p2;
00376 if (p2==fPlanes.size()-1) return kPLANE_NOT_FOUND;
00377 if (p2==0) return kPLANE_NOT_FOUND;
00378 }
00379 }
|
|
||||||||||||
|
Return the index of the next plane in a particular view
Definition at line 391 of file Geometry.cxx. References fPlanes, and geo::kPLANE_NOT_FOUND. Referenced by testFindPlanes().
00392 {
00393 assert(p1<fPlanes.size());
00394
00395 // March along from p1 in the direction d until we find a match
00396 int s = (d>0 ? 1 : -1);
00397 if (s<0 && p1==0) return kPLANE_NOT_FOUND;
00398 if (s>0 && p1==fPlanes.size()-1) return kPLANE_NOT_FOUND;
00399 for (unsigned int p2=p1+d; 1; p2+=s) {
00400 if (fPlanes[p1]->View() != fPlanes[p2]->View()) return p2;
00401 if (p2==fPlanes.size()) return kPLANE_NOT_FOUND;
00402 if (p2==0) return kPLANE_NOT_FOUND;
00403 }
00404 }
|
|
|
|
Calcualte the detector size based on the geomtry. Requires a little bit of work, so do this once when the geometry is updated Definition at line 444 of file Geometry.cxx. References geo::PlaneGeo::Cell(), fDetHalfHeight, fDetHalfWidth, fDetLength, fPlanes, geo::CellGeo::GetCenter(), and Plane(). Referenced by Geometry().
00445 {
00446 double dummy;
00447
00448 // Compute the height and width based on the sizes of the vertical
00449 // and horizontal planes. Remember, in the local plane frame z goes
00450 // along the length of the modules. Hence the use of axis=3 to get
00451 // the detector height (from the vertical planes) and width (from
00452 // the horizontal planes).
00453 const TGeoShape* vp = gGeoManager->GetVolume("vPlaneV")->GetShape();
00454 const TGeoShape* hp = gGeoManager->GetVolume("vPlaneH")->GetShape();
00455 vp->GetAxisRange(3,dummy,fDetHalfHeight);
00456 hp->GetAxisRange(3,dummy,fDetHalfWidth);
00457
00458 // Remember -- in the local plane coordinate frame, the "depth" is
00459 // along y, hence axis=2. In the world coordinate this is along z.
00460 double vplanez1, vplanez2;
00461 vp->GetAxisRange(2,vplanez1,vplanez2);
00462
00463 // Compute the detector length based on the center positions of
00464 // cells in the first and last plane. Adjust to account for the
00465 // plane widths. This ajustment works if the vertical and horizontal
00466 // planes have the same depth, or if the detector begins and ends
00467 // with vertical planes. As of the TDR both of these conditions was
00468 // true for all the NOvA detectors.
00469 double xyz1[3] = {0,0,0};
00470 double xyz2[3] = {0,0,0};
00471 this->Plane(0). Cell(0).GetCenter(xyz1);
00472 this->Plane(fPlanes.size()-1).Cell(0).GetCenter(xyz2);
00473 fDetLength = (xyz2[2]-xyz1[2])+(vplanez2-vplanez1);
00474 }
|
|
|
Definition at line 256 of file Geometry.cxx. Referenced by Geometry().
00256 { }
|
|
|
A typical y-position value at the surface (where earth meets air) for this detector site
Definition at line 210 of file Geometry.cxx. References fDetId. Referenced by evgen::CRYGen::Sample().
00211 {
00212 switch (fDetId) {
00213 case 0: return 130.0E2; // near det: surface ~130m up from det. center
00214 case 1: return 9.94E2; // far det: surface ~10m up from det. center
00215 case 2: return -2.0E2; // IPND: surface ~2 meter below det, center
00216 default: throw Exception(__FILE__,__LINE__,Exception::BAD_GEO_CONFIG);
00217 }
00218 return 0.0;
00219 }
|
|
||||||||||||||||||||||||||||
|
Return the ranges of x,y and z for the "world volume" that the entire geometry lives in. If any pointers are 0, then those coordinates are ignored.
Definition at line 233 of file Geometry.cxx. Referenced by evgen::CRYGen::Sample(), and testProject().
00236 {
00237 const TGeoShape* s = gGeoManager->GetVolume("vWorld")->GetShape();
00238 assert(s);
00239
00240 if (xlo || xhi) {
00241 double x1, x2;
00242 s->GetAxisRange(1,x1,x2); if (xlo) *xlo = x1; if (xhi) *xhi = x2;
00243 }
00244 if (ylo || yhi) {
00245 double y1, y2;
00246 s->GetAxisRange(2,y1,y2); if (ylo) *ylo = y1; if (yhi) *yhi = y2;
00247 }
00248 if (zlo || zhi) {
00249 double z1, z2;
00250 s->GetAxisRange(3,z1,z2); if (zlo) *zlo = z1; if (zhi) *zhi = z2;
00251 }
00252 }
|
|
|
List of all planes.
Definition at line 77 of file Geometry.h. Referenced by BuildMaps(), and GetPlanesByView(). |
|
|
Detector 1/2 height (cm).
Definition at line 82 of file Geometry.h. Referenced by DetHalfHeight(), and SetDetectorSize(). |
|
|
Detector 1/2 width (cm).
Definition at line 83 of file Geometry.h. Referenced by SetDetectorSize(). |
|
|
Id number of detector geometry.
Definition at line 73 of file Geometry.h. Referenced by Instance(), and SurfaceY(). |
|
|
Detector 1/2 length (cm).
Definition at line 81 of file Geometry.h. Referenced by DetLength(), and SetDetectorSize(). |
|
|
Unique ID -> Plane,Cell.
Definition at line 75 of file Geometry.h. Referenced by BuildMaps(), and IdToCell(). |
|
|
Instance of geometry.
Definition at line 27 of file Geometry.cxx. Referenced by Instance(). |
|
|
The detector planes.
Definition at line 74 of file Geometry.h. Referenced by BuildMaps(), Geometry(), MakePlane(), NextPlaneInView(), NextPlaneOtherView(), Plane(), SetDetectorSize(), and ~Geometry(). |
|
|
Run number of configuration.
Definition at line 72 of file Geometry.h. Referenced by Instance(). |
|
|
List of X measuring planes.
Definition at line 78 of file Geometry.h. Referenced by BuildMaps(), and GetPlanesByView(). |
|
|
List of Y measuring planes.
Definition at line 79 of file Geometry.h. Referenced by BuildMaps(), and GetPlanesByView(). |
1.3.5