First version of CRT
[u/mrichter/AliRoot.git] / CRT / AliCRTv0.cxx
CommitLineData
fb7a1f55 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
18
19*/
20
21///////////////////////////////////////////////////////////////////////////////
22// //
23// Alice COsmic Ray Trigger //
24// //
25// This class contains the functions for version 0 of the Cosmic Rays ALICE //
26// detector. //
27//
28// Authors:
29//
30// Arturo Fernandez <afernand@fcfm.buap.mx>
31// Enrique Gamez <egamez@fcfm.buap.mx>
32//
33// Universidad Autonoma de Puebla
34//
35//
36//Begin_Html
37/*
38<img src="picts/AliCRTv0Class.gif">
39</pre>
40<br clear=left>
41<p>The responsible person for this module is
42<a href="mailto:egamez@fcfm.buap.mx">Enrique Gamez</a>.
43</font>
44<pre>
45*/
46//End_Html
47// //
48///////////////////////////////////////////////////////////////////////////////
49
50#include <iostream>
51
52#include <TMath.h>
53#include <TGeometry.h>
54#include <TTUBE.h>
55#include <TNode.h>
56#include <TLorentzVector.h>
57
58#include "AliCRTv0.h"
59#include "AliCRTConstants.h"
60
61#include "AliRun.h"
62#include "AliMC.h"
63#include "AliMagF.h"
64#include "AliConst.h"
65#include "AliPDG.h"
66
67ClassImp(AliCRTv0)
68
69//_____________________________________________________________________________
70AliCRTv0::AliCRTv0() : AliCRT()
71{
72 //
73 // Default constructor for CRT
74 //
75 fMucur = 0;
76}
77
78//_____________________________________________________________________________
79AliCRTv0::AliCRTv0(const char *name, const char *title)
80 : AliCRT(name,title)
81{
82 //
83 // Standard constructor for CRT
84 //
85 //Begin_Html
86 /*
87 <img src="picts/AliCRTv0.gif">
88 */
89 //End_Html
90}
91
92//_____________________________________________________________________________
93void AliCRTv0::BuildGeometry()
94{
95
96}
97
98//_____________________________________________________________________________
99void AliCRTv0::CreateGeometry()
100{
101 //
102 // Create geometry for the CRT array
103 //
104
105 //
106 //-- Create the hall
107 CreateHall();
108
109 Int_t idrotm[2499]; // The rotation matrix.
110
111 // idtmed[1099->1198] equivalent to fIdtmed[0->100]
112 Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
113
114 // In order to generate the more correctly the modules (more datails)
115 // we will create a box (air box) as a (sub)mother volume.
116 // Inside this box we'll put the scintillator tiles, the PMTs the frame
117 // and, maybe, some other things.
118
119 Float_t box[3];
120 box[0] = AliCRTConstants::fgCageLenght/2.; // Half Length of the box along the X axis, cm.
121 box[1] = AliCRTConstants::fgCageHeight/2.; // Half Length of the box along the Y axis, cm.
122 box[2] = AliCRTConstants::fgCageWidth/2.; // Half Length of the box along the Z axis, cm.
123
124
125 // Define the Scintillators. as a big box.
126 Float_t scint[3];
127 scint[0] = AliCRTConstants::fgActiveAreaLenght/2.; // Half Length in X
128 scint[1] = AliCRTConstants::fgActiveAreaHeight/2.; // Half Length in Y
129 scint[2] = AliCRTConstants::fgActiveAreaWidth/2.; // Half Length in Z
130 gMC->Gsvolu("CRT1", "BOX ", idtmed[1102], scint, 3); // Scintillators
131 // Divide the modules in 2 planes.
132 //gMC->Gsdvn("CRT2", "CRT1", 2, 2);
133 // Now divide each plane in 8 palettes
134 //gMC->Gsdvn("CRT3", "CRT1", 8, 3);
135
136
137 //
138 // Define the coordinates where the draw will begin.
139 //
140
141 //
142 // -- X axis.
143 // we'll start dawing from the center.
144 Float_t initX = 0.;
145
146 //
147 // -- Y axis
148 Float_t gapY = 30.; // 30 cms. above the barrel.
149 // For the height we staimate the from the center of the ceiling,
150 // if were a cilinder, must be about 280cm.
151 Float_t barrel = 790.; // Barrel radius.
152 Float_t height = barrel + gapY - 30.;
153 Float_t initY = height;
154
155 //
156 // -- Z axis.
157 // we'll start dawing from the center.
158
159 //
160 // Put 4 modules on the top of the magnet
161 Int_t step = 4;
162 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
163 gMC->Gspos("CRT1", i, "CRTA", initX, initY, (i-step)*box[2], 0, "ONLY");
164 step--;
165 }
166
167 // Modules on the barrel sides.
168 // Because the openenig angle for each face is 22.5, and if we want to
169 // put the modules right in the middle
170 Float_t xtragap = 10.;
171 Float_t initXside = (height+xtragap)*TMath::Sin(2*22.5*kDegrad); //rigth side
172 Float_t initYside = (height+xtragap)*TMath::Cos(2*22.5*kDegrad);
173
174 // Put 4 modules on the left side of the magnet
175 // The rotation matrix parameters, for the left side.
176 AliMatrix(idrotm[232], 90., 315., 90., 45., 0., 337.5);
177 Int_t stepl = 4;
178 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
179 gMC->Gspos("CRT1", i+4, "CRTA", initXside, initYside, (i-stepl)*box[2],
180 idrotm[232], "ONLY");
181 stepl--;
182 }
183
184 // Put 4 modules on the right side of the magnet
185 // The rotation matrix parameters for the right side.
186 AliMatrix(idrotm[231], 90., 45., 90., 315., 180., 202.5);
187 Int_t stepr = 4;
188 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
189 gMC->Gspos("CRT1", i+8, "CRTA", -initXside, initYside, (i-stepr)*box[2],
190 idrotm[231], "ONLY");
191 stepr--;
192 }
193
194}
195
196//_____________________________________________________________________________
197void AliCRTv0::CreateHall()
198{
199
200 Float_t r2;
201 Float_t phid, phim, pbox[3], h, r, tspar[5];
202 Float_t w1, dh, am, bm, dl,cm, hm, dr, dx, xl;
203 Int_t idrotm[1999];
204 Float_t trdpar[4], trapar[11];
205 Float_t phi;
206
207 Int_t *idtmed = fIdtmed->GetArray()-1899;
208
209 // Because the BODY, was "filled with vaccum", we're goin to superimpose
210 // a volume with molasse, then using the boolenaq operations with volumes
211 // we are going the replace, with air, the part closed by the hall walls
212
213 // For the moment, just use the simple mother volume ...
214 Float_t mola[3];
215 mola[0] = 2000.;
216 mola[1] = 2000.;
217 mola[2] = 3000.;
218 gMC->Gsvolu("CRTA", "BOX", idtmed[1905], mola, 3);
219 gMC->Gspos("CRTA", 1, "ALIC", 0., 0., 0., 0, "MANY");
220
221 // Now make a cilinder with the size of the hall (raughtly)
222 // and fill it with air.
223 Float_t hall[3];
224 hall[0] = 0.; // Inner radius
225 hall[1] = 1170.; // Outer radius
226 hall[2] = 2625. + 200.; // Hall lenght
227 gMC->Gsvolu("CRTB", "TUBE", idtmed[1914], hall, 3);
228 // perform the substraction SMOL - SALL, asigning SMOL as MANY and
229 // SALL as ONLY.
230 gMC->Gspos("CRTB", 1, "CRTA", 0., 500., -2*375., 0, "ONLY");
231
232 // RB24/26 TUNNEL FLOOR
233
234 r = 220.;
235 h = 140.;
236 phi = TMath::ACos(h / r);
237 xl = r * TMath::Sin(phi);
238 dr = 100.;
239 dh = dr * TMath::Cos(phi);
240 dl = dr * TMath::Sin(phi);
241
242 AliMatrix(idrotm[1900], 90., 0., 0., 0., 90., 90.);
243 AliMatrix(idrotm[1901], 270., 0., 90., 90., 0., 0.);
244 // END WALL
245
246 pbox[0] = 1200.;
247 pbox[1] = 1300.;
248 pbox[2] = 60.;
249 gMC->Gsvolu("CRTC", "BOX ", idtmed[1956], pbox, 3);
250 gMC->Gspos("CRTC", 1, "CRTA", 0., 404., 1960, 0, "ONLY");
251
252 // hall floor, the interior part (left)
253
254 phid = 16.197;
255 trdpar[0] = 700.;
256 trdpar[1] = TMath::Tan(phid * kDegrad) * 190. + 700.;
257 trdpar[2] = 550.;
258 trdpar[3] = 95.;
259 gMC->Gsvolu("CRTD", "TRD1", idtmed[1956], trdpar, 4);
260 gMC->Gspos("CRTD", 1, "CRTA", 0., -801., 1350., idrotm[1900], "ONLY");
261
262 // hall floor, the outside part
263
264 phid = 16.197;
265 trdpar[0] = 700.;
266 trdpar[1] = TMath::Tan(phid * kDegrad) * 190. + 700.;
267 trdpar[2] = 1325.;
268 trdpar[3] = 95.;
269 gMC->Gsvolu("CRTE", "TRD1", idtmed[1956], trdpar, 4);
270 gMC->Gspos("CRTE", 2, "CRTA", 0., -801., -2125., idrotm[1900], "ONLY");
271
272 // hall side walls
273
274 // Interior walls
275 trapar[0] = 550.;
276 trapar[1] = 0.;
277 trapar[2] = 0.;
278 trapar[3] = 1273.78/2;
279 trapar[4] = 235.;
280 trapar[5] = 50.;
281 trapar[6] = TMath::ATan((trapar[4] - trapar[5]) / 2. / trapar[3]) * kRaddeg;
282 trapar[7] = trapar[3];
283 trapar[8] = trapar[4];
284 trapar[9] = trapar[5];
285 trapar[10] = trapar[6];
286 dx = trapar[4] * 1.5 + 700. - trapar[5] * .5;
287 gMC->Gsvolu("CRTF", "TRAP", idtmed[1956], trapar, 11);// interior wall
288 gMC->Gspos("CRTF", 1, "CRTA", dx, -896+trapar[3], 1350., 0, "ONLY");
289 gMC->Gspos("CRTF", 2, "CRTA",-dx, -896+trapar[3], 1350., idrotm[1901], "ONLY");
290
291 // Exterior walls
292 Float_t trapare[11];
293 trapare[0] = 275.;
294 for ( Int_t i = 1 ; i <= 10 ; i++ ) {
295 trapare[i] = trapar[i];
296 }
297 gMC->Gsvolu("CRTG", "TRAP", idtmed[1956], trapare, 11);// exterior wall
298 gMC->Gspos("CRTG", 1, "CRTA", dx, -896+trapar[3], -1075., 0, "ONLY");
299 gMC->Gspos("CRTG", 2, "CRTA",-dx, -896+trapar[3], -1075., idrotm[1901], "ONLY");
300
301 pbox[0] = 50.;
302 pbox[1] = (500. - (trapar[3] * 2. - 896.)) / 2.;
303 pbox[2] = 1625.;
304 gMC->Gsvolu("CRTH", "BOX ", idtmed[1956], pbox, 3);
305 gMC->Gspos("CRTH", 1, "CRTA", 1120., 500-pbox[1], 275., 0, "ONLY");
306 gMC->Gspos("CRTH", 2, "CRTA", -1120., 500-pbox[1], 275., 0, "ONLY");
307
308 // slanted wall close to L3 magnet
309
310 phim = 45.;
311 hm = 790.;
312 //rm = hm / TMath::Cos(phim / 2. * kDegrad);
313 am = hm * TMath::Tan(phim / 2. * kDegrad);
314 bm = (hm + 76.) / hm * am;
315 cm = bm * 2. / TMath::Sqrt(2.);
316 trapar[0] = 800.;
317 trapar[1] = 0.;
318 trapar[2] = 0.;
319 trapar[3] = (1273.78 - cm) / 2.;
320 trapar[4] = 235. - cm * TMath::Tan(phid * kDegrad) / 2.;
321 trapar[5] = 50.;
322 trapar[6] = TMath::ATan((trapar[4] - trapar[5]) / 2. / trapar[3]) * kRaddeg;
323 trapar[7] = trapar[3];
324 trapar[8] = trapar[4];
325 trapar[9] = trapar[5];
326 trapar[10] = trapar[6];
327 w1 = trapar[4];
328 dx = cm*TMath::Tan(phid * kDegrad) + 700. + trapar[4] * 1.5 - trapar[5] * .5;
329 gMC->Gsvolu("CRTI", "TRAP", idtmed[1956], trapar, 11);
330 r2 = cm - 896. + trapar[3];
331 gMC->Gspos("CRTI", 1, "CRTA", dx, r2, 0., 0, "ONLY");
332 gMC->Gspos("CRTI", 2, "CRTA",-dx, r2, 0., idrotm[1901], "ONLY");
333 trapar[3] = cm / 2.;
334 trapar[4] = w1 + cm / 2.;
335 trapar[5] = w1;
336 trapar[6] = TMath::ATan(.5) * kRaddeg;
337 trapar[7] = trapar[3];
338 trapar[8] = trapar[4];
339 trapar[9] = trapar[5];
340 trapar[10] = trapar[6];
341 dx = 1170. - trapar[4] * .5 - trapar[5] * .5;
342 gMC->Gsvolu("CRTJ", "TRAP", idtmed[1956], trapar, 11);
343 r2 = trapar[3] - 896.;
344 gMC->Gspos("CRTJ", 1, "CRTA", dx, r2, 0., 0, "ONLY");
345 gMC->Gspos("CRTJ", 2, "CRTA",-dx, r2, 0., idrotm[1901], "ONLY");
346
347 tspar[0] = 1070.;
348 tspar[1] = 1170.;
349 tspar[2] = pbox[2];
350 tspar[3] = 0.;
351 tspar[4] = 180.;
352 gMC->Gsvolu("CRTK", "TUBS", idtmed[1956], tspar, 5);
353 gMC->Gspos("CRTK", 1, "CRTA", 0., 500., 300., 0, "ONLY");
354 trdpar[0] = 1170 - trapar[4] * 2.;
355 trdpar[1] = trdpar[0] + TMath::Tan(phim * kDegrad) * 76.;
356 trdpar[2] = 800.;
357 trdpar[3] = 38.;
358 gMC->Gsvolu("CRTL", "TRD1", idtmed[1956], trdpar, 4);
359 gMC->Gspos("CRTL", 1, "CRTA", 0., -858., 0., idrotm[1900], "ONLY");
360
361
362
363 // Define the setion tube of the PX24, at the same level of hall
364 // rotate the tubes around X, Z'=Y, Y'=-Z
365 AliMatrix(idrotm[2001], 0., 0., 90., 0., 90., 90.);
366 Float_t pxi[5];
367 pxi[0] = 1150.; // inside radius
368 pxi[1] = 1250.; // outside radius
369 pxi[2] = 1300.; // half lenght in Z
370 pxi[3] = kRaddeg*TMath::ASin(tspar[0]/pxi[0]);//starting angle of the segment
371 pxi[4] = 360.-pxi[3]; // ending angle of the segment
372 gMC->Gsvolu("CRTM", "TUBS", idtmed[1956], pxi, 5);
373 gMC->Gspos("CRTM", 1, "CRTA", 0., 404., -2300., idrotm[2001], "MANY");
374
375 // Define the setion tube of the PX24, above the hall
376 Float_t pxa[3];
377 pxa[0] = pxi[0];
378 pxa[1] = pxi[1];
379 pxa[2] = 2550. - pxi[2]; // Half lenght
380 gMC->Gsvolu("CRTN", "TUBE", idtmed[1956], pxa, 3);
381 gMC->Gspos("CRTN", 1, "CRTA", 0.,pxi[2]+404+pxa[2], -2300., idrotm[2001], "MANY");
382 // Fill this section with air.
383 Float_t pxb[3];
384 pxb[0] = 0.;
385 pxb[1] = pxa[0];
386 pxb[2] = pxa[2];
387 gMC->Gsvolu("CRTO", "TUBE", idtmed[1914], pxb, 3);
388 gMC->Gspos("CRTO", 1, "CRTA", 0., pxi[2]+404+pxa[2], -2300., idrotm[2001], "ONLY");
389
390
391 // PM25 Acces shaft.
392 Float_t pma[3];
393 pma[0] = 910./2.;// Inner radius
394 pma[1] = pma[0] + 100.; // Outer Radius
395 pma[2] = 5100./2.; // Half lenght
396 gMC->Gsvolu("CRTP", "TUBE", idtmed[1956], pma, 3);
397 gMC->Gspos("CRTP", 1, "CRTA", -2100., 1654., 0., idrotm[2001], "ONLY");
398 // Fill it with air.
399 Float_t pmb[3];
400 pmb[0] = 0.;
401 pmb[1] = pma[0];
402 pmb[2] = pma[2];
403 gMC->Gsvolu("CRTQ", "TUBE", idtmed[1914], pmb, 3);
404 gMC->Gspos("CRTQ", 1, "CRTA", -2100., 1654., 0., idrotm[2001], "ONLY");
405
406
407 // PGC2 Acces shaft.
408 Float_t pgc[3];
409 pgc[0] = 1200./2.;// Inner Radius
410 pgc[1] = pgc[0] + 100.; // outer Radius
411 pgc[2] = 5100./2.; // Half lenght
412 gMC->Gsvolu("CRTR", "TUBE", idtmed[1956], pgc, 3);
413 gMC->Gspos("CRTR", 1, "CRTA", 375., 1654., 4850., idrotm[2001], "ONLY");
414 // Fill it with air.
415 Float_t pgd[3];
416 pgd[0] = 0.;
417 pgd[1] = pgc[0];
418 pgd[2] = pgc[2];
419 gMC->Gsvolu("CRTS", "TUBE", idtmed[1914], pgd, 3);
420 gMC->Gspos("CRTS", 1, "CRTA", 375., 1654., 4850., idrotm[2001], "ONLY");
421
422}
423//_____________________________________________________________________________
424void AliCRTv0::CreateMaterials()
425{
426 //
427 //--
428 //
429
430 // Use the standard materials.
431 AliCRT::CreateMaterials();
432}
433
434
435//_____________________________________________________________________________
436void AliCRTv0::DrawDetector()
437{
438
439}
440
441//_____________________________________________________________________________
442void AliCRTv0::DrawModule()
443{
444 //
445 // Draw a shaded view of the L3 magnet
446 //
447 cout << "AliCRTv0::DrawModule() : Drawing the module" << endl;
448
449 gMC->Gsatt("*", "seen", -1);
450 gMC->Gsatt("alic", "seen", 0);
451
452 gMC->Gsatt("ALIC","seen",0); // Mother volume, pit ceiling
453 gMC->Gsatt("L3MO","seen",1); // L3 Magnet
454 gMC->Gsatt("CRT1","seen",1); // Scintillators (air) box.
455
456 // Draw the volumes for all the hall.
457 gMC->Gsatt("CRTA","seen",1);
458 gMC->Gsatt("CRTB","seen",1);
459 gMC->Gsatt("CRTC","seen",1);
460 gMC->Gsatt("CRTD","seen",1);
461 gMC->Gsatt("CRTE","seen",1);
462 gMC->Gsatt("CRTF","seen",1);
463 gMC->Gsatt("CRTG","seen",1);
464 gMC->Gsatt("CRTH","seen",1);
465 gMC->Gsatt("CRTI","seen",1);
466 gMC->Gsatt("CRTJ","seen",1);
467 gMC->Gsatt("CRTK","seen",1);
468 gMC->Gsatt("CRTL","seen",1);
469 gMC->Gsatt("CRTM","seen",1);
470 gMC->Gsatt("CRTN","seen",1);
471 gMC->Gsatt("CRTO","seen",1);
472 gMC->Gsatt("CRTP","seen",1);
473 gMC->Gsatt("CRTQ","seen",1);
474 gMC->Gsatt("CRTR","seen",1);
475 gMC->Gsatt("CRTS","seen",1);
476
477
478 gMC->Gdopt("hide", "on");
479 gMC->Gdopt("edge","off");
480 gMC->Gdopt("shad", "on");
481 gMC->Gsatt("*", "fill", 7);
482 gMC->SetClipBox("ALIC", 0, 3000, -3000, 3000, -6000, 6000);
483 gMC->DefaultRange();
484 gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .009, .009);
485 gMC->Gdhead(1111, "View of CRT(ACORDE)");
486 gMC->Gdman(18, 4, "MAN");
487
488
489}
490
491//_____________________________________________________________________________
492void AliCRTv0::Init()
493{
494 //
495 // Initialise L3 magnet after it has been built
496 Int_t i;
497 //
498 if(fDebug) {
499 printf("\n%s: ",ClassName());
500 for(i=0;i<35;i++) printf("*");
501 printf(" CRTv0_INIT ");
502 for(i=0;i<35;i++) printf("*");
503 printf("\n%s: ",ClassName());
504 //
505 // Here the CRTv0 initialisation code (if any!)
506 for(i=0;i<80;i++) printf("*");
507 printf("\n");
508 }
509
510}
511
512//_____________________________________________________________________________
513void AliCRTv0::StepManager()
514{
515 //
516 // Called for every step in the CRT Detector
517 //
518 Float_t hits[12];
519 Int_t vol[5];
520
521 // Check if this is the last step of the track in the current volume
522 Bool_t laststepvol = gMC->IsTrackEntering();
523 // Obtain the medium
524 TLorentzVector xyz;
525 gMC->TrackPosition(xyz);
526 TLorentzVector pxyz;
527 gMC->TrackMomentum(pxyz);
528
529 if ( laststepvol && (strcmp(gMC->CurrentVolName(),"CRT1") == 0) ) {
530 if ( gMC->TrackCharge() != 0 || gMC->TrackPid() == kGamma ) {
531 Float_t vert[3];
532
533 hits[0] = fMucur++;
534
535 if ( (gMC->TrackPid() != kMuonPlus) && (gMC->TrackPid() != kMuonMinus)) {
536 hits[1] = -(Float_t)gMC->TrackPid();
537 } else {
538 hits[1] = (Float_t)gMC->TrackPid();
539 }
540
541 TLorentzVector xyz;
542 gMC->TrackPosition(xyz);
543 TLorentzVector pxyz;
544 gMC->TrackMomentum(pxyz);
545
546 hits[2] = xyz[0]; // X pit
547 hits[3] = xyz[1]; // Y pit
548 hits[4] = xyz[2]; // Z pit
549 hits[5] = pxyz[0]; // pxug
550 hits[6] = pxyz[1]; // pyug
551 hits[7] = pxyz[2]; // pzug
552
553 hits[8] = gMC->GetMedium(); // layer
554 hits[9] = vert[0]; // xver
555 hits[10] = vert[1]; // yver
556 hits[11] = vert[2]; // zver
557 }
558 }
559
560 // Store the hit.
561 AddHit(gAlice->CurrentTrack(),vol, hits);
562}