source: trunk/examples/advanced/air_shower/src/UltraAnalysisManager.cc @ 1303

Last change on this file since 1303 was 807, checked in by garnier, 16 years ago

update

File size: 4.1 KB
Line 
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 - ULTRA experiment example
30// --------------------------------------------------------------
31//
32// Code developed by:
33// B. Tome, M.C. Espirito-Santo, A. Trindade, P. Rodrigues
34//
35//    ****************************************************
36//    *      UltraAnalysisManager.cc
37//    ****************************************************
38//
39//    Class used for analysis procedures if the environment variable
40//    G4ANALYSIS_USE is set. AIDA is supported.
41//    Based on BrachyAnalysisManager class developed by S.Guatelli.
42//
43#ifdef G4ANALYSIS_USE
44#include <stdlib.h>
45#include <fstream>
46#include "UltraAnalysisManager.hh"
47#include "G4ios.hh"
48
49#include "AIDA/IHistogram1D.h"
50#include "AIDA/IHistogram2D.h"
51
52#include "AIDA/IManagedObject.h"
53#include "AIDA/IAnalysisFactory.h"
54#include "AIDA/IHistogramFactory.h"
55#include "AIDA/ITupleFactory.h"
56#include "AIDA/ITreeFactory.h"
57#include "AIDA/ITree.h"
58#include "AIDA/ITuple.h"
59
60UltraAnalysisManager* UltraAnalysisManager::instance = 0;
61
62UltraAnalysisManager::UltraAnalysisManager() : 
63  aFact(0), theTree(0), histFact(0), h1(0),h2(0)
64 
65{
66  //build up  the  factories
67  aFact = AIDA_createAnalysisFactory();
68
69  AIDA::ITreeFactory* treeFact = aFact->createTreeFactory();
70  //parameters for the TreeFactory
71
72  // "hbook" for HBOOK histograms
73  // "xml" for AIDA histograms
74  // "root" for ROOT histograms
75
76  std::string fileName = "ultra.aida";
77  theTree = treeFact->create(fileName,"xml",false, true);
78
79  delete treeFact;
80 
81  histFact = aFact->createHistogramFactory( *theTree );
82
83}
84
85UltraAnalysisManager::~UltraAnalysisManager() 
86{ 
87
88  delete histFact;
89  histFact = 0;
90
91  delete theTree;
92  histFact = 0;
93
94  delete aFact;
95  aFact = 0;
96}
97
98UltraAnalysisManager* UltraAnalysisManager::getInstance()
99{
100  if (instance == 0) instance = new UltraAnalysisManager;
101  return instance;
102}
103
104void UltraAnalysisManager::book() 
105{
106
107  h1 = histFact->createHistogram1D("10","Optical photons energy (eV)", //histoID,histo name
108                                  500,0.,5.); //bins' number, xmin, xmax
109 
110  h2 = histFact->createHistogram1D("20","Number of Detected Photons", 
111                                  10,0.,10.); //bins' number, xmin, xmax
112}
113 
114
115void UltraAnalysisManager::FillHistogram(G4int i, G4double f){
116
117  if(i == 1) h1->fill(f);
118  if(i == 2) h2->fill(f);
119
120}
121
122void UltraAnalysisManager::finish() 
123{ 
124  // write all histograms to file ...
125  theTree->commit();
126
127  // close (will again commit) ...
128  theTree->close();
129}
130
131
132#endif
133
134
135
136
137
138
139
Note: See TracBrowser for help on using the repository browser.