Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:52:14

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 // gpaterno, October 2025
0027 //
0028 /// \file Run.cc
0029 /// \brief Implementation of the Run class
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "Run.hh"
0034 
0035 #include "G4RunManager.hh"
0036 #include "G4Event.hh"
0037 
0038 #include "G4SDManager.hh"
0039 #include "G4HCofThisEvent.hh"
0040 #include "G4THitsMap.hh"
0041 #include "G4SystemOfUnits.hh"
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 void Run::RecordEvent(const G4Event* event)
0046 {
0047     //Retrieve total Edep in the Radiator Crystal
0048     //Hit Detection System
0049     if (fCollID_edep < 0) {
0050         G4String fCollName = "multisd/edep";
0051         //G4cout << "fCollName: " << fCollName << G4endl;
0052         fCollID_edep = 
0053             G4SDManager::GetSDMpointer()->GetCollectionID(fCollName);
0054     }
0055                 
0056     //get all Hits Collections of this Event
0057     G4HCofThisEvent* HCE = event->GetHCofThisEvent();
0058     if (!HCE) return;
0059 
0060     //fCollID_edep Hits Collection (map)
0061     G4THitsMap<G4double>* evtMap = 
0062         static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_edep));
0063 
0064     //map iterator
0065     std::map<G4int,G4double*>::iterator itr;
0066 
0067     //scan the hits Collection with Energy deposit
0068     G4double edep = 0.;
0069     G4double EdepEvent = 0.;
0070     for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
0071         edep = *(itr->second);
0072     
0073         //accumulate Edep in the whole Run
0074         fEdep += edep;
0075         fEdep2 += edep*edep;
0076                    
0077         //accumulate Edep in the Event
0078         EdepEvent += edep;
0079     }
0080     if (EdepEvent > 0) fGoodEvents++;
0081 
0082 
0083     //call base method
0084     G4Run::RecordEvent(event);
0085 }  
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 void Run::Merge(const G4Run* aRun)
0090 {
0091     //accumulate variables from each instance (one for thread) of Run
0092     const Run* localRun = static_cast<const Run*>(aRun);
0093     fEdep += localRun->fEdep;
0094     fEdep2 += localRun->fEdep2;
0095     fGoodEvents += localRun->fGoodEvents;
0096 
0097     //call base method (to pass accumulated variables to the master thread)
0098     G4Run::Merge(aRun);
0099 } 
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102