ModTypeRPD.cc 33.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
26
27
28
29
30
/// \file ModTypeRPD.hh
/// \brief Implementation of the ModTypeRPD class
/// \author Aric Tate
/// \date February 2019

31
32

#include "ModTypeRPD.hh"
33
#include "FiberSD.hh"
34

35

36
37
38
39
40
41
42
43
#include "G4GeometryManager.hh"
#include "G4SolidStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalBorderSurface.hh"
#include "G4LogicalSkinSurface.hh"
#include "G4OpticalSurface.hh"
#include "G4MaterialTable.hh"
44
45
#include "G4UserLimits.hh"

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

#include "G4RunManager.hh"
#include "G4SDManager.hh"

#include "G4NistManager.hh"
#include "G4CSGSolid.hh"
#include "G4Box.hh"
#include "G4Para.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Orb.hh"
#include "G4Sphere.hh"
#include "G4Trd.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"

#include <iostream>
#include <stdio.h>

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

70
ModTypeRPD::ModTypeRPD(const int cn, G4LogicalVolume* mother, G4ThreeVector* pos )
71
72
  : m_modNum( cn ),  m_pos( pos ), m_fiberDiam(new G4ThreeVector(.6,.68,.73)),
  m_logicMother( mother )
73
74
{
	materials = Materials::getInstance();
75
76
  materials->UseOpticalMaterials(true);
  materials->DefineOpticalProperties();
77
}
78
79
80

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

