Skip to content

DevelopmentGuidelines

kandrosov edited this page Apr 22, 2016 · 3 revisions

Code development guidelines

How to add file to the project (using qt-creator)

$ touch my_path/my_file

Go to qt creator and click "Run CMake" on the given project.

Simple analyzer example

// simple_analyzer.cxx
#include <boost/format.hpp>
#include "AnalysisTools/Run/include/program_main.h" // definition of wrappers for the program main and program arguments.

struct Arguments { // list of all program arguments
    REQ_ARG(std::string, input_file); // required argument "input_file"
    REQ_ARG(std::string, output_file); // required argument "output_file"
    OPT_ARG(bool, flag, false); // optional argument "flag" with the default value = false
};

class simple_analyzer { // simple analyzer definition
public:
    simple_analyzer(const Arguments& _args) : args(_args)
    {
        // Analyzer initialization (e.g. open input/output files, parse configs...)
    }
    void Run()
    {
        // analyzer code
        std::cout << boost::format("Processing input file '%1%' into output file '%2%' wiht flag = %3%.\n")
                     % args.input_file() % args.output_file() % args.flag();
    }
private:
    Arguments args;
};

PROGRAM_MAIN(simple_analyzer, Arguments) // definition of the main program function

How to run simple_analyzer:

./run.sh simple_analyzer --help
./run.sh simple_analyzer input.root output.root
./run.sh simple_analyzer input.root output.root true
./run.sh simple_analyzer --input_file=input.root --output_file=output.root --flag=true
Clone this wiki locally