EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICG4ZDCStructure.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICG4ZDCStructure.cc
1 //
2 // -1/June/2021 First ZDC design (Crystal + FoCal style) Shima Shimizu
3 // Started from miniFocal Geometry codes
4 // -14/Dec/2021 Second ZDC design
5 // Able to produce tower maps
6 
7 #include "EICG4ZDCStructure.h"
8 #include "EICG4ZDCconstants.h"
9 #include "EICG4ZDCdetid.h"
10 
11 #include <Geant4/G4LogicalVolume.hh>
12 #include <Geant4/G4VPhysicalVolume.hh>
13 #include <Geant4/G4PVPlacement.hh>
14 #include <Geant4/G4PVReplica.hh>
15 #include <Geant4/G4Box.hh>
16 #include <Geant4/G4NistManager.hh>
17 #include <Geant4/G4VisAttributes.hh>
18 #include <Geant4/G4Color.hh>
19 
20 
22  Materials();
23  SetColors();
24  fLayer=0;
25  _z_Crystal[0]=0;
26  _z_Crystal[1]=0;
27  _z_EMLayers[0]=0;
28  _z_EMLayers[1]=0;
29  _z_HCSilicon[0]=0;
30  _z_HCSilicon[1]=0;
31  _z_HCSci[0]=0;
32  _z_HCSci[1]=0;
33 
34 }
36 
37 void EICG4ZDCStructure::ProvideLogicalVolumesSets(std::set<G4LogicalVolume *> &ActiveLogicalVolumesSet,
38  std::set<G4LogicalVolume *> &AbsorberLogicalVolumesSet){
39 
40  ActiveLogicalVolumesSet = m_ActiveLogicalVolumesSet;
41  AbsorberLogicalVolumesSet= m_AbsorberLogicalVolumesSet;
42 
43  return;
44 
45 }
46 
47 void EICG4ZDCStructure::ProvideLogicalVolumeInfoMap(std::map<G4LogicalVolume *, int> &ActiveLogicalVolumeInfoMap,
48  std::map<G4LogicalVolume *, int> &AbsorberLogicalVolumeInfoMap){
49 
50  ActiveLogicalVolumeInfoMap = m_ActiveLogicalVolumeInfoMap;
51  AbsorberLogicalVolumeInfoMap = m_AbsorberLogicalVolumeInfoMap;
52 
53  return;
54 
55 }
56 
57 double EICG4ZDCStructure::ConstructCrystalTowers(double Start_X, double Start_Y, double Start_Z,
58  double End_X, double End_Y, double End_Z,
59  G4VPhysicalVolume *motherPhy) {
60  _z_Crystal[0] = Start_Z;
61 
62  double Center_X = (Start_X + End_X)/2.;
63  double Center_Y = (Start_Y + End_Y)/2.;
64  double Width_X = End_X - Start_X;
65  double Width_Y = End_Y - Start_Y;
66 
67  G4Box* PIX_Silicon = new G4Box("CPIX_Silicon", PIX_X/2.0, PIX_Y/2.0, PIX_Z/2.0);
68  G4Box* PIX_Glue2 = new G4Box("CPIX_Glue2", Width_X/2.0, Width_Y/2.0, PIX_Glue2_Z/2.0);
69  G4Box* PIX_FPC = new G4Box("CPIX_FPC", Width_X/2.0, Width_Y/2.0, PIX_FPC_Z/2.0);
70  G4Box *Crystal = new G4Box("Crystal", CTower_X*0.5 ,CTower_Y*0.5, CTower_Z*0.5);
71  G4Box *CrysEnvelope= new G4Box("CrysEnvelope",CTower_X*0.5 ,Width_Y*0.5, CTower_Z*0.5);
72  G4Box *CrysBox = new G4Box("CrysBox", Width_X*0.5 ,Width_Y*0.5, CTower_Z*0.5);
73  G4Box *PIXPlane = new G4Box("CPIXPlane", Width_X/2.0, Width_Y/2.0, PIX_Z/2.0);
74  G4Box *PIXEnvelope = new G4Box("CPIXEnvelope",PIX_X/2.0, Width_Y/2.0, PIX_Z/2.0);
75 
76  G4LogicalVolume* lV_PIX_Silicon = new G4LogicalVolume( PIX_Silicon, fmat_Si, "lV_Crystal_PIX_Silicon" );
77  G4LogicalVolume* lV_PIX_Glue2 = new G4LogicalVolume( PIX_Glue2, fmat_PET, "lV_Crystal_PIX_Glue2");
78  G4LogicalVolume* lV_PIX_FPC = new G4LogicalVolume( PIX_FPC, fmat_PET, "lV_Crystal_PIX_FPC");
79  G4LogicalVolume* lV_Crystal = new G4LogicalVolume( Crystal, fmat_Crystal, "lV_Crystal");
80  G4LogicalVolume* lV_CrysEnvelope= new G4LogicalVolume( CrysEnvelope, fmat_World, "lV_CrysEnvelope");
81  G4LogicalVolume* lV_CrysBox = new G4LogicalVolume( CrysBox, fmat_World, "lV_CrysBox");
82  G4LogicalVolume* lV_PIXPlane = new G4LogicalVolume( PIXPlane, fmat_World, "lV_CPIXPlane");
83  G4LogicalVolume* lV_PIXEnvelope = new G4LogicalVolume( PIXEnvelope, fmat_World, "lV_CPIXEnvelope");
84 
85  lV_Crystal->SetVisAttributes(fvisCrystal);
86  lV_PIX_Silicon->SetVisAttributes(fvisPIX);
87  lV_PIX_Glue2->SetVisAttributes(fvisDM);
88  lV_PIX_FPC->SetVisAttributes(fvisDM);
89 
90  lV_CrysBox->SetVisAttributes(G4VisAttributes::Invisible);
91  lV_CrysEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
92  lV_PIXPlane->SetVisAttributes(G4VisAttributes::Invisible);
93  lV_PIXEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
94 
95  std::pair<G4LogicalVolume*, int> pair_Crystal= std::make_pair(lV_Crystal, fLayer*100 + ZDCID::Crystal + ZDCID::CrystalTower);
96  std::pair<G4LogicalVolume*, int> pair_CPIX = std::make_pair(lV_PIX_Silicon, fLayer*100 + ZDCID::SI_PIXEL + ZDCID::CrystalTower);
97  m_ActiveLogicalVolumeInfoMap.insert(pair_Crystal);
98  m_ActiveLogicalVolumeInfoMap.insert(pair_CPIX);
99  std::pair<G4LogicalVolume*, int> pair_Glue2 = std::make_pair(lV_PIX_Glue2, fLayer*100 + ZDCID::Materials + ZDCID::CrystalTower);
100  std::pair<G4LogicalVolume*, int> pair_FPC = std::make_pair(lV_PIX_FPC, fLayer*100 + ZDCID::Materials + ZDCID::CrystalTower);
101  m_AbsorberLogicalVolumeInfoMap.insert(pair_Glue2);
102  m_AbsorberLogicalVolumeInfoMap.insert(pair_FPC);
103 
104  m_ActiveLogicalVolumesSet.insert(lV_PIX_Silicon);
105  m_ActiveLogicalVolumesSet.insert(lV_Crystal);
106  m_AbsorberLogicalVolumesSet.insert(lV_PIX_Glue2);
107  m_AbsorberLogicalVolumesSet.insert(lV_PIX_FPC);
108 
109  //Making PIX layers using Replica
110 
111  int NdivX = (int)(Width_X/ PIX_X);
112  new G4PVReplica("PV_CPIXEnvelope", lV_PIXEnvelope, lV_PIXPlane, kXAxis, NdivX, PIX_X,0);
113  int NdivY = (int)(Width_Y/ PIX_Y);
114  new G4PVReplica("PV_CPIX", lV_PIX_Silicon, lV_PIXEnvelope, kYAxis, NdivY, PIX_Y,0);
115 
116  //Making Crystal Box using Replica
117  new G4PVReplica("PV_CrysEnvelope", lV_CrysEnvelope, lV_CrysBox, kXAxis, nCTowerX, CTower_X,0);
118  new G4PVReplica("PV_Crystal", lV_Crystal, lV_CrysEnvelope, kYAxis, nCTowerY, CTower_Y,0);
119 
120  //*********************
121  //Now crete nCTowerZ+1 PIX layers with nCTowerZ Tower layers
122  //*******************
123 
124  double offsetZ=0;
125  int LayerID = fLayer;
126 
127  for(int ilayer=0; ilayer<nCTowerZ+1; ilayer++){
128  G4double position_Z_PIX_Silicon = Start_Z + offsetZ + PIX_Z/2.;
129  G4double position_Z_PIX_Glue2 = Start_Z + offsetZ + PIX_Z + PIX_Glue2_Z/2.;
130  G4double position_Z_PIX_FPC = Start_Z + offsetZ + PIX_Z + PIX_Glue2_Z + PIX_FPC_Z/2.;
131  offsetZ += PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap;
132 
133  G4ThreeVector threeVect_PIX_Silicon = G4ThreeVector(Center_X, Center_Y, position_Z_PIX_Silicon);
134  G4ThreeVector threeVect_PIX_Glue2 = G4ThreeVector(Center_X, Center_Y, position_Z_PIX_Glue2);
135  G4ThreeVector threeVect_PIX_FPC = G4ThreeVector(Center_X, Center_Y, position_Z_PIX_FPC);
136 
137  std::string ss_PIX_Plane = "PhysVol_CPIXPlane" + std::to_string(ilayer) + "_L" + std::to_string(LayerID);
138  std::string ss_PIX_Glue2 = "PhysVol_CGlue2_" + std::to_string(ilayer);
139  std::string ss_PIX_FPC = "PhysVol_CFPC_" + std::to_string(ilayer);
140 
141  new G4PVPlacement(0, threeVect_PIX_Silicon, ss_PIX_Plane, lV_PIXPlane, motherPhy, false, ilayer);
142  new G4PVPlacement(0, threeVect_PIX_Glue2, ss_PIX_Glue2, lV_PIX_Glue2, motherPhy, false, ilayer);
143  new G4PVPlacement(0, threeVect_PIX_FPC, ss_PIX_FPC, lV_PIX_FPC, motherPhy, false, ilayer);
144 
145  LayerID +=2;
146  offsetZ +=CTower_Z + CTower_GAP;
147  }
148 
149  offsetZ = PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap;
150  LayerID = fLayer+1;
151 
152  for (int ilayer =0; ilayer<nCTowerZ; ilayer++){
153  G4double position_Z_Crystal = Start_Z + offsetZ + CTower_Z/2.;
154 
155  G4ThreeVector threeVect_Crystal = G4ThreeVector(Center_X, Center_Y, position_Z_Crystal);
156  std::string ss_Crystal = "PhysVol_Crystal_L"+std::to_string(LayerID);
157 
158  new G4PVPlacement(0, threeVect_Crystal, ss_Crystal, lV_CrysBox, motherPhy, false, ilayer);
159 
160  LayerID += 2;
162  }
163 
164  fLayer += 2*nCTowerZ +1;
165 
166  _z_Crystal[1] = Start_Z + (CTower_Z + CTower_GAP) * nCTowerZ + (PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap) * (nCTowerZ +1);
167  return _z_Crystal[1];
168 
169 }
170 
171 double EICG4ZDCStructure::ConstructEMLayers(double Start_X, double Start_Y, double Start_Z,
172  double End_X, double End_Y, double End_Z,
173  G4VPhysicalVolume *motherPhy) {
174 
175  _z_EMLayers[0] = Start_Z;
176 
177  double Center_X = (Start_X + End_X)/2.;
178  double Center_Y = (Start_Y + End_Y)/2.;
179  double Width_X = End_X - Start_X;
180  double Width_Y = End_Y - Start_Y;
181  double PadOnlyThickness = PAD_Layer_Thickness * NPadOnlyLayers;
182 
183  //*****************************************************************************************
184  //G4box is the material
185  //Ignoring the width coming from the Guard Ring Thickness.
186  //PAD layer
187  G4Box* PAD_W = new G4Box("PPAD_W", Width_X/2.0, Width_Y/2.0, PAD_Absorber_Z/2.0);
188  G4Box* PAD_Glue1 = new G4Box("PPAD_Glue1", Width_X/2.0, Width_Y/2.0, PAD_Glue1_Z/2.0);
189  G4Box* PAD_Silicon = new G4Box("PPAD_Silicon", PAD_X/2.0, PAD_Y/2.0, PAD_Z/2.0);
190  G4Box* PAD_Glue2 = new G4Box("PPAD_Glue2", Width_X/2.0, Width_Y/2.0, PAD_Glue2_Z/2.0);
191  G4Box* PAD_FPC = new G4Box("PPAD_FPC", Width_X/2.0, Width_Y/2.0, PAD_FPC_Z/2.0);
192  G4Box *PAD_Plane = new G4Box("PAD_Plane", Width_X/2.0, Width_Y/2.0, PAD_Z/2.0);
193  G4Box *PAD_Envelope = new G4Box("PAD_Envelope", PAD_X/2.0, Width_Y/2.0, PAD_Z/2.0);
194  G4Box *PAD_Layer = new G4Box("PAD_Layer", Width_X/2.0, Width_Y/2.0, PAD_Layer_Thickness/2.0);
195  G4Box *PADonlyBox = new G4Box("PADonlyBox", Width_X/2.0, Width_Y/2.0, PadOnlyThickness/2.0);
196 
197  //PIX layer
198  G4Box* PIX_W = new G4Box("PPIX_W", Width_X/2.0, Width_Y/2.0, PIX_Absorber_Z/2.0);
199  G4Box* PIX_Glue1 = new G4Box("PPIX_Glue1", Width_X/2.0, Width_Y/2.0, PIX_Glue1_Z/2.0);
200  G4Box* PIX_Silicon = new G4Box("PPIX_Silicon", PIX_X/2.0, PIX_Y/2.0, PIX_Z/2.0);
201  G4Box* PIX_Glue2 = new G4Box("PPIX_Glue2", Width_X/2.0, Width_Y/2.0, PIX_Glue2_Z/2.0);
202  G4Box* PIX_FPC = new G4Box("PPIX_FPC", Width_X/2.0, Width_Y/2.0, PIX_FPC_Z/2.0);
203  G4Box *PIX_Plane = new G4Box("PIX_Plane", Width_X/2.0, Width_Y/2.0, PIX_Z/2.0);
204  G4Box *PIX_Envelope = new G4Box("PIX_Envelope", PIX_X/2.0, Width_Y/2.0, PIX_Z/2.0);
205  G4Box *PIX_Layer = new G4Box("PIX_Layer", Width_X/2.0, Width_Y/2.0, PIX_Layer_Thickness/2.0);
206 
207  //*****************************************************************************************
208  // Logical volumes
209  //*****************************************************************************************
210  //PAD
211  G4LogicalVolume* lV_PAD_W = new G4LogicalVolume( PAD_W, fmat_W, "lV_PAD_W");
212  G4LogicalVolume* lV_PAD_Glue1 = new G4LogicalVolume( PAD_Glue1, fmat_PET, "lV_PAD_Glue1" );
213  G4LogicalVolume* lV_PAD_Silicon = new G4LogicalVolume( PAD_Silicon, fmat_Si, "lV_PAD_Silicon" );
214  G4LogicalVolume* lV_PAD_Glue2 = new G4LogicalVolume( PAD_Glue2, fmat_PET, "lV_PAD_Glue2");
215  G4LogicalVolume* lV_PAD_FPC = new G4LogicalVolume( PAD_FPC, fmat_PET, "lV_PAD_FPC");
216  G4LogicalVolume* lV_PADPlane = new G4LogicalVolume( PAD_Plane, fmat_World, "lV_PADPlane");
217  G4LogicalVolume* lV_PADEnvelope = new G4LogicalVolume( PAD_Envelope, fmat_World, "lV_PADEnvelope");
218  G4LogicalVolume* lV_PADLayer = new G4LogicalVolume( PAD_Layer, fmat_World, "lV_PADLayer");
219  G4LogicalVolume* lV_PADonlyBox = new G4LogicalVolume( PADonlyBox, fmat_World, "lV_PADonlyBox");
220 
221  //PIX
222  G4LogicalVolume* lV_PIX_W = new G4LogicalVolume( PIX_W, fmat_W, "lV_PIX_W");
223  G4LogicalVolume* lV_PIX_Glue1 = new G4LogicalVolume( PIX_Glue1, fmat_PET, "lV_PIX_Glue1");
224  G4LogicalVolume* lV_PIX_Silicon = new G4LogicalVolume( PIX_Silicon, fmat_Si, "lV_PIX_Silicon" );
225  G4LogicalVolume* lV_PIX_Glue2 = new G4LogicalVolume( PIX_Glue2, fmat_PET, "lV_PIX_Glue2" );
226  G4LogicalVolume* lV_PIX_FPC = new G4LogicalVolume( PIX_FPC, fmat_PET, "lV_PIX_FPC");
227  G4LogicalVolume* lV_PIXPlane = new G4LogicalVolume( PIX_Plane, fmat_World, "lV_PIXPlane");
228  G4LogicalVolume* lV_PIXEnvelope = new G4LogicalVolume( PIX_Envelope, fmat_World, "lV_PIXEnvelope");
229  G4LogicalVolume* lV_PIXLayer = new G4LogicalVolume( PIX_Layer, fmat_World, "lV_PIXLayer");
230 
231  lV_PAD_W->SetVisAttributes(fvisW);
232  lV_PIX_W->SetVisAttributes(fvisW);
233 
234  lV_PAD_Silicon->SetVisAttributes(fvisPAD);
235  lV_PIX_Silicon->SetVisAttributes(fvisPIX);
236 
237  lV_PAD_Glue1->SetVisAttributes(fvisDM);
238  lV_PAD_Glue2->SetVisAttributes(fvisDM);
239  lV_PAD_FPC->SetVisAttributes(fvisDM);
240  lV_PIX_Glue1->SetVisAttributes(fvisDM);
241  lV_PIX_Glue2->SetVisAttributes(fvisDM);
242  lV_PIX_FPC->SetVisAttributes(fvisDM);
243 
244  lV_PADPlane->SetVisAttributes(G4VisAttributes::Invisible);
245  lV_PADEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
246  lV_PADLayer->SetVisAttributes(G4VisAttributes::Invisible);
247  lV_PADonlyBox->SetVisAttributes(G4VisAttributes::Invisible);
248  lV_PIXPlane->SetVisAttributes(G4VisAttributes::Invisible);
249  lV_PIXEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
250  lV_PIXLayer->SetVisAttributes(G4VisAttributes::Invisible);
251 
252  int infoval=0;
253  infoval = ZDCID::EMLayer+ NPadOnlyLayers * 10000 + fLayer*100 + ZDCID::SI_PAD;
254  std::pair<G4LogicalVolume*, int> pair_PAD_Si = std::make_pair(lV_PAD_Silicon, infoval);
255  infoval = ZDCID::EMLayer+ NPadOnlyLayers * 10000 + fLayer*100 + ZDCID::SI_PIXEL;
256  std::pair<G4LogicalVolume*, int> pair_PIX_Si = std::make_pair(lV_PIX_Silicon, infoval);
257  m_ActiveLogicalVolumeInfoMap.insert(pair_PAD_Si);
258  m_ActiveLogicalVolumeInfoMap.insert(pair_PIX_Si);
259  infoval = ZDCID::EMLayer+ NPadOnlyLayers * 10000 + fLayer*100 + ZDCID::Abs_Tungsten;
260  std::pair<G4LogicalVolume*, int> pair_PAD_W = std::make_pair(lV_PAD_W, infoval);
261  std::pair<G4LogicalVolume*, int> pair_PIX_W = std::make_pair(lV_PIX_W, infoval);
262  infoval = ZDCID::EMLayer+ NPadOnlyLayers * 10000 + fLayer*100 + ZDCID::Materials;
263  std::pair<G4LogicalVolume*, int> pair_PAD_Glue1 = std::make_pair(lV_PAD_Glue1, infoval);
264  std::pair<G4LogicalVolume*, int> pair_PIX_Glue1 = std::make_pair(lV_PIX_Glue1, infoval);
265  std::pair<G4LogicalVolume*, int> pair_PAD_Glue2 = std::make_pair(lV_PAD_Glue2, infoval);
266  std::pair<G4LogicalVolume*, int> pair_PIX_Glue2 = std::make_pair(lV_PIX_Glue2, infoval);
267  std::pair<G4LogicalVolume*, int> pair_PAD_FPC = std::make_pair(lV_PAD_FPC, infoval);
268  std::pair<G4LogicalVolume*, int> pair_PIX_FPC = std::make_pair(lV_PIX_FPC, infoval);
269  m_AbsorberLogicalVolumeInfoMap.insert(pair_PAD_W);
270  m_AbsorberLogicalVolumeInfoMap.insert(pair_PIX_W);
271  m_AbsorberLogicalVolumeInfoMap.insert(pair_PAD_Glue1);
272  m_AbsorberLogicalVolumeInfoMap.insert(pair_PIX_Glue1);
273  m_AbsorberLogicalVolumeInfoMap.insert(pair_PAD_Glue2);
274  m_AbsorberLogicalVolumeInfoMap.insert(pair_PIX_Glue2);
275  m_AbsorberLogicalVolumeInfoMap.insert(pair_PAD_FPC);
276  m_AbsorberLogicalVolumeInfoMap.insert(pair_PIX_FPC);
277 
278  m_ActiveLogicalVolumesSet.insert(lV_PAD_Silicon);
279  m_ActiveLogicalVolumesSet.insert(lV_PIX_Silicon);
280  m_AbsorberLogicalVolumesSet.insert(lV_PAD_W);
281  m_AbsorberLogicalVolumesSet.insert(lV_PAD_Glue1);
282  m_AbsorberLogicalVolumesSet.insert(lV_PAD_Glue2);
283  m_AbsorberLogicalVolumesSet.insert(lV_PAD_FPC);
284  m_AbsorberLogicalVolumesSet.insert(lV_PIX_W);
285  m_AbsorberLogicalVolumesSet.insert(lV_PIX_Glue1);
286  m_AbsorberLogicalVolumesSet.insert(lV_PIX_Glue2);
287  m_AbsorberLogicalVolumesSet.insert(lV_PIX_FPC);
288 
289  //Construct a PAD/PIX plane using Replica
290  new G4PVReplica("PV_PADEnvelope", lV_PADEnvelope, lV_PADPlane, kXAxis, NpadX, PAD_X,0);
291  new G4PVReplica("PV_PAD", lV_PAD_Silicon, lV_PADEnvelope, kYAxis, NpadY, PAD_Y,0);
292 
293  new G4PVReplica("PV_PIXEnvelope", lV_PIXEnvelope, lV_PIXPlane, kXAxis, NpixX, PIX_X,0);
294  new G4PVReplica("PV_PIX", lV_PIX_Silicon, lV_PIXEnvelope, kYAxis, NpixY, PIX_Y,0);
295 
296  //Constract a PAD/PIX layer including glue etc.
297  G4double posZ_PAD_Absorber = -0.5 * PAD_Layer_Thickness + PAD_Absorber_Z/2;
298  G4double posZ_PAD_Glue1 = -0.5 * PAD_Layer_Thickness + PAD_Absorber_Z + PAD_Glue1_Z/2 ;
299  G4double posZ_PAD_Silicon = -0.5 * PAD_Layer_Thickness + PAD_Absorber_Z + PAD_Glue1_Z + PAD_Z/2 ;
300  G4double posZ_PAD_Glue2 = -0.5 * PAD_Layer_Thickness + PAD_Absorber_Z + PAD_Glue1_Z + PAD_Z + PAD_Glue2_Z/2 ;
301  G4double posZ_PAD_FPC = -0.5 * PAD_Layer_Thickness + PAD_Absorber_Z + PAD_Glue1_Z + PAD_Z + PAD_Glue2_Z +PAD_FPC_Z/2 ;
302 
303  G4ThreeVector threeVect_PAD_Silicon = G4ThreeVector(0, 0, posZ_PAD_Silicon);
304  G4ThreeVector threeVect_PAD_W = G4ThreeVector(0, 0, posZ_PAD_Absorber);
305  G4ThreeVector threeVect_PAD_Glue1 = G4ThreeVector(0, 0, posZ_PAD_Glue1);
306  G4ThreeVector threeVect_PAD_Glue2 = G4ThreeVector(0, 0, posZ_PAD_Glue2);
307  G4ThreeVector threeVect_PAD_FPC = G4ThreeVector(0, 0, posZ_PAD_FPC);
308 
309  new G4PVPlacement(0, threeVect_PAD_W, lV_PAD_W, "PV_PAD_W", lV_PADLayer,false,0);
310  new G4PVPlacement(0, threeVect_PAD_Glue1, lV_PAD_Glue1,"PV_PAD_Glue1", lV_PADLayer,false,0);
311  new G4PVPlacement(0, threeVect_PAD_Silicon, lV_PADPlane, "PV_PAD_Plane", lV_PADLayer,false,0);
312  new G4PVPlacement(0, threeVect_PAD_Glue2, lV_PAD_Glue2,"PV_PAD_Glue2", lV_PADLayer,false,0);
313  new G4PVPlacement(0, threeVect_PAD_FPC, lV_PAD_FPC, "PV_PAD_FPC", lV_PADLayer,false,0);
314 
315  G4double posZ_PIX_Absorber = -0.5 * PIX_Layer_Thickness + PIX_Absorber_Z/2;
316  G4double posZ_PIX_Glue1 = -0.5 * PIX_Layer_Thickness + PIX_Absorber_Z + PIX_Glue1_Z/2 ;
317  G4double posZ_PIX_Silicon = -0.5 * PIX_Layer_Thickness + PIX_Absorber_Z + PIX_Glue1_Z + PIX_Z/2 ;
318  G4double posZ_PIX_Glue2 = -0.5 * PIX_Layer_Thickness + PIX_Absorber_Z + PIX_Glue1_Z + PIX_Z + PIX_Glue2_Z/2 ;
319  G4double posZ_PIX_FPC = -0.5 * PIX_Layer_Thickness + PIX_Absorber_Z + PIX_Glue1_Z + PIX_Z + PIX_Glue2_Z +PIX_FPC_Z/2 ;
320 
321  G4ThreeVector threeVect_PIX_Silicon = G4ThreeVector(0, 0, posZ_PIX_Silicon);
322  G4ThreeVector threeVect_PIX_W = G4ThreeVector(0, 0, posZ_PIX_Absorber);
323  G4ThreeVector threeVect_PIX_Glue1 = G4ThreeVector(0, 0, posZ_PIX_Glue1);
324  G4ThreeVector threeVect_PIX_Glue2 = G4ThreeVector(0, 0, posZ_PIX_Glue2);
325  G4ThreeVector threeVect_PIX_FPC = G4ThreeVector(0, 0, posZ_PIX_FPC);
326 
327  new G4PVPlacement(0, threeVect_PIX_W, lV_PIX_W, "PV_PIX_W", lV_PIXLayer,false,0);
328  new G4PVPlacement(0, threeVect_PIX_Glue1, lV_PIX_Glue1,"PV_PIX_Glue1", lV_PIXLayer,false,0);
329  new G4PVPlacement(0, threeVect_PIX_Silicon, lV_PIXPlane, "PV_PIX_Plane", lV_PIXLayer,false,0);
330  new G4PVPlacement(0, threeVect_PIX_Glue2, lV_PIX_Glue2,"PV_PIX_Glue2", lV_PIXLayer,false,0);
331  new G4PVPlacement(0, threeVect_PIX_FPC, lV_PIX_FPC, "PV_PIX_FPC", lV_PIXLayer,false,0);
332 
333  //construct PAD only layers
334  new G4PVReplica("PV_PADLayers", lV_PADLayer, lV_PADonlyBox, kZAxis, NPadOnlyLayers, PAD_Layer_Thickness,0);
335 
336  //*****************************************************************************************
337  //The PAD and PIX layer thicknesses can be different - this variable remembers the previous layer thickness either PIX or PAD
338  //It is changed at the end of the loops
339  G4double TotalLayerThickness = 0;
340 
341  for(G4int ilayer=0; ilayer<NumberPIX; ilayer++){
342 
343  G4double posZ_PAD_Box = Start_Z + TotalLayerThickness + 0.5*PadOnlyThickness;
344  G4ThreeVector threeVect_PAD_Box = G4ThreeVector(Center_X, Center_Y, posZ_PAD_Box);
345  std::string ss_PADBox = "PADOnlyBox" + std::to_string(ilayer);
346  new G4PVPlacement(0,threeVect_PAD_Box, ss_PADBox, lV_PADonlyBox, motherPhy, false, ilayer);
347  TotalLayerThickness += PadOnlyThickness;
348 
349  G4double posZ_PIX_Layer = Start_Z + TotalLayerThickness + 0.5 *PIX_Layer_Thickness;
350  G4ThreeVector threeVect_PIX_Layer = G4ThreeVector(Center_X, Center_Y, posZ_PIX_Layer);
351  std::string ss_PIX = "PixLayer" + std::to_string(ilayer);
352  new G4PVPlacement(0, threeVect_PIX_Layer,ss_PIX, lV_PIXLayer, motherPhy, false, (NPadOnlyLayers+1) * (ilayer+1) -1);
353  TotalLayerThickness += PIX_Layer_Thickness;
354 
355  }
356 
357  if(NumberPAD > NPadOnlyLayers * NumberPIX){
358  int NPadtoAdd = NumberPAD - NPadOnlyLayers * NumberPIX;
359  for(G4int ilayer =0; ilayer<NPadtoAdd; ilayer++){
360  G4double posZ_PAD_Layer = Start_Z + TotalLayerThickness + 0.5 *PAD_Layer_Thickness;
361  G4ThreeVector threeVect_PAD_Layer = G4ThreeVector(Center_X, Center_Y, posZ_PAD_Layer);
362  std::string ss_PAD = "PADLayer" + std::to_string(ilayer);
363  new G4PVPlacement(0, threeVect_PAD_Layer,ss_PAD, lV_PADLayer, motherPhy, false, ilayer);
364  TotalLayerThickness += PAD_Layer_Thickness;
365  }
366  }
367 
369 
370  _z_EMLayers[1] = Start_Z+TotalLayerThickness;
371  return _z_EMLayers[1];
372 
373 }
374 
375 double EICG4ZDCStructure::ConstructHCSiliconLayers(double Start_X, double Start_Y, double Start_Z,
376  double End_X, double End_Y, double End_Z,
377  G4VPhysicalVolume *motherPhy) {
378  _z_HCSilicon[0] = Start_Z;
379 
380  double Center_X = (Start_X + End_X)/2.;
381  double Center_Y = (Start_Y + End_Y)/2.;
382  double Width_X = End_X - Start_X;
383  double Width_Y = End_Y - Start_Y;
384  double TotalLayerThickness = HCal_Si_Layer_Thickness * HCALSiNumberOfLayers;
385 
386  G4Box* HCal_Absorber = new G4Box("HCal_SiAbsorber", Width_X/2.0, Width_Y/2.0, HCAL_Z_Absorber/2.0);
387  G4Box* HCal_Layer = new G4Box("HCal_SiLayer", Width_X/2.0, Width_Y/2.0, HCal_Si_Layer_Thickness/2.0);
388  G4Box* PAD_Glue1 = new G4Box("HPAD_Glue1", Width_X/2.0, Width_Y/2.0, PAD_Glue1_Z/2.0);
389  G4Box* PAD_Silicon = new G4Box("HPAD_Silicon", PAD_X/2.0, PAD_Y/2.0, PAD_Z/2.0);
390  G4Box* PAD_Glue2 = new G4Box("HPAD_Glue2", Width_X/2.0, Width_Y/2.0, PAD_Glue2_Z/2.0);
391  G4Box* PAD_FPC = new G4Box("HPAD_FPC", Width_X/2.0, Width_Y/2.0, PAD_FPC_Z/2.0);
392  G4Box *PAD_Plane = new G4Box("HPAD_Plane", Width_X/2.0, Width_Y/2.0, PAD_Z/2.0);
393  G4Box *PAD_Envelope = new G4Box("HPAD_Envelope", PAD_X/2.0, Width_Y/2.0, PAD_Z/2.0);
394  G4Box *HC_Si_Box = new G4Box("HC_Si_Box", Width_X/2., Width_Y/2., TotalLayerThickness/2.);
395 
396  G4LogicalVolume* lV_HCal_Absorber= new G4LogicalVolume( HCal_Absorber, fmat_Pb, "lV_HCal_SiAbsorber");
397  G4LogicalVolume* lV_HCal_Layer = new G4LogicalVolume( HCal_Layer, fmat_World, "lV_HCal_SiLayer");
398  G4LogicalVolume* lV_PAD_Glue1 = new G4LogicalVolume( PAD_Glue1, fmat_PET, "lV_HCal_PAD_Glue1" );
399  G4LogicalVolume* lV_PAD_Silicon = new G4LogicalVolume( PAD_Silicon, fmat_Si, "lV_HCal_PAD_Silicon" );
400  G4LogicalVolume* lV_PAD_Glue2 = new G4LogicalVolume( PAD_Glue2, fmat_PET, "lV_HCal_PAD_Glue2");
401  G4LogicalVolume* lV_PAD_FPC = new G4LogicalVolume( PAD_FPC, fmat_PET, "lV_HCal_PAD_FPC");
402  G4LogicalVolume* lV_PADPlane = new G4LogicalVolume( PAD_Plane, fmat_World, "lV_HPADPlane");
403  G4LogicalVolume* lV_PADEnvelope = new G4LogicalVolume( PAD_Envelope, fmat_World, "lV_HPADEnvelope");
404  G4LogicalVolume* lV_HC_Si_Box = new G4LogicalVolume( HC_Si_Box, fmat_World, "lV_HC_Si_Box");
405 
406  lV_HCal_Absorber->SetVisAttributes(fvisPb);
407  lV_PAD_Silicon->SetVisAttributes(fvisPAD);
408  lV_PAD_Glue1->SetVisAttributes(fvisDM);
409  lV_PAD_Glue2->SetVisAttributes(fvisDM);
410  lV_PAD_FPC->SetVisAttributes(fvisDM);
411 
412  lV_PADPlane->SetVisAttributes(G4VisAttributes::Invisible);
413  lV_PADEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
414  lV_HCal_Layer->SetVisAttributes(G4VisAttributes::Invisible);
415  lV_HC_Si_Box->SetVisAttributes(G4VisAttributes::Invisible);
416 
417  int infoval = ZDCID::HCPadLayer + fLayer*100 + ZDCID::SI_PAD;
418  std::pair<G4LogicalVolume*, int> pair_PAD= std::make_pair(lV_PAD_Silicon, infoval);
419  m_ActiveLogicalVolumeInfoMap.insert(pair_PAD);
420  infoval = ZDCID::HCPadLayer + fLayer*100 +ZDCID::Abs_Pb;
421  std::pair<G4LogicalVolume*, int> pair_Pb = std::make_pair(lV_HCal_Absorber,infoval);
422  infoval = ZDCID::HCPadLayer + fLayer*100 +ZDCID::Materials;
423  std::pair<G4LogicalVolume*, int> pair_Glue1 = std::make_pair(lV_PAD_Glue1,infoval);
424  std::pair<G4LogicalVolume*, int> pair_Glue2 = std::make_pair(lV_PAD_Glue2,infoval);
425  std::pair<G4LogicalVolume*, int> pair_FPC = std::make_pair(lV_PAD_FPC,infoval);
426  m_AbsorberLogicalVolumeInfoMap.insert(pair_Pb);
427  m_AbsorberLogicalVolumeInfoMap.insert(pair_Glue1);
428  m_AbsorberLogicalVolumeInfoMap.insert(pair_Glue2);
429  m_AbsorberLogicalVolumeInfoMap.insert(pair_FPC);
430 
431  m_ActiveLogicalVolumesSet.insert(lV_PAD_Silicon);
432  m_AbsorberLogicalVolumesSet.insert(lV_HCal_Absorber);
433  m_AbsorberLogicalVolumesSet.insert(lV_PAD_Glue1);
434  m_AbsorberLogicalVolumesSet.insert(lV_PAD_Glue2);
435  m_AbsorberLogicalVolumesSet.insert(lV_PAD_FPC);
436 
437  //Construct a PADplane using Replica
438  new G4PVReplica("PV_PADEnvelope", lV_PADEnvelope, lV_PADPlane, kXAxis, NpadX, PAD_X,0);
439  new G4PVReplica("PV_PAD", lV_PAD_Silicon, lV_PADEnvelope, kYAxis, NpadY, PAD_Y,0);
440 
441  //Construct a Layer
442  G4double posZ_HC_Absorber = -0.5 * HCal_Si_Layer_Thickness + HCAL_Z_Absorber/2;
443  G4double posZ_HC_Glue1 = -0.5 * HCal_Si_Layer_Thickness + HCAL_Z_Absorber+ PAD_Glue1_Z/2 ;
444  G4double posZ_HC_Silicon = -0.5 * HCal_Si_Layer_Thickness + HCAL_Z_Absorber + PAD_Glue1_Z + PAD_Z/2 ;
445  G4double posZ_HC_Glue2 = -0.5 * HCal_Si_Layer_Thickness + HCAL_Z_Absorber + PAD_Glue1_Z + PAD_Z + PAD_Glue2_Z/2 ;
446  G4double posZ_HC_FPC = -0.5 * HCal_Si_Layer_Thickness + HCAL_Z_Absorber + PAD_Glue1_Z + PAD_Z + PAD_Glue2_Z +PAD_FPC_Z/2 ;
447 
448  G4ThreeVector threeVect_HC_Absorber = G4ThreeVector(0, 0, posZ_HC_Absorber);
449  G4ThreeVector threeVect_HC_Glue1 = G4ThreeVector(0, 0, posZ_HC_Glue1);
450  G4ThreeVector threeVect_HC_Silicon = G4ThreeVector(0, 0, posZ_HC_Silicon);
451  G4ThreeVector threeVect_HC_Glue2 = G4ThreeVector(0, 0, posZ_HC_Glue2);
452  G4ThreeVector threeVect_HC_FPC = G4ThreeVector(0, 0, posZ_HC_FPC);
453 
454  new G4PVPlacement(0, threeVect_HC_Absorber, lV_HCal_Absorber, "PV_PAD_W", lV_HCal_Layer,false,0);
455  new G4PVPlacement(0, threeVect_HC_Glue1, lV_PAD_Glue1,"PV_PAD_Glue1", lV_HCal_Layer,false,0);
456  new G4PVPlacement(0, threeVect_HC_Silicon, lV_PADPlane, "PV_PAD_Plane", lV_HCal_Layer,false,0);
457  new G4PVPlacement(0, threeVect_HC_Glue2, lV_PAD_Glue2,"PV_PAD_Glue2", lV_HCal_Layer,false,0);
458  new G4PVPlacement(0, threeVect_HC_FPC, lV_PAD_FPC, "PV_PAD_FPC", lV_HCal_Layer,false,0);
459 
460  //construct a Box of layers
461  new G4PVReplica("HC_Layers", lV_HCal_Layer, lV_HC_Si_Box,kZAxis, HCALSiNumberOfLayers, HCal_Si_Layer_Thickness,0);
462 
463  G4ThreeVector threeVect_HC_Si_Box = G4ThreeVector(Center_X, Center_Y, Start_Z + TotalLayerThickness *0.5);
464  new G4PVPlacement(0, threeVect_HC_Si_Box, "PV_HC_Si_Box", lV_HC_Si_Box, motherPhy, false, 0);
465 
467 
468  _z_HCSilicon[1] = Start_Z + TotalLayerThickness;
469  return _z_HCSilicon[1];
470 
471 }
472 
473 double EICG4ZDCStructure::ConstructHCSciLayers(double Start_X, double Start_Y, double Start_Z,
474  double End_X, double End_Y, double End_Z,
475  G4VPhysicalVolume *motherPhy) {
476 
477  _z_HCSci[0] = Start_Z;
478 
479  double Center_X = (Start_X + End_X)/2.;
480  double Center_Y = (Start_Y + End_Y)/2.;
481  double Width_X = End_X - Start_X;
482  double Width_Y = End_Y - Start_Y;
483  double TotalTowerThickness = HCal_Layer_Thickness * NLayersHCALTower;
484 
485  //HCal tower
486  G4Box* HCal_Absorber = new G4Box("HCal_Absorber", Width_X/2.0, Width_Y/2.0, HCAL_Z_Absorber/2.0);
487  G4Box* HCal_Scintillator= new G4Box("HCal_Scintillator",HCAL_X_Tower/2.0, HCAL_Y_Tower/2.0, HCAL_Z_Scintillator/2.0);
488  G4Box* HCal_Gap = new G4Box("HCal_Gap", Width_X/2.0, Width_Y/2.0, HCAL_Z_Gap/2.0);
489  G4Box* HCal_Layer = new G4Box("HCal_Layer", Width_X/2.0, Width_Y/2.0, HCal_Layer_Thickness/2.0);
490  G4Box* HCal_SciPlane = new G4Box("HCal_SciPlane", Width_X/2.0, Width_Y/2.0, HCAL_Z_Scintillator/2.0);
491  G4Box* HCal_SciEnvelope = new G4Box("HCal_SciEnvelope", HCAL_X_Tower/2.0, Width_Y/2.0, HCAL_Z_Scintillator/2.0);
492  G4Box* HCal_Box = new G4Box("HCal_Box", Width_X/2.0, Width_Y/2.0, TotalTowerThickness/2.);
493 
494  //HCal volumes
495  G4LogicalVolume* lV_HCal_Absorber = new G4LogicalVolume( HCal_Absorber, fmat_Pb, "lV_HCal_Absorber");
496  G4LogicalVolume* lV_HCal_Scintillator = new G4LogicalVolume( HCal_Scintillator, fmat_Sci,"lV_HCal_Scintillator");
497  G4LogicalVolume* lV_HCal_Gap = new G4LogicalVolume( HCal_Gap, fmat_World, "lV_HCal_Gap");
498  G4LogicalVolume* lV_HCal_Layer = new G4LogicalVolume(HCal_Layer, fmat_World, "lV_HCal_Layer");
499  G4LogicalVolume* lV_HCal_SciPlane = new G4LogicalVolume(HCal_SciPlane, fmat_World, "lV_HCal_SciPlane");
500  G4LogicalVolume* lV_HCal_SciEnvelope = new G4LogicalVolume(HCal_SciEnvelope, fmat_World, "lV_HCal_SciEnvelope");
501  G4LogicalVolume* lV_HCal_Box = new G4LogicalVolume(HCal_Box, fmat_World, "lV_HCal_Box");
502 
503  lV_HCal_Absorber->SetVisAttributes(fvisPb);
504  lV_HCal_Scintillator->SetVisAttributes(fvisSci);
505 
506  lV_HCal_Gap->SetVisAttributes(G4VisAttributes::Invisible);
507  lV_HCal_Layer->SetVisAttributes(G4VisAttributes::Invisible);
508  lV_HCal_SciPlane->SetVisAttributes(G4VisAttributes::Invisible);
509  lV_HCal_SciEnvelope->SetVisAttributes(G4VisAttributes::Invisible);
510  lV_HCal_Box->SetVisAttributes(G4VisAttributes::Invisible);
511 
512  int infoval = ZDCID::HCSciLayer +NLayersHCALTower*10000 + fLayer*100 + ZDCID::Scintillator;
513  std::pair<G4LogicalVolume*, int> pair_Scint= std::make_pair(lV_HCal_Scintillator, infoval);
514  m_ActiveLogicalVolumeInfoMap.insert(pair_Scint);
515  infoval = ZDCID::HCSciLayer + NLayersHCALTower*10000 + fLayer*100 + ZDCID::Abs_Pb;
516  std::pair<G4LogicalVolume*, int> pair_Abs = std::make_pair(lV_HCal_Absorber, infoval);
517  m_AbsorberLogicalVolumeInfoMap.insert(pair_Abs);
518 
519  m_ActiveLogicalVolumesSet.insert(lV_HCal_Scintillator);
520  m_AbsorberLogicalVolumesSet.insert(lV_HCal_Absorber);
521 
522  new G4PVReplica("PV_HCSciEnvelope",lV_HCal_SciEnvelope, lV_HCal_SciPlane, kXAxis, HCALNumberOfTowersX, HCAL_X_Tower, 0);
523  new G4PVReplica("PV_HCScintillator",lV_HCal_Scintillator, lV_HCal_SciEnvelope, kYAxis, HCALNumberOfTowersY, HCAL_Y_Tower,0);
524 
525  G4double posZ_HCal_Absorber = -0.5 * HCal_Layer_Thickness + HCAL_Z_Absorber/2 ;
526  G4double posZ_HCal_Scintillator = -0.5 * HCal_Layer_Thickness + HCAL_Z_Absorber + HCAL_Z_Scintillator/2 ;
527  G4double posZ_HCal_Gap = -0.5 * HCal_Layer_Thickness + HCAL_Z_Absorber + HCAL_Z_Scintillator + HCAL_Z_Gap/2 ;
528 
529  G4ThreeVector threeVect_LogV_HCal_Absorber = G4ThreeVector(0, 0, posZ_HCal_Absorber);
530  G4ThreeVector threeVect_LogV_HCal_Scintillator = G4ThreeVector(0, 0, posZ_HCal_Scintillator);
531  G4ThreeVector threeVect_LogV_HCal_Gap = G4ThreeVector(0, 0, posZ_HCal_Gap);
532  new G4PVPlacement(0, threeVect_LogV_HCal_Scintillator, lV_HCal_SciPlane,"PV_HCal_Sci", lV_HCal_Layer,false,0);
533  new G4PVPlacement(0, threeVect_LogV_HCal_Absorber, lV_HCal_Absorber,"PV_HCal_Abs", lV_HCal_Layer,false,0);
534  new G4PVPlacement(0, threeVect_LogV_HCal_Gap, lV_HCal_Gap, "PV_HCal_Gap", lV_HCal_Layer,false,0);
535 
536  new G4PVReplica("PV_HCal_Layers",lV_HCal_Layer, lV_HCal_Box, kZAxis, NLayersHCALTower, HCal_Layer_Thickness,0);
537 
538  double TotalThicknessCreated = 0;
539  for(int ibox =0; ibox<HCALNumberOfTowersZ; ibox++){
540  G4double posZ_HCal_Box = Start_Z + TotalThicknessCreated + TotalTowerThickness * 0.5;
541  G4ThreeVector threeVect_LogV_HCal_Box = G4ThreeVector(Center_X, Center_Y, posZ_HCal_Box);
542  std::string ss_HCAL_Box = "PV_HCal_Box" + std::to_string(ibox);
543  new G4PVPlacement(0, threeVect_LogV_HCal_Box, ss_HCAL_Box, lV_HCal_Box,motherPhy,false,ibox);
544 
545  TotalThicknessCreated += TotalTowerThickness;
546  TotalThicknessCreated += HCAL_Tower_Gap;
547  }
548 
550 
551  _z_HCSci[1] = Start_Z+TotalThicknessCreated;
552  return _z_HCSci[1];
553 }
554 
556 
557  //*****************************************************************************************
558  //Unique materials
559  //*****************************************************************************************
560  G4NistManager* material_Man = G4NistManager::Instance(); //NistManager: start element destruction
561 
562  fmat_World = material_Man->FindOrBuildMaterial("G4_AIR");
563 
564  fmat_Crystal = material_Man->FindOrBuildMaterial("G4_PbWO4");
565 
566  //The definition of the W alloy
567  fmat_W = new G4Material("tungsten",18.73 *g/cm3,3);
568  //G4Material* material_tungsten = new G4Material("tungsten",19.3 *g/cm3,1);
569  G4Element* W = material_Man->FindOrBuildElement(74);//density: 19.3 I:727
570  G4Element* Ni = material_Man->FindOrBuildElement(28);//density: 8.902 I:311
571  G4Element* Cu = material_Man->FindOrBuildElement(29);//G4_Cu 8.96 I:322
572  fmat_W->AddElement(W,94.3 *perCent); //the percentage of materialal originally 100 --> 100./106
573  fmat_W->AddElement(Ni,3.77 *perCent); // 4. --> 4./106
574  fmat_W->AddElement(Cu,1.89 *perCent); //2. -->2./106.
575 
576  //Definition of the Epoxy Glue
577  fmat_PET = new G4Material("PET",1.38*g/cm3,3);
578  G4Element* O = material_Man->FindOrBuildElement(8);
579  G4Element* elH = new G4Element("Hydrogen","H", 1, 1.00794 *g/mole);
580  G4Element* elC = new G4Element("Carbon","C", 6, 12.011 *g/mole);
581  fmat_PET->AddElement(elC,10);
582  fmat_PET->AddElement(elH,8);
583  fmat_PET->AddElement(O,4);
584 
585  //Definition of the scintillator
586  G4double density= 1.032 *g/cm3; //to define the dencity on my own
587  fmat_Sci = new G4Material("Scintillator",density,2); //
588  fmat_Sci->AddElement(elC,8);
589  fmat_Sci->AddElement(elH,8);
590 
591  //Other materials
592  fmat_Si = material_Man->FindOrBuildMaterial("G4_Si");
593  fmat_Pb = material_Man->FindOrBuildMaterial("G4_Pb");
594  fmat_Cu = material_Man->FindOrBuildMaterial("G4_Cu");
595  fmat_Fe = material_Man->FindOrBuildMaterial("G4_Fe");
596  return;
597 }
598 
600 
601  std::cout<<"This is EICG4ZDCStructure"<<std::endl;
602 
603 }
604 
606 
607  fvisCrystal = new G4VisAttributes(G4Color(G4Colour::Yellow()));
608  fvisPIX = new G4VisAttributes(G4Color(G4Colour::Magenta()));
609  fvisPAD = new G4VisAttributes(G4Color(G4Colour::Cyan()));
610  fvisDM = new G4VisAttributes(G4Color(G4Colour::Grey()));
611  fvisW = new G4VisAttributes(G4Color(0.5,0.5,0.8,0.6));
612  fvisPb = new G4VisAttributes(G4Color(.3,.3,.3,0.6));
613  fvisSci = new G4VisAttributes(G4Color(G4Colour::Green()));
614 
615  fvisCrystal->SetForceSolid(true);
616  fvisPIX->SetForceSolid(true);
617  fvisPAD->SetForceSolid(true);
618  fvisDM->SetForceSolid(true);
619  fvisW->SetForceSolid(true);
620  fvisPb->SetForceSolid(true);
621  fvisSci->SetForceSolid(true);
622 
623  return;
624 
625 }
626 
627 void EICG4ZDCStructure::PrintTowerMap(const std::string &d){
628 
629  std::ofstream map_file;
630  std::string filename = "ZDC_"+d+"_mapping.txt";
631  map_file.open(filename,std::ios::out);
632 
633  map_file<<"# ZDC_"<<d<<std::endl;
634  map_file<<"Gx0 "<<"\t"<<"-962.4"<<std::endl;
635  map_file<<"Gy0 "<<"\t"<<"0."<<std::endl;
636  map_file<<"Gz0 "<<"\t"<<"37000."<<std::endl;
637  map_file<<"Grot_x "<<"\t"<<"0."<<std::endl;
638  map_file<<"Grot_y "<<"\t"<<"-0.025"<<std::endl;
639  map_file<<"Grot_z "<<"\t"<<"0."<<std::endl;
640 
641  double offsetZ=0;
642  if(d=="Crystal"){
643 
644  offsetZ=0;
645 
646  map_file<<"#Tower ID <-> Layer ID"<<std::endl;
647  for(int iL=0; iL<nCTowerZ; iL++)
648  map_file<<"iT_iL "<<iL<<"\t"<<2*iL+1<<std::endl;
649 
650  map_file<<"#Tower "<<"\t"<<"iLayer "<<"\t"<<"iX "<<"\t"<<"iY "<<"\t"
651  <<"x_cnt " <<"\t"<<"y_cnt " <<"\t"<<"z_cnt "<<"\t"
652  <<"size_x "<<"\t"<<"size_y "<<"\t"<<"size_z"<<std::endl;
653 
654  for(int iL=0; iL < nCTowerZ; iL++){
655  offsetZ += (PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap);
656  double z_cnt = offsetZ + CTower_Z/2;
657 
658  for(int ix = 0; ix < nCTowerX; ix++){
659  double x_cnt = (ix - nCTowerX/2) * CTower_X + CTower_X/2.;
660 
661  for(int iy = 0; iy < nCTowerY; iy++){
662  double y_cnt = (iy - nCTowerY/2) * CTower_Y + CTower_Y/2.;
663 
664  map_file<<"Tower "<<iL<<"\t"<<ix<<"\t"<<iy<<"\t"
665  <<x_cnt<<"\t"<<y_cnt<<"\t"<<z_cnt<<"\t"
666  <<CTower_X<<"\t"<<CTower_Y<<"\t"<<CTower_Z<<std::endl;
667 
668  }
669  }
670 
671  offsetZ += CTower_Z;
672  offsetZ += CTower_GAP;
673  }
674  }else if (d=="SiPixel"){
675 
676  offsetZ = 0;
677  int nPixLayer = 1 + nCTowerZ + NumberPIX;
678 
679  map_file<<"#Tower ID <-> Layer ID"<<std::endl;
680  for(int iL=0; iL<nPixLayer; iL++){
681  if(iL<=nCTowerZ)
682  map_file<<"iT_iL "<<iL<<"\t"<<2*iL<<std::endl;
683  else
684  map_file<<"iT_iL "<<iL<<"\t"
685  <<nCTowerZ*2 + (iL-nCTowerZ) * (NPadOnlyLayers + 1)<<std::endl;
686  }
687 
688  map_file<<"#Tower "<<"\t"<<"iLayer "<<"\t"<<"iX "<<"\t"<<"iY "<<"\t"
689  <<"x_cnt " <<"\t"<<"y_cnt " <<"\t"<<"z_cnt "<<"\t"
690  <<"size_x "<<"\t"<<"size_y "<<"\t"<<"size_z"<<std::endl;
691 
692  for(int iL=0; iL < nPixLayer; iL++){
693 
694  if(iL > nCTowerZ ) offsetZ += (PIX_Absorber_Z + PIX_Glue1_Z);
695 
696  double z_cnt = offsetZ + PIX_Z/2;
697 
698  offsetZ += (PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap);
699  if(iL<nCTowerZ)
700  offsetZ += (CTower_Z + CTower_GAP);
701  else
702  offsetZ += (PAD_Layer_Thickness * NPadOnlyLayers);
703 
704  for(int ix = 0; ix < NpixX; ix++){
705  double x_cnt = (ix - NpixX/2) * PIX_X + PIX_X/2.;
706 
707  for(int iy = 0; iy < NpixY; iy++){
708  double y_cnt = (iy - NpixY/2) * PIX_Y + PIX_Y/2.;
709 
710  map_file<<"Tower "<<iL<<"\t"<<ix<<"\t"<<iy<<"\t"
711  <<x_cnt<<"\t"<<y_cnt<<"\t"<<z_cnt<<"\t"
712  <<PIX_X<<"\t"<<PIX_Y<<"\t"<<PIX_Z<<std::endl;
713 
714  }
715  }
716  }
717 
718  }else if(d=="SiPad"){
719 
720  offsetZ = _z_EMLayers[0] - _z_Crystal[0];
721  int iTower=0;
722 
723  map_file<<"#Tower ID <-> Layer ID"<<std::endl;
724  for(int iB=0; iB<NumberPAD/NPadOnlyLayers; iB++){
725  for(int iL=0; iL<NPadOnlyLayers; iL++){
726  map_file<<"iT_iL "<<iTower<<"\t"
727  <<2*nCTowerZ + iB*(NPadOnlyLayers+1)+iL+1<<std::endl;
728  iTower++;
729  }
730  }
731  for(int iL=0; iL<HCALSiNumberOfLayers; iL++){
732  map_file<<"iT_iL "<<iTower<<"\t"
733  <<2*nCTowerZ+1+NumberOfLayers+iL<<std::endl;
734  iTower++;
735  }
736 
737 
738  map_file<<"#Tower "<<"\t"<<"iLayer "<<"\t"<<"iX "<<"\t"<<"iY "<<"\t"
739  <<"x_cnt " <<"\t"<<"y_cnt " <<"\t"<<"z_cnt "<<"\t"
740  <<"size_x "<<"\t"<<"size_y "<<"\t"<<"size_z"<<std::endl;
741 
742  offsetZ += (PIX_Z + PIX_Glue2_Z + PIX_FPC_Z + PIX_AirGap);
743 
744  iTower =0;
745  for(int iB=0; iB<NumberPAD/NPadOnlyLayers; iB++){
746  for(int iL=0; iL<NPadOnlyLayers; iL++){
747 
748  offsetZ += (PAD_Absorber_Z + PAD_Glue1_Z);
749  double z_cnt = offsetZ + PAD_Z/2;
750  offsetZ += (PAD_Z + PAD_Glue2_Z + PAD_FPC_Z + PAD_AirGap);
751 
752  for(int ix = 0; ix < NpadX; ix++){
753  double x_cnt = (ix - NpadX/2) * PAD_X + PAD_X/2.;
754 
755  for(int iy = 0; iy < NpadY; iy++){
756  double y_cnt = (iy - NpadY/2) * PAD_Y + PAD_Y/2.;
757 
758  map_file<<"Tower "<<iTower<<"\t"<<ix<<"\t"<<iy<<"\t"
759  <<x_cnt<<"\t"<<y_cnt<<"\t"<<z_cnt<<"\t"
760  <<PAD_X<<"\t"<<PAD_Y<<"\t"<<PAD_Z<<std::endl;
761 
762  }
763  }
764  iTower++;
765 
766  }
767 
768  offsetZ +=PIX_Layer_Thickness;
769  }
770 
771  offsetZ = _z_HCSilicon[0] - _z_Crystal[0];
772 
773  for(int iL=0; iL<HCALSiNumberOfLayers; iL++){
774  offsetZ += (HCAL_Z_Absorber + PAD_Glue1_Z);
775  double z_cnt = offsetZ + PAD_Z/2;
776  offsetZ += (PAD_Z + PAD_Glue2_Z + PAD_FPC_Z + PAD_AirGap);
777 
778  for(int ix = 0; ix < NpadX; ix++){
779  double x_cnt = (ix - NpadX/2) * PAD_X + PAD_X/2.;
780 
781  for(int iy = 0; iy < NpadY; iy++){
782  double y_cnt = (iy - NpadY/2) * PAD_Y + PAD_Y/2.;
783 
784  map_file<<"Tower "<<iTower<<"\t"<<ix<<"\t"<<iy<<"\t"
785  <<x_cnt<<"\t"<<y_cnt<<"\t"<<z_cnt<<"\t"
786  <<PAD_X<<"\t"<<PAD_Y<<"\t"<<PAD_Z<<std::endl;
787 
788  }
789  }
790  iTower++;
791 
792  }
793 
794  }else if(d=="Sci"){
795 
796  offsetZ = _z_HCSci[0] - _z_Crystal[0];
797 
798  map_file<<"#Tower ID <-> Layer ID"<<std::endl;
799  for(int iB=0; iB<HCALNumberOfTowersZ; iB++){
800  map_file<<"iT_iL "<<iB<<"\t"
802  + iB * NLayersHCALTower<<std::endl;
803  }
804 
805  map_file<<"#Tower "<<"\t"<<"iLayer "<<"\t"<<"iX "<<"\t"<<"iY "<<"\t"
806  <<"x_cnt " <<"\t"<<"y_cnt " <<"\t"<<"z_cnt "<<"\t"
807  <<"size_x "<<"\t"<<"size_y "<<"\t"<<"size_z"<<std::endl;
808 
809  double HCTower_Z = NLayersHCALTower * HCal_Layer_Thickness;
810  std::cout<<"HC mapping: "<<offsetZ<<" "<<HCTower_Z<<std::endl;
811 
812  for(int iB= 0; iB< HCALNumberOfTowersZ; iB++){
813 
814  double z_cnt = offsetZ + HCTower_Z/2.;
815  offsetZ += HCTower_Z;
816 
817  for(int ix = 0; ix < HCALNumberOfTowersX; ix++){
818  double x_cnt = (ix - HCALNumberOfTowersX/2) * HCAL_X_Tower + HCAL_X_Tower/2.;
819 
820  for(int iy = 0; iy < HCALNumberOfTowersY; iy++){
821  double y_cnt = (iy - HCALNumberOfTowersY/2) * HCAL_Y_Tower + HCAL_Y_Tower/2.;
822 
823  map_file<<"Tower "<<iB<<"\t"<<ix<<"\t"<<iy<<"\t"
824  <<x_cnt<<"\t"<<y_cnt<<"\t"<<z_cnt<<"\t"
825  <<HCAL_X_Tower<<"\t"<<HCAL_Y_Tower<<"\t"<<HCTower_Z<<std::endl;
826 
827  }
828  }
829 
830  offsetZ += HCAL_Tower_Gap;
831  }
832  }
833 
834  map_file.close();
835 
836 }