81
82
83
ModTypeRPD::ModTypeRPD(const int cn, ModTypeRPD* right)
  : m_modNum( cn )
{
84
85
	m_pos 						 = new G4ThreeVector(*right->m_pos);
	m_fiberDiam 			 = new G4ThreeVector(*right->m_fiberDiam);
86
87
88
	m_HousingThickness = right->m_HousingThickness;
	m_fiberPitch 			 = right->m_fiberPitch;
	m_tileSize 				 = right->m_tileSize;
89
90
91
92
93
	m_minWallThickness = right->m_minWallThickness;
  m_detType 				 = right->m_detType;
  OPTICAL 					 = right->OPTICAL;
  CHECK_OVERLAPS 		 = right->CHECK_OVERLAPS;
	materials					 = right->materials;
94
95
96
97
98
	m_logicMother 		 = right->m_logicMother;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

99
ModTypeRPD::ModTypeRPD()
100
101
102
103
104
  : m_modNum( 0 ), m_pos(new G4ThreeVector(0.,0.,0.)), m_fiberDiam(new G4ThreeVector(.6,.68,.73)),
   m_logicMother(NULL)
{
  materials = Materials::getInstance();
}
105
106
107
108
109
110
111
112
113
114

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

ModTypeRPD::~ModTypeRPD()
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void ModTypeRPD::Construct(){
  DefineMaterials();
115
116
117
118

	if(m_detType == "cms"){
		ConstructCMSDetector();
	}else {
119
		ConstructPanFluteDetector();
120
	}
121
122
123
124
125
126
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void ModTypeRPD::DefineMaterials()
{
127
  //----------------------------------------------
128
129
130
  // Define Materials
  //----------------------------------------------

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
	//Quartz
	m_matQuartz = materials->pQuartz;

	//Aluminum
	m_Al = materials->Al;

	//Air
	m_Air = materials->Air;

	//Polyethylene/Clad
	m_Poly = materials->Polyethylene;

	//Optical Grease
	m_Grease = materials->Grease;

	//Wavelength Shifter/Fiber
	m_PMMA = materials->PMMA;


150
151
152
153
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

154
void ModTypeRPD::ConstructPanFluteDetector()
155
156
157
158
159
160
{
	//retrieve RPD parameters
	float fiber_diam 	= m_fiberDiam->x(); // Just core for now

	char name[256];

161
  G4Colour colors[4] = { G4Colour::Cyan(),  G4Colour::Red(), G4Colour::Green(), G4Colour::Magenta() };
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

	int n_rows = 4;
	int n_columns = 4;
	int n_cycles_per_tile = (m_tileSize/fiber_diam)/n_rows;   //Divide to round down to a whole number
	int n_fibers_per_tile = n_cycles_per_tile*2*n_rows;  //The pattern will be repeated twice per tile

	//If you asked for a
	if(.707*m_minWallThickness < fiber_diam){
		m_minWallThickness = 1.414*fiber_diam;
		std::cout << "Minimum wall thickness entered is too small!!!" << std::endl;
		std::cout << "Using " << m_minWallThickness << "mm instead" << std::endl;
	}
	// If the remaining space in x leaves less than 1mm for each wall, remove a cycle and calculate
	// the new wall thickness
	calculate_wall_thickness:
	float wall_thickness = ((m_tileSize - n_fibers_per_tile*fiber_diam)/n_fibers_per_tile)*mm;
	if( wall_thickness < m_minWallThickness*mm ){
		--n_cycles_per_tile;
		n_fibers_per_tile = n_cycles_per_tile*n_rows;
		goto calculate_wall_thickness;
	}

	// Distance on center of fibers
	float pitch = wall_thickness + fiber_diam;
	// Distance in X and Z from one fiber to another diagonally from it
	float offset = pitch/2;
	// Will be filled with fiber height for each row
	float fiber_height;
	// Distance from the top of the RPD area of interest to the readout
	float distance_to_readout = 0*mm;
	// Positions of the current fiber for pattern1 and pattern2
	float posx1, posz1, posy, posx2, posz2;
	// Count the number of fibers as we go along
	m_PFrpd_cnt = 0;
196
197
198
199
200
201
  // Width (x) of the RPD housing
  float housingWidth = n_columns*m_tileSize + 2*m_HousingThickness;
  // Height (y) of the RPD housing
  float housingHeight = n_rows*m_tileSize + m_HousingThickness;
  // Depth (z) of the RPD housing
  float housingDepth = (n_rows + 0.5)*m_fiberPitch + fiber_diam + 2*m_HousingThickness;
202
203
204
205
206

	//create some rotation matrices
	G4RotationMatrix* stripRotation = new G4RotationMatrix();
	stripRotation->rotateX(90.*deg);
	G4RotationMatrix* nullRotation = new G4RotationMatrix();
207
208
  G4ThreeVector     nullVector(0.,0.,0.);

209

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  // Construct the housing
  m_PFrpd_housing = new G4Box( "RPDHousing", housingWidth*mm/2.0, housingHeight*mm/2.0, housingDepth*mm/2.0 );

  m_PFrpd_housingLogical = new G4LogicalVolume(m_PFrpd_housing, m_Al, "Housing_Logical");

  sprintf(name,"RPD%d_Case_Physical", m_modNum);
  m_PFrpd_housingPhysical =
    new G4PVPlacement(nullRotation,
                      G4ThreeVector(m_pos->x(),m_pos->y() - m_HousingThickness/2.0, m_pos->z() ),
                      m_PFrpd_housingLogical,
                      name,
                      m_logicMother,
                      false,
                      m_modNum,
                      CHECK_OVERLAPS);

  m_PFrpd_housingLogical->SetVisAttributes(G4Colour(1.0,1.0,1.0,0.7));//G4Colour(1.0,0.0,0.0,0.3)



  // Loop over rows
231
	for(int row = 0; row < n_rows; row++){
232
    // Calculate the height of fibers in this row
233
234
		fiber_height = m_tileSize*(row+1) + distance_to_readout;

235
		// The fiber solid and logical volume. One length for each row
236
237
238
239
240
241
242
243
		sprintf(name,"m_PFrpd_%d", row);
		m_PFrpd[row] = new G4Tubs(name,
														0.0*mm,
														(fiber_diam/2.0)*mm,
														fiber_height*mm/2.0 ,
														0.0*deg,
														360.0*deg);

244
245
246
247
248
249
250
251
252
    sprintf(name,"m_PFrpd_log_%d",row);
    m_PFrpdLogical[row] =
      new G4LogicalVolume(m_PFrpd[row],
                          m_matQuartz,
                          name);
    m_PFrpdLogical[row]->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,10*ms));

	  m_PFrpdLogical[row]->SetVisAttributes( colors[row] );

253
254

		// Create an air channel for the fiber to be routed
255
256
257
258
259
260
261
262
		sprintf(name,"m_PFchannel_%d", row);
		m_PFrpd_channel[row] =
      new G4Box( name,
                 (1.1*fiber_diam/2.0)*mm,
                 (1.1*fiber_diam/2.0)*mm,
                 fiber_height*mm/2.0);


263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
    //Subtract the fiber from the channel
    sprintf(name,"m_PFsubChannel_%d", row);
    m_subChannel[row] =
      new G4SubtractionSolid(name,
                             m_PFrpd_channel[row],
                             m_PFrpd[row]);

    sprintf(name,"m_PFchannel_log_%d",row);
    m_PFrpd_channelLogical[row] = new G4LogicalVolume(m_subChannel[row],m_Air,name);

    // Assemble the fiber and air channel
    m_PFrpd_FiberAssy[row] = new G4AssemblyVolume();
    m_PFrpd_FiberAssy[row]->AddPlacedVolume(m_PFrpd_channelLogical[row], nullVector, nullRotation );
    m_PFrpd_FiberAssy[row]->AddPlacedVolume(m_PFrpdLogical[row],         nullVector, nullRotation );


	  m_PFrpd_channelLogical[row]->SetVisAttributes( G4Colour(0.0,0.0,1.0,0.1) );// G4Colour(0.0,0.0,1.0,0.1) or G4VisAttributes::Invisible
280
281
282
283
284
285
286
287
288
289
290

		for(int col = 0; col < n_columns; col++){
			//Now we're in the realm of working on a single tile
			//we have to cycle through the two patterns until the tile
			//is filled in X
			for(int cycle = 0; cycle < n_cycles_per_tile; cycle++){

				for(int fiber = 0; fiber < n_columns; fiber++){
					// !!!!!!!Position calculations assume an even number of rows and columns!!!!!!! //////

					//Start at RPD center + tile width* number of tiles + cycle number * cycle width + stack number in cycle * pitch
291
					posx1 = m_tileSize*((n_columns/2) - col ) - (cycle*n_columns*pitch) - fiber*pitch - pitch/4;  //ARIC ADDED - pitch/4
292
293
294
					posx2 = posx1 - offset;

					//Start at Z center - half the stack depth + moving front to back and looping back to front
295
296
					posz1 = - pitch*(n_columns-0.5)/2 + pitch*((row + fiber	  )%4);
					posz2 = - pitch*(n_columns-0.5)/2 + pitch*((row + fiber + 2)%4) + offset; //Pattern is offset by 2
297
298

					//Start at RPDY center + distance to bottom of top tile + half the fiber height
299
300
					posy = ((n_rows/2 - 1) - row)*m_tileSize + fiber_height/2 + m_HousingThickness/2;

301
302
303
304
305
          G4ThreeVector pos1(posx1*mm, posy*mm, posz1*mm);
          G4ThreeVector pos2(posx2*mm, posy*mm, posz2*mm);


          //----------------------- Place the fiber assemblies -----------------------//
306

307
308
          m_PFrpd_FiberAssy[row]->MakeImprint(m_PFrpd_housingLogical, pos1, stripRotation );
          m_PFrpd_FiberAssy[row]->MakeImprint(m_PFrpd_housingLogical, pos2, stripRotation );
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

					m_PFrpd_cnt++;
					m_PFrpd_cnt++;

				}//end fiber
			}//end cycle
		}//end column
	}//end row


	//----------------------------------------------
	// SD and Scoring Volumes
	//----------------------------------------------


	G4SDManager* SDman = G4SDManager::GetSDMpointer();

	//Note one SD object for each module
	char fiberSDname[256];
328
	sprintf( fiberSDname, "RPD%d_SD", m_modNum);
329
330
331

	FiberSD* aFiberSD = new FiberSD( fiberSDname, m_modNum, OPTICAL );
	aFiberSD->HistInitialize();
Chad Lantz's avatar
Chad Lantz committed
332
	aFiberSD->SetTopOfVolume( m_pos->y() - m_HousingThickness/2.0 + housingHeight/2.0);
333
	SDman->AddNewDetector( aFiberSD );
334
  for(int i = 0; i < n_rows; i++){
335
336
	   m_PFrpdLogical[i]->SetSensitiveDetector( aFiberSD );
   }
337
338
339
340
341

	std::cout << "Prototype RPD construction finished: SD name " << fiberSDname << std::endl;

}

342
343
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

344
void ModTypeRPD::ConstructCMSDetector()
345
{
346
347
	bool test_tile = false;

348
	if(test_tile){
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
		for(int i =0;i<8;i++){
		rpd_comp[i]=false;
		}
	}
	else for(int i =0;i<8;i++){
		rpd_comp[i]=true;
		}

	// RPD components
	bool tile_flag = rpd_comp[0];				// quartz tiles
	bool fiber_flag = rpd_comp[1];			// readout fibers
	bool cladding_flag = rpd_comp[2];		// fiber cladding
	bool grease_flag = rpd_comp[3];			// optical grease
	bool foil_flag = rpd_comp[4];				// aluminum foil
	bool fr_bck_flag = rpd_comp[5]; 		// front and back aluminum casing
	bool vertical_flag = rpd_comp[6]; 	// veritcal aluminum dividers
	bool air_detec_flag = rpd_comp[7];	// photo detectors

367

368

369
	//retrieve RPD parameters
370
371
372
373
374
375
  float tileX 		= 20;
  float tileY 		= 20;
  float tileZ 		= 20;
  float halfX_gap 	= (1.58/2)*mm;
	float fiber_diam 	= 1*mm;
	float foil_thickness 	= 0.016*mm;
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392


	//manually create some RPD parameters
	float halfY_gap 	= (2.5*foil_thickness/2)*mm;
	float hole_center_offset = 0.05;
	float case_thickness = 0.9*2.0*halfX_gap;
	float core_diam;
	float grease_offset;
	if(grease_flag) grease_offset = 0.05;
	else grease_offset = 0.0;

	if(cladding_flag) core_diam = 0.970*(fiber_diam)*mm;
	else 							core_diam = (fiber_diam)*mm;

	float fiberHeightY[4];
	float foilHeightY[4];

393
  char name[256];
394
395
396
397
398
399
400

	//create some rotation matrices
	G4RotationMatrix* stripRotation = new G4RotationMatrix();
	stripRotation->rotateX(90.*deg);
	G4RotationMatrix* nullRotation = new G4RotationMatrix();

  // Option to switch on/off checking of volumes overlaps
401

402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421

	//create tile that has 4 holes to be used repeatedly later
  m_tile_no_fiber_hole = new G4Box("tile_no_hole",(tileX/2)*mm, (tileY/2)*mm, (tileZ/2)*mm);
	m_fiber_subtract = new G4Tubs( "fiber_sub",
						0.0*mm,
						((fiber_diam/2.0)+ grease_offset )*mm, //1mm diameter
						tileY*mm ,
						0.0*deg,
						360.0*deg);

	m_tile = new G4SubtractionSolid("tile",m_tile_no_fiber_hole,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 1*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset)*mm));
  m_tile = new G4SubtractionSolid("tile",m_tile,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 2*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));
	m_tile = new G4SubtractionSolid("tile",m_tile,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 3*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));
	m_tile = new G4SubtractionSolid("tile",m_tile,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 4*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));


  m_tileLogical	 = new G4LogicalVolume(m_tile, m_matQuartz, "tile_Logical");

  G4VisAttributes* quartzColor  = new G4VisAttributes(  G4Colour::Cyan());//
	//quartzColor->SetForceSolid(true);
