Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:36

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 // Code developed by:
0027 //  S.Larsson
0028 //
0029 //    ******************************
0030 //    *                            *
0031 //    *    PurgMagRunAction.cc     *
0032 //    *                            *
0033 //    ******************************
0034 //
0035 //
0036 
0037 #include "PurgMagRunAction.hh"
0038 
0039 #include "G4Run.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4AnalysisManager.hh"
0042 #include "Randomize.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0045 
0046 PurgMagRunAction::PurgMagRunAction()
0047 {   
0048   saveRndm = 1;  
0049 }
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0052 
0053 PurgMagRunAction::~PurgMagRunAction()
0054 {}
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0057 
0058 void PurgMagRunAction::BeginOfRunAction(const G4Run* aRun)
0059 {  
0060   //Analysis must be handled by master and workers
0061   Book();  
0062   
0063   if (IsMaster())    
0064     G4cout << "---> Run " << aRun->GetRunID() << " (master) start." 
0065        << G4endl;
0066   else
0067     G4cout << "---> Run " << aRun->GetRunID() << " (worker) start." 
0068        << G4endl;
0069 
0070   
0071   // save Rndm status
0072   if (saveRndm > 0 && IsMaster())
0073     { 
0074       G4Random::showEngineStatus();
0075       G4Random::saveEngineStatus("beginOfRun.rndm");
0076     }
0077       
0078 }
0079 
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0082 
0083 void PurgMagRunAction::EndOfRunAction(const G4Run* aRun)
0084 {      
0085   if (IsMaster())    
0086     G4cout << "Total number of event = " << aRun->GetNumberOfEvent() << G4endl;
0087   else
0088     G4cout << "Partial number of event in this worker = " 
0089        << aRun->GetNumberOfEvent() << G4endl;
0090  
0091        
0092   if (IsMaster())
0093     {
0094       // save Rndm status
0095       if (saveRndm == 1)
0096     { 
0097       G4Random::showEngineStatus();
0098       G4Random::saveEngineStatus("endOfRun.rndm");
0099     }             
0100     }            
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0104 
0105 void PurgMagRunAction::Book() 
0106 {
0107   // Get/create analysis manager
0108   G4AnalysisManager* man = G4AnalysisManager::Instance();
0109   man->SetDefaultFileType("csv");
0110  
0111   // Open an output file
0112   man->OpenFile("purgmag"); 
0113   man->SetFirstNtupleId(1);
0114   
0115   // Create 1st ntuple (id = 1)
0116   //    
0117   man->CreateNtuple("n101", "Electron");
0118   man->CreateNtupleDColumn("ex");
0119   man->CreateNtupleDColumn("ey");
0120   man->CreateNtupleDColumn("ez");
0121   man->CreateNtupleDColumn("ee");
0122   man->CreateNtupleDColumn("epx");
0123   man->CreateNtupleDColumn("epy");
0124   man->CreateNtupleDColumn("epz");
0125   man->FinishNtuple();
0126   G4cout << "Ntuple-1 created" << G4endl;
0127 
0128   // Create 2nd ntuple (id = 2)
0129   //    
0130   man->CreateNtuple("n102", "Gamma");
0131   man->CreateNtupleDColumn("gx");
0132   man->CreateNtupleDColumn("gy");
0133   man->CreateNtupleDColumn("gz");
0134   man->CreateNtupleDColumn("ge");
0135   man->CreateNtupleDColumn("gpx");
0136   man->CreateNtupleDColumn("gpy");
0137   man->CreateNtupleDColumn("gpz");
0138   man->FinishNtuple();
0139   G4cout << "Ntuple-2 created" << G4endl;
0140  
0141   // Create 3rd ntuple (id = 3)
0142   //
0143   man->CreateNtuple("n103", "Positron");
0144   man->CreateNtupleDColumn("px");
0145   man->CreateNtupleDColumn("py");
0146   man->CreateNtupleDColumn("pz");
0147   man->CreateNtupleDColumn("pe");
0148   man->CreateNtupleDColumn("ppx");
0149   man->CreateNtupleDColumn("ppy");
0150   man->CreateNtupleDColumn("ppz");
0151   man->FinishNtuple();
0152   G4cout << "Ntuple-3 created" << G4endl;
0153 
0154   return;
0155 }
0156 
0157 
0158