source: trunk/source/geometry/volumes/test/testG4NavigationHistory.cc @ 1350

Last change on this file since 1350 was 1347, checked in by garnier, 14 years ago

geant4 tag 9.4

File size: 4.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: testG4NavigationHistory.cc,v 1.9 2007/02/13 17:24:59 japost Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31// testG4NavigationHistory
32//             Ensure asserts are compiled in
33//
34
35#include <assert.h>
36
37// Global defs
38#include "globals.hh"
39
40// Tested entities
41#include "G4NavigationHistory.hh"
42
43// Required entities
44#include "G4PVPlacement.hh"
45#include "G4LogicalVolume.hh"
46#include "G4Box.hh"
47#include "G4AffineTransform.hh"
48#include "G4RotationMatrix.hh"
49#include "G4ThreeVector.hh"
50
51// Combined test of logical and physical volumes
52// 2 small cubes are positioned inside a larger cuboid
53//
54// Check navigation links, `Store' entries
55G4bool testG4NavigationHistory()
56{
57    G4Box myBigBox("cuboid",25,20,20);
58    G4Box myBox("cube",10,10,10);
59    G4ThreeVector vorigin,vmx(-15,0,0),vx(15,0,0);
60
61    G4LogicalVolume detectorLog(&myBigBox,0,
62                                "World",0,0,0);
63                                // Logical with no mag field,
64                                // sensitive detector or user limits
65   
66    G4PVPlacement detectorPhys(0,vorigin,
67                               "World",&detectorLog,
68                               0,false,0);
69                                // Note: no mother pointer set
70
71    G4LogicalVolume myDaughterLog(&myBox,0,"block",0,0,0);
72    G4PVPlacement offXPhys(0,vx,
73                           "Target 1",&myDaughterLog,
74                          &detectorPhys,false,0);
75    G4PVPlacement offMXPhys(0,vmx,
76                            "Target 2",&myDaughterLog,
77                            &detectorPhys,false,0);
78
79//
80// BEGIN test of G4NaviagtionHistory
81//
82    G4NavigationHistory nHist;
83
84    nHist.SetFirstEntry(&detectorPhys);
85    assert(nHist.GetDepth()==0);
86    assert(nHist.GetMaxDepth()>0);
87    assert(nHist.GetTransform(0)==G4AffineTransform(vorigin));
88    assert(nHist.GetReplicaNo(0)==0);
89    assert(nHist.GetVolume(0)==&detectorPhys);
90
91    nHist.NewLevel(&offXPhys);
92    assert(nHist.GetDepth()==1);
93    assert(nHist.GetTransform(1)==G4AffineTransform(vmx));
94    // assert(nHist.GetReplicaNo(1)==0);
95    assert(nHist.GetVolume(0)==&detectorPhys);
96    assert(nHist.GetVolume(1)==&offXPhys);
97
98    nHist.BackLevel();
99    assert(nHist.GetDepth()==0);
100    assert(nHist.GetTransform(0)==G4AffineTransform(vorigin));
101    assert(nHist.GetReplicaNo(0)==0);
102    assert(nHist.GetVolume(0)==&detectorPhys);
103
104    nHist.NewLevel(&offMXPhys);
105    assert(nHist.GetDepth()==1);
106    assert(nHist.GetTransform(1)==G4AffineTransform(vx));
107    // assert(nHist.GetReplicaNo(1)==0);
108    assert(nHist.GetVolume(0)==&detectorPhys);
109    assert(nHist.GetVolume(1)==&offMXPhys);
110
111    // Test a null History
112    G4NavigationHistory nullHist;
113    assert(nullHist.GetDepth()==0);
114    assert(nullHist.GetVolume(0)==0); 
115    assert(nullHist.GetReplicaNo(0)==(-1));   
116    assert(nullHist.GetTransform(0)==G4AffineTransform(vorigin)); 
117
118//
119// END test of G4NavigationHistory
120//
121    return true;
122}
123
124int main()
125{
126#ifdef NDEBUG
127    G4Exception("FAIL: *** Assertions must be compiled in! ***");
128#endif
129    assert(testG4NavigationHistory());
130    return 0;
131}
132
Note: See TracBrowser for help on using the repository browser.