ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExTGRCRegionCutsMgr.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExTGRCRegionCutsMgr.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 //
26 //
29 
30 #include "ExTGRCRegionCutsMgr.hh"
31 #include "ExTGRCRegionData.hh"
32 
33 #include "G4Region.hh"
34 #include "G4RegionStore.hh"
35 #include "G4ProductionCuts.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4tgbVolumeMgr.hh"
38 #include "G4tgrUtils.hh"
39 #include "G4UIcommand.hh"
40 
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 {
46  if( !fInstance )
47  {
49  }
50  return fInstance;
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 {
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 {
61  delete fInstance;
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 void ExTGRCRegionCutsMgr::AddRegionData( const std::vector<G4String>& rd )
66 {
67 
68  if( (rd.size() > 1) && (FindRegionData( rd[0] ).size() != 0) )
69  {
70  G4Exception("ExTGRCRegionCutsMgr::AddRegionData", "InvalidArgument",
72  G4String("Region already exists: " + rd[0]).c_str() );
73  return;
74  }
75  fRegionDatae.push_back( new ExTGRCRegionData( rd ) );
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 void ExTGRCRegionCutsMgr::AddRegionCuts( const std::vector<G4String>& rc )
80 {
81  if( rc.size() == 0 )
82  {
83  G4cerr << "ERROR - ExTGRCRegionCutsMgr::AddRegionCuts()" << G4endl
84  << " Must have 3 or 4 arguments : REGION_NAME, gamma_CUT,"
85  << " e-_CUT (e+_CUT)." << G4endl
86  << " It has only " << rc.size() << " !" << G4endl;
87  G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument",
89  }
90 
91  // Find region
92  // std::vector<ExTGRCRegionData*>::const_iterator iter;
93  std::vector<ExTGRCRegionData*> regs = FindRegionData(rc[0]);
94 
95  if( regs.size() == 0 )
96  {
97  G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()",
98  "InvalidArgument", FatalErrorInArgument,
99  G4String(" region does not exist: " + rc[0]).c_str());
100  }
101 
102  for( size_t ii = 0; ii < regs.size(); ii++)
103  {
104  regs[ii]->SetCutsData( rc );
105  }
106 }
107 
108 std::vector<ExTGRCRegionData*>
110 {
111  std::vector<ExTGRCRegionData*> regs;
112  std::vector<ExTGRCRegionData*>::const_iterator iter;
113  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
114  {
115  if( G4tgrUtils::AreWordsEquivalent( name , (*iter)->GetRegionName()) )
116  {
117  regs.push_back(*iter);
118  }
119  }
120  return regs;
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 {
126  std::vector<ExTGRCRegionData*>::const_iterator iter;
127  std::vector<G4String>::const_iterator ites;
128  // std::vector<G4LogicalVolume*>::const_iterator itelv;
129  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
130  {
131  G4Region* reg = new G4Region( (*iter)->GetRegionName() );
132  std::vector<G4String> lvs = (*iter)->GetLVNames();
133  for( ites = lvs.begin(); ites != lvs.end(); ites++ )
134  {
135  G4LogicalVolume* logVol =
136  G4tgbVolumeMgr::GetInstance()->FindG4LogVol(*ites, true );
137  reg->AddRootLogicalVolume( logVol );
138  }
139  }
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 {
145  std::vector<ExTGRCRegionData*>::const_iterator iter;
147  //----- loop to region datae
148  for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ )
149  {
150  if( (*iter)->CutsAreSet() )
151  {
152  G4Region* reg = regions->GetRegion( (*iter)->GetRegionName() );
153  if( !reg )
154  {
155  G4Exception("ExTGRCRegionCutsMgr::BuildProductionCuts()",
156  "InvalidArgument", FatalErrorInArgument,
157  G4String("Region not found: " + (*iter)->GetRegionName()).c_str() );
158  }
159  G4ProductionCuts* cuts = new G4ProductionCuts ;
160 
161  cuts->SetProductionCut((*iter)->GetGammaCut(),"gamma");
162  cuts->SetProductionCut((*iter)->GetElectronCut(),"e-");
163  cuts->SetProductionCut((*iter)->GetPositronCut(),"e+");
164  reg->SetProductionCuts(cuts);
165  }
166  }
167 }