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

Annotation of /PamCut/CollectionActions/SaveEventsAction/SaveEventsAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3.2.2 - (hide annotations) (download)
Thu Jun 24 17:20:19 2010 UTC (14 years, 5 months ago) by pam-fi
Branch: V8
CVS Tags: MergedToHEAD_1, nuclei_reproc
Changes since 1.3.2.1: +11 -11 lines
Compilation warning fixed.

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

  ViewVC Help
Powered by ViewVC 1.1.23