Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN07Run.cc
Go to the documentation of this file.
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$
28 //
29 
30 #include "ExN07Run.hh"
31 #include "G4Event.hh"
32 #include "G4HCofThisEvent.hh"
33 #include "G4SDManager.hh"
34 
36 {
37  G4String detName[6] = {"Calor-A_abs","Calor-A_gap","Calor-B_abs","Calor-B_gap","Calor-C_abs","Calor-C_gap"};
38  G4String primNameSum[6] = {"eDep","nGamma","nElectron","nPositron","trackLength","nStep"};
39  G4String primNameMin[3] = {"minEkinGamma","minEkinElectron","minEkinPositron"};
40  G4String paraName[3] = {"Calor-AP_para","Calor-BP_para","Calor-CP_para"};
41 
43  G4String fullName;
44  size_t i,j;
45  for(i=0;i<6;i++)
46  {
47  for(j=0;j<6;j++)
48  {
49  fullName = detName[i]+"/"+primNameSum[j];
50  colIDSum[i][j] = SDMan->GetCollectionID(fullName);
51  }
52  for(j=0;j<3;j++)
53  {
54  fullName = detName[i]+"/"+primNameMin[j];
55  colIDMin[i][j] = SDMan->GetCollectionID(fullName);
56  }
57  }
58  for(i=0;i<3;i++)
59  {
60  for(j=0;j<6;j++)
61  {
62  fullName = paraName[i]+"/"+primNameSum[j];
63  colIDPara[i][j] = SDMan->GetCollectionID(fullName);
64  }
65  }
66 }
67 
69 {;}
70 
72 {
73  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
74  if(!HCE) return;
75  numberOfEvent++;
76  size_t i,j;
77  for(i=0;i<6;i++)
78  {
79  for(j=0;j<6;j++)
80  {
81  G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDSum[i][j]));
82  mapSum[i][j] += *evtMap;
83  }
84  for(j=0;j<3;j++)
85  {
86  G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDMin[i][j]));
87  std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin();
88  for(; itr != evtMap->GetMap()->end(); itr++)
89  {
90  G4int key = (itr->first);
91  G4double val = *(itr->second);
92  G4double* mapP = mapMin[i][j][key];
93  if( mapP && (val>*mapP) ) continue;
94  mapMin[i][j].set(key,val);
95  }
96  }
97  }
98  for(i=0;i<3;i++)
99  {
100  for(j=0;j<6;j++)
101  {
102  G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colIDPara[i][j]));
103  mapPara[i][j] += *evtMap;
104  }
105  }
106 }
107 
108 G4double ExN07Run::GetTotal(const G4THitsMap<G4double> &map) const
109 {
110  G4double tot = 0.;
111  std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin();
112  for(; itr != map.GetMap()->end(); itr++)
113  { tot += *(itr->second); }
114  return tot;
115 }
116 
117 G4double ExN07Run::FindMinimum(const G4THitsMap<G4double> &map) const
118 {
119  G4double val = DBL_MAX;
120  std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin();
121  for(; itr != map.GetMap()->end(); itr++)
122  { if(val>*(itr->second)) val = *(itr->second); }
123  return val;
124 }
125 
126 
127