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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Fri Nov 13 16:37:12 2009 UTC (15 years ago) by pam-fi
Branch: MAIN
File MIME type: text/plain
Added to repository.

1 pam-fi 1.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.
22     */
23    
24     class TreeOutputAction: public CollectionAction {
25     public:
26    
27     /*! @brief Constructor.
28     *
29     * @param actionName The action's name.
30     * @param outFileName The name of the output file (with extension).
31     */
32     TreeOutputAction(const char *actionName, TString outFileName);
33    
34     /*! @brief Destructor.
35     *
36     * Note that this destructor won't call delete
37     */
38     ~TreeOutputAction();
39    
40     /*! @brief The pre-selection tasks.
41     *
42     * This routine opens the ROOT output file and calls the #_InitBranches() method.
43     */
44     void Setup(PamLevel2 *events);
45    
46     /*! @brief Routine for selected events.
47     *
48     * This will call #_ComputeBranches to compute the variables and then will call
49     * Fill() for the tree.
50     *
51     * @param event The selected event.
52     */
53     void OnGood(PamLevel2 *event);
54    
55    
56     /*! @brief The finalization routine.
57     *
58     * This method writes the tree on the file.
59     */
60     void Finalize();
61    
62     protected:
63     /*! @brief The tree object which will be saved in the file.
64     *
65     * The derived classes will have to handle the instantiation and the creation of
66     * the branches of this tree, as well as filling its buffer variables and deleting it.
67     * TreeOutputAction takes care of filling it with the buffers' values for each event and
68     * writing it on disk.
69     */
70     TTree *_tree;
71    
72     /*! @brief The branch-initialization routine.
73     *
74     * Concrete implementations of this method will have to set the branches to save in
75     * the file. The tree object which has to be branched is #_tree. If one wants to
76     * branch his own structure, one possibility is to define it in the child class' header.
77     */
78     virtual void _InitBranches(PamLevel2 *event) = 0;
79    
80     /*! @brief The branch computation routine.
81     *
82     * Here the buffers for the branches created in #_InitBranches() can be filled using the
83     * event's data. Remember to NOT call _tree.Fill() here: this operation is automatically
84     * handled by #OnGood(), so you have only to care about filling the buffers.
85     * Implementation is demanded to concrete children classes.
86     */
87     virtual void _ComputeBranches(PamLevel2 *event) = 0;
88    
89     private:
90    
91     TFile *_outFile;
92     TString _outFileName;
93    
94     };
95    
96     #endif /* TREEOUTPUTACTION_H_ */

  ViewVC Help
Powered by ViewVC 1.1.23