G3NegVolPars.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$ 
00028 //
00029 // modified by I. Hrivnacova, 13.10.99 
00030 
00031 #include "globals.hh"
00032 #include "G3VolTable.hh"
00033 #include "G4VSolid.hh"
00034 #include "G3toG4.hh"
00035 #include <cmath>
00036 
00037 G4bool G3CalcParamsFn(G4double *rpar, G4int npar, G4double *rparm,
00038                       G4String shape, G4String shapem)
00039   // Returns true only in case the parameters *after* processing
00040   // this method remain negative.
00041 {
00042   G4bool NegPresent = FALSE;
00043   // for normal single volume positioning, just substitute for the
00044   // negative parameters
00045   // treat only the legal cases
00046   if (shapem == shape) {
00047     if (shape == "BOX" || shape == "TRD1" || shape == "TRD2" || 
00048         shape == "ELTU") {
00049       for (G4int i=0;i<npar;i++) {
00050         if (rpar[i] < 0) {
00051           if (rparm != 0) rpar[i] = rparm[i];
00052           if (rpar[i] < 0) NegPresent = TRUE;
00053         }
00054       }
00055     }
00056     if (shape == "TRAP") {
00057       for (G4int i=0;i<11;i++) {
00058         if (i != 1 && i != 2 && i != 6 && i != 10) {
00059           if (rpar[i]<0) {
00060             if (rparm != 0) rpar[i] = rparm[i];
00061             if (rpar[i] < 0) NegPresent = TRUE;
00062           }  
00063         }
00064       }
00065     }
00066     if (shape == "TUBE" || shape == "TUBS" || shape == "PARA") {
00067       for (G4int i=0;i<3;i++) {
00068         if (rpar[i] < 0) {
00069           if (rparm != 0) rpar[i] = rparm[i];
00070           if (rpar[i] < 0) NegPresent = TRUE;
00071         }
00072       }
00073     }
00074     if (shape == "CONE" || shape == "CONS") {
00075       for (G4int i=0;i<5;i++) {
00076         if (rpar[i] < 0) {
00077           if (rparm != 0) rpar[i] = rparm[i];
00078           if (rpar[i] < 0) NegPresent = TRUE;
00079         }
00080       }
00081     }
00082     if (shape == "SPHE") {
00083       for (G4int i=0;i<2;i++) {
00084         if (rpar[i] < 0) {
00085           if (rparm != 0) rpar[i] = rparm[i];
00086           if (rpar[i] < 0) NegPresent = TRUE;
00087         }
00088       }
00089     }
00090     if (shape == "PGON") {
00091       G4int nz = G4int(rpar[3]);
00092       G4int ipl;
00093       for (G4int i=0;i<nz;i++) {
00094         ipl = 5 + i*3;
00095         if (rpar[ipl] < 0) {
00096           if (rparm != 0) rpar[ipl] = rparm[ipl];
00097           if (rpar[ipl] < 0) NegPresent = TRUE;
00098         }
00099         if (rpar[ipl+1] < 0) {
00100           if (rparm != 0)  rpar[ipl] = rparm[ipl];
00101           if (rpar[ipl] < 0) NegPresent = TRUE;
00102         }
00103       }
00104     }
00105     if (shape == "PCON") {
00106       G4int nz = G4int(rpar[2]);
00107       G4int ipl;
00108       for (G4int i=0;i<nz;i++) {
00109         ipl = 4 + i*3;
00110         if (rpar[ipl] < 0) {
00111           if (rparm != 0) rpar[ipl] = rparm[ipl];
00112           if (rpar[ipl] < 0) NegPresent = TRUE;
00113         }
00114         if (rpar[ipl+1] < 0) {
00115           // TO DO
00116           // check - folowing argument might be ipl+1
00117           if (rparm != 0) rpar[ipl] = rparm[ipl];
00118           if (rpar[ipl] < 0) NegPresent = TRUE;
00119         }
00120       }
00121     }
00122   }
00123 
00124   if (shape == "BOX") {
00125     if (shapem == "TRD1") {
00126       if (rpar[1] < 0) {
00127         if (rparm != 0) rpar[1] = rparm[2];
00128         if (rpar[1] < 0) NegPresent = TRUE;
00129       }
00130       if (rpar[2] < 0) {
00131         if (rparm != 0) rpar[2] = rparm[3];
00132         if (rpar[2] < 0) NegPresent = TRUE;
00133       }
00134       if (rpar[0] < 0) {
00135         if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) +
00136                                   std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[3];
00137         if (rpar[0] < 0) NegPresent = TRUE;
00138       }
00139     }
00140     if (shapem == "TRD2") {
00141       if (rpar[2] < 0) {
00142         if (rparm != 0) rpar[2] = rparm[4];
00143         if (rpar[2]<0) NegPresent = TRUE;
00144       }
00145       if (rpar[0] < 0) {
00146         if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) +
00147                                   std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[4];
00148         if (rpar[0]<0) NegPresent = TRUE;
00149       }
00150       if (rpar[1] < 0) {
00151         if (rparm != 0) rpar[1] = std::min(rparm[2],rparm[3]) +
00152                                   std::abs(rparm[2]-rparm[3])*.5*rpar[2]/rparm[4];
00153         if (rpar[1]<0) NegPresent = TRUE;
00154       }
00155     }
00156     if (shapem == "TRAP") {
00157       if (rpar[2] < 0) {
00158         if (rparm != 0) rpar[2] = rparm[0];
00159         if (rpar[2] < 0) NegPresent = TRUE;
00160       }
00161       if (rpar[0] < 0) {
00162         if (rparm != 0) {
00163           G4double xlo = std::min(rparm[4],rparm[8]) +
00164             std::abs(rparm[4]-rparm[8])*.5*rpar[2]/rparm[0];
00165           G4double xhi = std::min(rparm[5],rparm[9]) +
00166             std::abs(rparm[5]-rparm[9])*.5*rpar[2]/rparm[0];
00167           rpar[0] = std::min(xlo,xhi);
00168         }
00169         if (rpar[0] < 0) NegPresent = TRUE;
00170       }
00171       if (rpar[1] < 0) {
00172         if (rparm != 0) rpar[1] = std::min(rparm[3],rparm[7]) +
00173                         std::abs(rparm[3]-rparm[7])*.5*rpar[2]/rparm[0];
00174         if (rpar[1] < 0) NegPresent = TRUE;
00175       }
00176     }
00177   }
00178   return NegPresent;
00179 }
00180 
00181 G4bool G3NegVolPars(G4double pars[], G4int *nparpt,
00182                     G3VolTableEntry* vte,
00183                     G3VolTableEntry* mvte, const char routine[])
00184 {
00185   G4bool NegPresent = FALSE;
00186 
00187   // retrieve parameters 
00188 
00189   // the volume
00190   G4String shape = vte->GetShape();
00191   G4double* rpar = vte->GetRpar();
00192   G4int npar = vte->GetNpar();  
00193   if (npar ==0) {
00194     // no solid parameters are defined in vte
00195     npar = *nparpt;
00196     rpar = pars;
00197   }
00198   else {  
00199     // solid parameters are already defined in vte
00200     // pars[], nparpt are ignored
00201     // TO DO: check if g3 ignores them too or resets
00202     // vte parameters according to this new ones !!
00203   }  
00204       
00205   // mother
00206   G4String shapem = mvte->GetShape();
00207   G4double* rparm = mvte->GetRpar();
00208 
00209   if (strcmp(routine,"GSPOS") == 0 || strcmp(routine,"GSVOLU") == 0) {
00210     NegPresent = G3CalcParamsFn(rpar,npar,rparm,shape,shapem);
00211   }
00212   if (strcmp(routine,"GSDVN") == 0) {
00213     // just set the flag. The parametrization function figures out
00214     // what to do.
00215     for (G4int i=0;i<npar;i++) {
00216       if (rpar[i] < 0) {
00217         NegPresent = TRUE;
00218       }
00219     }
00220   }
00221   return NegPresent;
00222 }

Generated on Mon May 27 17:47:35 2013 for Geant4 by  doxygen 1.4.7