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 // 27 // 28 // modified by I. Hrivnacova, 13.10.99 28 // modified by I. Hrivnacova, 13.10.99 29 29 30 #include "globals.hh" 30 #include "globals.hh" 31 #include "G3VolTable.hh" 31 #include "G3VolTable.hh" 32 #include "G4VSolid.hh" 32 #include "G4VSolid.hh" 33 #include "G3toG4.hh" 33 #include "G3toG4.hh" 34 #include <cmath> 34 #include <cmath> 35 35 36 G4bool G3CalcParamsFn(G4double *rpar, G4int np 36 G4bool G3CalcParamsFn(G4double *rpar, G4int npar, G4double *rparm, 37 G4String shape, G4String 37 G4String shape, G4String shapem) 38 // Returns true only in case the parameters 38 // Returns true only in case the parameters *after* processing 39 // this method remain negative. 39 // this method remain negative. 40 { 40 { 41 G4bool NegPresent = FALSE; 41 G4bool NegPresent = FALSE; 42 // for normal single volume positioning, jus 42 // for normal single volume positioning, just substitute for the 43 // negative parameters 43 // negative parameters 44 // treat only the legal cases 44 // treat only the legal cases 45 if (shapem == shape) { 45 if (shapem == shape) { 46 if (shape == "BOX" || shape == "TRD1" || s 46 if (shape == "BOX" || shape == "TRD1" || shape == "TRD2" || 47 shape == "ELTU") { 47 shape == "ELTU") { 48 for (G4int i=0;i<npar;i++) { 48 for (G4int i=0;i<npar;i++) { 49 if (rpar[i] < 0) { 49 if (rpar[i] < 0) { 50 if (rparm != 0) rpar[i] = rparm[i]; 50 if (rparm != 0) rpar[i] = rparm[i]; 51 if (rpar[i] < 0) NegPresent = TRUE; 51 if (rpar[i] < 0) NegPresent = TRUE; 52 } 52 } 53 } 53 } 54 } 54 } 55 if (shape == "TRAP") { 55 if (shape == "TRAP") { 56 for (G4int i=0;i<11;i++) { 56 for (G4int i=0;i<11;i++) { 57 if (i != 1 && i != 2 && i != 6 && i != 57 if (i != 1 && i != 2 && i != 6 && i != 10) { 58 if (rpar[i]<0) { 58 if (rpar[i]<0) { 59 if (rparm != 0) rpar[i] = rparm[i] 59 if (rparm != 0) rpar[i] = rparm[i]; 60 if (rpar[i] < 0) NegPresent = TRUE; 60 if (rpar[i] < 0) NegPresent = TRUE; 61 } 61 } 62 } 62 } 63 } 63 } 64 } 64 } 65 if (shape == "TUBE" || shape == "TUBS" || 65 if (shape == "TUBE" || shape == "TUBS" || shape == "PARA") { 66 for (G4int i=0;i<3;i++) { 66 for (G4int i=0;i<3;i++) { 67 if (rpar[i] < 0) { 67 if (rpar[i] < 0) { 68 if (rparm != 0) rpar[i] = rparm[i]; 68 if (rparm != 0) rpar[i] = rparm[i]; 69 if (rpar[i] < 0) NegPresent = TRUE; 69 if (rpar[i] < 0) NegPresent = TRUE; 70 } 70 } 71 } 71 } 72 } 72 } 73 if (shape == "CONE" || shape == "CONS") { 73 if (shape == "CONE" || shape == "CONS") { 74 for (G4int i=0;i<5;i++) { 74 for (G4int i=0;i<5;i++) { 75 if (rpar[i] < 0) { 75 if (rpar[i] < 0) { 76 if (rparm != 0) rpar[i] = rparm[i]; 76 if (rparm != 0) rpar[i] = rparm[i]; 77 if (rpar[i] < 0) NegPresent = TRUE; 77 if (rpar[i] < 0) NegPresent = TRUE; 78 } 78 } 79 } 79 } 80 } 80 } 81 if (shape == "SPHE") { 81 if (shape == "SPHE") { 82 for (G4int i=0;i<2;i++) { 82 for (G4int i=0;i<2;i++) { 83 if (rpar[i] < 0) { 83 if (rpar[i] < 0) { 84 if (rparm != 0) rpar[i] = rparm[i]; 84 if (rparm != 0) rpar[i] = rparm[i]; 85 if (rpar[i] < 0) NegPresent = TRUE; 85 if (rpar[i] < 0) NegPresent = TRUE; 86 } 86 } 87 } 87 } 88 } 88 } 89 if (shape == "PGON") { 89 if (shape == "PGON") { 90 G4int nz = G4int(rpar[3]); 90 G4int nz = G4int(rpar[3]); 91 G4int ipl; 91 G4int ipl; 92 for (G4int i=0;i<nz;i++) { 92 for (G4int i=0;i<nz;i++) { 93 ipl = 5 + i*3; 93 ipl = 5 + i*3; 94 if (rpar[ipl] < 0) { 94 if (rpar[ipl] < 0) { 95 if (rparm != 0) rpar[ipl] = rparm[ip 95 if (rparm != 0) rpar[ipl] = rparm[ipl]; 96 if (rpar[ipl] < 0) NegPresent = TRUE; 96 if (rpar[ipl] < 0) NegPresent = TRUE; 97 } 97 } 98 if (rpar[ipl+1] < 0) { 98 if (rpar[ipl+1] < 0) { 99 if (rparm != 0) rpar[ipl] = rparm[i 99 if (rparm != 0) rpar[ipl] = rparm[ipl]; 100 if (rpar[ipl] < 0) NegPresent = TRUE; 100 if (rpar[ipl] < 0) NegPresent = TRUE; 101 } 101 } 102 } 102 } 103 } 103 } 104 if (shape == "PCON") { 104 if (shape == "PCON") { 105 G4int nz = G4int(rpar[2]); 105 G4int nz = G4int(rpar[2]); 106 G4int ipl; 106 G4int ipl; 107 for (G4int i=0;i<nz;i++) { 107 for (G4int i=0;i<nz;i++) { 108 ipl = 4 + i*3; 108 ipl = 4 + i*3; 109 if (rpar[ipl] < 0) { 109 if (rpar[ipl] < 0) { 110 if (rparm != 0) rpar[ipl] = rparm[ip 110 if (rparm != 0) rpar[ipl] = rparm[ipl]; 111 if (rpar[ipl] < 0) NegPresent = TRUE; 111 if (rpar[ipl] < 0) NegPresent = TRUE; 112 } 112 } 113 if (rpar[ipl+1] < 0) { 113 if (rpar[ipl+1] < 0) { 114 // TO DO 114 // TO DO 115 // check - folowing argument might be ipl+ 115 // check - folowing argument might be ipl+1 116 if (rparm != 0) rpar[ipl] = rparm[ip 116 if (rparm != 0) rpar[ipl] = rparm[ipl]; 117 if (rpar[ipl] < 0) NegPresent = TRUE; 117 if (rpar[ipl] < 0) NegPresent = TRUE; 118 } 118 } 119 } 119 } 120 } 120 } 121 } 121 } 122 122 123 if (shape == "BOX") { 123 if (shape == "BOX") { 124 if (shapem == "TRD1") { 124 if (shapem == "TRD1") { 125 if (rpar[1] < 0) { 125 if (rpar[1] < 0) { 126 if (rparm != 0) rpar[1] = rparm[2]; 126 if (rparm != 0) rpar[1] = rparm[2]; 127 if (rpar[1] < 0) NegPresent = TRUE; 127 if (rpar[1] < 0) NegPresent = TRUE; 128 } 128 } 129 if (rpar[2] < 0) { 129 if (rpar[2] < 0) { 130 if (rparm != 0) rpar[2] = rparm[3]; 130 if (rparm != 0) rpar[2] = rparm[3]; 131 if (rpar[2] < 0) NegPresent = TRUE; 131 if (rpar[2] < 0) NegPresent = TRUE; 132 } 132 } 133 if (rpar[0] < 0) { 133 if (rpar[0] < 0) { 134 if (rparm != 0) rpar[0] = std::min(rpa 134 if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) + 135 std::abs(rpa 135 std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[3]; 136 if (rpar[0] < 0) NegPresent = TRUE; 136 if (rpar[0] < 0) NegPresent = TRUE; 137 } 137 } 138 } 138 } 139 if (shapem == "TRD2") { 139 if (shapem == "TRD2") { 140 if (rpar[2] < 0) { 140 if (rpar[2] < 0) { 141 if (rparm != 0) rpar[2] = rparm[4]; 141 if (rparm != 0) rpar[2] = rparm[4]; 142 if (rpar[2]<0) NegPresent = TRUE; 142 if (rpar[2]<0) NegPresent = TRUE; 143 } 143 } 144 if (rpar[0] < 0) { 144 if (rpar[0] < 0) { 145 if (rparm != 0) rpar[0] = std::min(rpa 145 if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) + 146 std::abs(rpa 146 std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[4]; 147 if (rpar[0]<0) NegPresent = TRUE; 147 if (rpar[0]<0) NegPresent = TRUE; 148 } 148 } 149 if (rpar[1] < 0) { 149 if (rpar[1] < 0) { 150 if (rparm != 0) rpar[1] = std::min(rpa 150 if (rparm != 0) rpar[1] = std::min(rparm[2],rparm[3]) + 151 std::abs(rpa 151 std::abs(rparm[2]-rparm[3])*.5*rpar[2]/rparm[4]; 152 if (rpar[1]<0) NegPresent = TRUE; 152 if (rpar[1]<0) NegPresent = TRUE; 153 } 153 } 154 } 154 } 155 if (shapem == "TRAP") { 155 if (shapem == "TRAP") { 156 if (rpar[2] < 0) { 156 if (rpar[2] < 0) { 157 if (rparm != 0) rpar[2] = rparm[0]; 157 if (rparm != 0) rpar[2] = rparm[0]; 158 if (rpar[2] < 0) NegPresent = TRUE; 158 if (rpar[2] < 0) NegPresent = TRUE; 159 } 159 } 160 if (rpar[0] < 0) { 160 if (rpar[0] < 0) { 161 if (rparm != 0) { 161 if (rparm != 0) { 162 G4double xlo = std::min(rparm[4],rpa 162 G4double xlo = std::min(rparm[4],rparm[8]) + 163 std::abs(rparm[4]-rparm[8])*.5*rpa 163 std::abs(rparm[4]-rparm[8])*.5*rpar[2]/rparm[0]; 164 G4double xhi = std::min(rparm[5],rpa 164 G4double xhi = std::min(rparm[5],rparm[9]) + 165 std::abs(rparm[5]-rparm[9])*.5*rpa 165 std::abs(rparm[5]-rparm[9])*.5*rpar[2]/rparm[0]; 166 rpar[0] = std::min(xlo,xhi); 166 rpar[0] = std::min(xlo,xhi); 167 } 167 } 168 if (rpar[0] < 0) NegPresent = TRUE; 168 if (rpar[0] < 0) NegPresent = TRUE; 169 } 169 } 170 if (rpar[1] < 0) { 170 if (rpar[1] < 0) { 171 if (rparm != 0) rpar[1] = std::min(rpa 171 if (rparm != 0) rpar[1] = std::min(rparm[3],rparm[7]) + 172 std::abs(rparm[3]-rpar 172 std::abs(rparm[3]-rparm[7])*.5*rpar[2]/rparm[0]; 173 if (rpar[1] < 0) NegPresent = TRUE; 173 if (rpar[1] < 0) NegPresent = TRUE; 174 } 174 } 175 } 175 } 176 } 176 } 177 return NegPresent; 177 return NegPresent; 178 } 178 } 179 179 180 G4bool G3NegVolPars(G4double pars[], G4int *np 180 G4bool G3NegVolPars(G4double pars[], G4int *nparpt, 181 G3VolTableEntry* vte, 181 G3VolTableEntry* vte, 182 G3VolTableEntry* mvte, con 182 G3VolTableEntry* mvte, const char routine[]) 183 { 183 { 184 G4bool NegPresent = FALSE; 184 G4bool NegPresent = FALSE; 185 185 186 // retrieve parameters 186 // retrieve parameters 187 187 188 // the volume 188 // the volume 189 G4String shape = vte->GetShape(); 189 G4String shape = vte->GetShape(); 190 G4double* rpar = vte->GetRpar(); 190 G4double* rpar = vte->GetRpar(); 191 G4int npar = vte->GetNpar(); 191 G4int npar = vte->GetNpar(); 192 if (npar ==0) { 192 if (npar ==0) { 193 // no solid parameters are defined in vte 193 // no solid parameters are defined in vte 194 npar = *nparpt; 194 npar = *nparpt; 195 rpar = pars; 195 rpar = pars; 196 } 196 } 197 else { 197 else { 198 // solid parameters are already defined in 198 // solid parameters are already defined in vte 199 // pars[], nparpt are ignored 199 // pars[], nparpt are ignored 200 // TO DO: check if g3 ignores them too or 200 // TO DO: check if g3 ignores them too or resets 201 // vte parameters according to this new on 201 // vte parameters according to this new ones !! 202 } 202 } 203 203 204 // mother 204 // mother 205 G4String shapem = mvte->GetShape(); 205 G4String shapem = mvte->GetShape(); 206 G4double* rparm = mvte->GetRpar(); 206 G4double* rparm = mvte->GetRpar(); 207 207 208 if (strcmp(routine,"GSPOS") == 0 || strcmp(r 208 if (strcmp(routine,"GSPOS") == 0 || strcmp(routine,"GSVOLU") == 0) { 209 NegPresent = G3CalcParamsFn(rpar,npar,rpar 209 NegPresent = G3CalcParamsFn(rpar,npar,rparm,shape,shapem); 210 } 210 } 211 if (strcmp(routine,"GSDVN") == 0) { 211 if (strcmp(routine,"GSDVN") == 0) { 212 // just set the flag. The parametrization 212 // just set the flag. The parametrization function figures out 213 // what to do. 213 // what to do. 214 for (G4int i=0;i<npar;i++) { 214 for (G4int i=0;i<npar;i++) { 215 if (rpar[i] < 0) { 215 if (rpar[i] < 0) { 216 NegPresent = TRUE; 216 NegPresent = TRUE; 217 } 217 } 218 } 218 } 219 } 219 } 220 return NegPresent; 220 return NegPresent; 221 } 221 } 222 222