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

Diff of /PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pam-fi, Fri May 29 10:08:45 2009 UTC revision 1.3 by pam-fi, Wed Mar 10 08:49:42 2010 UTC
# Line 10  Line 10 
10  #include "SaveEventsAction.h"  #include "SaveEventsAction.h"
11    
12  SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, TString outOptions) :  SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, TString outOptions) :
13    CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions) {    CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions), _outFileName(outFileName) {
14    
15    }
16    
17    void SaveEventsAction::Setup(PamLevel2 *events) {
18    
19    // Open output file    // Open output file
20    /* Due to the combined weirdness of PamLevel2 and ROOT, this pointer must NOT    /* Due to the combined weirdness of PamLevel2 and ROOT, this pointer must NOT
# Line 18  SaveEventsAction::SaveEventsAction(const Line 22  SaveEventsAction::SaveEventsAction(const
22     * deletion in the destructors chain. This mechanism is not completely clear     * deletion in the destructors chain. This mechanism is not completely clear
23     * but it indeed happens...     * but it indeed happens...
24     */     */
25    _outTreeFile = new TFile(outFileName, "RECREATE");  
26      _outTreeFile = new TFile(_outFileName, "RECREATE");
27    
28    if (_outTreeFile->IsZombie()) {    if (_outTreeFile->IsZombie()) {
29      cout << "Output file could not be created\n";      cout << "Output file could not be created\n";
# Line 26  SaveEventsAction::SaveEventsAction(const Line 31  SaveEventsAction::SaveEventsAction(const
31      //TODO Gestire con un'eccezione      //TODO Gestire con un'eccezione
32      return;      return;
33    }    }
 }  
34    
 void SaveEventsAction::Setup(PamLevel2 *events){  
35    _events = events;    _events = events;
   _events->CreateCloneTrees(_outTreeFile);  
36    if (_outOptions.Length() > 0)    if (_outOptions.Length() > 0)
37      _events->SetWhichTrees(_outOptions);      _events->SetWhichTrees(_outOptions);
38      _events->CreateCloneTrees(_outTreeFile);
39  }  }
40    
41  void SaveEventsAction::OnGood(PamLevel2 *event){  void SaveEventsAction::OnGood(PamLevel2 *event) {
42    // Fill the tree    // Fill the tree
43    event->FillCloneTrees();    event->FillCloneTrees();
44  }  }
45    
46  void SaveEventsAction::Finalize(){  void SaveEventsAction::Finalize() {
47    _outTreeFile->cd();    _outTreeFile->cd();
48    _events->WriteCloneTrees();    _events->WriteCloneTrees();
49    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.23