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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /g3tog4/src/G3NegVolPars.cc (Version 11.3.0) and /g3tog4/src/G3NegVolPars.cc (Version 8.3.p1)


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