Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: FCALRunAction.cc 69896 2013-05-17 09:57:59Z gcosmo $ 26 // 27 // 27 // 28 // 28 29 29 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 31 32 >> 33 //#ifndef G4ANALYSIS_USE 32 34 33 #include "FCALRunAction.hh" 35 #include "FCALRunAction.hh" 34 36 35 #include "G4Run.hh" 37 #include "G4Run.hh" >> 38 #include "G4RunManager.hh" 36 #include "G4UImanager.hh" 39 #include "G4UImanager.hh" 37 #include "G4VVisManager.hh" 40 #include "G4VVisManager.hh" 38 #include "G4AnalysisManager.hh" << 41 #include "G4ios.hh" 39 42 >> 43 #include "Randomize.hh" >> 44 #include "FCALAnalysisManager.hh" >> 45 //#include <AIDA/AIDA.h> 40 46 41 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 42 48 43 FCALRunAction::FCALRunAction() 49 FCALRunAction::FCALRunAction() 44 { 50 { 45 // Get/create analysis manager << 46 G4AnalysisManager* man = G4AnalysisManager << 47 man->SetDefaultFileType("root"); << 48 << 49 // Open an output file << 50 G4cout << "Opening output file " << man->G << 51 man->SetFileName("fcal"); << 52 man->SetFirstHistoId(1); << 53 G4cout << " done" << G4endl; << 54 << 55 // Create histogram(s) << 56 man->CreateH1("1","Number of Out Of World" << 57 man->CreateH1("2","Number of Secondaries", << 58 man->CreateH1("3","Electromagnetic Energy/ << 59 man->CreateH1("4","hadronic Energy/MeV", 1 << 60 << 61 << 62 } 51 } 63 52 64 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 65 54 66 FCALRunAction::~FCALRunAction() 55 FCALRunAction::~FCALRunAction() 67 { 56 { >> 57 >> 58 // cleanHisto(); >> 59 68 } 60 } 69 61 >> 62 >> 63 //void FCALRunAction::bookHisto(){ >> 64 // >> 65 // AIDA::IAnalysisFactory* af = AIDA_createAnalysisFactory(); >> 66 // >> 67 // // Creating the tree factory >> 68 // AIDA::ITreeFactory* tf = af->createTreeFactory(); >> 69 // >> 70 // // Creating a tree mapped to an hbook file. >> 71 // tree = tf->create("fcal.paw", "hbook", false, true); >> 72 // >> 73 // // Creating a histogram factory, whose histograms will be handled by the tree >> 74 // AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree); >> 75 // >> 76 // // Creating a ntuple factory. >> 77 // >> 78 // AIDA::ITupleFactory* nf = af->createTupleFactory(*tree); >> 79 // >> 80 // // Creating ntuples >> 81 // >> 82 // ntuple[1] = nf->create("100","Number Out of World","float OutOfWorld, i, j"); >> 83 // >> 84 // ntuple[2] = nf->create("200","Secondary Info","float Secondary, i, j"); >> 85 // >> 86 // ntuple[3] = nf->create("300","Energy Deposits","float EmEdep, HadEdep"); >> 87 // >> 88 // // Creating Histograms >> 89 // >> 90 // histo[1] = hf->createHistogram1D("1","Number of OutOfWorld",100, 0., 100.); >> 91 // histo[2] = hf->createHistogram1D("2","Number of Secondaries",100, 0., 100.); >> 92 // histo[3] = hf->createHistogram1D("3","Electromagnetic Energy / MeV",100, 0., 100.); >> 93 // histo[4] = hf->createHistogram1D("4","Hadronic Energy / MeV",100, 0., 100.); >> 94 // >> 95 // delete hf; >> 96 // delete tf; >> 97 // delete af; >> 98 // delete nf; >> 99 // >> 100 //} >> 101 // >> 102 ////....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 103 // >> 104 //void FCALRunAction::cleanHisto() >> 105 //{ >> 106 // >> 107 // tree->commit(); // Writing the histograms to the file >> 108 // tree->close(); // and closing the tree (and the file) >> 109 // >> 110 // delete tree; >> 111 // >> 112 // >> 113 //} >> 114 // >> 115 >> 116 70 //....oooOO0OOooo........oooOO0OOooo........oo 117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 71 118 72 void FCALRunAction::BeginOfRunAction(const G4R 119 void FCALRunAction::BeginOfRunAction(const G4Run* aRun) 73 { 120 { 74 121 75 G4cout << "### Run " << aRun->GetRunID() << 122 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 76 123 77 // if (G4VVisManager::GetConcreteInstance()) << 124 // if (aRun->GetRunID() == 0) bookHisto(); 78 // { << 125 79 // G4UImanager* UI = G4UImanager::GetUIpo << 126 if (G4VVisManager::GetConcreteInstance()) 80 // UI->ApplyCommand("/vis/scene/notifyHan << 127 { 81 // } << 128 G4UImanager* UI = G4UImanager::GetUIpointer(); 82 << 129 UI->ApplyCommand("/vis/scene/notifyHandlers"); 83 G4AnalysisManager* man = G4AnalysisManager << 130 } 84 man->OpenFile(); << 131 >> 132 #ifdef G4ANALYSIS_USE >> 133 >> 134 // book histograms and ntuples >> 135 >> 136 FCALAnalysisManager * analysis = FCALAnalysisManager::getInstance(); >> 137 analysis->book(); >> 138 >> 139 #endif >> 140 85 } 141 } 86 142 87 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 88 144 89 void FCALRunAction::EndOfRunAction(const G4Run 145 void FCALRunAction::EndOfRunAction(const G4Run* ) 90 { 146 { 91 147 92 // if (G4VVisManager::GetConcreteInstance()) << 148 #ifdef G4ANALYSIS_USE 93 // G4UImanager::GetUIpointer()->ApplyComma << 149 FCALAnalysisManager* analysis = FCALAnalysisManager::getInstance(); 94 // } << 150 #endif 95 << 151 96 // Save histograms << 152 if (G4VVisManager::GetConcreteInstance()) { 97 G4AnalysisManager* man = G4AnalysisManager:: << 153 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update"); 98 man->Write(); << 154 } 99 man->CloseFile(); << 155 >> 156 #ifdef G4ANALYSIS_USE >> 157 analysis->finish(); >> 158 #endif >> 159 100 } 160 } >> 161 >> 162 //#endif 101 163 102 164 103 //....oooOO0OOooo........oooOO0OOooo........oo 165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 104 166 105 167 106 168 107 169 108 170 109 171 110 172