Message: How to access to G4VSolid* in StackingAction()? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None How to access to G4VSolid* in StackingAction()? 

Forum: Event and Track Management
Date: 21 Oct, 2007
From: <hyao@jlab.org>

I am trying to figure out if the primary vertex will hit the mirror. If
not, I will kill this event in StackingAction(), and I'm going to use
G4VSolid->DistantToIn(p,v). But the problem is that I can't get the solid information. 

This is the way I am doing ( I just type all the main part )
-----------------------------------------------------------------------
First, Create a UserDefined Class corresponding geo info.

class Geo()
{
   public:
         Geo();
         ~Geo();
   public:
         G4VSolid* GetGeoSolid() {return fSolid;}
         void SetGeoSolid(G4VSolid* aSolid){ fSolid=aSolid; }
         G4String GetGeoName() { return fName; }
       

   private:
         G4VSolid* fSolid;
         G4String fName;
}
----------------------------------------------------------------------
Second, I create a UserDefined Manager corresponding to detector part

Class UserManager()
{
   public:
        UserManager();
        ~UserManager();

   public:
        vector<Geo> GetMirror() { return mirror; }
        
        static UserManager* GetUserManager();
   private:
        static UserManager* fUserManager();

   private:
        vector<Geo> mirror;
}

---------------------------------------------------------------------
Third, I set mirror solid in DetectorConstruction.cc

UserManager* Userman=UserManager::GetUserManager();
vector<Geo> MirrorObj=Userman->GetMirror();
G4VSolid* mir_solid=(blablabla)
MirrorObj.SetGeoSolid(mir_solid);
G4cout<<"solid_name="<<MirrorObj.GetGeoSolid()->GetName()<<G4endl;

--------------------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Last, I try to read this mirror in StackingAction()

UserManager* Userman=UserManager::GetUserManager();
vector<Geo> MirrorObj=Userman->GetMirror();
G4cout<<"solid_name="<<MirrorObj.GetGeoName()<<G4endl;

//So far, everything is fine. I see the output. 
//Problem happens next line. It's exactly same with the code I written
//in DetectorConstruction.cc
G4cout<<"solid_name="<<MirrorObj.GetGeoSolid()->GetName()<<G4endl;

//Here the program gives me Segmentation fault error.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I guess MirrorObj lost the G4VSolid* var outside the DetectorConstruction

But I have no idea how to read it and let it in the memory. Or I have
to create UserDefined G4SolidStore() since I found the source code of
this class in our database has no GetSolid() method which really 
annoied me.

I use Geant4.8.0 and don't have the root privilage to install 4.9.0.

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

1 None: Re: How to access to G4VSolid* in StackingAction()?   (hyao@jlab.org - 21 Oct, 2007)
(_ More: Re: How to access to G4VSolid* in StackingAction()?   (Peter Gumplinger - 22 Oct, 2007)
1 None: Re: How to access to G4VSolid* in StackingAction()?   (hyao@jlab.org - 23 Oct, 2007)
3 None: Re: How to access to G4VSolid* in StackingAction()?   (hyao@jlab.org - 23 Oct, 2007)
 Add Message Add Message
to: "How to access to G4VSolid* in StackingAction()?"

 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 ]