PamCut: CollectionAction Class Reference

# CollectionAction Class Reference

An abstract class that defines the interface of a generic collection action. More...

`#include <CollectionAction.h>`

Inheritance diagram for CollectionAction:

List of all members.

## Public Member Functions
| CollectionAction (const char *actionName)
| Constructor.
virtual | ~CollectionAction ()
| Destructor.
virtual void | Setup (PamLevel2 *events)
| The initialization routine.
virtual void | OnGood (PamLevel2 *event)=0
| Routine for selected events.
virtual void | OnBad (PamLevel2 *event, int selectionResult)
| Routine for discarded events.
virtual void | Finalize ()=0
| The finalization routine.
const char * | GetName ()
| Returns the action name.
## Private Attributes
const char * | _actionName

## Detailed Description

An abstract class that defines the interface of a generic collection action.

The CollectionAction abstract class defines an interface for a generic action object which can be used to implement common actions that can be done by collections, like filling histograms or saving selected events. The structure of this class mimicks that of a standard collection: it has a Setup() and a Finalize() methods that are meant to be called at the beginning and at the end of the selection procedure, respectively. In Setup() one can prepare the analysis actions like instantiating a histogram object (this can be done also in the constructor), while in Finalize() the analysis can be closed by, eg., writing histograms on a file and closing that file. The two methods OnGood() and OnBad() have exactly the same purpose they have in a Collection: to define action to perform each time an event is selected as good or bad. The class SmartCollection is specially designed to handle CollectionAction objects: see the documentation of SmartCollection for info on how these objects are handled.

Definition at line 30 of file CollectionAction.h.

## Constructor & Destructor Documentation

CollectionAction::CollectionAction | ( | const char * | actionName | ) | `[inline]`

Constructor.

Parameters:

  | actionName | The action's name.

Definition at line 37 of file CollectionAction.h.

virtual CollectionAction::~CollectionAction | ( |  | ) | `[inline, virtual]`

Destructor.

Definition at line 41 of file CollectionAction.h.

## Member Function Documentation

virtual void CollectionAction::Finalize | ( |  | ) | `[pure virtual]`

The finalization routine.

This method is intended to be called at the end of the analysis. Its implementations contain the finalizing procedures, like writing histograms to file or printing reports. It is automatically called by SmartCollection::Finalize().

Implemented in ChargeHistosAction, EvRateS11VsCutoffHistoAction, FluxHistoAction, and SaveEventsAction.

const char* CollectionAction::GetName | ( |  | ) | `[inline]`

Returns the action name.

Definition at line 89 of file CollectionAction.h.

References _actionName.

Referenced by FluxHistoAction::Finalize().

virtual void CollectionAction::OnBad | ( | PamLevel2 * | event,
|  | int | selectionResult |
| ) |  |  | `[inline, virtual]`

Routine for discarded events.

The concrete implementations define what to do when an event is discarded. This is conceptually the same as PamCut::OnBad(). Call to this method is automatically done in SmartCollection::OnBad(). This method is not pure virtual, since many times there's nothing to do when a cut fails; this way, it's not necessary to implement it in derived classes. Current implementation is void.

Parameters:

  | event | The selected event.
  | selectionResult | The code describing the reason of cut's failure (collections will automatically pass the index of the failed cut as selectionResult).

Definition at line 78 of file CollectionAction.h.

virtual void CollectionAction::OnGood | ( | PamLevel2 * | event | ) | `[pure virtual]`

Routine for selected events.

The concrete implementations define what to do when an event is selected. This is conceptually the same as PamCut::OnGood(). Call to this method is automatically done in SmartCollection::OnGood().

Parameters:

  | event | The selected event.

Implemented in ChargeHistosAction, EvRateS11VsCutoffHistoAction, FluxHistoAction, and SaveEventsAction.

virtual void CollectionAction::Setup | ( | PamLevel2 * | events | ) | `[inline, virtual]`

The initialization routine.

In this routine the initialization procedure is to be defined. SmartCollection objects will call Setup() for each CollectionAction object they hold during SmartCollection::Setup(). This method is intended for some possible post-constructor initialization, like those who need to know the PamLevel2 object (eg., clone trees selection). This method is likely to be unnecessary most of the times, so it is implemented as a void function and it's not pure virtual.

Parameters:

  | events | The PamLevel2 events which will be analyzed by the collection hosting the action.

Reimplemented in SaveEventsAction.

Definition at line 55 of file CollectionAction.h.

## Member Data Documentation

const char* CollectionAction::_actionName`[private]`

Definition at line 94 of file CollectionAction.h.

Referenced by GetName().

The documentation for this class was generated from the following file:

- CollectionActions/CollectionAction/CollectionAction.h