422
423
	m_tileLogical->SetVisAttributes( quartzColor );

424
	int cn = 0, cn_fiber = 0;
425

426
427
428
	float RPD_centerX = m_pos->getX();
	float RPD_centerY = m_pos->getY();
	float RPD_centerZ = m_pos->getZ();
429

430
431
	float RPD_startX = RPD_centerX + 3*halfX_gap + 1.5*tileX;
	float RPD_startY = RPD_centerY + 3*halfY_gap + 1.5*tileY;
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491


//positioning variables
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

float factor1 = 1.5;
float hole_shift		= grease_offset + hole_center_offset;

float tileZcenter[4];
for(int i=0; i < 4; i++){
	tileZcenter[i] = RPD_centerZ + (i * (factor1*fiber_diam + foil_thickness) );
}
float fiberZcenter[4];
for(int i=0; i < 4; i++){
	fiberZcenter[i] = tileZcenter[i] + tileZ/2.0 - fiber_diam/2.0 - hole_shift;
}

float foil_gap = (fiberZcenter[1]-(fiber_diam/2.0)) - (fiberZcenter[0] + (fiber_diam/2.0));

float foilZcenter[4];
for(int i=0; i < 4; i++){
	foilZcenter[i] = fiberZcenter[i] + fiber_diam/2.0 + foil_gap/2.0;
}

