BLZStep.hh

Go to the documentation of this file.
00001 //      BLZStep.hh
00002 //#define ZSTEPWORLD
00003 
00004 #ifndef BLZSTEP_HH
00005 #define BLZSTEP_HH
00006 
00007 #include <vector>
00008 #include <map>
00009 
00010 #include "globals.hh" 
00011 #include "G4VUserParallelWorld.hh" 
00012 #include "G4Box.hh" 
00013 #include "G4LogicalVolume.hh" 
00014 #include "G4PVPlacement.hh" 
00015 #include "G4TransportationManager.hh" 
00016 #include "G4Navigator.hh" 
00017 
00018 
00019 #ifdef ZSTEPWORLD
00020 
00021 struct ZStep {
00022         G4double z;
00023         void *action; // always BLManager::ZSteppingAction 
00024         int when;
00025         G4VPhysicalVolume *pv;
00026         ZStep(G4double _z, void *a, int w)
00027                 { z=_z; action=a; when=w; pv=0; }
00028 };
00029 
00030 class BLZStep : public G4VUserParallelWorld {
00031         G4Navigator *navigator; // set in setupProcesses() -- delay needed
00032         std::vector<ZStep> &zStepVector;
00033         std::map<G4VPhysicalVolume*,int> &zStepMap;
00034         G4LogicalVolume *lvworld;
00035 public: 
00036         // Constructor. Gets vector and map from BLManager.
00037         BLZStep(std::vector<ZStep> &v, std::map<G4VPhysicalVolume*,int> &m) : 
00038                                         G4VUserParallelWorld("ZStepWorld"),
00039                                         zStepVector(v), zStepMap(m) { 
00040                 navigator = 0;
00041                 lvworld = 0;
00042                 printf("ZStepWorld initialized\n");
00043         }
00044 
00045         virtual ~BLZStep() { }
00046 
00047         /// getVolume() returns the current physical volume in ZStepWorld.
00048         G4VPhysicalVolume *getVolume() {
00049                 G4TouchableHistory *th = navigator->CreateTouchableHistory();
00050                 G4VPhysicalVolume *v = th->GetVolume();
00051                 delete th;
00052                 return v;
00053         }
00054 
00055         /// Construct() from G4VUserParallelWorld. Creates and places volumes
00056         /// for every Z step that BLManager has.
00057         virtual void Construct();
00058 
00059         /// setupProcesses() sets up the necessary physics processes
00060         void setupProcesses();
00061 
00062         /// placeVolume() places one volume into ZStepWorld
00063         G4VPhysicalVolume *placeVolume(G4double z);
00064 };
00065 
00066 #endif // ZSTEPWORLD
00067 #endif // BLZSTEP_HH
g4beamline