Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
A01AnalysisManager.cc
Go to the documentation of this file.
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 //
28 
29 #ifdef G4ANALYSIS_USE
30 
31 #include <fstream>
32 
33 #include "G4ios.hh"
34 #include "G4Run.hh"
35 #include "G4Event.hh"
36 #include "G4Track.hh"
37 #include "G4VVisManager.hh"
38 #include "G4TrajectoryContainer.hh"
39 #include "G4Trajectory.hh"
40 
41 #include <AIDA/AIDA.h>
42 
43 #include "A01AnalysisManager.hh"
44 
45 A01AnalysisManager* A01AnalysisManager::fInstance = 0;
46 
47 A01AnalysisManager::A01AnalysisManager()
48 :fAnalysisFactory(0), fFactory(0), tFactory(0), fPlotter(0)
49 {
50  // Hooking an AIDA compliant analysis system.
51  fAnalysisFactory = AIDA_createAnalysisFactory();
52  if(fAnalysisFactory)
53  {
54  ITreeFactory* treeFactory = fAnalysisFactory->createTreeFactory();
55  fTree = treeFactory->create("A01.aida","xml",false,true,"compress=yes");
56  fFactory = fAnalysisFactory->createHistogramFactory(*fTree);
57  tFactory = fAnalysisFactory->createTupleFactory(*fTree);
58  IPlotterFactory* pf = fAnalysisFactory->createPlotterFactory(0,0);
59  if (pf) {
60  fPlotter = pf->create("Plotter");
61  delete pf;
62  }
63  delete treeFactory; // Will not delete the ITree.
64  }
65 }
66 
68 {
69  if (fAnalysisFactory)
70  {
71  if (!fTree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl;
72  delete fTree;
73  delete tFactory;
74  delete fFactory;
75  delete fPlotter;
76  G4cout << "Warning: In case of working with JAS-AIDA, Geant4 will NOT exit unless you close the JAS-AIDA window." << G4endl;
77  delete fAnalysisFactory;
78  }
79 }
80 IHistogramFactory* A01AnalysisManager::getHistogramFactory()
81 {
82  return fFactory;
83 }
85 {
86  return tFactory;
87 }
89 {
90  return fPlotter;
91 }
92 
94 {
95  if (fInstance == 0) fInstance = new A01AnalysisManager();
96  return fInstance;
97 }
98 
100 {
101  if (fInstance != 0)
102  {
103  delete fInstance;
104  fInstance = 0;
105  }
106 }
107 
108 #endif // G4ANALYSIS_USE
109