Title: A Few Recent Updates To DANA
1A Few Recent Updates To DANA
- GlueX Software meeting
- July 26, 2005
- David Lawrence
2Shared Objects
- DANA can use shared objects for
- Event Sources
- Factories
It does this using the libdl library (dlopen,
dlsym, )
3Shared Objects
- Command line
-
- Attaching a single object
-
- hd_ana --solibhddm_shlib.a hdgeant.hddm
- Attaching all objects in a directory
-
- hd_ana --sodir/tmp/myshlibs hdgeant.hddm
- sodir can be a relative or full path
- filenames of the form lib.so will be attached
4Shared Objects
- Creating a shared object
-
- Makefile
PACKAGES ROOTDANA MODULE_NAME
hddm_shlib include (HALLD_HOME)/src/BMS/Makefile
.shlib
Makes the file libhddm_shlib.so from all files in
directory.
5Shared Objects
- Source code for shared object
include DApplication.h extern "C" extern
GetDEventSourceType_t GetDEventSourceType extern
MakeDEventSource_t MakeDEventSource extern
InitFactories_t InitFactories const char
GetDEventSourceType(void)return
"DEventSourceHDDM" DEventSource
MakeDEventSource(const char name) return new
DEventSourceHDDM(name) void
InitFactories(DEventLoop eventLoop) eventLoop-
gtAddFactory(new DFactory_DBCALHit())
6Shared Objects
- Using shared objects can be dangerous!
- The shared object mechanism in DANA is not
intended for normal use. - It could potentially provide a lot of benefit
during code development or in certain
circumstances, a more convenient path to legacy
compatibility.
7Using Multiple Threads
- Command Line
- hd_ana --nthreads4 hdgeant.hddm
- C Source
// Instantiate a DApplication object DApplication
app(narg, argv) // Run though all
events app.Run(myproc, 10)
Command line takes precedence!
8Using Multiple Threads
- Writing thread-safe code
- Dont use static or global variables
- Wrap ROOT calls in TThreadLock() and
TThreadUnLock() - Dont wrap your whole routine (or even a single
factory) with a mutex!!
9Factory Tags
- Tags can be used to distinguish two factories
which produce the same data type. - For example
vectorltconst DParticlegt particles vectorltconst
DParticlegt kaons loop-gtGet(particles) loop-gtGe
t(kaons, kaons)
10Factory Tags
- Tagging a factory
- in the factorys header file
- DFactory_Kaon.h
const char Tag(void)return kaons"
11Class Creation Scripts
located in HALLD_HOME/scripts
- mkclass - makes a class
- myclass.h
- myclass.cc
- mkfactory - makes a factory
- mydata.h
- DFactory_mydata.h
- DFactory_mydata.cc
- mkprocessor - makes an event processor
- DEventProcessor_name.h
- DEventProcessor_name.cc