/[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.2 by pam-fi, Tue Sep 22 13:01:41 2009 UTC revision 1.3 by pam-fi, Wed Mar 10 08:49:42 2010 UTC
# Line 9  Line 9 
9    
10  #include "SaveEventsAction.h"  #include "SaveEventsAction.h"
11    
12  SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName,  SaveEventsAction::SaveEventsAction(const char *actionName, TString outFileName, TString outOptions) :
13                  TString outOptions) :    CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions), _outFileName(outFileName) {
         CollectionAction(actionName), _outTreeFile(NULL), _events(NULL),  
                         _outOptions(outOptions), _outFileName(outFileName) {  
14    
15  }  }
16    
17  void SaveEventsAction::Setup(PamLevel2 *events) {  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
21           * be explicitly deleted, nor the file closed. This would generate a double     * be explicitly deleted, nor the file closed. This would generate a double
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    
26          _outTreeFile = new TFile(_outFileName, "RECREATE");    _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";
30                  _outTreeFile->Delete();      _outTreeFile->Delete();
31                  //TODO Gestire con un'eccezione      //TODO Gestire con un'eccezione
32                  return;      return;
33          }    }
34    
35          _events = events;    _events = events;
36          _events->CreateCloneTrees(_outTreeFile);    if (_outOptions.Length() > 0)
37          if (_outOptions.Length() > 0)      _events->SetWhichTrees(_outOptions);
38                  _events->SetWhichTrees(_outOptions);    _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    
50  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23