/[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.2.1 by pam-fi, Thu Jun 3 14:30:48 2010 UTC
# Line 9  Line 9 
9    
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) {      Long64_t maxFileSize) :
14      CollectionAction(actionName), _outTreeFile(NULL), _events(NULL), _outOptions(outOptions), _outFileName(outFileName),
15          _maxFileSize(maxFileSize) {
16    
17    }
18    
19    void SaveEventsAction::Setup(PamLevel2 *events) {
20    
21    // Open output file    // Open output file
22    /* 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 24  SaveEventsAction::SaveEventsAction(const
24     * deletion in the destructors chain. This mechanism is not completely clear     * deletion in the destructors chain. This mechanism is not completely clear
25     * but it indeed happens...     * but it indeed happens...
26     */     */
27    _outTreeFile = new TFile(outFileName, "RECREATE");  
28      _outTreeFile = new TFile(_outFileName, "RECREATE");
29    
30    if (_outTreeFile->IsZombie()) {    if (_outTreeFile->IsZombie()) {
31      cout << "Output file could not be created\n";      cout << "Output file could not be created\n";
# Line 26  SaveEventsAction::SaveEventsAction(const Line 33  SaveEventsAction::SaveEventsAction(const
33      //TODO Gestire con un'eccezione      //TODO Gestire con un'eccezione
34      return;      return;
35    }    }
 }  
36    
 void SaveEventsAction::Setup(PamLevel2 *events){  
37    _events = events;    _events = events;
   _events->CreateCloneTrees(_outTreeFile);  
38    if (_outOptions.Length() > 0)    if (_outOptions.Length() > 0)
39      _events->SetWhichTrees(_outOptions);      _events->SetWhichTrees(_outOptions);
40      _events->CreateCloneTrees(_outTreeFile);
41    
42      // Set the output file size
43      TTree * currTree = NULL;
44      if (currTree = _events->GetCloneTree("Run"))
45        currTree->SetMaxTreeSize(_maxFileSize);
46      currTree = NULL;
47      if (currTree = _events->GetCloneTree("SelectionList"))
48        currTree->SetMaxTreeSize(_maxFileSize);
49      currTree = NULL;
50      if (currTree = _events->GetCloneTree("Tracker"))
51        currTree->SetMaxTreeSize(_maxFileSize);
52      currTree = NULL;
53      if (currTree = _events->GetCloneTree("Calorimeter"))
54        currTree->SetMaxTreeSize(_maxFileSize);
55      currTree = NULL;
56      if (currTree = _events->GetCloneTree("ToF"))
57        currTree->SetMaxTreeSize(_maxFileSize);
58      currTree = NULL;
59      if (currTree = _events->GetCloneTree("Trigger"))
60        currTree->SetMaxTreeSize(_maxFileSize);
61      currTree = NULL;
62      if (currTree = _events->GetCloneTree("S4"))
63        currTree->SetMaxTreeSize(_maxFileSize);
64      currTree = NULL;
65      if (currTree = _events->GetCloneTree("NeutronD"))
66        currTree->SetMaxTreeSize(_maxFileSize);
67      currTree = NULL;
68      if (currTree = _events->GetCloneTree("Anticounter"))
69        currTree->SetMaxTreeSize(_maxFileSize);
70      currTree = NULL;
71      if (currTree = _events->GetCloneTree("OrbitalInfo"))
72        currTree->SetMaxTreeSize(_maxFileSize);
73      currTree = NULL;
74      if (currTree = _events->GetCloneTree("h20"))
75        currTree->SetMaxTreeSize(_maxFileSize);
76    
77  }  }
78    
79  void SaveEventsAction::OnGood(PamLevel2 *event){  void SaveEventsAction::OnGood(PamLevel2 *event) {
80    // Fill the tree    // Fill the tree
81    event->FillCloneTrees();    event->FillCloneTrees();
82  }  }
83    
84  void SaveEventsAction::Finalize(){  void SaveEventsAction::Finalize() {
85    _outTreeFile->cd();    _outTreeFile->cd();
86    _events->WriteCloneTrees();    _events->WriteCloneTrees();
87    

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

  ViewVC Help
Powered by ViewVC 1.1.23