ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE06Run.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RE06Run.cc
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 //
28 //
29 //
30 
31 #include "RE06Run.hh"
32 #include "G4Event.hh"
33 #include "G4HCofThisEvent.hh"
34 #include "G4SDManager.hh"
35 
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 
39  : G4Run()
40 {
41  G4String detName[6]
42  = {"Calor-A_abs","Calor-A_gap",
43  "Calor-B_abs","Calor-B_gap",
44  "Calor-C_abs","Calor-C_gap"};
45 
46  G4String primNameSum[6]
47  = {"eDep","nGamma","nElectron","nPositron","trackLength","nStep"};
48 
49  G4String primNameMin[3]
50  = {"minEkinGamma","minEkinElectron","minEkinPositron"};
51 
52  G4String paraName[3]
53  = {"Calor-AP_para","Calor-BP_para","Calor-CP_para"};
54 
56  G4String fullName;
57  size_t i,j;
58  for(i=0;i<6;i++)
59  {
60  for(j=0;j<6;j++)
61  {
62  fullName = detName[i]+"/"+primNameSum[j];
63  fColIDSum[i][j] = SDMan->GetCollectionID(fullName);
64  }
65  for(j=0;j<3;j++)
66  {
67  fullName = detName[i]+"/"+primNameMin[j];
68  fColIDMin[i][j] = SDMan->GetCollectionID(fullName);
69  }
70  }
71  for(i=0;i<3;i++)
72  {
73  for(j=0;j<6;j++)
74  {
75  fullName = paraName[i]+"/"+primNameSum[j];
76  fColIDPara[i][j] = SDMan->GetCollectionID(fullName);
77  }
78  }
79 
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {;}
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
89 void RE06Run::RecordEvent(const G4Event* evt)
90 {
91  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
92  if(!HCE) return;
93  numberOfEvent++;
94  size_t i,j;
95  for(i=0;i<6;i++)
96  {
97  for(j=0;j<6;j++)
98  {
99  G4THitsMap<G4double>* evtMap
100  = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDSum[i][j]));
101  fMapSum[i][j] += *evtMap;
102  }
103 
104  for(j=0;j<3;j++)
105  {
106  G4THitsMap<G4double>* evtMap
107  = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDMin[i][j]));
108  std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin();
109  for(; itr != evtMap->GetMap()->end(); itr++)
110  {
111  G4int key = (itr->first);
112  G4double val = *(itr->second);
113  G4double* mapP = fMapMin[i][j][key];
114  if( mapP && (val>*mapP) ) continue;
115  fMapMin[i][j].set(key,val);
116  }
117  }
118 
119  }
120  for(i=0;i<3;i++)
121  {
122  for(j=0;j<6;j++)
123  {
124  G4THitsMap<G4double>* evtMap
125  = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDPara[i][j]));
126  fMapPara[i][j] += *evtMap;
127  }
128  }
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 void RE06Run::Merge(const G4Run * aRun) {
133  const RE06Run * localRun = static_cast<const RE06Run *>(aRun);
134 
135  for(G4int i = 0; i < 6; i++) {
136  for(G4int j = 0; j < 6; j++) {
137  fMapSum[i][j] += localRun->fMapSum[i][j];
138  }
139 
140  for(G4int j = 0; j < 3; j++) {
141  std::map<G4int, G4double*>::iterator itr = localRun->fMapMin[i][j].GetMap()->begin();
142  for(; itr != localRun->fMapMin[i][j].GetMap()->end(); itr++) {
143  G4int key = itr->first;
144  G4double val = *(itr->second);
145  G4double * mapP = fMapMin[i][j][key];
146  if(!mapP || val < *mapP) fMapMin[i][j].set(key, val);
147  }
148  }
149  }
150 
151  for(G4int i = 0; i < 3; i++) {
152  for(G4int j = 0; j < 6; j++) {
153  fMapPara[i][j] += localRun->fMapPara[i][j];
154  }
155  }
156 
157  G4Run::Merge(aRun);
158 }
159 
160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 {
163  G4double tot = 0.;
164  if(map.GetSize()==0) return tot;
165  std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin();
166  for(; itr != map.GetMap()->end(); itr++)
167  { tot += *(itr->second); }
168  return tot;
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172 
174 {
175  G4double val = DBL_MAX;
176 
177  if(map.GetSize()==0) return val;
178  std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin();
179  for(; itr != map.GetMap()->end(); itr++)
180  { if(val>*(itr->second)) val = *(itr->second); }
181  return val;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......