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