Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/advanced/air_shower/src/UltraRunAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // --------------------------------------------------------------
0028 //                 GEANT 4 - ULTRA experiment example
0029 // --------------------------------------------------------------
0030 //
0031 // Code developed by:
0032 // B. Tome, M.C. Espirito-Santo, A. Trindade, P. Rodrigues
0033 //
0034 //    ****************************************************
0035 //    *      UltraRunAction.cc
0036 //    ****************************************************
0037 //
0038 //    RunAction class for Ultra; it has also a Messenger Class
0039 //
0040 #include "UltraRunAction.hh"
0041 #include "G4Run.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4AnalysisManager.hh"
0044 #include "Randomize.hh"
0045 #include <ctime>
0046 #include "Randomize.hh"
0047 
0048 
0049 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0050 
0051 UltraRunAction::UltraRunAction()
0052 {
0053    seed = -1;      // RANLUX seed
0054    luxury = 3;     // RANLUX luxury level (3 is default)
0055    saveRndm = 1;
0056 }
0057 
0058 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0059 
0060 UltraRunAction::~UltraRunAction()
0061 {;}
0062 
0063 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0064 
0065 void UltraRunAction::BeginOfRunAction(const G4Run* aRun)
0066 {
0067   // Get/create analysis manager: need to do that in the master and in the workers
0068   auto man = G4AnalysisManager::Instance();
0069   man->SetDefaultFileType("root");
0070 
0071   // Open an output file
0072   man->OpenFile("ultra");
0073   man->SetFirstHistoId(1);
0074 
0075   // Create histogram(s)
0076   man->CreateH1("PhotonEnergy","Optical photons energy (eV)", //histoID,histo name
0077         500,0.,5.); //bins' number, xmin, xmax
0078   man->CreateH1("NumberDetectedPhotons","Number of Detected Photons",
0079         10,0.,10.); //bins' number, xmin, xmax
0080 
0081   if (!IsMaster()) //it is a slave, do nothing else
0082     {
0083       G4cout << "ooo Run " << aRun->GetRunID() << " starts on slave." << G4endl;
0084       return;
0085     }
0086 
0087   //Master or sequential
0088   G4cout << "ooo Run " << aRun->GetRunID() << " starts (global)." << G4endl;
0089   if (seed<0) //not initialized by anybody else
0090     {
0091       seed=time(0);
0092       G4Random::setTheSeed(seed,luxury);
0093       G4Random::showEngineStatus();
0094     }
0095 
0096   // save Rndm status
0097   if (saveRndm > 0)
0098     G4Random::saveEngineStatus("beginOfRun.rndm");
0099 
0100   return;
0101 }
0102 
0103 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0104 
0105 void UltraRunAction::EndOfRunAction(const G4Run* aRun)
0106 {
0107   // Write histograms to file
0108   // Save histograms
0109   auto man = G4AnalysisManager::Instance();
0110   man->Write();
0111   man->CloseFile();
0112   // Complete clean-up
0113   man->Clear();
0114 
0115   if (!IsMaster())
0116     {
0117       G4cout << "### Run " << aRun->GetRunID() << " (slave) ended." << G4endl;
0118       return;
0119     }
0120 
0121   G4cout << "### Run " << aRun->GetRunID() << " (global) ended." << G4endl;
0122   // save Rndm status
0123   if (saveRndm == 1)
0124     G4Random::saveEngineStatus("endOfRun.rndm");
0125   return;
0126 }