source: trunk/examples/advanced/lAr_calorimeter/src/FCALEMModule.cc @ 1282

Last change on this file since 1282 was 807, checked in by garnier, 16 years ago

update

File size: 6.6 KB
Line 
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//
26//   Author:             Rachid Mazini
27//                       Rachid.Mazini@cern.ch
28//   Language:           C++
29//   Tested on :         g++ (egcs.2.1.1, RH6.1)
30//   Prerequisites:      None
31//   Purpose:            Source file defining the geometry of EMModule 0 of the
32//                       FCAL.
33//   Developped:         10-March-2000   R.M.
34//   
35//
36//-----------------------------------------------------------------------------
37
38#include "FCALEMModule.hh"
39
40#include "FCALMaterialConsultant.hh"
41
42#include "G4SDManager.hh"
43#include "FCALEMModuleSD.hh"
44
45#include "G4Box.hh"
46#include "G4Tubs.hh"
47#include "G4LogicalVolume.hh"
48#include "G4VPhysicalVolume.hh"
49#include "G4PVPlacement.hh"
50#include "G4SubtractionSolid.hh"
51
52#include "G4ThreeVector.hh"
53#include "G4VisAttributes.hh"
54#include "G4Colour.hh"
55
56#include <fstream>
57#include <cstdlib>
58
59FCALEMModule::FCALEMModule() : 
60  FcalEmModuleSD(0)
61 {
62  F1LArGapID   = new G4int[2400];
63  F1LArIX      = new G4int[2400];
64  F1LArJY      = new G4int[2400];
65  F1LArITile   = new G4int[2400];
66  F1LArGapPosX = new G4double[2400];
67  F1LArGapPosY = new G4double[2400];
68}
69
70
71FCALEMModule::~FCALEMModule(){
72  delete [] F1LArGapID;
73  delete [] F1LArGapPosX;
74  delete [] F1LArGapPosY;
75  delete [] F1LArIX;
76  delete [] F1LArJY;
77  delete [] F1LArITile;
78}
79
80
81void FCALEMModule::InitializeGeometry() {
82#include "FCALEMModuleParameters.input" 
83  std::ifstream File
84    ("geom_data/FCal1Electrodes.dat");
85 
86  if(!File)  G4cerr << "Failed to open file FCal1Electrodes data file  " << G4endl;
87  File.seekg(0);
88 
89  NF1LarGap = 0;
90  while(!(File.eof())) {
91    NF1LarGap++;
92    File >> F1LArGapID[NF1LarGap] >> F1LArGapPosX[NF1LarGap] >> F1LArGapPosY[NF1LarGap]
93         >> F1LArIX[NF1LarGap] >>  F1LArJY[NF1LarGap] >> F1LArITile[NF1LarGap];
94  };   
95  G4cout << "********" << " Number of Rods in FCAL1 : " << NF1LarGap-1 << G4endl;;
96}
97
98
99
100G4LogicalVolume * FCALEMModule::Construct()
101{
102  //-----------------------------
103  // construction of materials
104  //-----------------------------
105  FCALMaterialConsultant * FCALMaterials = new FCALMaterialConsultant();
106  FCALMaterials->construct();
107
108  G4VisAttributes * ColorOfEMModule = new G4VisAttributes(G4Colour(1.,0.,0.5));
109//  G4VisAttributes * ColorOfLArg = new G4VisAttributes(G4Colour(0.,0.,1.));
110
111  //----------------------------
112  //      Read Parameters
113  //----------------------------
114  InitializeGeometry();
115
116//-----------------------------------------
117// Logical to be returned (FCAL EM module)
118//-----------------------------------------
119  G4Tubs * SolidEmModule =
120    new G4Tubs("EmModuleSold", EmModuleRMin, EmModuleRMax, EmModuleLenght,
121               EmModuleStartPhi,EmModuleDPhi);
122  G4LogicalVolume * LogicalEmModule = 
123    new G4LogicalVolume(SolidEmModule, FCALMaterials->Material("Copper"),
124                        "EmModuleLogical");
125 
126  LogicalEmModule->SetSmartless(FCALEmSmart);
127
128   LogicalEmModule->SetVisAttributes(ColorOfEMModule);
129  //  LogicalEmModule->SetVisAttributes(G4VisAttributes::Invisible);
130
131
132//---------------------
133//  FCAL Cable Troff 
134//---------------------
135  G4Tubs * SolidF1CableTroff =
136    new G4Tubs("F1CableTroffSolid", F1CableTroffRMin, F1CableTroffRMax,
137               F1CableTroffLenght, F1CableTroffStartPhi, F1CableTroffDPhi);
138  G4LogicalVolume * LogicalF1CableTroff =
139    new G4LogicalVolume(SolidF1CableTroff, FCALMaterials->Material("FCAL1CuArKap"),
140                        "F1CableTroffLogical");
141
142  G4ThreeVector F1CableTroffTrans(0.,0.,0.);
143  G4RotationMatrix F1CableTroffRot;
144
145  G4int i=0;
146  for(i=0 ; i < NCableTroff ; i++)
147    {
148//      G4VPhysicalVolume * PhysicalF1CableTroff =
149        new G4PVPlacement(G4Transform3D(F1CableTroffRot,F1CableTroffTrans),
150                          LogicalF1CableTroff,"F1CableTroffPhysical",
151                          LogicalEmModule,0,i+1);
152
153      F1CableTroffRot.rotateZ(F1CableTroffRotZ);
154    }
155
156  LogicalF1CableTroff->SetVisAttributes(ColorOfEMModule);
157  // LogicalF1CableTroff->SetVisAttributes(G4VisAttributes::Invisible);
158
159
160   //----------------------
161   //    LArg gaps
162   //----------------------
163
164  G4Tubs * SolidF1LArGap = 
165    new G4Tubs("F1LArGapSolid",F1LArGapRmin, F1LArGapRmax, F1LArGapLenght, 
166               F1LArGapStartPhi,F1LArGapDPhi);
167       
168   G4LogicalVolume * LogicalF1LArGap = 
169     new G4LogicalVolume(SolidF1LArGap, FCALMaterials->Material("LiquidArgon"),
170                         "LArg Gap");
171 
172   for(i=1; i < NF1LarGap; i++){
173//     G4VPhysicalVolume * PhysicalF1LArGap =
174       new G4PVPlacement(0,G4ThreeVector(F1LArGapPosX[i]*cm,F1LArGapPosY[i]*cm,0.*cm),
175                          LogicalF1LArGap,"F1LArGapPhysical", LogicalEmModule, 0, i); 
176   };
177
178   // LogicalF1LArGap->SetVisAttributes(ColorOfLArg);
179   LogicalF1LArGap->SetVisAttributes(G4VisAttributes::Invisible);
180   
181
182    // Sensitive Volumes
183   G4SDManager* SDman = G4SDManager::GetSDMpointer();
184 
185   if(!FcalEmModuleSD)
186     {
187       FcalEmModuleSD = new FCALEMModuleSD("FCALTB/EmModuleSD");
188       SDman->AddNewDetector(FcalEmModuleSD);
189     }
190   LogicalF1LArGap->SetSensitiveDetector(FcalEmModuleSD);
191
192   
193
194   return LogicalEmModule;
195
196}
197
198
199G4int FCALEMModule::GetF1TileID(G4int GapID) 
200{ return F1LArITile[GapID]; }
201
202G4double FCALEMModule::GetF1LArGapPosX(G4int GapID)
203{ return F1LArGapPosX[GapID]; }
204
205
Note: See TracBrowser for help on using the repository browser.