float final_foil_pos = foilZcenter[3]+foil_thickness/2.0;
float assembly_midZ = RPD_centerZ + (final_foil_pos - (RPD_centerZ + (tileZ/2.0)))/2.0;
float half_Z_length = final_foil_pos-assembly_midZ;


int fiber_cnt=0;

//create fibers/cladding/grease with correct lengths
for(int k=0;k<4;k++) {
	fiberHeightY[k]=((k+1)*tileY)+(k*2*halfY_gap);

	sprintf(name,"fiber_a %d", k);
	m_fiber[k] 		= new G4Tubs( name,
						0.0*mm,
						(core_diam/2.0)*mm, //1mm diameter
						fiberHeightY[k]*mm/2.0 ,
						0.0*deg,
						360.0*deg);
if(grease_flag){
	sprintf(name,"fibergrease_a %d", k);
  m_fibergrease[k] 		= new G4Tubs( name,
						(fiber_diam/2.0)*mm,
						((fiber_diam+grease_offset)/2.0)*mm,
						fiberHeightY[k]*mm/2.0 ,
						0.0*deg,
						360.0*deg);
					}

if(cladding_flag){
	sprintf(name,"fiberclad_a %d", k);
	m_fiberclad[k] 		= new G4Tubs( name,
							(core_diam/2.0)*mm,
							((fiber_diam)/2.0)*mm,
							fiberHeightY[k]*mm/2.0 ,
							0.0*deg,
492
							360.0*deg);
493
494
495
496
497
498
499
500
501
						}

if(grease_flag){
	sprintf(name,"fibergreaseLogical_a %d", k);

	m_fibergreaseLogical[k] 	= new G4LogicalVolume(m_fibergrease[k]
						,m_Grease,//m_Poly
						name);
	m_fibergreaseLogical[k]->SetVisAttributes( G4Colour(1,1,1,0.3) );//G4VisAttributes::Invisible
502
	}
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594

if(cladding_flag){
	sprintf(name,"fibercladLogical_a %d", k);

	m_fibercladLogical[k] 	= new G4LogicalVolume(m_fiberclad[k]
						,m_Poly,//m_Poly
						name);
	m_fibercladLogical[k]->SetVisAttributes( G4Colour(1,0,0,0.2));//G4VisAttributes::Invisible
	}
}

for(int i=0;i<4;i++) {
	for(int j=0;j<4;j++) {
		for(int k=0;k<4;k++) {
				sprintf(name,"fiberLogical_%d_%d_%d",k,j,i);

						m_fiberLogical[fiber_cnt] 	= new G4LogicalVolume(m_fiber[k]
											,m_PMMA,
											name);
						m_fiberLogical[fiber_cnt]->SetVisAttributes( G4Colour(0.0,0.0,1.0,0.2) );

						m_fiberLogical[fiber_cnt]->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,10*ms));

							fiber_cnt++;
					}
				}
			}

// create alum containment

//create foil sections
for(int k=0;k<4;k++) {
foilHeightY[k]=(2*(k+1)-2) * halfY_gap + (k+1)*tileY;
sprintf(name,"foil_V %d", k);

m_foilV[k] 		= new G4Box(name,(tileX/2.0)*mm, (foilHeightY[k]/2.0)*mm, (0.75*foil_thickness/2.0)*mm);//

sprintf(name,"foilVlog %d", k);

m_foilVLogical[k] 	= new G4LogicalVolume(m_foilV[k]
					,m_Al,
					name);
m_foilVLogical[k]->SetVisAttributes(G4Colour(0.9,0.0,0.0,0.4));//G4VisAttributes::Invisible
}


