Message: Problem with AIDA and read or restore data from file (xml format)? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problem with AIDA and read or restore data from file (xml format)? 

Keywords: AIDA read restore file
Forum: Analysis
Date: 04 Mar, 2006
From: Shahrokh <Shahrokh>

Hi,
I have a running code that write out an N-tuple file with xml format. 
N-tuple is  filled with random numbers. It is compiled and runned finely and creates an N-tuple file with the name of gaussian.aida. 
I open this file with jas3 and see N-tuple with 3 columns. 
The file, that I compile and run, follow:


#include "AIDA/AIDA.h"
using namespace AIDA;

//prototype randgauss()
double randgauss(double, double, double, double);

//define randgauss()
double randgauss( double min, double max, double sigma, double center)
{
  double random= (min+ (max-min)*(double)rand()/RAND_MAX);
  
  double tmp=(random-center)/sigma;
  double gauss=std::exp(-tmp*tmp/2);
  return gauss;
}


int main()
{
  IAnalysisFactory *analysisFactory = AIDA_createAnalysisFactory();
		
  ITreeFactory *treeFactory = analysisFactory->createTreeFactory();
		
  ITree *tree = treeFactory->create();
		
  tree = treeFactory->create("gaussian.aida", "xml", false, true);
	
  ITupleFactory* tupleFactory = analysisFactory->createTupleFactory (*tree);
	
  ITuple* tuple = tupleFactory->create("tuplePhoton", "the   characteristics of photons ", "double r1,  r2,  r3");
	
  for(int i=0; i<24; i++)
    {
	float r1=0.;
	float r2=0.;
	float r3=0.;
	double min=0., max=1.0, sigma=1.0, center=0.;
	r1=randgauss(min, max, sigma, center);
	r2=randgauss(min, max, sigma, center)+10;
	r3=randgauss(min, max, sigma, center)+100;
	tuple->fill(0,r1);
	tuple->fill(1,r2);
	tuple->fill(2,r3);
	tuple->addRow();
  }
	
  tree->commit();
  tree->close();
  return 0;
}
At now, I want to read or restore the file (gaussian.aida). For this purpose, I compile and run this file that follows:

#include "AIDA/AIDA.h"
using namespace AIDA;

int main()
{
  IAnalysisFactory *analysisFactory = AIDA_createAnalysisFactory();
  
  ITreeFactory *treeFactory = analysisFactory->createTreeFactory();

  ITree *tree = treeFactory->create();
  tree = treeFactory->create("gaussian.aida","xml");
	
  IManagedObject* managedObject= tree->find("/tuplePhoton");
  if(!managedObject) cout<<"this pointer is NULL:"<<endl;
  if(managedObject)  cout<<"managedObject pointer is pointed to:"<<managedObject->name()<<endl;

  if(!managedObject->cast("AIDA::ITuple"))          cout<<"error:"<<endl;
  AIDA::ITuple *tuple=managedObject->cast("AIDA::ITuple"); //error is occurred at this line.
	
	tree->commit();
	tree->close();
	
	return 0;
}

With compiling the above file, I get this error message:

g++ -c gausAidaRead.cc `aida-config --include` -Wno-deprecated
gausAidaRead.cc: In function `int main()':
gausAidaRead.cc:32: invalid conversion from `void*' to `AIDA::ITuple*'

How can I read data from gaussian.aida and then these data are saved (or wrote or restored) on other files, for example with N-tuple format or histograms?
Please, please help me.
Thanks
Shahrokh.


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

1 None: Re: Problem with AIDA and read or restore data from file (xml format)?   (Guy Barrand - 06 Mar, 2006)
1 Ok: Re: Problem with AIDA and read or restore data from file (xml format)?   (Shahrokh - 06 Mar, 2006)
3 None: Re: Problem with AIDA and read or restore data from file (xml format)?   (Shahrokh - 06 Mar, 2006)
 Add Message Add Message
to: "Problem with AIDA and read or restore data from file (xml format)?"

 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 ]