Message: Re: Using OpenScientist to analyse Geant4 data Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Using OpenScientist to analyse Geant4 data 

Forum: Analysis
Re: Question Using OpenScientist to analyse Geant4 data (Mario O de Menezes)
Re: None Re: Using OpenScientist to analyse Geant4 data (Guy Barrand)
Re: None Re: Using OpenScientist to analyse Geant4 data (Mario O de Menezes)
Date: 03 May, 2002
From: Guy Barrand <Guy Barrand>

> For example, I would like to normalize a spectrum, having the maximum
> height equals 1. How do I iterate over the tuples/histo, doing a
> division for each one?

  We have no IHistogram1D::normalize(double weigth) method.

  I will let Andreas, that was against its introduction, argue
 the point...

  Anyway, within the Lab package, I put below a python procedure
 that will permit you to produce a normalize histogram suitable
 for plotting :

def H1D_normalize(aName,aLabel,aHistogram,aWeight = 1.):
 h_normalized = H1D(aName,aLabel,aHistogram.axis().bins(),aHistogram.axis().lowerEdge(),aHistogram.axis().upperEdge())
 hsw = aHistogram.sumBinHeights()
 factor = aWeight/hsw
 for i in range(0,aHistogram.axis().bins()):
   x = (aHistogram.axis().binLowerEdge(i) + aHistogram.axis().binUpperEdge(i))/2
   h_normalized.fill(x,aHistogram.binHeight(i) * factor)
 return h_normalized

 An example of usage :

# Get current plotter :
plotter = Plotter('')
# parametrize plotter (with two regions) :
plotter.createRegions(1,2)

# Create an histo :
h = H1D('h','Rand gauss',100,-5,5)
rg = Lib_RandomGauss(0,1)
for I in range(0,10000):
  h.fill(rg.shoot(),1)

# From h, create an histo "normalized" to 2 :
h_normalized = H1D_normalize('h_normalized','Rand gauss normalized',h,2)

print h_normalized.sumBinHeights()

# Plot h and h_normalized :
plotter.plot(h)
plotter.next()
plotter.plot(h_normalized)

 (H1D_normalize will be available at next release of the Lab package
 alond with an example).

> I've tried to play with the evaluator but did not succeed, because I
> couldn't understand well the interface.

  The evaluator permits to define an operation that will
 be done, at each row processing, on the column entries of a tuple.
  Its output will be used, for example, to fill an histo.
  The filter permits to define a cut that will be apply,
 at each row processing, on the column entries. 

  For example, imagine you have hooked a tuple with
 two columns "A" and "B" :
# Get the tuple :
tuple = ....
# Book an histo :
histo = ....
# Create an Evaluator that will do some operation on
# columns entries, at each row processing :
evaluator = Evaluator(tuple,'A + 2 * B')
# Create a filter to "cut" rows according some expression
# over column entries :
filter = Filter(tuple2,'(fabs(A)<=2)&&(B>=1)')
# Project the tuple on the histo.
# Only accepted row that have "passed" the filter will
# be "evaluated" according "evaluator" ; the result of the
# evaluation will be used to fill the histo :
tuple.project(histo,evaluator,filter)

  Note that here, I have used "Evaluator", "Filter", "H1D", "Plotter"
 procedure that are defined in Lab/scripts/Python/Lab_init.py.
 These procedures encapsulate some code using my
 SWIG Python wrapping of the AIDA interfaces.

  For the moment, in that Lab package, I have only "scripted"
 evaluator and filter, that is to say ones using an interpreter
 to evaluat and filter. Someone may ask to be able to 
 define and use compiled ones...

 Doc improvement :
 ---------------
  In general I will rely on the AIDA wed site for doc and examples
 about the interfaces. You will have to refer to these pages.

 If you do not find what you want, complain here or
 at project-aida-dev@cern.ch, we will try to improve.
 
  For the moment only the Tony java material of the SLAC
 user workshop had been put in the AIDA site, we have to find 
 a way to organize the pages to have c++ examples but 
 in fact also Python examples...

  Since I use SWIG to wrap the interfaces, a transcription
 from java example to python should be easy to do.

 Python AIDA API :
 ---------------
  Note that for Python, the AIDA group had not yet
 discussed the AIDA API for Python. Andreas and me,
 we are using the SWIG tool to wrap our c++ implementations, but I am 
 not sure that in fact we have the same Python API...
 Moreover I have no idea of the Python API that Tony
 have by using Jython...

  Then for the moment what you see in the Lab/examples/Python
 (and Lab/scripts/Python/Lab_init.py)
 scripts had not be "AIDA-discussed". I will try to raise 
 the point at our next AIDA workshop (begin of June at CERN).

> I'll try to dig deeper into the code but this is a hard way to go 
> further, that is, I couldn't find a straight doc, leading me to the
> point.

  And there is probably not one right now ; that is to say
 a one explaining thorougthly the interfaces along with examples
 for various languages (C++, Java, Python) and along with what is
 available in the implementations.
  Some material exists and have to be gather in the AIDA web sites.
 Mainly the situation is that now we have some code covering
 three languages that permits to do most of common things 
 (ok, except a normalize...) and that we are at the beginning of 
 organizing the doc (and the rest) for all that...

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

1 Feedback: Re: Using OpenScientist to analyse Geant4 data   (Mario O de Menezes - 03 May, 2002)
2 None: social security search   (mark - 03 Oct, 2004)
 Add Message Add Message
to: "Re: Using OpenScientist to analyse Geant4 data"

 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 ]