Variables renamed to avoid floating exceptions
[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$
bd1047f8 18Revision 1.4 2002/07/12 12:57:29 gamez
19Division of CRT1 corrected
20
7cedada3 21Revision 1.3.2.1 2002/07/12 12:32:50 gamez
22Division of CRT1 corrected
23
24Revision 1.3 2002/07/10 15:57:04 gamez
25CreateHall() removed, and new Molasse volumes
26
6e9adb00 27Revision 1.2 2002/07/09 08:45:35 hristov
28Old style include files needed on HP (aCC)
29
b73f53b3 30Revision 1.1 2002/06/16 17:08:19 hristov
31First version of CRT
32
fb7a1f55 33
34*/
35
36///////////////////////////////////////////////////////////////////////////////
37// //
6e9adb00 38// ALICE Cosmic Ray Trigger //
fb7a1f55 39// //
6e9adb00 40// This class contains the functions for version 0 of the ALICE Cosmic Ray //
41// Trigger. //
fb7a1f55 42//
43// Authors:
44//
45// Arturo Fernandez <afernand@fcfm.buap.mx>
46// Enrique Gamez <egamez@fcfm.buap.mx>
47//
48// Universidad Autonoma de Puebla
49//
50//
51//Begin_Html
52/*
53<img src="picts/AliCRTv0Class.gif">
54</pre>
55<br clear=left>
56<p>The responsible person for this module is
57<a href="mailto:egamez@fcfm.buap.mx">Enrique Gamez</a>.
58</font>
59<pre>
60*/
61//End_Html
62// //
63///////////////////////////////////////////////////////////////////////////////
64
b73f53b3 65#include <iostream.h>
fb7a1f55 66
67#include <TMath.h>
68#include <TGeometry.h>
69#include <TTUBE.h>
70#include <TNode.h>
71#include <TLorentzVector.h>
72
73#include "AliCRTv0.h"
74#include "AliCRTConstants.h"
75
76#include "AliRun.h"
77#include "AliMC.h"
78#include "AliMagF.h"
79#include "AliConst.h"
80#include "AliPDG.h"
81
82ClassImp(AliCRTv0)
83
84//_____________________________________________________________________________
85AliCRTv0::AliCRTv0() : AliCRT()
86{
87 //
88 // Default constructor for CRT
89 //
90 fMucur = 0;
91}
92
93//_____________________________________________________________________________
94AliCRTv0::AliCRTv0(const char *name, const char *title)
95 : AliCRT(name,title)
96{
97 //
98 // Standard constructor for CRT
99 //
100 //Begin_Html
101 /*
102 <img src="picts/AliCRTv0.gif">
103 */
104 //End_Html
105}
106
107//_____________________________________________________________________________
108void AliCRTv0::BuildGeometry()
109{
110
111}
112
113//_____________________________________________________________________________
114void AliCRTv0::CreateGeometry()
115{
116 //
117 // Create geometry for the CRT array
118 //
119
fb7a1f55 120 Int_t idrotm[2499]; // The rotation matrix.
121
fb7a1f55 122 Int_t * idtmed = fIdtmed->GetArray() - 1099 ;
123
6e9adb00 124 //
125 // Molasse
126 //
127
128 // Exactly above the hall
129 Float_t tspar[5];
130 tspar[0] = 1170.;
131 tspar[1] = 1170. + 375.;
132 tspar[2] = (1900.+1150.)/2.+100.;
133 tspar[3] = 0.;
134 tspar[4] = 180.;
7cedada3 135 gMC->Gsvolu("CMO1", "TUBS", idtmed[1123], tspar, 5);
6e9adb00 136 gMC->Gspos("CMO1", 1, "ALIC", 0., 500., 1900.-tspar[2]+400., 0, "MANY");
137
138 Float_t tbox[3];
139 tbox[0] = 1250.;
140 tbox[1] = (4420. - 1670.)/2.;
141 tbox[2] = (1900.+1150.)/2. + 200.;
7cedada3 142 gMC->Gsvolu("CM12", "BOX", idtmed[1123], tbox, 3);
6e9adb00 143 gMC->Gspos("CM12", 1, "ALIC", 0., 4420. -tbox[1], 1900.-tbox[2]+400., 0, "MANY");
144
145 AliMatrix(idrotm[2003], 0., 0., 90., 0., 90., 90.);
146 // Along the PM25
147 Float_t tube[3];
148 tube[0] = 455. + 100.;
149 tube[1] = 555. + 375.;
150 tube[2] = (5150. - 1166.)/2.;
7cedada3 151 gMC->Gsvolu("CMO2", "TUBE", idtmed[1123], tube, 3);
6e9adb00 152 gMC->Gspos("CMO2", 1, "ALIC", -2100., 4420.-tube[2], 0., idrotm[2003], "MANY");
153
154
155 // Along the PGC2
156 tube[0] = 650.;
157 tube[1] = 2987.7;
158 tube[2] = (5150. - 690.)/2.;
7cedada3 159 gMC->Gsvolu("CMO3", "TUBE", idtmed[1123], tube, 3);
6e9adb00 160 gMC->Gspos("CMO3", 1, "ALIC", 375., 4420.-tube[2], 1900.+2987.7, idrotm[2003], "MANY");
161 // Behind the PGC2 up to the end of the M. volume.
162 tbox[0] = 12073.;
163 tbox[1] = 2575. + 95.;
164 tbox[2] = (12073. - 1900.+2987.7+650.)/2.;
7cedada3 165 gMC->Gsvolu("CMO7", "BOX", idtmed[1123], tbox, 3);
6e9adb00 166 gMC->Gspos("CMO7", 1, "ALIC", 0., 4420.-tbox[1], 1900.+2987.7+650.+tbox[2], 0, "MANY");
167
168 // Along the PX24 , upper part.
169 tube[0] = 1250.;
170 tube[1] = 2300;
171 tube[2] = 2575. - 1300. + 95.;
7cedada3 172 gMC->Gsvolu("CMO4", "TUBE", idtmed[1123], tube, 3);
6e9adb00 173 gMC->Gspos("CMO4", 1, "ALIC", 0., 404.+1300.+tube[2], -2300., idrotm[2003], "MANY");
174
175 // Along the PX24 , lower part
176 tspar[0] = 1250.;
177 tspar[1] = 2300;
178 tspar[2] = 1300.;
179 tspar[3] = kRaddeg*TMath::ASin(1070./1150.);
180 tspar[4] = 360. - tspar[3];
7cedada3 181 gMC->Gsvolu("CMO5", "TUBS", idtmed[1123], tspar, 5);
6e9adb00 182 gMC->Gspos("CMO5", 1, "ALIC", 0., 404., -2300., idrotm[2003], "MANY");
183 // behind the PX24
184 tbox[0] = 12073.;
185 tbox[1] = 2575. + 95.;
186 tbox[2] = 8523./2.;
7cedada3 187 gMC->Gsvolu("CMO6", "BOX", idtmed[1123], tbox, 3);
6e9adb00 188 gMC->Gspos("CMO6", 1, "ALIC", 0., 4420.-tbox[1], -3550.-tbox[2], 0, "MANY");
189
190
191 // On the right side of th hall
192 tbox[0] = (12073. - 1250.)/2.;
193 tbox[1] = 2575. + 95.;
194 tbox[2] = (8437.7+650.)/2.;
7cedada3 195 gMC->Gsvolu("CMO8", "BOX", idtmed[1123], tbox, 3);
6e9adb00 196 gMC->Gspos("CMO8", 1, "ALIC", 1250.+tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
197
198 // on the left side of the hall, behind
199 tbox[0] = (12073. - 2755.)/2.;
200 tbox[1] = 2575. + 95.;
201 tbox[2] = (8437.7+650.)/2.;
7cedada3 202 gMC->Gsvolu("CMO9", "BOX", idtmed[1123], tbox, 3);
6e9adb00 203 gMC->Gspos("CMO9", 1, "ALIC", -2755.-tbox[0], 4420.-tbox[1], -3550.+tbox[2], 0, "MANY");
204
205
206 // Molasse betwen the PX24 & PM25 on the left side.
207 tbox[0] = (2755. - 1250.)/2.;
208 tbox[1] = 2575. + 95.;
209 tbox[2] = (3550. - 555.)/2.;
7cedada3 210 gMC->Gsvolu("CM10", "BOX", idtmed[1123], tbox, 3);
6e9adb00 211 gMC->Gspos("CM10", 1, "ALIC", -1250.-tbox[0], 4420.-tbox[1], -tbox[2]-555., 0, "MANY");
212
213
214 // Molasse betwen the PGC2 & PM25 on the left side.
215 tbox[0] = (2755. - 1250.)/2.;
216 tbox[1] = 2575. + 95.;
217 tbox[2] = (1900.+2987.7 - 555. + 650.)/2.;
7cedada3 218 gMC->Gsvolu("CM11", "BOX", idtmed[1123], tbox, 3);
6e9adb00 219 gMC->Gspos("CM11", 1, "ALIC", -1250.-tbox[0], 4420.-tbox[1], 555.+tbox[2], 0, "MANY");
220
221 //
222 // Scintillators
fb7a1f55 223
224 Float_t box[3];
225 box[0] = AliCRTConstants::fgCageLenght/2.; // Half Length of the box along the X axis, cm.
226 box[1] = AliCRTConstants::fgCageHeight/2.; // Half Length of the box along the Y axis, cm.
227 box[2] = AliCRTConstants::fgCageWidth/2.; // Half Length of the box along the Z axis, cm.
228
229
230 // Define the Scintillators. as a big box.
231 Float_t scint[3];
232 scint[0] = AliCRTConstants::fgActiveAreaLenght/2.; // Half Length in X
233 scint[1] = AliCRTConstants::fgActiveAreaHeight/2.; // Half Length in Y
234 scint[2] = AliCRTConstants::fgActiveAreaWidth/2.; // Half Length in Z
bd1047f8 235 gMC->Gsvolu("CRT1", "BOX ", idtmed[1112], scint, 3); // Scintillators
fb7a1f55 236 // Divide the modules in 2 planes.
6e9adb00 237 gMC->Gsdvn("CRT2", "CRT1", 2, 2);
fb7a1f55 238 // Now divide each plane in 8 palettes
7cedada3 239 gMC->Gsdvn("CRT3", "CRT2", 8, 3);
fb7a1f55 240
241
242 //
243 // Define the coordinates where the draw will begin.
244 //
245
246 //
247 // -- X axis.
248 // we'll start dawing from the center.
249 Float_t initX = 0.;
250
251 //
252 // -- Y axis
253 Float_t gapY = 30.; // 30 cms. above the barrel.
254 // For the height we staimate the from the center of the ceiling,
255 // if were a cilinder, must be about 280cm.
256 Float_t barrel = 790.; // Barrel radius.
257 Float_t height = barrel + gapY - 30.;
258 Float_t initY = height;
259
260 //
261 // -- Z axis.
262 // we'll start dawing from the center.
263
264 //
265 // Put 4 modules on the top of the magnet
266 Int_t step = 4;
267 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
6e9adb00 268 gMC->Gspos("CRT1", i, "ALIC", initX, initY, (i-step)*box[2], 0, "ONLY");
fb7a1f55 269 step--;
270 }
271
272 // Modules on the barrel sides.
273 // Because the openenig angle for each face is 22.5, and if we want to
274 // put the modules right in the middle
275 Float_t xtragap = 10.;
276 Float_t initXside = (height+xtragap)*TMath::Sin(2*22.5*kDegrad); //rigth side
277 Float_t initYside = (height+xtragap)*TMath::Cos(2*22.5*kDegrad);
278
279 // Put 4 modules on the left side of the magnet
280 // The rotation matrix parameters, for the left side.
281 AliMatrix(idrotm[232], 90., 315., 90., 45., 0., 337.5);
282 Int_t stepl = 4;
283 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
6e9adb00 284 gMC->Gspos("CRT1", i+4, "ALIC", initXside, initYside, (i-stepl)*box[2],
fb7a1f55 285 idrotm[232], "ONLY");
286 stepl--;
287 }
288
289 // Put 4 modules on the right side of the magnet
290 // The rotation matrix parameters for the right side.
291 AliMatrix(idrotm[231], 90., 45., 90., 315., 180., 202.5);
292 Int_t stepr = 4;
293 for ( Int_t i = 1 ; i <= 4 ; i++ ) {
6e9adb00 294 gMC->Gspos("CRT1", i+8, "ALIC", -initXside, initYside, (i-stepr)*box[2],
fb7a1f55 295 idrotm[231], "ONLY");
296 stepr--;
297 }
298
299}
300
fb7a1f55 301//_____________________________________________________________________________
302void AliCRTv0::CreateMaterials()
303{
304 //
305 //--
306 //
307
308 // Use the standard materials.
309 AliCRT::CreateMaterials();
310}
311
312
313//_____________________________________________________________________________
314void AliCRTv0::DrawDetector()
315{
316
317}
318
319//_____________________________________________________________________________
320void AliCRTv0::DrawModule()
321{
322 //
323 // Draw a shaded view of the L3 magnet
324 //
325 cout << "AliCRTv0::DrawModule() : Drawing the module" << endl;
326
327 gMC->Gsatt("*", "seen", -1);
328 gMC->Gsatt("alic", "seen", 0);
329
6e9adb00 330 gMC->Gsatt("ALIC","seen",0);
fb7a1f55 331 gMC->Gsatt("L3MO","seen",1); // L3 Magnet
6e9adb00 332 gMC->Gsatt("CRT1","seen",1); // Scintillators
333
334 // Draw the molasse volumes
335 gMC->Gsatt("CMO1","seen",0); // Exactly above the HALL
336 gMC->Gsatt("CMO2","seen",0); // Molasse, along the PM25
337 gMC->Gsatt("CMO3","seen",0); // molasse along the PGC2
338 gMC->Gsatt("CMO4","seen",0); // Molasse, behind the PX24 upper part
339 gMC->Gsatt("CMO5","seen",0); // molasse behind px24, lower part
340 gMC->Gsatt("CMO6","seen",0); // behind the PX24
341 gMC->Gsatt("CMO7","seen",0); // behind the PGC2
342 gMC->Gsatt("CMO8","seen",0); // on the right side.
343 gMC->Gsatt("CMO9","seen",0); // on the left side.
344 gMC->Gsatt("CM10","seen",0); // betwen PX24 & PM25.
345 gMC->Gsatt("CM11","seen",0); // betwen PGC2 & PM25.
346 gMC->Gsatt("CM12","seen",0); // box above the hall.
fb7a1f55 347
348 gMC->Gdopt("hide", "on");
349 gMC->Gdopt("edge","off");
350 gMC->Gdopt("shad", "on");
351 gMC->Gsatt("*", "fill", 7);
352 gMC->SetClipBox("ALIC", 0, 3000, -3000, 3000, -6000, 6000);
353 gMC->DefaultRange();
354 gMC->Gdraw("alic", 40, 30, 0, 10, 9.5, .009, .009);
355 gMC->Gdhead(1111, "View of CRT(ACORDE)");
356 gMC->Gdman(18, 4, "MAN");
357
358
359}
360
361//_____________________________________________________________________________
362void AliCRTv0::Init()
363{
364 //
365 // Initialise L3 magnet after it has been built
366 Int_t i;
367 //
368 if(fDebug) {
369 printf("\n%s: ",ClassName());
370 for(i=0;i<35;i++) printf("*");
371 printf(" CRTv0_INIT ");
372 for(i=0;i<35;i++) printf("*");
373 printf("\n%s: ",ClassName());
374 //
375 // Here the CRTv0 initialisation code (if any!)
376 for(i=0;i<80;i++) printf("*");
377 printf("\n");
378 }
379
380}
381
382//_____________________________________________________________________________
383void AliCRTv0::StepManager()
384{
385 //
386 // Called for every step in the CRT Detector
387 //
388 Float_t hits[12];
389 Int_t vol[5];
390
391 // Check if this is the last step of the track in the current volume
392 Bool_t laststepvol = gMC->IsTrackEntering();
393 // Obtain the medium
394 TLorentzVector xyz;
395 gMC->TrackPosition(xyz);
396 TLorentzVector pxyz;
397 gMC->TrackMomentum(pxyz);
398
399 if ( laststepvol && (strcmp(gMC->CurrentVolName(),"CRT1") == 0) ) {
bd1047f8 400 if ( gMC->TrackCharge() != 0 || gMC->TrackPid() == kGamma ) {
401 Float_t vert[3];
402
403 hits[0] = fMucur++;
404
405 if ( (gMC->TrackPid() != kMuonPlus)
406 && (gMC->TrackPid() != kMuonMinus)) {
407 hits[1] = -(Float_t)gMC->TrackPid();
408 } else {
409 hits[1] = (Float_t)gMC->TrackPid();
410 }
411
412 TLorentzVector xyz;
413 gMC->TrackPosition(xyz);
414 TLorentzVector pxyz;
415 gMC->TrackMomentum(pxyz);
416
417 hits[2] = xyz[0]; // X pit
418 hits[3] = xyz[1]; // Y pit
419 hits[4] = xyz[2]; // Z pit
420 hits[5] = pxyz[0]; // pxug
421 hits[6] = pxyz[1]; // pyug
422 hits[7] = pxyz[2]; // pzug
423
424 hits[8] = gMC->GetMedium(); // layer
425 hits[9] = vert[0]; // xver
426 hits[10] = vert[1]; // yver
427 hits[11] = vert[2]; // zver
428 // Store the hit.
429 AddHit(gAlice->CurrentTrack(),vol, hits);
fb7a1f55 430 }
fb7a1f55 431 }
fb7a1f55 432}
bd1047f8 433
434