ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgrVolumeAssembly.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgrVolumeAssembly.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // class G4tgrVolumeAssembly
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
35 #include "G4tgrVolumeAssembly.hh"
36 #include "G4tgrUtils.hh"
37 #include "G4tgrVolumeMgr.hh"
38 #include "G4tgrPlaceSimple.hh"
39 #include "G4tgrPlaceDivRep.hh"
41 #include "G4tgrFileReader.hh"
42 #include "G4tgrMessenger.hh"
43 
44 //-------------------------------------------------------------
46 {
47 }
48 
49 
50 //-------------------------------------------------------------
52 {
53 }
54 
55 
56 //-------------------------------------------------------------
57 G4tgrVolumeAssembly::G4tgrVolumeAssembly( const std::vector<G4String>& wl )
58 {
59  theType = "VOLAssembly";
60 
61  //---------- set name
62  theName = G4tgrUtils::GetString( wl[1] );
63 
64  G4int nVol = G4tgrUtils::GetInt( wl[2] );
65 
66  G4tgrUtils::CheckWLsize( wl, 3+nVol*5, WLSIZE_GE,
67  "G4tgrVolumeAssembly::G4tgrVolumeAssembly" );
68 
69 
70  for(G4int ii=0; ii<nVol*5; ii+=5)
71  {
72 #ifdef G4VERBOSE
74  {
75  G4cout << " G4tgrVolumeAssembly::G4tgrVolumeAssembly() -"
76  << " Adding component: " << ii << " - " << wl[ii+3] << G4endl;
77  }
78 #endif
79  theComponentNames.push_back(G4tgrUtils::GetString( wl[3+ii+0]));
80  theComponentRMs.push_back(G4tgrUtils::GetString( wl[3+ii+1]));
82  G4tgrUtils::GetDouble(wl[3+ii+3]),
83  G4tgrUtils::GetDouble(wl[3+ii+4])));
84  }
85  theVisibility = 1;
86  theRGBColour = new G4double[4];
87  for (size_t ii=0; ii<4; ii++) { theRGBColour[ii] = -1.; }
88 
89  theSolid = 0;
90 
91 #ifdef G4VERBOSE
93  {
94  G4cout << " Created " << *this << G4endl;
95  }
96 #endif
97 
98 }
99 
100 
101 //-------------------------------------------------------------------------
102 G4tgrPlace* G4tgrVolumeAssembly::AddPlace( const std::vector<G4String>& wl )
103 {
104  //---------- Check for exact number of words read
105  G4tgrUtils::CheckWLsize( wl, 7, WLSIZE_EQ, " G4tgrVolumeAssembly::AddPlace");
106 
107  //---------- set G4tgrPlace
108  G4tgrPlaceSimple* pl = new G4tgrPlaceSimple( wl );
109 
110  pl->SetVolume( this );
111  thePlacements.push_back( pl );
112 
113 #ifdef G4VERBOSE
115  {
116  G4cout << " New placement: " << thePlacements.size()
117  << " added for Volume " << theName
118  << " inside " << pl->GetParentName()
119  << " type " << pl->GetType() << G4endl;
120  }
121 #endif
122  //---------- register parent - child
124 
125  return pl;
126 }
127 
128 
129 // -------------------------------------------------------------------------
130 std::ostream& operator<<(std::ostream& os, const G4tgrVolumeAssembly& obj)
131 {
132  os << "G4tgrVolumeAssembly= " << obj.theName;
133 
134  for( size_t ii = 0; ii < obj.theComponentNames.size(); ii++ )
135  {
136  os << obj.theComponentNames[ii] << " RotMatName= "
137  << obj.theComponentRMs[ii] << " Position= "
138  << obj.theComponentPos[ii].x() << " "
139  << obj.theComponentPos[ii].y() << " "
140  << obj.theComponentPos[ii].z();
141  }
142  os << G4endl;
143 
144  return os;
145 }