How to write an apparatus class for the C++ analyzer
Ole Hansen
Rev. 1.0, 14 June 2003
This document refers to version 0.55 or higher of the C++ analyzer.
An apparatus is a collection of detectors that work together and should
be analyzed as a group.
In the standard analyzer, detectors cannot be analyzed
individually, they must be part of an apparatus.
Writing a class for a new apparatus can be relatively simple.
If you want to create a completely new apparatus (i.e. one
that does not resemble an existing one at all, like a new type of
spectrometer), your new apparatus class should inherit from
- THaApparatus if
you want to create a generic apparatus such as a collection
of beamline or target instrumentation; or
- THaSpectrometer
if you want to create a new spectrometer that is capable of
particle tracking and, possibly, PID.
In the first case (generic apparatus), you must
- write a Reconstruct() method. This can be a dummy if you only want to
decode the detectors. This function is expected to do any
processing that combines results from different detectors within
the apparatus, for instance using tracks found by wire chambers to
locate clusters in a shower counter;
- create the detector objects of the apparatus in the constructor.
Since THaApparatus::Reconstruct() is a pure virtual function, you will not
be able to instantiate any objects of your class unless
this method is implemented.
In the second case (spectrometer), you can take advantage of the infrastructure
already implemented by the
THaSpectrometer base class.
In particular, THaSpectrometer provides a fairly generic Reconstruct()
method (see standard analyzer).
At the minimum, your spectrometer apparatus class must
- provide a TrackCalc() method. TrackCalc() is called by
THaSpectrometer::Reconstruct() to compute particle track
properties such as momentum and beta right after the FineProcess()
stage of the analysis. This can be a dummy function if no such
calculations are necessary;
- provide a FindVertices() method. FindVertices() is called by
THaSpectrometer::Reconstruct() at the end of processing
to reconstruct tracks to the target. This can be a dummy
function if no such reconstruction is necessary;
- create the detector objects of the apparatus in the constructor.
Since THaSpectrometer::TrackCalc() and
THaSpectrometer::FindVertices() are pure virtual functions, you
will not be able to instantiate any objects of your class unless
these methods are implemented.
Additionally, you can override any of the other virtual functions of
THaApparatus and
THaSpectrometer. Some
obvious candidates are
- Reconstruct() to modify tracking-related computations;
- CalcPID() to modify the way PID is handled.
If you want to modify an existing apparatus,
for example to change an algorithm or the default detector configuration,
the best approach probably is to write a new class that inherits
from the existing apparatus class. This is especially useful in the
case of the standard HRS spectrometers in Hall A.
Note that if you simply want to add a detector to an existing
apparatus, you can do so using the AddDetector() method (see
adding and removing detectors).
Last modified: Sat Jun 14 13:16:24 EDT 2003
Maintained by Ole Hansen