source: trunk/source/persistency/ascii/src/G4tgrLineProcessor.cc @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 9.4 KB
Line 
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//
27//
28// class G4tgrLineProcessor
29
30// History:
31// - Created.                                 P.Arce, CIEMAT (November 2007)
32// -------------------------------------------------------------------------
33
34#include "G4tgrLineProcessor.hh"
35#include "G4tgrParameterMgr.hh"
36#include "G4tgrFileIn.hh"
37#include "G4tgrElementSimple.hh"
38#include "G4tgrElementFromIsotopes.hh"
39#include "G4tgrVolume.hh"
40#include "G4tgrVolumeDivision.hh"
41#include "G4tgrVolumeAssembly.hh"
42#include "G4tgrPlaceDivRep.hh"
43#include "G4tgrPlaceParameterisation.hh"
44#include "G4tgrVolumeMgr.hh"
45#include "G4tgrUtils.hh"
46#include "G4tgrMaterialFactory.hh"
47#include "G4tgrRotationMatrixFactory.hh"
48#include "G4tgrMessenger.hh"
49
50
51//---------------------------------------------------------------
52G4tgrLineProcessor::G4tgrLineProcessor()
53{
54  volmgr = G4tgrVolumeMgr::GetInstance();
55}
56
57
58//---------------------------------------------------------------
59G4tgrLineProcessor::~G4tgrLineProcessor()
60{
61}
62
63
64//---------------------------------------------------------------
65G4bool G4tgrLineProcessor::ProcessLine( const std::vector<G4String>& wl )
66{
67#ifdef G4VERBOSE
68  if( G4tgrMessenger::GetVerboseLevel() >= 1 )
69  {
70    G4tgrUtils::DumpVS(wl, "@@@ Processing input line");
71  }
72#endif 
73
74  G4String wl0 = wl[0];
75  for( size_t ii = 0; ii < wl0.length(); ii++ )
76  {
77    wl0[ii] = toupper( wl0[ii] );
78  }
79
80  //------------------------------- parameter number
81  if( wl0 == ":P" )
82  {
83    G4tgrParameterMgr::GetInstance()->AddParameterNumber( wl );
84   
85  //------------------------------- parameter string
86  }
87  else if( wl0 == ":PS" )
88  {
89    G4tgrParameterMgr::GetInstance()->AddParameterString( wl );
90
91  //------------------------------- isotope
92  }
93  else if( wl0 == ":ISOT" )
94  {
95    G4tgrIsotope* isot = G4tgrMaterialFactory::GetInstance()
96                       ->AddIsotope( wl );
97    volmgr->RegisterMe( isot );
98
99  //------------------------------- element
100  }
101  else if( wl0 == ":ELEM" )
102  {
103    G4tgrElementSimple* elem = G4tgrMaterialFactory::GetInstance()
104                             ->AddElementSimple( wl );
105    volmgr->RegisterMe( elem );
106
107  //------------------------------- element from isotopes
108  }
109  else if( wl0 == ":ELEM_FROM_ISOT" )
110  {
111    //:ELEM_FROM_ISOT NAME SYMBOL N_ISOT (ISOT_NAME ISOT_ABUNDANCE)
112    G4tgrElementFromIsotopes* elem = G4tgrMaterialFactory::GetInstance()
113                                   ->AddElementFromIsotopes( wl );
114    volmgr->RegisterMe( elem );
115   
116  //------------------------------- material
117  }
118  else if( wl0 == ":MATE" )
119  {
120
121    G4tgrMaterialSimple* mate = G4tgrMaterialFactory::GetInstance()
122                              ->AddMaterialSimple( wl );
123    volmgr->RegisterMe( mate );
124   
125    //------------------------------- material mixtures & by weight
126  }
127  else if( (wl0 == ":MIXT") || (wl0 == ":MIXT_BY_WEIGHT") )
128  {
129    G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
130                          ->AddMaterialMixture( wl, "MaterialMixtureByWeight" );
131    volmgr->RegisterMe( mate );
132
133    //------------------------------- material mixture by number of atoms
134  }
135  else if( wl0 == ":MIXT_BY_NATOMS" )
136  {
137    G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
138                          ->AddMaterialMixture(wl, "MaterialMixtureByNoAtoms");
139    volmgr->RegisterMe( mate );
140
141    //------------------------------- material mixture by volume
142  }
143  else if( wl0 == ":MIXT_BY_VOLUME" )
144  {
145    G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
146                          ->AddMaterialMixture( wl, "MaterialMixtureByVolume" );
147    volmgr->RegisterMe( mate );
148
149    //------------------------------- material Mean Excitation Energy of
150    //                                Ionisation Potential
151  }
152  else if( wl0 == ":MATE_MEE" )
153  {
154    G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()
155                        ->FindMaterial( G4tgrUtils::GetString( wl[1] ) );
156    if( mate == 0 )
157    {
158      G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
159                  FatalException, G4tgrUtils::GetString( wl[1] ) );
160      return false;
161    }
162    mate->SetIonisationMeanExcitationEnergy( G4tgrUtils::GetDouble( wl[2] ) );
163
164    //------------------------------- solid
165  }
166  else if( wl0 == ":SOLID" )
167  {                      // called from here or from G4tgrVolume::G4tgrVolume
168    volmgr->CreateSolid( wl, 0 );
169
170    //------------------------------- volume
171  }
172  else if( wl0 == ":VOLU" )
173  {
174    G4tgrVolume* vol = new G4tgrVolume( wl );
175    volmgr->RegisterMe( vol );
176   
177    //--------------------------------- single placement
178  }
179  else if( wl0 == ":PLACE" )
180  {
181    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
182    G4tgrPlace* vpl = vol->AddPlace( wl );
183    volmgr->RegisterMe( vpl );
184   
185    //--------------------------------- parameterisation
186  }
187  else if( wl0 == ":PLACE_PARAM" )
188  {
189    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
190    G4tgrPlaceParameterisation* vpl = vol->AddPlaceParam( wl );
191    volmgr->RegisterMe( vpl );
192
193    //--------------------------------- division
194  }
195  else if( (wl0 == ":DIV_NDIV") || (wl0 == ":DIV_WIDTH")
196        || (wl0 == ":DIV_NDIV_WIDTH") )
197  {
198    //---------- Create G4tgrVolumeDivision and fill the volume params
199    G4tgrVolumeDivision* vol = new G4tgrVolumeDivision( wl );
200    volmgr->RegisterMe( vol );
201
202    //--------------------------------- replica
203  }
204  else if( wl0 == ":REPL" )
205  {
206    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
207    G4tgrPlaceDivRep* vpl = vol->AddPlaceReplica( wl );
208    volmgr->RegisterMe( vpl );
209   
210    //----------------------------- assembly volume: definition of components
211  }
212  else if( wl0 == ":VOLU_ASSEMBLY" )
213  {
214    G4tgrVolumeAssembly* vol = new G4tgrVolumeAssembly( wl );
215    volmgr->RegisterMe( vol );
216   
217    //----------------------------- assembly volume: definition of components
218  }
219  else if( wl0 == ":PLACE_ASSEMBLY" )
220  {
221    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
222    G4tgrPlace* vpl = vol->AddPlace( wl );
223    volmgr->RegisterMe( vpl );
224
225    //---------------------------------  rotation matrix
226  }
227  else if( wl0 == ":ROTM" )
228  {
229    //---------- When second word is ':NEXT/:MNXT' it is used for defining a
230    //           rotation matrix that will be used for the next placement/s
231    G4tgrRotationMatrix* rm = G4tgrRotationMatrixFactory::GetInstance()
232                            ->AddRotMatrix( wl );
233    volmgr->RegisterMe( rm );
234   
235    //------------------------------- visualisation
236  }
237  else if( wl0 == ":VIS" )
238  {
239    std::vector<G4tgrVolume*> vols =
240       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
241    for( size_t ii = 0; ii < vols.size(); ii++ )
242    {
243      vols[ii]->AddVisibility( wl );
244    }
245
246    //--------------------------------- colour
247  }
248  else if( (wl0 == ":COLOUR") || (wl0 == ":COLOR") )
249  {
250    std::vector<G4tgrVolume*> vols =
251       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
252    for( size_t ii = 0; ii < vols.size(); ii++ )
253    {
254      vols[ii]->AddRGBColour( wl );
255    }
256
257    //--------------------------------- check overlaps
258  }
259  else if( wl0 == ":CHECK_OVERLAPS" )
260  {
261    std::vector<G4tgrVolume*> vols =
262       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
263    for( size_t ii = 0; ii < vols.size(); ii++ )
264    {
265      vols[ii]->AddCheckOverlaps( wl );
266    }
267    //--------------------------------- ERROR
268  }
269  else
270  {
271    return 0;
272  } 
273
274  return 1;
275}
276
277
278//---------------------------------------------------------------
279G4tgrVolume* G4tgrLineProcessor::FindVolume( const G4String& volname )
280{
281  G4tgrVolume* vol=0;
282
283  G4tgrVolume* volt = volmgr->FindVolume( volname, 1);
284
285  if( volt->GetType() == "VOLDivision" )
286  {
287    G4Exception("G4tgrLineProcessor::FindVolume()",
288                "InvalidSetup", FatalException,
289                "Using 'PLACE' for a volume created by a division !");
290  }
291  else
292  { 
293    vol = (G4tgrVolume*)volt;
294  }
295
296  return vol;
297}
Note: See TracBrowser for help on using the repository browser.