--- PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp 2009/05/29 10:08:45 1.1 +++ PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp 2009/09/22 13:01:41 1.2 @@ -9,39 +9,44 @@ #include "SaveEventsAction.h" -SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, TString outOptions) : - CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions) { +SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, + TString outOptions) : + CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), + _outOptions(outOptions), _outFileName(outFileName) { - // Open output file - /* Due to the combined weirdness of PamLevel2 and ROOT, this pointer must NOT - * be explicitly deleted, nor the file closed. This would generate a double - * deletion in the destructors chain. This mechanism is not completely clear - * but it indeed happens... - */ - _outTreeFile = new TFile(outFileName, "RECREATE"); - - if (_outTreeFile->IsZombie()) { - cout << "Output file could not be created\n"; - _outTreeFile->Delete(); - //TODO Gestire con un'eccezione - return; - } } -void SaveEventsAction::Setup(PamLevel2 *events){ - _events = events; - _events->CreateCloneTrees(_outTreeFile); - if (_outOptions.Length() > 0) - _events->SetWhichTrees(_outOptions); +void SaveEventsAction::Setup(PamLevel2 *events) { + + // Open output file + /* Due to the combined weirdness of PamLevel2 and ROOT, this pointer must NOT + * be explicitly deleted, nor the file closed. This would generate a double + * deletion in the destructors chain. This mechanism is not completely clear + * but it indeed happens... + */ + + _outTreeFile = new TFile(_outFileName, "RECREATE"); + + if (_outTreeFile->IsZombie()) { + cout << "Output file could not be created\n"; + _outTreeFile->Delete(); + //TODO Gestire con un'eccezione + return; + } + + _events = events; + _events->CreateCloneTrees(_outTreeFile); + if (_outOptions.Length() > 0) + _events->SetWhichTrees(_outOptions); } -void SaveEventsAction::OnGood(PamLevel2 *event){ - // Fill the tree - event->FillCloneTrees(); +void SaveEventsAction::OnGood(PamLevel2 *event) { + // Fill the tree + event->FillCloneTrees(); } -void SaveEventsAction::Finalize(){ - _outTreeFile->cd(); - _events->WriteCloneTrees(); +void SaveEventsAction::Finalize() { + _outTreeFile->cd(); + _events->WriteCloneTrees(); }