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