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: G4FastSimulationManager.hh,v 1.13 2007/05/11 13:50:20 mverderi Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // |
---|
31 | //--------------------------------------------------------------- |
---|
32 | // |
---|
33 | // G4FastSimulationManager.hh |
---|
34 | // |
---|
35 | // Description: |
---|
36 | // Manages the Fast Simulation models attached to a envelope. |
---|
37 | // |
---|
38 | // History: |
---|
39 | // Oct 97: Verderi && MoraDeFreitas - First Implementation. |
---|
40 | // |
---|
41 | //--------------------------------------------------------------- |
---|
42 | |
---|
43 | |
---|
44 | #ifndef G4FastSimulationManager_h |
---|
45 | #define G4FastSimulationManager_h 1 |
---|
46 | |
---|
47 | #include "globals.hh" |
---|
48 | |
---|
49 | #include "G4LogicalVolume.hh" |
---|
50 | #include "G4Region.hh" |
---|
51 | #include "G4VPhysicalVolume.hh" |
---|
52 | #include "G4ParticleTable.hh" |
---|
53 | #include "G4ParticleDefinition.hh" |
---|
54 | #include "G4VParticleChange.hh" |
---|
55 | #include "G4FastTrack.hh" |
---|
56 | #include "G4FastStep.hh" |
---|
57 | #include "G4VFastSimulationModel.hh" |
---|
58 | #include "G4RotationMatrix.hh" |
---|
59 | #include "G4ThreeVector.hh" |
---|
60 | #include "G4Transform3D.hh" |
---|
61 | #include "G4FastSimulationVector.hh" |
---|
62 | |
---|
63 | #include "G4ios.hh" |
---|
64 | |
---|
65 | //--------------------------- |
---|
66 | // For possible future needs: |
---|
67 | //--------------------------- |
---|
68 | typedef G4Region G4Envelope; |
---|
69 | |
---|
70 | //------------------------------------------- |
---|
71 | // |
---|
72 | // G4FastSimulationManager class |
---|
73 | // |
---|
74 | //------------------------------------------- |
---|
75 | |
---|
76 | // Class Description: |
---|
77 | // The G4VFastSimulationModel objects are attached to the envelope |
---|
78 | // through a G4FastSimulationManager. |
---|
79 | // This object will manage the list of models and will message them |
---|
80 | // at tracking time. |
---|
81 | // |
---|
82 | |
---|
83 | |
---|
84 | class G4FastSimulationManager |
---|
85 | { |
---|
86 | public: // with description |
---|
87 | //------------------------ |
---|
88 | // Constructor/Destructor |
---|
89 | //------------------------ |
---|
90 | // Only one Constructor. By default the envelope can |
---|
91 | // be placed n-Times. |
---|
92 | // If the user is sure that it is placed just one time, |
---|
93 | // the IsUnique flag should be set TRUE to avoid the |
---|
94 | // G4AffineTransform re-calculations each time we reach |
---|
95 | // the envelope. |
---|
96 | |
---|
97 | G4FastSimulationManager(G4Envelope *anEnvelope, |
---|
98 | G4bool IsUnique = FALSE); |
---|
99 | // This is the only constructor. In this constructor you specify |
---|
100 | // the envelope by giving the G4Region (typedef-ed as G4Envelope) |
---|
101 | // pointer. The G4FastSimulationManager object will bind itself to |
---|
102 | // this envelope and will notify this G4Region to become an envelope. |
---|
103 | // If you know that this region is used for only one logical volume, |
---|
104 | // you can turn the IsUnique boolean to "true" to allow some optimization. |
---|
105 | // |
---|
106 | // Note that if you choose to use the G4VFastSimulationModel(const G4String&, |
---|
107 | // G4Region*, G4bool) constructor for you model, the G4FastSimulationManager |
---|
108 | // will be constructed using the given G4Region* and G4bool values of the |
---|
109 | // model constructor. |
---|
110 | // |
---|
111 | |
---|
112 | public: // without description |
---|
113 | ~G4FastSimulationManager(); |
---|
114 | |
---|
115 | |
---|
116 | public: // with description |
---|
117 | // Methods to add/remove models to/from the Model |
---|
118 | // List. |
---|
119 | // |
---|
120 | void AddFastSimulationModel(G4VFastSimulationModel*); |
---|
121 | // Add a model to the Model List. |
---|
122 | |
---|
123 | void RemoveFastSimulationModel(G4VFastSimulationModel*); |
---|
124 | // Remove a model from the Model List. |
---|
125 | |
---|
126 | // Methods to activate/inactivate models from the Model |
---|
127 | // List. |
---|
128 | |
---|
129 | G4bool ActivateFastSimulationModel(const G4String&); |
---|
130 | // Activate a model in the Model List. |
---|
131 | |
---|
132 | G4bool InActivateFastSimulationModel(const G4String&); |
---|
133 | // Inactivate a model in the Model List. |
---|
134 | |
---|
135 | public: // without description |
---|
136 | // Methods for print/control commands |
---|
137 | void ListTitle() const; |
---|
138 | void ListModels() const; |
---|
139 | void ListModels(const G4ParticleDefinition*) const; |
---|
140 | void ListModels(const G4String& aName) const; |
---|
141 | const G4Envelope* GetEnvelope() const; |
---|
142 | |
---|
143 | G4VFastSimulationModel* GetFastSimulationModel(const G4String& modelName, |
---|
144 | const G4VFastSimulationModel* previousFound, |
---|
145 | bool &foundPrevious) const; |
---|
146 | |
---|
147 | const std::vector<G4VFastSimulationModel*>& GetFastSimulationModelList() const |
---|
148 | {return ModelList;} |
---|
149 | |
---|
150 | |
---|
151 | //---------------------------------------------- |
---|
152 | // Interface methods for the |
---|
153 | // G4FastSimulationManagerProcess process. |
---|
154 | //---------------------------------------------- |
---|
155 | // Trigger |
---|
156 | G4bool PostStepGetFastSimulationManagerTrigger(const G4Track &, |
---|
157 | const G4Navigator* a = 0); |
---|
158 | // DoIt |
---|
159 | G4VParticleChange* InvokePostStepDoIt(); |
---|
160 | |
---|
161 | // AtRest methods: |
---|
162 | G4bool AtRestGetFastSimulationManagerTrigger(const G4Track &, |
---|
163 | const G4Navigator* a = 0); |
---|
164 | G4VParticleChange* InvokeAtRestDoIt(); |
---|
165 | |
---|
166 | // For management |
---|
167 | G4bool operator == ( const G4FastSimulationManager&) const; |
---|
168 | |
---|
169 | private: |
---|
170 | // Private members : |
---|
171 | G4FastTrack fFastTrack; |
---|
172 | G4FastStep fFastStep; |
---|
173 | G4VFastSimulationModel* fTriggedFastSimulationModel; |
---|
174 | G4FastSimulationVector <G4VFastSimulationModel> ModelList; |
---|
175 | G4FastSimulationVector <G4VFastSimulationModel> fInactivatedModels; |
---|
176 | |
---|
177 | G4ParticleDefinition* fLastCrossedParticle; |
---|
178 | G4FastSimulationVector <G4VFastSimulationModel> fApplicableModelList; |
---|
179 | |
---|
180 | // -- *** depracating, to be dropped @ next major release: |
---|
181 | G4FastSimulationVector <G4Transform3D> GhostPlacements; |
---|
182 | }; |
---|
183 | |
---|
184 | inline void |
---|
185 | G4FastSimulationManager::AddFastSimulationModel(G4VFastSimulationModel* fsm) |
---|
186 | { |
---|
187 | ModelList.push_back(fsm); |
---|
188 | // forces the fApplicableModelList to be rebuild |
---|
189 | fLastCrossedParticle = 0; |
---|
190 | } |
---|
191 | |
---|
192 | inline void |
---|
193 | G4FastSimulationManager::RemoveFastSimulationModel(G4VFastSimulationModel* fsm) |
---|
194 | { |
---|
195 | if(!ModelList.remove(fsm)) fInactivatedModels.remove(fsm); |
---|
196 | // forces the fApplicableModelList to be rebuild |
---|
197 | fLastCrossedParticle = 0; |
---|
198 | } |
---|
199 | |
---|
200 | inline G4bool |
---|
201 | G4FastSimulationManager::operator == (const G4FastSimulationManager& fsm) const |
---|
202 | { |
---|
203 | return (this==&fsm) ? true : false; |
---|
204 | } |
---|
205 | |
---|
206 | inline const G4Envelope* |
---|
207 | G4FastSimulationManager::GetEnvelope() const |
---|
208 | { |
---|
209 | return fFastTrack.GetEnvelope(); |
---|
210 | } |
---|
211 | |
---|
212 | #endif |
---|