Geant4  10.03
CCalHcal.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: CCalHcal.cc
28 // Description: CCalHcal Geometry factory class for the hadron calorimeter
30 #include "CCalHcal.hh"
31 
32 #include <fstream>
33 #include "CCalutils.hh"
34 
35 //#define debug
36 
38  CCalDetector(name),xposBox(0),typeLayerScnt(0),mothLayerScnt(0),
39  xposLayerScnt(0),typeLayerAbs(0),mothLayerAbs(0),xposLayerAbs(0),
40  dx_2Absorber(0),dy_2ScntLayer(0),dx_2ScntLayer(0),dx_2Wrapper(0),
41  dx_2FrontPlastic(0),dx_2BackPlastic(0),dx_2Scintillator(0) {}
42 
44  if (xposBox)
45  delete[] xposBox;
46  if (typeLayerScnt)
47  delete[] typeLayerScnt;
48  if (mothLayerScnt)
49  delete[] mothLayerScnt;
50  if (xposLayerScnt)
51  delete[] xposLayerScnt;
52  if (typeLayerAbs)
53  delete[] typeLayerAbs;
54  if (mothLayerAbs)
55  delete[] mothLayerAbs;
56  if (xposLayerAbs)
57  delete[] xposLayerAbs;
58  if (dx_2Absorber)
59  delete[] dx_2Absorber;
60  if (dy_2ScntLayer)
61  delete[] dy_2ScntLayer;
62  if (dx_2ScntLayer)
63  delete[] dx_2ScntLayer;
64  if (dx_2Wrapper)
65  delete[] dx_2Wrapper;
66  if (dx_2FrontPlastic)
67  delete[] dx_2FrontPlastic;
68  if (dx_2BackPlastic)
69  delete[] dx_2BackPlastic;
70  if (dx_2Scintillator)
71  delete[] dx_2Scintillator;
72 }
73 
76  //Let's open the file
77  G4cout << " ==> Opening file " << File() << " to read elements..."
78  << G4endl;
79 
80  std::ifstream is;
81  bool ok = openGeomFile(is, pathName, File());
82  if (!ok)
83  return 0;
84 
85  // Find *DO HCal
86  findDO(is, G4String("HCal"));
87 
88  // Calorimeter boundaries
90  is >> dy_2Cal >> dx_2Cal >> xposCal >> jump;
91 #ifdef debug
92  G4cout << tab << "General material: " << genMaterial << " Size " << dy_2Cal
93  << ", " << dx_2Cal << " Position " << xposCal << G4endl;
94 #endif
95 
96  // Boxes
98  is >> nBox >> dy_2Box >> dx_2Box >> wallThickBox;
99  int i = 0;
100  xposBox = new double[nBox];
101  for (i=0; i<nBox; i++)
102  is >> xposBox[i];
103 #ifdef debug
104  G4cout << tab << "Box material: " << boxMaterial << " Size " << dy_2Box
105  << ", " << dx_2Box << " Wall Thickness " << wallThickBox << " number "
106  << nBox << " position ";
107  for (i=0; i<nBox; i++)
108  G4cout << i << " " << xposBox[i] << " ";
109  G4cout << G4endl;
110 #endif
111 
112  // Layers of scintillators
113  G4String rubbish;
114  readName(is,rubbish);
115  is >> nLayerScnt;
116  typeLayerScnt = new int[nLayerScnt];
117  mothLayerScnt = new int[nLayerScnt];
118  xposLayerScnt = new double[nLayerScnt];
119  for (i=0; i<nLayerScnt; i++)
120  is >> typeLayerScnt[i] >> mothLayerScnt[i] >> xposLayerScnt[i];
121 #ifdef debug
122  G4cout << tab << nLayerScnt << " Layers of scintillators of type/mother box/"
123  << "position" << G4endl;
124  for (i=0; i<nLayerScnt; i++)
125  G4cout << tab << i << " " << typeLayerScnt[i] << " " << mothLayerScnt[i]
126  << " " << xposLayerScnt[i] << G4endl;
127 #endif
128 
129  // Layers of absorbers
130  readName(is,rubbish);
131  is >> nLayerAbs;
132  typeLayerAbs = new int[nLayerAbs];
133  mothLayerAbs = new int[nLayerAbs];
134  xposLayerAbs = new double[nLayerAbs];
135  for (i=0; i<nLayerAbs; i++)
136  is >> typeLayerAbs[i] >> mothLayerAbs[i] >> xposLayerAbs[i];
137 #ifdef debug
138  G4cout << tab << nLayerAbs << " Layers of absorbers of type/mother box/"
139  << "position" << G4endl;
140  for (i=0; i<nLayerAbs; i++)
141  G4cout << tab << i << " " << typeLayerAbs[i] << " " << mothLayerAbs[i]
142  << " " << xposLayerAbs[i] << G4endl;
143 #endif
144 
145  // Absorber parameters
146  readName(is,absMaterial);
147  is >> nAbsorber >> dy_2Absorber;
148  dx_2Absorber = new double[nAbsorber];
149  for (i=0; i<nAbsorber; i++)
150  is >> dx_2Absorber[i];
151 #ifdef debug
152  G4cout << "\tAbsorber mad of " << absMaterial << " with " << nAbsorber
153  << " types and size " << dy_2Absorber;
154  for (i=0; i<nAbsorber; i++)
155  G4cout << " " << i << " " << dx_2Absorber[i];
156  G4cout << G4endl;
157 #endif
158 
159  // Scintillator parameters
163  is >> nScintillator;
164  dy_2ScntLayer = new double[nScintillator];
165  dx_2ScntLayer = new double[nScintillator];
166  dx_2Wrapper = new double[nScintillator];
167  dx_2FrontPlastic = new double[nScintillator];
168  dx_2BackPlastic = new double[nScintillator];
169  dx_2Scintillator = new double[nScintillator];
170  for (i=0; i<nScintillator; i++)
171  is >> dy_2ScntLayer[i] >> dx_2ScntLayer[i] >> dx_2Wrapper[i]
173 #ifdef debug
174  G4cout << tab << nScintillator << " Scintillator layers made of "
175  << scntMaterial << " " << wrapMaterial << " and " << plasMaterial
176  << " of sizes " << G4endl;
177  for (i=0; i<nScintillator; i++)
178  G4cout << tab << i << " " << dy_2ScntLayer[i] << " " << dx_2ScntLayer[i]
179  << " " << dx_2Wrapper[i] << " " << dx_2FrontPlastic[i] << " "
180  << dx_2BackPlastic[i] << " " << dx_2Scintillator[i] << G4endl;
181 #endif
182 
184  // Close the file
185  G4cout << " ==> Closing file " << File() << G4endl;
186  is.close();
187 
188  return 1;
189 
190 }
191 
193 }
double * xposLayerScnt
Definition: CCalHcal.hh:95
int * mothLayerScnt
Definition: CCalHcal.hh:94
double * dx_2BackPlastic
Definition: CCalHcal.hh:115
double dy_2Absorber
Definition: CCalHcal.hh:104
double xposCal
Definition: CCalHcal.hh:83
bool openGeomFile(std::ifstream &is, const G4String &pathname, const G4String &filename)
Definition: CCalutils.cc:116
G4String absMaterial
Definition: CCalHcal.hh:102
double * xposLayerAbs
Definition: CCalHcal.hh:100
double * dx_2Wrapper
Definition: CCalHcal.hh:113
virtual void constructDaughters()
Definition: CCalHcal.cc:192
int * typeLayerScnt
Definition: CCalHcal.hh:93
const char * name(G4int ptype)
int * mothLayerAbs
Definition: CCalHcal.hh:99
std::istream & jump(std::istream &)
Definition: CCalutils.cc:95
std::ifstream & findDO(std::ifstream &, const G4String &)
Definition: CCalutils.cc:72
int nBox
Definition: CCalHcal.hh:86
double dx_2Cal
Definition: CCalHcal.hh:82
std::ifstream & readName(std::ifstream &, G4String &)
Definition: CCalutils.cc:53
G4GLOB_DLL std::ostream G4cout
int nScintillator
Definition: CCalHcal.hh:110
virtual int readFile()
Definition: CCalHcal.cc:74
int nAbsorber
Definition: CCalHcal.hh:103
double * xposBox
Definition: CCalHcal.hh:90
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
G4String pathName
double * dx_2Absorber
Definition: CCalHcal.hh:105
int nLayerScnt
Definition: CCalHcal.hh:92
double * dy_2ScntLayer
Definition: CCalHcal.hh:111
double dy_2Box
Definition: CCalHcal.hh:87
virtual ~CCalHcal()
Definition: CCalHcal.cc:43
G4String plasMaterial
Definition: CCalHcal.hh:109
G4String genMaterial
Definition: CCalHcal.hh:80
double * dx_2Scintillator
Definition: CCalHcal.hh:116
G4String boxMaterial
Definition: CCalHcal.hh:85
double wallThickBox
Definition: CCalHcal.hh:89
double dx_2Box
Definition: CCalHcal.hh:88
G4String scntMaterial
Definition: CCalHcal.hh:107
int nLayerAbs
Definition: CCalHcal.hh:97
#define G4endl
Definition: G4ios.hh:61
double * dx_2FrontPlastic
Definition: CCalHcal.hh:114
G4String File() const
Definition: CCalDetector.hh:79
CCalHcal(const G4String &name)
Definition: CCalHcal.cc:37
double dy_2Cal
Definition: CCalHcal.hh:81
G4String wrapMaterial
Definition: CCalHcal.hh:108
double * dx_2ScntLayer
Definition: CCalHcal.hh:112
int * typeLayerAbs
Definition: CCalHcal.hh:98