1 |
/* |
2 |
* TreeOutputAction.cpp |
3 |
* |
4 |
* Created on: 03/nov/2009 |
5 |
* Author: Nicola Mori |
6 |
*/ |
7 |
|
8 |
#include "TreeOutputAction.h" |
9 |
|
10 |
TreeOutputAction::TreeOutputAction(const char *actionName, TString outFileName) : |
11 |
CollectionAction(actionName), _outFileName(outFileName) { |
12 |
} |
13 |
|
14 |
TreeOutputAction::~TreeOutputAction() { |
15 |
delete _outFile; |
16 |
_outFile = NULL; |
17 |
} |
18 |
|
19 |
void TreeOutputAction::Setup(PamLevel2 *events) { |
20 |
|
21 |
_outFile = new TFile(_outFileName, "RECREATE"); |
22 |
_InitBranches(events); |
23 |
|
24 |
} |
25 |
|
26 |
void TreeOutputAction::OnGood(PamLevel2 *event) { |
27 |
|
28 |
_ComputeBranches(event); |
29 |
_outFile->cd(); |
30 |
_tree->Fill(); |
31 |
|
32 |
} |
33 |
|
34 |
void TreeOutputAction::Finalize() { |
35 |
|
36 |
_outFile->cd(); |
37 |
//cout << _tree->GetEntries() << endl; |
38 |
_tree->Write(); |
39 |
|
40 |
_outFile->Close(); |
41 |
|
42 |
} |