from paida import IAnalysisFactory analysisFactory = IAnalysisFactory.create() treeFactory = analysisFactory.createTreeFactory() ### No compressed XML storing. You can read easily the stored values in the created file. tree = treeFactory.create('sampleTuple.aida', 'xml', False, True, 'compress=no') ### Simple tuples. import paida.PTypes as PTypes tupleFactory = analysisFactory.createTupleFactory(tree) columnNames = ['iFlat = 0', 'fGauss = 3.0', 'fFlat'] columnTypes = [PTypes.Integer, PTypes.Float, PTypes.Float] simpleTuple1 = tupleFactory.create('simple tuple1', 'Simple Tuple1', columnNames, columnTypes) ### The same as simpleTuple1. simpleTuple2 = tupleFactory.create('simple tuple2', 'Simple Tuple2', 'int iFlat = 0, float fGauss = 3.0, float fFlat') ### Filling. import random r = random.Random() for i in range(10): simpleTuple1.fill(0, r.randint(1, 5)) simpleTuple1.fill(1, r.gauss(0.0, 1.0)) simpleTuple1.fill(2, r.random()) simpleTuple2.fill(0, r.randint(1, 5)) simpleTuple2.fill(1, r.gauss(0.0, 1.0)) simpleTuple2.fill(2, r.random()) simpleTuple1.addRow() simpleTuple2.addRow() ### Evaluator and filter. evaluator = tupleFactory.createEvaluator('iFlat * fGauss * fFlat') filter = tupleFactory.createFilter('fGauss * fFlat > 0.0') evaluator.initialize(simpleTuple1) filter.initialize(simpleTuple1) histogramFactory = analysisFactory.createHistogramFactory(tree) h1d1 = histogramFactory.createHistogram1D('histogram1', 'Histogram1', 20, -10.0, 10.0) h1d2 = histogramFactory.createHistogram1D('histogram2', 'Histogram2', 20, -10.0, 10.0) simpleTuple1.project(h1d1, evaluator) simpleTuple1.project(h1d2, evaluator, filter) plotterFactory = analysisFactory.createPlotterFactory() plotter = plotterFactory.create('PAIDA Plotter') plotter.createRegions(1, 2) plotter.region(0).setTitle('Original') plotter.region(0).style().setParameter('showTitle', 'true') plotter.region(0).plot(h1d1) plotter.region(1).setTitle('Filterd') plotter.region(1).style().setParameter('showTitle', 'true') plotter.region(1).plot(h1d2) ### Wait. dummy = raw_input('Hit any key.') ### Complex tuple. columnString = 'int event=0; tracks=0, ITuple momentums={double px=0.2; py=3.0; pz=0.0, ITuple hits={int x;y;z}}, float ipx;ipy;ipz' complexTuple = tupleFactory.create('complex tuple', 'Complex Tuple', columnString) ### Filling. events = 5 for i in range(events): complexTuple.fill(0, i) tracks = r.randint(0, 6) complexTuple.fill(1, tracks) momentum = complexTuple.getTuple(2) for j in range(tracks): momentum.fill(0, r.gauss(1.0, 1.0)) momentum.fill(1, r.gauss(1.0, 1.0)) momentum.fill(2, r.gauss(1.0, 1.0)) nHits = r.randint(0, 3) hits = momentum.getTuple(3) for k in range(nHits): hits.fill(0, r.randint(0, 10)) hits.fill(1, r.randint(0, 10)) hits.fill(2, r.randint(0, 10)) hits.addRow() momentum.addRow() complexTuple.fill(3, r.gauss(2.0, 2.0)) complexTuple.fill(4, r.gauss(2.0, 2.0)) complexTuple.fill(5, r.gauss(2.0, 2.0)) complexTuple.addRow() tree.commit() tree.close()