Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:46

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 /// \file RE06/src/RE06Run.cc
0027 /// \brief Implementation of the RE06Run class
0028 //
0029 //
0030 
0031 #include "RE06Run.hh"
0032 
0033 #include "G4Event.hh"
0034 #include "G4HCofThisEvent.hh"
0035 #include "G4SDManager.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 RE06Run::RE06Run() : G4Run()
0040 {
0041   G4String detName[6] = {"Calor-A_abs", "Calor-A_gap", "Calor-B_abs",
0042                          "Calor-B_gap", "Calor-C_abs", "Calor-C_gap"};
0043 
0044   G4String primNameSum[6] = {"eDep", "nGamma", "nElectron", "nPositron", "trackLength", "nStep"};
0045 
0046   G4String primNameMin[3] = {"minEkinGamma", "minEkinElectron", "minEkinPositron"};
0047 
0048   G4String paraName[3] = {"Calor-AP_para", "Calor-BP_para", "Calor-CP_para"};
0049 
0050   G4SDManager* SDMan = G4SDManager::GetSDMpointer();
0051   G4String fullName;
0052   size_t i, j;
0053   for (i = 0; i < 6; i++) {
0054     for (j = 0; j < 6; j++) {
0055       fullName = detName[i] + "/" + primNameSum[j];
0056       fColIDSum[i][j] = SDMan->GetCollectionID(fullName);
0057     }
0058     for (j = 0; j < 3; j++) {
0059       fullName = detName[i] + "/" + primNameMin[j];
0060       fColIDMin[i][j] = SDMan->GetCollectionID(fullName);
0061     }
0062   }
0063   for (i = 0; i < 3; i++) {
0064     for (j = 0; j < 6; j++) {
0065       fullName = paraName[i] + "/" + primNameSum[j];
0066       fColIDPara[i][j] = SDMan->GetCollectionID(fullName);
0067     }
0068   }
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 RE06Run::~RE06Run()
0074 {
0075   ;
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 void RE06Run::RecordEvent(const G4Event* evt)
0081 {
0082   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0083   if (!HCE) return;
0084   numberOfEvent++;
0085   size_t i, j;
0086   for (i = 0; i < 6; i++) {
0087     for (j = 0; j < 6; j++) {
0088       G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDSum[i][j]));
0089       fMapSum[i][j] += *evtMap;
0090     }
0091 
0092     for (j = 0; j < 3; j++) {
0093       G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDMin[i][j]));
0094       std::map<G4int, G4double*>::iterator itr = evtMap->GetMap()->begin();
0095       for (; itr != evtMap->GetMap()->end(); itr++) {
0096         G4int key = (itr->first);
0097         G4double val = *(itr->second);
0098         G4double* mapP = fMapMin[i][j][key];
0099         if (mapP && (val > *mapP)) continue;
0100         fMapMin[i][j].set(key, val);
0101       }
0102     }
0103   }
0104   for (i = 0; i < 3; i++) {
0105     for (j = 0; j < 6; j++) {
0106       G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDPara[i][j]));
0107       fMapPara[i][j] += *evtMap;
0108     }
0109   }
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0113 void RE06Run::Merge(const G4Run* aRun)
0114 {
0115   const RE06Run* localRun = static_cast<const RE06Run*>(aRun);
0116 
0117   for (G4int i = 0; i < 6; i++) {
0118     for (G4int j = 0; j < 6; j++) {
0119       fMapSum[i][j] += localRun->fMapSum[i][j];
0120     }
0121 
0122     for (G4int j = 0; j < 3; j++) {
0123       std::map<G4int, G4double*>::iterator itr = localRun->fMapMin[i][j].GetMap()->begin();
0124       for (; itr != localRun->fMapMin[i][j].GetMap()->end(); itr++) {
0125         G4int key = itr->first;
0126         G4double val = *(itr->second);
0127         G4double* mapP = fMapMin[i][j][key];
0128         if (!mapP || val < *mapP) fMapMin[i][j].set(key, val);
0129       }
0130     }
0131   }
0132 
0133   for (G4int i = 0; i < 3; i++) {
0134     for (G4int j = 0; j < 6; j++) {
0135       fMapPara[i][j] += localRun->fMapPara[i][j];
0136     }
0137   }
0138 
0139   G4Run::Merge(aRun);
0140 }
0141 
0142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0143 G4double RE06Run::GetTotal(const G4THitsMap<G4double>& map) const
0144 {
0145   G4double tot = 0.;
0146   if (map.GetSize() == 0) return tot;
0147   std::map<G4int, G4double*>::iterator itr = map.GetMap()->begin();
0148   for (; itr != map.GetMap()->end(); itr++) {
0149     tot += *(itr->second);
0150   }
0151   return tot;
0152 }
0153 
0154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0155 
0156 G4double RE06Run::FindMinimum(const G4THitsMap<G4double>& map) const
0157 {
0158   G4double val = DBL_MAX;
0159 
0160   if (map.GetSize() == 0) return val;
0161   std::map<G4int, G4double*>::iterator itr = map.GetMap()->begin();
0162   for (; itr != map.GetMap()->end(); itr++) {
0163     if (val > *(itr->second)) val = *(itr->second);
0164   }
0165   return val;
0166 }
0167 
0168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......