m_foilVfront 		= new G4Box("m_foilVfront",(tileX/2.0)*mm, (tileY/2.0)*mm, (0.75*foil_thickness/2.0)*mm);//
m_foilVfrontLogical 	= new G4LogicalVolume(m_foilVfront
				,m_Al,
				"foilVfrntlog");
m_foilVfrontLogical->SetVisAttributes( G4Colour(0.9,0.0,0.0,0.4) );//


m_foilH 			= new G4Box("foil_H",(tileX/2.0)*mm, (0.75*foil_thickness/2.0)*mm, ((tileZ+(foil_gap)-hole_center_offset)/2.0) *mm) ;// foil/2.0
m_foilHLogical 	= new G4LogicalVolume(m_foilH
				,m_Al,
				"foil_H_log");
m_foilHLogical->SetVisAttributes( G4Colour(0.9,0.0,0.0,0.4));//


m_foilHtop 			= new G4Box("foil_H_top",(tileX/2.0)*mm, (0.75*foil_thickness/2.0)*mm, ((tileZ)/2.0) *mm) ;//+(foil_gap)-hole_center_offset
m_foilHtop_hole = new G4SubtractionSolid("foil_H_top_hole",m_foilHtop,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 1*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset)*mm));
m_foilHtop_hole = new G4SubtractionSolid("foil_H_top_hole",m_foilHtop_hole,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 2*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));
m_foilHtop_hole = new G4SubtractionSolid("foil_H_top_hole",m_foilHtop_hole,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 3*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));
m_foilHtop_hole = new G4SubtractionSolid("foil_H_top_hole",m_foilHtop_hole,m_fiber_subtract,stripRotation, G4ThreeVector(( tileX/2.0 - 4*(tileX/5)  )*mm,0,(tileZ/2.0 - fiber_diam/2.0 - grease_offset - hole_center_offset )*mm));

m_foilHtopLogical 	= new G4LogicalVolume(m_foilHtop_hole
				,m_Al,
				"foil_Htop_log");
m_foilHtopLogical->SetVisAttributes(  G4Colour(0.9,0.0,0.0,0.4) );//

//create alum case pieces

//vertical dividers
m_AlcaseV 			= new G4Box("case_V",(case_thickness/2.0)*mm, ((fiberHeightY[3]+case_thickness)/2.0)*mm, ((final_foil_pos)-(RPD_centerZ-(tileZ/2.0))+case_thickness)/2.0 *mm );
m_AlcaseVLogical 	= new G4LogicalVolume(m_AlcaseV
					,m_Al,
					"case_V_log");
m_AlcaseVLogical->SetVisAttributes( G4Colour(0.0,0.0,0.9,0.4));

//front and back plate
m_Alcase 			= new G4Box("case_fr_bck",((4*tileX+8*halfX_gap+case_thickness)/2.0)*mm, ((fiberHeightY[3]+case_thickness)/2.0)*mm, ((0.99*case_thickness)/2.0)*mm );
m_AlcaseLogical 	= new G4LogicalVolume(m_Alcase
					,m_Al,
					"case_fr_bck_log");
m_AlcaseLogical->SetVisAttributes( G4Colour(0.0,0.0,0.9,0.4));//


///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// if Optical is turned on we need to build air detector above each fibers

