CERN Accelerating science

This website is no longer maintained. Its content may be obsolete. Please visit http://home.cern/ for current CERN information.

Creating and plotting histograms in logical tree mapped to an HBOOK file.

Description

Two 1-dimensional histograms are created, filled, plotted and saved in an HBook file.

C++ program

Click to retrieve the C++ source code of the example.

Note that whenever an object returns a pointer of type T the latter is immediatelly assigned either to an auto pointer of the standard library std::auto_ptr<T> in case the ownership of the pointed object is passed to the user or or a reference T& if the parent object retains the ownership.
For simplicity reasons, no pointer checking is done.

You can build the application typing :
g++ -o b4.exe b4.cpp -I$AIDA_DIR -L$ANAPHE_REL_DIR/lib \
-lAnaphe_AIDA_AnalysisFactory_native -lAnaphe_AIDA_Annotation_native \
-lAnaphe_AIDA_Histogram_native -lAnaphe_AIDA_Tree_native -lAnaphe_AIDA_HBookStore \
-lAnaphe_AIDA_Plotter_Grace -lGracePlotter -lg2c

or even simpler by typing :
g++ -o b4.exe b4.cpp `aida-config --includes --libs`

Lizard session

Click to retrieve the corresponing python script to be executed by Lizard, in order to achieve the same result.
During the Lizard startup the following objects are instantiated:

For simplicity reasons, no pointer checking is done.

Program flow

  1. The master analysis factory is created.
  2. A factory for the creation of plotters is created using the analysis factory.
  3. The plotter factory is used to create a plotter.
  4. A factory for the creation of logical trees is created using the analysis factory.
  5. The tree factory is used to create a logical tree mapped to a new HBook file.
  6. The analysis factory is used to create a histogram factory in association with the logical tree.
  7. Two 1-dimensional histograms are created using the histogram factory.
  8. The histograms are filled with random data.
  9. The plotter plots the histograms (one at a time waiting) in its current active region with the option of showing the annotation items as well.
  10. The histograms are flushed to the file by an explicit commit call to the tree, before closing it.