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

Last change on this file since 1035 was 1035, checked in by garnier, 15 years ago

dossiers oublies

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    }
161    mate->SetIonisationMeanExcitationEnergy( G4tgrUtils::GetDouble( wl[2] ) );
162
163    //------------------------------- solid
164  }
165  else if( wl0 == ":SOLID" )
166  {                      // called from here or from G4tgrVolume::G4tgrVolume
167    volmgr->CreateSolid( wl, 0 );
168
169    //------------------------------- volume
170  }
171  else if( wl0 == ":VOLU" )
172  {
173    G4tgrVolume* vol = new G4tgrVolume( wl );
174    volmgr->RegisterMe( vol );
175   
176    //--------------------------------- single placement
177  }
178  else if( wl0 == ":PLACE" )
179  {
180    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
181    G4tgrPlace* vpl = vol->AddPlace( wl );
182    volmgr->RegisterMe( vpl );
183   
184    //--------------------------------- parameterisation
185  }
186  else if( wl0 == ":PLACE_PARAM" )
187  {
188    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
189    G4tgrPlaceParameterisation* vpl = vol->AddPlaceParam( wl );
190    volmgr->RegisterMe( vpl );
191
192    //--------------------------------- division
193  }
194  else if( (wl0 == ":DIV_NDIV") || (wl0 == ":DIV_WIDTH")
195        || (wl0 == ":DIV_NDIV_WIDTH") )
196  {
197    //---------- Create G4tgrVolumeDivision and fill the volume params
198    G4tgrVolumeDivision* vol = new G4tgrVolumeDivision( wl );
199    volmgr->RegisterMe( vol );
200
201    //--------------------------------- replica
202  }
203  else if( wl0 == ":REPL" )
204  {
205    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
206    G4tgrPlaceDivRep* vpl = vol->AddPlaceReplica( wl );
207    volmgr->RegisterMe( vpl );
208   
209    //----------------------------- assembly volume: definition of components
210  }
211  else if( wl0 == ":VOLU_ASSEMBLY" )
212  {
213    G4tgrVolumeAssembly* vol = new G4tgrVolumeAssembly( wl );
214    volmgr->RegisterMe( vol );
215   
216    //----------------------------- assembly volume: definition of components
217  }
218  else if( wl0 == ":PLACE_ASSEMBLY" )
219  {
220    G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
221    G4tgrPlace* vpl = vol->AddPlace( wl );
222    volmgr->RegisterMe( vpl );
223
224    //---------------------------------  rotation matrix
225  }
226  else if( wl0 == ":ROTM" )
227  {
228    //---------- When second word is ':NEXT/:MNXT' it is used for defining a
229    //           rotation matrix that will be used for the next placement/s
230    G4tgrRotationMatrix* rm = G4tgrRotationMatrixFactory::GetInstance()
231                            ->AddRotMatrix( wl );
232    volmgr->RegisterMe( rm );
233   
234    //------------------------------- visualisation
235  }
236  else if( wl0 == ":VIS" )
237  {
238    std::vector<G4tgrVolume*> vols =
239       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
240    for( size_t ii = 0; ii < vols.size(); ii++ )
241    {
242      vols[ii]->AddVisibility( wl );
243    }
244
245    //--------------------------------- colour
246  }
247  else if( (wl0 == ":COLOUR") || (wl0 == ":COLOR") )
248  {
249    std::vector<G4tgrVolume*> vols =
250       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
251    for( size_t ii = 0; ii < vols.size(); ii++ )
252    {
253      vols[ii]->AddRGBColour( wl );
254    }
255
256    //--------------------------------- check overlaps
257  }
258  else if( wl0 == ":CHECK_OVERLAPS" )
259  {
260    std::vector<G4tgrVolume*> vols =
261       volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
262    for( size_t ii = 0; ii < vols.size(); ii++ )
263    {
264      vols[ii]->AddCheckOverlaps( wl );
265    }
266    //--------------------------------- ERROR
267  }
268  else
269  {
270    return 0;
271  } 
272
273  return 1;
274}
275
276
277//---------------------------------------------------------------
278G4tgrVolume* G4tgrLineProcessor::FindVolume( const G4String& volname )
279{
280  G4tgrVolume* vol=0;
281
282  G4tgrVolume* volt = volmgr->FindVolume( volname, 1);
283
284  if( volt->GetType() == "VOLDivision" )
285  {
286    G4Exception("G4tgrLineProcessor::FindVolume()",
287                "InvalidSetup", FatalException,
288                "Using 'PLACE' for a volume created by a division !");
289  }
290  else
291  { 
292    vol = (G4tgrVolume*)volt;
293  }
294
295  return vol;
296}
Note: See TracBrowser for help on using the repository browser.