Geant4_10
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 }
void SetForceWireframe(G4bool)
G4String GetName() const
G4VPhysicalVolume * PhysicalVolume(G4VPhysicalVolume *)
Definition: CCalG4Able.cc:65
void setVisType(CCalVisualisable::visType, G4LogicalVolume *)
Definition: CCalG4Able.cc:104
void SetVisibility(G4bool)
G4String G4Name() const
Definition: CCalG4Able.hh:78
const XML_Char * name
Definition: expat.h:151
CCalG4Able(G4String name)
Definition: CCalG4Able.cc:49
G4bool sensitivity
Definition: CCalG4Able.hh:104
CCalG4AbleTable theG4DetectorsInside
Definition: CCalG4Able.hh:100
G4bool isSensitive() const
Definition: CCalG4Able.hh:75
static CCalSensitiveConfiguration * getInstance()
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
Int_t col[ntarg]
Definition: Style.C:29
bool G4bool
Definition: G4Types.hh:79
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
G4VisAttributes * g4VisAtt[CCalVisualisable::TotalVisTypes]
Definition: CCalG4Able.hh:108
double colorBlue(visType v) const
static CCalGeometryConfiguration * getInstance()
G4VPhysicalVolume * detPhysicalVolume
Definition: CCalG4Able.hh:99
double colorRed(visType v) const
int getSensitiveFlag(const G4String &n)
void Stop()
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
#define G4endl
Definition: G4ios.hh:61
bool isVisible(visType v) const
void Start()
G4bool operator==(const CCalG4Able &right) const
Definition: CCalG4Able.cc:133
virtual void constructSensitive()
Definition: CCalG4Able.hh:94
virtual G4VPhysicalVolume * constructIn(G4VPhysicalVolume *)=0
CCalVisualisable visProperties
Definition: CCalG4Able.hh:107
virtual ~CCalG4Able()
Definition: CCalG4Able.cc:60
void SetVisAttributes(const G4VisAttributes *pVA)
bool isWireFrame(visType v) const
double colorGreen(visType v) const
void AddCCalG4Able(CCalG4Able *)
Definition: CCalG4Able.cc:100