Message: Re: Getting UserDetectorConstruction Instance Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: Getting UserDetectorConstruction Instance 

Forum: Run Management
Re: Question Getting UserDetectorConstruction Instance (Michael Rinaldi)
Date: 02 Dec, 2010
From: Gumplinger Peter <Gumplinger Peter>

Hi Mike

> G4RunManager *runManager = G4RunManager::GetRunManager(); const
> G4VUserDetectorConstruction* myDet =
> runManager->GetUserDetectorConstruction();
> But this does not return my object since some of the methods in my
> Detectorconstruction object were not defined.

try this:

const MyDetectorConstruction* myDet =

(const MyDetectorConstruction*) (G4RunManager::GetRunManager()->GetUserDetectorConstruction());

or put after your code:

const MyDetectorConstruction* myDetector = dynamic_cast<const MyDetectorConstruction *>(myDet);

and now use the pointer to your derived class - myDetector; e.g. your myDet is a pointer to the base class and hence can only invoke base class methods. Indeed, a C++ question.


Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Getting UserDetectorConstruction Instance   (Michael H. Kelsey - 02 Dec, 2010)
2 None: Re: Getting UserDetectorConstruction Instance   (michel maire - 03 Dec, 2010)
1 Feedback: Re: Getting UserDetectorConstruction Instance   (Michael Rinaldi - 03 Dec, 2010)
 Add Message Add Message
to: "Re: Getting UserDetectorConstruction Instance"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]