Howto:How to make a package with a C++ algorithm
|Offline Documentation: [Offline Category] [FAQ] [Howto] [Reference] [Manual]|
|This article is part |
of the Offline Documentation
This is an extension to Howto:How_to_make_an_analysis_package?. It shows you the differences you need to do to make a C++ algorithm as compared to a Python one.
Set up your project and package in the same way. You can add your C++ algorithm to an existing package if it is closely enough related.
C++ code locations
Put your algorithm code, both .cc and .h files, under:
It is unlikely but you may also want to write a library for other packages to use. For details on the distinction between component and linker libraries see this topic.
Add to your package's cmt/requirements file:
include_path none library MyPackage *.cc apply_pattern component_library library=MyPackage
User configuration of your algorithm proceeds in the usual way.
A quick start: Use a template
Get the template and tool into one of your CMT project area. You can use "cmt create_project my_proj" to create one. Note the last line help you to rename every thing related to your favorite name.
> svn co $DYBSVN/people/wangzhe/Start > svn export $DYBSVN/people/wangzhe/ProjRename > ProjRename Start MyNewAlg
> cd MyNewAlg/cmt > cmt config; source setup.csh; make; source setup.csh > nuwa.py -n 10 -m MyNewAlg.run
“Start” includes all basic things to run in nuwa
Start/cmt/requirements Start/cmt/version.cmt Start/src/Start.cc Start/src/Start_entries.cc Start/src/Start.h Start/src/Start_load.cc Start/python/Start/__init__.py Start/python/Start/run.py Start/aileron/run.py@ -> ../python/Start/run.py
ProjRename: It will go into all possible corners of algorithm “Start”, help you replace the name, even for the code in source file, even capital “START”.
> ProjRename Start MyNewAlg
This will change Start to MyNewAlg and START to MYNEWALG
> ProjRename MyNewAlg Water
MyNewAlg to Water and MYNEWALG to WATER. Remember not to rename it to some words which will confuse c++.
Besides the links included above, for more info see:
- ConfigurableExample gives an example of a C++-algorithm based package.
- CMT projects and packages
- How to write a "tool" class this is a handy way to break large algorithms into reusable "chunks".
- Passing command line options to your algorithm
- In the manual: algorithms described and some more info on writing algorithms.
|Offline Software Documentation: [Offline Categories] [FAQ] [Offline Howto Category]|