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