Howto:How to make a package with a C++ algorithm

From Daya Bay
Jump to navigation Jump to search
Offline Documentation: [Offline Category] [FAQ] [Howto] [Reference] [Manual]


Offline Documentation
This article is part
of the Offline Documentation
Other pages...

Offline Category
FAQ
How Tos
Reference
Manual
Getting Started
Software Installation

See also...

General Help on this Wiki


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.

Same things

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:

MyPackage/src/components/

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.

cmt/requirements

Add to your package's cmt/requirements file:

include_path none
library MyPackage *.cc
apply_pattern component_library library=MyPackage

Configuration

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

Run it.

>  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++.

Related Topics

Besides the links included above, for more info see:

Offline Software Documentation: [Offline Categories] [FAQ] [Offline Howto Category]