GEARS
Geant4 Example Application with Rich features and Small footprints
Public Member Functions | Public Attributes | List of all members
LineProcessor Class Reference

Extension to default text geometry file line processor. More...

Inheritance diagram for LineProcessor:
Inheritance graph
[legend]
Collaboration diagram for LineProcessor:
Collaboration graph
[legend]

Public Member Functions

 LineProcessor ()
 
 ~LineProcessor ()
 
G4bool ProcessLine (const vector< G4String > &words)
 Overwrite G4tgrLineProcessor::ProcessLine to add new tags. More...
 

Public Attributes

BorderSurfaceBorder
 pointer to a BorderSurface object More...
 

Detailed Description

Extension to default text geometry file line processor.

Definition at line 173 of file gears.cc.

Constructor & Destructor Documentation

◆ LineProcessor()

LineProcessor::LineProcessor ( )
inline

Definition at line 179 of file gears.cc.

179 : G4tgrLineProcessor(), Border(0) {};
BorderSurface * Border
pointer to a BorderSurface object
Definition: gears.cc:199

◆ ~LineProcessor()

LineProcessor::~LineProcessor ( )
inline

Definition at line 180 of file gears.cc.

180  {
181  while (Border) { // deleting G4OpticalSurface is done in Geant4
182  BorderSurface *next=Border->next;
183  delete Border;
184  Border=next;
185  }
186  }
BorderSurface * Border
pointer to a BorderSurface object
Definition: gears.cc:199
A link list of G4LogicalBorderSurface.
Definition: gears.cc:159
BorderSurface * next
link to next border surface
Definition: gears.cc:165

Member Function Documentation

◆ ProcessLine()

G4bool LineProcessor::ProcessLine ( const vector< G4String > &  words)

Overwrite G4tgrLineProcessor::ProcessLine to add new tags.

Two new tags are added: ":PROP" and ":SURF" (case insensitive):

  • ":prop" is used to add optical properties to a material
  • ":surf" is used to define an optical surface

The function is called for each new line. Be sure to insert an end-of-line character by typing <Enter> at the end of the last line, otherwise, the last line will not be processed.

Definition at line 206 of file gears.cc.

207 {
208  // process default text geometry tags
209  G4bool processed = G4tgrLineProcessor::ProcessLine(words);
210  if (processed) return true; // no new tags involved
211 
212  // process added tags: prop & surf
213  G4String tag = words[0]; G4StrUtil::to_lower(tag); // to lower cases
214  if (tag.substr(0,5)==":prop") { // set optical properties of a material
215  G4NistManager *mgr = G4NistManager::Instance(); mgr->SetVerbose(2);
216  G4Material *m = mgr->FindOrBuildMaterial(words[1]);
217  if (m==NULL) // if not in NIST, then build in tgb
218  m=G4tgbMaterialMgr::GetInstance()->FindOrBuildG4Material(words[1]);
219  G4cout<<"GEARS: Set optical properties of "<<words[1]<<":"<<G4endl;
220  m->SetMaterialPropertiesTable(CreateMaterialPropertiesTable(words,2));
221  return true;
222  } else if (tag.substr(0,5)==":surf") { // define an optical surface
223  auto bdr = new BorderSurface;
224  bdr->next=Border; // save current border pointer
225  Border=bdr; // overwrite current border pointer
226  bdr->name=words[1];
227  bdr->v1=words[2];
228  bdr->v2=words[3];
229  bdr->optic = new G4OpticalSurface(words[1]);
230  size_t i=4;
231  // loop over optical surface setup lines
232  while (i<words.size()) {
233  G4String setting = words[i], value = words[i+1];
234  G4StrUtil::to_lower(setting); G4StrUtil::to_lower(value);
235  if (setting=="property") {
236  i++; break;
237  } else if (setting=="type") {
238  if (value=="dielectric_metal") bdr->optic->SetType(dielectric_metal);
239  else if (value=="dielectric_dielectric")
240  bdr->optic->SetType(dielectric_dielectric);
241  else if (value=="firsov") bdr->optic->SetType(firsov);
242  else if (value=="x_ray") bdr->optic->SetType(x_ray);
243  else G4cout<<"GERAS: Ignore unknown surface type "<<value<<G4endl;
244  } else if (setting=="model") {
245  if (value=="glisur") bdr->optic->SetModel(glisur);
246  else if (value=="unified") bdr->optic->SetModel(unified);
247  else G4cout<<"GERAS: Ignore unknown surface model "<<value<<G4endl;
248  } else if (setting=="finish") {
249  G4cout<<"GERAS: Set surface finish to be "<<value<<G4endl;
250  if (value=="polished") bdr->optic->SetFinish(polished);
251  else if (value=="polishedfrontpainted")
252  bdr->optic->SetFinish(polishedfrontpainted);
253  else if (value=="polishedbackpainted")
254  bdr->optic->SetFinish(polishedbackpainted);
255  else if (value=="ground") bdr->optic->SetFinish(ground);
256  else if (value=="groundfrontpainted")
257  bdr->optic->SetFinish(groundfrontpainted);
258  else if (value=="groundbackpainted")
259  bdr->optic->SetFinish(groundbackpainted);
260  else {
261  G4cout<<"GERAS: Unknown surface finish: "<<value<<"!"<<G4endl;
262  abort();
263  }
264  } else if (setting=="sigma_alpha") {
265  bdr->optic->SetSigmaAlpha(G4UIcommand::ConvertToInt(value));
266  } else
267  G4cout<<"GERAS: Ignore unknown surface setting "<<value<<G4endl;
268  i+=2;
269  }
270  if (i<words.size()) { // break while loop because of "property"
271  G4cout<<"GEARS: Set optical properties of "<<bdr->name<<":"<<G4endl;
272  bdr->optic->SetMaterialPropertiesTable(
273  CreateMaterialPropertiesTable(words,i));
274  }
275  return true;
276  } else
277  return false;
278 }
BorderSurface * Border
pointer to a BorderSurface object
Definition: gears.cc:199
A link list of G4LogicalBorderSurface.
Definition: gears.cc:159
G4String name
name of the surface
Definition: gears.cc:161
BorderSurface * next
link to next border surface
Definition: gears.cc:165

Member Data Documentation

◆ Border

BorderSurface* LineProcessor::Border

pointer to a BorderSurface object

Definition at line 199 of file gears.cc.


The documentation for this class was generated from the following file: