[807] | 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 | |
---|
[893] | 62 | //OSC:begin |
---|
| 63 | AIDA::IAnalysisFactory* A01AnalysisManager::m_AIDA = 0; |
---|
| 64 | void A01AnalysisManager::setAIDA(AIDA::IAnalysisFactory* a_AIDA) {m_AIDA = a_AIDA;} |
---|
| 65 | AIDA::IAnalysisFactory* A01AnalysisManager::getAIDA(){return m_AIDA;} |
---|
| 66 | //OSC:end |
---|
| 67 | |
---|
| 68 | |
---|
[807] | 69 | A01AnalysisManager* A01AnalysisManager::instance = 0; |
---|
| 70 | |
---|
| 71 | A01AnalysisManager::A01AnalysisManager() |
---|
| 72 | :analysisFactory(0), hFactory(0), tFactory(0), plotter(0) |
---|
| 73 | { |
---|
| 74 | // Hooking an AIDA compliant analysis system. |
---|
[893] | 75 | //OSC:begin |
---|
| 76 | analysisFactory = getAIDA(); |
---|
| 77 | //OSC:end |
---|
[807] | 78 | if(analysisFactory) |
---|
| 79 | { |
---|
| 80 | ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); |
---|
| 81 | tree = treeFactory->create("A01.aida","xml",false,true,"compress=yes"); |
---|
| 82 | hFactory = analysisFactory->createHistogramFactory(*tree); |
---|
| 83 | tFactory = analysisFactory->createTupleFactory(*tree); |
---|
| 84 | IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0); |
---|
| 85 | if (pf) { |
---|
| 86 | plotter = pf->create("Plotter"); |
---|
| 87 | delete pf; |
---|
| 88 | } |
---|
| 89 | delete treeFactory; // Will not delete the ITree. |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | A01AnalysisManager::~A01AnalysisManager() |
---|
| 94 | { |
---|
| 95 | if (analysisFactory) |
---|
| 96 | { |
---|
| 97 | if (!tree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl; |
---|
| 98 | delete tree; |
---|
| 99 | delete tFactory; |
---|
| 100 | delete hFactory; |
---|
| 101 | delete plotter; |
---|
| 102 | G4cout << "Warning: In case of working with JAS-AIDA, Geant4 will NOT exit unless you close the JAS-AIDA window." << G4endl; |
---|
[893] | 103 | //OSC:begin |
---|
| 104 | // AIDA analysis factory is managed by |
---|
| 105 | // G4Lab::UIOnX, it can't be delete here. |
---|
| 106 | // delete analysisFactory; |
---|
| 107 | //OSC:end |
---|
[807] | 108 | } |
---|
| 109 | } |
---|
| 110 | IHistogramFactory* A01AnalysisManager::getHistogramFactory() |
---|
| 111 | { |
---|
| 112 | return hFactory; |
---|
| 113 | } |
---|
| 114 | ITupleFactory* A01AnalysisManager::getTupleFactory() |
---|
| 115 | { |
---|
| 116 | return tFactory; |
---|
| 117 | } |
---|
| 118 | IPlotter* A01AnalysisManager::getPlotter() |
---|
| 119 | { |
---|
| 120 | return plotter; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | A01AnalysisManager* A01AnalysisManager::getInstance() |
---|
| 124 | { |
---|
| 125 | if (instance == 0) instance = new A01AnalysisManager(); |
---|
| 126 | return instance; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | void A01AnalysisManager::dispose() |
---|
| 130 | { |
---|
| 131 | if (instance != 0) |
---|
| 132 | { |
---|
| 133 | delete instance; |
---|
| 134 | instance = 0; |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | #endif // G4ANALYSIS_USE |
---|
| 139 | |
---|