| 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 |
_outFile->Close(); |
| 16 |
delete _outFile; |
| 17 |
_outFile = NULL; |
| 18 |
} |
| 19 |
|
| 20 |
void TreeOutputAction::Setup(PamLevel2 *events) { |
| 21 |
|
| 22 |
_outFile = new TFile(_outFileName, "RECREATE"); |
| 23 |
_InitBranches(events); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
void TreeOutputAction::OnGood(PamLevel2 *event) { |
| 28 |
|
| 29 |
_ComputeBranches(event); |
| 30 |
_outFile->cd(); |
| 31 |
_tree->Fill(); |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
void TreeOutputAction::Finalize() { |
| 36 |
|
| 37 |
_outFile->cd(); |
| 38 |
_tree->Write(); |
| 39 |
|
| 40 |
} |