Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCalG4Able.cc
Go to the documentation of this file.
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 //
27 // File: CCalG4Able.cc
28 // Description: CCalG4Able is the base class of a Geant4 geometry factory
30 //Comment/Uncomment next line to unset/set debug information printing
31 //#define debug
32 //#define ddebug
33 
34 #ifdef ddebug
35  #include "G4Timer.hh"
36 #endif
37 #ifdef debug
38  #include "CCalutils.hh"
39 #endif
40 
42 #include "CCalG4Able.hh"
44 
45 #include "G4Color.hh"
46 #include "G4VisAttributes.hh"
47 
48 
50  detPhysicalVolume(0), g4ableName(name), sensitivity(false),
51  visProperties(CCalSensitiveConfiguration::getInstance()->getFileName(name)+".vis") {
52  //Initialize g4VisAtt pointers
53  for (int i=0; i<CCalVisualisable::TotalVisTypes; i++) {
54  g4VisAtt[i]=0;
55  }
56  sensitivity =
58 }
59 
61  if (detPhysicalVolume)
62  delete[] detPhysicalVolume;
63 }
64 
66  //If detPhysicalVolume is not (nil) the volume has already been built
67  //so return it. In other case, construct it and its daughters, then
68  //check for sensitivity and build it if set.
69 #ifdef ddebug
70  G4Timer timer;
71  timer.Start();
72 #endif
73  if (CCalGeometryConfiguration::getInstance()->getConstructFlag(G4Name())!=0){
74  if (!detPhysicalVolume) {
76  for (unsigned int i = 0; i < theG4DetectorsInside.size(); i++) {
77  theG4DetectorsInside[i]->PhysicalVolume(detPhysicalVolume);
78  }
79  if (sensitivity) {
80 #ifdef debug
81  G4cout << "==> Making " << detPhysicalVolume->GetName() << " sensitive..."
82  << G4endl;
83 #endif
85  } //if sensitivity
86  } //if sensitive
87  } //if construct
88  else {
89  G4cout << "NOTE: You decided to skip the construction of "
90  << G4Name() << G4endl;
91  }
92 #ifdef ddebug
93  timer.Stop();
94  G4cout << tab << "CCalG4Able::PhysicalVolume(...) --> time spent: "
95  << timer << G4endl;
96 #endif
97  return detPhysicalVolume;
98 }
99 
101  theG4DetectorsInside.push_back(det);
102 }
103 
105  if (!g4VisAtt[vt]) {
106 #ifdef debug
107  G4cout << "CCalG4Able::setVisType: Constructing G4VisAttributes for "
108  << log->GetName() << " as " << vt << G4endl;
109 #endif
114  G4bool visible = visProperties.isVisible(vt);
115 
116 #ifdef debug
117  G4cout << "Color: "
118  << visProperties.colorRed(vt) << ", "
119  << visProperties.colorGreen(vt) << ", "
120  << visProperties.colorBlue(vt) << tab
121  << "Wireframe: " << wf << tab
122  << "Visible: " << visible << G4endl;
123 #endif
124  g4VisAtt[vt] = new G4VisAttributes(col);
125  g4VisAtt[vt]->SetForceWireframe(wf);
126  g4VisAtt[vt]->SetVisibility(visible);
127  }
128  log->SetVisAttributes(g4VisAtt[vt]);
129 }
130 
131 
132 
134  return detPhysicalVolume==right.detPhysicalVolume;
135 }
136 
137 
138 
139 //========================================================================
140 //Protected and private methods.
141 
142 //========================================================================
143 //Global operators
144 std::ostream& operator<<(std::ostream& os, const CCalG4Able& det) {
145  if (det.detPhysicalVolume)
146  os << "Physical volume already constructed." << G4endl;
147  else
148  os << "Physical volume still not constructed." << G4endl;
149 
150  if (det.isSensitive())
151  os << "and it is Sensitive" << G4endl;
152  else
153  os << "and it is not Sensitive" << G4endl;
154 
155  return os;
156 }