595
if ( OPTICAL ){
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630

float air_detect_thickness = 0.1;
float correction = 0.0;

m_air_detect = new G4Tubs( "air_detect",
					0.0*mm,
					((core_diam/2.0)-correction)*mm,
					((air_detect_thickness/2.0))*mm ,
					0.0*deg,
					360.0*deg);


int air_detecT_cnt = 0;
for(int i=0;i<4;i++) {
	for(int j=0;j<4;j++) {
		for(int k=0;k<4;k++) {
			sprintf(name,"photo_detect_log_%d_%d_%d",i, j, k);
			m_air_detect_Logical[air_detecT_cnt]	 = new G4LogicalVolume(m_air_detect, m_PMMA, name);
			m_air_detect_Logical[air_detecT_cnt]->SetVisAttributes( G4Colour(0.0,1.0,0.0,5.0) );

			//sprintf(name,"photo_detect %d", k);
			sprintf(name,"photo_detect_phys_%d_%d_%d",i, j, k);//comment

			if(air_detec_flag){

			m_air_detectPhysical[air_detecT_cnt]		  = new G4PVPlacement(
					nullRotation,
					G4ThreeVector(( 0.0 ) *mm ,
									 ( 0.0 ) 	 *mm ,
									 (fiberHeightY[k]/2 - (air_detect_thickness/2.0) - correction)*mm),
					m_air_detect_Logical[air_detecT_cnt],
					name,
					m_fiberLogical[air_detecT_cnt],
					false,
					air_detecT_cnt,
631
					CHECK_OVERLAPS);
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661



					air_detecT_cnt++;

				}
			}
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

//place vertical dividers
for(int k=0;k<5;k++) {

	sprintf(name,"case_V %d", k);

	if(vertical_flag){
		m_AlcaseVPhysical[k] = new G4PVPlacement(
						nullRotation,
						G4ThreeVector((( 	(RPD_startX + tileX/2.0) + halfX_gap  ) - k*(2*halfX_gap+tileX)  ) 	*mm ,
													 (RPD_centerY )   	*mm ,
													 (assembly_midZ )			*mm),
						m_AlcaseVLogical,
						name,
						m_logicMother,
						false,
						k,
662
						CHECK_OVERLAPS);
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
						}
}
//place front/back plate
for(int k=0;k<2;k++) {

	sprintf(name,"case_fr_bck %d", k);

	if(fr_bck_flag){
		m_AlcasePhysical[k] = new G4PVPlacement(
						nullRotation,
						G4ThreeVector(  (RPD_centerX) 	*mm ,
														(RPD_centerY)   	*mm ,
													 (assembly_midZ - half_Z_length - case_thickness + 2.0*k*(half_Z_length+case_thickness) )			*mm),
						m_AlcaseLogical,
						name,
						m_logicMother,
						false,
						k,
681
						CHECK_OVERLAPS);
682
683
684
685
686
687
688
689
690
691
692
					}
}
//place tiles, fibers, foil
  for(int j=0;j<4;j++) {
    for(int i=0;i<4;i++) {



		if(tile_flag){
			sprintf(name,"tilephys_%d_%d", i,j);
    	m_tilePhysical[i][j] = new G4PVPlacement(
693
							nullRotation,
694
695
696
							G4ThreeVector( ( 	RPD_startX - (i*( tileX+(2*halfX_gap) ) ) )  	*mm ,
										   			( 	RPD_startY - (j*( tileY+(2*halfY_gap) ) ) )	*mm ,
											 					tileZcenter[j] *mm),
697
698
699
700
701
							m_tileLogical,
							name,
							m_logicMother,
							false,
							cn,
702
							CHECK_OVERLAPS);
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
						}



			if(foil_flag){
				sprintf(name,"foil_V_%d_%d",  i,j);
				m_foilVPhysical[i][j] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector( ( 	RPD_startX - (j*( tileX+(2*halfX_gap) ) ) )  	*mm ,
											   		   ( RPD_startY + tileY/2 - (fiberHeightY[i]/2)  ) 		*mm ,
												 			 ( foilZcenter[i]) *mm),
								m_foilVLogical[i],
								name,
								m_logicMother,
								false,
								cn,
719
								CHECK_OVERLAPS);
720
721
722
723
724
725
726
727
728
729
730
731
732

			sprintf(name,"foil_V_front_%d_%d",  i,j);

				m_foilVfrontPhysical[i][j] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector( ( 	RPD_startX - (i*( tileX+(2*halfX_gap) ) ) )  	*mm ,
											   		  ( 	RPD_startY - (j*( tileY+(2*halfY_gap) ) ) ) 		*mm ,
												 			 ( tileZcenter[j] - tileZ/2.0 -foil_gap/2.0) *mm),//fiberZcenter[i] + fiber_diam/2.0 + foil_gap/2.0;
								m_foilVfrontLogical,
								name,
								m_logicMother,
								false,
								cn,
733
								CHECK_OVERLAPS);
734
735
736
737
738
739
740
741
742
743
744
745
746
747


			sprintf(name,"foil_H_%d_%d", i,j);

				m_foilHPhysical[i][j] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector( ( 	RPD_startX - (j*( tileX+(2*halfX_gap) ) ) )  	*mm ,
											   		   ( RPD_startY + tileY/2 + 1.3*halfY_gap - (i+1) * (tileY + 2 * halfY_gap ))   		*mm ,
												 			 (tileZcenter[i]  - hole_center_offset/2.0)			*mm),
								m_foilHLogical,
								name,
								m_logicMother,
								false,
								i,
748
								CHECK_OVERLAPS);
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763

			if(i==0){

			sprintf(name,"foil_H_top_%d", j);

				m_foilHtopPhysical[j] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector( ( 	RPD_startX - (j*( tileX+(2*halfX_gap) ) ) )  	*mm ,
											   		   (RPD_startY + tileY/2 + 1.5*foil_thickness)   		*mm ,
												 			 (tileZcenter[0] *mm)),
								m_foilHtopLogical,
								name,
								m_logicMother,
								false,
								j,
764
								CHECK_OVERLAPS);
765
766
767
768
769
770
771
							}
				}

		for(int k=0;k<4;k++) {
			if(fiber_flag){
				sprintf(name,"fiberphys_%d_%d_%d",i, j, k);
				m_fiberPhysical[cn_fiber]		  = new G4PVPlacement(
772
							stripRotation,
773
							G4ThreeVector( ( RPD_startX - (j*( tileX+(2*halfX_gap) ) ) ) + (tileX/2) - ((i+1)*tileX/5) *mm ,
774
										   ( RPD_startY + tileY/2 - (fiberHeightY[k]/2)  )	 *mm ,
775
776
777
778
779
780
											 (fiberZcenter[k]) *mm),
							m_fiberLogical[cn_fiber],
							name,
							m_logicMother,
							false,
							cn_fiber,
781
							CHECK_OVERLAPS);
782
783
784
785
786
787
788
789
790
						}
			if(cladding_flag){
				sprintf(name,"cladphys_%d_%d_%d",i, j, k);
				m_fibercladPhysical[cn_fiber]		  = new G4PVPlacement(
							stripRotation,
							G4ThreeVector( ( RPD_startX - (j*( tileX+(2*halfX_gap) ) ) ) + (tileX/2) - ((i+1)*tileX/5) *mm ,
												( RPD_startY + tileY/2 - (fiberHeightY[k]/2)  )	 *mm ,
												(fiberZcenter[k]) *mm),
							m_fibercladLogical[k],
791
792
793
794
							name,
							m_logicMother,
							false,
							cn_fiber,
795
							CHECK_OVERLAPS);
796
797
798
799
800
801
802
803
804
805
806
807
808
						}
			if(grease_flag){
				sprintf(name,"greasephys_%d_%d_%d",i, j, k);
				m_fibergreasePhysical[cn_fiber]		  = new G4PVPlacement(
							stripRotation,
							G4ThreeVector( ( RPD_startX - (j*( tileX+(2*halfX_gap) ) ) ) + (tileX/2) - ((i+1)*tileX/5) *mm ,
													( RPD_startY + tileY/2 - (fiberHeightY[k]/2)  )	 *mm ,
													(fiberZcenter[k]) *mm),
							m_fibergreaseLogical[k],
							name,
							m_logicMother,
							false,
							cn_fiber,
809
							CHECK_OVERLAPS);
810
811
									}

812
813
814
							cn_fiber++;
		}

815
			//
aricct2's avatar
aricct2 committed
816
817
818
819
820
821
822
823
824
825
826
827
      // std::cout  << std:: endl << "tilex = "
			// 	<<  RPD_startX - (i*( tileX+(2*halfX_gap) ) )
			// 	<< ", tiley = "
			// 	<<  RPD_startY - (j*( tileY+(2*halfY_gap) ) )
			// 	<< ", tilez = "
			// 	<< tileZcenter[j]
			// 	<< ", ("
			// 	<< i
			// 	<< ","
			// 	<< j
			// 	<< ")"
			// 	<< std::endl << std::endl;
828
829
830


      cn++;
831
    }
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// TEST SETUP
if(test_tile){
		float testtileY = 100;
		float testtileZ = 50;
		float testgreaseY = 30;
		float testgreaseZ = 2.5;
		float testPDY = 2.5;
		float testcoreZ = 5;
		float testblckZ 	= 15;
		float offsetZ 	= testtileZ/2+testblckZ/2;
		float offsetY 	= 5;

	  m_test_tile 		= new G4Box("test_tile",(100/2)*mm, (testtileY/2)*mm, (testtileZ/2)*mm);
		m_test_alum 		= new G4Box("test_alum",(100/2)*mm, (testtileY/2)*mm, (testblckZ/2)*mm);
		m_test_wls 			= new G4Box("test_wls",(100/2)*mm, (testgreaseY/2)*mm, (testcoreZ/2)*mm);
		m_test_PD 			= new G4Box("test_PD",(100/2)*mm, (testPDY/2)*mm, (testcoreZ/2)*mm);
		m_test_clad 		= new G4Box("test_clad",(100/2)*mm, (testgreaseY/2)*mm, (testgreaseZ/2)*mm);
		m_test_grease 	= new G4Box("test_grease",(100/2)*mm, (testgreaseY/2)*mm, (testgreaseZ/2)*mm);
		m_test_block 		= new G4Box("test_blck1",(100/2)*mm, ((testgreaseY)/2)*mm, (testblckZ/2)*mm);


		m_test_tileLogical	 = new G4LogicalVolume(m_test_tile, m_matQuartz, "testtile_Logical");
		m_test_alumLogical	 = new G4LogicalVolume(m_test_alum, m_Al, "testalum_Logical");
		m_test_wlsLogical	 = new G4LogicalVolume(m_test_wls, m_PMMA, "testwls_Logical");
		m_test_PDLogical	 = new G4LogicalVolume(m_test_PD, m_PMMA, "testPD_Logical");
		m_test_cladLogical	 = new G4LogicalVolume(m_test_clad, m_Poly, "testclad_Logical");
		m_test_greaseLogical	 = new G4LogicalVolume(m_test_grease, m_Grease, "testgrease_Logical");
		m_test_blockLogical	 = new G4LogicalVolume(m_test_block, m_Al, "testblck_Logical");

		m_test_tileLogical->SetVisAttributes( G4Colour(0.0,1.0,0.0,0.3) );
		m_test_alumLogical->SetVisAttributes( G4Colour(0.8,0.0,0.0,0.3) );
		m_test_wlsLogical->SetVisAttributes( G4Colour(0.0,0.0,1.0,0.3) );
		m_test_PDLogical->SetVisAttributes( G4Colour(0.0,0.0,1.0,0.3) );
		m_test_cladLogical->SetVisAttributes( G4Colour(0.3,0.5,0.0,0.3) );
		m_test_greaseLogical->SetVisAttributes( G4Colour(0.0,0.6,0.8,0.3) );
		m_test_blockLogical->SetVisAttributes( G4Colour(0.8,0.0,0.0,0.3) );

		m_test_tilePhysical = new G4PVPlacement(
						nullRotation,
						G4ThreeVector(( 0.0  ) 	*mm ,
													 (0.0 )   	*mm ,
													 (assembly_midZ)			*mm),
						m_test_tileLogical,
						"testtilephys",
						m_logicMother,
						false,
						1,
885
						CHECK_OVERLAPS);
886
887
888
889
890
891
892
893
894
895
896

		m_test_greasePhysical[0] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector(( 0.0  ) 	*mm ,
															 (testtileY/2 + testgreaseY/2 - offsetY)   	*mm ,
															 (assembly_midZ - testcoreZ/2 - 1.5*testgreaseZ +offsetZ)			*mm),
								m_test_greaseLogical,
								"testgrease1phys",
								m_logicMother,
								false,
								0,
897
								CHECK_OVERLAPS);
