Message: Problem with XML file and long time for running? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problem with XML file and long time for running? 

Keywords: xml AIDA run-time
Forum: Analysis
Date: 15 Mar, 2006
From: Shahrokh <Shahrokh>

It turns out to take a long time for running of my program. 
In other words; during run-time, the physical memory of computer occupies gradually and 
the speed of run is much slowly. 
The glance of my program:
I want to generate primary particles that their positions, momentum directions 
and energies are read from a file. The file format is N-Tuple (XML file).
The characteristics include: particle position ( xOfPosition, yOfPosition,zOfPosition ),
momentum direction ( xOfDirection, yOfDirection, zOfDirection )and particle energy ( energy ). 
Each row of N-Tuple is related to one event or one particle. 
For each event generated (for example, each event of /run/beamOn 100000), 
one particle is produced with the characteristics reading from row of N-Tuple and next event from next row….
For this purpose, I think that this is necessary to position the read cursor immediately 
before the first row (with starting each event) with ITuple::start()function
and then position the cursor at a given row with ITuple::setRow(anEvent->get_eventID()) function for next event. 
But this way is very slowly and time-consuming, since for each event 
and setting that event(SetParticlePostion(), SetParticleMomentumDirection(), SetParticleEnergy()), 
this is necessary to position cursor at first row of N-tuple and scan across the file. 
The size of file is 3.3 MB. The run-time of 20 events is almost 20 minutes. 
I think that this problem is arose from structure of XML files, that is complex structure (perhaps, parse tree)
and the task of data analysis at XML file is time-consuming. 
I don’t know what my problem is. If N-Tuple file is re-formatted to .root or .hbook formt,
is the run-time agreeable or time-saving? 
In other words, do I have to change file format (xml) to other format for reducing of run-time?
The file, that I compile, follow:
#include "AIDA/AIDA.h"
#include "AIDA/IManagedObject.h"

using namespace AIDA;

#include "PrimaryGeneratorAction.hh"

#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "globals.hh"

#include "G4UnitsTable.hh"

  xOfPostion = 0.0;
  yOfPostion = 0.0;
  zOfPostion = 0.0;
  xOfdirection = 0.0;
  yOfdirection = 0.0;
  zOfdirection = 0.0;
  energy = 0.0;

   delete particleGun;
   delete analysisFactory;
   delete tree;
   delete managedObject;

void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
   //initialize reading from .aida file that is one database of photon specifications.
   analysisFactory = AIDA_createAnalysisFactory();

   ITreeFactory *treeFactory = analysisFactory->createTreeFactory();

   tree = treeFactory->create("DataBaseOfPhoton.aida","xml",true, false);
   delete treeFactory;

   managedObject = tree->find("/tuples/tuplePhoton");
   AIDA::ITuple* tuple = dynamic_cast<AIDA::ITuple*> (managedObject);
   //int numberOfrows = tuple->rows();
   //get position of photon from DataBaseOfPhoton.aida file
   //get  movement direction of photon from DataBaseOfPhoton.aida file
   //get energy of photon from DataBaseOfPhoton.aida file
  //primary generator
  G4int n_particle = 1;
  particleGun = new G4ParticleGun(n_particle);

  //setting type of particle
  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  G4String particleName;
  //setting energy of photon
  G4cout << "energy of primary photon: " <<G4BestUnit( energy , "Energy" )<< G4endl;
  //setting postion of photon
  particleGun->SetParticlePosition(G4ThreeVector(xOfPostion*mm, yOfPostion*mm, zOfPostion*mm));
  G4cout<<"the position characteristics of primary photon: ("<<G4BestUnit( xOfPostion,"Length")<<", "<<G4BestUnit( yOfPostion,"Length")<<", "<<G4BestUnit( zOfPostion,"Length")<<" )"<<G4endl;
  //setting movement direction of photon
  G4ThreeVector v(xOfdirection, yOfdirection, zOfdirection);

  //delete analysisFactory;   <------------this line must to be block.
Please help me.
thanks a lot.

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

1 None: Re: Problem with XML file and long time for running?   (Guy Barrand - 16 Mar, 2006)
 Add Message Add Message
to: "Problem with XML file and long time for running?"

 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 ]