This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv2.cxx
CommitLineData
fe4da5cc 1//-*-C++-*-
2//_________________________________________________________________________
3// Manager and hit classes for PHOS
4//*-- Author : Maxim Volkov, RRC KI
5// AliPHOSv2 derives directly from AliDetector, because too much functionality
6// has been put in AliPHOS for my liking.
7//////////////////////////////////////////////////////////////////////////////
8
9// --- ROOT system ---
10#include "TH1.h"
11#include "TRandom.h"
12#include "TFile.h"
13#include "TTree.h"
14#include "TBRIK.h"
15#include "TNode.h"
16
17// --- Standard library ---
18#include <stdio.h>
19#include <string.h>
20#include <stdlib.h>
21
22// --- galice header files ---
23#include "AliPHOSv2.h"
24#include "AliRun.h"
25#include "AliConst.h"
26#include "AliMC.h"
27
28///////////////////////////////////////////////////////////////////////////////
29
30ClassImp(AliPHOSv2)
31
32///////////////////////////////////////////////////////////////////////////////
33
34AliPHOSv2::~AliPHOSv2(void)
35{
36
37 // fNV = 0;
38 // fNH = 0;
39 fIshunt = 0;
40
41 delete fHits;
42
43}
44
45///////////////////////////////////////////////////////////////////////////////
46
47AliPHOSv2::AliPHOSv2()
48{
49
50 // fNV = 0;
51 // fNH = 0;
52 fIshunt = 0;
53 fHits = 0;
54 fDigits = 0;
55
56}
57
58///////////////////////////////////////////////////////////////////////////////
59
60AliPHOSv2::AliPHOSv2(const char *name, const char *title):
61 AliDetector(name,title)
62{
63
64 //Begin_Html
65 /*
66 <img src="gif/aliphos.gif">
67 */
68 //End_Html
69
70 fHits = new TClonesArray("AliPHOShitv2", 405);
71
72 // fNV = 4;
73 // fNH = 4;
74 fIshunt = 1; // All hits are associated with primary particles
75
76 DefPars(); // Set geometry parameters
77
78 // SetMarkerColor(kGreen);
79 // SetMarkerStyle(2);
80 // SetMarkerSize(0.4);
81
82}
83
84//////////////////////////////////////////////////////////////////////////////
85
86void AliPHOSv2::DefPars(void)
87{
88
89 // Initialization of GEANT3 geometry parameters
90 fXtlSize[0]=2.2;
91 fXtlSize[1]=18.0;
92 fXtlSize[2]=2.2;
93
94 fWrapThickness=0.01;
95
96 fPINSize[0]=1.0;
97 fPINSize[1]=0.1;
98 fPINSize[2]=1.0;
99
100 fCPVThickness=1.0;
101
102 fPHOSFoam[0]=214.6;
103 fPHOSFoam[1]=80.0;
104 fPHOSFoam[2]=260.0;
105
106 fPHOStxwall[0]=209.0;
107 fPHOStxwall[1]=71.0;
108 fPHOStxwall[2]=250.0;
109
110 fPHOSAir[0]=206.0;
111 fPHOSAir[1]=66.0;
112 fPHOSAir[2]=244.0;
113
114 fRadius[0]=447.0;
115 fRadius[1]=460.0;
116
117 fPHOSextra[0]=0.005; // Titanium cover thickness
118 fPHOSextra[1]=6.95; // Crystal support height
119 fPHOSextra[2]=4.0; // Thermo Insulating outer cover Upper plate thickness
120 fPHOSextra[3]=5.0; // Upper Polystyrene Foam plate thickness
121 fPHOSextra[4]=2.0; // Thermo insulating Crystal Block wall thickness
122 fPHOSextra[5]=0.06; // Upper Cooling Plate thickness
123 fPHOSextra[6]=10.0; // Al Support Plate thickness
124 fPHOSextra[7]=3.0; // Lower Thermo Insulating Plate thickness
125 fPHOSextra[8]=1.0; // Lower Textolit Plate thickness
126 fPHOSextra[9]=0.03; // 1/2 total gap between adjacent crystals
127
128 fNphi=88;
129 fNz=104;
130
131 fNModules=4;
132
133 fPHOSAngle[0]=0.0; // Module position angles are set in CreateGeometry()
134 fPHOSAngle[1]=0.0;
135 fPHOSAngle[2]=0.0;
136 fPHOSAngle[3]=0.0;
137
138}
139
140//////////////////////////////////////////////////////////////////////////////
141
142void AliPHOSv2::Init(void)
143{
144
145 Int_t i;
146
147 printf("\n");
148 for(i=0;i<35;i++) printf("*");
149 printf(" PHOS_INIT ");
150 for(i=0;i<35;i++) printf("*");
151 printf("\n");
152
153 // Here the PHOS initialisation code (if any!)
154 for(i=0;i<80;i++) printf("*");
155 printf("\n");
156
157}
158
159//////////////////////////////////////////////////////////////////////////////
160
161void AliPHOSv2::BuildGeometry()
162{
163
164 // Stolen completely from A. Zvyagine
165
166 TNode *Node, *Top;
167
168 const int kColorPHOS = kRed;
169
170 Top=gAlice->GetGeometry()->GetNode("alice");
171
172 // PHOS
173 Float_t pphi=12.9399462;
174 new TRotMatrix("rot988","rot988",90,-3*pphi,90,90-3*pphi,0,0);
175 new TRotMatrix("rot989","rot989",90,- pphi,90,90- pphi,0,0);
176 new TRotMatrix("rot990","rot990",90, pphi,90,90+ pphi,0,0);
177 new TRotMatrix("rot991","rot991",90, 3*pphi,90,90+3*pphi,0,0);
178 new TBRIK("S_PHOS","PHOS box","void",107.3,40,130);
179 Top->cd();
180 Node=new TNode("PHOS1","PHOS1","S_PHOS",-317.824921,-395.014343,0,"rot988");
181 Node->SetLineColor(kColorPHOS);
182 fNodes->Add(Node);
183 Top->cd();
184 Node=new TNode("PHOS2","PHOS2","S_PHOS",-113.532333,-494.124908,0,"rot989");
185 fNodes->Add(Node);
186 Node->SetLineColor(kColorPHOS);
187 Top->cd();
188 Node=new TNode("PHOS3","PHOS3","S_PHOS", 113.532333,-494.124908,0,"rot990");
189 Node->SetLineColor(kColorPHOS);
190 fNodes->Add(Node);
191 Top->cd();
192 Node=new TNode("PHOS4","PHOS4","S_PHOS", 317.824921,-395.014343,0,"rot991");
193 Node->SetLineColor(kColorPHOS);
194 fNodes->Add(Node);
195
196}
197
198//////////////////////////////////////////////////////////////////////////////
199
200void AliPHOSv2::CreateMaterials()
201{
202
203 // DEFINITION OF AVAILABLE PHOS MATERIALS
204
205 AliMC* pMC=AliMC::GetMC();
206
207 Int_t ISXFLD=gAlice->Field()->Integ();
208 Float_t SXMGMX=gAlice->Field()->Max();
209
210 // --- The PbWO4 crystals ---
211 Float_t AX[3]={207.19, 183.85, 16.0};
212 Float_t ZX[3]={82.0, 74.0, 8.0};
213 Float_t WX[3]={1.0, 1.0, 4.0};
214 Float_t DX=8.28;
215
216 // --- Titanium ---
217 Float_t ATIT[3]={47.88, 26.98, 54.94};
218 Float_t ZTIT[3]={22.0, 13.0, 25.0};
219 Float_t WTIT[3]={69.0, 6.0, 1.0};
220 Float_t DTIT=4.5;
221
222 // --- The polysterene scintillator (CH) ---
223 Float_t AP[2]={12.011, 1.00794};
224 Float_t ZP[2]={6.0, 1.0};
225 Float_t WP[2]={1.0, 1.0};
226 Float_t DP=1.032;
227
228 // --- Tyvek (CnH2n) ---
229 Float_t AT[2]={12.011, 1.00794};
230 Float_t ZT[2]={6.0, 1.0};
231 Float_t WT[2]={1.0, 2.0};
232 Float_t DT=0.331;
233
234 // --- Polystyrene foam ---
235 Float_t AF[2]={12.011, 1.00794};
236 Float_t ZF[2]={6.0, 1.0};
237 Float_t WF[2]={1.0, 1.0};
238 Float_t DF=0.12;
239
240 // --- Foam thermo insulation ---
241 Float_t ATI[2]={12.011, 1.00794};
242 Float_t ZTI[2]={6.0, 1.0};
243 Float_t WTI[2]={1.0, 1.0};
244 Float_t DTI=0.1;
245
246 // --- Textolit ---
247 Float_t ATX[4]={16.0, 28.09, 12.011, 1.00794};
248 Float_t ZTX[4]={8.0, 14.0, 6.0, 1.0};
249 Float_t WTX[4]={292.0, 68.0, 462.0, 736.0};
250 Float_t DTX=1.75;
251
252 Int_t *idtmed = gAlice->Idtmed();
253
254 AliMixture(0, "PbWO4$", AX, ZX, DX, -3, WX);
255 AliMixture(1, "Polystyrene$", AP, ZP, DP, -2, WP);
256 AliMaterial(2, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0);
257 // --- Absorption length^ is ignored ---
258 AliMixture(3, "Tyvek$", AT, ZT, DT, -2, WT);
259 AliMixture(4, "Foam$", AF, ZF, DF, -2, WF);
260 AliMixture(5, "Titanium$", ATIT, ZTIT, DTIT, -3, WTIT);
261 AliMaterial(6, "Si$", 28.09, 14., 2.33, 9.36, 42.3, 0, 0);
262 AliMixture(7, "Thermo Insul.$", ATI, ZTI, DTI, -2, WTI);
263 AliMixture(8, "Textolit$", ATX, ZTX, DTX, -4, WTX);
264 AliMaterial(99, "Air$", 14.61, 7.3, 0.001205, 30420., 67500., 0, 0);
265
266 AliMedium(700, "PHOS Xtal $", 0, 1,
267 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0);
268 AliMedium(701, "CPV scint. $", 1, 1,
269 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0);
270 AliMedium(702, "Al parts $", 2, 0,
271 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0);
272 AliMedium(703, "Tyvek wrapper$", 3, 0,
273 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0);
274 AliMedium(704, "Polyst. foam $", 4, 0,
275 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0);
276 AliMedium(705, "Titan. cover $", 5, 0,
277 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.0001, 0.0001, 0, 0);
278 AliMedium(706, "Si PIN $", 6, 0,
279 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.01, 0.01, 0, 0);
280 AliMedium(707, "Thermo Insul.$", 7, 0,
281 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0);
282 AliMedium(708, "Textolit $", 8, 0,
283 ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0);
284 AliMedium(799, "Air $", 99, 0,
285 ISXFLD, SXMGMX, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0);
286
287 // --- Set decent energy thresholds for gamma and electron tracking
288 pMC->Gstpar(idtmed[700],"CUTGAM",0.5E-4);
289 pMC->Gstpar(idtmed[700],"CUTELE",1.0E-4);
290 // --- Generate explicitly delta rays in the titan cover ---
291 pMC->Gstpar(idtmed[705],"LOSS",3.);
292 pMC->Gstpar(idtmed[705],"DRAY",1.);
293 // --- and in aluminium parts ---
294 pMC->Gstpar(idtmed[702],"LOSS",3.);
295 pMC->Gstpar(idtmed[702],"DRAY",1.);
296
297}
298
299//////////////////////////////////////////////////////////////////////////////
300
301void AliPHOSv2::CreateGeometry()
302{
303
304 AliMC* pMC = AliMC::GetMC();
305
306 AliPHOSv2 *PHOS_tmp = (AliPHOSv2*)gAlice->GetDetector("PHOS");
307 if(PHOS_tmp==NULL){
308
309 fprintf(stderr,"PHOS detector not found!\n");
310 return;
311
312 }
313
314 // --- Dimensions of volumes ---
315 Float_t DPHOS[3], DPTXW[3], DPAIR[3];
316 Float_t DPUFP[3], DPUCP[3], DPASP[3], DPTIP[3], DPTXP[3];
317 Float_t DPTCB[3], DPCBL[3], DPSTC[3], DPPAP[3], DPXTL[3], DPSUP[3],
318 DPPIN[3];
319 Float_t DPCPV[3], DPCPA[3];
320
321 Float_t R, YO, XP1, YP1, PPHI, angle;
322 Int_t IDROTM[99];
323 Int_t i;
324
325 Double_t const RADDEG=180.0/kPI;
326 // Double_t const DEGRAD=kPI/180.0;
327
328 // --- Dimensions of PbWO4 crystal ---
329 // PARAMETER(XTL_X=2.2,XTL_Y=18.,XTL_Z=2.2)
330 Float_t XTL_X=GetCrystalSize(0);
331 Float_t XTL_Y=GetCrystalSize(1);
332 Float_t XTL_Z=GetCrystalSize(2);
333
334 // --- Tyvek wrapper thickness
335 // PARAMETER(PAP_THICK=0.01)
336 Float_t PAP_THICK=GetWrapThickness();
337
338 // --- Steel (titanium) cover thickness ---
339 // PARAMETER(STE_THICK=0.005)
340 Float_t STE_THICK=GetPHOSextra(0);
341
342 // --- Crystal support height ---
343 // PARAMETER(SUP_Y=6.95)
344 Float_t SUP_Y=GetPHOSextra(1);
345
346 // --- PIN-diode dimensions ---
347 // PARAMETER(PIN_X=1.4,PIN_Y=0.4,PIN_Z=1.4)
348 Float_t PIN_X=GetPINSize(0);
349 Float_t PIN_Y=GetPINSize(1);
350 Float_t PIN_Z=GetPINSize(2);
351
352 // --- CPV thickness ---
353 // PARAMETER(CPV_Y=0.5)
354 Float_t CPV_Y=GetCPVThickness();
355
356 // --- Foam Thermo Insulating outer cover dimensions ---
357 // PARAMETER(FTI_X=214.6,FTI_Y=80.,FTI_Z=260.)
358 Float_t FTI_X=GetPHOSFoam(0);
359 Float_t FTI_Y=GetPHOSFoam(1);
360 Float_t FTI_Z=GetPHOSFoam(2);
361
362 // --- Thermo Insulating outer cover Upper plate thickness ---
363 // PARAMETER(FTIU_THICK=4.)
364 Float_t FTIU_THICK=GetPHOSextra(2);
365
366 // --- Textolit Wall box dimentions ---
367 // PARAMETER(TXW_X=209.,TXW_Y=71.,TXW_Z=250.)
368 Float_t TXW_X=GetPHOStxwall(0);
369 Float_t TXW_Y=GetPHOStxwall(1);
370 Float_t TXW_Z=GetPHOStxwall(2);
371
372 // --- Inner AIR volume dimensions ---
373 // PARAMETER(AIR_X=206.,AIR_Y=66.,AIR_Z=244.)
374 Float_t AIR_X=GetPHOSAir(0);
375 Float_t AIR_Y=GetPHOSAir(1);
376 Float_t AIR_Z=GetPHOSAir(2);
377
378 // --- Upper Polystyrene Foam plate thickness ---
379 // PARAMETER(UFP_Y=5.)
380 Float_t UFP_Y=GetPHOSextra(3);
381
382 // --- Thermo insulating Crystal Block wall thickness ---
383 // PARAMETER(TCB_THICK=2.)
384 Float_t TCB_THICK=GetPHOSextra(4);
385
386 // --- Upper Cooling Plate thickness ---
387 // PARAMETER(UCP_Y=0.06)
388 Float_t UCP_Y=GetPHOSextra(5);
389
390 // --- Al Support Plate thickness ---
391 // PARAMETER(ASP_Y=10.)
392 Float_t ASP_Y=GetPHOSextra(6);
393
394 // --- Lower Thermo Insulating Plate thickness ---
395 // PARAMETER(TIP_Y=3.)
396 Float_t TIP_Y=GetPHOSextra(7);
397
398 // --- Lower Textolit Plate thickness ---
399 // PARAMETER(TXP_Y=1.)
400 Float_t TXP_Y=GetPHOSextra(8);
401
402 // --- 1/2 total gap between adjacent crystals
403 Float_t TOTAL_GAP=GetPHOSextra(9);
404
405 // --- Distance from IP to Foam Thermo Insulating top plate ---
406 // PARAMETER(FTI_R=467.)
407 Float_t FTI_R=GetRadius(0);
408
409 // --- Distance from IP to Crystal Block top Surface (needs to be 460.) ---
410 // PARAMETER(CBS_R=480.)
411 Float_t CBS_R=GetRadius(1);
412
413 // Get pointer to the array containing media indeces
414 Int_t *IDTMED = gAlice->Idtmed();
415
416 // --- Define PHOS box volume, fill with thermo insulating foam ---
417 DPHOS[0]=FTI_X/2.0;
418 DPHOS[1]=FTI_Y/2.0;
419 DPHOS[2]=FTI_Z/2.0;
420 pMC->Gsvolu("PHOS", "BOX ", IDTMED[706], DPHOS, 3);
421
422 // --- Define Textolit Wall box, position inside PHOS ---
423 DPTXW[0]=TXW_X/2.0;
424 DPTXW[1]=TXW_Y/2.0;
425 DPTXW[2]=TXW_Z/2.0;
426 pMC->Gsvolu("PTXW", "BOX ", IDTMED[707], DPTXW, 3);
427 YO=(FTI_Y-TXW_Y)/2.0-FTIU_THICK;
428 pMC->Gspos("PTXW", 1, "PHOS", 0.0, YO, 0.0, 0, "ONLY");
429
430 // --- Define Upper Polystyrene Foam Plate, place inside PTXW ---
431 // --- immediately below Foam Thermo Insulation Upper plate ---
432 DPUFP[0]=TXW_X/2.0;
433 DPUFP[1]=UFP_Y/2.0;
434 DPUFP[2]=TXW_Z/2.0;
435 pMC->Gsvolu("PUFP", "BOX ", IDTMED[703], DPUFP, 3);
436 YO=(TXW_Y-UFP_Y)/2.0;
437 pMC->Gspos("PUFP", 1, "PTXW", 0.0, YO, 0.0, 0, "ONLY");
438
439 // --- Define air-filled box, place inside PTXW ---
440 DPAIR[0]=AIR_X/2.0;
441 DPAIR[1]=AIR_Y/2.0;
442 DPAIR[2]=AIR_Z/2.0;
443 pMC->Gsvolu("PAIR", "BOX ", IDTMED[798], DPAIR, 3);
444 YO=(TXW_Y-AIR_Y)/2.0-UFP_Y;
445 pMC->Gspos("PAIR", 1, "PTXW", 0.0, YO, 0.0, 0, "ONLY");
446
447 // --- Define Thermo insulating Crystal Box, position inside PAIR ---
448 DPTCB[0]=GetNphi()*(XTL_X+2*TOTAL_GAP)/2.0+TCB_THICK;
449 DPTCB[1]=(XTL_Y+SUP_Y+PAP_THICK+STE_THICK)/2.0+TCB_THICK/2.0;
450 DPTCB[2]=GetNz()*(XTL_Z+2*TOTAL_GAP)/2.0+TCB_THICK;
451 pMC->Gsvolu("PTCB", "BOX ", IDTMED[706], DPTCB, 3);
452 YO=AIR_Y/2.0-DPTCB[1]-
453 (CBS_R-FTI_R-TCB_THICK-FTIU_THICK-UFP_Y);
454 pMC->Gspos("PTCB", 1, "PAIR", 0.0, YO, 0.0, 0, "ONLY");
455
456 // --- Define Crystal BLock filled with air, position it inside PTCB ---
457 DPCBL[0]=GetNphi()*(XTL_X+2*TOTAL_GAP)/2.0;
458 DPCBL[1]=(XTL_Y+SUP_Y+PAP_THICK+STE_THICK)/2.0;
459 DPCBL[2]=GetNz()*(XTL_Z+2*TOTAL_GAP)/2.0;
460 pMC->Gsvolu("PCBL", "BOX ", IDTMED[798], DPCBL, 3);
461
462 // --- Divide PCBL in X (phi) and Z directions --
463 pMC->Gsdvn("PROW", "PCBL", Int_t (GetNphi()), 1);
464 pMC->Gsdvn("PCEL", "PROW", Int_t (GetNz()), 3);
465 YO=-TCB_THICK/2.0;
466 pMC->Gspos("PCBL", 1, "PTCB", 0.0, YO, 0.0, 0, "ONLY");
467
468 // --- Define STeel (actually, it's titanium) Cover volume, place inside PCEL
469 DPSTC[0]=(XTL_X+2*PAP_THICK)/2.0;
470 DPSTC[1]=(XTL_Y+SUP_Y+PAP_THICK+STE_THICK)/2.0;
471 DPSTC[2]=(XTL_Z+2*PAP_THICK+2*STE_THICK)/2.0;
472 pMC->Gsvolu("PSTC", "BOX ", IDTMED[704], DPSTC, 3);
473 pMC->Gspos("PSTC", 1, "PCEL", 0.0, 0.0, 0.0, 0, "ONLY");
474
475 // --- Define Tyvek volume, place inside PSTC ---
476 DPPAP[0]=XTL_X/2.0+PAP_THICK;
477 DPPAP[1]=(XTL_Y+SUP_Y+PAP_THICK)/2.0;
478 DPPAP[2]=XTL_Z/2.0+PAP_THICK;
479 pMC->Gsvolu("PPAP", "BOX ", IDTMED[702], DPPAP, 3);
480 YO=(XTL_Y+SUP_Y+PAP_THICK)/2.0-(XTL_Y+SUP_Y+PAP_THICK+STE_THICK)/2.0;
481 pMC->Gspos("PPAP", 1, "PSTC", 0.0, YO, 0.0, 0, "ONLY");
482
483 // --- Define PbWO4 crystal volume, place inside PPAP ---
484 DPXTL[0]=XTL_X/2.0;
485 DPXTL[1]=XTL_Y/2.0;
486 DPXTL[2]=XTL_Z/2.0;
487 pMC->Gsvolu("PXTL", "BOX ", IDTMED[699], DPXTL, 3);
488 YO=(XTL_Y+SUP_Y+PAP_THICK)/2.0-XTL_Y/2.0-PAP_THICK;
489 pMC->Gspos("PXTL", 1, "PPAP", 0.0, YO, 0.0, 0, "ONLY");
490
491 // --- Define crystal support volume, place inside PPAP ---
492 DPSUP[0]=XTL_X/2.0+PAP_THICK;
493 DPSUP[1]=SUP_Y/2.0;
494 DPSUP[2]=XTL_Z/2.0+PAP_THICK;
495 pMC->Gsvolu("PSUP", "BOX ", IDTMED[798], DPSUP, 3);
496 YO=SUP_Y/2.0-(XTL_Y+SUP_Y+PAP_THICK)/2.0;
497 pMC->Gspos("PSUP", 1, "PPAP", 0.0, YO, 0.0, 0, "ONLY");
498
499 // --- Define PIN-diode volume and position it inside crystal support ---
500 // --- right behind PbWO4 crystal
501 DPPIN[0]=PIN_X/2.0;
502 DPPIN[1]=PIN_Y/2.0;
503 DPPIN[2]=PIN_Z/2.0;
504 pMC->Gsvolu("PPIN", "BOX ", IDTMED[705], DPPIN, 3);
505 YO=SUP_Y/2.0-PIN_Y/2.0;
506 pMC->Gspos("PPIN", 1, "PSUP", 0.0, YO, 0.0, 0, "ONLY");
507
508 // --- Define Upper Cooling Panel, place it on top of PTCB ---
509 DPUCP[0]=DPTCB[0];
510 DPUCP[1]=UCP_Y/2.0;
511 DPUCP[2]=DPTCB[2];
512 pMC->Gsvolu("PUCP", "BOX ", IDTMED[701], DPUCP,3);
513 YO=(AIR_Y-UCP_Y)/2.0-(CBS_R-FTI_R-TCB_THICK-FTIU_THICK-UFP_Y-UCP_Y);
514 pMC->Gspos("PUCP", 1, "PAIR", 0.0, YO, 0.0, 0, "ONLY");
515
516 // --- Define Al Support Plate, position it inside PAIR ---
517 // --- right beneath PTCB ---
518 DPASP[0]=AIR_X/2.0;
519 DPASP[1]=ASP_Y/2.0;
520 DPASP[2]=AIR_Z/2.0;
521 pMC->Gsvolu("PASP", "BOX ", IDTMED[701], DPASP, 3);
522 YO=(AIR_Y-ASP_Y)/2.0-(CBS_R-FTI_R-FTIU_THICK-UFP_Y+DPCBL[1]*2);
523 pMC->Gspos("PASP", 1, "PAIR", 0.0, YO, 0.0, 0, "ONLY");
524
525 // --- Define Thermo Insulating Plate, position it inside PAIR ---
526 // --- right beneath PASP ---
527 DPTIP[0]=AIR_X/2.0;
528 DPTIP[1]=TIP_Y/2.0;
529 DPTIP[2]=AIR_Z/2.0;
530 pMC->Gsvolu("PTIP", "BOX ", IDTMED[706], DPTIP, 3);
531 YO=(AIR_Y-TIP_Y)/2.0-(CBS_R-FTI_R-FTIU_THICK-UFP_Y+DPCBL[1]*2+ASP_Y);
532 pMC->Gspos("PTIP", 1, "PAIR", 0.0, YO, 0.0, 0, "ONLY");
533
534 // --- Define Textolit Plate, position it inside PAIR ---
535 // --- right beneath PTIP ---
536 DPTXP[0]=AIR_X/2.0;
537 DPTXP[1]=TXP_Y/2.0;
538 DPTXP[2]=AIR_Z/2.0;
539 pMC->Gsvolu("PTXP", "BOX ", IDTMED[707], DPTXP, 3);
540 YO=(AIR_Y-TXP_Y)/2.0-
541 (CBS_R-FTI_R-FTIU_THICK-UFP_Y+DPCBL[1]*2+ASP_Y+TIP_Y);
542 pMC->Gspos("PTXP", 1, "PAIR", 0.0, YO, 0.0, 0, "ONLY");
543
544 // --- Define CPV volume, DON'T PLACE IT YET ---
545 // --- Divide in X and Z direction (same way as PCBL) ---
546 DPCPV[0]=DPCBL[0];
547 DPCPV[1]=CPV_Y/2.0;
548 DPCPV[2]=DPCBL[2];
549 // pMC->Gsvolu("PCPV", "BOX ", IDTMED[700], DPCPV, 3);
550 pMC->Gsvolu("PCPV", "BOX ", IDTMED[798], DPCPV, 3);
551 pMC->Gsdvn("PCRO", "PCPV", Int_t (GetNphi()), 1);
552 pMC->Gsdvn("PCCE", "PCRO", Int_t (GetNz()), 3);
553
554 // Define CPV sensitive pad. It has the same size as PCCE.
555 DPCPA[0]=DPCBL[0]/GetNphi();
556 DPCPA[1]=CPV_Y/2.0;
557 DPCPA[2]=DPCBL[2]/GetNz();
558 pMC->Gsvolu("PCPA", "BOX ", IDTMED[700], DPCPA, 3);
559 pMC->Gspos("PCPA", 1, "PCCE", 0.0, 0.0, 0.0, 0, "ONLY");
560
561 // --- Position various PHOS units in ALICE setup ---
562 // --- PHOS itself first ---
563 PPHI=TMath::ATan(FTI_X/(2.0*FTI_R));
564 PPHI*=RADDEG;
565
566 for(i=1; i<=GetNModules(); i++){
567
568 angle=PPHI*2*(i-GetNModules()/2.0-0.5);
569 AliMatrix(IDROTM[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0);
570
571 // --- Position various PHOS units in ALICE setup ---
572 // --- PHOS itself first ---
573 R=FTI_R+FTI_Y/2.0;
574 XP1=R*TMath::Sin(angle/RADDEG);
575 YP1=-R*TMath::Cos(angle/RADDEG);
576 pMC->Gspos("PHOS", i, "ALIC", XP1, YP1, 0.0, IDROTM[i-1], "ONLY");
577
578 // --- Now position PCPV so that its plates are right on top of ---
579 // --- corresponding PHOS modules (previously called cradles) ---
580 R=FTI_R-CPV_Y/2.0;
581 XP1=R*TMath::Sin(angle/RADDEG);
582 YP1=-R*TMath::Cos(angle/RADDEG);
583 pMC->Gspos("PCPV", i, "ALIC", XP1, YP1, 0.0, IDROTM[i-1], "ONLY");
584 GetModuleAngle(i-1)=angle-90.0;
585
586 }
587
588 // --- Set volumes seen without their descendants for drawing ---
589 pMC->Gsatt("PCEL", "SEEN", -2);
590 pMC->Gsatt("PCCE", "SEEN", -2);
591
592}
593
594//////////////////////////////////////////////////////////////////////////////
595
596void AliPHOSv2::StepManager(void)
597{
598
599 AliMC *pMC=AliMC::GetMC();
600 Int_t blrc[4]; // (box, layer, row, column) indices
601 Float_t xyze[4]; // position wrt MRS and energy deposited
602
603 Int_t *IDTMED=gAlice->Idtmed();
604
605 if(pMC->GetMedium()==IDTMED[700]){ // We are inside a CPV sensitive pad
606
607 pMC->TrackPosition(xyze);
608 xyze[3]=pMC->Edep();
609
610 pMC->CurrentVolOff(3, (Text_t*)NULL, blrc[0]);
611 blrc[1]=1; // CPV corresponds to layer 1
612 pMC->CurrentVolOff(2, (Text_t*)NULL, blrc[2]);
613 pMC->CurrentVolOff(1, (Text_t*)NULL, blrc[3]);
614
615 AddHit(gAlice->CurrentTrack(), blrc, xyze);
616
617 }
618
619 if(pMC->GetMedium()==IDTMED[699]){ // We are inside a PWO crystal
620
621 pMC->TrackPosition(xyze);
622 xyze[3]=pMC->Edep();
623
624 pMC->CurrentVolOff(9, (Text_t*)NULL, blrc[0]);
625 blrc[1]=2; // PWO crystals correspond to layer 2
626 pMC->CurrentVolOff(4, (Text_t*)NULL, blrc[2]);
627 pMC->CurrentVolOff(3, (Text_t*)NULL, blrc[3]);
628
629 AddHit(gAlice->CurrentTrack(), blrc, xyze);
630
631 }
632}
633
634////////////////////////////////////////////////////////////////////////////
635
636void AliPHOSv2::AddHit(Int_t track, Int_t *vol, Float_t *hits)
637{
638
639 Int_t hitCounter;
640 TClonesArray &lhits = *fHits;
641 AliPHOShitv2 *newHit,*curHit;
642
643 newHit=new AliPHOShitv2(fIshunt, track, vol, hits);
644
645 for(hitCounter=0;hitCounter<fNhits;hitCounter++){
646 curHit=(AliPHOShitv2*)lhits[hitCounter];
647 if(*curHit==*newHit){
648 *curHit=*curHit+*newHit;
649 delete newHit;
650 return;
651 }
652 }
653
654 new(lhits[fNhits++]) AliPHOShitv2(*newHit);
655 delete newHit;
656
657}
658
659///////////////////////////////////////////////////////////////////////////////
660
661ClassImp(AliPHOShitv2)
662
663//////////////////////////////////////////////////////////////////////////////
664
665AliPHOShitv2::AliPHOShitv2(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
666AliHit(shunt, track)
667{
668
669 Int_t i;
670 for (i=0;i<4;i++)fVolume[i]=vol[i];
671
672 fX = hits[0];
673 fY = hits[1];
674 fZ = hits[2];
675 fELOS = hits[3];
676
677}
678
679//////////////////////////////////////////////////////////////////////////////
680
681Bool_t AliPHOShitv2::operator==(AliPHOShitv2 const &rValue) const
682{
683
684 Int_t volCounter;
685
686 // if(fDet!=rValue.GetDet()) return kFALSE;
687 if(fTrack!=rValue.GetTrack()) return kFALSE;
688
689 for(volCounter=0;volCounter<4;volCounter++)
690 if(fVolume[volCounter]!=rValue.GetVolume(volCounter))return kFALSE;
691
692 return kTRUE;
693
694}
695
696/////////////////////////////////////////////////////////////////////////////
697
698AliPHOShitv2 const AliPHOShitv2::operator+(AliPHOShitv2 const &rValue) const
699{
700
701 AliPHOShitv2 added(*this);
702
703 added.fELOS+=rValue.GetEnergy();
704 return added;
705
706}
707
708//////////////////////////////////////////////////////////////////////////////