898
899
900
901
902
903
904
905
906
907
908

		m_test_greasePhysical[1] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector(( 0.0  ) 	*mm ,
															 (testtileY/2 + testgreaseY/2- offsetY )   	*mm ,
															 (assembly_midZ + testcoreZ/2 + 1.5*testgreaseZ+offsetZ )			*mm),
								m_test_greaseLogical,
								"testgrease2phys",
								m_logicMother,
								false,
								1,
909
								CHECK_OVERLAPS);
910
911
912
913
914
915
916
917
918
919
920

		m_test_cladPhysical[0] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector(( 0.0  ) 	*mm ,
															 (testtileY/2 + testgreaseY/2- offsetY )   	*mm ,
															 (assembly_midZ - testcoreZ/2 - testgreaseZ/2+offsetZ )			*mm),
								m_test_cladLogical,
								"testclad1phys",
								m_logicMother,
								false,
								0,
921
								CHECK_OVERLAPS);
922
923
924
925
926
927
928
929
930
931
932

		m_test_cladPhysical[1] = new G4PVPlacement(
								nullRotation,
								G4ThreeVector(( 0.0  ) 	*mm ,
															 (testtileY/2 + testgreaseY/2- offsetY )   	*mm ,
															 (assembly_midZ+ testcoreZ/2 + testgreaseZ/2+offsetZ )			*mm),
								m_test_cladLogical,
								"testclad2phys",
								m_logicMother,
								false,
								1,
933
								CHECK_OVERLAPS);
