1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // ********************************************************************** |
---|
28 | // * * |
---|
29 | // * GEANT 4 tutorial 1 * |
---|
30 | // * * |
---|
31 | // * MODULE: A01AnalysisManager.cc * |
---|
32 | // * ------- * |
---|
33 | // * * |
---|
34 | // * Version: 0.1 * |
---|
35 | // * Date: January 28 2002 * |
---|
36 | // * Author: T.Johnson * |
---|
37 | // * Organisation: SLAC * |
---|
38 | // * * |
---|
39 | // ********************************************************************** |
---|
40 | // |
---|
41 | // CHANGE HISTORY |
---|
42 | // -------------- |
---|
43 | // |
---|
44 | // Nov 4 2002 -- Upgrade to AIDA 3.0 |
---|
45 | // ********************************************************************** |
---|
46 | #ifdef G4ANALYSIS_USE |
---|
47 | |
---|
48 | #include <fstream> |
---|
49 | |
---|
50 | #include "G4ios.hh" |
---|
51 | #include "G4Run.hh" |
---|
52 | #include "G4Event.hh" |
---|
53 | #include "G4Track.hh" |
---|
54 | #include "G4VVisManager.hh" |
---|
55 | #include "G4TrajectoryContainer.hh" |
---|
56 | #include "G4Trajectory.hh" |
---|
57 | |
---|
58 | #include <AIDA/AIDA.h> |
---|
59 | |
---|
60 | #include "A01AnalysisManager.hh" |
---|
61 | |
---|
62 | A01AnalysisManager* A01AnalysisManager::instance = 0; |
---|
63 | |
---|
64 | A01AnalysisManager::A01AnalysisManager() |
---|
65 | :analysisFactory(0), hFactory(0), tFactory(0), plotter(0) |
---|
66 | { |
---|
67 | // Hooking an AIDA compliant analysis system. |
---|
68 | analysisFactory = AIDA_createAnalysisFactory(); |
---|
69 | if(analysisFactory) |
---|
70 | { |
---|
71 | ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); |
---|
72 | tree = treeFactory->create("A01.aida","xml",false,true,"compress=yes"); |
---|
73 | hFactory = analysisFactory->createHistogramFactory(*tree); |
---|
74 | tFactory = analysisFactory->createTupleFactory(*tree); |
---|
75 | IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0); |
---|
76 | if (pf) { |
---|
77 | plotter = pf->create("Plotter"); |
---|
78 | delete pf; |
---|
79 | } |
---|
80 | delete treeFactory; // Will not delete the ITree. |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | A01AnalysisManager::~A01AnalysisManager() |
---|
85 | { |
---|
86 | if (analysisFactory) |
---|
87 | { |
---|
88 | if (!tree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl; |
---|
89 | delete tree; |
---|
90 | delete tFactory; |
---|
91 | delete hFactory; |
---|
92 | delete plotter; |
---|
93 | G4cout << "Warning: In case of working with JAS-AIDA, Geant4 will NOT exit unless you close the JAS-AIDA window." << G4endl; |
---|
94 | delete analysisFactory; |
---|
95 | } |
---|
96 | } |
---|
97 | IHistogramFactory* A01AnalysisManager::getHistogramFactory() |
---|
98 | { |
---|
99 | return hFactory; |
---|
100 | } |
---|
101 | ITupleFactory* A01AnalysisManager::getTupleFactory() |
---|
102 | { |
---|
103 | return tFactory; |
---|
104 | } |
---|
105 | IPlotter* A01AnalysisManager::getPlotter() |
---|
106 | { |
---|
107 | return plotter; |
---|
108 | } |
---|
109 | |
---|
110 | A01AnalysisManager* A01AnalysisManager::getInstance() |
---|
111 | { |
---|
112 | if (instance == 0) instance = new A01AnalysisManager(); |
---|
113 | return instance; |
---|
114 | } |
---|
115 | |
---|
116 | void A01AnalysisManager::dispose() |
---|
117 | { |
---|
118 | if (instance != 0) |
---|
119 | { |
---|
120 | delete instance; |
---|
121 | instance = 0; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | #endif // G4ANALYSIS_USE |
---|
126 | |
---|