00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 //--------------------------------------------------------------- 00031 // 00032 // G4FastSimulationManager.hh 00033 // 00034 // Description: 00035 // Manages the Fast Simulation models attached to a envelope. 00036 // 00037 // History: 00038 // Oct 97: Verderi && MoraDeFreitas - First Implementation. 00039 // 00040 //--------------------------------------------------------------- 00041 00042 00043 #ifndef G4FastSimulationManager_h 00044 #define G4FastSimulationManager_h 1 00045 00046 #include "globals.hh" 00047 00048 #include "G4LogicalVolume.hh" 00049 #include "G4Region.hh" 00050 #include "G4VPhysicalVolume.hh" 00051 #include "G4ParticleTable.hh" 00052 #include "G4ParticleDefinition.hh" 00053 #include "G4VParticleChange.hh" 00054 #include "G4FastTrack.hh" 00055 #include "G4FastStep.hh" 00056 #include "G4VFastSimulationModel.hh" 00057 #include "G4RotationMatrix.hh" 00058 #include "G4ThreeVector.hh" 00059 #include "G4Transform3D.hh" 00060 #include "G4FastSimulationVector.hh" 00061 00062 #include "G4ios.hh" 00063 00064 //--------------------------- 00065 // For possible future needs: 00066 //--------------------------- 00067 typedef G4Region G4Envelope; 00068 00069 //------------------------------------------- 00070 // 00071 // G4FastSimulationManager class 00072 // 00073 //------------------------------------------- 00074 00075 // Class Description: 00076 // The G4VFastSimulationModel objects are attached to the envelope 00077 // through a G4FastSimulationManager. 00078 // This object will manage the list of models and will message them 00079 // at tracking time. 00080 // 00081 00082 00083 class G4FastSimulationManager 00084 { 00085 public: // with description 00086 //------------------------ 00087 // Constructor/Destructor 00088 //------------------------ 00089 // Only one Constructor. By default the envelope can 00090 // be placed n-Times. 00091 // If the user is sure that it is placed just one time, 00092 // the IsUnique flag should be set TRUE to avoid the 00093 // G4AffineTransform re-calculations each time we reach 00094 // the envelope. 00095 00096 G4FastSimulationManager(G4Envelope *anEnvelope, 00097 G4bool IsUnique = FALSE); 00098 // This is the only constructor. In this constructor you specify 00099 // the envelope by giving the G4Region (typedef-ed as G4Envelope) 00100 // pointer. The G4FastSimulationManager object will bind itself to 00101 // this envelope and will notify this G4Region to become an envelope. 00102 // If you know that this region is used for only one logical volume, 00103 // you can turn the IsUnique boolean to "true" to allow some optimization. 00104 // 00105 // Note that if you choose to use the G4VFastSimulationModel(const G4String&, 00106 // G4Region*, G4bool) constructor for you model, the G4FastSimulationManager 00107 // will be constructed using the given G4Region* and G4bool values of the 00108 // model constructor. 00109 // 00110 00111 public: // without description 00112 ~G4FastSimulationManager(); 00113 00114 00115 public: // with description 00116 // Methods to add/remove models to/from the Model 00117 // List. 00118 // 00119 void AddFastSimulationModel(G4VFastSimulationModel*); 00120 // Add a model to the Model List. 00121 00122 void RemoveFastSimulationModel(G4VFastSimulationModel*); 00123 // Remove a model from the Model List. 00124 00125 // Methods to activate/inactivate models from the Model 00126 // List. 00127 00128 G4bool ActivateFastSimulationModel(const G4String&); 00129 // Activate a model in the Model List. 00130 00131 G4bool InActivateFastSimulationModel(const G4String&); 00132 // Inactivate a model in the Model List. 00133 00134 public: // without description 00135 // Methods for print/control commands 00136 void ListTitle() const; 00137 void ListModels() const; 00138 void ListModels(const G4ParticleDefinition*) const; 00139 void ListModels(const G4String& aName) const; 00140 const G4Envelope* GetEnvelope() const; 00141 00142 G4VFastSimulationModel* GetFastSimulationModel(const G4String& modelName, 00143 const G4VFastSimulationModel* previousFound, 00144 bool &foundPrevious) const; 00145 00146 const std::vector<G4VFastSimulationModel*>& GetFastSimulationModelList() const 00147 {return ModelList;} 00148 00149 00150 //---------------------------------------------- 00151 // Interface methods for the 00152 // G4FastSimulationManagerProcess process. 00153 //---------------------------------------------- 00154 // Trigger 00155 G4bool PostStepGetFastSimulationManagerTrigger(const G4Track &, 00156 const G4Navigator* a = 0); 00157 // DoIt 00158 G4VParticleChange* InvokePostStepDoIt(); 00159 00160 // AtRest methods: 00161 G4bool AtRestGetFastSimulationManagerTrigger(const G4Track &, 00162 const G4Navigator* a = 0); 00163 G4VParticleChange* InvokeAtRestDoIt(); 00164 00165 // For management 00166 G4bool operator == ( const G4FastSimulationManager&) const; 00167 00168 private: 00169 // Private members : 00170 G4FastTrack fFastTrack; 00171 G4FastStep fFastStep; 00172 G4VFastSimulationModel* fTriggedFastSimulationModel; 00173 G4FastSimulationVector <G4VFastSimulationModel> ModelList; 00174 G4FastSimulationVector <G4VFastSimulationModel> fInactivatedModels; 00175 00176 G4ParticleDefinition* fLastCrossedParticle; 00177 G4FastSimulationVector <G4VFastSimulationModel> fApplicableModelList; 00178 00179 // -- *** depracating, to be dropped @ next major release: 00180 G4FastSimulationVector <G4Transform3D> GhostPlacements; 00181 }; 00182 00183 inline void 00184 G4FastSimulationManager::AddFastSimulationModel(G4VFastSimulationModel* fsm) 00185 { 00186 ModelList.push_back(fsm); 00187 // forces the fApplicableModelList to be rebuild 00188 fLastCrossedParticle = 0; 00189 } 00190 00191 inline void 00192 G4FastSimulationManager::RemoveFastSimulationModel(G4VFastSimulationModel* fsm) 00193 { 00194 if(!ModelList.remove(fsm)) fInactivatedModels.remove(fsm); 00195 // forces the fApplicableModelList to be rebuild 00196 fLastCrossedParticle = 0; 00197 } 00198 00199 inline G4bool 00200 G4FastSimulationManager::operator == (const G4FastSimulationManager& fsm) const 00201 { 00202 return (this==&fsm) ? true : false; 00203 } 00204 00205 inline const G4Envelope* 00206 G4FastSimulationManager::GetEnvelope() const 00207 { 00208 return fFastTrack.GetEnvelope(); 00209 } 00210 00211 #endif