/[PAMELA software]/PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp
ViewVC logotype

Contents of /PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri May 29 10:08:45 2009 UTC (15 years, 6 months ago) by pam-fi
Branch: MAIN
Added to repository

1 /*
2 * SaveEventsAction.cpp
3 *
4 * Created on: 16-mag-2009
5 * Author: Nicola Mori
6 */
7
8 /*! @file SaveEventsAction.cpp The SaveEventsAction class implementation file */
9
10 #include "SaveEventsAction.h"
11
12 SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, TString outOptions) :
13 CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions) {
14
15 // Open output file
16 /* Due to the combined weirdness of PamLevel2 and ROOT, this pointer must NOT
17 * be explicitly deleted, nor the file closed. This would generate a double
18 * deletion in the destructors chain. This mechanism is not completely clear
19 * but it indeed happens...
20 */
21 _outTreeFile = new TFile(outFileName, "RECREATE");
22
23 if (_outTreeFile->IsZombie()) {
24 cout << "Output file could not be created\n";
25 _outTreeFile->Delete();
26 //TODO Gestire con un'eccezione
27 return;
28 }
29 }
30
31 void SaveEventsAction::Setup(PamLevel2 *events){
32 _events = events;
33 _events->CreateCloneTrees(_outTreeFile);
34 if (_outOptions.Length() > 0)
35 _events->SetWhichTrees(_outOptions);
36 }
37
38 void SaveEventsAction::OnGood(PamLevel2 *event){
39 // Fill the tree
40 event->FillCloneTrees();
41 }
42
43 void SaveEventsAction::Finalize(){
44 _outTreeFile->cd();
45 _events->WriteCloneTrees();
46
47 }

  ViewVC Help
Powered by ViewVC 1.1.23