diff --git a/GaudiPython/CMakeLists.txt b/GaudiPython/CMakeLists.txt index 38ea9e610de5335286e6b138da5f8d106047a128..3f0b9e721dd0b0e3ef01c0670ca2631336d8dc7d 100644 --- a/GaudiPython/CMakeLists.txt +++ b/GaudiPython/CMakeLists.txt @@ -18,15 +18,5 @@ gaudi_add_module(GaudiPython src/Services/*.cpp gaudi_add_dictionary(GaudiPython dict/kernel.h dict/selection_kernel.xml LINK_LIBRARIES GaudiPythonLib GaudiUtilsLib) -if(GAUDI_BUILD_TESTS) - gaudi_add_library(GPyTest src/Test/*.cpp - LINK_LIBRARIES GaudiKernel PythonLibs CLHEP - NO_PUBLIC_HEADERS) - gaudi_add_dictionary(test_GPyTest src/Test/test.h src/Test/test_selection.xml - LINK_LIBRARIES GaudiKernel PythonLibs CLHEP - INCLUDE_DIRS src/Test) - include_directories(src/Test) -endif() - #---Installation------------------------------------------------------------ gaudi_install_python_modules() diff --git a/GaudiPython/examples/dump_component_properties.py b/GaudiPython/examples/dump_component_properties.py deleted file mode 100644 index e0e2b490e7c2bcca357acc535279ada8512d3f08..0000000000000000000000000000000000000000 --- a/GaudiPython/examples/dump_component_properties.py +++ /dev/null @@ -1,18 +0,0 @@ -import os, gaudimodule -#---Get the list of DLLs available-------------------------------- -modules = [ e[:-3] for e in os.environ if e[-3:].upper() == 'SHR'] -for m in modules : #---For each one dump the cotents of Component and Properties - try: properties = gaudimodule.getComponentProperties(m) - except: continue - for c in properties : - print 80*'-' - print 'Properties of %s %s in library %s' % (properties[c][0], c, m) - print 80*'-' - for p in properties[c][1] : - value = properties[c][1][p] - if type(value) is str : - print "%-30s = '%s'" % ( c+'.'+p , value) - else : - print "%-30s = %s" % ( c+'.'+p , str(value)) - - diff --git a/GaudiPython/examples/read_lhcb_event_file.py b/GaudiPython/examples/read_lhcb_event_file.py deleted file mode 100644 index da2aad56f7952010ac7e797fc5afab024d75e323..0000000000000000000000000000000000000000 --- a/GaudiPython/examples/read_lhcb_event_file.py +++ /dev/null @@ -1,29 +0,0 @@ -#-------------------------------------------------- -#Note that it is assumed the LHCb environment setup -#-------------------------------------------------- -import gaudimodule,os -g = gaudimodule.AppMgr() - -g.loaddict('EventDict') -#g.readOptions(os.environ['EVENTSYSROOT']+'/options/PoolDicts.opts') - -sel = g.evtsel() -sel.open('rfio:/castor/cern.ch/lhcb/prod/00000080_00000001_5.oodst') -#sel.open('rfio:/castor/cern.ch/user/c/cattanem/Brunel/v23r0/Pool412400.dst',typ='POOL_ROOT') - -evt = g.evtsvc() -his = g.histsvc() - -h1 = his.book('h1','# of MCParticles', 40, 0, 5000) - -class DumpAlg(gaudimodule.PyAlgorithm): - def execute(self): - evh = evt['Header'] - mcps = evt['MC/Particles'] - print 'event # = ',evh.evtNum() - h1.fill(mcps.size()) - -g.addAlgorithm(DumpAlg()) -g.run(5) -print h1.contents() - diff --git a/GaudiPython/home/AnalysisInit.py b/GaudiPython/home/AnalysisInit.py deleted file mode 100644 index 7857db7259dedda959d392bb02409c3d0d4dc147..0000000000000000000000000000000000000000 --- a/GaudiPython/home/AnalysisInit.py +++ /dev/null @@ -1,47 +0,0 @@ -""" Simple Analysis Tools -""" -from math import * -from random import * -from gaudiextra import PartSvc - -#-------------------Algorithm----------------------------------------------- -class PhysAnalAlg(PyAlgorithm): - def initialize(self): - print 'Initializing User Analysis...' - global evt, his, det, pdt - his = g.histoSvc() - evt = g.evtSvc() - det = g.detSvc() - pdt = PartSvc() - initialize() - print '....User Analysis Initialized' - return 1 - def execute(self): - execute() - return 1 - def finalize(self): - print 'Finalizing User Analysis...' - finalize() - print '....User Analysis Finalized' - return 1 - -#-------------------Global utility fucntions-------------------------------- -def select(list,sel): - r = [] - for i in list: - if apply(sel,[i]): r.append(i) - return r - -#-------------------Configuration of Appliaction --------------------------- - -physalg = PhysAnalAlg(g,'PhysAnalAlg') -g.topAlg = g.topAlg + ['PhysAnalAlg'] -g.DLLs = g.DLLs + ['GaudiIntrospection'] -g.ExtSvc = g.ExtSvc + ['IntrospectionSvc', 'ParticlePropertySvc'] - - - - - - - diff --git a/GaudiPython/home/AnalysisTest.py b/GaudiPython/home/AnalysisTest.py deleted file mode 100644 index 94a56d33f53a0cf7f328f67229cc29649c8656d6..0000000000000000000000000000000000000000 --- a/GaudiPython/home/AnalysisTest.py +++ /dev/null @@ -1,46 +0,0 @@ -#--Initialize ------------------------------------------------ -execfile('../options/AnalysisInit.py') -#------------------------------------------------------------- - -#------------------------------------------------------------- -def electron(c): -#------------------------------------------------------------- - if c : return 1 - return 0 - -#------------------------------------------------------------- -def initialize(): -#------------------------------------------------------------- - global h0, h1, h2 - try: - h0 = his.histo('h0') - h1 = his.histo('h1') - h2 = his.histo('h2') - except: - h0 = his.book('h0', 'Histogram 1D for random tests', 35, -10., 10.) - h1 = his.book('h1', 'Histogram 1D for tests', 20, 0., 40.) - h2 = his.book('h2', 'Histogram 2D for test2', 20, 0., 40., 20, 0., 10.) - -#------------------------------------------------------------- -def execute(): -#------------------------------------------------------------- - global cands - cands = evt['Anal/AxParticleCandidates'] - - electrons = select(cands,electron) - print 'MyTracks collection contains ' + `len(tks)` + ' tracks and ' + `len(electrons)` + ' electrons' - - -#-------End of declarative part----------------------------------------------------- - -#g.run(10) -#excel.plot(h1) - -g.run(1) -sel = evt['Phys/PhysSel'] -sel.decayIsInMCTree('B0PP') - - - - - diff --git a/GaudiPython/home/ExcelPlotter.py b/GaudiPython/home/ExcelPlotter.py deleted file mode 100644 index 58b69ea6e812dc197ebade9dbd384e80c1da2580..0000000000000000000000000000000000000000 --- a/GaudiPython/home/ExcelPlotter.py +++ /dev/null @@ -1,31 +0,0 @@ -import win32com.client -import gaudiextra - -class Excel: - def __init__(self): - self.ex = win32com.client.Dispatch('Excel.Application') - self.wb = self.ex.Workbooks.Add() - self.ws = self.wb.WorkSheets.Add() - self.ws.Name = 'HistoData' - self.ch = self.wb.Charts.Add() - self.ch.Name = 'HistoPlot' - def plot(self, h): - self.ex.Visible = 0 - heights = h.heights() - nbin = len(heights) - xmin, xmax = h.edges() - for i in range(nbin) : - self.ws.Cells(i+1,1).value = heights[i] - self.ws.Cells(i+1,2).value = xmin + i*(xmax-xmin)/nbin - self.ch.SetSourceData(self.ws.Range(self.ws.Cells(1,1), self.ws.Cells(nbin+1,1))) - self.ch.HasTitle = 1 - self.ch.ChartTitle.Text = h.title() - self.ser = self.ch.SeriesCollection(1) - self.ser.XValues = self.ws.Range(self.ws.Cells(1,2), self.ws.Cells(nbin+1,2)) - self.ex.Visible = 1 - -global excel -excel = Excel() - - - diff --git a/GaudiPython/home/FillExcel.py b/GaudiPython/home/FillExcel.py deleted file mode 100644 index 8003ebae0c433ba1c976cef4b49121302c2817cf..0000000000000000000000000000000000000000 --- a/GaudiPython/home/FillExcel.py +++ /dev/null @@ -1,4 +0,0 @@ -import rootmodule - -hfile = TFile('hsimple.root') -ntuple = gROOT.FindObject('ntuple') \ No newline at end of file diff --git a/GaudiPython/home/ReadSicbFile.py b/GaudiPython/home/ReadSicbFile.py deleted file mode 100644 index 43cffa082e5891680759cb2c841b3c84acda735b..0000000000000000000000000000000000000000 --- a/GaudiPython/home/ReadSicbFile.py +++ /dev/null @@ -1,27 +0,0 @@ -#----Load the needed DynamicLibraries -g.DLLs = ['GaudiAlg', 'GaudiIntrospection','SicbCnv'] - -#----SICB stuff -sicbcnv = g.service('SicbEventCnvSvc') -perssvc = g.service('EventPersistencySvc') -perssvc.CnvServices = [ 'SicbEventCnvSvc' ] -evtsel = g.service('EventSelector') -evtsel.Input = ["FILE='//cern.ch/dfs/Experiments/lhcb/data/mc/sicb_bpipi_v233_100ev.dst1'"] - -#----Introspection Service Setup with its dictionaries -introssvc = g.service('IntrospectionSvc') -introssvc.Dictionaries = ['LHCbEventDict'] - - -#----Application Manager configuration -g.ExtSvc = ['ParticlePropertySvc', - 'SicbEventCnvSvc', - 'IntrospectionSvc'] - -g.EvtSel = 'SICB' -g.HistogramPersistency = 'NONE' -g.topAlg = [] -g.EvtMax = 10 - -print g.properties() - diff --git a/GaudiPython/home/Test.py b/GaudiPython/home/Test.py deleted file mode 100644 index 75018e1c24721a682d68edae02a20f859a3ca3ad..0000000000000000000000000000000000000000 --- a/GaudiPython/home/Test.py +++ /dev/null @@ -1,87 +0,0 @@ -import math -import sys -#----------Patch to force loading .so with RTDL_GLOBAL -if sys.platform == 'linux2' : sys.setdlopenflags(0x100|0x2) - -import gaudimodule as gaudi -g = gaudi.AppMgr() -g.JobOptionsType = 'NONE' -g.EvtSel = "NONE" - -g.config() -print '**************GaudiPython Job has been configured*************' - -g.DLLs = ['GaudiAlg', 'GaudiIntrospection'] -g.ExtSvc = ['IntrospectionSvc'] - -g.service('IntrospectionSvc').Dictionaries = ['TestDict'] - -g.DLLs += ['Test'] - -seq1 = g.algorithm('seq1') -seq1.members = ['HelloWorld', 'WriteAlg' ] - -g.topAlg += ['Sequencer/seq1'] - -g.initialize() -print '**************GaudiPython Job has been initialized*************' -g.run(2) -print '**************GaudiPython Job has been run ********************' - - -evt = gaudi.DataSvc(g.service('EventDataSvc')) -header = evt['/Event'] -print '***The event header is: ', header.values() -tracks = evt['/Event/MyTracks'] -print '***I got ', len(tracks), ' tracks' - -his = gaudi.HistoSvc(g.service('HistogramDataSvc')) -h1 = his.book('h1', 'histogram title 1D', 10, 0, 10) -print '***Created 1D histogram' -print h1 -h2 = his.book('h2', 'histogram title 1D', 10, 0, 10, 20, 0, 10) -print '***Created 2D histogram' -print h2 - -print '**************Histograms Tested ********************' - - -#---------------User Algorithm---------------------------------------------- -class PhysAnalAlg(gaudi.PyAlgorithm): - def initialize(self): - self.evt = gaudi.DataSvc(g.service('EventDataSvc')) - self.his = gaudi.HistoSvc(g.service('HistogramDataSvc')) - print 'Initializing User Analysis...' - self.h1 = self.his.book('myhisto1', 'Histogram 1D for tests', 20, 0., 40.) - self.h2 = self.his.book('myhisto2', 'Histogram 2D for test2', 20, 0., 40., 20, 0., 10.) - print '....User Analysis Initialized' - return 1 - def execute(self): - tks = self.evt.object('MyTracks') - print 'MyTracks collection contains ' + `len(tks)` + ' Tracks' - for t in tks : - self.h1.fill( math.sqrt(t.px*t.px + t.py*t.py + t.pz*t.pz), 1) - self.h2.fill( t.px, t.py ) - return 1 - def finalize(self): - print 'Finalizing User Analysis...' - print self.h1 - print self.h1.entries() - print self.h2 - print '....User Analysis Finalized' - return 1 - -print '**************Testing Python Algorithms ********************' -phyanalalg = PhysAnalAlg('PythonAlgorithm') -g.topAlg = g.topAlg + [ 'PythonAlgorithm' ] -g.run(100) -g.exit() - - - - - - - - - diff --git a/GaudiPython/src/Embedded/main.cpp b/GaudiPython/src/Embedded/main.cpp deleted file mode 100644 index 84d037ce51ac4eb8395c15ed5ef7e593c2e6b86e..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Embedded/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Python.h" -#include <iostream> -#include <string> -#include <fstream> - - -int main ( int argc, char** argv ) { - if (argc < 2 ) { - std::cout << "ERROR: insufficient command arguments" << std::endl; - return 0; - } - Py_Initialize(); - // Get the Python version - std::string fullversion = Py_GetVersion(); - std::string version( fullversion, 0, fullversion.find_first_of(' ')); - std::string vers(version, 0, version.find_first_of('.',version.find_first_of('.')+1)); - std::cout << "Python version: [" << vers << "]" << std::endl; - - // Startup commands - PyRun_SimpleString( "print dir()" ); - - std::cout << "Running now: " << argv[1] << std::endl; - std::ifstream file(argv[1]); - if ( file ) { - std::string buffer; - file.seekg(0, std::ios::end); - buffer.reserve(file.tellg()); - file.seekg(0, std::ios::beg); - buffer.assign((std::istreambuf_iterator<char>{file}), - std::istreambuf_iterator<char>{}); - file.close(); - PyRun_SimpleString( buffer.c_str() ); - } else { - std::cout << "ERROR: could not open file " << argv[1] << std::endl; - } - std::cout << "Exiting now " << std::endl; - - return 0 ; -} diff --git a/GaudiPython/src/Test/Dictionary/Class_dict.cpp b/GaudiPython/src/Test/Dictionary/Class_dict.cpp deleted file mode 100644 index 69c279c3052ca02c6fd299c5201743cff468426c..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/Dictionary/Class_dict.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <iostream> -#include <string> - -#define private public -#include "../Event.h" -#include "../MyTrack.h" -#include "../MyVertex.h" -#undef private - -#include "GaudiKernel/DataObject.h" - -class C_dict { -public: C_dict(); -}; - -void* Event_run( void* o ) { - static long r; - r = ((Event*)o)->run(); - return &r; -} -void Event_setRun( void* o, std::vector<void*> argv) { - ((Event*)o)->setRun( *(long*)(argv[0]) ); - return; -} - -void* MyTrack_event( void* o ) { - return const_cast<Event*>(((MyTrack*)o)->event()); -} -void MyTrack_setEvent( void* o, std::vector<void*> argv) { - ((MyTrack*)o)->setEvent( (Event*)(argv[0]) ); - return; -} - -static C_dict instance; - -C_dict::C_dict() -{ - MetaClass* meta1 = new MetaClass("Event", "Event header"); - meta1->addField("event", "long", "Event Number", OffsetOf(Event,m_event)); - meta1->addField("run", "long", "Run Number", OffsetOf(Event,m_run)); - meta1->addField("time", "Time", "Event creation Time", OffsetOf(Event,m_time)); - meta1->addMethod("getRun", "Get run number", "long", Event_run ); - std::vector<std::string> argnames1; - argnames1.push_back("long"); - meta1->addMethod("setRun", "Set run number", argnames1, Event_setRun ); - - MetaClass* meta2 = new MetaClass("Time", "Absolute time (64-bit) in ns"); - meta2->addField("time", "longlong", "Time",OffsetOf(Gaudi::Time,m_time)); - - MetaClass* meta3 = new MetaClass("MyTrack", "Track test object"); - meta3->addField("px", "float", "Momentum in x direction", OffsetOf(MyTrack,m_px)); - meta3->addField("py", "float", "Momentum in y direction", OffsetOf(MyTrack,m_py)); - meta3->addField("pz", "float", "Momentum in z direction", OffsetOf(MyTrack,m_pz)); - meta3->addField("event", "SmartRef<Event>", "Link to event root",OffsetOf(MyTrack,m_event)); - meta3->addField("decay", "SmartRef<MyVertex>", "Link to decay Vertex", OffsetOf(MyTrack,m_decay)); - meta3->addMethod("getEvent", "Get Event pointer", "Event*", MyTrack_event ); - std::vector<std::string> argnames3; - argnames3.push_back("Event*"); - meta3->addMethod("setEvent", "Set Event", argnames3, MyTrack_setEvent ); - - MetaClass* meta4 = new MetaClass("MyVertex", "Vertex test object"); - meta4->addField("x", "double", "Position in x", OffsetOf(MyVertex,m_x)); - meta4->addField("y", "double", "Position in y", OffsetOf(MyVertex,m_y)); - meta4->addField("z", "double", "Position in z", OffsetOf(MyVertex,m_z)); - meta4->addField("mother", "SmartRef<MyTrack>", "Link to mother Track", OffsetOf(MyVertex,m_mother)); - meta4->addField("daughters", "SmartRefVector<MyTrack>", "Link to daughter Tracks", OffsetOf(MyVertex,m_daughters)); -} - diff --git a/GaudiPython/src/Test/Event.h b/GaudiPython/src/Test/Event.h deleted file mode 100644 index 092bc7d66e1c0c817989f84ab9286614cf3fcfa4..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/Event.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef GAUDIEXAMPLES_EVENT_H -#define GAUDIEXAMPLES_EVENT_H 1 - -// Include files -#include "GaudiKernel/Kernel.h" -#include "GaudiKernel/Time.h" -#include "GaudiKernel/StreamBuffer.h" -#include "GaudiKernel/DataObject.h" -#include <iostream> -#include <iomanip> - -/** @class Event - - Essential information of the event used in examples - It can be identified by "/Event" - - - @author Pavel Binko -*/ - -static const CLID CLID_Event = 110; - -class Event : public DataObject { - -public: - /// Constructors - Event(): DataObject(), m_event(0), m_run(0) { } - /// Destructor - virtual ~Event() { } - - /// Retrieve reference to class definition structure - const CLID& clID() const override { return classID(); } - static const CLID& classID() { return CLID_Event; } - - /// Retrieve event number - long event () const { return m_event; } - /// Update event number - void setEvent (long value) { m_event = value; } - - /// Retrieve run number - long run () const { return m_run; } - /// Update run number - void setRun (long value) { m_run = value; } - - /// Retrieve reference to event time stamp - const Gaudi::Time& time () const { return m_time; } - /// Update reference to event time stamp - void setTime (const Gaudi::Time& value) { m_time = value; } - - /// Output operator (ASCII) - friend std::ostream& operator<< ( std::ostream& s, const Event& obj ) { - return obj.fillStream(s); - } - /// Fill the output stream (ASCII) - inline std::ostream& fillStream( std::ostream& s ) const override; - -private: - /// Event number - long m_event; - /// Run number - long m_run; - /// Time stamp - Gaudi::Time m_time; -}; - -/// Fill the output stream (ASCII) -inline std::ostream& Event::fillStream( std::ostream& s ) const { - return s - << "class Event :" - << "\n Event number = " - << std::setw(12) - << m_event - << "\n Run number = " - << std::setw(12) - << m_run - << "\n Time = " << m_time; -} - - -#endif // GAUDIEXAMPLES_EVENT_H diff --git a/GaudiPython/src/Test/HelloWorld.cpp b/GaudiPython/src/Test/HelloWorld.cpp deleted file mode 100644 index 7b00887e2d957692c5e1376365772f11e6c2e70e..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/HelloWorld.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Include files -#include "HelloWorld.h" - -// Static Factory declaration -DECLARE_COMPONENT(HelloWorld) - -// Constructor -//------------------------------------------------------------------------------ -HelloWorld::HelloWorld(const std::string& name, ISvcLocator* ploc) - : Algorithm(name, ploc) { -//------------------------------------------------------------------------------ - m_initialized = false; -} - -//------------------------------------------------------------------------------ -StatusCode HelloWorld::initialize() { -//------------------------------------------------------------------------------ - // avoid calling initialize more than once - if( m_initialized ) return StatusCode::SUCCESS; - - info() << "initializing...." << endmsg; - - m_initialized = true; - return StatusCode::SUCCESS; -} - - -//------------------------------------------------------------------------------ -StatusCode HelloWorld::execute() { -//------------------------------------------------------------------------------ - info() << "executing...." << endmsg; - - return StatusCode::SUCCESS; -} - - -//------------------------------------------------------------------------------ -StatusCode HelloWorld::finalize() { -//------------------------------------------------------------------------------ - info() << "finalizing...." << endmsg; - - m_initialized = false; - return StatusCode::SUCCESS; -} -//------------------------------------------------------------------------------ -StatusCode HelloWorld::beginRun() { -//------------------------------------------------------------------------------ - info() << "beginning new run...." << endmsg; - - m_initialized = true; - return StatusCode::SUCCESS; -} - - -//------------------------------------------------------------------------------ -StatusCode HelloWorld::endRun() { -//------------------------------------------------------------------------------ - info() << "ending new run...." << endmsg; - - m_initialized = true; - return StatusCode::SUCCESS; -} diff --git a/GaudiPython/src/Test/HelloWorld.h b/GaudiPython/src/Test/HelloWorld.h deleted file mode 100644 index 0c01329f2dec4e6304b1b755cf229cc3c18d22a7..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/HelloWorld.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef GAUDIEXAMPLE_HELLOWORLD_H -#define GAUDIEXAMPLE_HELLOWORLD_H 1 - -// Include files -#include "GaudiKernel/Algorithm.h" -#include "GaudiKernel/Property.h" -#include "GaudiKernel/MsgStream.h" - -/** @class HelloWorld - Trivial Algorithm for tutotial purposes - - @author nobody -*/ -class HelloWorld : public Algorithm { -public: - /// Constructor of this form must be provided - HelloWorld(const std::string& name, ISvcLocator* pSvcLocator); - - /// Three mandatory member functions of any algorithm - StatusCode initialize() override; - StatusCode execute() override; - StatusCode finalize() override; - StatusCode beginRun() override; - StatusCode endRun() override; -private: - bool m_initialized; - /// These data members are used in the execution of this algorithm - /// They are set in the initialisation phase by the job options service - IntegerProperty m_int; - DoubleProperty m_double; - StringProperty m_string; -}; - -#endif // GAUDIEXAMPLE_HELLOWORLD_H diff --git a/GaudiPython/src/Test/MyTrack.h b/GaudiPython/src/Test/MyTrack.h deleted file mode 100644 index 3196e5d8b59ed4655a374fed6552e8e626fae032..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/MyTrack.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef GAUDIEXAMPLES_MYTRACK_H -#define GAUDIEXAMPLES_MYTRACK_H - -// Include files -#include "GaudiKernel/SmartRef.h" -#include "GaudiKernel/StreamBuffer.h" -#include "GaudiKernel/ContainedObject.h" -#include "GaudiKernel/KeyedContainer.h" - -#include "Event.h" - -class MyVertex; - - -// External declaration -static const CLID& CLID_MyTrack = 9999; - - -/** @class MyTack - - Simple class that represents a track for testing purposes - - @author Markus Frank - @author Pere Mato -*/ -class MyTrack : public KeyedObject<int> { -private: - /// The track momentum - float m_px, m_py, m_pz; - /// Link to Top level event - SmartRef<Event> m_event; - SmartRef<MyVertex> m_decay; -public: - /// Standard constructor - MyTrack() : m_px(0.0), m_py(0.0), m_pz(0.0) { - } - /// Standard constructor - MyTrack(float x, float y, float z) : m_px(x), m_py(y), m_pz(z) { - } - /// Standard Destructor - virtual ~MyTrack() { - } - /// Retrieve pointer to class definition structure - const CLID& clID() const override { return classID(); } - static const CLID& classID() { return CLID_MyTrack; } - /// Accessors: Retrieve x-component of the track momentum - float px() const { return m_px; } - /// Accessors: Retrieve y-component of the track momentum - float py() const { return m_py; } - /// Accessors: Retrieve z-component of the track momentum - float pz() const { return m_pz; } - /// Accessors: Update x-component of the track momentum - void setPx(float px) { m_px = px; } - /// Accessors: Update y-component of the track momentum - void setPy(float py) { m_py = py; } - /// Accessors: Update z-component of the track momentum - void setPz(float pz) { m_pz = pz; } - - /// Access to the source track object (constant case) - const Event* event() const { - return m_event; - } - /// Access to event object - void setEvent(Event* evt) { - m_event = evt; - } - - /// Access to the source track object (constant case) - const MyVertex* decayVertex() const; - - /// Access to event object - void setDecayVertex(MyVertex* decay); - - std::ostream& fillStream( std::ostream& s ) const override { - s << "px: " << px() << "py: " << py() << "px: " << pz(); - return s; - } - - -}; - -#include "MyVertex.h" -/// Access to the source track object (constant case) -inline const MyVertex* MyTrack::decayVertex() const { - return m_decay; -} - -/// Access to event object -inline void MyTrack::setDecayVertex(MyVertex* decay) { - m_decay = decay; -} - -// Definition of all container types of MCParticle -typedef KeyedContainer<MyTrack> MyTrackVector; - -#endif // RIO_EXAMPLE1_MYTRACK_H diff --git a/GaudiPython/src/Test/MyVertex.h b/GaudiPython/src/Test/MyVertex.h deleted file mode 100644 index d9ce47f6784f4cbd065c21e707f1650d9ea216da..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/MyVertex.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef GAUDIEXAMPLES_MYVERTEX_H -#define GAUDIEXAMPLES_MYVERTEX_H - -// Include files -#include "GaudiKernel/SmartRef.h" -#include "GaudiKernel/SmartRefVector.h" -#include "GaudiKernel/StreamBuffer.h" -#include "GaudiKernel/ContainedObject.h" -#include "GaudiKernel/KeyedContainer.h" - -// Forward declaration -class MyTrack; - -// External declaration -static const CLID& CLID_MyVertex = 9998; - -/** @class MyVertex - - Simple class that represents a vertex for testing purposes - - @author Pere Mato -*/ -class MyVertex : public KeyedObject<int> { -private: - /// The track momentum - double m_x, m_y, m_z; - /// Link to Top level event - SmartRef<MyTrack> m_mother; - SmartRefVector<MyTrack> m_daughters; -public: - /// Standard constructor - MyVertex() : m_x(0.0), m_y(0.0), m_z(0.0) { - } - /// Standard constructor - MyVertex(double x, double y, double z) : m_x(x), m_y(y), m_z(z) { - } - /// Standard Destructor - virtual ~MyVertex() { - } - /// Retrieve pointer to class definition structure - const CLID& clID() const override { return classID(); } - static const CLID& classID() { return CLID_MyVertex; } - /// Accessors: Retrieve x-position - double x() const { return m_x; } - /// Accessors: Retrieve y-position - double y() const { return m_y; } - /// Accessors: Retrieve z-position - double z() const { return m_z; } - /// Accessors: Update x-position - void setX(double x) { m_x = x; } - /// Accessors: Update y-position - void setY(double y) { m_y = y; } - /// Accessors: Update z-position - void setZ(double z) { m_z = z; } - - /// Retrieve pointer to mother particle (const or non-const) - const MyTrack* motherTrack() const { return m_mother; } - MyTrack* motherTrack() { return m_mother; } - /// Update pointer to mother particle (by a C++ pointer or a smart reference) - void setMotherTrack( MyTrack* value ) { m_mother = value; } - //void setMotherTrack( SmartRef<MyTrack> value ); - - /// Retrieve pointer to vector of daughter particles (const or non-const) - //const SmartRefVector<MyTrack>& daughterTracks() const; - // SmartRefVector<MyTrack>& daughterTracks(); - /// Update all daughter particles - //void setDaughterTracks( const SmartRefVector<MyTrack>& value ); - /// Remove all daughter particles - //void removeDaughterTracks(); - /// Add single daughter particle to vector of daughter particles - /// (by a C++ pointer or a smart reference) - void addDaughterTrack( MyTrack* value ) { m_daughters.push_back(value); } - //void addDaughterTrack( SmartRef<MyTrack> value ); - - /// Input streamer - StreamBuffer& serialize(StreamBuffer& s) override; - - /// Output streamer - StreamBuffer& serialize(StreamBuffer& s) const override; -}; - -#include "MyTrack.h" - -/// Input streamer -inline StreamBuffer& MyVertex::serialize(StreamBuffer& s) { - return s >> m_x >> m_y >> m_z >> m_mother(this) >> m_daughters(this); -} -/// Output streamer -inline StreamBuffer& MyVertex::serialize(StreamBuffer& s) const { - return s << m_x << m_y << m_z << m_mother(this) << m_daughters(this); -} - - -// Definition of all container types of MyVertex -typedef KeyedContainer<MyVertex> MyVertexVector; - -#endif // RIO_EXAMPLE1_MYTRACK_H diff --git a/GaudiPython/src/Test/PropertyAlg.cpp b/GaudiPython/src/Test/PropertyAlg.cpp deleted file mode 100644 index 006279dbf18cd9f8f094b231b0e71ed6f0f89df9..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/PropertyAlg.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Include files -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/DataObject.h" -#include "GaudiKernel/IDataProviderSvc.h" -#include "GaudiKernel/IChronoStatSvc.h" -#include "GaudiKernel/IJobOptionsSvc.h" -#include "GaudiKernel/SmartIF.h" -#include "PropertyAlg.h" - - -// Static Factory declaration -DECLARE_COMPONENT(PropertyAlg) - -// Constructor -//------------------------------------------------------------------------------ -PropertyAlg::PropertyAlg(const std::string& name, ISvcLocator* ploc) - : Algorithm(name, ploc) { -//------------------------------------------------------------------------------ - // Declare the algorithm's properties - - declareProperty( "Bool", m_bool = true); - declareProperty( "Char", m_char = 100); - declareProperty( "Uchar", m_uchar = 100); - declareProperty( "Schar", m_schar = 100); - declareProperty( "Short", m_short = 100); - declareProperty( "Ushort", m_ushort = 100); - declareProperty( "Int", m_int = 100); - declareProperty( "Uint", m_uint = 100); - declareProperty( "Long", m_long = 100L); - declareProperty( "Ulong", m_ulong = 100L); - declareProperty( "Longlong", m_longlong = 100LL); - declareProperty( "Ulonglong", m_ulonglong = 100LL); - declareProperty( "Float", m_float = 100.0F); - declareProperty( "Double", m_double = 100.); - declareProperty( "String", m_string = "hundred"); - - declareProperty( "BoolArray", m_boolarray ); - declareProperty( "CharArray", m_chararray ); - declareProperty( "UcharArray", m_uchararray ); - declareProperty( "ScharArray", m_schararray ); - declareProperty( "ShortArray", m_shortarray ); - declareProperty( "UshortArray", m_ushortarray ); - declareProperty( "IntArray", m_intarray ); - declareProperty( "UintArray", m_uintarray ); - declareProperty( "LongArray", m_longarray ); - declareProperty( "UlongArray", m_ulongarray ); - declareProperty( "LonglongArray", m_longlongarray ); - declareProperty( "UlonglongArray", m_ulonglongarray ); - declareProperty( "FloatArray", m_floatarray ); - declareProperty( "DoubleArray", m_doublearray ); - declareProperty( "StringArray", m_stringarray ); - -} - - - diff --git a/GaudiPython/src/Test/PropertyAlg.h b/GaudiPython/src/Test/PropertyAlg.h deleted file mode 100644 index 460c7ff35ef09f5f9a044be8b43796a04421efd3..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/PropertyAlg.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef GAUDIEXAMPLE_PROPERTYALG_H -#define GAUDIEXAMPLE_PROPERTYALG_H - -// Include files -#include "GaudiKernel/Algorithm.h" -#include "GaudiKernel/Property.h" -#include "GaudiKernel/MsgStream.h" - -/** @class PropertyAlg - Trivial Algorithm for tutotial purposes - - @author nobody -*/ -class PropertyAlg : public Algorithm { -public: - /// Constructor of this form must be provided - PropertyAlg(const std::string& name, ISvcLocator* pSvcLocator); - - /// Three mandatory member functions of any algorithm - StatusCode initialize() override { return StatusCode::SUCCESS; } - StatusCode execute() override { return StatusCode::SUCCESS; } - StatusCode finalize() override { return StatusCode::SUCCESS; } - -private: - /// These data members are used in the execution of this algorithm - /// They are set in the initialisation phase by the job options service - - bool m_bool; - char m_char; - signed char m_schar; - unsigned char m_uchar; - short m_short; - unsigned short m_ushort; - int m_int; - unsigned int m_uint; - long m_long; - unsigned long m_ulong; - long long m_longlong; - unsigned long long m_ulonglong; - float m_float; - double m_double; - std::string m_string; - - std::vector<bool> m_boolarray; - std::vector<char> m_chararray; - std::vector<unsigned char> m_uchararray; - std::vector<signed char> m_schararray; - std::vector<short> m_shortarray; - std::vector<unsigned short> m_ushortarray; - std::vector<int> m_intarray; - std::vector<unsigned int> m_uintarray; - std::vector<long> m_longarray; - std::vector<unsigned long> m_ulongarray; - std::vector<long long> m_longlongarray; - std::vector<unsigned long long> m_ulonglongarray; - std::vector<float> m_floatarray; - std::vector<double> m_doublearray; - std::vector<std::string> m_stringarray; - -}; - -#endif // GAUDIEXAMPLE_PROPERTYALG_H diff --git a/GaudiPython/src/Test/RandomNumberAlg.cpp b/GaudiPython/src/Test/RandomNumberAlg.cpp deleted file mode 100644 index d9a8736b4a07087175caa982d2e1a79eac08c56d..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/RandomNumberAlg.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Framework include files -#include "GaudiKernel/SmartIF.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/IRndmGen.h" -#include "GaudiKernel/IRndmGenSvc.h" -#include "GaudiKernel/IHistogramSvc.h" -#include "GaudiKernel/IDataProviderSvc.h" -#include "GaudiKernel/DataObject.h" -#include "GaudiKernel/SmartDataPtr.h" - -#include "AIDA/IHistogram1D.h" -#include "AIDA/IHistogram2D.h" - -// Example related include files -#include "RandomNumberAlg.h" - -DECLARE_COMPONENT(RandomNumberAlg) - -/** Algorithm parameters which can be set at run time must be declared. - This should be done in the constructor. -*/ -RandomNumberAlg::RandomNumberAlg(const std::string& name, ISvcLocator* pSvcLocator) -: Algorithm(name, pSvcLocator) { -} - -// Standard destructor -RandomNumberAlg::~RandomNumberAlg() { -} - -// The "functional" part of the class: For the EmptyAlgorithm example they do -// nothing apart from print out info messages. -StatusCode RandomNumberAlg::initialize() { - StatusCode sc; - - // Initilize random number generators - sc = m_poissonNumbers.initialize(randSvc(), Rndm::Poisson(0.3)); - if ( sc.isFailure() ) return sc; - sc = m_gaussNumbers.initialize(randSvc(), Rndm::Gauss(0.5,0.2)); - if ( sc.isFailure() ) return sc; - sc = m_expNumbers.initialize(randSvc(), Rndm::Exponential(0.2)); - if ( sc.isFailure() ) return sc; - - - // Initiatize Histograms - m_gaussHisto = histoSvc()->book( "simple/1", "Gauss", 40, 0., 3.); - m_gauss2Histo = histoSvc()->book( "simple/2", "Gauss 2D", 40, 0., 3., 50, 0., 3.); - m_expHisto = histoSvc()->book( "simple/3", "Exponential", 40, 0., 3.); - m_poissonHisto = histoSvc()->book( "simple/4", "Poisson", 40, 0., 3.); - - return sc; -} - -StatusCode RandomNumberAlg::execute() { - StatusCode sc; - - m_gaussHisto->fill(m_gaussNumbers(), 1.0 ); - m_gauss2Histo->fill(m_gaussNumbers(), m_gaussNumbers(), 1.0 ); - m_poissonHisto->fill(m_poissonNumbers(), 1.0 ); - m_expHisto->fill(m_expNumbers(), 1.0 ); - return sc; -} - -StatusCode RandomNumberAlg::finalize() { - return StatusCode::SUCCESS; -} - diff --git a/GaudiPython/src/Test/RandomNumberAlg.h b/GaudiPython/src/Test/RandomNumberAlg.h deleted file mode 100644 index f17c9df810a941ec59355eeab2da08932327e996..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/RandomNumberAlg.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef GAUDIEXAMPLES_RANDOMNUMBERALG_H -#define GAUDIEXAMPLES_RANDOMNUMBERALG_H - -// Framework include files -#include "GaudiKernel/Algorithm.h" -#include "GaudiKernel/RndmGenerators.h" - -namespace AIDA { - class IHistogram1D; - class IHistogram2D; -} - - -/** @class RandomNumberAlg - A small algorithm class using the random number service - - @author M.Frank - @date 1999 -*/ -class RandomNumberAlg : public Algorithm { - protected: - /// Allocate wrapper for random number generator - Rndm::Numbers m_gaussNumbers; - Rndm::Numbers m_poissonNumbers; - Rndm::Numbers m_expNumbers; - - AIDA::IHistogram1D* m_gaussHisto; - AIDA::IHistogram2D* m_gauss2Histo; - AIDA::IHistogram1D* m_poissonHisto; - AIDA::IHistogram1D* m_expHisto; - -public: - /// Constructor: A constructor of this form must be provided. - RandomNumberAlg(const std::string& name, ISvcLocator* pSvcLocator); - /// Standard Destructor - ~RandomNumberAlg() override; - /// Customized initialisation - StatusCode initialize() override; - /// Customized finalisation - StatusCode finalize() override; - /// Event callback - StatusCode execute() override; -}; - -#endif // GAUDIEXAMPLES_RANDOMNUMBERALG_H diff --git a/GaudiPython/src/Test/WriteAlg.cpp b/GaudiPython/src/Test/WriteAlg.cpp deleted file mode 100644 index 2407c01a3067e164566dd89f703260b0f5eb3454..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/WriteAlg.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Framework include files -#include "GaudiKernel/SmartDataPtr.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/RndmGenerators.h" - -#include "GaudiKernel/IDataProviderSvc.h" -#include "GaudiKernel/IDataManagerSvc.h" - -// Example related include files -#include "WriteAlg.h" - -// Event Model related classes -#include "Event.h" -#include "MyTrack.h" -#include "MyVertex.h" - -DECLARE_COMPONENT(WriteAlg) - -//-------------------------------------------------------------------- -// Initialize -//-------------------------------------------------------------------- -StatusCode WriteAlg::initialize() { - return StatusCode::SUCCESS; -} - -//-------------------------------------------------------------------- -// Execute -//-------------------------------------------------------------------- -StatusCode WriteAlg::execute() { - StatusCode sc; - - static int evtnum = 0; - static int runnum = 999; - - Rndm::Numbers rndmflat(randSvc(), Rndm::Flat(0.,1.)); - Rndm::Numbers rndmgauss(randSvc(), Rndm::Gauss(10.,1.)); - - // Create the Event header and set it as "root" of the event store - Event* event = new Event(); - event->setEvent(++evtnum); - event->setRun(runnum); - event->setTime(Gaudi::Time()); - - auto evtmgr = eventSvc().as<IDataManagerSvc>(); - sc = evtmgr->setRoot("/Event", event); - if( sc.isFailure() ) { - error() << "Unable to register /Event object" << endmsg; - return sc; - } - // Create containers - MyTrackVector* myTracks = new MyTrackVector(); - MyVertexVector* myVertices = new MyVertexVector(); - // Create the primary trackm and vector - MyTrack* ptrack = new MyTrack((float)rndmgauss(),(float)rndmgauss(),(float)rndmgauss()); - MyVertex* dvertex = new MyVertex(0,0,0); - ptrack->setDecayVertex(dvertex); - ptrack->setEvent(event); - dvertex->setMotherTrack(ptrack); - myTracks->add( ptrack ); - myVertices->add ( dvertex ); - // loop over first decays... - int n = (int)(rndmflat() * 100.); - for( int i = 0; i < n; i++ ) { - // Create new track - MyTrack* t = new MyTrack((float)rndmgauss(),(float)rndmgauss(),(float)rndmgauss()); - myTracks->add ( t ); - t->setEvent(event); - dvertex->addDaughterTrack(t); - if( rndmflat() > 0.5 ) { - MyVertex* dv = new MyVertex(rndmflat(),rndmflat(),rndmflat()*10.); - myVertices->add ( dv ); - dv->setMotherTrack(t); - int m = (int)(rndmflat() * 10.); - for( int j = 0; j < m; j++ ) { - MyTrack* dt = new MyTrack(t->px()/m,t->py()/m,t->pz()/m); - myTracks->add ( dt ); - dt->setEvent(event); - dv->addDaughterTrack(dt); - } - } - } - - sc = eventSvc()->registerObject("/Event","MyTracks",myTracks); - if( sc.isFailure() ) { - error() << "Unable to register MyTracks" << endmsg; - return sc; - } - sc = eventSvc()->registerObject("/Event","MyVertices",myVertices); - if( sc.isFailure() ) { - error() << "Unable to register MyVertices" << endmsg; - return sc; - } - - // All done - info() << "Generated event " << evtnum << endmsg; - return StatusCode::SUCCESS; -} - -//-------------------------------------------------------------------- -// Finalize -//-------------------------------------------------------------------- -StatusCode WriteAlg::finalize() { - return StatusCode::SUCCESS; -} diff --git a/GaudiPython/src/Test/WriteAlg.h b/GaudiPython/src/Test/WriteAlg.h deleted file mode 100644 index e28b1eb80a460203c5db5bf7b2de3ba1733d33d2..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/WriteAlg.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef GAUDIEXAMPLE_WRITEALG_H -#define GAUDIEXAMPLE_WRITEALG_H - -// Framework include files -#include "GaudiKernel/Algorithm.h" - -/** @class WriteAlg WriteAlg.h - - WriteAlg class for the RootIOExample - - @author Markus Frank -*/ - -class WriteAlg : public Algorithm { -public: - /// Constructor: A constructor of this form must be provided. - WriteAlg(const std::string& name, ISvcLocator* pSvcLocator) - : Algorithm(name, pSvcLocator) { } - /// Standard Destructor - ~WriteAlg() override { } - /// Initialize - StatusCode initialize() override; - /// Finalize - StatusCode finalize() override; - /// Event callback - StatusCode execute() override; -}; - -#endif // GAUDIEXAMPLE_WRITEALG_H diff --git a/GaudiPython/src/Test/test.h b/GaudiPython/src/Test/test.h deleted file mode 100644 index 11bb8481d7cbfeb9b6d7875fad8f8ffad426011f..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/test.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef __ICC -// disable icc warning #191: type qualifier is meaningless on cast type -#pragma warning(disable:191) -#endif - -#include "Event.h" -#include "MyTrack.h" -#include "MyVertex.h" - -struct __Instantiations -{ - KeyedContainer<MyTrack> i0; - KeyedContainer<MyVertex> i1; -}; diff --git a/GaudiPython/src/Test/test_selection.xml b/GaudiPython/src/Test/test_selection.xml deleted file mode 100644 index ab8a29b1f1b30456c0297c35d54258835e94b499..0000000000000000000000000000000000000000 --- a/GaudiPython/src/Test/test_selection.xml +++ /dev/null @@ -1,7 +0,0 @@ -<lcgdict> - <class name="Event"/> - <class name="MyTrack"/> - <class name="MyVertex"/> - <class pattern="KeyedContainer<*>"/> - <class name="std::vector<MyTrack*>"/> -</lcgdict> \ No newline at end of file diff --git a/GaudiPython/tests/test.opts b/GaudiPython/tests/test.opts deleted file mode 100644 index fe5b39e2473c96fd86e2cee1db67b4175af26f53..0000000000000000000000000000000000000000 --- a/GaudiPython/tests/test.opts +++ /dev/null @@ -1,2 +0,0 @@ -aaa.bbb = 10; -ccc.ddd = "text"; diff --git a/GaudiPython/tests/test_analysis.py b/GaudiPython/tests/test_analysis.py deleted file mode 100644 index 068b69f79c06c61854b3faac96231a66dbb3fff4..0000000000000000000000000000000000000000 --- a/GaudiPython/tests/test_analysis.py +++ /dev/null @@ -1,88 +0,0 @@ -import gaudimodule as gaudi -import math -g = gaudi.AppMgr() -g.JobOptionsType = 'NONE' -g.EvtSel = "NONE" -g.config() -print '**************GaudiPython Job has been configured*************' - -g.DLLs = ['GaudiAlg'] -g.DLLs += ['GPyTest'] -g.loaddict('test_GPyTestDict') - -seq1 = g.algorithm('seq1') -seq1.members = ['HelloWorld', 'WriteAlg' ] -g.topAlg += ['Sequencer/seq1'] - -g.initialize() -print '**************GaudiPython Job has been initialized*************' -g.run(2) -print '**************GaudiPython Job has been run ********************' -evt = g.datasvc('EventDataSvc') - -header = evt['/Event'] -print '***The event number is: ', header.event() -tracks = evt['/Event/MyTracks'] -print '***I got ', tracks.size(), ' tracks' - -his = g.histsvc('HistogramDataSvc') -h1 = his.book('h1', 'histogram title 1D', 10, 0, 10) -print '***Created 1D histogram' -print h1 - -h2 = his.book('h2', 'histogram title 2D', 10, 0, 10, 20, 0, 10) -print '***Created 2D histogram' -print h2 - -print '**************Histograms Tested ********************' - -#---------------User Algorithm---------------------------------------------- -class PhysAnalAlg(gaudi.PyAlgorithm): - def initialize(self): - self.evt = g.evtsvc() - self.his = g.histsvc() - print 'Initializing User Analysis...' - self.h1 = self.his.book('myhisto1', 'Histogram 1D for tests', 20, 0., 40.) - self.h2 = self.his.book('myhisto2', 'Histogram 2D for tests', 20, 0., 40., 20, 0., 10.) - print '....User Analysis Initialized' - return 1 - def execute(self): - tks = self.evt['MyTracks'] - print 'MyTracks collection contains ' + `tks.size()` + ' Tracks' - for t in tks : - self.h1.fill( math.sqrt(t.px()*t.px() + t.py()*t.py() + t.pz()*t.pz()), 1) - self.h2.fill( t.px(), t.py() ) - return 1 - def finalize(self): - print 'Finalizing User Analysis...' - print self.h1 - print self.h1.contents() - print self.h2 - print '....User Analysis Finalized' - return 1 - def __repr__(self): - return 'here we are' - - - -from GaudiAlgs import HistoAlgo - -class MyHistoAlg(HistoAlgo) : - def execute( self ) : - #--waiting to fix a problem in PyROOT - self.plot( 15 , 'ha-ha-ha' , 0 , 100 ) - return 1 - - - -print '**************Testing Python Algorithms ********************' -phyanalalg = PhysAnalAlg('PythonAlgorithm') -myAlg = MyHistoAlg('MyAlg') -g.setAlgorithms( ['Sequencer/seq1', phyanalalg, myAlg ] ) - -g.run(10) - -hh=myAlg.histoSvc('MyAlg/1') -print hh - -#g.exit() diff --git a/GaudiPython/tests/test_basics.py b/GaudiPython/tests/test_basics.py deleted file mode 100644 index 2bfc792479540528bb81bbfec5ee6ec113f72a52..0000000000000000000000000000000000000000 --- a/GaudiPython/tests/test_basics.py +++ /dev/null @@ -1,341 +0,0 @@ -import unittest -import GaudiPython - -g = GaudiPython.AppMgr(outputlevel=5) -g.initialize() - -class BasicTests(unittest.TestCase): - def setUp(self): - pass - def tearDown(self): - pass - - def test01ProtoProperties(self): - #--When not yet existing - alg = g.algorithm('myalg') - alg.strings = ['string1', 'string2'] - alg.string = 'word1 word2' - alg.numbers = [1,2,3] - alg.number = 7.8 - self.failUnless( len(alg.strings) == 2, 'strings len fail' ) - self.failUnless( alg.strings == ['string1', 'string2'], 'strings len fail' ) - self.failUnless( len(alg.numbers) == 3, 'strings fail' ) - self.failUnless( alg.numbers == [1,2,3], 'numbers fail' ) - self.failUnless( alg.number == 7.8, 'fail to set float property' ) - self.failUnless( alg.string == 'word1 word2', 'fail to set string property' ) - self.failUnless( alg.number == 7.8, 'fail to set float property' ) - - def test02Properties(self): - properties = g.properties() - for p in properties : - self.failUnlessEqual(properties[p].value(), getattr(g, str(p))) - - def test03Properties(self) : - g.Dlls += ['GPyTest'] - g.topAlg += ['PropertyAlg'] - p = g.algorithm('PropertyAlg') - #---Bool - self.failUnlessEqual( p.Bool, True ) - p.Bool = False - self.failUnlessEqual( p.Bool, False ) - #---Char - """ - self.failUnlessEqual( p.Char, chr(100) ) - p.Char = chr(99) - self.failUnlessEqual( p.Char, chr(99) ) - self.failUnlessEqual( p.Schar, chr(100) ) - p.Schar = chr(99) - self.failUnlessEqual( p.Schar, chr(99) ) - self.failUnlessEqual( p.Uchar, chr(100) ) - p.Uchar = chr(99) - self.failUnlessEqual( p.Uchar, chr(99) ) - """ - #---Short - self.failUnlessEqual( p.Short, 100 ) - p.Short = -99 - self.failUnlessEqual( p.Short, -99 ) - self.failUnlessEqual( p.Ushort, 100 ) - p.Ushort = 99 - self.failUnlessEqual( p.Ushort, 99 ) - #---Int - self.failUnlessEqual( p.Int, 100 ) - p.Int = -999 - self.failUnlessEqual( p.Int, -999 ) - self.failUnlessEqual( p.Uint, 100 ) - p.Uint = 999 - self.failUnlessEqual( p.Uint, 999 ) - #---Long - self.failUnlessEqual( p.Long, 100 ) - p.Long = -9999 - self.failUnlessEqual( p.Long, -9999 ) - self.failUnlessEqual( p.Ulong, 100 ) - p.Ulong = 9999 - self.failUnlessEqual( p.Ulong, 9999 ) - #---LongLong - #self.failUnlessEqual( p.Longlong, 100 ) - #p.Longlong = -99999 - #self.failUnlessEqual( p.Longlong, -99999 ) - #self.failUnlessEqual( p.Ulonglong, 100 ) - #p.Ulonglong = 99999 - #self.failUnlessEqual( p.Ulonglong, 99999 ) - #---Float - self.failUnlessEqual( p.Float, 100. ) - p.Float = -99.00 - self.failUnlessEqual( p.Float, -99.00 ) - #---Double - self.failUnlessEqual( p.Double, 100. ) - p.Double = 999.999 - self.failUnlessEqual( p.Double, 999.999 ) - #---String - self.failUnlessEqual( p.String, 'hundred' ) - p.String = 'another string' - self.failUnlessEqual( p.String, 'another string' ) - #---Bool Array - self.failUnlessEqual( p.BoolArray, [] ) - p.BoolArray = [True,False] - self.failUnlessEqual( p.BoolArray, [True,False] ) - #---Char Array - self.failUnlessEqual( p.CharArray, [] ) - p.CharArray = [0x20, 0x21] - #---FIXME---self.failUnlessEqual( p.CharArray, [0x20,0x21] ) - #---Short Array - self.failUnlessEqual( p.ShortArray, [] ) - p.ShortArray = range(10) - #---FIXME---self.failUnlessEqual( p.ShortArray, range(10) ) - #---Int Array - self.failUnlessEqual( p.IntArray, [] ) - p.IntArray = range(10,0,-1) - self.failUnlessEqual( p.IntArray, range(10,0,-1) ) - #---Long Array - self.failUnlessEqual( p.LongArray, [] ) - p.LongArray = range(10,0,-1) - self.failUnlessEqual( p.LongArray, range(10,0,-1) ) - #---LongLong Array - #self.failUnlessEqual( p.LongLongArray, [] ) - #p.LongLongArray = range(10,0,-1) - #self.failUnlessEqual( p.LongLongArray, range(10,0,-1) ) - #---Float Array - self.failUnlessEqual( p.FloatArray, [] ) - p.FloatArray = [ 1., 2., 3. ] - self.failUnlessEqual( p.FloatArray, [1., 2., 3.] ) - #---Double Array - self.failUnlessEqual( p.DoubleArray, [] ) - p.DoubleArray = [ 1., 2., 3. ] - self.failUnlessEqual( p.DoubleArray, [1., 2., 3.] ) - #---String Array - self.failUnlessEqual( p.StringArray, [] ) - p.StringArray = [ 'abc', 'def', 'g' ] - self.failUnlessEqual( p.StringArray, ['abc','def','g'] ) - p.StringArray += [ 'xyz' ] - self.failUnlessEqual( p.StringArray, ['abc','def','g', 'xyz'] ) - - def test03ReadProperties(self): - g.Dlls += ['GaudiAlg'] - f = open('tmp.opts','w') - f.write('s1.members = {"Prescaler/p1","Prescaler/p2"};\n') - f.write('p1.ErrorMax = 99;\n') - f.write('p2.ErrorMax = 88;\n') - f.close() - g.readOptions('tmp.opts') - g.topAlg += ['Sequencer/s1'] - g.HistogramPersistency = 'NONE' - g.reinitialize() - p1 = g.algorithm('p1') - p2 = g.algorithm('p2') - self.failUnless(p1) - self.failUnless(p2) - self.failUnlessEqual(p1.ErrorMax, 99) - self.failUnlessEqual(p2.ErrorMax, 88) - - def test04EventStore(self): - evt = g.datasvc('EventDataSvc') - objs = [] - for i in range(10) : objs.append(GaudiPython.gbl.DataObject()) - for o in objs : o.addRef() # To keep the ownership - self.failUnless(evt) - self.failUnless(evt.setRoot('Root',objs[1]).isSuccess()) - self.failUnless(evt.registerObject('AB',objs[2]).isSuccess()) - self.failUnless(evt.registerObject('A',objs[3]).isSuccess()) - self.failUnless(evt.registerObject('B',objs[4]).isSuccess()) - self.failUnless(evt.registerObject('A/O1',objs[5]).isSuccess()) - self.failUnless(evt.registerObject('A/O2',objs[6]).isSuccess()) - self.failUnless(evt.registerObject('B/O1',objs[7]).isSuccess()) - self.failUnless(evt.registerObject('B/O2',objs[8]).isSuccess()) - o = evt.retrieveObject('/Root/A/O1') - self.failUnless(o) - self.failUnlessEqual(o.registry().identifier(), '/Root/A/O1') - self.failUnlessEqual(len(evt.leaves()), 3) - o = evt['B'] - self.failUnlessEqual(len(evt.leaves(o)), 2) - self.failUnlessEqual(evt.leaves(o)[0].name(), '/O1') - self.failUnlessEqual(evt.leaves(o)[1].name(), '/O2') - self.failUnlessEqual(evt.leaves(o)[0].identifier(), '/Root/B/O1') - self.failUnlessEqual(evt.leaves(o)[1].identifier(), '/Root/B/O2') - self.failUnless(evt.clearStore().isSuccess()) - - - def test05HistogramSvc(self): - hsvc = g.histsvc() - self.failUnless(hsvc) - h1 = hsvc.book('h1', 'Histogram title 1D', 10, 0, 10) - self.failUnless(h1) - self.failUnlessEqual(h1.title(), 'Histogram title 1D') - self.failUnlessEqual(h1.axis().bins(), 10) - self.failUnlessEqual(h1.axis().lowerEdge(), 0.) - self.failUnlessEqual(h1.axis().upperEdge(), 10.) - self.failUnlessEqual(h1.entries(), 0) - h1.fill(5) - self.failUnlessEqual(h1.entries(), 1) - h2 = hsvc.book('h2', 'Histogram title 2D', 10, 0, 10, 20, 0, 10) - self.failUnless(h2) - self.failUnlessEqual(h2.title(), 'Histogram title 2D') - self.failUnlessEqual(h2.xAxis().bins(), 10) - self.failUnlessEqual(h2.xAxis().lowerEdge(), 0.) - self.failUnlessEqual(h2.xAxis().upperEdge(), 10.) - self.failUnlessEqual(h2.yAxis().bins(), 20) - self.failUnlessEqual(h2.yAxis().lowerEdge(), 0.) - self.failUnlessEqual(h2.yAxis().upperEdge(), 10.) - self.failUnlessEqual(h2.entries(), 0) - for i in range(10) : h2.fill(i,i) - self.failUnlessEqual(h2.entries(), 10) - h3 = hsvc.book('h3', 'Histogram title 3D', 10, 0, 10, 20, 0, 10, 30, -10, 10) - self.failUnless(h2) - self.failUnlessEqual(h3.title(), 'Histogram title 3D') - self.failUnlessEqual(h3.xAxis().bins(), 10) - self.failUnlessEqual(h3.xAxis().lowerEdge(), 0.) - self.failUnlessEqual(h3.xAxis().upperEdge(), 10.) - self.failUnlessEqual(h3.yAxis().bins(), 20) - self.failUnlessEqual(h3.yAxis().lowerEdge(), 0.) - self.failUnlessEqual(h3.yAxis().upperEdge(), 10.) - self.failUnlessEqual(h3.zAxis().bins(), 30) - self.failUnlessEqual(h3.zAxis().lowerEdge(), -10.) - self.failUnlessEqual(h3.zAxis().upperEdge(), 10.) - self.failUnlessEqual(h3.entries(), 0) - for i in range(10) : h3.fill(i,i,i) - self.failUnlessEqual(h3.entries(), 10) - th1 = hsvc.retrieve1D('h1') - self.failUnless(th1) - self.failUnlessEqual(th1.title(), 'Histogram title 1D') - th2 = hsvc.retrieve2D('/stat/h2') - self.failUnless(th2) - self.failUnlessEqual(th2.title(), 'Histogram title 2D') - th3 = hsvc.retrieve3D('/stat/h3') - self.failUnless(th3) - self.failUnlessEqual(th3.title(), 'Histogram title 3D') - th = hsvc.retrieve('h2') - self.failUnless(th) - self.failUnlessEqual(th.title(), 'Histogram title 2D') - - - def test06Config(self): - f = open('tmp2.opts','w') - f.write('ApplicationMgr.EvtMax = -1;') - f.write('ApplicationMgr.Dlls += { "GaudiAlg" };') - f.close() - g.config( files = ['tmp2.opts'], - options = ['ApplicationMgr.Go = 123'] ) - self.failUnlessEqual(g.DLLs, ['GPyTest', 'GaudiAlg']) - self.failUnlessEqual(g.Go, 123) - - def test07NTupleSvc(self) : - ntsvc = g.ntuplesvc() - self.failUnless(ntsvc) - ntsvc.defineOutput({'L1':'file1.root','L2':'file2.root'}) - self.failUnless(ntsvc.initialize().isSuccess()) - - def test08Buffer(self) : - gbl = GaudiPython.gbl - vi = gbl.std.vector(int)() - vi.push_back(10) - vi.push_back(20) - vi.push_back(30) - vi.push_back(40) - ai = getattr(gbl.GaudiPython.Helper, 'toAddress<int>')(vi) - self.failUnless(ai) - bi = gbl.GaudiPython.Helper.toIntArray(ai,vi.size()) - self.failUnless(bi) - self.failUnlessEqual(len(bi),len(vi)) - for i in range(len(vi)) : self.failUnlessEqual(bi[i],vi[i]) - #double - vd = gbl.std.vector('double')() - vd.push_back(10.) - vd.push_back(20.) - vd.push_back(30.) - vd.push_back(40.) - ad = getattr(gbl.GaudiPython.Helper, 'toAddress<double>')(vd) - self.failUnless(ad) - bd = gbl.GaudiPython.Helper.toDoubleArray(ad,vd.size()) - self.failUnless(bd) - self.failUnlessEqual(len(bd),len(vd)) - for i in range(len(vd)) : self.failUnlessEqual(bd[i],vd[i]) - - def test09GlobalTools(self) : - svc = g.toolsvc() - self.failUnless(svc) - t1 = svc.create('SequencerTimerTool','tool1') - self.failUnless(t1) - self.failUnlessEqual( t1.Normalised, 0) - self.failUnlessEqual( t1.name(), 'ToolSvc.tool1') - self.failUnlessEqual( t1.type(), 'SequencerTimerTool') - t2 = g.tool('ToolSvc.tool1') - self.failUnless(t2) - self.failUnlessEqual( t2.Normalised, 0) - self.failUnlessEqual( t2.name(), 'ToolSvc.tool1') - self.failUnlessEqual( t2.type(), 'SequencerTimerTool') - - def test10LocalTools(self) : - g.DLLs = ['GaudiAlg'] - g.topAlg = ['Prescaler'] - p = g.algorithm('Prescaler') - self.failUnless(p._ialg) - svc = g.toolsvc() - t1 = svc.create('SequencerTimerTool','tool1',p._ialg) - self.failUnless(t1) - self.failUnlessEqual( t1.Normalised, False) - self.failUnlessEqual( t1.name(), 'Prescaler.tool1') - self.failUnlessEqual( t1.type(), 'SequencerTimerTool') - t1.Normalised = False - t2 = g.tool('Prescaler.tool1') - self.failUnless(t2) - self.failUnlessEqual( t2.Normalised, False) - self.failUnlessEqual( t2.name(), 'Prescaler.tool1') - self.failUnlessEqual( t2.type(), 'SequencerTimerTool') - t3 = svc.create('SequencerTimerTool','subtool1',t1._ip) - self.failUnless(t3) - self.failUnlessEqual( t3.Normalised, False) - self.failUnlessEqual( t3.name(), 'Prescaler.tool1.subtool1') - self.failUnlessEqual( t3.type(), 'SequencerTimerTool') - t4 = g.tool('Prescaler.tool1.subtool1') - self.failUnless(t4) - self.failUnlessEqual( t4.Normalised, False) - self.failUnlessEqual( t4.name(), 'Prescaler.tool1.subtool1') - self.failUnlessEqual( t4.type(), 'SequencerTimerTool') - - def test11ostreamcallback(self) : - def test11do_msg(s) : self.got_it = True - self.got_it = False - buf = GaudiPython.CallbackStreamBuf(test11do_msg) - ostream = GaudiPython.gbl.basic_ostream('char','char_traits<char>')(buf) - msgSvc = g.service('MessageSvc', GaudiPython.gbl.IMessageSvc) - original = msgSvc.defaultStream() - msgSvc.setDefaultStream(ostream) - msgSvc.reportMessage('TEST',7,'This is a test message') - msgSvc.setDefaultStream(original) - self.failUnless(self.got_it) - - def test12pickle(self) : - import pickle - o = GaudiPython.gbl.TH1F('sss','aaa',10,0.,1.) - self.failUnlessEqual(o.GetName(), pickle.loads(pickle.dumps(o)).GetName() ) - o = GaudiPython.gbl.std.vector('double')() - o.push_back(10.) - o.push_back(20.) - self.failUnlessEqual([i for i in o], [i for i in pickle.loads(pickle.dumps(o))]) - - -suite = unittest.makeSuite(BasicTests,'test') - -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite) - g.finalize() -