Message: Re: ITupleFactory cant store G4ThreeVector objects?! Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: ITupleFactory cant store G4ThreeVector objects?! 

Forum: Analysis
Re: Question ITupleFactory canít store G4ThreeVector objects?! (Shahrokh)
Re: None Re: ITupleFactory cant store G4ThreeVector objects?! (Vladimir IVANTCHENKO )
Re: Question Re: ITupleFactory cant store G4ThreeVector objects?! (Shahrokh)
Date: 01 Feb, 2006
From: Vladimir IVANTCHENKO <vnivanch@mail.cern.ch>

On Wed, 1 Feb 2006, Shahrokh wrote:

> *** Discussion title: Analysis
> Email replies to PublicHyperNews@slac.stanford.edu must include:
>   In-Reply-To: <"/analysis/155/1/1"@geant4-hn.slac.stanford.edu>
>   Subject: ...change this to be about your reply.
> 
> Thanks for you suugestion. I can successfully compile the program and it executes as expected,
> and writes an Ntuple file in xml format. But when I analysis this file, using jas3, I can get nothing.
> I dont know what is the wrong. The source files include( in src folder):
> [root@localhost src]# ls
> DetectorConstruction.cc
> FluenceMeterParameterisation.cc    
> fFluenceMeterSD.cc                
> PhysicsList.cc                         
> PrimaryGeneratorAction.cc
> Histo.cc                                  
> RunAction.cc
> 
> Meanwhile, I enter these commands:
> [root@localhost root]# JDK_HOME=/root/geant4/java/jdk1.5.0
> [root@localhost root]# export JDK_HOME
> [root@localhost root]# JAIDA_HOME=/root/geant4/JAIDA-3.2.4
> [root@localhost root]# export JAIDA_HOME
> [root@localhost root]# source /root/geant4/JAIDA-3.2.4/bin/aida-setup.sh
> [root@localhost root]# AIDAJNI_HOME=/root/geant4/AIDAJNI-3.2.3
> [root@localhost root]# export AIDAJNI_HOME
> [root@localhost root]# source /root/geant4/AIDAJNI-3.2.3/bin/Linux-g++/aidajni-setup.sh
> 
> the folling lines are parts of above source files.
> 
> *******DetectorConstruction.cc*****
> ...
> //All managed (deleted) by SDManager
>  G4VSensitiveDetector* fluenceMeterSD;
> ...
> //Fluence Meter
> G4double innerRadiusOfFluenceMeter=0.*cm;
> G4double outerRadiusOfFluenceMeter=5.*cm;
> G4double hightOfFluenceMeter=0.05*cm;    //note: the hight of Fluence meter is equal to defaultCutValue ( = 1.*mm ) 
> G4double startAngleOfFluenceMeter=0.*deg;
> G4double spanningAngleOfFluenceMeter=360.*deg;
> 
> G4Tubs* fluenceMeter_Tub=new G4Tubs("fluenceMeter_Tub", innerRadiusOfFluenceMeter, outerRadiusOfFluenceMeter, hightOfFluenceMeter, startAngleOfFluenceMeter, spanningAngleOfFluenceMeter);
> 
> fluenceMeter_Log=new G4LogicalVolume (fluenceMeter_Tub, Air, "fluenceMeter_Log",0, 0,0);
> 
> fluenceMeter_Phys= new G4PVPlacement (0, G4ThreeVector(0., 0., -66.7*mm), fluenceMeter_Log,"FluenceMeter", worldVolume_Log,0,0);
> 
> //Shells of Fluence Meter
> G4Tubs* dummyShellOfFluenceMeter_Tubs= new G4Tubs("dummyShellOfFluenceMeter_Tubs", 10.*cm, 20.*cm, 10.*mm, 0.*deg, 360.*deg);
> 
> dummyShellOfFluenceMeter_Log= new G4LogicalVolume( dummyShellOfFluenceMeter_Tubs, Air, "dummyShellOfFluenceMeter_Log",0,0,0);
> 
> //shells sizes of fluence meter
> NbOfShells=100;
> widthOfShells=0.1*cm;
> firstRMax=0.5*cm;
> startAngle=0.*deg;
> spanAngle=360.*deg;
> 
> G4VPVParameterisation* shellParam= new FluenceMeterParameterisation(NbOfShells,widthOfShells, firstRMax, startAngle,spanAngle);
> 
> new G4PVParameterised( "dummyShellOfFluenceMeter_Phys", dummyShellOfFluenceMeter_Log, fluenceMeter_Log, kZAxis, 100, shellParam);
> ...
> //Sensitive volume
> G4SDManager* SDman = G4SDManager::GetSDMpointer();
> G4String SDname;
>   
> fluenceMeterSD= new fFluenceMeterSD(SDname="/fluenceMeter");
> SDman->AddNewDetector(fluenceMeterSD);
> dummyShellOfFluenceMeter_Log->SetSensitiveDetector(fluenceMeterSD);
> 
> *****FluenceMeterParameterisation.cc*****
> ...
> FluenceMeterParameterisation::FluenceMeterParameterisation(G4int noShells, G4double widthShell, G4double firstMaxRadius, G4double startAngle, G4double spanningAngle)
> {
>    NoOfShells=noShells;
>    halfWidth=0.5*widthShell;
>    fMaxRadius=firstMaxRadius;
>    startAngleOfShells=startAngle;
>    spanAngleOfShells=spanningAngle;
>    for(G4int i=0; i<100; i++)
>        zPosition[i]=0.0*cm;
> }    
>   
> FluenceMeterParameterisation::~FluenceMeterParameterisation() 
>  {;}
>  
> void FluenceMeterParameterisation::ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol)const
> {
>     physVol->SetTranslation(G4ThreeVector (0.*cm,0.*cm, zPosition[copyNo]));
> }
>    
> void FluenceMeterParameterisation::ComputeDimensions( G4Tubs& shellOfFluenceMeter, const G4int copyNo,const  G4VPhysicalVolume *)const
> {
>   G4double  MinRadius= (std::sqrt(static_cast<G4double>(copyNo)))*fMaxRadius;
>   G4double  MaxRadius= (std::sqrt(static_cast<G4double>(copyNo+1)))*fMaxRadius;
>   shellOfFluenceMeter.SetInnerRadius(MinRadius);
>   shellOfFluenceMeter.SetOuterRadius(MaxRadius);
>   shellOfFluenceMeter.SetZHalfLength(halfWidth);
>   shellOfFluenceMeter.SetStartPhiAngle(startAngleOfShells);
>   shellOfFluenceMeter.SetDeltaPhiAngle(spanAngleOfShells);
> }
> 
> *****Histo.cc*****
> ...
> Histo* Histo::fManager = 0;  //Initialize the static data member, refer to page:518 from Deitel book
> 
> //
> Histo* Histo::GetPointer()
> {
>   if(!fManager) {
>     fManager = new Histo();
>   }
>   return fManager;
> }
> 
> //
> Histo::Histo()
> :factory(0), tree(0)
> {
> }
> 
> //
> Histo::~Histo()
> {
> }
> 
> //
> void Histo::BeginOfHisto()
> {
>   factory= AIDA_createAnalysisFactory();
>   if(!factory) G4cout<<"factory failed"<<G4endl;
>    
>   ITreeFactory* treeFactory= factory->createTreeFactory();
>   if( !treeFactory) G4cout<<" treeFactory failed "<<G4endl;
>    
>   tree= treeFactory-> create();
>   if(!tree) G4cout<<"tree failed"<<G4endl;
>    
>   tree= treeFactory->create("LinacWithFluenceSD.aida", "xml", false, true);
>    
>   ITupleFactory* tupleFactory = factory->createTupleFactory(*tree);
>   tree->mkdir("/tuples");
>   tree->cd("/tuples");
>    
>   tuplePhoton = tupleFactory->create("tuplePhoton", "the characteristics of photons ", "double xOfPostion,  yOfPostion,  zOfPostion,  xOfdirection,  yOfdirection,  zOfdirection,  energy");
>    
>   tupleElectron = tupleFactory->create("tupleElectron", "the characteristics of electrons ", "double xOfPostion,  yOfPostion,  zOfPostion,  xOfdirection,  yOfdirection,  zOfdirection,  energy");
> }
> 
> //
> void Histo::EndOfHisto()
> {
>   tree->commit();
>   G4cout << "Ntuples are saved" << G4endl;
>   
>   tree->close();
>   G4cout << "Tree is closed" << G4endl;
> }
> 
> //filling tuples
> void Histo::SaveToTuples()
> {
>   //Photon  
>   tuplePhoton->fill(0,(double)xPositionOfPhoton);
>   tuplePhoton->fill(1,(double)yPositionOfPhoton);
>   tuplePhoton->fill(2,(double)zPositionOfPhoton);
> 
>   tuplePhoton->fill(3,(double)xDirectionOfPhoton);
>   tuplePhoton->fill(4,(double)yDirectionOfPhoton);
>   tuplePhoton->fill(5,(double)zDirectionOfPhoton);
> 
>   tuplePhoton->fill(6,(double)energyOfPhoton);
>   
>   tuplePhoton->addRow();
>   
>   //Electron
>   tupleElectron->fill(0,(double)xPositionOfElectron);
>   tupleElectron->fill(1,(double)yPositionOfElectron);
>   tupleElectron->fill(2,(double)zPositionOfElectron);
> 
>   tupleElectron->fill(3,(double)xDirectionOfElectron);
>   tupleElectron->fill(4,(double)yDirectionOfElectron);
>   tupleElectron->fill(5,(double)zDirectionOfElectron);
> 
>   tupleElectron->fill(6,(double)energyOfElectron);
>   
>   tupleElectron->addRow();
>   }
> 
> //
> void Histo::AddGamma(  G4double  xPos, G4double yPos, G4double zPos, G4double xDir, G4double yDir, G4double zDir, G4double en )  
> {
>   xPositionOfPhoton=xPos;
>   yPositionOfPhoton=yPos;
>   zPositionOfPhoton=zPos;
> 
>   xDirectionOfPhoton=xDir;
>   yDirectionOfPhoton=yDir;
>   zDirectionOfPhoton=zDir;
> 
>   energyOfPhoton=en;
> }
> 
> //Electron
> void Histo::AddElectron(  G4double xPos, G4double yPos, G4double zPos, G4double xDir, G4double yDir, G4double zDir, G4double en )  //E is abbreviation of electron
> {
>   xPositionOfElectron=xPos;
>   yPositionOfElectron=yPos;
>   zPositionOfElectron=zPos;
> 
>   xDirectionOfElectron=xDir;
>   yDirectionOfElectron=yDir;
>   zDirectionOfElectron=zDir;
> 
>   energyOfElectron=en;
> }
> 
> *****fFluenceMeterSD.cc******
> fFluenceMeterSD::fFluenceMeterSD(const G4String& name)
>  :G4VSensitiveDetector(name),
>   theHisto(Histo::GetPointer())
> {}
> 
> fFluenceMeterSD::~fFluenceMeterSD()
> {}
> 
> void fFluenceMeterSD::Initialize(G4HCofThisEvent*)
> {}
> 
> G4bool fFluenceMeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
> {
>   const G4Track* track = aStep->GetTrack();
>   
>   //photon
>   if (track->GetDefinition() == G4Gamma::Gamma()) 
>   {
>      //the position of photon
>      G4ThreeVector position = track->GetPosition();     
>      G4double x = position.x();
>      G4double y = position.y();
>      G4double z = position.z();
>         
>      //the direction of momentum
>      G4ThreeVector directionOfMomentum = track->GetMomentumDirection();
>      G4double dx=directionOfMomentum.x();
>      G4double dy=directionOfMomentum.y();
>      G4double dz=directionOfMomentum.z();
>      
>      //the energy of photon
>      G4double energy = track->GetKineticEnergy();  
>      
>      theHisto->AddGamma(x, y, z, dx, dy, dz, energy);
>   }
>   
>   //electron
>   else if (track->GetDefinition() == G4Electron::Electron()) 
>   {
>      //the position of electron
>      G4ThreeVector position = track->GetPosition();
>      G4double x = position.x();
>      G4double y = position.y();
>      G4double z = position.z();
>          
>      //the direction of momentum
>      G4ThreeVector directionOfMomentum = track->GetMomentumDirection();
>      G4double dx=directionOfMomentum.x();
>      G4double dy=directionOfMomentum.y();
>      G4double dz=directionOfMomentum.z();
>      
>      //the energy of electron
>      G4double energy = track->GetKineticEnergy();  
>      
>      theHisto->AddElectron(x, y, z, dx, dy, dz, energy);
>   }
>   return true;
> }
> 
> void fFluenceMeterSD::EndOfEvent(G4HCofThisEvent*)
> {}
> 
> void fFluenceMeterSD::clear()
> {}
> 
> void fFluenceMeterSD::PrintAll()
> {}
> 
> *****RunAction.cc*****
> RunAction::RunAction()
> {}
> 
> RunAction::~RunAction()
> {}
> 
> void RunAction::BeginOfRunAction(const G4Run* aRun)
> {
>   G4int id = aRun->GetRunID();
>   G4cout << "### Run " << id << " start" << G4endl;
>   (Histo::GetPointer())->BeginOfHisto();
> }
> 
> void RunAction::EndOfRunAction(const G4Run*)
> {
>   G4cout << "RunAction: End of run actions are started" << G4endl;
>   (Histo::GetPointer())->EndOfHisto();
> }
> 
> I run the executable code, interactively.
> ...
> Idle> /control/execute LinacWithgps.mac
> ...
> LinacWithgps.mac include the following lines:
> /gps/particle e-
> /gps/pos/type Point
> /gps/pos/centre 0. 0. 3.36 cm
> /gps/ang/rot1 -1  0  0 
> /gps/ang/rot2 0  -1  0 
> /gps/ang/type beam1d
> /gps/ang/sigma_r 0.63023 deg
> /gps/ang/mintheta 1.909152 deg
> /gps/ene/type Gauss
> /gps/ene/mono 10.4 MeV
> /gps/ene/sigma 1.284 MeV
> 
> /tracking/verbose 0
> /run/beamOn 10000
> 
> Please help me.
> Cheers.
> 

Because AIDA output file is gzipped ASCII format, one can read what is 
inside without JAS or any other tools. So, you have everything in your 
hand to understand your application.

VI

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

1 Question: Re: ITupleFactory cant store G4ThreeVector objects?!   (Shahrokh - 01 Feb, 2006)
(_ More: Re: ITupleFactory cant store G4ThreeVector objects?!   (Shahrokh - 01 Feb, 2006)
(_ Ok: Re: ITupleFactory cant store G4ThreeVector objects?!   (Shahrokh - 05 Feb, 2006)
 Add Message Add Message
to: "Re: ITupleFactory cant store G4ThreeVector objects?!"

 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 ]