Geant4  10.00.p03
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>
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 G4String CCalDetector::pathName = getenv("CCAL_GEOMPATH");
43 
44 CCalDetector::CCalDetector(const G4String &name): detectorName(name) {
45 #ifdef ddebug
46  G4cout << "CCAL_GEOMPATH=" << pathName << G4endl;
47 #endif
48  fileName =
50  constructFlag =
52 }
53 
55  CCalDetectorTable::iterator ite;
56  for (ite=theDetectorsInside.begin(); ite !=theDetectorsInside.end(); ite++) {
57  delete *ite;
58  }
59  theDetectorsInside.clear();
60 }
61 
63 #ifdef debug
64  G4cout << "===> Entering CCalDetector::construct() for " << Name() << G4endl;
65 #endif
66  int isgood = 0;
67 
68  //If constructFlag is unset we don't go into all this bussines
69  if (constructFlag!=0) {
70 
71  if (!isgood)
72  isgood = buildFromFile();
73 
74  if (isgood) {
76  for (unsigned int i=0; i < theDetectorsInside.size(); i++) {
77  theDetectorsInside[i]->constructHierarchy();
78  }
79  }
80  }
81 #ifdef debug
82  G4cout << "===> Exiting CCalDetector::construct() for " << Name() << G4endl;
83 #endif
84 }
85 
86 
88  theDetectorsInside.push_back(det);
89 }
90 
91 
92 
93 //========================================================================
94 //Protected and private methods.
96  return readFile();
97 }
98 
99 
100 
101 //========================================================================
102 //Global operators
103 std::ostream& operator<<(std::ostream& os, const CCalDetector& det) {
104  os << "Detector \"" << det.detectorName
105  << "\" read from " << det.fileName << "." << G4endl;
106 
107  os << "With " << det.theDetectorsInside.size()
108  << " detectors inside { "<< G4endl;
109 
110  for (unsigned int i=0; i<det.theDetectorsInside.size(); i++)
111  os << det.theDetectorsInside[i] << G4endl;
112 
113  os << "}" << G4endl;
114 
115  return os;
116 }
117 
118 
119 
120 
121 
122 
123 
virtual void constructDaughters()=0
void addDetector(CCalDetector *)
Definition: CCalDetector.cc:87
CCalDetector(const G4String &name)
Definition: CCalDetector.cc:44
G4String name
Definition: TRTMaterials.hh:40
G4String Name() const
Definition: CCalDetector.hh:77
virtual ~CCalDetector()
Definition: CCalDetector.cc:54
void construct()
Definition: CCalDetector.cc:62
G4String getFileName(const G4String &n)
G4GLOB_DLL std::ostream G4cout
int buildFromFile()
Definition: CCalDetector.cc:95
static G4String pathName
G4String fileName
static CCalGeometryConfiguration * getInstance()
G4String detectorName
virtual int readFile()=0
CCalDetectorTable theDetectorsInside
#define G4endl
Definition: G4ios.hh:61
int getConstructFlag(const G4String &n)
std::ostream & operator<<(std::ostream &os, const CCalDetector &det)