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 163 of file gears.cc.

Constructor & Destructor Documentation

◆ LineProcessor()

LineProcessor::LineProcessor ( )
inline

Definition at line 169 of file gears.cc.

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

◆ ~LineProcessor()

LineProcessor::~LineProcessor ( )
inline

Definition at line 170 of file gears.cc.

170  {
171  while (Border) { // deleting G4OpticalSurface is done in Geant4
172  BorderSurface *next=Border->next;
173  delete Border;
174  Border=next;
175  }
176  }
BorderSurface * Border
pointer to a BorderSurface object
Definition: gears.cc:189
A link list of G4LogicalBorderSurface.
Definition: gears.cc:149
BorderSurface * next
link to next border surface
Definition: gears.cc:155

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 196 of file gears.cc.

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

Member Data Documentation

◆ Border

BorderSurface* LineProcessor::Border

pointer to a BorderSurface object

Definition at line 189 of file gears.cc.


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