Logo ROOT   6.12/07
Reference Guide
TGDMLParse.cxx
Go to the documentation of this file.
1 /* @(#)root/gdml:$Id$ */
2 // Author: Ben Lloyd 09/11/06
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 /** \class TGDMLParse
14 \ingroup Geometry_gdml
15 
16  This class contains the implementation of the GDML parser associated to
17  all the supported GDML elements. User should never need to explicitly
18  instaciate this class. It is internally used by the TGeoManager.
19 
20  Each element process has a 'Binding' to ROOT. The 'binding' is specific
21  mapping of GDML elements (materials, solids, etc) to specific objects which
22  should be instanciated by the converted. In the present case (ROOT) the
23  binding is implemented at the near the end of each process function. Most
24  bindings follow similar format, dependent on what is being added to the
25  geometry.
26 
27  This file also contains the implementation of the TGDMLRefl class. This is
28  just a small helper class used internally by the 'reflection' method (for
29  reflected solids).
30 
31  The presently supported list of TGeo classes is the following:
32 
33 #### Materials:
34  - TGeoElement
35  - TGeoMaterial
36  - TGeoMixture
37 
38 #### Solids:
39  - TGeoBBox
40  - TGeoArb8
41  - TGeoTubeSeg
42  - TGeoConeSeg
43  - TGeoCtub
44  - TGeoPcon
45  - TGeoTrap
46  - TGeoGtra
47  - TGeoTrd2
48  - TGeoSphere
49  - TGeoPara
50  - TGeoTorus
51  - TGeoHype
52  - TGeoPgon
53  - TGeoXtru
54  - TGeoEltu
55  - TGeoParaboloid
56  - TGeoCompositeShape (subtraction, union, intersection)
57 
58 #### Approximated Solids:
59  - Ellipsoid (approximated to a TGeoBBox)
60  - Elliptical cone (approximated to a TGeoCone)
61 
62 #### Geometry:
63  - TGeoVolume
64  - TGeoVolumeAssembly
65  - divisions
66  - reflection
67 
68 When most solids or volumes are added to the geometry they
69 
70 
71  Whenever a new element is added to GDML schema, this class needs to be extended.
72  The appropriate method (process) needs to be implemented, as well as the new
73  element process then needs to be linked thru the function TGDMLParse
74 
75  For any question or remarks concerning this code, please send an email to
76  ben.lloyd@cern.ch
77 
78 */
79 
80 #include "TGeoManager.h"
81 #include "TGeoMatrix.h"
82 #include "TXMLEngine.h"
83 #include "TGeoVolume.h"
84 #include "TGeoBBox.h"
85 #include "TGeoParaboloid.h"
86 #include "TGeoArb8.h"
87 #include "TGeoTube.h"
88 #include "TGeoCone.h"
89 #include "TGeoTrd2.h"
90 #include "TGeoPcon.h"
91 #include "TGeoPgon.h"
92 #include "TGeoSphere.h"
93 #include "TGeoTorus.h"
94 #include "TGeoPara.h"
95 #include "TGeoHype.h"
96 #include "TGeoEltu.h"
97 #include "TGeoXtru.h"
98 #include "TGeoScaledShape.h"
99 #include "TGeoVolume.h"
100 #include "TROOT.h"
101 #include "TMath.h"
102 #include "TMap.h"
103 #include "TObjString.h"
104 #include "TGeoExtension.h"
105 #include "TGeoMaterial.h"
106 #include "TGeoBoolNode.h"
107 #include "TGeoMedium.h"
108 #include "TGeoElement.h"
109 #include "TGeoShape.h"
110 #include "TGeoCompositeShape.h"
111 #include "TGeoRegion.h"
112 #include "TGDMLParse.h"
113 #include <stdlib.h>
114 #include <string>
115 #include <locale>
116 
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Creates the new instance of the XMLEngine called 'gdml', using the filename >>
121 /// then parses the file and creates the DOM tree. Then passes the DOM to the
122 /// next function to translate it.
123 
124 TGeoVolume* TGDMLParse::GDMLReadFile(const char* filename)
125 {
126  // First create engine
127  TXMLEngine* gdml = new TXMLEngine;
128  gdml->SetSkipComments(kTRUE);
129 
130  // Now try to parse xml file
131  XMLDocPointer_t gdmldoc = gdml->ParseFile(filename);
132  if (gdmldoc == 0) {
133  delete gdml;
134  return 0;
135  } else {
136 
137  // take access to main node
138  XMLNodePointer_t mainnode = gdml->DocGetRootElement(gdmldoc);
139 
140  fFileEngine[fFILENO] = gdml;
141  fStartFile = filename;
142  fCurrentFile = filename;
143 
144  // display recursively all nodes and subnodes
145  ParseGDML(gdml, mainnode);
146 
147  // Release memory before exit
148  gdml->FreeDoc(gdmldoc);
149  delete gdml;
150 
151  }
152  return fWorld;
153 
154 }
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// This function recursively moves thru the DOM tree of the GDML file. It checks for
158 /// key words along the way and if a key word is found it calls the corresponding
159 /// function to interpret the node.
160 
162 {
163  XMLAttrPointer_t attr = gdml->GetFirstAttr(node);
164  const char* name = gdml->GetNodeName(node);
165  XMLNodePointer_t parentn = gdml->GetParent(node);
166  const char* parent = gdml->GetNodeName(parentn);
167  XMLNodePointer_t childtmp = 0;
168 
169  const char* posistr = "position";
170  const char* setustr = "setup";
171  const char* consstr = "constant";
172  const char* varistr = "variable";
173  const char* rotastr = "rotation";
174  const char* scalstr = "scale";
175  const char* elemstr = "element";
176  const char* istpstr = "isotope";
177  const char* matestr = "material";
178  const char* volustr = "volume";
179  const char* assestr = "assembly";
180  const char* twtrstr = "twistedtrap"; //name changed according to schema
181  const char* cutTstr = "cutTube";
182  const char* bboxstr = "box";
183  const char* xtrustr = "xtru";
184  const char* arb8str = "arb8";
185  const char* tubestr = "tube";
186  const char* conestr = "cone";
187  const char* polystr = "polycone";
188  const char* hypestr = "hype";
189  const char* trapstr = "trap";
190  const char* trdstr = "trd";
191  const char* sphestr = "sphere";
192  const char* orbstr = "orb";
193  const char* parastr = "para";
194  const char* torustr = "torus";
195  const char* hedrstr = "polyhedra";
196  const char* eltustr = "eltube";
197  const char* subtstr = "subtraction";
198  const char* uniostr = "union";
199  const char* parbstr = "paraboloid";
200  const char* intestr = "intersection";
201  const char* reflstr = "reflectedSolid";
202  const char* ellistr = "ellipsoid";
203  const char* elcnstr = "elcone";
204  const char* usrstr = "userinfo";
205  Bool_t hasIsotopes;
206  Bool_t hasIsotopesExtended;
207 
208  if ((strcmp(name, posistr)) == 0) {
209  node = PosProcess(gdml, node, attr);
210  } else if ((strcmp(name, rotastr)) == 0) {
211  node = RotProcess(gdml, node, attr);
212  } else if ((strcmp(name, scalstr)) == 0) {
213  node = SclProcess(gdml, node, attr);
214  } else if ((strcmp(name, setustr)) == 0) {
215  node = TopProcess(gdml, node);
216  } else if ((strcmp(name, consstr)) == 0) {
217  node = ConProcess(gdml, node, attr);
218  } else if ((strcmp(name, varistr)) == 0) {
219  node = ConProcess(gdml, node, attr);
220  }
221  //*************eleprocess********************************
222 
223  else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, elemstr)) == 0)) {
224  hasIsotopes = kFALSE;
225  hasIsotopesExtended = kFALSE;
226  node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);
227  }
228  else if ((strcmp(name, elemstr) == 0) && !gdml->HasAttr(node, "Z")) {
229  hasIsotopes = kTRUE;
230  hasIsotopesExtended = kFALSE;
231  node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);
232  }
233 
234  else if ((strcmp(name, elemstr) == 0) && gdml->HasAttr(node, "Z")) {
235  childtmp = gdml->GetChild(node);
236  if ((strcmp(gdml->GetNodeName(childtmp), "fraction") == 0) ){
237  hasIsotopes = kFALSE;
238  hasIsotopesExtended = kTRUE;
239  node = EleProcess(gdml, node, parentn, hasIsotopes, hasIsotopesExtended);}
240  }
241 
242  //********isoprocess******************************
243 
244  else if (((strcmp(name, "atom")) == 0) && ((strcmp(parent, istpstr)) == 0)) {
245  node = IsoProcess(gdml, node, parentn);
246  }
247 
248  //********matprocess***********************************
249  else if ((strcmp(name, matestr)) == 0 && gdml->HasAttr(node, "Z")) {
250  childtmp = gdml->GetChild(node);
251 // if ((strcmp(gdml->GetNodeName(childtmp), "fraction") == 0) || (strcmp(gdml->GetNodeName(childtmp), "D") == 0)){
252  // Bool_t frac = kFALSE;
253  Bool_t atom = kFALSE;
254  while(childtmp) {
255  // frac = strcmp(gdml->GetNodeName(childtmp),"fraction")==0;
256  atom = strcmp(gdml->GetNodeName(childtmp),"atom")==0;
257  gdml->ShiftToNext(childtmp);
258  }
259  int z = (atom) ? 1 : 0;
260  node = MatProcess(gdml, node, attr, z);
261  }
262  else if ((strcmp(name, matestr)) == 0 && !gdml->HasAttr(node, "Z")) {
263  int z = 0;
264  node = MatProcess(gdml, node, attr, z);
265  }
266 
267  //*********************************************
268  else if ((strcmp(name, volustr)) == 0) {
269  node = VolProcess(gdml, node);
270  } else if ((strcmp(name, bboxstr)) == 0) {
271  node = Box(gdml, node, attr);
272  } else if ((strcmp(name, ellistr)) == 0) {
273  node = Ellipsoid(gdml, node, attr);
274  } else if ((strcmp(name, elcnstr)) == 0) {
275  node = ElCone(gdml, node, attr);
276  } else if ((strcmp(name, cutTstr)) == 0) {
277  node = CutTube(gdml, node, attr);
278  } else if ((strcmp(name, arb8str)) == 0) {
279  node = Arb8(gdml, node, attr);
280  } else if ((strcmp(name, tubestr)) == 0) {
281  node = Tube(gdml, node, attr);
282  } else if ((strcmp(name, conestr)) == 0) {
283  node = Cone(gdml, node, attr);
284  } else if ((strcmp(name, polystr)) == 0) {
285  node = Polycone(gdml, node, attr);
286  } else if ((strcmp(name, trapstr)) == 0) {
287  node = Trap(gdml, node, attr);
288  } else if ((strcmp(name, trdstr)) == 0) {
289  node = Trd(gdml, node, attr);
290  } else if ((strcmp(name, sphestr)) == 0) {
291  node = Sphere(gdml, node, attr);
292  } else if ((strcmp(name, xtrustr)) == 0) {
293  node = Xtru(gdml, node, attr);
294  } else if ((strcmp(name, twtrstr)) == 0) {
295  node = TwistTrap(gdml, node, attr);
296  } else if ((strcmp(name, hypestr)) == 0) {
297  node = Hype(gdml, node, attr);
298  } else if ((strcmp(name, orbstr)) == 0) {
299  node = Orb(gdml, node, attr);
300  } else if ((strcmp(name, parastr)) == 0) {
301  node = Para(gdml, node, attr);
302  } else if ((strcmp(name, torustr)) == 0) {
303  node = Torus(gdml, node, attr);
304  } else if ((strcmp(name, eltustr)) == 0) {
305  node = ElTube(gdml, node, attr);
306  } else if ((strcmp(name, hedrstr)) == 0) {
307  node = Polyhedra(gdml, node, attr);
308  } else if ((strcmp(name, parbstr)) == 0) {
309  node = Paraboloid(gdml, node, attr);
310  } else if ((strcmp(name, subtstr)) == 0) {
311  node = BooSolid(gdml, node, attr, 1);
312  } else if ((strcmp(name, intestr)) == 0) {
313  node = BooSolid(gdml, node, attr, 2);
314  } else if ((strcmp(name, uniostr)) == 0) {
315  node = BooSolid(gdml, node, attr, 3);
316  } else if ((strcmp(name, reflstr)) == 0) {
317  node = Reflection(gdml, node, attr);
318  } else if ((strcmp(name, assestr)) == 0) {
319  node = AssProcess(gdml, node);
320  } else if ((strcmp(name, usrstr)) == 0) {
321  node = UsrProcess(gdml, node);
322  //CHECK FOR TAGS NOT SUPPORTED
323  } else if (((strcmp(name, "gdml")) != 0) && ((strcmp(name, "define")) != 0) &&
324  ((strcmp(name, "element")) != 0) && ((strcmp(name, "materials")) != 0) &&
325  ((strcmp(name, "solids")) != 0) && ((strcmp(name, "structure")) != 0) &&
326  ((strcmp(name, "zplane")) != 0) && ((strcmp(name, "first")) != 0) &&
327  ((strcmp(name, "second")) != 0) && ((strcmp(name, "twoDimVertex")) != 0) &&
328  ((strcmp(name, "firstposition")) != 0) && ((strcmp(name, "firstpositionref")) != 0) &&
329  ((strcmp(name, "firstrotation")) != 0) && ((strcmp(name, "firstrotationref")) != 0) &&
330  ((strcmp(name, "section")) != 0) && ((strcmp(name, "world")) != 0) &&
331  ((strcmp(name, "isotope")) != 0)) {
332  std::cout << "Error: Unsupported GDML Tag Used :" << name << ". Please Check Geometry/Schema." << std::endl;
333  }
334 
335  // Check for Child node - if present call this funct. recursively until no more
336 
337  XMLNodePointer_t child = gdml->GetChild(node);
338  while (child != 0) {
339  ParseGDML(gdml, child);
340  child = gdml->GetNext(child);
341  }
342 
343  return fWorldName;
344 
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Takes a string containing a mathematical expression and returns the value of
349 /// the expression
350 
351 double TGDMLParse::Evaluate(const char* evalline)
352 {
353 
354  return TFormula("TFormula", evalline).Eval(0);
355 }
356 
357 ////////////////////////////////////////////////////////////////////////////////
358 /// When using the 'divide' process in the geometry this function
359 /// sets the variable 'axis' depending on what is specified.
360 
361 Int_t TGDMLParse::SetAxis(const char* axisString)
362 {
363  Int_t axis = 0;
364 
365  if ((strcmp(axisString, "kXAxis")) == 0) {
366  axis = 1;
367  } else if ((strcmp(axisString, "kYAxis")) == 0) {
368  axis = 2;
369  } else if ((strcmp(axisString, "kZAxis")) == 0) {
370  axis = 3;
371  } else if ((strcmp(axisString, "kRho")) == 0) {
372  axis = 1;
373  } else if ((strcmp(axisString, "kPhi")) == 0) {
374  axis = 2;
375  }
376 
377  return axis;
378 }
379 
380 ////////////////////////////////////////////////////////////////////////////////
381 /// This function looks thru a string for the chars '0x' next to
382 /// each other, when it finds this, it calls another function to strip
383 /// the hex address. It does this recursively until the end of the
384 /// string is reached, returning a string without any hex addresses.
385 
386 const char* TGDMLParse::NameShort(const char* name)
387 {
388  static TString stripped;
389  stripped = name;
390  Int_t index = stripped.Index("0x");
391  if (index >= 0) stripped = stripped(0, index);
392  return stripped.Data();
393 }
394 
395 ////////////////////////////////////////////////////////////////////////////////
396 /// In the define section of the GDML file, constants can be declared.
397 /// when the constant keyword is found, this function is called, and the
398 /// name and value of the constant is stored in the "fformvec" vector as
399 /// a TFormula class, representing a constant function
400 
402 {
403  TString name = "";
404  TString value = "";
405  TString tempattr;
406 
407  while (attr != 0) {
408  tempattr = gdml->GetAttrName(attr);
409  tempattr.ToLower();
410 
411  if (tempattr == "name") {
412  name = gdml->GetAttrValue(attr);
413  }
414  if (tempattr == "value") {
415  value = gdml->GetAttrValue(attr);
416  }
417  attr = gdml->GetNextAttr(attr);
418  }
419 
420  //if ((strcmp(fCurrentFile, fStartFile)) != 0) {
421  // name = TString::Format("%s_%s", name.Data(), fCurrentFile);
422  //}
423 
424  fconsts[name.Data()] = Value(value);
425 
426  return node;
427 }
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Throughout the GDML file, a unit can de specified. Whether it be
430 /// angular or linear, values can be used as well as abbreviations such as
431 /// 'mm' or 'deg'. This function is passed the specified unit and if it is
432 /// found, replaces it with the appropriate value.
433 
434 TString TGDMLParse::GetScale(const char* unit)
435 {
436  TString retunit = "";
437 
438  if (strcmp(unit, "mm") == 0) {
439  retunit = "0.1";
440  } else if (strcmp(unit, "milimeter") == 0) {
441  retunit = "0.1";
442  } else if (strcmp(unit, "cm") == 0) {
443  retunit = "1.0";
444  } else if (strcmp(unit, "centimeter") == 0) {
445  retunit = "1.0";
446  } else if (strcmp(unit, "m") == 0) {
447  retunit = "100.0";
448  } else if (strcmp(unit, "meter") == 0) {
449  retunit = "100.0";
450  } else if (strcmp(unit, "km") == 0) {
451  retunit = "100000.0";
452  } else if (strcmp(unit, "kilometer") == 0) {
453  retunit = "100000.0";
454  } else if (strcmp(unit, "rad") == 0) {
455  retunit = TString::Format("%.12f", TMath::RadToDeg());
456  } else if (strcmp(unit, "radian") == 0) {
457  retunit = TString::Format("%.12f", TMath::RadToDeg());
458  } else if (strcmp(unit, "deg") == 0) {
459  retunit = "1.0";
460  } else if (strcmp(unit, "degree") == 0) {
461  retunit = "1.0";
462  } else if (strcmp(unit, "pi") == 0) {
463  retunit = "pi";
464  } else if (strcmp(unit, "avogadro") == 0) {
465  retunit = TString::Format("%.12g", TMath::Na());
466  } else {
467  Fatal("GetScale", "Unit <%s> not known", unit);
468  retunit = "0";
469  }
470  return retunit;
471 
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Throughout the GDML file, a unit can de specified. Whether it be
476 /// angular or linear, values can be used as well as abbreviations such as
477 /// 'mm' or 'deg'. This function is passed the specified unit and if it is
478 /// found, replaces it with the appropriate value.
479 
481 {
482  Double_t retunit = 0.;
483  TString unit(sunit);
484  unit.ToLower();
485 
486  if ((unit == "mm") || (unit == "milimeter")) {
487  retunit = 0.1;
488  } else if ((unit == "cm") || (unit == "centimeter")) {
489  retunit = 1.0;
490  } else if ((unit == "m") || (unit == "meter")) {
491  retunit = 100.0;
492  } else if ((unit == "km") || (unit == "kilometer")) {
493  retunit = 100000.0;
494  } else if ((unit == "rad") || (unit == "radian")) {
495  retunit = TMath::RadToDeg();
496  } else if ((unit == "deg") || (unit == "degree")) {
497  retunit = 1.0;
498  } else if ((unit == "ev") || (unit == "electronvolt")) {
499  retunit = 0.000000001;
500  } else if ((unit == "kev") || (unit == "kiloelectronvolt")) {
501  retunit = 0.000001;
502  } else if ((unit == "mev") || (unit == "megaelectronvolt")) {
503  retunit = 0.001;
504  } else if ((unit == "gev") || (unit == "gigaelectronvolt")) {
505  retunit = 1;
506  } else if (unit == "pi") {
507  retunit = TMath::Pi();
508  } else if (unit == "avogadro") {
509  retunit = TMath::Na();
510  } else {
511  Fatal("GetScaleVal", "Unit <%s> not known", sunit);
512  retunit = 0;
513  }
514  return retunit;
515 }
516 
517 ////////////////////////////////////////////////////////////////////////////////
518 /// Convert number in string format to double value.
519 
520 Double_t TGDMLParse::Value(const char *svalue) const
521 {
522  char *end;
523  double val = strtod(svalue, &end);
524 
525  // ignore white spaces.
526  while( *end != 0 && isspace(*end) ) ++end;
527 
528  // Successfully parsed all the characters up to the ending NULL, so svalue
529  // was a simple number.
530  if (*end == 0) return val;
531 
532  // Otherwise we'll use TFormula to evaluate the string, having first found
533  // all the GDML variable names in it and marked them with [] so that
534  // TFormula will recognize them as parameters.
535 
536  std::string expanded;
537  expanded.reserve(strlen(svalue) * 2);
538 
539  // Be careful about locale so we always mean the same thing by
540  // "alphanumeric"
541  const std::locale &loc = std::locale::classic(); // "C" locale
542 
543  // Walk through the string inserting '[' and ']' where necessary
544  const char *p = svalue;
545  while (*p) {
546  // Find a site for a '['. Just before the first alphabetic character
547  for (; *p != 0; ++p) {
548  if (std::isalpha(*p, loc) || *p == '_') {
549  expanded += '[';
550  break;
551  }
552  expanded += *p;
553  }
554  // If we reached the end of the string while looking for the start of a
555  // token then we're done
556  if (*p == 0) break;
557 
558  // Now look for the position of the following ']'. Straight before the
559  // first non-alphanumeric character
560  for (; *p != 0; ++p) {
561  if (!isalnum(*p, loc) && *p != '_') {
562  expanded += ']';
563  break;
564  }
565  expanded += *p;
566  }
567  // If we reached the end of the string while looking for a position for a
568  // ']' then it goes here
569  if (*p == 0) expanded += ']';
570  } // end loop over svalue
571 
572  TFormula f("TFormula", expanded.c_str());
573 
574  // Tell the TFormula about every parameter we know about
575  for (auto it: fconsts) f.SetParameter(it.first.c_str(), it.second);
576 
577  val = f.Eval(0);
578 
579  if (std::isnan(val) || std::isinf(val)) {
580  Fatal("Value", "Got bad value %lf from string '%s'", val, svalue);
581  }
582 
583  return val;
584 }
585 
586 ////////////////////////////////////////////////////////////////////////////////
587 /// In the define section of the GDML file, positions can be declared.
588 /// when the position keyword is found, this function is called, and the
589 /// name and values of the position are converted into type TGeoPosition
590 /// and stored in fposmap map using the name as its key. This function
591 /// can also be called when declaring solids.
592 
594 {
595  TString lunit = "mm";
596  TString xpos = "0";
597  TString ypos = "0";
598  TString zpos = "0";
599  TString name = "0";
600  TString tempattr;
601 
602  while (attr != 0) {
603 
604  tempattr = gdml->GetAttrName(attr);
605  tempattr.ToLower();
606 
607  if (tempattr == "name") {
608  name = gdml->GetAttrValue(attr);
609  } else if (tempattr == "x") {
610  xpos = gdml->GetAttrValue(attr);
611  } else if (tempattr == "y") {
612  ypos = gdml->GetAttrValue(attr);
613  } else if (tempattr == "z") {
614  zpos = gdml->GetAttrValue(attr);
615  } else if (tempattr == "unit") {
616  lunit = gdml->GetAttrValue(attr);
617  }
618 
619  attr = gdml->GetNextAttr(attr);
620  }
621 
622  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
623  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
624  }
625 
626  Double_t retunit = GetScaleVal(lunit);
627  Double_t xline = Value(xpos)*retunit;
628  Double_t yline = Value(ypos)*retunit;
629  Double_t zline = Value(zpos)*retunit;
630 
631  TGeoTranslation* pos = new TGeoTranslation(xline, yline, zline);
632 
633  fposmap[name.Data()] = pos;
634 
635  return node;
636 
637 }
638 
639 ////////////////////////////////////////////////////////////////////////////////
640 /// In the define section of the GDML file, rotations can be declared.
641 /// when the rotation keyword is found, this function is called, and the
642 /// name and values of the rotation are converted into type TGeoRotation
643 /// and stored in frotmap map using the name as its key. This function
644 /// can also be called when declaring solids.
645 
647 {
648  TString aunit = "rad";
649  TString xpos = "0";
650  TString ypos = "0";
651  TString zpos = "0";
652  TString name = "";
653  TString tempattr;
654 
655  while (attr != 0) {
656 
657  tempattr = gdml->GetAttrName(attr);
658  tempattr.ToLower();
659 
660  if (tempattr == "name") {
661  name = gdml->GetAttrValue(attr);
662  } else if (tempattr == "x") {
663  xpos = gdml->GetAttrValue(attr);
664  } else if (tempattr == "y") {
665  ypos = gdml->GetAttrValue(attr);
666  } else if (tempattr == "z") {
667  zpos = gdml->GetAttrValue(attr);
668  } else if (tempattr == "unit") {
669  aunit = gdml->GetAttrValue(attr);
670  }
671 
672  attr = gdml->GetNextAttr(attr);
673  }
674 
675  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
676  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
677  }
678 
679  Double_t retunit = GetScaleVal(aunit);
680 
681  Double_t xline = Value(xpos)*retunit;
682  Double_t yline = Value(ypos)*retunit;
683  Double_t zline = Value(zpos)*retunit;
684 
685  TGeoRotation* rot = new TGeoRotation();
686 
687  rot->RotateZ(-zline);
688  rot->RotateY(-yline);
689  rot->RotateX(-xline);
690 
691  frotmap[name.Data()] = rot;
692 
693  return node;
694 
695 }
696 
697 ////////////////////////////////////////////////////////////////////////////////
698 /// In the define section of the GDML file, rotations can be declared.
699 /// when the scale keyword is found, this function is called, and the
700 /// name and values of the scale are converted into type TGeoScale
701 /// and stored in fsclmap map using the name as its key. This function
702 /// can also be called when declaring solids.
703 
705 {
706  TString xpos = "0";
707  TString ypos = "0";
708  TString zpos = "0";
709  TString name = "";
710  TString tempattr;
711 
712  while (attr != 0) {
713 
714  tempattr = gdml->GetAttrName(attr);
715  tempattr.ToLower();
716 
717  if (tempattr == "name") {
718  name = gdml->GetAttrValue(attr);
719  } else if (tempattr == "x") {
720  xpos = gdml->GetAttrValue(attr);
721  } else if (tempattr == "y") {
722  ypos = gdml->GetAttrValue(attr);
723  } else if (tempattr == "z") {
724  zpos = gdml->GetAttrValue(attr);
725  }
726 
727  attr = gdml->GetNextAttr(attr);
728  }
729 
730  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
731  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
732  }
733 
734  TGeoScale* scl = new TGeoScale(Value(xpos), Value(ypos), Value(zpos));
735 
736  fsclmap[name.Data()] = scl;
737 
738  return node;
739 }
740 
741 ////////////////////////////////////////////////////////////////////////////////
742 /// In the material section of the GDML file, an isotope may be declared.
743 /// when the isotope keyword is found, this function is called, and the
744 /// required parameters are taken and stored, these are then bound and
745 /// converted to type TGeoIsotope and stored in fisomap map using the name
746 /// as its key.
747 
749 {
750  TString z = "0";
751  TString name = "";
752  TString n = "0";
753  TString atom = "0";
754  TString tempattr;
755 
756  //obtain attributes for the element
757 
758  XMLAttrPointer_t attr = gdml->GetFirstAttr(parentn);
759 
760  while (attr != 0) {
761 
762  tempattr = gdml->GetAttrName(attr);
763  tempattr.ToLower();
764 
765  if (tempattr == "name") {
766  name = gdml->GetAttrValue(attr);
767  } else if (tempattr == "z") {
768  z = gdml->GetAttrValue(attr);
769  } else if (tempattr == "n") {
770  n = gdml->GetAttrValue(attr);
771  }
772 
773  attr = gdml->GetNextAttr(attr);
774  }
775 
776  //get the atom value for the element
777 
778  attr = gdml->GetFirstAttr(node);
779 
780  while (attr != 0) {
781 
782  tempattr = gdml->GetAttrName(attr);
783 
784  if (tempattr == "value") {
785  atom = gdml->GetAttrValue(attr);
786  }
787 
788  attr = gdml->GetNextAttr(attr);
789  }
790 
791  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
792  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
793  }
794 
795  Int_t z2 = (Int_t)Value(z);
796  Int_t n2 = (Int_t)Value(n);
797  Double_t atom2 = Value(atom);
798 
799  TGeoIsotope* iso = new TGeoIsotope(NameShort(name), z2 , n2, atom2);
800  fisomap[name.Data()] = iso;
801 
802  return node;
803 
804 }
805 
806 ////////////////////////////////////////////////////////////////////////////////
807 /// When the element keyword is found, this function is called, and the
808 /// name and values of the element are converted into type TGeoElement and
809 /// stored in felemap map using the name as its key.
810 
811 XMLNodePointer_t TGDMLParse::EleProcess(TXMLEngine* gdml, XMLNodePointer_t node, XMLNodePointer_t parentn, Bool_t hasIsotopes, Bool_t hasIsotopesExtended)
812 
813 {
814  TString z = "0";
815  TString name = "";
816  TString formula = "";
817  TString atom = "0";
818  TString tempattr;
819  Int_t ncompo = 0;
820  typedef FracMap::iterator fractions;
821  FracMap fracmap;
822 
823  XMLNodePointer_t child = 0;
824 
825  //obtain attributes for the element
826 
827  XMLAttrPointer_t attr = gdml->GetFirstAttr(node);
828 
829  if (hasIsotopes) {
830 
831  // Get the name of the element
832  while (attr != 0) {
833  tempattr = gdml->GetAttrName(attr);
834  if (tempattr == "name") {
835  name = gdml->GetAttrValue(attr);
836 
837  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
838  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
839  }
840  break;
841  }
842  attr = gdml->GetNextAttr(attr);
843  }
844  // Get component isotopes. Loop all children.
845  child = gdml->GetChild(node);
846  while (child != 0) {
847 
848  // Check for fraction node name
849  if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
850  Double_t n = 0;
851  TString ref = "";
852  ncompo = ncompo + 1;
853  attr = gdml->GetFirstAttr(child);
854  while (attr != 0) {
855  tempattr = gdml->GetAttrName(attr);
856  tempattr.ToLower();
857  if (tempattr == "n") {
858  n = Value(gdml->GetAttrValue(attr));
859  } else if (tempattr == "ref") {
860  ref = gdml->GetAttrValue(attr);
861  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
862  ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
863  }
864  }
865  attr = gdml->GetNextAttr(attr);
866  } // loop on child attributes
867  fracmap[ref.Data()] = n;
868  }
869  child = gdml->GetNext(child);
870  } // loop on children
871  // Create TGeoElement - note: Object(name, title) corresponds to Element(formula, name)
872  TGeoElement *ele = new TGeoElement(NameShort(name), NameShort(name), ncompo);
873  for (fractions f = fracmap.begin(); f != fracmap.end(); ++f) {
874  if (fisomap.find(f->first) != fisomap.end()) {
875  ele->AddIsotope((TGeoIsotope*)fisomap[f->first], f->second);
876  }
877  }
878  felemap[name.Data()] = ele;
879  return child;
880  } // hasisotopes end loop
881 
882  //*************************
883 
884 
885  if (hasIsotopesExtended) {
886 
887  while (attr != 0) {
888  tempattr = gdml->GetAttrName(attr);
889 
890  if (tempattr == "name") {
891  name = gdml->GetAttrValue(attr);
892 
893  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
894  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
895  }
896  break;
897  }
898  attr = gdml->GetNextAttr(attr);
899  }
900  // Get component isotopes. Loop all children.
901  child = gdml->GetChild(node);
902  while (child != 0) {
903 
904  // Check for fraction node name
905  if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
906  Double_t n = 0;
907  TString ref = "";
908  ncompo = ncompo + 1;
909  attr = gdml->GetFirstAttr(child);
910  while (attr != 0) {
911  tempattr = gdml->GetAttrName(attr);
912  tempattr.ToLower();
913  if (tempattr == "n") {
914  n = Value(gdml->GetAttrValue(attr));
915  } else if (tempattr == "ref") {
916  ref = gdml->GetAttrValue(attr);
917  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
918  ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
919  }
920  }
921  attr = gdml->GetNextAttr(attr);
922  } // loop on child attributes
923  fracmap[ref.Data()] = n;
924  }
925  child = gdml->GetNext(child);
926  } // loop on children
927  // Create TGeoElement - note: Object(name, title) corresponds to Element(formula, name)
928  TGeoElement *ele = new TGeoElement(NameShort(name), NameShort(name), ncompo);
929  for (fractions f = fracmap.begin(); f != fracmap.end(); ++f) {
930  if (fisomap.find(f->first) != fisomap.end()) {
931  ele->AddIsotope((TGeoIsotope*)fisomap[f->first], f->second);
932  }
933  }
934  felemap[name.Data()] = ele;
935  return child;
936  } // hasisotopesExtended end loop
937 
938  //***************************
939 
940  attr = gdml->GetFirstAttr(parentn);
941  while (attr != 0) {
942 
943  tempattr = gdml->GetAttrName(attr);
944  tempattr.ToLower();
945 
946  if (tempattr == "name") {
947  name = gdml->GetAttrValue(attr);
948 
949  } else if (tempattr == "z") {
950  z = gdml->GetAttrValue(attr);
951  } else if (tempattr == "formula") {
952  formula = gdml->GetAttrValue(attr);
953  }
954 
955  attr = gdml->GetNextAttr(attr);
956  }
957 
958  //get the atom value for the element
959 
960  attr = gdml->GetFirstAttr(node);
961 
962  while (attr != 0) {
963 
964  tempattr = gdml->GetAttrName(attr);
965  tempattr.ToLower();
966 
967  if (tempattr == "value") {
968  atom = gdml->GetAttrValue(attr);
969  }
970 
971  attr = gdml->GetNextAttr(attr);
972  }
973 
974  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
975  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
976  }
977 
978  Int_t z2 = (Int_t)Value(z);
979  Double_t atom2 = Value(atom);
980 
981  TGeoElement* ele = new TGeoElement(formula, NameShort(name), z2 , atom2);
982 
983  felemap[name.Data()] = ele;
984 
985  return node;
986 
987 }
988 
989 ////////////////////////////////////////////////////////////////////////////////
990 /// In the materials section of the GDML file, materials can be declared.
991 /// when the material keyword is found, this function is called, and the
992 /// name and values of the material are converted into type TGeoMaterial
993 /// and stored in fmatmap map using the name as its key. Mixtures can also
994 /// be declared, and they are converted to TGeoMixture and stored in
995 /// fmixmap. These mixtures and materials are then all converted into one
996 /// common type - TGeoMedium. The map fmedmap is then built up of all the
997 /// mixtures and materials.
998 
1000 {
1001  //!Map to hold fractions while being processed
1002  typedef FracMap::iterator fractions;
1003 // typedef FracMap::iterator i;
1004  FracMap fracmap;
1005 
1006  static int medid = 0;
1007  XMLNodePointer_t child = gdml->GetChild(node);
1008  TString tempattr = "";
1009  Int_t ncompo = 0, mixflag = 2;
1010  Double_t density = 0;
1011  TString name = "";
1012  TGeoMixture* mix = 0;
1013  TGeoMaterial* mat = 0;
1014  TString tempconst = "";
1015  TString matname;
1016  Bool_t composite = kFALSE;
1017 
1018  if (z == 1) {
1019  Double_t a = 0;
1020  Double_t d = 0;
1021 
1022  while (child != 0) {
1023  attr = gdml->GetFirstAttr(child);
1024 
1025  if ((strcmp(gdml->GetNodeName(child), "atom")) == 0) {
1026  while (attr != 0) {
1027  tempattr = gdml->GetAttrName(attr);
1028  tempattr.ToLower();
1029 
1030  if (tempattr == "value") {
1031  a = Value(gdml->GetAttrValue(attr));
1032  }
1033  attr = gdml->GetNextAttr(attr);
1034  }
1035  }
1036 
1037  if ((strcmp(gdml->GetNodeName(child), "D")) == 0) {
1038  while (attr != 0) {
1039  tempattr = gdml->GetAttrName(attr);
1040  tempattr.ToLower();
1041 
1042  if (tempattr == "value") {
1043  d = Value(gdml->GetAttrValue(attr));
1044  }
1045  attr = gdml->GetNextAttr(attr);
1046  }
1047  }
1048  child = gdml->GetNext(child);
1049  }
1050  //still in the is Z else...but not in the while..
1051 
1052  name = gdml->GetAttr(node, "name");
1053 
1054  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1055  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
1056  }
1057 
1058  //CHECK FOR CONSTANTS
1059  tempconst = gdml->GetAttr(node, "Z");
1060 
1061  Double_t valZ = Value(tempconst);
1062 
1063  TString tmpname = name;
1064  //deal with special case - Z of vacuum is always 0
1065  tmpname.ToLower();
1066  if (tmpname == "vacuum") {
1067  valZ = 0;
1068  }
1069  mat = new TGeoMaterial(NameShort(name), a, valZ, d);
1070  mixflag = 0;
1071  //Note: Object(name, title) corresponds to Element(formula, name)
1072  TGeoElement* mat_ele = new TGeoElement(NameShort(name), NameShort(name), atoi(tempconst), a);
1073  felemap[name.Data()] = mat_ele;
1074 
1075  }
1076 
1077  else if (z == 0) {
1078  while (child != 0) {
1079  attr = gdml->GetFirstAttr(child);
1080 
1081  if ((strcmp(gdml->GetNodeName(child), "fraction")) == 0) {
1082  Double_t n = 0;
1083  TString ref = "";
1084  ncompo = ncompo + 1;
1085 
1086  while (attr != 0) {
1087  tempattr = gdml->GetAttrName(attr);
1088  tempattr.ToLower();
1089 
1090  if (tempattr == "n") {
1091  n = Value(gdml->GetAttrValue(attr));
1092  } else if (tempattr == "ref") {
1093  ref = gdml->GetAttrValue(attr);
1094  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1095  ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
1096  }
1097 
1098  }
1099 
1100  attr = gdml->GetNextAttr(attr);
1101  }
1102  fracmap[ref.Data()] = n;
1103 
1104  }
1105 
1106  else if ((strcmp(gdml->GetNodeName(child), "composite")) == 0) {
1107  composite = kTRUE;
1108  Double_t n = 0;
1109  TString ref = "";
1110  ncompo = ncompo + 1;
1111 
1112  while (attr != 0) {
1113  tempattr = gdml->GetAttrName(attr);
1114  tempattr.ToLower();
1115 
1116  if (tempattr == "n") {
1117  n = Value(gdml->GetAttrValue(attr));
1118  } else if (tempattr == "ref") {
1119  ref = gdml->GetAttrValue(attr);
1120  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1121  ref = TString::Format("%s_%s", ref.Data(), fCurrentFile);
1122  }
1123  }
1124 
1125  attr = gdml->GetNextAttr(attr);
1126  }
1127 
1128  fracmap[ref.Data()] = n;
1129 
1130  }
1131  else if ((strcmp(gdml->GetNodeName(child), "D")) == 0) {
1132  while (attr != 0) {
1133  tempattr = gdml->GetAttrName(attr);
1134  tempattr.ToLower();
1135 
1136  if (tempattr == "value") {
1137  density = Value(gdml->GetAttrValue(attr));
1138  }
1139 
1140  attr = gdml->GetNextAttr(attr);
1141  }
1142  }
1143 
1144  child = gdml->GetNext(child);
1145  }
1146  //still in the not Z else...but not in the while..
1147 
1148  name = gdml->GetAttr(node, "name");
1149  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1150  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
1151  }
1152  //mix = new TGeoMixture(NameShort(name), 0 /*ncompo*/, density);
1153  mix = new TGeoMixture(NameShort(name), ncompo, density);
1154  mixflag = 1;
1155  Int_t natoms;
1156  Double_t weight;
1157 
1158  for (fractions f = fracmap.begin(); f != fracmap.end(); ++f) {
1159  matname = f->first;
1160  matname = NameShort(matname);
1161 
1163 
1164  if (mattmp || (felemap.find(f->first) != felemap.end())) {
1165  if (composite) {
1166  natoms = (Int_t)f->second;
1167 
1168  mix->AddElement(felemap[f->first], natoms);
1169 
1170  }
1171 
1172  else {
1173  weight = f->second;
1174  if (mattmp){
1175 
1176  mix->AddElement(mattmp, weight);
1177  }
1178  else {
1179 
1180  mix->AddElement(felemap[f->first], weight);
1181  }
1182  }
1183  }
1184  }
1185 
1186  }//end of not Z else
1187 
1188  medid = medid + 1;
1189 
1190  TGeoMedium* med = 0;
1191 
1192  if (mixflag == 1) {
1193  fmixmap[name.Data()] = mix;
1194  med = new TGeoMedium(NameShort(name), medid, mix);
1195  } else if (mixflag == 0) {
1196  fmatmap[name.Data()] = mat;
1197  med = new TGeoMedium(NameShort(name), medid, mat);
1198  }
1199 
1200  fmedmap[name.Data()] = med;
1201 
1202  return child;
1203 
1204 }
1205 
1206 ////////////////////////////////////////////////////////////////////////////////
1207 /// In the structure section of the GDML file, volumes can be declared.
1208 /// when the volume keyword is found, this function is called, and the
1209 /// name and values of the volume are converted into type TGeoVolume and
1210 /// stored in fvolmap map using the name as its key. Volumes reference to
1211 /// a solid declared higher up in the solids section of the GDML file.
1212 /// Some volumes reference to other physical volumes to contain inside
1213 /// that volume, declaring positions and rotations within that volume.
1214 /// when each 'physvol' is declared, a matrix for its rotation and
1215 /// translation is built and the 'physvol node' is added to the original
1216 /// volume using TGeoVolume->AddNode.
1217 /// volume division is also declared within the volume node, and once the
1218 /// values for the division have been collected, using TGeoVolume->divide,
1219 /// the division can be applied.
1220 
1222 {
1223  XMLAttrPointer_t attr;
1224  XMLNodePointer_t subchild;
1225  XMLNodePointer_t subsubchild;
1226 
1227  XMLNodePointer_t child = gdml->GetChild(node);
1228  TString name;
1229  TString solidname = "";
1230  TString tempattr = "";
1231  TGeoShape* solid = 0;
1232  TGeoMedium* medium = 0;
1233  TGeoVolume* vol = 0;
1234  TGeoVolume* lv = 0;
1235  TGeoShape* reflex = 0;
1236  const Double_t* parentrot = 0;
1237  int yesrefl = 0;
1238  TString reftemp = "";
1239  TMap *auxmap = 0;
1240 
1241  while (child != 0) {
1242  if ((strcmp(gdml->GetNodeName(child), "solidref")) == 0) {
1243 
1244  reftemp = gdml->GetAttr(child, "ref");
1245  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1246  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1247  }
1248  if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
1249  solid = fsolmap[reftemp.Data()];
1250  } else if (freflectmap.find(reftemp.Data()) != freflectmap.end()) {
1251  solidname = reftemp;
1252  reflex = fsolmap[freflectmap[reftemp.Data()]];
1253  } else {
1254  printf("Solid: %s, Not Yet Defined!\n", reftemp.Data());
1255  }
1256  }
1257 
1258  if ((strcmp(gdml->GetNodeName(child), "materialref")) == 0) {
1259  reftemp = gdml->GetAttr(child, "ref");
1260  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1261  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1262  }
1263  if (fmedmap.find(reftemp.Data()) != fmedmap.end()) {
1264  medium = fmedmap[reftemp.Data()];
1265  } else {
1266  printf("Medium: %s, Not Yet Defined!\n", gdml->GetAttr(child, "ref"));
1267  }
1268  }
1269 
1270  child = gdml->GetNext(child);
1271  }
1272 
1273  name = gdml->GetAttr(node, "name");
1274 
1275  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1276  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
1277  }
1278 
1279  if (reflex == 0) {
1280  vol = new TGeoVolume(NameShort(name), solid, medium);
1281  } else {
1282  vol = new TGeoVolume(NameShort(name), reflex, medium);
1283  freflvolmap[name.Data()] = solidname;
1284  TGDMLRefl* parentrefl = freflsolidmap[solidname.Data()];
1285  parentrot = parentrefl->GetMatrix()->GetRotationMatrix();
1286  yesrefl = 1;
1287  }
1288 
1289  fvolmap[name.Data()] = vol;
1290 
1291  //PHYSVOL - run through child nodes of VOLUME again..
1292 
1293  child = gdml->GetChild(node);
1294 
1295  while (child != 0) {
1296  if ((strcmp(gdml->GetNodeName(child), "physvol")) == 0) {
1297 
1298  TString volref = "";
1299 
1300  TGeoTranslation* pos = 0;
1301  TGeoRotation* rot = 0;
1302  TGeoScale* scl = 0;
1303  TString pnodename = gdml->GetAttr(child, "name");
1304  TString scopynum = gdml->GetAttr(child, "copynumber");
1305  Int_t copynum = (scopynum.IsNull()) ? 0 : (Int_t)Value(scopynum);
1306 
1307  subchild = gdml->GetChild(child);
1308 
1309  while (subchild != 0) {
1310  tempattr = gdml->GetNodeName(subchild);
1311  tempattr.ToLower();
1312 
1313  if (tempattr == "volumeref") {
1314  reftemp = gdml->GetAttr(subchild, "ref");
1315  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1316  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1317  }
1318  lv = fvolmap[reftemp.Data()];
1319  volref = reftemp;
1320  }
1321  else if (tempattr == "file") {
1322  const char* filevol;
1323  const char* prevfile = fCurrentFile;
1324 
1325  fCurrentFile = gdml->GetAttr(subchild, "name");
1326  filevol = gdml->GetAttr(subchild, "volname");
1327 
1328  TXMLEngine* gdml2 = new TXMLEngine;
1329  gdml2->SetSkipComments(kTRUE);
1330  XMLDocPointer_t filedoc1 = gdml2->ParseFile(fCurrentFile);
1331  if (filedoc1 == 0) {
1332  Fatal("VolProcess", "Bad filename given %s", fCurrentFile);
1333  }
1334  // take access to main node
1335  XMLNodePointer_t mainnode2 = gdml2->DocGetRootElement(filedoc1);
1336  //increase depth counter + add DOM pointer
1337  fFILENO = fFILENO + 1;
1338  fFileEngine[fFILENO] = gdml2;
1339 
1340  if (ffilemap.find(fCurrentFile) != ffilemap.end()) {
1341  volref = ffilemap[fCurrentFile];
1342  } else {
1343  volref = ParseGDML(gdml2, mainnode2);
1344  ffilemap[fCurrentFile] = volref;
1345  }
1346 
1347  if (filevol) {
1348  volref = filevol;
1349  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1350  volref = TString::Format("%s_%s", volref.Data(), fCurrentFile);
1351  }
1352  }
1353 
1354  fFILENO = fFILENO - 1;
1355  gdml = fFileEngine[fFILENO];
1356  fCurrentFile = prevfile;
1357 
1358  lv = fvolmap[volref.Data()];
1359  //File tree complete - Release memory before exit
1360 
1361  gdml->FreeDoc(filedoc1);
1362  delete gdml2;
1363  }
1364  else if (tempattr == "position") {
1365  attr = gdml->GetFirstAttr(subchild);
1366  PosProcess(gdml, subchild, attr);
1367  reftemp = gdml->GetAttr(subchild, "name");
1368  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1369  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1370  }
1371  pos = fposmap[reftemp.Data()];
1372  } else if (tempattr == "positionref") {
1373  reftemp = gdml->GetAttr(subchild, "ref");
1374  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1375  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1376  }
1377  if (fposmap.find(reftemp.Data()) != fposmap.end()) pos = fposmap[reftemp.Data()];
1378  else std::cout << "ERROR! Physvol's position " << reftemp << " not found!" << std::endl;
1379  } else if (tempattr == "rotation") {
1380  attr = gdml->GetFirstAttr(subchild);
1381  RotProcess(gdml, subchild, attr);
1382  reftemp = gdml->GetAttr(subchild, "name");
1383  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1384  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1385  }
1386  rot = frotmap[reftemp.Data()];
1387  } else if (tempattr == "rotationref") {
1388  reftemp = gdml->GetAttr(subchild, "ref");
1389  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1390  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1391  }
1392  if (frotmap.find(reftemp.Data()) != frotmap.end()) rot = frotmap[reftemp.Data()];
1393  else std::cout << "ERROR! Physvol's rotation " << reftemp << " not found!" << std::endl;
1394  } else if (tempattr == "scale") {
1395  attr = gdml->GetFirstAttr(subchild);
1396  SclProcess(gdml, subchild, attr);
1397  reftemp = gdml->GetAttr(subchild, "name");
1398  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1399  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1400  }
1401  scl = fsclmap[reftemp.Data()];
1402  } else if (tempattr == "scaleref") {
1403  reftemp = gdml->GetAttr(subchild, "ref");
1404  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1405  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1406  }
1407  if (fsclmap.find(reftemp.Data()) != fsclmap.end()) scl = fsclmap[reftemp.Data()];
1408  else std::cout << "ERROR! Physvol's scale " << reftemp << " not found!" << std::endl;
1409  }
1410 
1411  subchild = gdml->GetNext(subchild);
1412  }
1413 
1414  //ADD PHYSVOL TO GEOMETRY
1415  fVolID = fVolID + 1;
1416 
1417  TGeoHMatrix *transform = new TGeoHMatrix();
1418 
1419  if (pos != 0) transform->SetTranslation(pos->GetTranslation());
1420  if (rot != 0) transform->SetRotation(rot->GetRotationMatrix());
1421 
1422  if (scl != 0) { // Scaling must be added to the rotation matrix!
1423 
1424  Double_t scale3x3[9];
1425  memset(scale3x3, 0, 9 * sizeof(Double_t));
1426  const Double_t *diagonal = scl->GetScale();
1427 
1428  scale3x3[0] = diagonal[0];
1429  scale3x3[4] = diagonal[1];
1430  scale3x3[8] = diagonal[2];
1431 
1432  TGeoRotation scaleMatrix;
1433  scaleMatrix.SetMatrix(scale3x3);
1434  transform->Multiply(&scaleMatrix);
1435  }
1436 
1437 // BEGIN: reflectedSolid. Remove lines between if reflectedSolid will be removed from GDML!!!
1438 
1439  if (freflvolmap.find(volref.Data()) != freflvolmap.end()) {
1440  // if the volume is a reflected volume the matrix needs to be CHANGED
1441  TGDMLRefl* temprefl = freflsolidmap[freflvolmap[volref.Data()]];
1442  transform->Multiply(temprefl->GetMatrix());
1443  }
1444 
1445  if (yesrefl == 1) {
1446  // reflection is done per solid so that we cancel it if exists in mother volume!!!
1447  TGeoRotation prot;
1448  prot.SetMatrix(parentrot);
1449  transform->MultiplyLeft(&prot);
1450  }
1451 
1452 // END: reflectedSolid
1453 
1454  vol->AddNode(lv, copynum, transform);
1455  if (!pnodename.IsNull())
1456  ((TNamed*)vol->GetNodes()->Last())->SetName(pnodename);
1457  } else if ((strcmp(gdml->GetNodeName(child), "divisionvol")) == 0) {
1458 
1459  TString divVolref = "";
1460  Int_t axis = 0;
1461  TString number = "";
1462  TString width = "";
1463  TString offset = "";
1464  TString lunit = "mm";
1465 
1466  attr = gdml->GetFirstAttr(child);
1467 
1468  while (attr != 0) {
1469 
1470  tempattr = gdml->GetAttrName(attr);
1471  tempattr.ToLower();
1472 
1473  if (tempattr == "axis") {
1474  axis = SetAxis(gdml->GetAttrValue(attr));
1475  } else if (tempattr == "number") {
1476  number = gdml->GetAttrValue(attr);
1477  } else if (tempattr == "width") {
1478  width = gdml->GetAttrValue(attr);
1479  } else if (tempattr == "offset") {
1480  offset = gdml->GetAttrValue(attr);
1481  } else if (tempattr == "unit") {
1482  lunit = gdml->GetAttrValue(attr);
1483  }
1484 
1485  attr = gdml->GetNextAttr(attr);
1486 
1487  }
1488 
1489  subchild = gdml->GetChild(child);
1490 
1491  while (subchild != 0) {
1492  tempattr = gdml->GetNodeName(subchild);
1493  tempattr.ToLower();
1494 
1495  if (tempattr == "volumeref") {
1496  reftemp = gdml->GetAttr(subchild, "ref");
1497  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1498  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1499  }
1500  divVolref = reftemp;
1501  }
1502 
1503  subchild = gdml->GetNext(subchild);
1504  }
1505 
1506 
1507  Double_t numberline = Value(number);
1508  Double_t retunit = GetScaleVal(lunit);
1509  Double_t step = Value(width) * retunit;
1510  Double_t offsetline = Value(offset) * retunit;
1511 
1512  fVolID = fVolID + 1;
1513  Double_t xlo, xhi;
1514  vol->GetShape()->GetAxisRange(axis, xlo, xhi);
1515 
1516  Int_t ndiv = (Int_t)numberline;
1517  Double_t start = xlo + offsetline;
1518 
1519  Int_t numed = 0;
1520  TGeoVolume *old = fvolmap[NameShort(reftemp)];
1521  if (old) {
1522  // We need to recreate the content of the divided volume
1523  old = fvolmap[NameShort(reftemp)];
1524  // medium id
1525  numed = old->GetMedium()->GetId();
1526  }
1527  TGeoVolume *divvol = vol->Divide(NameShort(reftemp), axis, ndiv, start, step, numed);
1528  if (!divvol) {
1529  Fatal("VolProcess", "Cannot divide volume %s", vol->GetName());
1530  return child;
1531  }
1532  if (old && old->GetNdaughters()) {
1533  divvol->ReplayCreation(old);
1534  }
1535  fvolmap[NameShort(reftemp)] = divvol;
1536 
1537  }//end of Division else if
1538 
1539 
1540  else if ((strcmp(gdml->GetNodeName(child), "replicavol")) == 0) {
1541 
1542  TString divVolref = "";
1543  Int_t axis = 0;
1544  TString number = "";
1545  TString width = "";
1546  TString offset = "";
1547  TString wunit = "mm";
1548  TString ounit = "mm";
1549  Double_t wvalue = 0;
1550  Double_t ovalue = 0;
1551 
1552 
1553  attr = gdml->GetFirstAttr(child);
1554 
1555  while (attr != 0) {
1556 
1557  tempattr = gdml->GetAttrName(attr);
1558  tempattr.ToLower();
1559 
1560  if (tempattr == "number") {
1561  number = gdml->GetAttrValue(attr);
1562  }
1563  attr = gdml->GetNextAttr(attr);
1564  }
1565 
1566  subchild = gdml->GetChild(child);
1567 
1568  while (subchild != 0) {
1569  tempattr = gdml->GetNodeName(subchild);
1570  tempattr.ToLower();
1571 
1572  if (tempattr == "volumeref") {
1573  reftemp = gdml->GetAttr(subchild, "ref");
1574  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1575  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1576  }
1577  divVolref = reftemp;
1578  }
1579 
1580  if (tempattr == "replicate_along_axis") {
1581  subsubchild = gdml->GetChild(subchild);
1582 
1583  while (subsubchild != 0) {
1584  if ((strcmp(gdml->GetNodeName(subsubchild), "width")) == 0) {
1585  attr = gdml->GetFirstAttr(subsubchild);
1586  while (attr != 0) {
1587  tempattr = gdml->GetAttrName(attr);
1588  tempattr.ToLower();
1589  if (tempattr == "value") {
1590  wvalue = Value(gdml->GetAttrValue(attr));
1591  }
1592  else if (tempattr == "unit"){
1593  wunit = gdml->GetAttrValue(attr);
1594  }
1595 
1596  attr = gdml->GetNextAttr(attr);
1597  }
1598  }
1599  else if ((strcmp(gdml->GetNodeName(subsubchild), "offset")) == 0) {
1600  attr = gdml->GetFirstAttr(subsubchild);
1601  while (attr != 0) {
1602  tempattr = gdml->GetAttrName(attr);
1603  tempattr.ToLower();
1604  if (tempattr == "value") {
1605  ovalue = Value(gdml->GetAttrValue(attr));
1606  }
1607  else if (tempattr == "unit"){
1608  ounit = gdml->GetAttrValue(attr);
1609  }
1610  attr = gdml->GetNextAttr(attr);
1611  }
1612  }
1613  else if ((strcmp(gdml->GetNodeName(subsubchild), "direction")) == 0) {
1614  attr = gdml->GetFirstAttr(subsubchild);
1615  while (attr != 0) {
1616  tempattr = gdml->GetAttrName(attr);
1617  tempattr.ToLower();
1618  if (tempattr == "x") {
1619  axis = 1;
1620  }
1621  else if (tempattr == "y"){
1622  axis = 2;
1623  }
1624  else if (tempattr == "z"){
1625  axis = 3;
1626  }
1627  else if (tempattr == "rho"){
1628  axis = 1;
1629  }
1630  else if (tempattr == "phi"){
1631  axis = 2;
1632  }
1633 
1634  attr = gdml->GetNextAttr(attr);
1635  }
1636  }
1637 
1638  subsubchild = gdml->GetNext(subsubchild);
1639  }
1640 
1641  }
1642 
1643  subchild = gdml->GetNext(subchild);
1644  }
1645 
1646 
1647  Double_t retwunit = GetScaleVal(wunit);
1648  Double_t retounit = GetScaleVal(ounit);
1649 
1650  Double_t numberline = Value(number);
1651  Double_t widthline = wvalue*retwunit;
1652  Double_t offsetline = ovalue*retounit;
1653 
1654  fVolID = fVolID + 1;
1655  Double_t xlo, xhi;
1656  vol->GetShape()->GetAxisRange(axis, xlo, xhi);
1657 
1658  Int_t ndiv = (Int_t)numberline;
1659  Double_t start = xlo + offsetline;
1660 
1661  Double_t step = widthline;
1662  Int_t numed = 0;
1663  TGeoVolume *old = fvolmap[NameShort(reftemp)];
1664  if (old) {
1665  // We need to recreate the content of the divided volume
1666  old = fvolmap[NameShort(reftemp)];
1667  // medium id
1668  numed = old->GetMedium()->GetId();
1669  }
1670  TGeoVolume *divvol = vol->Divide(NameShort(reftemp), axis, ndiv, start, step, numed);
1671  if (!divvol) {
1672  Fatal("VolProcess", "Cannot divide volume %s", vol->GetName());
1673  return child;
1674  }
1675  if (old && old->GetNdaughters()) {
1676  divvol->ReplayCreation(old);
1677  }
1678  fvolmap[NameShort(reftemp)] = divvol;
1679 
1680  } //End of replicavol
1681  else if (strcmp(gdml->GetNodeName(child), "auxiliary") == 0) {
1682  TString auxType, auxUnit, auxValue;
1683  if(!auxmap) {
1684  printf("Auxiliary values for volume %s\n",vol->GetName());
1685  auxmap = new TMap();
1686  vol->SetUserExtension(new TGeoRCExtension(auxmap));
1687  }
1688  attr = gdml->GetFirstAttr(child);
1689  while(attr) {
1690  if (!strcmp(gdml->GetAttrName(attr),"auxtype")) auxType = gdml->GetAttrValue(attr);
1691  else if (!strcmp(gdml->GetAttrName(attr),"auxvalue")) auxValue = gdml->GetAttrValue(attr);
1692  else if (!strcmp(gdml->GetAttrName(attr),"auxunit")) auxUnit = gdml->GetAttrValue(attr);
1693  attr = gdml->GetNextAttr(attr);
1694  }
1695  if (!auxUnit.IsNull()) auxValue = TString::Format("%s*%s", auxValue.Data(), auxUnit.Data());
1696  auxmap->Add(new TObjString(auxType),new TObjString(auxValue));
1697  printf(" %s: %s\n", auxType.Data(), auxValue.Data());
1698  }
1699 
1700  child = gdml->GetNext(child);
1701  }
1702 
1703  return child;
1704 
1705 }
1706 
1707 ////////////////////////////////////////////////////////////////////////////////
1708 /// In the solid section of the GDML file, boolean solids can be
1709 /// declared. when the subtraction, intersection or union keyword
1710 /// is found, this function is called, and the values (rotation and
1711 /// translation) of the solid are converted into type TGeoCompositeShape
1712 /// and stored in fsolmap map using the name as its key.
1713 ///
1714 /// - 1 = SUBTRACTION
1715 /// - 2 = INTERSECTION
1716 /// - 3 = UNION
1717 
1719 {
1720  TString reftemp = "";
1721  TString tempattr = "";
1722  XMLNodePointer_t child = gdml->GetChild(node);
1723 
1724  TGeoShape* first = 0;
1725  TGeoShape* second = 0;
1726 
1727  TGeoTranslation* firstPos = new TGeoTranslation(0, 0, 0);
1728  TGeoTranslation* secondPos = new TGeoTranslation(0, 0, 0);
1729 
1730  TGeoRotation* firstRot = new TGeoRotation();
1731  TGeoRotation* secondRot = new TGeoRotation();
1732 
1733  firstRot->RotateZ(0);
1734  firstRot->RotateY(0);
1735  firstRot->RotateX(0);
1736 
1737  secondRot->RotateZ(0);
1738  secondRot->RotateY(0);
1739  secondRot->RotateX(0);
1740 
1741  TString name = gdml->GetAttr(node, "name");
1742 
1743  if ((strcmp(fCurrentFile, fStartFile)) != 0)
1744  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
1745 
1746  while (child != 0) {
1747  tempattr = gdml->GetNodeName(child);
1748  tempattr.ToLower();
1749 
1750  if (tempattr == "first") {
1751  reftemp = gdml->GetAttr(child, "ref");
1752  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1753  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1754  }
1755  if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
1756  first = fsolmap[reftemp.Data()];
1757  }
1758  } else if (tempattr == "second") {
1759  reftemp = gdml->GetAttr(child, "ref");
1760  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1761  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1762  }
1763  if (fsolmap.find(reftemp.Data()) != fsolmap.end()) {
1764  second = fsolmap[reftemp.Data()];
1765  }
1766  } else if (tempattr == "position") {
1767  attr = gdml->GetFirstAttr(child);
1768  PosProcess(gdml, child, attr);
1769  reftemp = gdml->GetAttr(child, "name");
1770  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1771  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1772  }
1773  secondPos = fposmap[reftemp.Data()];
1774  } else if (tempattr == "positionref") {
1775  reftemp = gdml->GetAttr(child, "ref");
1776  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1777  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1778  }
1779  if (fposmap.find(reftemp.Data()) != fposmap.end()) {
1780  secondPos = fposmap[reftemp.Data()];
1781  }
1782  } else if (tempattr == "rotation") {
1783  attr = gdml->GetFirstAttr(child);
1784  RotProcess(gdml, child, attr);
1785  reftemp = gdml->GetAttr(child, "name");
1786  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1787  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1788  }
1789  secondRot = frotmap[reftemp.Data()];
1790  } else if (tempattr == "rotationref") {
1791  reftemp = gdml->GetAttr(child, "ref");
1792  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1793  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1794  }
1795  if (frotmap.find(reftemp.Data()) != frotmap.end()) {
1796  secondRot = frotmap[reftemp.Data()];
1797  }
1798  } else if (tempattr == "firstposition") {
1799  attr = gdml->GetFirstAttr(child);
1800  PosProcess(gdml, child, attr);
1801  reftemp = gdml->GetAttr(child, "name");
1802  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1803  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1804  }
1805  firstPos = fposmap[reftemp.Data()];
1806  } else if (tempattr == "firstpositionref") {
1807  reftemp = gdml->GetAttr(child, "ref");
1808  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1809  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1810  }
1811  if (fposmap.find(reftemp.Data()) != fposmap.end()) {
1812  firstPos = fposmap[reftemp.Data()];
1813  }
1814  } else if (tempattr == "firstrotation") {
1815  attr = gdml->GetFirstAttr(child);
1816  RotProcess(gdml, child, attr);
1817  reftemp = gdml->GetAttr(child, "name");
1818  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1819  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1820  }
1821  firstRot = frotmap[reftemp.Data()];
1822  } else if (tempattr == "firstrotationref") {
1823  reftemp = gdml->GetAttr(child, "ref");
1824  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1825  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1826  }
1827  if (frotmap.find(reftemp.Data()) != frotmap.end()) {
1828  firstRot = frotmap[reftemp.Data()];
1829  }
1830  }
1831  child = gdml->GetNext(child);
1832  }
1833 
1834  TGeoMatrix* firstMatrix = new TGeoCombiTrans(*firstPos, firstRot->Inverse());
1835  TGeoMatrix* secondMatrix = new TGeoCombiTrans(*secondPos, secondRot->Inverse());
1836 
1837  TGeoCompositeShape* boolean = 0;
1838  if (!first || !second) {
1839  Fatal("BooSolid", "Incomplete solid %s, missing shape components", name.Data());
1840  return child;
1841  }
1842  switch (num) {
1843  case 1:
1844  boolean = new TGeoCompositeShape(NameShort(name), new TGeoSubtraction(first, second, firstMatrix, secondMatrix));
1845  break; // SUBTRACTION
1846  case 2:
1847  boolean = new TGeoCompositeShape(NameShort(name), new TGeoIntersection(first, second, firstMatrix, secondMatrix));
1848  break; // INTERSECTION
1849  case 3:
1850  boolean = new TGeoCompositeShape(NameShort(name), new TGeoUnion(first, second, firstMatrix, secondMatrix));
1851  break; // UNION
1852  default:
1853  break;
1854  }
1855 
1856  fsolmap[name.Data()] = boolean;
1857 
1858  return child;
1859 }
1860 
1861 ////////////////////////////////////////////////////////////////////////////////
1862 /// User data to be processed.
1863 
1865 {
1866  XMLNodePointer_t child = gdml->GetChild(node);
1867  TString nodename, auxtype, auxtypec, auxvalue, auxvaluec, auxunit, auxunitc;
1868  double value = 0.;
1869  TGeoRegion *region;
1870  while (child) {
1871  region = nullptr;
1872  nodename = gdml->GetNodeName(child);
1873  if (nodename == "auxiliary") {
1874  auxtype = gdml->GetAttr(child, "auxtype");
1875  auxvalue = gdml->GetAttr(child, "auxvalue");
1876  if (auxtype == "Region") {
1877  auxvalue = NameShort(auxvalue);
1878  region = new TGeoRegion(auxvalue);
1879  }
1880  }
1881  XMLNodePointer_t subchild = gdml->GetChild(child);
1882  while (subchild) {
1883  auxtypec = gdml->GetAttr(subchild, "auxtype");
1884  auxvaluec = gdml->GetAttr(subchild, "auxvalue");
1885  auxunitc = gdml->GetAttr(subchild, "auxunit");
1886  if (auxtypec == "volume") {
1887  auxvaluec = NameShort(auxvaluec);
1888  if (region) region->AddVolume(auxvaluec);
1889  }
1890  if (auxtypec.Contains("cut")) {
1891  value = Value(auxvaluec) * GetScaleVal(auxunitc);
1892  if (region) region->AddCut(auxtypec, value);
1893  }
1894  subchild = gdml->GetNext(subchild);
1895  }
1896  if (region) {
1897  gGeoManager->AddRegion(region);
1898  // region->Print();
1899  }
1900  child = gdml->GetNext(child);
1901  }
1902  return child;
1903 }
1904 
1905 ////////////////////////////////////////////////////////////////////////////////
1906 /// In the structure section of the GDML file, assembly volumes can be
1907 /// declared. when the assembly keyword is found, this function is called,
1908 /// and the name is converted into type TGeoVolumeAssembly and
1909 /// stored in fvolmap map using the name as its key. Some assembly volumes
1910 /// reference to other physical volumes to contain inside that assembly,
1911 /// declaring positions and rotations within that volume. When each 'physvol'
1912 /// is declared, a matrix for its rotation and translation is built and the
1913 /// 'physvol node' is added to the original assembly using TGeoVolume->AddNode.
1914 
1916 {
1917  TString name = gdml->GetAttr(node, "name");
1918  TString reftemp = "";
1919 
1920  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1921  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
1922  }
1923 
1924  XMLAttrPointer_t attr;
1925  XMLNodePointer_t subchild;
1926  XMLNodePointer_t child = gdml->GetChild(node);
1927  TString tempattr = "";
1928  TGeoVolume* lv = 0;
1929  TGeoTranslation* pos = 0;
1930  TGeoRotation* rot = 0;
1931  TGeoCombiTrans* matr;
1932 
1933  TGeoVolumeAssembly* assem = new TGeoVolumeAssembly(NameShort(name));
1934 
1935 
1936  //PHYSVOL - run through child nodes of VOLUME again..
1937 
1938 // child = gdml->GetChild(node);
1939 
1940  while (child != 0) {
1941  if ((strcmp(gdml->GetNodeName(child), "physvol")) == 0) {
1942  TString pnodename = gdml->GetAttr(child, "name");
1943  TString scopynum = gdml->GetAttr(child, "copynumber");
1944  Int_t copynum = (scopynum.IsNull()) ? 0 : (Int_t)Value(scopynum);
1945 
1946  subchild = gdml->GetChild(child);
1947  pos = new TGeoTranslation(0, 0, 0);
1948  rot = new TGeoRotation();
1949 
1950  while (subchild != 0) {
1951  tempattr = gdml->GetNodeName(subchild);
1952  tempattr.ToLower();
1953 
1954  if (tempattr == "volumeref") {
1955  reftemp = gdml->GetAttr(subchild, "ref");
1956  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1957  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1958  }
1959  lv = fvolmap[reftemp.Data()];
1960  } else if (tempattr == "positionref") {
1961  reftemp = gdml->GetAttr(subchild, "ref");
1962  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1963  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1964  }
1965  if (fposmap.find(reftemp.Data()) != fposmap.end()) {
1966  pos = fposmap[reftemp.Data()];
1967  }
1968  } else if (tempattr == "position") {
1969  attr = gdml->GetFirstAttr(subchild);
1970  PosProcess(gdml, subchild, attr);
1971  reftemp = gdml->GetAttr(subchild, "name");
1972  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1973  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1974  }
1975  pos = fposmap[reftemp.Data()];
1976  } else if (tempattr == "rotationref") {
1977  reftemp = gdml->GetAttr(subchild, "ref");
1978  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1979  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1980  }
1981  if (frotmap.find(reftemp.Data()) != frotmap.end()) {
1982  rot = frotmap[reftemp.Data()];
1983  }
1984  } else if (tempattr == "rotation") {
1985  attr = gdml->GetFirstAttr(subchild);
1986  RotProcess(gdml, subchild, attr);
1987  reftemp = gdml->GetAttr(subchild, "name");
1988  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
1989  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
1990  }
1991  rot = frotmap[reftemp.Data()];
1992  }
1993 
1994  subchild = gdml->GetNext(subchild);
1995  }
1996 
1997  //ADD PHYSVOL TO GEOMETRY
1998  fVolID = fVolID + 1;
1999  matr = new TGeoCombiTrans(*pos, *rot);
2000  assem->AddNode(lv, copynum, matr);
2001  if (!pnodename.IsNull())
2002  ((TNamed*)assem->GetNodes()->Last())->SetName(pnodename);
2003 
2004  }
2005  child = gdml->GetNext(child);
2006  }
2007 
2008  fvolmap[name.Data()] = assem;
2009  return child;
2010 }
2011 
2012 ////////////////////////////////////////////////////////////////////////////////
2013 /// In the setup section of the GDML file, the top volume need to be
2014 /// declared. when the setup keyword is found, this function is called,
2015 /// and the top volume ref is taken and 'world' is set
2016 
2018 {
2019  const char* name = gdml->GetAttr(node, "name");
2020  gGeoManager->SetName(name);
2021  XMLNodePointer_t child = gdml->GetChild(node);
2022  TString reftemp = "";
2023 
2024  while (child != 0) {
2025 
2026  if ((strcmp(gdml->GetNodeName(child), "world") == 0)) {
2027  //const char* reftemp;
2028  //TString reftemp = "";
2029  reftemp = gdml->GetAttr(child, "ref");
2030 
2031 
2032  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2033  reftemp = TString::Format("%s_%s", reftemp.Data(), fCurrentFile);
2034 
2035  }
2036  fWorld = fvolmap[reftemp.Data()];
2037  fWorldName = reftemp.Data();
2038 
2039  }
2040  child = gdml->GetNext(child);
2041  }
2042  return node;
2043 }
2044 
2045 ////////////////////////////////////////////////////////////////////////////////
2046 /// In the solids section of the GDML file, a box may be declared.
2047 /// when the box keyword is found, this function is called, and the
2048 /// dimensions required are taken and stored, these are then bound and
2049 /// converted to type TGeoBBox and stored in fsolmap map using the name
2050 /// as its key.
2051 
2053 {
2054  TString lunit = "mm";
2055  TString xpos = "0";
2056  TString ypos = "0";
2057  TString zpos = "0";
2058  TString name = "";
2059  TString tempattr;
2060 
2061  while (attr != 0) {
2062 
2063  tempattr = gdml->GetAttrName(attr);
2064  tempattr.ToLower();
2065 
2066  if (tempattr == "name") {
2067  name = gdml->GetAttrValue(attr);
2068  } else if (tempattr == "x") {
2069  xpos = gdml->GetAttrValue(attr);
2070  } else if (tempattr == "y") {
2071  ypos = gdml->GetAttrValue(attr);
2072  } else if (tempattr == "z") {
2073  zpos = gdml->GetAttrValue(attr);
2074  } else if (tempattr == "lunit") {
2075  lunit = gdml->GetAttrValue(attr);
2076  }
2077 
2078  attr = gdml->GetNextAttr(attr);
2079  }
2080 
2081  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2082  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2083  }
2084 
2085  Double_t retunit = GetScaleVal(lunit);
2086 
2087  Double_t xline = 0.5*Value(xpos)*retunit;
2088  Double_t yline = 0.5*Value(ypos)*retunit;
2089  Double_t zline = 0.5*Value(zpos)*retunit;
2090 
2091 
2092  TGeoBBox* box = new TGeoBBox(NameShort(name), xline, yline, zline);
2093 
2094  fsolmap[name.Data()] = box;
2095 
2096  return node;
2097 
2098 }
2099 
2100 ////////////////////////////////////////////////////////////////////////////////
2101 /// In the solids section of the GDML file, an ellipsoid may be declared.
2102 /// Unfortunately, the ellipsoid is not supported under ROOT so,
2103 /// when the ellipsoid keyword is found, this function is called
2104 /// to convert it to a simple box with similar dimensions, and the
2105 /// dimensions required are taken and stored, these are then bound and
2106 /// converted to type TGeoBBox and stored in fsolmap map using the name
2107 /// as its key.
2108 
2110 {
2111  TString lunit = "mm";
2112  TString ax = "0";
2113  TString by = "0";
2114  TString cz = "0";
2115  //initialization to empty string
2116  TString zcut1 = "";
2117  TString zcut2 = "";
2118  TString name = "";
2119  TString tempattr;
2120 
2121  while (attr != 0) {
2122 
2123  tempattr = gdml->GetAttrName(attr);
2124  tempattr.ToLower();
2125 
2126  if (tempattr == "name") {
2127  name = gdml->GetAttrValue(attr);
2128  } else if (tempattr == "ax") {
2129  ax = gdml->GetAttrValue(attr);
2130  } else if (tempattr == "by") {
2131  by = gdml->GetAttrValue(attr);
2132  } else if (tempattr == "cz") {
2133  cz = gdml->GetAttrValue(attr);
2134  } else if (tempattr == "zcut1") {
2135  zcut1 = gdml->GetAttrValue(attr);
2136  } else if (tempattr == "zcut2") {
2137  zcut2 = gdml->GetAttrValue(attr);
2138  } else if (tempattr == "lunit") {
2139  lunit = gdml->GetAttrValue(attr);
2140  }
2141 
2142  attr = gdml->GetNextAttr(attr);
2143  }
2144 
2145  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2146  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2147  }
2148 
2149  Double_t retunit = GetScaleVal(lunit);
2150 
2151  Double_t dx = Value(ax)*retunit;
2152  Double_t dy = Value(by)*retunit;
2153  Double_t radius = Value(cz)*retunit;
2154  Double_t sx = dx / radius;
2155  Double_t sy = dy / radius;
2156  Double_t sz = 1.;
2157  Double_t z1, z2;
2158  //Initialization of cutting
2159  if (zcut1 == "") {
2160  z1 = -radius;
2161  } else {
2162  z1 = Value(zcut1)*retunit;
2163  }
2164  if (zcut2 == "") {
2165  z2 = radius;
2166  } else {
2167  z2 = Value(zcut2)*retunit;
2168  }
2169 
2170  TGeoSphere *sph = new TGeoSphere(0, radius);
2171  TGeoScale *scl = new TGeoScale("", sx, sy, sz);
2172  TGeoScaledShape *shape = new TGeoScaledShape(NameShort(name), sph, scl);
2173 
2174  Double_t origin[3] = {0., 0., 0.};
2175  origin[2] = 0.5 * (z1 + z2);
2176  Double_t dz = 0.5 * (z2 - z1);
2177  TGeoBBox *pCutBox = new TGeoBBox("cutBox", dx, dy, dz, origin);
2178  TGeoBoolNode *pBoolNode = new TGeoIntersection(shape, pCutBox, 0, 0);
2179  TGeoCompositeShape *cs = new TGeoCompositeShape(NameShort(name), pBoolNode);
2180  fsolmap[name.Data()] = cs;
2181 
2182  return node;
2183 
2184 }
2185 
2186 ////////////////////////////////////////////////////////////////////////////////
2187 /// In the solids section of the GDML file, an elliptical cone may be declared.
2188 /// Unfortunately, the elliptical cone is not supported under ROOT so,
2189 /// when the elcone keyword is found, this function is called
2190 /// to convert it to a simple box with similar dimensions, and the
2191 /// dimensions required are taken and stored, these are then bound and
2192 /// converted to type TGeoBBox and stored in fsolmap map using the name
2193 /// as its key.
2194 
2196 {
2197  TString lunit = "mm";
2198  TString dx = "0";
2199  TString dy = "0";
2200  TString zmax = "0";
2201  TString zcut = "0";
2202  TString name = "";
2203  TString tempattr;
2204 
2205  while (attr != 0) {
2206 
2207  tempattr = gdml->GetAttrName(attr);
2208  tempattr.ToLower();
2209 
2210  if (tempattr == "name") {
2211  name = gdml->GetAttrValue(attr);
2212  } else if (tempattr == "dx") {
2213  dx = gdml->GetAttrValue(attr);
2214  } else if (tempattr == "dy") {
2215  dy = gdml->GetAttrValue(attr);
2216  } else if (tempattr == "zmax") {
2217  zmax = gdml->GetAttrValue(attr);
2218  } else if (tempattr == "zcut") {
2219  zcut = gdml->GetAttrValue(attr);
2220  } else if (tempattr == "lunit") {
2221  lunit = gdml->GetAttrValue(attr);
2222  }
2223 
2224  attr = gdml->GetNextAttr(attr);
2225  }
2226 
2227  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2228  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2229  }
2230 
2231  //semiaxises of elliptical cone (elcone) are different then ellipsoid
2232 
2233  Double_t retunit = GetScaleVal(lunit);
2234 
2235  //dxline and dyline are without units because they are as a ration
2236  Double_t dxratio = Value(dx);
2237  Double_t dyratio = Value(dy);
2238  Double_t z = Value(zmax)*retunit;
2239  Double_t z1 = Value(zcut)*retunit;
2240 
2241  if (z1 <= 0) {
2242  Info("ElCone", "ERROR! Parameter zcut = %.12g is not set properly, elcone will not be imported.", z1);
2243  return node;
2244  }
2245  if (z1 > z){
2246  z1 = z;
2247  }
2248  Double_t rx1 = (z + z1) * dxratio;
2249  Double_t ry1 = (z + z1) * dyratio;
2250  Double_t rx2 = (z - z1) * dxratio;
2251  Double_t sx = 1.;
2252  Double_t sy = ry1 / rx1;
2253  Double_t sz = 1.;
2254 
2255  TGeoCone *con = new TGeoCone(z1, 0, rx1, 0, rx2);
2256  TGeoScale *scl = new TGeoScale("", sx, sy, sz);
2257  TGeoScaledShape *shape = new TGeoScaledShape(NameShort(name), con, scl);
2258 
2259  fsolmap[name.Data()] = shape;
2260 
2261  return node;
2262 
2263 }
2264 
2265 ////////////////////////////////////////////////////////////////////////////////
2266 /// In the solids section of the GDML file, a Paraboloid may be declared.
2267 /// when the paraboloid keyword is found, this function is called, and the
2268 /// dimensions required are taken and stored, these are then bound and
2269 /// converted to type TGeoParaboloid and stored in fsolmap map using the name
2270 /// as its key.
2271 
2273 {
2274  TString lunit = "mm";
2275  TString rlopos = "0";
2276  TString rhipos = "0";
2277  TString dzpos = "0";
2278  TString name = "";
2279  TString tempattr;
2280 
2281  while (attr != 0) {
2282 
2283  tempattr = gdml->GetAttrName(attr);
2284  tempattr.ToLower();
2285 
2286  if (tempattr == "name") {
2287  name = gdml->GetAttrValue(attr);
2288  } else if (tempattr == "rlo") {
2289  rlopos = gdml->GetAttrValue(attr);
2290  } else if (tempattr == "rhi") {
2291  rhipos = gdml->GetAttrValue(attr);
2292  } else if (tempattr == "dz") {
2293  dzpos = gdml->GetAttrValue(attr);
2294  } else if (tempattr == "lunit") {
2295  lunit = gdml->GetAttrValue(attr);
2296  }
2297 
2298  attr = gdml->GetNextAttr(attr);
2299  }
2300 
2301  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2302  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2303  }
2304 
2305  Double_t retunit = GetScaleVal(lunit);
2306 
2307  Double_t rlo = Value(rlopos)*retunit;
2308  Double_t rhi = Value(rhipos)*retunit;
2309  Double_t dz = Value(dzpos)*retunit;
2310 
2311  TGeoParaboloid* paraboloid = new TGeoParaboloid(NameShort(name), rlo, rhi, dz);
2312 
2313  fsolmap[name.Data()] = paraboloid;
2314 
2315  return node;
2316 
2317 }
2318 
2319 ////////////////////////////////////////////////////////////////////////////////
2320 /// In the solids section of the GDML file, an Arb8 may be declared.
2321 /// when the arb8 keyword is found, this function is called, and the
2322 /// dimensions required are taken and stored, these are then bound and
2323 /// converted to type TGeoArb8 and stored in fsolmap map using the name
2324 /// as its key.
2325 
2327 {
2328  TString lunit = "mm";
2329  TString v1xpos = "0";
2330  TString v1ypos = "0";
2331  TString v2xpos = "0";
2332  TString v2ypos = "0";
2333  TString v3xpos = "0";
2334  TString v3ypos = "0";
2335  TString v4xpos = "0";
2336  TString v4ypos = "0";
2337  TString v5xpos = "0";
2338  TString v5ypos = "0";
2339  TString v6xpos = "0";
2340  TString v6ypos = "0";
2341  TString v7xpos = "0";
2342  TString v7ypos = "0";
2343  TString v8xpos = "0";
2344  TString v8ypos = "0";
2345  TString dzpos = "0";
2346  TString name = "";
2347  TString tempattr;
2348 
2349  while (attr != 0) {
2350 
2351  tempattr = gdml->GetAttrName(attr);
2352  tempattr.ToLower();
2353 
2354  if (tempattr == "name") {
2355  name = gdml->GetAttrValue(attr);
2356  } else if (tempattr == "v1x") {
2357  v1xpos = gdml->GetAttrValue(attr);
2358  } else if (tempattr == "v1y") {
2359  v1ypos = gdml->GetAttrValue(attr);
2360  } else if (tempattr == "v2x") {
2361  v2xpos = gdml->GetAttrValue(attr);
2362  } else if (tempattr == "v2y") {
2363  v2ypos = gdml->GetAttrValue(attr);
2364  } else if (tempattr == "v3x") {
2365  v3xpos = gdml->GetAttrValue(attr);
2366  } else if (tempattr == "v3y") {
2367  v3ypos = gdml->GetAttrValue(attr);
2368  } else if (tempattr == "v4x") {
2369  v4xpos = gdml->GetAttrValue(attr);
2370  } else if (tempattr == "v4y") {
2371  v4ypos = gdml->GetAttrValue(attr);
2372  } else if (tempattr == "v5x") {
2373  v5xpos = gdml->GetAttrValue(attr);
2374  } else if (tempattr == "v5y") {
2375  v5ypos = gdml->GetAttrValue(attr);
2376  } else if (tempattr == "v6x") {
2377  v6xpos = gdml->GetAttrValue(attr);
2378  } else if (tempattr == "v6y") {
2379  v6ypos = gdml->GetAttrValue(attr);
2380  } else if (tempattr == "v7x") {
2381  v7xpos = gdml->GetAttrValue(attr);
2382  } else if (tempattr == "v7y") {
2383  v7ypos = gdml->GetAttrValue(attr);
2384  } else if (tempattr == "v8x") {
2385  v8xpos = gdml->GetAttrValue(attr);
2386  } else if (tempattr == "v8y") {
2387  v8ypos = gdml->GetAttrValue(attr);
2388  } else if (tempattr == "dz") {
2389  dzpos = gdml->GetAttrValue(attr);
2390  } else if (tempattr == "lunit") {
2391  lunit = gdml->GetAttrValue(attr);
2392  }
2393 
2394  attr = gdml->GetNextAttr(attr);
2395  }
2396 
2397  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2398  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2399  }
2400 
2401  Double_t retunit = GetScaleVal(lunit);
2402 
2403  Double_t v1x = Value(v1xpos)*retunit;
2404  Double_t v1y = Value(v1ypos)*retunit;
2405  Double_t v2x = Value(v2xpos)*retunit;
2406  Double_t v2y = Value(v2ypos)*retunit;
2407  Double_t v3x = Value(v3xpos)*retunit;
2408  Double_t v3y = Value(v3ypos)*retunit;
2409  Double_t v4x = Value(v4xpos)*retunit;
2410  Double_t v4y = Value(v4ypos)*retunit;
2411  Double_t v5x = Value(v5xpos)*retunit;
2412  Double_t v5y = Value(v5ypos)*retunit;
2413  Double_t v6x = Value(v6xpos)*retunit;
2414  Double_t v6y = Value(v6ypos)*retunit;
2415  Double_t v7x = Value(v7xpos)*retunit;
2416  Double_t v7y = Value(v7ypos)*retunit;
2417  Double_t v8x = Value(v8xpos)*retunit;
2418  Double_t v8y = Value(v8ypos)*retunit;
2419  Double_t dz = Value(dzpos)*retunit;
2420 
2421 
2422  TGeoArb8* arb8 = new TGeoArb8(NameShort(name), dz);
2423 
2424  arb8->SetVertex(0, v1x, v1y);
2425  arb8->SetVertex(1, v2x, v2y);
2426  arb8->SetVertex(2, v3x, v3y);
2427  arb8->SetVertex(3, v4x, v4y);
2428  arb8->SetVertex(4, v5x, v5y);
2429  arb8->SetVertex(5, v6x, v6y);
2430  arb8->SetVertex(6, v7x, v7y);
2431  arb8->SetVertex(7, v8x, v8y);
2432 
2433  fsolmap[name.Data()] = arb8;
2434 
2435  return node;
2436 
2437 }
2438 
2439 ////////////////////////////////////////////////////////////////////////////////
2440 /// In the solids section of the GDML file, a Tube may be declared.
2441 /// when the tube keyword is found, this function is called, and the
2442 /// dimensions required are taken and stored, these are then bound and
2443 /// converted to type TGeoTubeSeg and stored in fsolmap map using the name
2444 /// as its key.
2445 
2447 {
2448  TString lunit = "mm";
2449  TString aunit = "rad";
2450  TString rmin = "0";
2451  TString rmax = "0";
2452  TString z = "0";
2453  TString startphi = "0";
2454  TString deltaphi = "0";
2455  TString name = "";
2456  TString tempattr;
2457 
2458  while (attr != 0) {
2459 
2460  tempattr = gdml->GetAttrName(attr);
2461  tempattr.ToLower();
2462 
2463  if (tempattr == "name") {
2464  name = gdml->GetAttrValue(attr);
2465  } else if (tempattr == "rmin") {
2466  rmin = gdml->GetAttrValue(attr);
2467  } else if (tempattr == "rmax") {
2468  rmax = gdml->GetAttrValue(attr);
2469  } else if (tempattr == "z") {
2470  z = gdml->GetAttrValue(attr);
2471  } else if (tempattr == "lunit") {
2472  lunit = gdml->GetAttrValue(attr);
2473  } else if (tempattr == "aunit") {
2474  aunit = gdml->GetAttrValue(attr);
2475  } else if (tempattr == "startphi") {
2476  startphi = gdml->GetAttrValue(attr);
2477  } else if (tempattr == "deltaphi") {
2478  deltaphi = gdml->GetAttrValue(attr);
2479  }
2480 
2481  attr = gdml->GetNextAttr(attr);
2482  }
2483 
2484  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2485  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2486  }
2487 
2488  Double_t retlunit = GetScaleVal(lunit);
2489  Double_t retaunit = GetScaleVal(aunit);
2490 
2491  Double_t rminline = Value(rmin)*retlunit;
2492  Double_t rmaxline = Value(rmax)*retlunit;
2493  Double_t zline = Value(z)*retlunit;
2494  Double_t startphideg = Value(startphi)*retaunit;
2495  Double_t deltaphideg = Value(deltaphi)*retaunit;
2496  Double_t endphideg = startphideg + deltaphideg;
2497 
2498  TGeoShape *tube = 0;
2499  if (deltaphideg < 360.)
2500  tube = new TGeoTubeSeg(NameShort(name), rminline,
2501  rmaxline,
2502  zline / 2,
2503  startphideg,
2504  endphideg);
2505  else
2506  tube = new TGeoTube(NameShort(name), rminline,
2507  rmaxline,
2508  zline / 2);
2509  fsolmap[name.Data()] = tube;
2510 
2511  return node;
2512 
2513 }
2514 
2515 ////////////////////////////////////////////////////////////////////////////////
2516 /// In the solids section of the GDML file, a Cut Tube may be declared.
2517 /// when the cutTube keyword is found, this function is called, and the
2518 /// dimensions required are taken and stored, these are then bound and
2519 /// converted to type TGeoCtub and stored in fsolmap map using the name
2520 /// as its key.
2521 
2523 {
2524  TString lunit = "mm";
2525  TString aunit = "rad";
2526  TString rmin = "0";
2527  TString rmax = "0";
2528  TString z = "0";
2529  TString startphi = "0";
2530  TString deltaphi = "0";
2531  TString lowX = "0";
2532  TString lowY = "0";
2533  TString lowZ = "0";
2534  TString highX = "0";
2535  TString highY = "0";
2536  TString highZ = "0";
2537  TString name = "";
2538  TString tempattr;
2539 
2540  while (attr != 0) {
2541 
2542  tempattr = gdml->GetAttrName(attr);
2543  tempattr.ToLower();
2544 
2545  if (tempattr == "name") {
2546  name = gdml->GetAttrValue(attr);
2547  } else if (tempattr == "rmin") {
2548  rmin = gdml->GetAttrValue(attr);
2549  } else if (tempattr == "rmax") {
2550  rmax = gdml->GetAttrValue(attr);
2551  } else if (tempattr == "z") {
2552  z = gdml->GetAttrValue(attr);
2553  } else if (tempattr == "lunit") {
2554  lunit = gdml->GetAttrValue(attr);
2555  } else if (tempattr == "aunit") {
2556  aunit = gdml->GetAttrValue(attr);
2557  } else if (tempattr == "startphi") {
2558  startphi = gdml->GetAttrValue(attr);
2559  } else if (tempattr == "deltaphi") {
2560  deltaphi = gdml->GetAttrValue(attr);
2561  } else if (tempattr == "lowx") {
2562  lowX = gdml->GetAttrValue(attr);
2563  } else if (tempattr == "lowy") {
2564  lowY = gdml->GetAttrValue(attr);
2565  } else if (tempattr == "lowz") {
2566  lowZ = gdml->GetAttrValue(attr);
2567  } else if (tempattr == "highx") {
2568  highX = gdml->GetAttrValue(attr);
2569  } else if (tempattr == "highy") {
2570  highY = gdml->GetAttrValue(attr);
2571  } else if (tempattr == "highz") {
2572  highZ = gdml->GetAttrValue(attr);
2573  }
2574 
2575  attr = gdml->GetNextAttr(attr);
2576  }
2577 
2578  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2579  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2580  }
2581 
2582  Double_t retlunit = GetScaleVal(lunit);
2583  Double_t retaunit = GetScaleVal(aunit);
2584 
2585  Double_t rminline = Value(rmin)*retlunit;
2586  Double_t rmaxline = Value(rmax)*retlunit;
2587  Double_t zline = Value(z)*retlunit;
2588  Double_t startphiline = Value(startphi)*retaunit;
2589  Double_t deltaphiline = Value(deltaphi)*retaunit + startphiline;
2590  Double_t lowXline = Value(lowX)*retlunit;
2591  Double_t lowYline = Value(lowY)*retlunit;
2592  Double_t lowZline = Value(lowZ)*retlunit;
2593  Double_t highXline = Value(highX)*retlunit;
2594  Double_t highYline = Value(highY)*retlunit;
2595  Double_t highZline = Value(highZ)*retlunit;
2596 
2597 
2598  TGeoCtub* cuttube = new TGeoCtub(NameShort(name), rminline,
2599  rmaxline,
2600  zline / 2,
2601  startphiline,
2602  deltaphiline,
2603  lowXline,
2604  lowYline,
2605  lowZline,
2606  highXline,
2607  highYline,
2608  highZline);
2609 
2610 
2611  fsolmap[name.Data()] = cuttube;
2612 
2613  return node;
2614 
2615 }
2616 
2617 ////////////////////////////////////////////////////////////////////////////////
2618 /// In the solids section of the GDML file, a cone may be declared.
2619 /// when the cone keyword is found, this function is called, and the
2620 /// dimensions required are taken and stored, these are then bound and
2621 /// converted to type TGeoConSeg and stored in fsolmap map using the name
2622 /// as its key.
2623 
2625 {
2626  TString lunit = "mm";
2627  TString aunit = "rad";
2628  TString rmin1 = "0";
2629  TString rmax1 = "0";
2630  TString rmin2 = "0";
2631  TString rmax2 = "0";
2632  TString z = "0";
2633  TString startphi = "0";
2634  TString deltaphi = "0";
2635  TString name = "";
2636  TString tempattr;
2637 
2638  while (attr != 0) {
2639 
2640  tempattr = gdml->GetAttrName(attr);
2641  tempattr.ToLower();
2642 
2643  if (tempattr == "name") {
2644  name = gdml->GetAttrValue(attr);
2645  } else if (tempattr == "rmin1") {
2646  rmin1 = gdml->GetAttrValue(attr);
2647  } else if (tempattr == "rmax1") {
2648  rmax1 = gdml->GetAttrValue(attr);
2649  } else if (tempattr == "rmin2") {
2650  rmin2 = gdml->GetAttrValue(attr);
2651  } else if (tempattr == "rmax2") {
2652  rmax2 = gdml->GetAttrValue(attr);
2653  } else if (tempattr == "z") {
2654  z = gdml->GetAttrValue(attr);
2655  } else if (tempattr == "lunit") {
2656  lunit = gdml->GetAttrValue(attr);
2657  } else if (tempattr == "aunit") {
2658  aunit = gdml->GetAttrValue(attr);
2659  } else if (tempattr == "startphi") {
2660  startphi = gdml->GetAttrValue(attr);
2661  } else if (tempattr == "deltaphi") {
2662  deltaphi = gdml->GetAttrValue(attr);
2663  }
2664 
2665  attr = gdml->GetNextAttr(attr);
2666  }
2667 
2668  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2669  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2670  }
2671 
2672  Double_t retlunit = GetScaleVal(lunit);
2673  Double_t retaunit = GetScaleVal(aunit);
2674 
2675  Double_t rmin1line = Value(rmin1)*retlunit;
2676  Double_t rmax1line = Value(rmax1)*retlunit;
2677  Double_t rmin2line = Value(rmin2)*retlunit;
2678  Double_t rmax2line = Value(rmax2)*retlunit;
2679  Double_t zline = Value(z)*retlunit;
2680  Double_t sphi = Value(startphi)*retaunit;
2681  Double_t dphi = Value(deltaphi)*retaunit;
2682  Double_t ephi = sphi + dphi;
2683 
2684  TGeoShape *cone = 0;
2685  if (dphi < 360.)
2686  cone = new TGeoConeSeg(NameShort(name), zline / 2,
2687  rmin1line,
2688  rmax1line,
2689  rmin2line,
2690  rmax2line,
2691  sphi, ephi);
2692  else
2693  cone = new TGeoCone(NameShort(name), zline / 2,
2694  rmin1line,
2695  rmax1line,
2696  rmin2line,
2697  rmax2line);
2698 
2699  fsolmap[name.Data()] = cone;
2700 
2701  return node;
2702 
2703 }
2704 
2705 ////////////////////////////////////////////////////////////////////////////////
2706 /// In the solids section of the GDML file, a Trap may be declared.
2707 /// when the trap keyword is found, this function is called, and the
2708 /// dimensions required are taken and stored, these are then bound and
2709 /// converted to type TGeoTrap and stored in fsolmap map using the name
2710 /// as its key.
2711 
2713 {
2714  TString lunit = "mm";
2715  TString aunit = "rad";
2716  TString x1 = "0";
2717  TString x2 = "0";
2718  TString x3 = "0";
2719  TString x4 = "0";
2720  TString y1 = "0";
2721  TString y2 = "0";
2722  TString z = "0";
2723  TString phi = "0";
2724  TString theta = "0";
2725  TString alpha1 = "0";
2726  TString alpha2 = "0";
2727  TString name = "";
2728  TString tempattr;
2729 
2730  while (attr != 0) {
2731 
2732  tempattr = gdml->GetAttrName(attr);
2733  tempattr.ToLower();
2734 
2735  if (tempattr == "name") {
2736  name = gdml->GetAttrValue(attr);
2737  } else if (tempattr == "x1") {
2738  x1 = gdml->GetAttrValue(attr);
2739  } else if (tempattr == "x2") {
2740  x2 = gdml->GetAttrValue(attr);
2741  } else if (tempattr == "x3") {
2742  x3 = gdml->GetAttrValue(attr);
2743  } else if (tempattr == "x4") {
2744  x4 = gdml->GetAttrValue(attr);
2745  } else if (tempattr == "y1") {
2746  y1 = gdml->GetAttrValue(attr);
2747  } else if (tempattr == "y2") {
2748  y2 = gdml->GetAttrValue(attr);
2749  } else if (tempattr == "z") {
2750  z = gdml->GetAttrValue(attr);
2751  } else if (tempattr == "lunit") {
2752  lunit = gdml->GetAttrValue(attr);
2753  } else if (tempattr == "aunit") {
2754  aunit = gdml->GetAttrValue(attr);
2755  } else if (tempattr == "phi") {
2756  phi = gdml->GetAttrValue(attr);
2757  } else if (tempattr == "theta") {
2758  theta = gdml->GetAttrValue(attr);
2759  } else if (tempattr == "alpha1") {
2760  alpha1 = gdml->GetAttrValue(attr);
2761  } else if (tempattr == "alpha2") {
2762  alpha2 = gdml->GetAttrValue(attr);
2763  }
2764 
2765  attr = gdml->GetNextAttr(attr);
2766  }
2767 
2768  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2769  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2770  }
2771 
2772  Double_t retlunit = GetScaleVal(lunit);
2773  Double_t retaunit = GetScaleVal(aunit);
2774 
2775  Double_t x1line = Value(x1)*retlunit;
2776  Double_t x2line = Value(x2)*retlunit;
2777  Double_t x3line = Value(x3)*retlunit;
2778  Double_t x4line = Value(x4)*retlunit;
2779  Double_t y1line = Value(y1)*retlunit;
2780  Double_t y2line = Value(y2)*retlunit;
2781  Double_t zline = Value(z)*retlunit;
2782  Double_t philine = Value(phi)*retaunit;
2783  Double_t thetaline = Value(theta)*retaunit;
2784  Double_t alpha1line = Value(alpha1)*retaunit;
2785  Double_t alpha2line = Value(alpha2)*retaunit;
2786 
2787  TGeoTrap* trap = new TGeoTrap(NameShort(name), zline / 2,
2788  thetaline,
2789  philine,
2790  y1line / 2,
2791  x1line / 2,
2792  x2line / 2,
2793  alpha1line,
2794  y2line / 2,
2795  x3line / 2,
2796  x4line / 2,
2797  alpha2line);
2798 
2799  fsolmap[name.Data()] = trap;
2800 
2801  return node;
2802 
2803 }
2804 
2805 ////////////////////////////////////////////////////////////////////////////////
2806 /// In the solids section of the GDML file, a Trd may be declared.
2807 /// when the trd keyword is found, this function is called, and the
2808 /// dimensions required are taken and stored, these are then bound and
2809 /// converted to type TGeoTrd2 and stored in fsolmap map using the name
2810 /// as its key.
2811 
2813 {
2814  TString lunit = "mm";
2815  TString x1 = "0";
2816  TString x2 = "0";
2817  TString y1 = "0";
2818  TString y2 = "0";
2819  TString z = "0";
2820  TString name = "";
2821  TString tempattr;
2822 
2823  while (attr != 0) {
2824 
2825  tempattr = gdml->GetAttrName(attr);
2826  tempattr.ToLower();
2827 
2828  if (tempattr == "name") {
2829  name = gdml->GetAttrValue(attr);
2830  } else if (tempattr == "x1") {
2831  x1 = gdml->GetAttrValue(attr);
2832  } else if (tempattr == "x2") {
2833  x2 = gdml->GetAttrValue(attr);
2834  } else if (tempattr == "y1") {
2835  y1 = gdml->GetAttrValue(attr);
2836  } else if (tempattr == "y2") {
2837  y2 = gdml->GetAttrValue(attr);
2838  } else if (tempattr == "z") {
2839  z = gdml->GetAttrValue(attr);
2840  } else if (tempattr == "lunit") {
2841  lunit = gdml->GetAttrValue(attr);
2842  }
2843 
2844  attr = gdml->GetNextAttr(attr);
2845  }
2846 
2847  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2848  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2849  }
2850 
2851  Double_t retlunit = GetScaleVal(lunit);
2852 
2853  Double_t x1line = Value(x1)*retlunit;
2854  Double_t x2line = Value(x2)*retlunit;
2855  Double_t y1line = Value(y1)*retlunit;
2856  Double_t y2line = Value(y2)*retlunit;
2857  Double_t zline = Value(z)*retlunit;
2858 
2859  TGeoTrd2* trd = new TGeoTrd2(NameShort(name),
2860  x1line / 2,
2861  x2line / 2,
2862  y1line / 2,
2863  y2line / 2,
2864  zline / 2);
2865 
2866  fsolmap[name.Data()] = trd;
2867 
2868  return node;
2869 
2870 }
2871 
2872 ////////////////////////////////////////////////////////////////////////////////
2873 /// In the solids section of the GDML file, a Polycone may be declared.
2874 /// when the polycone keyword is found, this function is called, and the
2875 /// dimensions required are taken and stored, these are then bound and
2876 /// converted to type TGeoPCon and stored in fsolmap map using the name
2877 /// as its key. Polycone has Zplanes, planes along the z axis specifying
2878 /// the rmin, rmax dimensions at that point along z.
2879 
2881 {
2882  TString lunit = "mm";
2883  TString aunit = "rad";
2884  TString rmin = "0";
2885  TString rmax = "0";
2886  TString z = "0";
2887  TString startphi = "0";
2888  TString deltaphi = "0";
2889  TString name = "";
2890  TString tempattr;
2891 
2892  while (attr != 0) {
2893 
2894  tempattr = gdml->GetAttrName(attr);
2895  tempattr.ToLower();
2896 
2897  if (tempattr == "name") {
2898  name = gdml->GetAttrValue(attr);
2899  } else if (tempattr == "lunit") {
2900  lunit = gdml->GetAttrValue(attr);
2901  } else if (tempattr == "aunit") {
2902  aunit = gdml->GetAttrValue(attr);
2903  } else if (tempattr == "startphi") {
2904  startphi = gdml->GetAttrValue(attr);
2905  } else if (tempattr == "deltaphi") {
2906  deltaphi = gdml->GetAttrValue(attr);
2907  }
2908  attr = gdml->GetNextAttr(attr);
2909  }
2910 
2911  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
2912  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
2913  }
2914 
2915  Double_t retlunit = GetScaleVal(lunit);
2916  Double_t retaunit = GetScaleVal(aunit);
2917 
2918  //START TO LOOK THRU CHILD (ZPLANE) NODES...
2919 
2920  XMLNodePointer_t child = gdml->GetChild(node);
2921  int numplanes = 0;
2922 
2923  while (child != 0) {
2924  numplanes = numplanes + 1;
2925  child = gdml->GetNext(child);
2926  }
2927 
2928  int cols;
2929  int i;
2930  cols = 3;
2931  double ** table = new double*[numplanes];
2932  for (i = 0; i < numplanes; i++) {
2933  table[i] = new double[cols];
2934  }
2935 
2936  child = gdml->GetChild(node);
2937  int planeno = 0;
2938 
2939  while (child != 0) {
2940  if (strcmp(gdml->GetNodeName(child), "zplane") == 0) {
2941  //removed original dec
2942  Double_t rminline = 0;
2943  Double_t rmaxline = 0;
2944  Double_t zline = 0;
2945 
2946  attr = gdml->GetFirstAttr(child);
2947 
2948  while (attr != 0) {
2949  tempattr = gdml->GetAttrName(attr);
2950  tempattr.ToLower();
2951 
2952  if (tempattr == "rmin") {
2953  rmin = gdml->GetAttrValue(attr);
2954  rminline = Value(rmin)*retlunit;
2955  table[planeno][0] = rminline;
2956  } else if (tempattr == "rmax") {
2957  rmax = gdml->GetAttrValue(attr);
2958  rmaxline = Value(rmax)*retlunit;
2959  table[planeno][1] = rmaxline;
2960  } else if (tempattr == "z") {
2961  z = gdml->GetAttrValue(attr);
2962  zline = Value(z)*retlunit;
2963  table[planeno][2] = zline;
2964  }
2965  attr = gdml->GetNextAttr(attr);
2966  }
2967  }
2968  planeno = planeno + 1;
2969  child = gdml->GetNext(child);
2970  }
2971 
2972  Double_t startphiline = Value(startphi)*retaunit;
2973  Double_t deltaphiline = Value(deltaphi)*retaunit;
2974 
2975  TGeoPcon* poly = new TGeoPcon(NameShort(name),
2976  startphiline,
2977  deltaphiline,
2978  numplanes);
2979  Int_t zno = 0;
2980 
2981  for (int j = 0; j < numplanes; j++) {
2982  poly->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
2983  zno = zno + 1;
2984  }
2985 
2986  fsolmap[name.Data()] = poly;
2987  for (i = 0; i < numplanes; i++) {
2988  delete [] table[i];
2989  }
2990  delete [] table;
2991 
2992  return node;
2993 }
2994 
2995 ////////////////////////////////////////////////////////////////////////////////
2996 /// In the solids section of the GDML file, a Polyhedra may be declared.
2997 /// when the polyhedra keyword is found, this function is called, and the
2998 /// dimensions required are taken and stored, these are then bound and
2999 /// converted to type TGeoPgon and stored in fsolmap map using the name
3000 /// as its key. Polycone has Zplanes, planes along the z axis specifying
3001 /// the rmin, rmax dimensions at that point along z.
3002 
3004 {
3005  TString lunit = "mm";
3006  TString aunit = "rad";
3007  TString rmin = "0";
3008  TString rmax = "0";
3009  TString z = "0";
3010  TString startphi = "0";
3011  TString deltaphi = "0";
3012  TString numsides = "1";
3013  TString name = "";
3014  TString tempattr;
3015 
3016  while (attr != 0) {
3017 
3018  tempattr = gdml->GetAttrName(attr);
3019  tempattr.ToLower();
3020 
3021  if (tempattr == "name") {
3022  name = gdml->GetAttrValue(attr);
3023  } else if (tempattr == "lunit") {
3024  lunit = gdml->GetAttrValue(attr);
3025  } else if (tempattr == "aunit") {
3026  aunit = gdml->GetAttrValue(attr);
3027  } else if (tempattr == "startphi") {
3028  startphi = gdml->GetAttrValue(attr);
3029  } else if (tempattr == "deltaphi") {
3030  deltaphi = gdml->GetAttrValue(attr);
3031  } else if (tempattr == "numsides") {
3032  numsides = gdml->GetAttrValue(attr);
3033  }
3034 
3035  attr = gdml->GetNextAttr(attr);
3036  }
3037 
3038  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3039  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3040  }
3041 
3042  Double_t retlunit = GetScaleVal(lunit);
3043  Double_t retaunit = GetScaleVal(aunit);
3044 
3045  //START TO LOOK THRU CHILD (ZPLANE) NODES...
3046 
3047  XMLNodePointer_t child = gdml->GetChild(node);
3048  int numplanes = 0;
3049 
3050  while (child != 0) {
3051  numplanes = numplanes + 1;
3052  child = gdml->GetNext(child);
3053  }
3054 
3055  int cols;
3056  int i;
3057  cols = 3;
3058  double ** table = new double*[numplanes];
3059  for (i = 0; i < numplanes; i++) {
3060  table[i] = new double[cols];
3061  }
3062 
3063  child = gdml->GetChild(node);
3064  int planeno = 0;
3065 
3066  while (child != 0) {
3067  if (strcmp(gdml->GetNodeName(child), "zplane") == 0) {
3068 
3069  Double_t rminline = 0;
3070  Double_t rmaxline = 0;
3071  Double_t zline = 0;
3072  attr = gdml->GetFirstAttr(child);
3073 
3074  while (attr != 0) {
3075  tempattr = gdml->GetAttrName(attr);
3076  tempattr.ToLower();
3077 
3078  if (tempattr == "rmin") {
3079  rmin = gdml->GetAttrValue(attr);
3080  rminline = Value(rmin)*retlunit;
3081  table[planeno][0] = rminline;
3082  } else if (tempattr == "rmax") {
3083  rmax = gdml->GetAttrValue(attr);
3084  rmaxline = Value(rmax)*retlunit;
3085  table[planeno][1] = rmaxline;
3086  } else if (tempattr == "z") {
3087  z = gdml->GetAttrValue(attr);
3088  zline = Value(z)*retlunit;
3089  table[planeno][2] = zline;
3090  }
3091 
3092  attr = gdml->GetNextAttr(attr);
3093  }
3094  }
3095  planeno = planeno + 1;
3096  child = gdml->GetNext(child);
3097  }
3098 
3099  Double_t startphiline = Value(startphi)*retaunit;
3100  Double_t deltaphiline = Value(deltaphi)*retaunit;
3101  Int_t numsidesline = (int)Value(numsides);
3102 
3103  TGeoPgon* polyg = new TGeoPgon(NameShort(name),
3104  startphiline,
3105  deltaphiline,
3106  numsidesline,
3107  numplanes);
3108  Int_t zno = 0;
3109 
3110  for (int j = 0; j < numplanes; j++) {
3111  polyg->DefineSection(zno, table[j][2], table[j][0], table[j][1]);
3112  zno = zno + 1;
3113  }
3114 
3115  fsolmap[name.Data()] = polyg;
3116  for (i = 0; i < numplanes; i++) {
3117  delete [] table[i];
3118  }
3119  delete [] table;
3120 
3121  return node;
3122 
3123 }
3124 
3125 ////////////////////////////////////////////////////////////////////////////////
3126 /// In the solids section of the GDML file, a Sphere may be declared.
3127 /// when the sphere keyword is found, this function is called, and the
3128 /// dimensions required are taken and stored, these are then bound and
3129 /// converted to type TGeoSphere and stored in fsolmap map using the name
3130 /// as its key.
3131 
3133 {
3134  TString lunit = "mm";
3135  TString aunit = "rad";
3136  TString rmin = "0";
3137  TString rmax = "0";
3138  TString startphi = "0";
3139  TString deltaphi = "0";
3140  TString starttheta = "0";
3141  TString deltatheta = "0";
3142  TString name = "";
3143  TString tempattr;
3144 
3145  while (attr != 0) {
3146  tempattr = gdml->GetAttrName(attr);
3147  tempattr.ToLower();
3148 
3149  if (tempattr == "name") {
3150  name = gdml->GetAttrValue(attr);
3151  } else if (tempattr == "rmin") {
3152  rmin = gdml->GetAttrValue(attr);
3153  } else if (tempattr == "rmax") {
3154  rmax = gdml->GetAttrValue(attr);
3155  } else if (tempattr == "lunit") {
3156  lunit = gdml->GetAttrValue(attr);
3157  } else if (tempattr == "aunit") {
3158  aunit = gdml->GetAttrValue(attr);
3159  } else if (tempattr == "startphi") {
3160  startphi = gdml->GetAttrValue(attr);
3161  } else if (tempattr == "deltaphi") {
3162  deltaphi = gdml->GetAttrValue(attr);
3163  } else if (tempattr == "starttheta") {
3164  starttheta = gdml->GetAttrValue(attr);
3165  } else if (tempattr == "deltatheta") {
3166  deltatheta = gdml->GetAttrValue(attr);
3167  }
3168 
3169  attr = gdml->GetNextAttr(attr);
3170  }
3171 
3172  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3173  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3174  }
3175 
3176  Double_t retlunit = GetScaleVal(lunit);
3177  Double_t retaunit = GetScaleVal(aunit);
3178 
3179  Double_t rminline = Value(rmin)*retlunit;
3180  Double_t rmaxline = Value(rmax)*retlunit;
3181  Double_t startphiline = Value(startphi)*retaunit;
3182  Double_t deltaphiline = startphiline+ Value(deltaphi)*retaunit;
3183  Double_t startthetaline = Value(starttheta)*retaunit;
3184  Double_t deltathetaline = startthetaline + Value(deltatheta)*retaunit;
3185 
3186  TGeoSphere* sphere = new TGeoSphere(NameShort(name),
3187  rminline,
3188  rmaxline,
3189  startthetaline,
3190  deltathetaline,
3191  startphiline,
3192  deltaphiline);
3193 
3194  fsolmap[name.Data()] = sphere;
3195 
3196  return node;
3197 
3198 }
3199 
3200 ////////////////////////////////////////////////////////////////////////////////
3201 /// In the solids section of the GDML file, a Torus may be declared.
3202 /// when the torus keyword is found, this function is called, and the
3203 /// dimensions required are taken and stored, these are then bound and
3204 /// converted to type TGeoTorus and stored in fsolmap map using the name
3205 /// as its key.
3206 
3208 {
3209  TString lunit = "mm";
3210  TString aunit = "rad";
3211  TString rmin = "0";
3212  TString rmax = "0";
3213  TString rtor = "0";
3214  TString startphi = "0";
3215  TString deltaphi = "0";
3216  TString name = "";
3217  TString tempattr;
3218 
3219  while (attr != 0) {
3220 
3221  tempattr = gdml->GetAttrName(attr);
3222  tempattr.ToLower();
3223 
3224  if (tempattr == "name") {
3225  name = gdml->GetAttrValue(attr);
3226  } else if (tempattr == "rmin") {
3227  rmin = gdml->GetAttrValue(attr);
3228  } else if (tempattr == "rmax") {
3229  rmax = gdml->GetAttrValue(attr);
3230  } else if (tempattr == "rtor") {
3231  rtor = gdml->GetAttrValue(attr);
3232  } else if (tempattr == "lunit") {
3233  lunit = gdml->GetAttrValue(attr);
3234  } else if (tempattr == "aunit") {
3235  aunit = gdml->GetAttrValue(attr);
3236  } else if (tempattr == "startphi") {
3237  startphi = gdml->GetAttrValue(attr);
3238  } else if (tempattr == "deltaphi") {
3239  deltaphi = gdml->GetAttrValue(attr);
3240  }
3241 
3242  attr = gdml->GetNextAttr(attr);
3243  }
3244 
3245  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3246  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3247  }
3248 
3249  Double_t retlunit = GetScaleVal(lunit);
3250  Double_t retaunit = GetScaleVal(aunit);
3251 
3252  Double_t rminline = Value(rmin)*retlunit;
3253  Double_t rmaxline = Value(rmax)*retlunit;
3254  Double_t rtorline = Value(rtor)*retlunit;
3255  Double_t startphiline = Value(startphi)*retaunit;
3256  Double_t deltaphiline = Value(deltaphi)*retaunit;
3257 
3258 
3259  TGeoTorus* torus = new TGeoTorus(NameShort(name), rtorline,
3260  rminline,
3261  rmaxline,
3262  startphiline,
3263  deltaphiline);
3264 
3265  fsolmap[name.Data()] = torus;
3266 
3267  return node;
3268 
3269 }
3270 
3271 ////////////////////////////////////////////////////////////////////////////////
3272 /// In the solids section of the GDML file, a Hype may be declared.
3273 /// when the hype keyword is found, this function is called, and the
3274 /// dimensions required are taken and stored, these are then bound and
3275 /// converted to type TGeoHype and stored in fsolmap map using the name
3276 /// as its key.
3277 
3279 {
3280  TString lunit = "mm";
3281  TString aunit = "rad";
3282  TString rmin = "0";
3283  TString rmax = "0";
3284  TString z = "0";
3285  TString inst = "0";
3286  TString outst = "0";
3287  TString name = "";
3288  TString tempattr;
3289 
3290  while (attr != 0) {
3291  tempattr = gdml->GetAttrName(attr);
3292  tempattr.ToLower();
3293 
3294  if (tempattr == "name") {
3295  name = gdml->GetAttrValue(attr);
3296  } else if (tempattr == "rmin") {
3297  rmin = gdml->GetAttrValue(attr);
3298  } else if (tempattr == "rmax") {
3299  rmax = gdml->GetAttrValue(attr);
3300  } else if (tempattr == "z") {
3301  z = gdml->GetAttrValue(attr);
3302  } else if (tempattr == "lunit") {
3303  lunit = gdml->GetAttrValue(attr);
3304  } else if (tempattr == "aunit") {
3305  aunit = gdml->GetAttrValue(attr);
3306  } else if (tempattr == "inst") {
3307  inst = gdml->GetAttrValue(attr);
3308  } else if (tempattr == "outst") {
3309  outst = gdml->GetAttrValue(attr);
3310  }
3311 
3312  attr = gdml->GetNextAttr(attr);
3313  }
3314 
3315  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3316  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3317  }
3318 
3319  Double_t retlunit = GetScaleVal(lunit);
3320  Double_t retaunit = GetScaleVal(aunit);
3321 
3322  Double_t rminline = Value(rmin)*retlunit;
3323  Double_t rmaxline = Value(rmax)*retlunit;
3324  Double_t zline = Value(z)*retlunit;
3325  Double_t instline = Value(inst)*retaunit;
3326  Double_t outstline = Value(outst)*retaunit;
3327 
3328 
3329  TGeoHype* hype = new TGeoHype(NameShort(name),
3330  rminline,
3331  instline,
3332  rmaxline,
3333  outstline,
3334  zline / 2);
3335 
3336  fsolmap[name.Data()] = hype;
3337 
3338  return node;
3339 
3340 }
3341 
3342 ////////////////////////////////////////////////////////////////////////////////
3343 /// In the solids section of the GDML file, a Para may be declared.
3344 /// when the para keyword is found, this function is called, and the
3345 /// dimensions required are taken and stored, these are then bound and
3346 /// converted to type TGeoPara and stored in fsolmap map using the name
3347 /// as its key.
3348 
3350 {
3351  TString lunit = "mm";
3352  TString aunit = "rad";
3353  TString x = "0";
3354  TString y = "0";
3355  TString z = "0";
3356  TString phi = "0";
3357  TString theta = "0";
3358  TString alpha = "0";
3359  TString name = "";
3360  TString tempattr;
3361 
3362  while (attr != 0) {
3363 
3364  tempattr = gdml->GetAttrName(attr);
3365  tempattr.ToLower();
3366 
3367  if (tempattr == "name") {
3368  name = gdml->GetAttrValue(attr);
3369  } else if (tempattr == "x") {
3370  x = gdml->GetAttrValue(attr);
3371  } else if (tempattr == "y") {
3372  y = gdml->GetAttrValue(attr);
3373  } else if (tempattr == "z") {
3374  z = gdml->GetAttrValue(attr);
3375  } else if (tempattr == "lunit") {
3376  lunit = gdml->GetAttrValue(attr);
3377  } else if (tempattr == "aunit") {
3378  aunit = gdml->GetAttrValue(attr);
3379  } else if (tempattr == "phi") {
3380  phi = gdml->GetAttrValue(attr);
3381  } else if (tempattr == "theta") {
3382  theta = gdml->GetAttrValue(attr);
3383  } else if (tempattr == "alpha") {
3384  alpha = gdml->GetAttrValue(attr);
3385  }
3386 
3387  attr = gdml->GetNextAttr(attr);
3388  }
3389 
3390  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3391  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3392  }
3393 
3394  Double_t retlunit = GetScaleVal(lunit);
3395  Double_t retaunit = GetScaleVal(aunit);
3396 
3397  Double_t xline = Value(x)*retlunit;
3398  Double_t yline = Value(y)*retlunit;
3399  Double_t zline = Value(z)*retlunit;
3400  Double_t philine = Value(phi)*retaunit;
3401  Double_t alphaline = Value(alpha)*retaunit;
3402  Double_t thetaline = Value(theta)*retaunit;
3403 
3404 
3405  TGeoPara* para = new TGeoPara(NameShort(name),
3406  xline / 2,
3407  yline / 2,
3408  zline / 2,
3409  alphaline,
3410  thetaline,
3411  philine);
3412 
3413  fsolmap[name.Data()] = para;
3414 
3415  return node;
3416 
3417 }
3418 
3419 ////////////////////////////////////////////////////////////////////////////////
3420 /// In the solids section of the GDML file, a TwistTrap may be declared.
3421 /// when the twistedtrap keyword is found, this function is called, and the
3422 /// dimensions required are taken and stored, these are then bound and
3423 /// converted to type TGeoGTra and stored in fsolmap map using the name
3424 /// as its key.
3425 
3427 {
3428  TString lunit = "mm";
3429  TString aunit = "rad";
3430  TString x1 = "0";
3431  TString x2 = "0";
3432  TString x3 = "0";
3433  TString x4 = "0";
3434  TString y1 = "0";
3435  TString y2 = "0";
3436  TString z = "0";
3437  TString phi = "0";
3438  TString theta = "0";
3439  TString alpha1 = "0";
3440  TString alpha2 = "0";
3441  TString twist = "0";
3442  TString name = "";
3443  TString tempattr;
3444 
3445  while (attr != 0) {
3446 
3447  tempattr = gdml->GetAttrName(attr);
3448  tempattr.ToLower();
3449 
3450  if (tempattr == "name") {
3451  name = gdml->GetAttrValue(attr);
3452  } else if (tempattr == "x1") {
3453  x1 = gdml->GetAttrValue(attr);
3454  } else if (tempattr == "x2") {
3455  x2 = gdml->GetAttrValue(attr);
3456  } else if (tempattr == "x3") {
3457  x3 = gdml->GetAttrValue(attr);
3458  } else if (tempattr == "x4") {
3459  x4 = gdml->GetAttrValue(attr);
3460  } else if (tempattr == "y1") {
3461  y1 = gdml->GetAttrValue(attr);
3462  } else if (tempattr == "y2") {
3463  y2 = gdml->GetAttrValue(attr);
3464  } else if (tempattr == "z") {
3465  z = gdml->GetAttrValue(attr);
3466  } else if (tempattr == "lunit") {
3467  lunit = gdml->GetAttrValue(attr);
3468  } else if (tempattr == "aunit") {
3469  aunit = gdml->GetAttrValue(attr);
3470  } else if (tempattr == "phi") {
3471  phi = gdml->GetAttrValue(attr);
3472  } else if (tempattr == "theta") {
3473  theta = gdml->GetAttrValue(attr);
3474  } else if (tempattr == "alph") { //gdml schema knows only alph attribute
3475  alpha1 = gdml->GetAttrValue(attr);
3476  alpha2 = alpha1;
3477  //} else if (tempattr == "alpha2") {
3478  // alpha2 = gdml->GetAttrValue(attr);
3479  } else if (tempattr == "phitwist") {
3480  twist = gdml->GetAttrValue(attr);
3481  }
3482 
3483  attr = gdml->GetNextAttr(attr);
3484  }
3485 
3486  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3487  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3488  }
3489 
3490  Double_t retlunit = GetScaleVal(lunit);
3491  Double_t retaunit = GetScaleVal(aunit);
3492 
3493  Double_t x1line = Value(x1)*retlunit;
3494  Double_t x2line = Value(x2)*retlunit;
3495  Double_t x3line = Value(x3)*retlunit;
3496  Double_t x4line = Value(x4)*retlunit;
3497  Double_t y1line = Value(y1)*retlunit;
3498  Double_t y2line = Value(y2)*retlunit;
3499  Double_t zline = Value(z)*retlunit;
3500  Double_t philine = Value(phi)*retaunit;
3501  Double_t thetaline = Value(theta)*retaunit;
3502  Double_t alpha1line = Value(alpha1)*retaunit;
3503  Double_t alpha2line = Value(alpha2)*retaunit;
3504  Double_t twistline = Value(twist)*retaunit;
3505 
3506 
3507  TGeoGtra* twtrap = new TGeoGtra(NameShort(name), zline / 2,
3508  thetaline,
3509  philine,
3510  twistline,
3511  y1line / 2,
3512  x1line / 2,
3513  x2line / 2,
3514  alpha1line,
3515  y2line / 2,
3516  x3line / 2,
3517  x4line / 2,
3518  alpha2line);
3519 
3520  fsolmap[name.Data()] = twtrap;
3521 
3522  return node;
3523 
3524 }
3525 
3526 
3527 ////////////////////////////////////////////////////////////////////////////////
3528 /// In the solids section of the GDML file, a ElTube may be declared.
3529 /// when the eltube keyword is found, this function is called, and the
3530 /// dimensions required are taken and stored, these are then bound and
3531 /// converted to type TGeoEltu and stored in fsolmap map using the name
3532 /// as its key.
3533 
3535 {
3536  TString lunit = "mm";
3537  TString xpos = "0";
3538  TString ypos = "0";
3539  TString zpos = "0";
3540  TString name = "";
3541  TString tempattr;
3542 
3543  while (attr != 0) {
3544 
3545  tempattr = gdml->GetAttrName(attr);
3546  tempattr.ToLower();
3547 
3548  if (tempattr == "name") {
3549  name = gdml->GetAttrValue(attr);
3550  } else if (tempattr == "dx") {
3551  xpos = gdml->GetAttrValue(attr);
3552  } else if (tempattr == "dy") {
3553  ypos = gdml->GetAttrValue(attr);
3554  } else if (tempattr == "dz") {
3555  zpos = gdml->GetAttrValue(attr);
3556  } else if (tempattr == "lunit") {
3557  lunit = gdml->GetAttrValue(attr);
3558  }
3559 
3560  attr = gdml->GetNextAttr(attr);
3561  }
3562 
3563  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3564  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3565  }
3566 
3567  Double_t retunit = GetScaleVal(lunit);
3568 
3569  Double_t xline = Value(xpos)*retunit;
3570  Double_t yline = Value(ypos)*retunit;
3571  Double_t zline = Value(zpos)*retunit;
3572 
3573  TGeoEltu* eltu = new TGeoEltu(NameShort(name), xline,
3574  yline,
3575  zline);
3576 
3577  fsolmap[name.Data()] = eltu;
3578 
3579  return node;
3580 
3581 }
3582 ////////////////////////////////////////////////////////////////////////////////
3583 /// In the solids section of the GDML file, an Orb may be declared.
3584 /// when the orb keyword is found, this function is called, and the
3585 /// dimensions required are taken and stored, these are then bound and
3586 /// converted to type TGeoSphere and stored in fsolmap map using the name
3587 /// as its key.
3588 
3590 {
3591  TString lunit = "mm";
3592  TString r = "0";
3593  TString name = "";
3594  TString tempattr;
3595 
3596  while (attr != 0) {
3597 
3598  tempattr = gdml->GetAttrName(attr);
3599  tempattr.ToLower();
3600 
3601  if (tempattr == "name") {
3602  name = gdml->GetAttrValue(attr);
3603  } else if (tempattr == "r") {
3604  r = gdml->GetAttrValue(attr);
3605  } else if (tempattr == "lunit") {
3606  lunit = gdml->GetAttrValue(attr);
3607  }
3608 
3609  attr = gdml->GetNextAttr(attr);
3610  }
3611 
3612  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3613  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3614  }
3615 
3616  Double_t retunit = GetScaleVal(lunit);
3617 
3618  Double_t rline = Value(r)*retunit;
3619 
3620  TGeoSphere* orb = new TGeoSphere(NameShort(name), 0, rline, 0, 180, 0, 360);
3621 
3622  fsolmap[name.Data()] = orb;
3623 
3624  return node;
3625 
3626 }
3627 
3628 
3629 ////////////////////////////////////////////////////////////////////////////////
3630 /// In the solids section of the GDML file, an Xtru may be declared.
3631 /// when the xtru keyword is found, this function is called, and the
3632 /// dimensions required are taken and stored, these are then bound and
3633 /// converted to type TGeoXtru and stored in fsolmap map using the name
3634 /// as its key. The xtru has child nodes of either 'twoDimVertex'or
3635 /// 'section'. These two nodes define the real structure of the shape.
3636 /// The twoDimVertex's define the x,y sizes of a vertice. The section links
3637 /// the vertice to a position within the xtru.
3638 
3640 {
3641  TString lunit = "mm";
3642 // TString aunit = "rad";
3643  TString x = "0";
3644  TString y = "0";
3645  TString zorder = "0";
3646  TString zpos = "0";
3647  TString xoff = "0";
3648  TString yoff = "0";
3649  TString scale = "0";
3650  TString name = "";
3651  TString tempattr;
3652 
3653  while (attr != 0) {
3654 
3655  tempattr = gdml->GetAttrName(attr);
3656  tempattr.ToLower();
3657 
3658  if (tempattr == "name") {
3659  name = gdml->GetAttrValue(attr);
3660  } else if (tempattr == "lunit") {
3661  lunit = gdml->GetAttrValue(attr);
3662  }
3663 
3664  attr = gdml->GetNextAttr(attr);
3665  }
3666 
3667  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3668  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3669  }
3670 
3671  Double_t retlunit = GetScaleVal(lunit);
3672 
3673  //START TO LOOK THRU CHILD NODES...
3674 
3675  XMLNodePointer_t child = gdml->GetChild(node);
3676  int nosects = 0;
3677  int noverts = 0;
3678 
3679  while (child != 0) {
3680  tempattr = gdml->GetNodeName(child);
3681 
3682  if (tempattr == "twoDimVertex") {
3683  noverts = noverts + 1;
3684  } else if (tempattr == "section") {
3685  nosects = nosects + 1;
3686  }
3687 
3688  child = gdml->GetNext(child);
3689  }
3690 
3691  //Build the dynamic arrays..
3692  int cols;
3693  int i;
3694  double *vertx = new double[noverts];
3695  double *verty = new double[noverts];
3696  cols = 5;
3697  double ** section = new double*[nosects];
3698  for (i = 0; i < nosects; i++) {
3699  section[i] = new double[cols];
3700  }
3701 
3702  child = gdml->GetChild(node);
3703  int sect = 0;
3704  int vert = 0;
3705 
3706  while (child != 0) {
3707  if (strcmp(gdml->GetNodeName(child), "twoDimVertex") == 0) {
3708  Double_t xline = 0;
3709  Double_t yline = 0;
3710 
3711  attr = gdml->GetFirstAttr(child);
3712 
3713  while (attr != 0) {
3714  tempattr = gdml->GetAttrName(attr);
3715 
3716  if (tempattr == "x") {
3717  x = gdml->GetAttrValue(attr);
3718  xline = Value(x)*retlunit;
3719  vertx[vert] = xline;
3720  } else if (tempattr == "y") {
3721  y = gdml->GetAttrValue(attr);
3722  yline = Value(y)*retlunit;
3723  verty[vert] = yline;
3724  }
3725 
3726  attr = gdml->GetNextAttr(attr);
3727  }
3728 
3729  vert = vert + 1;
3730  }
3731 
3732  else if (strcmp(gdml->GetNodeName(child), "section") == 0) {
3733 
3734  Double_t zposline = 0;
3735  Double_t xoffline = 0;
3736  Double_t yoffline = 0;
3737 
3738  attr = gdml->GetFirstAttr(child);
3739 
3740  while (attr != 0) {
3741  tempattr = gdml->GetAttrName(attr);
3742 
3743  if (tempattr == "zOrder") {
3744  zorder = gdml->GetAttrValue(attr);
3745  section[sect][0] = Value(zorder);
3746  } else if (tempattr == "zPosition") {
3747  zpos = gdml->GetAttrValue(attr);
3748  zposline = Value(zpos)*retlunit;
3749  section[sect][1] = zposline;
3750  } else if (tempattr == "xOffset") {
3751  xoff = gdml->GetAttrValue(attr);
3752  xoffline = Value(xoff)*retlunit;
3753  section[sect][2] = xoffline;
3754  } else if (tempattr == "yOffset") {
3755  yoff = gdml->GetAttrValue(attr);
3756  yoffline = Value(yoff)*retlunit;
3757  section[sect][3] = yoffline;
3758  } else if (tempattr == "scalingFactor") {
3759  scale = gdml->GetAttrValue(attr);
3760  section[sect][4] = Value(scale);
3761  }
3762 
3763  attr = gdml->GetNextAttr(attr);
3764  }
3765 
3766  sect = sect + 1;
3767  }
3768  child = gdml->GetNext(child);
3769  }
3770 
3771  TGeoXtru* xtru = new TGeoXtru(nosects);
3772  xtru->SetName(NameShort(name));
3773  xtru->DefinePolygon(vert, vertx, verty);
3774 
3775  for (int j = 0; j < sect; j++) {
3776  xtru->DefineSection((int)section[j][0], section[j][1], section[j][2], section[j][3], section[j][4]);
3777  }
3778 
3779  fsolmap[name.Data()] = xtru;
3780  delete [] vertx;
3781  delete [] verty;
3782  for (i = 0; i < nosects; i++) {
3783  delete [] section[i];
3784  }
3785  delete [] section;
3786  return node;
3787 }
3788 
3789 ////////////////////////////////////////////////////////////////////////////////
3790 /// In the solids section of the GDML file, a Reflected Solid may be
3791 /// declared when the ReflectedSolid keyword is found, this function
3792 /// is called. The rotation, position and scale for the reflection are
3793 /// applied to a matrix that is then stored in the class object
3794 /// TGDMLRefl. This is then stored in the map freflsolidmap, with
3795 /// the reflection name as a reference. also the name of the solid to
3796 /// be reflected is stored in a map called freflectmap with the reflection
3797 /// name as a reference.
3798 
3800 {
3801  std::cout << "WARNING! The reflectedSolid is obsolete! Use scale transformation instead!" << std::endl;
3802 
3803  TString sx = "0";
3804  TString sy = "0";
3805  TString sz = "0";
3806  TString rx = "0";
3807  TString ry = "0";
3808  TString rz = "0";
3809  TString dx = "0";
3810  TString dy = "0";
3811  TString dz = "0";
3812  TString name = "0";
3813  TString solid = "0";
3814  TString tempattr;
3815 
3816  while (attr != 0) {
3817 
3818  tempattr = gdml->GetAttrName(attr);
3819  tempattr.ToLower();
3820 
3821  if (tempattr == "name") {
3822  name = gdml->GetAttrValue(attr);
3823  } else if (tempattr == "sx") {
3824  sx = gdml->GetAttrValue(attr);
3825  } else if (tempattr == "sy") {
3826  sy = gdml->GetAttrValue(attr);
3827  } else if (tempattr == "sz") {
3828  sz = gdml->GetAttrValue(attr);
3829  } else if (tempattr == "rx") {
3830  rx = gdml->GetAttrValue(attr);
3831  } else if (tempattr == "ry") {
3832  ry = gdml->GetAttrValue(attr);
3833  } else if (tempattr == "rz") {
3834  rz = gdml->GetAttrValue(attr);
3835  } else if (tempattr == "dx") {
3836  dx = gdml->GetAttrValue(attr);
3837  } else if (tempattr == "dy") {
3838  dy = gdml->GetAttrValue(attr);
3839  } else if (tempattr == "dz") {
3840  dz = gdml->GetAttrValue(attr);
3841  } else if (tempattr == "solid") {
3842  solid = gdml->GetAttrValue(attr);
3843  }
3844  attr = gdml->GetNextAttr(attr);
3845  }
3846 
3847  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3848  name = TString::Format("%s_%s", name.Data(), fCurrentFile);
3849  }
3850  if ((strcmp(fCurrentFile, fStartFile)) != 0) {
3851  solid = TString::Format("%s_%s", solid.Data(), fCurrentFile);
3852  }
3853 
3854  TGeoRotation* rot = new TGeoRotation();
3855  rot->RotateZ(-(Value(rz)));
3856  rot->RotateY(-(Value(ry)));
3857  rot->RotateX(-(Value(rx)));
3858 
3859  if (atoi(sx) == -1) {
3860  rot->ReflectX(kTRUE);
3861  }
3862  if (atoi(sy) == -1) {
3863  rot->ReflectY(kTRUE);
3864  }
3865  if (atoi(sz) == -1) {
3866  rot->ReflectZ(kTRUE);
3867  }
3868 
3869  TGeoCombiTrans* relf_matx = new TGeoCombiTrans(Value(dx), Value(dy), Value(dz), rot);
3870 
3871  TGDMLRefl* reflsol = new TGDMLRefl(NameShort(name), solid, relf_matx);
3872  freflsolidmap[name.Data()] = reflsol;
3873  freflectmap[name.Data()] = solid;
3874 
3875  return node;
3876 }
3877 
3878 /** \class TGDMLRefl
3879 \ingroup Geometry_gdml
3880 
3881 This class is a helper class for TGDMLParse. It assists in the
3882 reflection process. This process takes a previously defined solid
3883 and can reflect the matrix of it. This class stores the name of the
3884 reflected solid, along with the name of the solid that is being
3885 reflected, and finally the reflected solid's matrix. This is then
3886 recalled when the volume is used in the structure part of the gdml
3887 file.
3888 
3889 */
3890 
3892 
3893 ////////////////////////////////////////////////////////////////////////////////
3894 /// This constructor method stores the values brought in as params.
3895 
3896 TGDMLRefl::TGDMLRefl(const char* name, const char* solid, TGeoMatrix* matrix)
3897 {
3898  fNameS = name;
3899  fSolid = solid;
3900  fMatrix = matrix;
3901 }
3902 
3903 ////////////////////////////////////////////////////////////////////////////////
3904 /// This accessor method returns the matrix.
3905 
3907 {
3908  return fMatrix;
3909 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
XMLNodePointer_t UsrProcess(TXMLEngine *gdml, XMLNodePointer_t node)
User data to be processed.
XMLNodePointer_t ConProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the define section of the GDML file, constants can be declared.
Definition: TGDMLParse.cxx:401
Mixtures of elements.
Definition: TGeoMaterial.h:134
Spherical shell class.
Definition: TGeoSphere.h:17
Cylindrical tube class.
Definition: TGeoTube.h:17
XMLNodePointer_t TwistTrap(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a TwistTrap may be declared.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
Double_t Eval(Double_t x) const
Sets first variable (e.g. x) and evaluate formula.
Definition: TFormula.cxx:3075
RotMap frotmap
Map containing position names and the TGeoTranslation for it.
Definition: TGDMLParse.h:202
Box class.
Definition: TGeoBBox.h:17
Volume assemblies.
Definition: TGeoVolume.h:307
XMLNodePointer_t Trd(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Trd may be declared.
MatMap fmatmap
Map containing element names and the TGeoElement for it.
Definition: TGDMLParse.h:206
TGeoVolume * fWorld
Definition: TGDMLParse.h:100
Collectable string class.
Definition: TObjString.h:28
void MultiplyLeft(const TGeoMatrix *left)
multiply to the left with an other transformation if right is identity matrix, just return ...
Gtra is a twisted trapezoid.
Definition: TGeoArb8.h:143
Geometrical transformation package.
Definition: TGeoMatrix.h:40
XMLNodePointer_t Paraboloid(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Paraboloid may be declared.
XMLNodePointer_t Xtru(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, an Xtru may be declared.
A polycone.
Definition: TGeoPcon.h:17
virtual const Double_t * GetRotationMatrix() const =0
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
A polygone.
Definition: TGeoPgon.h:19
XMLNodePointer_t Reflection(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Reflected Solid may be declared when the ReflectedSolid key...
EleMap felemap
Map containing isotope names and the TGeoIsotope for it.
Definition: TGDMLParse.h:205
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
virtual void RotateX(Double_t angle)
Rotate about X axis of the master frame with angle expressed in degrees.
XMLNodePointer_t Cone(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a cone may be declared.
void SetTranslation(const Double_t *vect)
Definition: TGeoMatrix.h:462
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
Torus segment class.
Definition: TGeoTorus.h:17
Class describing translations.
Definition: TGeoMatrix.h:121
virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.)
defines z position of a section plane, rmin and rmax at this z.
Definition: TGeoXtru.cxx:731
Int_t AddRegion(TGeoRegion *region)
Add a new region of volumes.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
Int_t GetId() const
Definition: TGeoMedium.h:48
TString GetScale(const char *unit)
Throughout the GDML file, a unit can de specified.
Definition: TGDMLParse.cxx:434
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped ...
Basic string class.
Definition: TString.h:125
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:420
Base class describing materials.
Definition: TGeoMaterial.h:29
void Multiply(const TGeoMatrix *right)
multiply to the right with an other transformation if right is identity matrix, just return ...
XMLNodePointer_t IsoProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLNodePointer_t parentn)
In the material section of the GDML file, an isotope may be declared.
Definition: TGDMLParse.cxx:748
XMLNodePointer_t Polycone(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Polycone may be declared.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetSkipComments(Bool_t on=kTRUE)
Definition: TXMLEngine.h:48
void ReplayCreation(const TGeoVolume *other)
Recreate the content of the other volume without pointer copying.
A shape scaled by a TGeoScale transformation.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
virtual const Double_t * GetScale() const
Definition: TGeoMatrix.h:279
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
return next attribute in the list
Definition: TXMLEngine.cxx:673
TGeoHMatrix Inverse() const
Return a temporary inverse of this.
Definition: TGeoMatrix.cxx:976
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
Paraboloid class.
double GetScaleVal(const char *unit)
Throughout the GDML file, a unit can de specified.
Definition: TGDMLParse.cxx:480
TList * GetListOfMaterials() const
Definition: TGeoManager.h:463
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
TObjArray * GetNodes()
Definition: TGeoVolume.h:170
ReflectionsMap freflectmap
Map containing volume names and the TGeoVolume for it.
Definition: TGDMLParse.h:211
Int_t GetNdaughters() const
Definition: TGeoVolume.h:350
const char * fCurrentFile
Definition: TGDMLParse.h:105
XMLNodePointer_t SclProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the define section of the GDML file, rotations can be declared.
Definition: TGDMLParse.cxx:704
This class contains the implementation of the GDML parser associated to all the supported GDML elemen...
Definition: TGDMLParse.h:96
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Definition: TObjArray.cxx:505
static const double x2[5]
XMLNodePointer_t BooSolid(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr, int num)
In the solid section of the GDML file, boolean solids can be declared.
Double_t x[n]
Definition: legend1.C:17
double Evaluate(const char *evalline)
Takes a string containing a mathematical expression and returns the value of the expression.
Definition: TGDMLParse.cxx:351
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2365
A phi segment of a conical tube.
Definition: TGeoCone.h:98
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void * XMLDocPointer_t
Definition: TXMLEngine.h:20
TGeoMatrix * GetMatrix()
This accessor method returns the matrix.
TCanvas * fractions()
Definition: fractions.C:1
TGeoVolume * GDMLReadFile(const char *filename="test.gdml")
Creates the new instance of the XMLEngine called &#39;gdml&#39;, using the filename >> then parses the file a...
Definition: TGDMLParse.cxx:124
void SetParameter(const char *name, Double_t value)
Sets parameter value.
Definition: TFormula.cxx:2729
void AddIsotope(TGeoIsotope *isotope, Double_t relativeAbundance)
Add an isotope for this element. All isotopes have to be isotopes of the same element.
Base class for chemical elements.
Definition: TGeoElement.h:36
static const double x4[22]
XMLNodePointer_t Arb8(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, an Arb8 may be declared.
TGeoMedium * GetMedium() const
Definition: TGeoVolume.h:176
double Value(const char *svalue) const
Convert number in string format to double value.
Definition: TGDMLParse.cxx:520
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
Set values for a given vertex.
Definition: TGeoArb8.cxx:1248
TRAP is a general trapezoid, i.e.
Definition: TGeoArb8.h:89
virtual void RotateY(Double_t angle)
Rotate about Y axis of the master frame with angle expressed in degrees.
FileMap ffilemap
Map containing reflected volume names and the solid ref for it.
Definition: TGDMLParse.h:214
constexpr Double_t Pi()
Definition: TMath.h:40
ConstMap fconsts
Map containing files parsed during entire parsing, with their world volume name.
Definition: TGDMLParse.h:215
virtual const Double_t * GetTranslation() const
Definition: TGeoMatrix.h:160
static constexpr double second
virtual TGeoVolume * Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Division a la G3.
auto * lv
Definition: textalign.C:5
This class is a helper class for TGDMLParse.
Definition: TGDMLParse.h:31
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
XMLNodePointer_t CutTube(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Cut Tube may be declared.
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:984
XMLNodePointer_t Sphere(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Sphere may be declared.
virtual const Double_t * GetRotationMatrix() const
Definition: TGeoMatrix.h:230
XMLNodePointer_t Orb(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, an Orb may be declared.
Class handling Boolean composition of shapes.
A trapezoid with both x and y lengths varying with z.
Definition: TGeoTrd2.h:17
XMLNodePointer_t PosProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the define section of the GDML file, positions can be declared.
Definition: TGDMLParse.cxx:593
Parallelepiped class.
Definition: TGeoPara.h:17
XMLNodePointer_t Torus(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Torus may be declared.
int isnan(double)
XMLNodePointer_t Box(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a box may be declared.
XMLNodePointer_t Ellipsoid(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, an ellipsoid may be declared.
Base abstract class for all shapes.
Definition: TGeoShape.h:25
void ShiftToNext(XMLNodePointer_t &xmlnode, Bool_t realnode=kTRUE)
shifts specified node to next if realnode==kTRUE, any special nodes in between will be skipped ...
ROOT::R::TRInterface & r
Definition: Object.C:4
std::map< std::string, double > FracMap
Definition: TGDMLParse.h:198
Class describing rotation + translation.
Definition: TGeoMatrix.h:291
XMLNodePointer_t Para(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Para may be declared.
XMLNodePointer_t Trap(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Trap may be declared.
auto * a
Definition: textangle.C:12
const char * fStartFile
Definition: TGDMLParse.h:104
The Formula class.
Definition: TFormula.h:83
Regions are groups of volumes having a common set of user tracking cuts.
Definition: TGeoRegion.h:36
Hyperboloid class defined by 5 parameters.
Definition: TGeoHype.h:17
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
return value of attribute
Definition: TXMLEngine.cxx:695
XMLNodePointer_t RotProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the define section of the GDML file, rotations can be declared.
Definition: TGDMLParse.cxx:646
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
return first attribute in the list, namespace (if exists) will be skipped
Definition: TXMLEngine.cxx:657
TXMLEngine * fFileEngine[20]
Definition: TGDMLParse.h:103
XMLNodePointer_t Hype(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Hype may be declared.
void * XMLNodePointer_t
Definition: TXMLEngine.h:17
IsoMap fisomap
Map containing scale names and the TGeoScale for it.
Definition: TGDMLParse.h:204
constexpr Double_t Na()
Definition: TMath.h:202
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a component to the assembly.
void SetUserExtension(TGeoExtension *ext)
Connect user-defined extension to the volume.
virtual void RotateZ(Double_t angle)
Rotate about Z axis of the master frame with angle expressed in degrees.
XMLNodePointer_t TopProcess(TXMLEngine *gdml, XMLNodePointer_t node)
In the setup section of the GDML file, the top volume need to be declared.
Class describing rotations.
Definition: TGeoMatrix.h:174
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char *name)
checks if node has attribute of specified name
Definition: TXMLEngine.cxx:531
A tube segment cut with 2 planes.
Definition: TGeoTube.h:168
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
An extrusion with fixed outline shape in x-y and a sequence of z extents (segments).
Definition: TGeoXtru.h:21
void * XMLAttrPointer_t
Definition: TXMLEngine.h:19
Class describing scale transformations.
Definition: TGeoMatrix.h:244
static const double x1[5]
XMLNodePointer_t Polyhedra(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Polyhedra may be declared.
#define ClassImp(name)
Definition: Rtypes.h:359
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:559
double Double_t
Definition: RtypesCore.h:55
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
Definition: TXMLEngine.cxx:547
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
Conical tube class.
Definition: TGeoCone.h:17
MixMap fmixmap
Map containing medium names and the TGeoMedium for it.
Definition: TGDMLParse.h:208
Double_t y[n]
Definition: legend1.C:17
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:570
void AddVolume(TGeoVolume *vol)
Definition: TGeoRegion.h:49
Reference counted extension which has a pointer to and owns a user defined TObject.
Definition: TGeoExtension.h:36
Int_t SetAxis(const char *axisString)
When using the &#39;divide&#39; process in the geometry this function sets the variable &#39;axis&#39; depending on w...
Definition: TGDMLParse.cxx:361
An arbitrary trapezoid with less than 8 vertices standing on two parallel planes perpendicular to Z a...
Definition: TGeoArb8.h:17
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:23
Bool_t IsNull() const
Definition: TString.h:383
const char * NameShort(const char *name)
This function looks thru a string for the chars &#39;0x&#39; next to each other, when it finds this...
Definition: TGDMLParse.cxx:386
void SetMatrix(const Double_t *rot)
Definition: TGeoMatrix.h:225
MedMap fmedmap
Map containing material names and the TGeoMaterial for it.
Definition: TGDMLParse.h:207
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
constexpr Double_t RadToDeg()
Definition: TMath.h:60
SclMap fsclmap
Map containing rotation names and the TGeoRotation for it.
Definition: TGDMLParse.h:203
SolMap fsolmap
Map containing mixture names and the TGeoMixture for it.
Definition: TGDMLParse.h:209
const char * ParseGDML(TXMLEngine *gdml, XMLNodePointer_t node)
This function recursively moves thru the DOM tree of the GDML file.
Definition: TGDMLParse.cxx:161
ReflVolMap freflvolmap
Map containing reflection names and the TGDMLRefl for it - containing refl matrix.
Definition: TGDMLParse.h:213
VolMap fvolmap
Map containing solid names and the TGeoShape for it.
Definition: TGDMLParse.h:210
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
Base class for Boolean operations between two shapes.
Definition: TGeoBoolNode.h:24
Elliptical tube class.
Definition: TGeoEltu.h:17
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
returns parent of xmlnode
void SetRotation(const Double_t *matrix)
Definition: TGeoMatrix.h:463
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
XMLNodePointer_t ElTube(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a ElTube may be declared.
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
Defines z position of a section plane, rmin and rmax at this z.
Definition: TGeoPcon.cxx:618
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const =0
ReflSolidMap freflsolidmap
Map containing reflection names and the Solid name ir references to.
Definition: TGDMLParse.h:212
Definition: first.py:1
XMLNodePointer_t MatProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr, int z)
In the materials section of the GDML file, materials can be declared.
Definition: TGDMLParse.cxx:999
XMLNodePointer_t EleProcess(TXMLEngine *gdml, XMLNodePointer_t node, XMLNodePointer_t parentn, Bool_t hasIsotopes, Bool_t hasIsotopesExtended)
When the element keyword is found, this function is called, and the name and values of the element ar...
Definition: TGDMLParse.cxx:811
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:908
TGeoShape * GetShape() const
Definition: TGeoVolume.h:191
XMLNodePointer_t Tube(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, a Tube may be declared.
void AddCut(const char *name, Double_t cut)
Add cut to the region.
Definition: TGeoRegion.cxx:75
XMLNodePointer_t AssProcess(TXMLEngine *gdml, XMLNodePointer_t node)
In the structure section of the GDML file, assembly volumes can be declared.
XMLNodePointer_t VolProcess(TXMLEngine *gdml, XMLNodePointer_t node)
In the structure section of the GDML file, volumes can be declared.
const char * GetAttrName(XMLAttrPointer_t xmlattr)
return name of the attribute
Definition: TXMLEngine.cxx:684
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
TString fWorldName
Definition: TGDMLParse.h:99
gr SetName("gr")
char name[80]
Definition: TGX11.cxx:109
XMLNodePointer_t ElCone(TXMLEngine *gdml, XMLNodePointer_t node, XMLAttrPointer_t attr)
In the solids section of the GDML file, an elliptical cone may be declared.
Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv)
Creates the polygon representing the blueprint of any Xtru section.
Definition: TGeoXtru.cxx:698
PosMap fposmap
Definition: TGDMLParse.h:201
static const double x3[11]
const char * Data() const
Definition: TString.h:345
A phi segment of a tube.
Definition: TGeoTube.h:88