Geant4
10.03
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
CCalDetector.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: CCalDetector.cc
28
// Description: CCalDetector is a detector factory class
30
31
#include "
CCalDetector.hh
"
32
33
#include <fstream>
34
#include "
CCalGeometryConfiguration.hh
"
35
#include "
CCalutils.hh
"
36
37
//Comment/Uncomment to hide/show some debug information
38
//#define debug
39
//Comment/Uncomment to hide/show some more debug information
40
//#define ddebug
41
42
43
44
CCalDetector::CCalDetector
(
const
G4String
&
name
): detectorName(name)
45
{
46
if
(getenv(
"CCAL_GEOMPATH"
))
47
pathName
= getenv(
"CCAL_GEOMPATH"
);
48
else
49
G4Exception
(
"CCalDetector::CCalDetector"
,
"ccal001"
,
50
FatalException
,
51
"Environment variable CCAL_GEOMPATH not defined"
);
52
53
#ifdef ddebug
54
G4cout
<<
"CCAL_GEOMPATH="
<<
pathName
<<
G4endl
;
55
#endif
56
fileName
=
57
CCalGeometryConfiguration::getInstance
()->
getFileName
(name);
58
constructFlag
=
59
CCalGeometryConfiguration::getInstance
()->
getConstructFlag
(name);
60
}
61
62
CCalDetector::~CCalDetector
() {
63
CCalDetectorTable::iterator ite;
64
for
(ite=
theDetectorsInside
.begin(); ite !=
theDetectorsInside
.end(); ite++) {
65
delete
*ite;
66
}
67
theDetectorsInside
.clear();
68
}
69
70
void
CCalDetector::construct
() {
71
#ifdef debug
72
G4cout
<<
"===> Entering CCalDetector::construct() for "
<<
Name
() <<
G4endl
;
73
#endif
74
int
isgood = 0;
75
76
//If constructFlag is unset we don't go into all this bussines
77
if
(
constructFlag
!=0) {
78
79
if
(!isgood)
80
isgood =
buildFromFile
();
81
82
if
(isgood) {
83
constructDaughters
();
84
for
(
unsigned
int
i=0; i <
theDetectorsInside
.size(); i++) {
85
theDetectorsInside
[i]->constructHierarchy();
86
}
87
}
88
}
89
#ifdef debug
90
G4cout
<<
"===> Exiting CCalDetector::construct() for "
<<
Name
() <<
G4endl
;
91
#endif
92
}
93
94
95
void
CCalDetector::addDetector
(
CCalDetector
* det) {
96
theDetectorsInside
.push_back(det);
97
}
98
99
100
101
//========================================================================
102
//Protected and private methods.
103
int
CCalDetector::buildFromFile
() {
104
return
readFile
();
105
}
106
107
108
109
//========================================================================
110
//Global operators
111
std::ostream&
operator<<
(std::ostream& os,
const
CCalDetector
& det) {
112
os <<
"Detector \""
<< det.
detectorName
113
<<
"\" read from "
<< det.
fileName
<<
"."
<<
G4endl
;
114
115
os <<
"With "
<< det.
theDetectorsInside
.size()
116
<<
" detectors inside { "
<<
G4endl
;
117
118
for
(
unsigned
int
i=0; i<det.
theDetectorsInside
.size(); i++)
119
os << det.
theDetectorsInside
[i] <<
G4endl
;
120
121
os <<
"}"
<<
G4endl
;
122
123
return
os;
124
}
125
126
127
128
129
130
131
CCalDetector::constructDaughters
virtual void constructDaughters()=0
CCalDetector::addDetector
void addDetector(CCalDetector *)
Definition:
CCalDetector.cc:95
CCalDetector::CCalDetector
CCalDetector(const G4String &name)
Definition:
CCalDetector.cc:44
CCalDetector::Name
G4String Name() const
Definition:
CCalDetector.hh:77
CCalDetector::~CCalDetector
virtual ~CCalDetector()
Definition:
CCalDetector.cc:62
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:77
CCalDetector::construct
void construct()
Definition:
CCalDetector.cc:70
CCalGeometryConfiguration::getFileName
G4String getFileName(const G4String &n)
Definition:
CCalGeometryConfiguration.cc:63
CCalDetector.hh
G4cout
G4GLOB_DLL std::ostream G4cout
CCalDetector
Definition:
CCalDetector.hh:49
CCalDetector::buildFromFile
int buildFromFile()
Definition:
CCalDetector.cc:103
CCalDetector::pathName
G4String pathName
Definition:
CCalDetector.hh:118
CCalDetector::constructFlag
int constructFlag
Definition:
CCalDetector.hh:122
CCalDetector::fileName
G4String fileName
Definition:
CCalDetector.hh:117
G4Exception
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition:
G4Exception.cc:41
CCalGeometryConfiguration::getInstance
static CCalGeometryConfiguration * getInstance()
Definition:
CCalGeometryConfiguration.cc:41
FatalException
Definition:
G4ExceptionSeverity.hh:60
CCalDetector::detectorName
G4String detectorName
Definition:
CCalDetector.hh:116
CCalDetector::readFile
virtual int readFile()=0
CCalDetector::theDetectorsInside
CCalDetectorTable theDetectorsInside
Definition:
CCalDetector.hh:120
G4endl
#define G4endl
Definition:
G4ios.hh:61
CCalGeometryConfiguration::getConstructFlag
int getConstructFlag(const G4String &n)
Definition:
CCalGeometryConfiguration.cc:48
operator<<
std::ostream & operator<<(std::ostream &os, const CCalDetector &det)
Definition:
CCalDetector.cc:111
CCalutils.hh
CCalGeometryConfiguration.hh
G4String
Definition:
G4String.hh:45
geant4.10.03
examples
advanced
composite_calorimeter
src
CCalDetector.cc
Generated on Thu Feb 14 2002 02:27:31 for Geant4 by
1.8.8