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