934
935
936
937
938
939
940
941
942
943
944

		m_test_wlsPhysical = new G4PVPlacement(
							nullRotation,
							G4ThreeVector(( 0.0  ) 	*mm ,
														 (testtileY/2 + testgreaseY/2- offsetY )   	*mm,
														 (assembly_midZ + offsetZ)			*mm),
							m_test_wlsLogical,
							"testtilewls",
							m_logicMother,
							false,
							1,
945
							CHECK_OVERLAPS);
946
947
948
949
950
951
952
953
954
955
956

		m_test_PDPhysical = new G4PVPlacement(
						nullRotation,
						G4ThreeVector(( 0.0  ) 	*mm ,
													 (testgreaseY/2 - testPDY/2  )   	*mm ,
													 (0.0)			*mm),
						m_test_PDLogical,
						"photo_detect",
						m_test_wlsLogical,
						false,
						1,
957
						CHECK_OVERLAPS);
958
959
960
961
962
963
964
965
966
967
968

		m_test_alumPhysical = new G4PVPlacement(
								nullRotation,
								G4ThreeVector(( 0.0  ) 	*mm ,
															 (0.0 - offsetY )   	*mm ,
															 (assembly_midZ + testblckZ/2 + testtileZ/2 )			*mm),
								m_test_alumLogical,
								"testalumphys",
								m_logicMother,
								false,
								1,
969
								CHECK_OVERLAPS);
970
971
972
973
974
975
976
977
978
979
980

	m_test_blockPhysical[0] = new G4PVPlacement(
							nullRotation,
							G4ThreeVector(( 0.0  ) 	*mm ,
														 (testtileY/2 + testgreaseY/2 )   	*mm ,
														(assembly_midZ + testblckZ/2 + 2.0* testgreaseZ + testcoreZ/2 +offsetZ)			*mm),
							m_test_blockLogical,
							"testblck1phys",
							m_logicMother,
							false,
							1,
981
							CHECK_OVERLAPS);
982
983
984
985
986
987
988
989
990
991
992

	m_test_blockPhysical[1] = new G4PVPlacement(
							nullRotation,
							G4ThreeVector(( 0.0  ) 	*mm ,
														 (testtileY/2 + testgreaseY/2   )   	*mm ,
														 (assembly_midZ - testblckZ/2 - 2.0* testgreaseZ - testcoreZ/2 +offsetZ)			*mm),
							m_test_blockLogical,
							"testblck2phys",
							m_logicMother,
							false,
							1,
993
							CHECK_OVERLAPS);
994
995
996


}
997

998
  //----------------------------------------------
999
1000
  // SD and Scoring Volumes
  //----------------------------------------------
For faster browsing, not all history is shown. View entire blame