Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExTGRCRegionCutsMgr.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 // $Id: ExTGRCRegionCutsMgr.cc 76943 2013-11-19 09:57:34Z gcosmo $
27 //
28 /// \file persistency/P03/src/ExTGRCRegionCutsMgr.cc
29 /// \brief Implementation of the ExTGRCRegionCutsMgr class
30 
31 #include "ExTGRCRegionCutsMgr.hh"
32 #include "ExTGRCRegionData.hh"
33 
34 #include "G4Region.hh"
35 #include "G4RegionStore.hh"
36 #include "G4ProductionCuts.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4tgbVolumeMgr.hh"
39 #include "G4tgrUtils.hh"
40 #include "G4UIcommand.hh"
41 
42 ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::fInstance = 0;
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 {
47  if( !fInstance )
48  {
49  fInstance = new ExTGRCRegionCutsMgr;
50  }
51  return fInstance;
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 ExTGRCRegionCutsMgr::ExTGRCRegionCutsMgr()
56 {
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 {
62  delete fInstance;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 void ExTGRCRegionCutsMgr::AddRegionData( const std::vector<G4String>& rd )
67 {
68 
69  if( (rd.size() > 1) && (FindRegionData( rd[0] ).size() != 0) )
70  {
71  G4Exception("ExTGRCRegionCutsMgr::AddRegionData", "InvalidArgument",
73  G4String("Region already exists: " + rd[0]).c_str() );
74  return;
75  }
76  fRegionDatae.push_back( new ExTGRCRegionData( rd ) );
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 void ExTGRCRegionCutsMgr::AddRegionCuts( const std::vector<G4String>& rc )
81 {
82  if( rc.size() == 0 )
83  {
84  G4cerr << "ERROR - ExTGRCRegionCutsMgr::AddRegionCuts()" << G4endl
85  << " Must have 3 or 4 arguments : REGION_NAME, gamma_CUT,"
86  << " e-_CUT (e+_CUT)." << G4endl
87  << " It has only " << rc.size() << " !" << G4endl;
88  G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument",
90  }
91 
92  // Find region
93  std::vector<ExTGRCRegionData*>::const_iterator iter;
94  std::vector<ExTGRCRegionData*> regs = FindRegionData(rc[0]);
95 
96  if( regs.size() == 0 )
97  {
98  G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()",
99  "InvalidArgument", FatalErrorInArgument,
100  G4String(" region does not exist: " + rc[0]).c_str());
101  }
102 
103  for( size_t ii = 0; ii < regs.size(); ii++)
104  {
105  regs[ii]->SetCutsData( rc );
106  }
107 }
108 
109 std::vector<ExTGRCRegionData*>
111 {
112  std::vector<ExTGRCRegionData*> regs;
113  std::vector<ExTGRCRegionData*>::const_iterator iter;
114  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
115  {
116  if( G4tgrUtils::AreWordsEquivalent( name , (*iter)->GetRegionName()) )
117  {
118  regs.push_back(*iter);
119  }
120  }
121  return regs;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 {
127  std::vector<ExTGRCRegionData*>::const_iterator iter;
128  std::vector<G4String>::const_iterator ites;
129  std::vector<G4LogicalVolume*>::const_iterator itelv;
130  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
131  {
132  G4Region* reg = new G4Region( (*iter)->GetRegionName() );
133  std::vector<G4String> lvs = (*iter)->GetLVNames();
134  for( ites = lvs.begin(); ites != lvs.end(); ites++ )
135  {
136  G4LogicalVolume* logVol =
137  G4tgbVolumeMgr::GetInstance()->FindG4LogVol(*ites, true );
138  reg->AddRootLogicalVolume( logVol );
139  }
140  }
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145 {
146  std::vector<ExTGRCRegionData*>::const_iterator iter;
148  //----- loop to region datae
149  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
150  {
151  if( (*iter)->CutsAreSet() )
152  {
153  G4Region* reg = regions->GetRegion( (*iter)->GetRegionName() );
154  if( !reg )
155  {
156  G4Exception("ExTGRCRegionCutsMgr::BuildProductionCuts()",
157  "InvalidArgument", FatalErrorInArgument,
158  G4String("Region not found: " + (*iter)->GetRegionName()).c_str() );
159  }
160  G4ProductionCuts* cuts = new G4ProductionCuts ;
161 
162  cuts->SetProductionCut((*iter)->GetGammaCut(),"gamma");
163  cuts->SetProductionCut((*iter)->GetElectronCut(),"e-");
164  cuts->SetProductionCut((*iter)->GetPositronCut(),"e+");
165  reg->SetProductionCuts(cuts);
166  }
167  }
168 }
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
Definition of the ExTGRCRegionCutsMgr class.
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
const XML_Char * name
void SetProductionCut(G4double cut, G4int index=-1)
static G4bool AreWordsEquivalent(const G4String &word1, const G4String &word2)
Definition: G4tgrUtils.cc:672
int G4int
Definition: G4Types.hh:78
void AddRegionCuts(const std::vector< G4String > &rc)
static G4RegionStore * GetInstance()
G4ThreadLocal struct user_regs_struct regs
Definition: tracer.cxx:62
void AddRegionData(const std::vector< G4String > &rd)
std::vector< ExTGRCRegionData * > FindRegionData(const G4String &name)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void SetProductionCuts(G4ProductionCuts *cut)
static G4tgbVolumeMgr * GetInstance()
static ExTGRCRegionCutsMgr * GetInstance()
Definition of the ExTGRCRegionData class.
G4GLOB_DLL std::ostream G4cerr
G4LogicalVolume * FindG4LogVol(const G4String &theName, const G4bool bExists=0)