Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file persistency/P03/src/ExTGRCRegionCuts 27 /// \file persistency/P03/src/ExTGRCRegionCutsMgr.cc 28 /// \brief Implementation of the ExTGRCRegionC 28 /// \brief Implementation of the ExTGRCRegionCutsMgr class 29 29 30 #include "ExTGRCRegionCutsMgr.hh" 30 #include "ExTGRCRegionCutsMgr.hh" 31 << 32 #include "ExTGRCRegionData.hh" 31 #include "ExTGRCRegionData.hh" 33 32 34 #include "G4LogicalVolume.hh" << 35 #include "G4ProductionCuts.hh" << 36 #include "G4Region.hh" 33 #include "G4Region.hh" 37 #include "G4RegionStore.hh" 34 #include "G4RegionStore.hh" 38 #include "G4UIcommand.hh" << 35 #include "G4ProductionCuts.hh" >> 36 #include "G4LogicalVolume.hh" 39 #include "G4tgbVolumeMgr.hh" 37 #include "G4tgbVolumeMgr.hh" 40 #include "G4tgrUtils.hh" 38 #include "G4tgrUtils.hh" >> 39 #include "G4UIcommand.hh" 41 40 42 ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::fIns 41 ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::fInstance = 0; 43 42 44 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 45 ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::GetI 44 ExTGRCRegionCutsMgr* ExTGRCRegionCutsMgr::GetInstance() 46 { 45 { 47 if (!fInstance) { << 46 if( !fInstance ) >> 47 { 48 fInstance = new ExTGRCRegionCutsMgr; 48 fInstance = new ExTGRCRegionCutsMgr; 49 } 49 } 50 return fInstance; 50 return fInstance; 51 } 51 } 52 52 53 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 ExTGRCRegionCutsMgr::ExTGRCRegionCutsMgr() {} << 54 ExTGRCRegionCutsMgr::ExTGRCRegionCutsMgr() >> 55 { >> 56 } 55 57 56 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 ExTGRCRegionCutsMgr::~ExTGRCRegionCutsMgr() 59 ExTGRCRegionCutsMgr::~ExTGRCRegionCutsMgr() 58 { 60 { 59 delete fInstance; 61 delete fInstance; 60 } 62 } 61 63 62 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 void ExTGRCRegionCutsMgr::AddRegionData(const << 65 void ExTGRCRegionCutsMgr::AddRegionData( const std::vector<G4String>& rd ) 64 { 66 { 65 if ((rd.size() > 1) && (FindRegionData(rd[0] << 67 66 G4Exception("ExTGRCRegionCutsMgr::AddRegio << 68 if( (rd.size() > 1) && (FindRegionData( rd[0] ).size() != 0) ) 67 G4String("Region already exist << 69 { >> 70 G4Exception("ExTGRCRegionCutsMgr::AddRegionData", "InvalidArgument", >> 71 JustWarning, >> 72 G4String("Region already exists: " + rd[0]).c_str() ); 68 return; 73 return; 69 } 74 } 70 fRegionDatae.push_back(new ExTGRCRegionData( << 75 fRegionDatae.push_back( new ExTGRCRegionData( rd ) ); 71 } 76 } 72 77 73 //....oooOO0OOooo........oooOO0OOooo........oo 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 void ExTGRCRegionCutsMgr::AddRegionCuts(const << 79 void ExTGRCRegionCutsMgr::AddRegionCuts( const std::vector<G4String>& rc ) 75 { 80 { 76 if (rc.size() == 0) { << 81 if( rc.size() == 0 ) >> 82 { 77 G4cerr << "ERROR - ExTGRCRegionCutsMgr::Ad 83 G4cerr << "ERROR - ExTGRCRegionCutsMgr::AddRegionCuts()" << G4endl 78 << " Must have 3 or 4 argume 84 << " Must have 3 or 4 arguments : REGION_NAME, gamma_CUT," 79 << " e-_CUT (e+_CUT)." << G4endl << << 85 << " e-_CUT (e+_CUT)." << G4endl 80 << G4endl; << 86 << " It has only " << rc.size() << " !" << G4endl; 81 G4Exception("ExTGRCRegionCutsMgr::AddRegio << 87 G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", "InvalidArgument", 82 G4UIcommand::ConvertToString(G << 88 FatalErrorInArgument, G4UIcommand::ConvertToString(G4int(rc.size())) ); 83 } 89 } 84 90 85 // Find region 91 // Find region 86 // std::vector<ExTGRCRegionData*>::const_ite 92 // std::vector<ExTGRCRegionData*>::const_iterator iter; 87 std::vector<ExTGRCRegionData*> regs = FindRe 93 std::vector<ExTGRCRegionData*> regs = FindRegionData(rc[0]); 88 94 89 if (regs.size() == 0) { << 95 if( regs.size() == 0 ) 90 G4Exception("ExTGRCRegionCutsMgr::AddRegio << 96 { >> 97 G4Exception("ExTGRCRegionCutsMgr::AddRegionCuts()", >> 98 "InvalidArgument", FatalErrorInArgument, 91 G4String(" region does not exi 99 G4String(" region does not exist: " + rc[0]).c_str()); 92 } << 100 } 93 101 94 for (size_t ii = 0; ii < regs.size(); ii++) << 102 for( size_t ii = 0; ii < regs.size(); ii++) 95 regs[ii]->SetCutsData(rc); << 103 { >> 104 regs[ii]->SetCutsData( rc ); 96 } 105 } 97 } 106 } 98 107 99 std::vector<ExTGRCRegionData*> ExTGRCRegionCut << 108 std::vector<ExTGRCRegionData*> >> 109 ExTGRCRegionCutsMgr::FindRegionData( const G4String& name) 100 { 110 { 101 std::vector<ExTGRCRegionData*> regs; 111 std::vector<ExTGRCRegionData*> regs; 102 std::vector<ExTGRCRegionData*>::const_iterat 112 std::vector<ExTGRCRegionData*>::const_iterator iter; 103 for (iter = fRegionDatae.begin(); iter != fR << 113 for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ ) 104 if (G4tgrUtils::AreWordsEquivalent(name, ( << 114 { >> 115 if( G4tgrUtils::AreWordsEquivalent( name , (*iter)->GetRegionName()) ) >> 116 { 105 regs.push_back(*iter); 117 regs.push_back(*iter); 106 } 118 } 107 } 119 } 108 return regs; << 120 return regs; 109 } 121 } 110 122 111 //....oooOO0OOooo........oooOO0OOooo........oo 123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 112 void ExTGRCRegionCutsMgr::BuildRegions() 124 void ExTGRCRegionCutsMgr::BuildRegions() 113 { 125 { 114 std::vector<ExTGRCRegionData*>::const_iterat 126 std::vector<ExTGRCRegionData*>::const_iterator iter; 115 std::vector<G4String>::const_iterator ites; 127 std::vector<G4String>::const_iterator ites; 116 // std::vector<G4LogicalVolume*>::const_iter 128 // std::vector<G4LogicalVolume*>::const_iterator itelv; 117 for (iter = fRegionDatae.begin(); iter != fR << 129 for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ ) 118 G4Region* reg = new G4Region((*iter)->GetR << 130 { >> 131 G4Region* reg = new G4Region( (*iter)->GetRegionName() ); 119 std::vector<G4String> lvs = (*iter)->GetLV 132 std::vector<G4String> lvs = (*iter)->GetLVNames(); 120 for (ites = lvs.begin(); ites != lvs.end() << 133 for( ites = lvs.begin(); ites != lvs.end(); ites++ ) 121 G4LogicalVolume* logVol = G4tgbVolumeMgr << 134 { 122 reg->AddRootLogicalVolume(logVol); << 135 G4LogicalVolume* logVol = >> 136 G4tgbVolumeMgr::GetInstance()->FindG4LogVol(*ites, true ); >> 137 reg->AddRootLogicalVolume( logVol ); 123 } 138 } 124 } 139 } 125 } 140 } 126 141 127 //....oooOO0OOooo........oooOO0OOooo........oo 142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 128 void ExTGRCRegionCutsMgr::BuildProductionCuts( 143 void ExTGRCRegionCutsMgr::BuildProductionCuts() 129 { 144 { 130 std::vector<ExTGRCRegionData*>::const_iterat 145 std::vector<ExTGRCRegionData*>::const_iterator iter; 131 G4RegionStore* regions = G4RegionStore::GetI 146 G4RegionStore* regions = G4RegionStore::GetInstance(); 132 //----- loop to region datae 147 //----- loop to region datae 133 for (iter = fRegionDatae.begin(); iter != fR << 148 for( iter = fRegionDatae.begin(); iter != fRegionDatae.end(); iter++ ) 134 if ((*iter)->CutsAreSet()) { << 149 { 135 G4Region* reg = regions->GetRegion((*ite << 150 if( (*iter)->CutsAreSet() ) 136 if (!reg) { << 151 { 137 G4Exception("ExTGRCRegionCutsMgr::Buil << 152 G4Region* reg = regions->GetRegion( (*iter)->GetRegionName() ); 138 FatalErrorInArgument, << 153 if( !reg ) 139 G4String("Region not found << 154 { 140 } << 155 G4Exception("ExTGRCRegionCutsMgr::BuildProductionCuts()", 141 G4ProductionCuts* cuts = new G4Productio << 156 "InvalidArgument", FatalErrorInArgument, 142 << 157 G4String("Region not found: " + (*iter)->GetRegionName()).c_str() ); 143 cuts->SetProductionCut((*iter)->GetGamma << 158 } 144 cuts->SetProductionCut((*iter)->GetElect << 159 G4ProductionCuts* cuts = new G4ProductionCuts ; 145 cuts->SetProductionCut((*iter)->GetPosit << 160 >> 161 cuts->SetProductionCut((*iter)->GetGammaCut(),"gamma"); >> 162 cuts->SetProductionCut((*iter)->GetElectronCut(),"e-"); >> 163 cuts->SetProductionCut((*iter)->GetPositronCut(),"e+"); 146 reg->SetProductionCuts(cuts); 164 reg->SetProductionCuts(cuts); 147 } 165 } 148 } 166 } 149 } 167 } 150 168