Changeset 288
- Timestamp:
- Sep 25, 2007, 12:24:08 PM (17 years ago)
- Location:
- snovis/trunk/source/G4Lab
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
snovis/trunk/source/G4Lab/DigitsCollectionAccessor.h
r233 r288 11 11 class G4LogicalVolume; 12 12 class G4Colour; 13 class G4RunManager; 13 14 14 15 namespace Slash {namespace Core {class ISession;}} … … 29 30 virtual void visualize(Slash::Data::IAccessor::Data,void*); 30 31 public: 31 DigitsCollectionBaseAccessor(Slash::Core::ISession&,const std::string& = ""); 32 DigitsCollectionBaseAccessor(Slash::Core::ISession&,G4RunManager*, 33 const std::string& = ""); 32 34 virtual ~DigitsCollectionBaseAccessor(); 33 35 const std::string& DCName() const; 34 36 protected: 35 static G4VDigiCollection* getCollection(Slash::Core::IWriter&,const std::string&);36 37 static G4LogicalVolume* digiLogicalVolume(const G4VDigi&); 37 38 static G4Transform3D* digiTransform3D(const G4VDigi&); … … 39 40 void setProperties(G4VDigi&); 40 41 protected: 42 G4VDigiCollection* getCollection(Slash::Core::IWriter&,const std::string&); 43 protected: 41 44 std::string fType; 45 G4RunManager* fRunManager; 42 46 std::map<G4String,G4AttDef>* fAttDefs; 43 47 std::string fDC; … … 88 92 } 89 93 public: 90 DigitsCollectionAccessor(Slash::Core::ISession& aSession,const std::string& aName = "") 91 :DigitsCollectionBaseAccessor(aSession,aName){} 94 DigitsCollectionAccessor(Slash::Core::ISession& aSession, 95 G4RunManager* aRunManager, 96 const std::string& aName = "") 97 :DigitsCollectionBaseAccessor(aSession,aRunManager,aName){} 92 98 virtual ~DigitsCollectionAccessor(){} 93 99 }; -
snovis/trunk/source/G4Lab/HitsCollectionAccessor.h
r233 r288 11 11 class G4LogicalVolume; 12 12 class G4Colour; 13 class G4RunManager; 13 14 14 15 namespace Slash {namespace Core {class ISession;}} … … 30 31 virtual void visualize(Slash::Data::IAccessor::Data,void*); 31 32 public: 32 HitsCollectionAccessor(Slash::Core::ISession&,const std::string& = ""); 33 HitsCollectionAccessor(Slash::Core::ISession&,G4RunManager*, 34 const std::string& = ""); 33 35 virtual ~HitsCollectionAccessor(); 34 36 const std::string& HCName() const; … … 37 39 static G4Transform3D* hitTransform3D(const G4VHit&); 38 40 static bool hitColor(const G4VHit&,G4Colour&); 39 static G4VHitsCollection* getCollection(Slash::Core::IWriter&,const std::string&); 41 protected: 42 G4VHitsCollection* getCollection(Slash::Core::IWriter&,const std::string&); 40 43 private: 41 44 std::string fType; 45 G4RunManager* fRunManager; 42 46 std::map<G4String,G4AttDef>* fAttDefs; 43 47 std::string fHC; -
snovis/trunk/source/G4Lab/PhysicsTableAccessor.h
r233 r288 14 14 namespace AIDA {class IAnalysisFactory;} 15 15 16 namespace G4Lab {class PhysicsTable;} 17 18 class IGeant4Manager; 19 16 20 namespace G4Lab { 17 18 class PhysicsTable;19 21 20 22 class PhysicsTableAccessor 21 23 :public Lib::BaseAccessor 22 ,public Slash::Data::IVisualizer24 ,public virtual Slash::Data::IVisualizer 23 25 { 24 26 public: //Slash::Data::IAccessor 27 virtual void* cast(const std::string& aClass) const; 25 28 virtual std::string name() const; 26 29 virtual Slash::Data::IIterator* iterator(); … … 31 34 virtual void endVisualize(); 32 35 public: 33 PhysicsTableAccessor(Slash::Core::ISession&,AIDA::IAnalysisFactory*); 36 PhysicsTableAccessor(Slash::Core::ISession&, 37 IGeant4Manager&, 38 AIDA::IAnalysisFactory*); 34 39 virtual ~PhysicsTableAccessor(); 35 40 private: 41 bool buildProcessTables(); 36 42 bool findProcessTables(G4ParticleDefinition*, 37 43 G4VProcess*, … … 43 49 std::vector<PhysicsTable*> fTables; 44 50 AIDA::IAnalysisFactory* fAIDA; 51 IGeant4Manager& fManager; 45 52 }; 46 53 -
snovis/trunk/source/G4Lab/SoG4RunManager.h
r233 r288 2 2 #define G4Lab_SoG4RunManager_h 3 3 4 // Inheritance : 4 5 #include <Inventor/nodes/SoSubNode.h> 6 5 7 #include <Inventor/fields/SoSFInt32.h> 8 9 class G4RunManager; 6 10 7 11 class SoG4RunManager : public SoNode { … … 11 15 public: 12 16 SoG4RunManager(); 17 SoG4RunManager(G4RunManager*); 13 18 public: 14 19 static void initClass(); … … 17 22 protected: 18 23 virtual ~SoG4RunManager(); 24 private: 25 G4RunManager* fRunManager; 19 26 }; 20 27 -
snovis/trunk/source/G4Lab/SoG4Trajectories.h
r233 r288 14 14 15 15 class G4TrajectoryContainer; 16 class G4RunManager; 17 16 18 class SoSensor; 17 19 class SoFieldSensor; … … 48 50 public: 49 51 SoG4Trajectories(); 52 SoG4Trajectories(G4RunManager*); 50 53 virtual void generateAlternateRep(); 51 54 virtual void clearAlternateRep(); … … 63 66 void flush(); 64 67 static void sensorCB(void*,SoSensor*); 65 bool isG4LabTrajectories(G4TrajectoryContainer*);66 68 void timeOrder(G4TrajectoryContainer*); 67 69 private: 70 G4RunManager* fRunManager; 68 71 G4TrajectoryContainer* fContainer; 69 72 std::vector< std::vector<PointIdentifier> > fTimeOrderedPoints; -
snovis/trunk/source/G4Lab/Trajectory.h
r233 r288 2 2 #define G4Lab_Trajectory_h 3 3 4 // Inheritance : 4 5 #include <G4Trajectory.hh> 6 #include <G4Lab/Interfaces/IGeant4Trajectory.h> 5 7 6 8 #include <vector> … … 8 10 #include <Lib/Debug.h> 9 11 12 //class G4VProcess; 13 10 14 namespace G4Lab { 11 15 12 16 class TrajectoryPoint; 13 17 14 class Trajectory : public G4Trajectory { 18 class Trajectory 19 :public G4Trajectory 20 ,public virtual IGeant4Trajectory 21 { 22 public: // G4VTrajectory: 23 virtual const std::map<G4String,G4AttDef>* GetAttDefs() const; 24 virtual std::vector<G4AttValue>* CreateAttValues() const; 15 25 public: // G4Trajectory: 16 26 virtual void ShowTrajectory(std::ostream& = G4cout) const; … … 20 30 virtual G4VTrajectoryPoint* GetPoint(G4int) const; 21 31 virtual void MergeTrajectory(G4VTrajectory*); 32 public: // IGeant4Trajectory: 33 virtual double kineticEnergy() const; 34 virtual double totalEnergy() const; 35 virtual double globalTime() const; 36 virtual unsigned int pointEntries() const; 37 virtual double pointGlobalTime(unsigned int) const; 38 virtual std::string creatorProcessName() const; 39 virtual std::string creatorProcessType() const; 40 virtual void setSave(bool); 41 virtual bool save() const; 42 virtual std::vector<double> stoppingPoint() const; 43 virtual G4VPhysicalVolume* stoppingPhysicalVolume() const; 22 44 public: 23 45 Trajectory(const G4Track*); 24 46 Trajectory(Trajectory&); 25 47 virtual ~Trajectory(); 26 /*inline*/ void* operator new(size_t); 27 /*inline*/ void operator delete(void*); 28 /*inline*/ int operator == (const Trajectory&) const; 29 G4double GetKineticEnergy() const; 30 G4double GetTotalEnergy() const; 31 G4double GetGlobalTime() const; 32 G4double GetPointGlobalTime(G4int) const; 48 void* operator new(size_t); 49 void operator delete(void*); 50 int operator == (const Trajectory&) const; 33 51 private: 34 52 std::vector<TrajectoryPoint*> fPoints; … … 36 54 G4double fTotalEnergy; 37 55 G4double fGlobalTime; 56 const G4VProcess* fProcess; 57 bool fSave; 58 G4ThreeVector fStoppingPoint; 59 G4VPhysicalVolume* fStoppingVolume; 38 60 Lib::Debug fDebug; 39 61 }; -
snovis/trunk/source/G4Lab/TrajectoryAccessor.h
r233 r288 13 13 class IOut; 14 14 15 class G4RunManager; 16 17 #include <map> 18 #include <G4AttDef.hh> 19 #include <G4String.hh> 20 15 21 namespace G4Lab { 16 22 … … 25 31 virtual void endVisualize(); 26 32 public: 27 TrajectoryAccessor(Slash::Core::ISession& );33 TrajectoryAccessor(Slash::Core::ISession&,G4RunManager*); 28 34 virtual ~TrajectoryAccessor(); 29 35 private: 30 36 void addPolyline(SoGroup*,const SbName&, 31 37 int,SbVec3f*,const SbColor&,const SbColor&,IOut&); 32 bool isG4LabTrajectory(); 38 bool isIGeant4Trajectory(); 39 void addAttDefsProperties(); 40 Slash::Core::IValue* findAttDefsValue(Slash::Data::IAccessor::Data, 41 const std::string&,void*); 33 42 private: 34 43 std::string fType; 44 G4RunManager* fRunManager; 45 std::map<G4String,G4AttDef>* fAttDefs; 35 46 std::string fModeling; 36 bool f G4Lab;47 bool fIGeant4Trajectory; 37 48 SoSeparator* fSeparator; 38 49 SoCoordinate3* fCoordinate; -
snovis/trunk/source/G4Lab/TrajectoryContainerAccessor.h
r233 r288 7 7 namespace Slash {namespace Core {class ISession;}} 8 8 9 class G4RunManager; 10 9 11 namespace G4Lab { 10 12 … … 13 15 virtual std::string name() const; 14 16 virtual Slash::Data::IIterator* iterator(); 17 virtual Slash::Core::IValue* findValue(Slash::Data::IAccessor::Data,const std::string&,void*); 15 18 public: //Slash::Data::IVisualizer 16 19 virtual void beginVisualize(); … … 18 21 virtual void endVisualize(); 19 22 public: 20 TrajectoryContainerAccessor(Slash::Core::ISession& );23 TrajectoryContainerAccessor(Slash::Core::ISession&,G4RunManager*); 21 24 virtual ~TrajectoryContainerAccessor(); 22 25 private: 23 26 std::string fType; 27 G4RunManager* fRunManager; 24 28 }; 25 29 -
snovis/trunk/source/G4Lab/Version.h
r233 r288 3 3 4 4 #define G4LAB_MAJOR_VERSION 8 5 #define G4LAB_MINOR_VERSION 05 #define G4LAB_MINOR_VERSION 1 6 6 #define G4LAB_PATCH_VERSION 0 7 #define G4LAB_VERSION "8. 0.0"8 #define G4LAB_VERSION_VRP "v8r 0p0"7 #define G4LAB_VERSION "8.1.0" 8 #define G4LAB_VERSION_VRP "v8r1p0" 9 9 10 10 #endif -
snovis/trunk/source/G4Lab/cxx/DigitsCollectionAccessor.cxx
r233 r288 47 47 G4Lab::DigitsCollectionBaseAccessor::DigitsCollectionBaseAccessor( 48 48 Slash::Core::ISession& aSession 49 ,G4RunManager* aRunManager 49 50 ,const std::string& aDC 50 51 ) 51 52 :OnX::InventorAccessor(aSession) 52 53 ,fType("DC") 54 ,fRunManager(aRunManager) 53 55 ,fAttDefs(0) 54 56 ,fDC(aDC) … … 277 279 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 278 280 { 279 G4RunManager* runManager = G4RunManager::GetRunManager(); 280 if(!runManager) { 281 if(!fRunManager) { 281 282 Lib::Out out(aPrinter); 282 283 out << "No G4RunManager." << Lib::endl; 283 284 return 0; 284 285 } 285 const G4Event* event = runManager->GetCurrentEvent();286 const G4Event* event = fRunManager->GetCurrentEvent(); 286 287 if(!event) { 287 288 Lib::Out out(aPrinter); -
snovis/trunk/source/G4Lab/cxx/HitsCollectionAccessor.cxx
r233 r288 44 44 G4Lab::HitsCollectionAccessor::HitsCollectionAccessor( 45 45 Slash::Core::ISession& aSession 46 ,G4RunManager* aRunManager 46 47 ,const std::string& aHC 47 48 ) 48 49 :OnX::InventorAccessor(aSession) 49 50 ,fType("HC") 51 ,fRunManager(aRunManager) 50 52 ,fAttDefs(0) 51 53 ,fHC(aHC) … … 341 343 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 342 344 { 343 G4RunManager* runManager = G4RunManager::GetRunManager(); 344 if(!runManager) { 345 if(!fRunManager) { 345 346 Lib::Out out(aPrinter); 346 347 out << "No G4RunManager." << Lib::endl; 347 348 return 0; 348 349 } 349 const G4Event* event = runManager->GetCurrentEvent();350 const G4Event* event = fRunManager->GetCurrentEvent(); 350 351 if(!event) { 351 352 Lib::Out out(aPrinter); -
snovis/trunk/source/G4Lab/cxx/Manager.cxx
r233 r288 174 174 } else { 175 175 if(!accessorManager->findAccessor("PV")) { 176 if(!fRunManager) { 177 Lib::Out out(fSession.printer()); 178 out << "G4Lab::Manager::initialize :" 179 << " no G4RunManager." 180 << Lib::endl; 181 } 182 176 183 accessorManager->addAccessor(new PhysicalVolumeAccessor(fSession)); 177 accessorManager->addAccessor(new TrajectoryContainerAccessor(fSession)); 178 accessorManager->addAccessor(new TrajectoryAccessor(fSession)); 179 accessorManager->addAccessor(new PhysicsTableAccessor(fSession,aida)); 184 accessorManager->addAccessor 185 (new TrajectoryContainerAccessor(fSession,fRunManager)); 186 accessorManager->addAccessor 187 (new TrajectoryAccessor(fSession,fRunManager)); 188 accessorManager->addAccessor 189 (new PhysicsTableAccessor(fSession,*this,aida)); 180 190 181 191 // Declare HitsCollections types : … … 200 210 G4String hcName = hcTable->GetHCname(index); 201 211 accessorManager->addAccessor 202 (new HitsCollectionAccessor(fSession, hcName));212 (new HitsCollectionAccessor(fSession,fRunManager,hcName)); 203 213 if(fSession.verboseLevel()) { 204 214 Lib::Out out(fSession.printer()); … … 214 224 215 225 //Declare the generic HitsCollection type : 216 accessorManager->addAccessor(new HitsCollectionAccessor(fSession)); 226 accessorManager->addAccessor 227 (new HitsCollectionAccessor(fSession,fRunManager)); 217 228 218 229 // Should be initialized once after Inventor and HEPVis : -
snovis/trunk/source/G4Lab/cxx/PhysicsTableAccessor.cxx
r233 r288 24 24 #include <Slash/Data/IIterator.h> 25 25 #include <Lib/Out.h> 26 #include <Lib/sout.h> 26 27 #include <Lib/Value.h> 27 28 #include <Lib/smanip.h> 28 29 #include <Lib/fmanip.h> 29 30 #include <Lib/dirmanip.h> 31 #include <Lib/Cast.h> 30 32 #include <Lib/Debug.h> 31 33 … … 39 41 #include <AIDA/IFunctionFactory.h> 40 42 #include <AIDA/IFunction.h> 43 44 // G4Lab : 45 #include <G4Lab/Interfaces/IGeant4Manager.h> 41 46 42 47 namespace G4Lab { … … 72 77 G4Lab::PhysicsTableAccessor::PhysicsTableAccessor( 73 78 Slash::Core::ISession& aSession 79 ,IGeant4Manager& aManager 74 80 ,AIDA::IAnalysisFactory* aAIDA 75 81 ) 76 82 :Lib::BaseAccessor(aSession.printer()) 77 83 ,fSession(aSession) 84 ,fManager(aManager) 78 85 ,fType("PhysicsTable") 79 86 ,fAIDA(aAIDA) … … 94 101 { 95 102 for(unsigned int index=0;index<fTables.size();index++) delete fTables[index]; 103 } 104 ////////////////////////////////////////////////////////////////////////////// 105 void* G4Lab::PhysicsTableAccessor::cast( 106 const std::string& aClass 107 ) const 108 ////////////////////////////////////////////////////////////////////////////// 109 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 110 { 111 if_Lib_SCast(Slash::Data::IVisualizer) 112 else return Lib::BaseAccessor::cast(aClass); 96 113 } 97 114 ////////////////////////////////////////////////////////////////////////////// … … 129 146 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 130 147 { 131 if(!fTables.size() ) { 132 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 133 if(particleTable) { 134 G4ParticleTable::G4PTblDicIterator* particleTableIterator = 135 particleTable->GetIterator(); 136 if(particleTableIterator) { 137 particleTableIterator->reset(); 138 while( (*particleTableIterator)() ){ 139 G4ParticleDefinition* particle = particleTableIterator->value(); 140 if(particle) { 141 G4String particleName = particle->GetParticleName(); 142 //Lib::Out out(fSession.printer()); 143 //out << "debug : Particle : " << particleName << Lib::endl; 144 // Processes for this particle : 145 G4ProcessManager* processManager = particle->GetProcessManager(); 146 if(processManager) { 147 G4ProcessVector* processList = processManager->GetProcessList(); 148 if(processList) { 149 int number = processList->entries(); 150 for (int index=0;index<number;index++){ 151 G4VProcess* process = (*processList)(index); 152 std::vector<std::string> names; 153 std::vector<G4PhysicsTable*> tables; 154 if(findProcessTables(particle, 155 process, 156 names, 157 tables)) { 158 for(unsigned int i=0;i<tables.size();i++) { 159 std::vector<std::string> words; 160 Lib::smanip::words(names[i],".",words); 161 if(words.size()==3) { 162 fTables.push_back(new PhysicsTable(words[0], 163 words[1], 164 words[2], 165 tables[i], 166 process, 167 particle)); 168 } 169 } 170 } 171 } 172 } 173 } 174 } 175 } 176 } 177 } 178 } 179 148 if(!fTables.size()) { 149 if(!buildProcessTables()) return 0; 150 } 180 151 return new PhysicsTableIterator(fTables); 181 152 } … … 277 248 G4PhysicsVector* physicsVector = (*(obj->fTable))[count]; 278 249 size_t n = physicsVector->GetVectorLength(); 279 if(n>=2) { 280 std::string name; 281 Lib::smanip::printf(name,1024,"%s.%s.%s.%d", 282 obj->fTableName.c_str(), 283 obj->fProcessName.c_str(), 284 obj->fParticleName.c_str(), 285 count); 286 std::vector<double> params; 287 params.push_back(1); // Dimension of the grid (here one). 288 params.push_back(n); // Number of entries for first grid axis. 289 size_t i; 290 for (i=0;i<n;i++) params.push_back(i); // Xs. 291 for (i=0;i<n;i++) params.push_back((*physicsVector)[i]); //Values. 292 AIDA::IFunction* function = 293 functionFactory->createFunctionByName(name,"Grid1D"); 294 if(!function) { 295 Lib::Out out(fSession.printer()); 296 out << "Can't create \"" << name << "\" function." << Lib::endl; 297 break; 298 } 299 function->setParameters(params); 250 if(n<2) { 251 Lib::Out out(fSession.printer()); 252 out << "PhysicsVector with " << int(n) << " entries. Can't plot." 253 << Lib::endl; 254 continue; 255 } 256 257 std::string name; 258 Lib::smanip::printf(name,1024,"%s.%s.%s.%d", 259 obj->fTableName.c_str(), 260 obj->fProcessName.c_str(), 261 obj->fParticleName.c_str(), 262 count); 263 std::vector<double> params; 264 params.push_back(1); // Dimension of the grid (here one). 265 params.push_back(n); // Number of entries for first grid axis. 266 size_t i; 267 for (i=0;i<n;i++) params.push_back(i); // Xs. 268 for (i=0;i<n;i++) params.push_back((*physicsVector)[i]); //Values. 269 AIDA::IFunction* function = 270 functionFactory->createFunctionByName(name,"Grid1D"); 271 if(!function) { 272 Lib::Out out(fSession.printer()); 273 out << "Can't create \"" << name << "\" function." << Lib::endl; 274 break; 275 } 276 function->setParameters(params); 300 277 301 AIDA::IPlotterRegion& region = plotter->currentRegion(); 302 303 region.plot(*function); 304 region.setParameter("plotter.xAxisAutomated","FALSE"); 305 std::string value1; 306 Lib::smanip::printf(value1,32,"%g",0.); 307 region.setParameter("plotter.xAxisMinimum",value1); 308 std::string value2; 309 Lib::smanip::printf(value2,32,"%g",(double)(n-1)); 310 region.setParameter("plotter.xAxisMaximum",value2); 311 std::string value3; 312 Lib::smanip::printf(value3,32,"%d",4 * n); 313 region.setParameter("plotter.xNumberOfPoints",value3); 314 /* 315 fSession.out().println("debug : min : %s, max : %s, steps : %s\n.", 316 value1.c_str(),value2.c_str(),value3.c_str()); 317 */ 318 319 if(!superpose) plotter->next(); 278 AIDA::IPlotterRegion& region = plotter->currentRegion(); 279 280 region.plot(*function); 281 region.setParameter("plotter.xAxisAutomated","FALSE"); 282 std::string value1; 283 Lib::smanip::printf(value1,32,"%g",0.); 284 region.setParameter("plotter.xAxisMinimum",value1); 285 std::string value2; 286 Lib::smanip::printf(value2,32,"%g",(double)(n-1)); 287 region.setParameter("plotter.xAxisMaximum",value2); 288 //std::string value3; 289 //Lib::smanip::printf(value3,32,"%d",4 * n); 290 //region.setParameter("plotter.xNumberOfPoints",value3); 291 /* 292 fSession.out().println("debug : min : %s, max : %s, steps : %s\n.", 293 value1.c_str(),value2.c_str(),value3.c_str()); 294 */ 295 if(!superpose) plotter->next(); 320 296 321 }322 297 } 323 298 … … 335 310 } 336 311 ////////////////////////////////////////////////////////////////////////////// 312 bool G4Lab::PhysicsTableAccessor::buildProcessTables( 313 ) 314 ////////////////////////////////////////////////////////////////////////////// 315 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 316 { 317 if(fTables.size()) return true; //done. 318 319 if(!fManager.isRunning()) { 320 Lib::Out out(fSession.printer()); 321 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 322 << " It is needed to have started a run to get physics tables." 323 << Lib::endl; 324 return false; 325 } 326 327 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 328 if(!particleTable) { 329 Lib::Out out(fSession.printer()); 330 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 331 << " Can't get particle table." 332 << Lib::endl; 333 return false; 334 } 335 336 G4ParticleTable::G4PTblDicIterator* particleTableIterator = 337 particleTable->GetIterator(); 338 if(!particleTableIterator) { 339 Lib::Out out(fSession.printer()); 340 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 341 << " Can't get particle table iterator." 342 << Lib::endl; 343 return false; 344 } 345 346 particleTableIterator->reset(); 347 while( (*particleTableIterator)() ){ 348 G4ParticleDefinition* particle = particleTableIterator->value(); 349 if(!particle) { 350 Lib::Out out(fSession.printer()); 351 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 352 << " Can't get particle table particle." 353 << Lib::endl; 354 return false; 355 } 356 G4String particleName = particle->GetParticleName(); 357 //Lib::Out out(fSession.printer()); 358 //out << "debug : Particle : " << particleName << Lib::endl; 359 360 // Processes for this particle : 361 G4ProcessManager* processManager = particle->GetProcessManager(); 362 if(!processManager) { 363 Lib::Out out(fSession.printer()); 364 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 365 << " Can't get process manager of particle " 366 << particleName << "." 367 << Lib::endl; 368 return false; 369 } 370 371 G4ProcessVector* processList = processManager->GetProcessList(); 372 if(!processList) { 373 Lib::Out out(fSession.printer()); 374 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 375 << " Can't get process list for process manager of particle " 376 << particleName << "." 377 << Lib::endl; 378 return false; 379 } 380 381 int number = processList->entries(); 382 for (int index=0;index<number;index++){ 383 G4VProcess* process = (*processList)(index); 384 std::vector<std::string> names; 385 std::vector<G4PhysicsTable*> tables; 386 if(!findProcessTables(particle,process,names,tables)) { 387 return false; 388 } 389 390 for(unsigned int i=0;i<tables.size();i++) { 391 std::vector<std::string> words; 392 Lib::smanip::words(names[i],".",words); 393 if(words.size()!=3) { 394 Lib::Out out(fSession.printer()); 395 out << "G4Lab::PhysicsTableAccessor::buildProcessTables :" 396 << " Three words separted with a dot expected in " 397 << names[i] << " for particle " << particleName << "." 398 << Lib::endl; 399 return false; 400 } 401 fTables.push_back(new PhysicsTable(words[0], 402 words[1], 403 words[2], 404 tables[i], 405 process, 406 particle)); 407 } 408 } 409 } 410 411 return true; 412 } 413 ////////////////////////////////////////////////////////////////////////////// 337 414 bool G4Lab::PhysicsTableAccessor::findProcessTables( 338 415 G4ParticleDefinition* aParticle … … 364 441 #else 365 442 G4bool ascii = false; 443 //G4bool ascii = true; 366 444 #endif 367 aProcess->StorePhysicsTable(aParticle,tmpName,ascii); 368 369 // Analyse the content of the directory : 370 std::vector<std::string> files; 371 if(!Lib::dirmanip::entries(tmpName,files,false)) { 372 Lib::Out out(fSession.printer()); 373 out << "Can't get files in \"" << tmpName << "\" directory." << Lib::endl; 445 446 if(!aProcess->StorePhysicsTable(aParticle,tmpName,ascii)) { 447 Lib::Out out(fSession.printer()); 448 out << "Can't store physics table for particle " 449 << aParticle->GetParticleName() 450 << " and process " << aProcess->GetProcessName() << "." 451 << Lib::endl; 452 //return false; 374 453 } else { 375 // Analyse files : 376 Lib::smanip::remove(files,"."); 377 Lib::smanip::remove(files,".."); 378 for(unsigned int index=0;index<files.size();index++) { 379 std::vector<std::string> words; 380 Lib::smanip::words(files[index],".",words); 381 //Lib::Out out(fSession.printer()); 382 //out << "debug : Analyse \"" << files[index] << "\" ." << Lib::endl; 383 if(words.size()==4) { 454 455 // Analyse the content of the directory : 456 std::vector<std::string> files; 457 if(!Lib::dirmanip::entries(tmpName,files,false)) { 458 Lib::Out out(fSession.printer()); 459 out << "Can't get files in \"" << tmpName << "\" directory." 460 << Lib::endl; 461 } else { 462 // Analyse files : 463 Lib::smanip::remove(files,"."); 464 Lib::smanip::remove(files,".."); 465 /* 466 if(!files.size()) { 467 Lib::Out out(fSession.printer()); 468 out << "No files in \"" << tmpName << "\" directory for particle " 469 << aParticle->GetParticleName() 470 << " and process " << aProcess->GetProcessName() << "." 471 << Lib::endl; 472 //return false; 473 } 474 */ 475 for(unsigned int index=0;index<files.size();index++) { 476 std::vector<std::string> words; 477 Lib::smanip::words(files[index],".",words); 478 //Lib::Out out(fSession.printer()); 479 //out << "debug : Analyse \"" << files[index] << "\" ." << Lib::endl; 480 if(words.size()!=4) { 481 Lib::Out out(fSession.printer()); 482 out << "Bad syntax in file name " << Lib::sout(files[index]) 483 << " for particle " << aParticle->GetParticleName() 484 << " and process " << aProcess->GetProcessName() << "." 485 << Lib::endl; 486 //aTables.clear(); 487 //aPhysicsTables.clear(); 488 //return false; 489 continue; 490 } 384 491 std::string table = words[0]; 385 492 std::string process = words[1]; … … 393 500 G4PhysicsTable* physicsTable = 394 501 new G4PhysicsTable(G4Element::GetNumberOfElements()); 395 if(physicsTable) { 396 G4bool status = physicsTable->RetrievePhysicsTable(filename,ascii); 397 if(!status){ 398 Lib::Out out(fSession.printer()); 399 out << "Unable to read \"" << filename << "\" file." << Lib::endl; 400 delete physicsTable; 401 physicsTable = 0; 402 } 502 G4bool status = physicsTable->RetrievePhysicsTable(filename,ascii); 503 if(!status){ 504 Lib::Out out(fSession.printer()); 505 out << "Unable to read \"" << filename << "\" file." << Lib::endl; 506 delete physicsTable; 507 physicsTable = 0; 403 508 } 404 509 if(physicsTable) { … … 408 513 } 409 514 } 515 410 516 } 411 517 -
snovis/trunk/source/G4Lab/cxx/SoG4RunManager.cxx
r233 r288 27 27 SoG4RunManager::SoG4RunManager( 28 28 ) 29 :fRunManager(0) 30 ////////////////////////////////////////////////////////////////////////////// 31 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 32 { 33 SO_NODE_CONSTRUCTOR(SoG4RunManager); 34 SO_NODE_ADD_FIELD(numberOfEvents,(1)); 35 } 36 ////////////////////////////////////////////////////////////////////////////// 37 SoG4RunManager::SoG4RunManager( 38 G4RunManager* aRunManager 39 ) 40 :fRunManager(aRunManager) 29 41 ////////////////////////////////////////////////////////////////////////////// 30 42 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// … … 47 59 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 48 60 { 49 G4RunManager* runManager = G4RunManager::GetRunManager(); 50 if(!runManager) return; 61 if(!fRunManager) return; 51 62 52 63 G4Lab::SteppingAction* g4LabSteppingAction = 0; 53 64 54 65 G4UserSteppingAction* steppingAction = 55 (G4UserSteppingAction*) runManager->GetUserSteppingAction();66 (G4UserSteppingAction*)fRunManager->GetUserSteppingAction(); 56 67 if(steppingAction) { 57 68 g4LabSteppingAction = dynamic_cast<G4Lab::SteppingAction*>(steppingAction); … … 68 79 mb.sendFirst(); 69 80 70 runManager->BeamOn(numberOfEvents.getValue());81 fRunManager->BeamOn(numberOfEvents.getValue()); 71 82 72 83 if(g4LabSteppingAction) g4LabSteppingAction->disable(); -
snovis/trunk/source/G4Lab/cxx/SoG4Trajectories.cxx
r233 r288 23 23 // Geant4 : 24 24 #include <G4RunManager.hh> 25 #include <G4Trajectory.hh>26 25 27 26 // G4Lab : … … 47 46 SoG4Trajectories::SoG4Trajectories( 48 47 ) 49 :fContainer(0) 48 :fRunManager(0) 49 ,fContainer(0) 50 50 ,fSensor(0) 51 51 ////////////////////////////////////////////////////////////////////////////// … … 78 78 } 79 79 ////////////////////////////////////////////////////////////////////////////// 80 SoG4Trajectories::SoG4Trajectories( 81 G4RunManager* aRunManager 82 ) 83 :fRunManager(aRunManager) 84 ,fContainer(0) 85 ,fSensor(0) 86 ////////////////////////////////////////////////////////////////////////////// 87 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 88 { 89 SO_NODE_CONSTRUCTOR(SoG4Trajectories); 90 SO_NODE_ADD_FIELD(model,(ALL)); 91 SO_NODE_ADD_FIELD(timeStart,(0)); 92 SO_NODE_ADD_FIELD(timeInterval,(0.05F)); 93 SO_NODE_ADD_FIELD(timeSteps,(100)); 94 SO_NODE_ADD_FIELD(timeIndex,(0)); 95 96 SO_NODE_ADD_FIELD(timeMin,(0)); 97 SO_NODE_ADD_FIELD(timeMax,(0)); 98 SO_NODE_ADD_FIELD(verbose,(FALSE)); 99 100 SO_NODE_ADD_FIELD(alternateRep,(NULL)); 101 102 SO_NODE_DEFINE_ENUM_VALUE(Model,ALL); 103 SO_NODE_DEFINE_ENUM_VALUE(Model,TIMED); 104 105 SO_NODE_SET_SF_ENUM_TYPE(model,Model); 106 107 fSensor = new SoFieldSensor(sensorCB,this); 108 fSensor->attach(&timeInterval); 109 110 timeSteps.addAuditor(&timeInterval,SoNotRec::FIELD); 111 timeStart.addAuditor(&timeInterval,SoNotRec::FIELD); 112 113 } 114 ////////////////////////////////////////////////////////////////////////////// 80 115 SoG4Trajectories::~SoG4Trajectories( 81 116 ) … … 94 129 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 95 130 { 96 G4RunManager* runManager = G4RunManager::GetRunManager(); 97 if(!runManager) return; 98 const G4Event* event = runManager->GetCurrentEvent(); 131 if(!fRunManager) return; 132 const G4Event* event = fRunManager->GetCurrentEvent(); 99 133 if(!event) return; 100 134 G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer(); … … 146 180 int itraj = ids[i].fTrajectory; 147 181 int ipoint = ids[i].fPoint; 148 G4Trajectory* trajectory = 149 (G4Trajectory*)(*trajectoryContainer)[(size_t)itraj]; 182 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)itraj]; 150 183 int pointn = trajectory->GetPointEntries(); 151 184 if( (pointn==1) || (ipoint==pointn-1) ) { 152 G4TrajectoryPoint* tp = 153 (G4TrajectoryPoint*)(trajectory->GetPoint(ipoint)); 185 G4VTrajectoryPoint* tp = trajectory->GetPoint(ipoint); 154 186 G4ThreeVector pos = tp->GetPosition(); 155 187 glVertex3d(pos.x(),pos.y(),pos.z()); … … 163 195 int itraj = ids[i].fTrajectory; 164 196 int ipoint = ids[i].fPoint; 165 G4Trajectory* trajectory = 166 (G4Trajectory*)(*trajectoryContainer)[(size_t)itraj]; 197 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)itraj]; 167 198 int pointn = trajectory->GetPointEntries(); 168 199 if( (pointn==1) || (ipoint==pointn-1) ) { 169 200 } else { 170 G4TrajectoryPoint* tp = 171 (G4TrajectoryPoint*)(trajectory->GetPoint(ipoint)); 201 G4VTrajectoryPoint* tp = trajectory->GetPoint(ipoint); 172 202 G4ThreeVector pos = tp->GetPosition(); 173 203 glVertex3d(pos.x(),pos.y(),pos.z()); 174 tp = (G4TrajectoryPoint*)(trajectory->GetPoint(ipoint+1));204 tp = trajectory->GetPoint(ipoint+1); 175 205 pos = tp->GetPosition(); 176 206 glVertex3d(pos.x(),pos.y(),pos.z()); … … 185 215 int number = trajectoryContainer->entries(); 186 216 for(int index=0;index<number;index++) { 187 G4Trajectory* trajectory = 188 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 217 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 189 218 int pointn = trajectory->GetPointEntries(); 190 219 if(pointn==1) { 191 220 glBegin(GL_POINTS); 192 G4 TrajectoryPoint* tp = (G4TrajectoryPoint*)(trajectory->GetPoint(0));221 G4VTrajectoryPoint* tp = trajectory->GetPoint(0); 193 222 G4ThreeVector pos = tp->GetPosition(); 194 223 glVertex3d(pos.x(),pos.y(),pos.z()); … … 197 226 glBegin(GL_LINE_STRIP); 198 227 for (int i = 0; i < pointn ; i++) { 199 G4TrajectoryPoint* tp = 200 (G4TrajectoryPoint*)(trajectory->GetPoint(i)); 228 G4VTrajectoryPoint* tp = trajectory->GetPoint(i); 201 229 G4ThreeVector pos = tp->GetPosition(); 202 230 glVertex3d(pos.x(),pos.y(),pos.z()); … … 224 252 aAction->setObjectSpace(); 225 253 226 G4RunManager* runManager = G4RunManager::GetRunManager(); 227 if(runManager) { 228 const G4Event* event = runManager->GetCurrentEvent(); 254 if(fRunManager) { 255 const G4Event* event = fRunManager->GetCurrentEvent(); 229 256 if(event) { 230 257 G4TrajectoryContainer* trajectoryContainer = … … 233 260 int number = trajectoryContainer->entries(); 234 261 for(int index=0;index<number;index++) { 235 G4Trajectory* trajectory = 236 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 262 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 237 263 int pointn = trajectory->GetPointEntries(); 238 264 if(!pointn) continue; 239 G4TrajectoryPoint* tp = 240 (G4TrajectoryPoint*)(trajectory->GetPoint(0)); 265 G4VTrajectoryPoint* tp = trajectory->GetPoint(0); 241 266 G4ThreeVector pos = tp->GetPosition(); 242 267 SbVec3f v0; 243 268 v0.setValue((float)pos.x(),(float)pos.y(),(float)pos.z()); 244 269 for (int i = 1; i < pointn ; i++) { 245 tp = (G4TrajectoryPoint*)(trajectory->GetPoint(i));270 tp = trajectory->GetPoint(i); 246 271 pos = tp->GetPosition(); 247 272 SbVec3f v1((float)pos.x(),(float)pos.y(),(float)pos.z()); … … 271 296 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 272 297 { 273 G4RunManager* runManager = G4RunManager::GetRunManager(); 274 if(runManager) { 275 const G4Event* event = runManager->GetCurrentEvent(); 298 if(fRunManager) { 299 const G4Event* event = fRunManager->GetCurrentEvent(); 276 300 if(event) { 277 301 G4TrajectoryContainer* trajectoryContainer = … … 287 311 bool first = true; 288 312 for(int index=0;index<number;index++) { 289 G4Trajectory* trajectory = 290 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 313 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 291 314 int pointn = trajectory->GetPointEntries(); 292 315 for (int i = 0; i < pointn ; i++) { 293 G4TrajectoryPoint* tp = 294 (G4TrajectoryPoint*)(trajectory->GetPoint(i)); 316 G4VTrajectoryPoint* tp = trajectory->GetPoint(i); 295 317 G4ThreeVector pos = tp->GetPosition(); 296 318 if(first) { … … 336 358 } 337 359 ////////////////////////////////////////////////////////////////////////////// 338 bool SoG4Trajectories::isG4LabTrajectories(339 G4TrajectoryContainer* aContainer340 )341 //////////////////////////////////////////////////////////////////////////////342 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//343 {344 if(!aContainer) return false;345 346 int number = aContainer->entries();347 if(number<=0) return false;348 349 // Check if G4Trajectory is a G4Lab::Trajectory :350 G4Lab::Trajectory* trajectory =351 dynamic_cast<G4Lab::Trajectory*>((G4Trajectory*)(*aContainer)[(size_t)0]);352 353 return (trajectory ? true : false);354 }355 //////////////////////////////////////////////////////////////////////////////356 360 void SoG4Trajectories::timeOrder( 357 361 G4TrajectoryContainer* aContainer … … 366 370 367 371 if(!aContainer) return; 368 369 if(!isG4LabTrajectories(aContainer)) return;370 372 371 373 int number = aContainer->entries(); … … 377 379 int numberOfPoints = 0; 378 380 for(int index=0;index<number;index++) { 379 G4Lab::Trajectory* trajectory = 380 (G4Lab::Trajectory*)(*aContainer)[(size_t)index]; 381 int pointn = trajectory->GetPointEntries(); 382 for (int i = 0; i < pointn ; i++) { 383 double globalTime = trajectory->GetPointGlobalTime(i); 381 IGeant4Trajectory* trajectory = 382 dynamic_cast<IGeant4Trajectory*>((*aContainer)[(size_t)index]); 383 if(!trajectory) { 384 fTimeOrderedPoints.clear(); 385 return; 386 } 387 unsigned int pointn = trajectory->pointEntries(); 388 for (unsigned int i = 0; i < pointn ; i++) { 389 double globalTime = trajectory->pointGlobalTime(i); 384 390 if(numberOfPoints==0) { 385 391 minTime = globalTime; … … 392 398 } 393 399 } 400 401 402 394 403 SbBool flag = enableNotify(FALSE); 395 404 timeMin.setValue((float)minTime); … … 409 418 double tmax = tmin + deltaTime; 410 419 for(int index=0;index<number;index++) { 411 G4Lab::Trajectory* trajectory =412 (G4Lab::Trajectory*)(*aContainer)[(size_t)index];413 int pointn = trajectory->GetPointEntries();414 for ( int i = 0; i < pointn ; i++) {415 double globalTime = trajectory-> GetPointGlobalTime(i);420 IGeant4Trajectory* trajectory = 421 dynamic_cast<IGeant4Trajectory*>((*aContainer)[(size_t)index]); 422 unsigned int pointn = trajectory->pointEntries(); 423 for (unsigned int i = 0; i < pointn ; i++) { 424 double globalTime = trajectory->pointGlobalTime(i); 416 425 if((tmin<=globalTime) && (globalTime<tmax)) { 417 426 ids.push_back(PointIdentifier(index,i)); … … 446 455 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 447 456 { 448 G4RunManager* runManager = G4RunManager::GetRunManager(); 449 if(!runManager) return; 450 const G4Event* event = runManager->GetCurrentEvent(); 457 SoG4Trajectories* This = (SoG4Trajectories*)aData; 458 459 if(!This->fRunManager) return; 460 const G4Event* event = This->fRunManager->GetCurrentEvent(); 451 461 if(!event) return; 462 452 463 G4TrajectoryContainer* trajectoryContainer = 453 464 event->GetTrajectoryContainer(); 454 465 if(!trajectoryContainer) return; 455 456 SoG4Trajectories* This = (SoG4Trajectories*)aData;457 466 458 467 This->timeOrder(trajectoryContainer); … … 470 479 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 471 480 { 472 G4RunManager* runManager = G4RunManager::GetRunManager(); 473 if(!runManager) return; 474 const G4Event* event = runManager->GetCurrentEvent(); 481 if(!fRunManager) return; 482 const G4Event* event = fRunManager->GetCurrentEvent(); 475 483 if(!event) return; 476 484 G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer(); … … 480 488 int number = trajectoryContainer->entries(); 481 489 for(int index=0;index<number;index++) { 482 G4Trajectory* trajectory = 483 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 490 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 484 491 int pointn = trajectory->GetPointEntries(); 485 492 if(pointn>=1) { 486 493 SbVec3f* points = new SbVec3f[pointn]; 487 494 for (int i = 0; i < pointn ; i++) { 488 G4TrajectoryPoint* tp = 489 (G4TrajectoryPoint*)(trajectory->GetPoint(i)); 495 G4VTrajectoryPoint* tp = trajectory->GetPoint(i); 490 496 G4ThreeVector pos = tp->GetPosition(); 491 497 points[i].setValue((float)pos.x(),(float)pos.y(),(float)pos.z()); … … 513 519 {int number = trajectoryContainer->entries(); 514 520 for(int index=0;index<number;index++) { 515 G4Trajectory* trajectory = 516 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 521 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 517 522 int pointn = trajectory->GetPointEntries(); 518 523 if(pointn>=1) { … … 531 536 int number = trajectoryContainer->entries(); 532 537 for(int index=0;index<number;index++) { 533 G4Trajectory* trajectory = 534 (G4Trajectory*)(*trajectoryContainer)[(size_t)index]; 538 G4VTrajectory* trajectory = (*trajectoryContainer)[(size_t)index]; 535 539 int pointn = trajectory->GetPointEntries(); 536 540 if(pointn>=1) { 537 541 for (int i = 0; i < pointn ; i++) { 538 G4TrajectoryPoint* tp = 539 (G4TrajectoryPoint*)(trajectory->GetPoint(i)); 542 G4VTrajectoryPoint* tp = trajectory->GetPoint(i); 540 543 G4ThreeVector pos = tp->GetPosition(); 541 544 points[ipoint].setValue((float)pos.x(),(float)pos.y(),(float)pos.z()); -
snovis/trunk/source/G4Lab/cxx/Trajectory.cxx
r233 r288 8 8 // Geant4 : 9 9 #include <G4Track.hh> 10 #include <G4VProcess.hh> 10 11 11 12 static G4Allocator<G4Lab::Trajectory> sTrajectoryAllocator; // Beurk. … … 31 32 ) 32 33 :G4Trajectory(aTrack) 34 ,fProcess(0) 35 ,fSave(false) 36 ,fStoppingVolume(0) 33 37 ////////////////////////////////////////////////////////////////////////////// 34 38 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// … … 37 41 fTotalEnergy = aTrack->GetTotalEnergy(); 38 42 fGlobalTime = aTrack->GetGlobalTime(); 43 fProcess = aTrack->GetCreatorProcess(); 44 45 fStoppingPoint = aTrack->GetPosition(); 46 fStoppingVolume = aTrack->GetVolume(); 47 39 48 /* 40 49 printf("debug : G4Lab::Trajectory : \"%s\", kineticEnergy : %g, totalEnergy : %g, globalTime : %g\n", … … 47 56 aTrack->GetGlobalTime()); 48 57 fPoints.push_back(tp); 58 49 59 } 50 60 ////////////////////////////////////////////////////////////////////////////// 51 61 G4Lab::Trajectory::Trajectory( 52 Trajectory& aRight 53 ) 54 :G4Trajectory(aRight) 55 ////////////////////////////////////////////////////////////////////////////// 56 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 57 { 58 fKineticEnergy = aRight.fKineticEnergy; 59 fTotalEnergy = aRight.fTotalEnergy; 60 fGlobalTime = aRight.fGlobalTime; 61 62 size_t number = aRight.fPoints.size(); 62 Trajectory& aFrom 63 ) 64 :G4Trajectory(aFrom) 65 //,IGeant4Trajectory(aFrom) 66 ////////////////////////////////////////////////////////////////////////////// 67 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 68 { 69 fKineticEnergy = aFrom.fKineticEnergy; 70 fTotalEnergy = aFrom.fTotalEnergy; 71 fGlobalTime = aFrom.fGlobalTime; 72 fProcess = aFrom.fProcess; 73 fSave = aFrom.fSave; 74 75 size_t number = aFrom.fPoints.size(); 63 76 for(size_t index=0;index<number;index++) { 64 G4TrajectoryPoint* point = a Right.fPoints[index]->point();77 G4TrajectoryPoint* point = aFrom.fPoints[index]->point(); 65 78 TrajectoryPoint* tp = 66 new TrajectoryPoint(new G4TrajectoryPoint(*point),a Right.fGlobalTime);79 new TrajectoryPoint(new G4TrajectoryPoint(*point),aFrom.fGlobalTime); 67 80 fPoints.push_back(tp); 68 81 } … … 82 95 } 83 96 ////////////////////////////////////////////////////////////////////////////// 84 G4double G4Lab::Trajectory::GetKineticEnergy( 97 ////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////// 100 double G4Lab::Trajectory::kineticEnergy( 85 101 ) const 86 102 ////////////////////////////////////////////////////////////////////////////// … … 90 106 } 91 107 ////////////////////////////////////////////////////////////////////////////// 92 G4double G4Lab::Trajectory::GetTotalEnergy(108 double G4Lab::Trajectory::totalEnergy( 93 109 ) const 94 110 ////////////////////////////////////////////////////////////////////////////// … … 98 114 } 99 115 ////////////////////////////////////////////////////////////////////////////// 100 G4double G4Lab::Trajectory::GetGlobalTime(116 double G4Lab::Trajectory::globalTime( 101 117 ) const 102 118 ////////////////////////////////////////////////////////////////////////////// … … 106 122 } 107 123 ////////////////////////////////////////////////////////////////////////////// 108 /*inline*/ void* G4Lab::Trajectory::operator new( 124 unsigned int G4Lab::Trajectory::pointEntries( 125 ) const 126 ////////////////////////////////////////////////////////////////////////////// 127 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 128 { 129 return fPoints.size(); 130 } 131 ////////////////////////////////////////////////////////////////////////////// 132 double G4Lab::Trajectory::pointGlobalTime( 133 unsigned int aIndex 134 ) const 135 ////////////////////////////////////////////////////////////////////////////// 136 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 137 { 138 return fPoints[aIndex]->globalTime(); 139 } 140 ////////////////////////////////////////////////////////////////////////////// 141 std::string G4Lab::Trajectory::creatorProcessName( 142 ) const 143 ////////////////////////////////////////////////////////////////////////////// 144 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 145 { 146 if(!fProcess) return ""; 147 return fProcess->GetProcessName(); 148 } 149 ////////////////////////////////////////////////////////////////////////////// 150 std::string G4Lab::Trajectory::creatorProcessType( 151 ) const 152 ////////////////////////////////////////////////////////////////////////////// 153 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 154 { 155 if(!fProcess) return "NotDefined"; 156 switch(fProcess->GetProcessType()){ 157 case fNotDefined: return "NotDefined"; 158 case fTransportation: return "Transportation"; 159 case fElectromagnetic: return "Electromagnetic"; 160 case fOptical: return "Optical"; 161 case fHadronic: return "Hadronic"; 162 case fPhotolepton_hadron: return "Photolepton_hadron"; 163 case fDecay: return "Decay"; 164 case fGeneral: return "General"; 165 case fParameterisation: return "Parameterisation"; 166 case fUserDefined: return "UserDefined"; 167 }; 168 return "NotDefined"; 169 } 170 ////////////////////////////////////////////////////////////////////////////// 171 void G4Lab::Trajectory::setSave( 172 bool aFlag 173 ) 174 ////////////////////////////////////////////////////////////////////////////// 175 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 176 { 177 fSave = aFlag; 178 } 179 ////////////////////////////////////////////////////////////////////////////// 180 bool G4Lab::Trajectory::save( 181 ) const 182 ////////////////////////////////////////////////////////////////////////////// 183 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 184 { 185 return fSave; 186 } 187 ////////////////////////////////////////////////////////////////////////////// 188 std::vector<double> G4Lab::Trajectory::stoppingPoint( 189 ) const 190 ////////////////////////////////////////////////////////////////////////////// 191 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 192 { 193 std::vector<double> v(3); 194 v[0] = fStoppingPoint.x(); 195 v[1] = fStoppingPoint.y(); 196 v[2] = fStoppingPoint.z(); 197 return v; 198 } 199 ////////////////////////////////////////////////////////////////////////////// 200 G4VPhysicalVolume* G4Lab::Trajectory::stoppingPhysicalVolume( 201 ) const 202 ////////////////////////////////////////////////////////////////////////////// 203 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 204 { 205 return fStoppingVolume; 206 } 207 ////////////////////////////////////////////////////////////////////////////// 208 ////////////////////////////////////////////////////////////////////////////// 209 ////////////////////////////////////////////////////////////////////////////// 210 void* G4Lab::Trajectory::operator new( 109 211 size_t 110 212 ) … … 115 217 } 116 218 ////////////////////////////////////////////////////////////////////////////// 117 /*inline*/void G4Lab::Trajectory::operator delete(219 void G4Lab::Trajectory::operator delete( 118 220 void* aTrajectory 119 221 ) … … 124 226 } 125 227 ////////////////////////////////////////////////////////////////////////////// 126 /*inline*/int G4Lab::Trajectory::operator == (228 int G4Lab::Trajectory::operator == ( 127 229 const G4Lab::Trajectory& aRight 128 230 ) const … … 177 279 { 178 280 return fPoints[aIndex]->point(); 179 }180 //////////////////////////////////////////////////////////////////////////////181 G4double G4Lab::Trajectory::GetPointGlobalTime(182 G4int aIndex183 ) const184 //////////////////////////////////////////////////////////////////////////////185 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//186 {187 return fPoints[aIndex]->globalTime();188 281 } 189 282 ////////////////////////////////////////////////////////////////////////////// … … 205 298 tj->fPoints.clear(); 206 299 } 300 ////////////////////////////////////////////////////////////////////////////// 301 const std::map<G4String,G4AttDef>* G4Lab::Trajectory::GetAttDefs() const 302 ////////////////////////////////////////////////////////////////////////////// 303 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 304 { 305 //return G4Trajectory::GetAttDefs(); 306 return 0; 307 } 308 ////////////////////////////////////////////////////////////////////////////// 309 std::vector<G4AttValue>* G4Lab::Trajectory::CreateAttValues() const 310 ////////////////////////////////////////////////////////////////////////////// 311 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 312 { 313 //return G4Trajectory::CreateAttValues(); 314 return 0; 315 } 316 -
snovis/trunk/source/G4Lab/cxx/TrajectoryAccessor.cxx
r233 r288 20 20 // Geant4 : 21 21 #include <G4RunManager.hh> 22 #include <G4VTrajectoryPoint.hh> 23 #include <G4AttValue.hh> 24 #include <G4UnitsTable.hh> 22 25 23 26 // Slash : … … 30 33 #include <Lib/Value.h> 31 34 #include <Lib/smanip.h> 35 #include <Lib/sout.h> 32 36 33 37 // G4Lab : 34 #include <G4Lab/ Trajectory.h>38 #include <G4Lab/Interfaces/IGeant4Trajectory.h> 35 39 #include <G4Lab/SoG4Trajectories.h> 40 #include <G4Lab/BestUnit.h> 36 41 37 42 ////////////////////////////////////////////////////////////////////////////// 38 43 G4Lab::TrajectoryAccessor::TrajectoryAccessor( 39 44 Slash::Core::ISession& aSession 45 ,G4RunManager* aRunManager 40 46 ) 41 47 :OnX::InventorAccessor(aSession) 42 48 ,fType("Trajectory") 49 ,fRunManager(aRunManager) 50 ,fAttDefs(0) 43 51 ,fModeling("immediate_all") 44 ,f G4Lab(false)52 ,fIGeant4Trajectory(false) 45 53 ,fSeparator(0) 46 54 ,fCoordinate(0) … … 93 101 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 94 102 { 95 // Set properties here since a user G4 Trajectory may103 // Set properties here since a user G4VTrajectory may 96 104 // had been declared very lately. 97 105 clearProperties(); 98 // G4 Trajectory properties :106 // G4VTrajectory properties : 99 107 addProperty("particle",Lib::Property::STRING); 100 108 addProperty("track",Lib::Property::INTEGER); 101 109 addProperty("parent",Lib::Property::INTEGER); 102 110 addProperty("charge",Lib::Property::DOUBLE); 103 if(isG4LabTrajectory()) { 111 addProperty("pdg",Lib::Property::INTEGER); 112 addProperty("px",Lib::Property::DOUBLE); 113 addProperty("py",Lib::Property::DOUBLE); 114 addProperty("pz",Lib::Property::DOUBLE); 115 116 fIGeant4Trajectory = isIGeant4Trajectory(); 117 if(fIGeant4Trajectory) { 104 118 // G4Lab::Trajectory properties : 105 119 addProperty("energy",Lib::Property::DOUBLE); 106 120 addProperty("totalEnergy",Lib::Property::DOUBLE); 107 121 addProperty("globalTime",Lib::Property::DOUBLE); 122 addProperty("process",Lib::Property::STRING); 123 addProperty("stopX",Lib::Property::DOUBLE); 124 addProperty("stopY",Lib::Property::DOUBLE); 125 addProperty("stopZ",Lib::Property::DOUBLE); 126 addProperty("stopPV",Lib::Property::STRING); 108 127 } 109 128 //addProperty("id",Lib::Property::POINTER); 110 111 G4RunManager* runManager = G4RunManager::GetRunManager(); 112 if(!runManager) return 0; 113 const G4Event* event = runManager->GetCurrentEvent(); 129 addAttDefsProperties(); 130 131 if(!fRunManager) { 132 Lib::Out out(fSession.printer()); 133 out << "No G4RunManager." << Lib::endl; 134 return 0; 135 } 136 const G4Event* event = fRunManager->GetCurrentEvent(); 114 137 if(!event) { 115 138 Lib::Out out(fSession.printer()); … … 125 148 } 126 149 127 fG4Lab = isG4LabTrajectory();128 129 150 return new TrajectoryIterator(*trajectoryContainer); 130 151 } … … 133 154 Slash::Data::IAccessor::Data aData 134 155 ,const std::string& aName 135 ,void* 136 ) 137 ////////////////////////////////////////////////////////////////////////////// 138 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 139 { 140 G4Trajectory* obj = (G4Trajectory*)aData; 156 ,void* aTag 157 ) 158 ////////////////////////////////////////////////////////////////////////////// 159 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 160 { 161 G4VTrajectory* obj = (G4VTrajectory*)aData; 162 IGeant4Trajectory* iobj = dynamic_cast<IGeant4Trajectory*>(obj); 163 141 164 //if(aName=="id") { 142 165 //return new Lib::Value((void*)obj); 143 166 //} else 167 // G4VTrajectory data : 144 168 if(aName=="particle") { 145 169 return new Lib::Value(obj->GetParticleName()); … … 150 174 } else if(aName=="charge") { 151 175 return new Lib::Value(obj->GetCharge()); 152 } else if(!fG4Lab) { 153 return new Lib::Value(); 154 } else { // We have G4Lab::Trajectory objects : 155 G4Lab::Trajectory* obj = (G4Lab::Trajectory*)aData; 176 } else if(aName=="pdg") { 177 return new Lib::Value(obj->GetPDGEncoding()); 178 } else if(aName=="px") { 179 return new Lib::Value(obj->GetInitialMomentum().x()); 180 } else if(aName=="py") { 181 return new Lib::Value(obj->GetInitialMomentum().y()); 182 } else if(aName=="pz") { 183 return new Lib::Value(obj->GetInitialMomentum().z()); 184 } else if(iobj) { 156 185 if(aName=="energy") { 157 return new Lib::Value( obj->GetKineticEnergy());186 return new Lib::Value(iobj->kineticEnergy()); 158 187 } else if(aName=="totalEnergy") { 159 return new Lib::Value( obj->GetTotalEnergy());188 return new Lib::Value(iobj->totalEnergy()); 160 189 } else if(aName=="globalTime") { 161 return new Lib::Value(obj->GetGlobalTime()); 162 } else { 163 return new Lib::Value(); 164 } 165 } 190 return new Lib::Value(iobj->globalTime()); 191 } else if(aName=="process") { 192 return new Lib::Value(iobj->creatorProcessName()); 193 } else if(aName=="stopX") { 194 return new Lib::Value(iobj->stoppingPoint()[0]); 195 } else if(aName=="stopY") { 196 return new Lib::Value(iobj->stoppingPoint()[1]); 197 } else if(aName=="stopZ") { 198 return new Lib::Value(iobj->stoppingPoint()[2]); 199 } else if(aName=="stopPV") { 200 G4VPhysicalVolume* pv = iobj->stoppingPhysicalVolume(); 201 if(!pv) return new Lib::Value(); 202 return new Lib::Value(pv->GetName()); 203 } 204 } 205 return findAttDefsValue(aData,aName,aTag); 166 206 } 167 207 ////////////////////////////////////////////////////////////////////////////// … … 197 237 separator->addChild(fSoGC.getLightModel()); 198 238 199 SoG4Trajectories* soG4Trajectories = new SoG4Trajectories ;239 SoG4Trajectories* soG4Trajectories = new SoG4Trajectories(fRunManager); 200 240 separator->addChild(soG4Trajectories); 201 241 … … 233 273 if(!fSeparator) return; // not in "pickable" mode. 234 274 235 G4 Trajectory* obj = (G4Trajectory*)aData;275 G4VTrajectory* obj = (G4VTrajectory*)aData; 236 276 if(!obj) return; 237 277 … … 242 282 int32_t* coordIndex = new int32_t[pointn+1]; 243 283 244 G4TrajectoryPoint* tp;245 G4ThreeVector pos;246 284 for (int i = 0; i < pointn ; i++) { 247 tp = (G4TrajectoryPoint*)(obj->GetPoint(i)); //?248 pos = tp->GetPosition();285 G4VTrajectoryPoint* tp = obj->GetPoint(i); //? 286 G4ThreeVector pos = tp->GetPosition(); 249 287 points[i].setValue((float)pos.x(),(float)pos.y(),(float)pos.z()); 250 288 coordIndex[i] = fIndex+i; … … 307 345 } 308 346 ////////////////////////////////////////////////////////////////////////////// 309 bool G4Lab::TrajectoryAccessor::is G4LabTrajectory(347 bool G4Lab::TrajectoryAccessor::isIGeant4Trajectory( 310 348 ) 311 349 ////////////////////////////////////////////////////////////////////////////// 312 350 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 313 351 { 314 G4RunManager* runManager = G4RunManager::GetRunManager(); 315 if(!runManager) return false; 316 const G4Event* event = runManager->GetCurrentEvent(); 352 if(!fRunManager) return false; 353 const G4Event* event = fRunManager->GetCurrentEvent(); 317 354 if(!event) return false; 318 355 G4TrajectoryContainer* trajectoryContainer = … … 321 358 int number = trajectoryContainer->entries(); 322 359 if(number<=0) return false; 323 G4 Lab::Trajectory* trajectory =324 dynamic_cast<G4Lab::Trajectory*>((G4Trajectory*)(*trajectoryContainer)[(size_t)0]);360 G4VTrajectory* vt = (*trajectoryContainer)[(size_t)0]; 361 IGeant4Trajectory* trajectory = dynamic_cast<IGeant4Trajectory*>(vt); 325 362 return (trajectory?true:false); 326 363 } 364 ////////////////////////////////////////////////////////////////////////////// 365 void G4Lab::TrajectoryAccessor::addAttDefsProperties( 366 ) 367 ////////////////////////////////////////////////////////////////////////////// 368 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 369 { 370 fAttDefs = 0; 371 if(!fRunManager) return; 372 const G4Event* event = fRunManager->GetCurrentEvent(); 373 if(!event) return; 374 G4TrajectoryContainer* trajectoryContainer = 375 event->GetTrajectoryContainer(); 376 if(!trajectoryContainer) return; 377 int number = trajectoryContainer->entries(); 378 if(number<=0) return; 379 G4VTrajectory* vt = (*trajectoryContainer)[(size_t)0]; 380 381 // AttDefs properties : 382 fAttDefs = (std::map<G4String,G4AttDef>*)vt->GetAttDefs(); 383 if(!fAttDefs) return; 384 385 std::map<G4String,G4AttDef>::const_iterator it; 386 for(it=fAttDefs->begin();it!=fAttDefs->end();++it) { 387 const std::string& sname = (*it).second.GetName(); 388 const std::string& stype = (*it).second.GetValueType(); 389 390 if(sname=="Color") continue; //Do not put some AttDef as property. 391 392 //printf("debug : add %s %s\n",sname.c_str(),stype.c_str()); 393 394 if( (stype=="int") || 395 (stype=="G4int") ) { 396 addProperty((*it).first,Lib::Property::INTEGER); 397 } else if( (stype=="double") || 398 (stype=="float") || 399 (stype=="G4double") || 400 (stype=="G4float") ) { 401 addProperty((*it).first,Lib::Property::DOUBLE); 402 } else if( (stype=="std::string") || 403 (stype=="G4String") ) { 404 addProperty((*it).first,Lib::Property::STRING); 405 } else if( (stype=="std::vector<double>") || 406 (stype=="std::vector<float>") || 407 (stype=="G4ThreeVector") || 408 (stype=="std::vector<G4double>") || 409 (stype=="std::vector<G4float>") ) { 410 addProperty((*it).first,Lib::Property::VECTOR_DOUBLE); 411 } else { 412 addProperty((*it).first,Lib::Property::STRING); 413 } 414 } 415 } 416 ////////////////////////////////////////////////////////////////////////////// 417 Slash::Core::IValue* G4Lab::TrajectoryAccessor::findAttDefsValue( 418 Slash::Data::IAccessor::Data aData 419 ,const std::string& aName 420 ,void* 421 ) 422 ////////////////////////////////////////////////////////////////////////////// 423 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 424 { 425 //printf("debug : find %s (%ld)...\n",aName.c_str(),fAttDefs); 426 427 if(!fAttDefs) return new Lib::Value(); 428 429 G4VTrajectory* obj = (G4VTrajectory*)aData; 430 std::vector<G4AttValue>* vec = obj->CreateAttValues(); 431 if(!vec) { 432 Lib::Out out(printer()); 433 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 434 << " problem to get AttValues fot trajectory." 435 << Lib::endl; 436 return new Lib::Value(); 437 } 438 439 unsigned int number = vec->size(); 440 for(unsigned int index=0;index<number;index++) { 441 const G4AttValue& val = (*vec)[index]; 442 if(aName==val.GetName()) { 443 const std::string& stype = (*fAttDefs)[val.GetName()].GetValueType(); 444 if( (stype=="int") || 445 (stype=="G4int") ) { 446 int v; 447 if(!Lib::smanip::toint(val.GetValue(),v)) { 448 Lib::Out out(printer()); 449 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 450 << " " << Lib::sout(val.GetValue()) << " not a G4int." 451 << Lib::endl; 452 delete vec; 453 return new Lib::Value(); 454 } 455 delete vec; 456 return new Lib::Value(v); 457 } else if( (stype=="double") || 458 (stype=="float") || 459 (stype=="G4double") || 460 (stype=="G4float") ) { 461 double v = 0; 462 if(!Lib::smanip::todouble(val.GetValue(),v)) { 463 std::vector<double> vs; 464 if(!BestUnit::toDoubles(printer(),val.GetValue(),vs)) { 465 delete vec; 466 return new Lib::Value(); 467 } 468 if(vs.size()!=1) { 469 Lib::Out out(printer()); 470 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 471 << " " << Lib::sout(val.GetValue()) << " not a double." 472 << Lib::endl; 473 delete vec; 474 return new Lib::Value(); 475 } 476 v = vs[0]; 477 } 478 delete vec; 479 return new Lib::Value(v); 480 } else if( (stype=="std::string") || 481 (stype=="G4String") ) { 482 delete vec; 483 return new Lib::Value(val.GetValue()); 484 } else if(stype=="G4ThreeVector") { 485 std::vector<double> vs; 486 if(!BestUnit::toDoubles(printer(),val.GetValue(),vs)) { 487 delete vec; 488 return new Lib::Value(); 489 } 490 if(vs.size()!=3) { 491 Lib::Out out(printer()); 492 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 493 << " " << Lib::sout(val.GetValue()) << " not a vector." 494 << Lib::endl; 495 delete vec; 496 return new Lib::Value(); 497 } 498 delete vec; 499 return new Lib::Value(vs); 500 } else if( (stype=="std::vector<float>") || 501 (stype=="std::vector<G4float>") ) { 502 void* p; 503 if(!Lib::smanip::topointer(val.GetValue(),p)) { 504 Lib::Out out(printer()); 505 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 506 << " " << Lib::sout(val.GetValue()) << " not a pointer." 507 << Lib::endl; 508 delete vec; 509 return new Lib::Value(); 510 } 511 std::vector<float>* vvec = (std::vector<float>*)p; 512 unsigned int vn = vvec->size(); 513 std::vector<double> array(vn); 514 for(unsigned int vi=0;vi<vn;vi++) array[vi] = double((*vvec)[vi]); 515 delete vec; 516 return new Lib::Value(array); 517 } else if( (stype=="std::vector<double>") || 518 (stype=="std::vector<G4double>") ){ 519 void* p; 520 if(!Lib::smanip::topointer(val.GetValue(),p)) { 521 Lib::Out out(printer()); 522 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 523 << " " << Lib::sout(val.GetValue()) << " not a pointer." 524 << Lib::endl; 525 delete vec; 526 return new Lib::Value(); 527 } 528 std::vector<double>* vvec = (std::vector<double>*)p; 529 delete vec; 530 return new Lib::Value(*vvec); 531 } else { 532 delete vec; 533 return new Lib::Value(val.GetValue()); 534 } 535 } 536 } 537 Lib::Out out(printer()); 538 out << "G4Lab::TrajectoryAccessor::findAttDefsValue :" 539 << " AttValue not found for property " << Lib::sout(aName) << "." 540 << Lib::endl; 541 delete vec; 542 return new Lib::Value(); 543 } -
snovis/trunk/source/G4Lab/cxx/TrajectoryContainerAccessor.cxx
r233 r288 27 27 G4Lab::TrajectoryContainerAccessor::TrajectoryContainerAccessor( 28 28 Slash::Core::ISession& aSession 29 ,G4RunManager* aRunManager 29 30 ) 30 31 :OnX::InventorAccessor(aSession) 31 32 ,fType("TrajectoryContainer") 33 ,fRunManager(aRunManager) 32 34 ////////////////////////////////////////////////////////////////////////////// 33 35 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// … … 71 73 } 72 74 ////////////////////////////////////////////////////////////////////////////// 75 Slash::Core::IValue* G4Lab::TrajectoryContainerAccessor::findValue( 76 Slash::Data::IAccessor::Data aData 77 ,const std::string& aName 78 ,void* aTag 79 ) 80 ////////////////////////////////////////////////////////////////////////////// 81 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 82 { 83 return 0; 84 } 85 ////////////////////////////////////////////////////////////////////////////// 73 86 void G4Lab::TrajectoryContainerAccessor::beginVisualize( 74 87 ) … … 102 115 separator->addChild(fSoGC.getLightModel()); 103 116 104 SoG4RunManager* soG4RunManager = new SoG4RunManager( );117 SoG4RunManager* soG4RunManager = new SoG4RunManager(fRunManager); 105 118 soG4RunManager->numberOfEvents.setValue(number); 106 119 separator->addChild(soG4RunManager);
Note: See TracChangeset
for help on using the changeset viewer.