ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgrFileReader.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgrFileReader.cc
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 //
29 // class G4tgrFileReader
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
35 #include "G4tgrFileReader.hh"
36 #include "G4tgrParameterMgr.hh"
37 #include "G4tgrFileIn.hh"
38 #include "G4tgrElementSimple.hh"
40 #include "G4tgrVolume.hh"
41 #include "G4tgrPlaceDivRep.hh"
43 #include "G4tgrVolumeDivision.hh"
44 #include "G4tgrVolumeMgr.hh"
45 #include "G4tgrUtils.hh"
46 #include "G4tgrMaterialFactory.hh"
48 #include "G4tgrLineProcessor.hh"
49 #include "G4tgrMessenger.hh"
50 
51 
53 
54 
55 //---------------------------------------------------------------
57 {
59 }
60 
61 
62 //---------------------------------------------------------------
64 {
65  delete theLineProcessor;
66  delete theInstance;
67 }
68 
69 
70 //---------------------------------------------------------------
72 {
73  if( !theInstance ) {
75  }
76  return theInstance;
77 }
78 
79 //---------------------------------------------------------------
81 {
82 
83  std::vector< G4String > wl,wlnew;
84 
85 #ifdef G4VERBOSE
87  {
88  G4cout << " Number of geometry data files = " << theTextFiles.size()
89  << G4endl;
90  }
91 #endif
92 
93  if( theTextFiles.size() == 0 )
94  {
95  G4Exception("G4tgrFileReader::ReadFiles()", "InvalidInput",
96  FatalException, "No files to read ...");
97  }
98 
99  for( size_t ii = 0; ii < theTextFiles.size(); ii++ )
100  {
101 #ifdef G4VERBOSE
103  {
104  G4cout << " Reading data file " << theTextFiles[ii] << G4endl;
105  }
106 #endif
107 
109 
110  G4int nlines = 0;
111  for(;;)
112  {
113  nlines++;
114  if(! fin.GetWordsInLine( wlnew ) ) { break; }
115  // Check if it is continuation line or first line
116  if( wlnew[0].c_str()[0] != ':' )
117  {
118  wl.insert( wl.end(), wlnew.begin(), wlnew.end() );
119 #ifdef G4VERBOSE
121  {
122  G4tgrUtils::DumpVS(wl, "!!!! adding line");
123  }
124 #endif
125  continue;
126  }
127  else
128  {
129  //----- Process previous tag
130 #ifdef G4VERBOSE
132  {
133  G4tgrUtils::DumpVS(wl, "!!!! line read");
134  }
135 #endif
136  if( nlines != 1) // first line has no previous tag
137  {
138  if( ! theLineProcessor->ProcessLine( wl ) )
139  {
140  fin.DumpException( "Tag not found: " + wl[0]);
141  }
142  }
143  wl = wlnew;
144  }
145  }
146 
147  if( wl.size() != 0 )
148  {
149  if( ! theLineProcessor->ProcessLine( wl ) )
150  {
151  fin.DumpException( "Tag not found: " + wl[0]);
152  }
153  }
154  }
155  return 1;
156 }