1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: ExN07Run.cc,v 1.6 2007/05/04 01:49:28 asaim Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | |
---|
31 | #include "ExN07Run.hh" |
---|
32 | #include "G4Event.hh" |
---|
33 | #include "G4HCofThisEvent.hh" |
---|
34 | #include "G4SDManager.hh" |
---|
35 | |
---|
36 | ExN07Run::ExN07Run() |
---|
37 | { |
---|
38 | G4String detName[6] = {"Calor-A_abs","Calor-A_gap","Calor-B_abs","Calor-B_gap","Calor-C_abs","Calor-C_gap"}; |
---|
39 | G4String primNameSum[6] = {"eDep","nGamma","nElectron","nPositron","trackLength","nStep"}; |
---|
40 | G4String primNameMin[3] = {"minEkinGamma","minEkinElectron","minEkinPositron"}; |
---|
41 | G4String paraName[3] = {"Calor-AP_para","Calor-BP_para","Calor-CP_para"}; |
---|
42 | |
---|
43 | G4SDManager* SDMan = G4SDManager::GetSDMpointer(); |
---|
44 | G4String fullName; |
---|
45 | size_t i,j; |
---|
46 | for(i=0;i<6;i++) |
---|
47 | { |
---|
48 | for(j=0;j<6;j++) |
---|
49 | { |
---|
50 | fullName = detName[i]+"/"+primNameSum[j]; |
---|
51 | colIDSum[i][j] = SDMan->GetCollectionID(fullName); |
---|
52 | } |
---|
53 | for(j=0;j<3;j++) |
---|
54 | { |
---|
55 | fullName = detName[i]+"/"+primNameMin[j]; |
---|
56 | colIDMin[i][j] = SDMan->GetCollectionID(fullName); |
---|
57 | } |
---|
58 | } |
---|
59 | for(i=0;i<3;i++) |
---|
60 | { |
---|
61 | for(j=0;j<6;j++) |
---|
62 | { |
---|
63 | fullName = paraName[i]+"/"+primNameSum[j]; |
---|
64 | colIDPara[i][j] = SDMan->GetCollectionID(fullName); |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | ExN07Run::~ExN07Run() |
---|
70 | {;} |
---|
71 | |
---|
72 | void ExN07Run::RecordEvent(const G4Event* evt) |
---|
73 | { |
---|
74 | G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); |
---|
75 | if(!HCE) return; |
---|
76 | numberOfEvent++; |
---|
77 | size_t i,j; |
---|
78 | for(i=0;i<6;i++) |
---|
79 | { |
---|
80 | for(j=0;j<6;j++) |
---|
81 | { |
---|
82 | G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDSum[i][j])); |
---|
83 | mapSum[i][j] += *evtMap; |
---|
84 | } |
---|
85 | for(j=0;j<3;j++) |
---|
86 | { |
---|
87 | G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDMin[i][j])); |
---|
88 | std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin(); |
---|
89 | for(; itr != evtMap->GetMap()->end(); itr++) |
---|
90 | { |
---|
91 | G4int key = (itr->first); |
---|
92 | G4double val = *(itr->second); |
---|
93 | G4double* mapP = mapMin[i][j][key]; |
---|
94 | if( mapP && (val>*mapP) ) continue; |
---|
95 | mapMin[i][j].set(key,val); |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | for(i=0;i<3;i++) |
---|
100 | { |
---|
101 | for(j=0;j<6;j++) |
---|
102 | { |
---|
103 | G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDPara[i][j])); |
---|
104 | mapPara[i][j] += *evtMap; |
---|
105 | } |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | G4double ExN07Run::GetTotal(const G4THitsMap<G4double> &map) const |
---|
110 | { |
---|
111 | G4double tot = 0.; |
---|
112 | std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin(); |
---|
113 | for(; itr != map.GetMap()->end(); itr++) |
---|
114 | { tot += *(itr->second); } |
---|
115 | return tot; |
---|
116 | } |
---|
117 | |
---|
118 | G4double ExN07Run::FindMinimum(const G4THitsMap<G4double> &map) const |
---|
119 | { |
---|
120 | G4double val = DBL_MAX; |
---|
121 | std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin(); |
---|
122 | for(; itr != map.GetMap()->end(); itr++) |
---|
123 | { if(val>*(itr->second)) val = *(itr->second); } |
---|
124 | return val; |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | |
---|