/[PAMELA software]/PamCut/CollectionActions/TreeOutputActions/TreeOutputAction/TreeOutputAction.h
ViewVC logotype

Contents of /PamCut/CollectionActions/TreeOutputActions/TreeOutputAction/TreeOutputAction.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Mar 23 17:27:43 2010 UTC (14 years, 8 months ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1, V9, HEAD
Branch point for: V8
Changes since 1.1: +9 -2 lines
File MIME type: text/plain
Error occurred while calculating annotation data.
Documentation updated.

1 /*
2 * TreeOutputAction.h
3 *
4 * Created on: 03/nov/2009
5 * Author: Nicola Mori
6 */
7
8 /*! @file TreeOutputAction.h The TreeOutputAction class declaration file. */
9
10 #ifndef TREEOUTPUTACTION_H_
11 #define TREEOUTPUTACTION_H_
12
13 #include "../../CollectionAction/CollectionAction.h"
14
15 /*! @brief An abstract class which provides a template for a custom ROOT tree output action.
16 *
17 * This class defines a common template for a custom output action in ROOT tree format.
18 * It takes care of opening the file, filling the tree and writing it on a file. Descendants
19 * have to implement the pure virtual members #_InitBranches() and #_ComputeBranches, which
20 * takes care, for the current event, of creating the branches and filling the structures
21 * linked to the branches. #_InitBranches() will be automatically called at the beginning of
22 * the analysis, while #_ComputeBranches will be invoked for each event.
23 */
24
25 class TreeOutputAction: public CollectionAction {
26 public:
27
28 /*! @brief Constructor.
29 *
30 * @param actionName The action's name.
31 * @param outFileName The name of the output file (with extension).
32 */
33 TreeOutputAction(const char *actionName, TString outFileName);
34
35 /*! @brief Destructor.
36 *
37 * Note that this destructor won't call delete
38 */
39 ~TreeOutputAction();
40
41 /*! @brief The pre-selection tasks.
42 *
43 * This routine opens the ROOT output file and calls the #_InitBranches() method.
44 *
45 * @param events Pointer to PamLevel2 object which contains the events to analize.
46 */
47 void Setup(PamLevel2 *events);
48
49 /*! @brief Routine for selected events.
50 *
51 * This will call #_ComputeBranches to compute the variables and then will call
52 * Fill() for the tree.
53 *
54 * @param event The selected event.
55 */
56 void OnGood(PamLevel2 *event);
57
58
59 /*! @brief The finalization routine.
60 *
61 * This method writes the tree on the file.
62 */
63 void Finalize();
64
65 protected:
66 /*! @brief The tree object which will be saved in the file.
67 *
68 * The derived classes will have to handle the instantiation and the creation of
69 * the branches of this tree, as well as filling its buffer variables and deleting it.
70 * TreeOutputAction takes care of filling it with the buffers' values for each event and
71 * writing it on disk.
72 */
73 TTree *_tree;
74
75 /*! @brief The branch-initialization routine.
76 *
77 * Concrete implementations of this method will have to set the branches to save in
78 * the file. The tree object which has to be branched is #_tree. If one wants to
79 * branch his own structure, one possibility is to define it in the child class' header.
80 *
81 * @param events Pointer to PamLevel2 object which contains the events to analize.
82 */
83 virtual void _InitBranches(PamLevel2 *events) = 0;
84
85 /*! @brief The branch computation routine.
86 *
87 * Here the buffers for the branches created in #_InitBranches() can be filled using the
88 * event's data. Remember to NOT call _tree.Fill() here: this operation is automatically
89 * handled by #OnGood(), so you have only to care about filling the buffers.
90 * Implementation is demanded to concrete children classes.
91 *
92 * @param event The selected event.
93 */
94 virtual void _ComputeBranches(PamLevel2 *event) = 0;
95
96 private:
97
98 TFile *_outFile;
99 TString _outFileName;
100
101 };
102
103 #endif /* TREEOUTPUTACTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23