]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEv0.cxx
bugfix: corrected defines to use right default algorithms
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEv0.cxx
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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // ALICE Cosmic Ray Trigger                                                  //
21 //                                                                           //
22 //  This class contains the functions for version 0 of the ALICE Cosmic Ray  //
23 //  Trigger. This version will be used to simulation comic rays in alice with//
24 //  all the detectors. It include geometry and hits (posicion and momentum)  //
25 //                                                                           //
26 //                  Send comments to:                                        //
27 //      Arturo Fernandez <afernand@fcfm.buap.mx>                             //
28 //      Enrique Gamez    <egamez@fcfm.buap.mx>                               //
29 //      Eleazar Cuautle  <ecuautle@nucleares.unam.mx>                        //
30 ///////////////////////////////////////////////////////////////////////////////
31
32
33 #include "AliACORDEv0.h"
34 #include <TClonesArray.h>
35 #include <TLorentzVector.h>
36 #include <TVirtualMC.h>
37 #include <TPDGCode.h>
38 #include <TGeometry.h>
39 #include <TBRIK.h>
40 #include <TNode.h>
41
42
43 #include "AliRun.h"
44 #include "AliConst.h"
45 #include "AliACORDEhit.h"
46 #include "AliACORDEConstants.h"
47 #include "AliMC.h"
48 #include "AliLog.h"
49
50 ClassImp(AliACORDEv0)
51  
52 //_____________________________________________________________________________
53 AliACORDEv0::AliACORDEv0()
54   : AliACORDE()
55 {
56   //
57   // Default constructor
58   fIshunt = 0;
59   fHits = 0;
60   //
61
62 //_____________________________________________________________________________
63 AliACORDEv0::AliACORDEv0(const char *name, const char *title)
64   : AliACORDE(name, title)
65 {
66   //
67   // Standard constructor
68   //
69   fIshunt = 1; // All hits are associated with primary particles 
70   fHits =  new TClonesArray("AliACORDEhit",400);
71   gAlice->GetMCApp()->AddHitList(fHits);
72 }
73 //_____________________________________________________________________________
74 AliACORDEv0::~AliACORDEv0()
75 {
76   //
77   // Default destructor
78   //
79 }
80 //_____________________________________________________________________________
81 void AliACORDEv0::BuildGeometry()
82 {
83
84   // not needed anymore
85
86 }
87
88 //_____________________________________________________________________________
89 void AliACORDEv0::CreateGeometry()
90 {
91   CreateAcorde();
92   if (GetCreateCavern()) CreateCavern();
93 }
94
95 void AliACORDEv0::CreateCavern()
96 {
97   Int_t* idtmed = fIdtmed->GetArray() - 1099 ;
98     // Create the mother volume, the one which will contain all the material
99   // above the hall.
100   Float_t pbox[3];
101   pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
102   //pbox[0] = 12073;
103   pbox[1] = AliACORDEConstants::Instance()->Depth();
104   pbox[2] = pbox[0];
105   gMC->Gsvolu("ACORDE", "BOX", idtmed[1114], pbox, 3);
106   gMC->Gspos("ACORDE", 1, "ALIC", 0, 0, 0, 0, "ONLY");
107   CreateShafts();
108   CreateMolasse();
109 }
110
111 void AliACORDEv0::CreateShafts()
112
113 {
114
115   //
116   Int_t  idrotm[2499];    // The rotation matrix.
117   Int_t* idtmed = fIdtmed->GetArray() - 1099 ;
118
119   //
120   // Acces shafts
121   //
122   AliMatrix(idrotm[2001], 0, 0, 90, 0, 90, 90);
123
124
125   // Create a bing cilinder to hold the main structures in the shaft.
126   //   All the structures relative to the shaft will be put into
127   // this volume.
128   //   This shaft is composed by an open tube down in the hall, and
129   // a cilinder avobe the level of the ceiling.
130   Float_t ptube[3];
131   ptube[0] = 0;    // inner radius
132   ptube[1] = 1250; // outer radius
133   ptube[2] = 5150/2; // Half lenght in Z
134   gMC->Gsvolu("CSF1", "TUBE", idtmed[1114], ptube, 3);
135
136   Float_t ptubs[5];
137   // The open section of the PX24
138   ptubs[0] = 1150; // Inner radius
139   ptubs[1] = 1250; // Outer radius
140   ptubs[2] = 1300; // Half length
141   ptubs[3] = 180 + kRaddeg*TMath::ASin(1070/ptubs[0]); // starting angle
142   ptubs[4] = 180 -  kRaddeg*TMath::ASin(1070/ptubs[0]);
143   gMC->Gsvolu("CSF2", "TUBS", idtmed[1116], ptubs, 5);
144   gMC->Gspos("CSF2", 1, "CSF1", 0, 0, -ptube[2] + ptubs[2], 0, "MANY");
145
146   // The other part of the shaft.
147   ptube[0] = ptubs[0]; // Inner radius
148   ptube[1] = ptubs[1]; // Outer radius
149   ptube[2] = 5150/2 - ptubs[2]; // Half lenght
150   gMC->Gsvolu("CSF3", "TUBE", idtmed[1116], ptube, 3);
151   gMC->Gspos("CSF3", 1, "CSF1", 0, 0, 5150/2 - ptube[2], 0, "MANY");
152
153   Float_t pbox[3];
154   // Concrete walls along the shaft (next to the elevator.)
155   pbox[0] = 480/2;  // Half length in X
156   pbox[1] = 120/2;  // Half length in Y
157   pbox[2] = 5150/2; // Half length in Z
158   gMC->Gsvolu("CSW1", "BOX", idtmed[1116], pbox, 3);
159   gMC->Gspos("CSW1", 1, "CSF1", 820+pbox[0],  150+pbox[1], 0, 0, "MANY");
160   gMC->Gspos("CSW1", 2, "CSF1", 820+pbox[0], -300-pbox[1], 0, 0, "MANY");
161
162   //
163   pbox[0] = 120/2;  // Half length in X
164   pbox[1] = 750/2;  // Half length in Y
165   pbox[2] = 5150/2; // Half length in Z
166   gMC->Gsvolu("CSW2", "BOX", idtmed[1116], pbox, 3);
167   gMC->Gspos("CSW2", 1, "CSF1", 820-60, 150+pbox[1], 0, 0, "MANY");
168
169   //
170   pbox[0] = 120/2;  // Half length in X
171   pbox[1] = 600/2;  // Half lenght in Y
172   pbox[2] = 5150/2; // Half length in Z
173   gMC->Gsvolu("CSW3", "BOX", idtmed[1116], pbox, 3);
174   gMC->Gspos("CSW3", 1, "CSF1", 820-60, -300-pbox[1], 0, 0, "MANY");
175
176   // Material below the counting rooms.
177   pbox[0] = 400/2;
178   pbox[1] = 2300/2;
179   pbox[2] = 300/2;
180   gMC->Gsvolu("CSW4", "BOX", idtmed[1116], pbox, 3);
181   gMC->Gspos("CSW4",1,"CSF1",2300/2-pbox[0],0,3000-5150/2-pbox[2], 0, "MANY");
182
183   // Shielding plug.
184   pbox[0] = 1400/2;
185   pbox[1] = 2300/2;
186   pbox[2] = 170/2;
187   gMC->Gsvolu("CSW5", "BOX", idtmed[1116], pbox, 3);
188   gMC->Gspos("CSW5", 1, "CSF1", 0, 0, 3000-5150/2-130, 0, "MANY");
189
190   // The end of the support for the shielding plug.
191   pbox[0] = 170/2;
192   pbox[1] = 2300/2;
193   pbox[2] = 300/2;
194   gMC->Gsvolu("CSW6", "BOX", idtmed[1116], pbox, 3);
195   gMC->Gspos("CSW6",1,"CSF1",-1400/2-pbox[0],0,3000-5150/2-pbox[2],0,"MANY");
196
197   // ...
198   pbox[0] = 100/2;
199   pbox[1] = 2300/2;
200   pbox[2] = 450/2;
201   gMC->Gsvolu("CSW7", "BOX", idtmed[1116], pbox, 3);
202   gMC->Gspos("CSW7",1,"CSF1",-1400/2-170-pbox[0],0,3000-5150/2+pbox[2],0,"MANY");
203
204   // Material close to the pipe.
205   pbox[0] = 300/2;
206   pbox[1] = 2300/2;
207   pbox[2] = 170/2;
208   gMC->Gsvolu("CSW8", "BOX", idtmed[1116], pbox, 3);
209   gMC->Gspos("CSW8",1,"CSF1",-2300/2+pbox[0],0,2500-5150/2,0,"MANY");
210
211   // Now put the shaft into the mother volume.
212   gMC->Gspos("CSF1", 1, "ACORDE", 0, AliACORDEConstants::Instance()->Depth() - 5150/2, 2300, idrotm[2001], "MANY");
213
214   // PM25 Access Shaft
215   ptube[0] = 910/2;
216   ptube[1] = ptube[0] + 100;
217   ptube[2] = (5150 - 1166)/2;
218   gMC->Gsvolu("CSF4", "TUBE", idtmed[1116], ptube, 3);
219   gMC->Gspos("CSF4", 1, "ACORDE", 2100, AliACORDEConstants::Instance()->Depth()-ptube[2], 0, idrotm[2001], "MANY");
220
221   // PGC2 Access Shaft
222   ptube[0] = 1100/2;
223   ptube[1] = ptube[0] + 100;
224   ptube[2] = (5150 - 690)/2;
225   gMC->Gsvolu("CSF5", "TUBE", idtmed[1116], ptube, 3);
226   gMC->Gspos("CSF5", 1, "ACORDE", -375, AliACORDEConstants::Instance()->Depth()-ptube[2], -1900 - 2987.7, idrotm[2001], "MANY");
227
228 }
229
230
231 void AliACORDEv0::CreateMolasse()
232
233 {
234
235   //
236   Int_t  idrotm[2499];    // The rotation matrix.
237   Int_t* idtmed = fIdtmed->GetArray() - 1099 ;
238
239   Float_t px24radius = 2300/2;
240   Float_t px24X = 0;
241   //Float_t px24Y = ;
242   Float_t px24Z = 2300;
243
244   Float_t pm25radius = 910/2;
245   Float_t pm25X = 2100;
246   //Float_t pm25Y = ;
247   Float_t pm25Z = 0;
248
249   Float_t pgc2radius = 1100/2;
250   Float_t pgc2X = -375;
251   //Float_t pgc2Y = ;
252   Float_t pgc2Z = -(1900 + 2987.7);
253
254   Float_t concreteWidth = 100; // Standard width of the hall walls.
255
256
257   // Create a local mother volume.
258   Float_t pbox[3];
259   pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
260   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
261   pbox[2] = pbox[0];
262   gMC->Gsvolu("CMO1", "BOX", idtmed[1114], pbox, 3);
263
264   // Now put the molasse exactly above the hall. OK
265   // Above the ceiling
266   Float_t ptubs[5];
267   ptubs[0] = 1170;
268   ptubs[1] = 2100 - pm25radius;
269   ptubs[2] = 1900/2 + px24radius;
270   ptubs[3] = 0;
271   ptubs[4] = 180;
272   gMC->Gsvolu("CMO2", "TUBS", idtmed[1123], ptubs, 5);
273   gMC->Gspos("CMO2", 1, "CMO1", 0, 500-AliACORDEConstants::Instance()->Depth()/2, ptubs[2]-1900, 0, "MANY");
274
275   // Molasse around the RB24/26 Wall. OK
276   ptubs[0] = 220 + 1600;
277   ptubs[1] = AliACORDEConstants::Instance()->Depth() - ptubs[0];
278   ptubs[2] = 2987.7/2 - 1100/4 - concreteWidth/2;
279   ptubs[3] = 0;
280   ptubs[4] = 180;
281   gMC->Gsvolu("CMO3", "TUBS", idtmed[1123], ptubs, 5);
282   gMC->Gspos("CMO3", 1, "CMO1", 70, 40-AliACORDEConstants::Instance()->Depth()/2, -1900 - ptubs[2], 0, "MANY");
283
284   // A big block above the RB24/26 wall. OK
285   pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
286   pbox[1] = (AliACORDEConstants::Instance()->Depth() - 220 - 1600)/2;
287   pbox[2] = 2987.7/2 - 1100/4 - concreteWidth/2;
288   gMC->Gsvolu("CMO4", "BOX", idtmed[1123], pbox, 3);
289   gMC->Gspos("CMO4", 1, "CMO1", 0, AliACORDEConstants::Instance()->Depth()/2 - pbox[1], -1900 - pbox[2], 0, "MANY");
290   // Small blocks below the volume CMO4 on both sides of the wall RB24/26. OK
291   pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) -
292 ptubs[0])/2;
293   pbox[1] = AliACORDEConstants::Instance()->Depth()/2 - pbox[1];
294   gMC->Gsvolu("CM17", "BOX", idtmed[1123], pbox, 3);
295   gMC->Gspos("CM17", 1, "CMO1", AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) - pbox[0], -AliACORDEConstants::Instance()->Depth()/2 + pbox[1], -1900 - pbox[2], 0, "MANY");
296   gMC->Gspos("CM17", 2, "CMO1", -AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)+ pbox[0], -AliACORDEConstants::Instance()->Depth()/2 + pbox[1], -1900 - pbox[2], 0, "MANY");
297
298   // And a big block of molasse above the hall up to the surface. OK
299   pbox[0] = pm25X - pm25radius;
300   pbox[1] = (AliACORDEConstants::Instance()->Depth()-500-1170)/2;
301   pbox[2] = (1900 + 1150)/2;
302   gMC->Gsvolu("CMO5", "BOX", idtmed[1123], pbox, 3);
303   gMC->Gspos("CMO5", 1, "CMO1", 0,AliACORDEConstants::Instance()->Depth()/2-pbox[1], pbox[2]-1900, 0, "MANY");
304   // Small blocks of molasse betwen the blocks CMO2, CMO5 and PM25. Ok
305   pbox[0] = (pm25X - pm25radius - 1170)/2;
306   pbox[1] = 1000;
307   gMC->Gsvolu("CM16", "BOX", idtmed[1123], pbox, 3);
308   gMC->Gspos("CM16", 1, "CMO1", 1170 + pbox[0], -AliACORDEConstants::Instance()->Depth()/2+pbox[1], pbox[2] - 1900, 0, "MANY");
309
310   // Molasse around the shafts.
311   AliMatrix(idrotm[2003], 0, 0, 90, 0, 90, 90);
312   // Around the PX24, the open section. OK
313   ptubs[0] = px24radius + concreteWidth;
314   ptubs[1] = ptubs[0] + 1000;
315   ptubs[2] = (2300 - (5150 - AliACORDEConstants::Instance()->Depth()))/2;
316   ptubs[3] = 180 + kRaddeg*TMath::ASin(1070/ptubs[0]);
317   ptubs[4] = 180 -  kRaddeg*TMath::ASin(1070/ptubs[0]);
318   gMC->Gsvolu("CMO6", "TUBS", idtmed[1123], ptubs, 5);
319   gMC->Gspos("CMO6", 1, "CMO1", px24X, ptubs[2] - AliACORDEConstants::Instance()->Depth()/2, px24Z, idrotm[2003], "MANY");
320   // Around the PX24, the closed section. OK
321   Float_t ptube[3];
322   ptube[0] = px24radius + concreteWidth;
323   ptube[1] = ptube[0] + 1000;
324   ptube[2] = (5150 - 2300)/2;
325   gMC->Gsvolu("CMO7", "TUBE", idtmed[1123], ptube, 3);
326   gMC->Gspos("CMO7", 1, "CMO1", px24X, AliACORDEConstants::Instance()->Depth()/2 - ptube[2], px24Z, idrotm[2003], "MANY");
327
328   // Around PM25. OK
329   ptube[0] = pm25radius + concreteWidth;
330   ptube[1] = ptube[0] + 400;
331   ptube[2] = AliACORDEConstants::Instance()->Depth()/2;
332   gMC->Gsvolu("CMO8", "TUBE", idtmed[1123], ptube, 3);
333   gMC->Gspos("CMO8", 1, "CMO1", pm25X, 0, pm25Z, idrotm[2003], "MANY");
334   // On both sides of the PM25 along the HALL.
335   pbox[0] = (2100 + pm25radius - 1170)/2;
336   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
337   pbox[2] = (3*px24radius - pm25radius)/2;
338   gMC->Gsvolu("CM18", "BOX", idtmed[1123], pbox, 3);
339   gMC->Gspos("CM18", 1, "CMO1", 2100, 0, pbox[2] + pm25radius, 0, "MANY");
340
341   pbox[2] = (1900 - pm25radius)/2;
342   gMC->Gsvolu("CM19", "BOX", idtmed[1123], pbox, 3);
343   gMC->Gspos("CM19", 1, "CMO1", 2100, 0, -pbox[2] - pm25radius, 0, "MANY");
344
345   // Around the PGC2. OK
346   ptube[0] = pgc2radius + concreteWidth;
347   ptube[1] = 2987.7 - 740;
348   ptube[2] = AliACORDEConstants::Instance()->Depth()/2;
349   gMC->Gsvolu("CMO9", "TUBE", idtmed[1123], ptube, 3);
350   gMC->Gspos("CMO9", 1, "CMO1", pgc2X, 0, pgc2Z, idrotm[2003], "MANY");
351
352   // On both sides of the PGC2.OK
353   pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) -
354 1100 - 375)/2;
355   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
356   pbox[2] = pgc2radius + concreteWidth;
357   gMC->Gsvolu("CM10", "BOX", idtmed[1123], pbox, 3);
358   gMC->Gspos("CM10", 1, "CMO1", AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) - pbox[0], 0, pgc2Z, 0, "MANY");
359   gMC->Gspos("CM10", 2, "CMO1", -AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) + pbox[0], 0, pgc2Z, 0, "MANY");
360
361   // big block of molasse behind the PX24. OK
362   pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
363   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
364   pbox[2] = (pbox[0] - (2300 + 1150 + 100))/2;
365   gMC->Gsvolu("CM12", "BOX", idtmed[1123], pbox, 3);
366   gMC->Gspos("CM12", 1, "CMO1", px24X, 0, px24Z + px24radius + concreteWidth + pbox[2], 0, "MANY");
367
368   // big block of molasse in the opposite side of the PM25. OK
369   pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) -
370 1150)/2;
371   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
372   pbox[2] = (1900 + 2300 + 1150)/2;
373   gMC->Gsvolu("CM13", "BOX", idtmed[1123], pbox, 3);
374   gMC->Gspos("CM13", 1, "CMO1", -1150 - pbox[0], 0, pbox[2] - 1900, 0, "MANY");
375
376   // big block of molasse behind the PM25. OK
377   pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) -
378 (2100 + 910/2 + 100))/2;
379   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
380   pbox[2] = (1900 + 2300 + 1150)/2;
381   gMC->Gsvolu("CM14", "BOX", idtmed[1123], pbox, 3);
382   gMC->Gspos("CM14", 1, "CMO1", pm25X + pm25radius + concreteWidth + pbox[0], 0, pbox[2] - 1900, 0, "MANY");
383
384   // big block of molasse behind the PGC2. OK
385   pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
386   pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
387   pbox[2] = (pbox[0] - (2987.7 + 1900 + 1100/2 + 100))/2;
388   gMC->Gsvolu("CM15", "BOX", idtmed[1123], pbox, 3);
389   gMC->Gspos("CM15", 1, "CMO1", 0, 0, -pbox[0] + pbox[2], 0, "MANY");
390
391   gMC->Gspos("CMO1",1,"ACORDE",0,AliACORDEConstants::Instance()->Depth()/2,0,0,"MANY");
392
393 }
394
395 void AliACORDEv0::CreateAcorde()
396 {
397   //
398   // Create geometry for the ACORDE array
399   // done in two main steps
400   //  1.- definition of the modules
401   //  2.- placement of the modules
402   //
403   Int_t  idrotm[2499];    // The rotation matrix.
404   Int_t* idtmed = fIdtmed->GetArray() - 1099;
405   AliACORDEConstants* constants = AliACORDEConstants::Instance();
406   Float_t box[3];
407   Float_t placed_at;
408   Float_t placed_at2;
409   Float_t small = 0.05; // to separate slightly some volumes
410                         // by half a mm so that they do not overlap
411
412
413   // 1.- Definition of a module
414   // *  ACORDE1 => volume filled with air, representing a module
415   //               it contains all other volumes defining the module
416   //               there are 60 copies of it
417   // *  ACORDE2 => volume defining one scintillator pad
418   //               there are 2 copies of it per module
419   // *  ACORDE3-6 => volumes representing the Al walls of box
420   //               surrounding the plastic
421   //               3: long wall, 2 copies (front, back)
422   //               4: end caps, 2 copies (left, right)
423   //               5: long stripe to model the profile 
424   //                  4 copies (upper front and back, lower)
425   //               6: short stripe to model the profile
426   //                  4 copies (upper left, right; lower)
427
428   // The full module volume.
429   // This volume will be ocupied by all the material of the module
430   // the scintillators, the aluminium frame, etc.
431   box[0] = constants->ModuleLength()/2;
432   box[1] = constants->ModuleHeight()/2;
433   box[2] = constants->ModuleWidth()/2;
434   gMC->Gsvolu("ACORDE1", "BOX", idtmed[1114], box, 3);
435
436   // The scintillators
437   box[0] = constants->PlasticLength()/2;
438   box[1] = constants->PlasticHeight()/2;
439   box[2] = constants->PlasticWidth()/2;
440   gMC->Gsvolu("ACORDE2", "BOX", idtmed[1112], box, 3);
441
442   // it is important to keep this order for easy assignment of 
443   // a volume to a physical module:
444   placed_at = box[1]+constants->ProfileThickness()
445     - constants->ModuleHeight()/2+small;
446   gMC->Gspos("ACORDE2", 1, "ACORDE1", 0, placed_at, 0, 0, "MANY");
447   placed_at = placed_at + 2.0*box[1]+small;
448   gMC->Gspos("ACORDE2", 2, "ACORDE1", 0, placed_at, 0, 0, "MANY");
449
450
451   // The metallic frame: long walls of box
452   // back,front,left,right, defined looking
453   // from the + z diraction into alice; i.e.
454   // back ==> z<0, front ==> z>0
455   // left ==> x<0, right ==> x>0
456   // up ==> increasing y, down ==> decreasing y
457   box[0] = constants->ModuleLength()/2;
458   box[1] = constants->ModuleHeight()/2;
459   box[2] = constants->ProfileThickness()/2.0; 
460   gMC->Gsvolu("ACORDE3", "BOX", idtmed[1108], box, 3);
461   // front wall
462   placed_at = constants->ModuleWidth()/2-constants->ProfileThickness()/2.0;
463   gMC->Gspos("ACORDE3", 1, "ACORDE1", 0, 0, placed_at, 0, "MANY");
464   // back wall
465   gMC->Gspos("ACORDE3", 2, "ACORDE1", 0, 0, -placed_at , 0, "MANY");
466
467   // The metallic frame: end caps
468   box[0] = constants->ProfileThickness()/2.0;
469   box[1] = constants->ModuleHeight()/2;
470   box[2] = constants->ModuleWidth()/2;
471   gMC->Gsvolu("ACORDE4", "BOX", idtmed[1108], box, 3);
472   // right cap
473   placed_at = constants->ModuleLength()/2-constants->ProfileThickness()/2.0;
474   gMC->Gspos("ACORDE4", 1, "ACORDE1", placed_at, 0, 0, 0, "MANY");
475   // left cap
476   gMC->Gspos("ACORDE4", 2, "ACORDE1", -placed_at, 0, 0, 0, "MANY");
477
478   // The metallic frame: the profile, long stripes
479   box[0] = constants->ModuleLength()/2.0;
480   box[1] = constants->ProfileThickness()/2;
481   box[2] = constants->ProfileWidth()/2;
482   gMC->Gsvolu("ACORDE5", "BOX", idtmed[1108], box, 3);
483   // upper front
484   placed_at = constants->ModuleHeight()/2-box[1];
485   placed_at2 = constants->ModuleWidth()/2-
486     constants->ProfileThickness()-box[2];
487   gMC->Gspos("ACORDE5", 1, "ACORDE1",0,placed_at,placed_at2, 0, "MANY");
488   // upper back
489   gMC->Gspos("ACORDE5", 2, "ACORDE1",0,placed_at,-placed_at2, 0, "MANY");
490   // lower front
491   gMC->Gspos("ACORDE5", 3, "ACORDE1",0,-placed_at,placed_at2, 0, "MANY");
492   // lower back
493   gMC->Gspos("ACORDE5", 4, "ACORDE1",0,-placed_at,-placed_at2, 0, "MANY");
494
495   // The metallic frame: the profile, long stripes
496   box[0] = constants->ProfileWidth()/2.0;
497   box[1] = constants->ProfileThickness()/2;
498   box[2] = constants->ModuleWidth()/2-constants->ProfileWidth();
499   gMC->Gsvolu("ACORDE6", "BOX", idtmed[1108], box, 3);
500   // upper right
501   placed_at = constants->ModuleHeight()/2-box[1];
502   placed_at2 = constants->ModuleLength()/2-
503     constants->ProfileThickness()-box[0];
504   gMC->Gspos("ACORDE6", 1, "ACORDE1",placed_at2,placed_at,0, 0, "MANY");
505   // upper left
506   gMC->Gspos("ACORDE6", 2, "ACORDE1",-placed_at2,placed_at,0, 0, "MANY");
507   // lower right
508   gMC->Gspos("ACORDE6", 3, "ACORDE1",placed_at2,-placed_at,0, 0, "MANY");
509   // lower left
510   gMC->Gspos("ACORDE6", 4, "ACORDE1",-placed_at2,-placed_at,0, 0, "MANY");
511
512   // End of MODULE definition
513
514   ////////////////////////////////////////////////////////////////////
515   ////////////////////////////////////////////////////////////////////
516
517   // 2.- placement of the module
518   // Now put all of them in the right position in 
519   // master volume ALIC
520
521   // rotation matrices (see Geant manual for conventions)
522   // for columns 4 and 5
523   AliMatrix(idrotm[231], 90, 45, 90, 135, 0, 0);
524   // for columns 0 and 1
525   AliMatrix(idrotm[232], 90, 315, 90, 45, 0, 0);
526
527   // place each one of the 6 columns in turn
528   // for the first and the last column the position
529   // of the two last modules depends on the value 
530   // of the fITSGeometry variable
531
532   // it is important to keep this order because
533   // the copy number defines the module!
534
535   // first column, except first and last  modules
536   for (Int_t copy = 2; copy < 10; copy++)
537     gMC->Gspos("ACORDE1",copy,"ALIC",
538                constants->ModulePositionX(copy-1),
539                constants->ModulePositionY(copy-1),
540                constants->ModulePositionZ(copy-1),
541                idrotm[232], "MANY");
542   // second column
543   for (Int_t copy = 11; copy < 21; copy++)
544     gMC->Gspos("ACORDE1",copy,"ALIC",
545                constants->ModulePositionX(copy-1),
546                constants->ModulePositionY(copy-1),
547                constants->ModulePositionZ(copy-1),
548                idrotm[232], "MANY");
549   // third and fourth columns
550   for (Int_t copy = 21; copy < 41; copy++)
551     gMC->Gspos("ACORDE1",copy,"ALIC",
552                constants->ModulePositionX(copy-1),
553                constants->ModulePositionY(copy-1),
554                constants->ModulePositionZ(copy-1),
555                0, "MANY");
556   // fifth column
557   for (Int_t copy = 41; copy < 51; copy++)
558     gMC->Gspos("ACORDE1",copy,"ALIC",
559                constants->ModulePositionX(copy-1),
560                constants->ModulePositionY(copy-1),
561                constants->ModulePositionZ(copy-1),
562                idrotm[231], "MANY");
563   // last column, except first and last  modules
564   for (Int_t copy = 52; copy < 60; copy++)
565     gMC->Gspos("ACORDE1",copy,"ALIC",
566                constants->ModulePositionX(copy-1),
567                constants->ModulePositionY(copy-1),
568                constants->ModulePositionZ(copy-1),
569                idrotm[231], "MANY");
570   // the last four modules
571   if (GetITSGeometry()) {
572     gMC->Gspos("ACORDE1",1,"ALIC",
573                constants->ExtraModulePositionX(),
574                constants->ExtraModulePositionY(),
575                constants->ExtraModulePositionZ(0),
576                0, "MANY");  
577     gMC->Gspos("ACORDE1",10,"ALIC",
578                constants->ExtraModulePositionX(),
579                constants->ExtraModulePositionY(),
580                constants->ExtraModulePositionZ(1),
581                0, "MANY");  
582     gMC->Gspos("ACORDE1",51,"ALIC",
583                constants->ExtraModulePositionX(),
584                constants->ExtraModulePositionY(),
585                constants->ExtraModulePositionZ(2),
586                0, "MANY");  
587     gMC->Gspos("ACORDE1",60,"ALIC",
588                constants->ExtraModulePositionX(),
589                constants->ExtraModulePositionY(),
590                constants->ExtraModulePositionZ(3),
591                0, "MANY");  
592   } else {
593     gMC->Gspos("ACORDE1",1,"ALIC",
594                constants->ModulePositionX(0),
595                constants->ModulePositionY(0),
596                constants->ModulePositionZ(0),
597                idrotm[232], "MANY");
598     gMC->Gspos("ACORDE1",10,"ALIC",
599                constants->ModulePositionX(9),
600                constants->ModulePositionY(9),
601                constants->ModulePositionZ(9),
602                idrotm[232], "MANY");
603     gMC->Gspos("ACORDE1",51,"ALIC",
604                constants->ModulePositionX(50),
605                constants->ModulePositionY(50),
606                constants->ModulePositionZ(50),
607                idrotm[231], "MANY");
608     gMC->Gspos("ACORDE1",60,"ALIC",
609                constants->ModulePositionX(59),
610                constants->ModulePositionY(59),
611                constants->ModulePositionZ(59),
612                idrotm[231], "MANY");
613   } // end if (fITSGeometry)
614
615 }
616 //_____________________________________________________________________________
617 void AliACORDEv0::DrawDetector() const
618 {
619
620   // not needed anymore
621
622 }
623
624 //____________________________________________________________________________
625
626 void AliACORDEv0::Init()
627 {
628   // Initialise L3 magnet after it has been built
629   Int_t i;
630   if(AliLog::GetGlobalDebugLevel()>0) {
631     printf("\n%s: ",ClassName());
632     for(i=0;i<35;i++) printf("*");
633     printf(" ACORDEv0_INIT ");
634     for(i=0;i<35;i++) printf("*");
635     printf("\n%s: ",ClassName());
636     // Here the ACORDEv initialisation code (if any!)
637     for(i=0;i<80;i++) printf("*");
638     printf("\n");
639   }
640  // AliACORDE::Init();  
641 }
642 //____________________________________________________________________________
643 void AliACORDEv0::StepManager()
644 {
645   //
646   // Called for every step in the Cosmic Ray Trigger
647   //
648
649
650   // volume: 
651   //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
652   //  [1] = Plastic number: 0 (down) to 1 (up)
653   static Int_t   vol[2]; 
654   //
655   // hit
656   // [0] = PID
657   // [1-3] = x, y, z 
658   // [4] = time 
659   // [5-7] = px, py, pz
660   // [8] = energy 
661   // [9] = energy loss
662   // [10] = length of track through plastic
663   static Float_t hits[11];
664
665   // local static variables
666   static Float_t eloss;
667   static Float_t step;
668   // scintillator volume
669   static Int_t idScint = gMC->VolId("ACORDE2");
670
671   // local variables
672   Int_t copy;
673   TLorentzVector pos;
674   TLorentzVector mom;
675
676   // only charged tracks
677   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
678
679   // only in sensitive material
680   if (gMC->CurrentVolID(copy) == idScint) {
681     step  += gMC->TrackStep();
682     eloss += gMC->Edep();
683     // set all hit variables except eloss which is resetted
684     // set volume variables
685     if (gMC->IsTrackEntering()) {
686       eloss = 0.0;
687       step = 0.0;
688       gMC->TrackPosition(pos);
689       gMC->TrackMomentum(mom);
690       // hit
691       // [0] = PID
692       // [1-3] = x, y, z 
693       // [4] = time 
694       // [5-7] = px, py, pz
695       // [8] = energy 
696       // [9] = energy loss
697       hits[0]  = (Float_t ) gMC->TrackPid(); 
698       hits[1] = pos[0]; 
699       hits[2] = pos[1]; 
700       hits[3] = pos[2]; 
701       hits[4] = gMC->TrackTime();
702       hits[5] = mom[0]; 
703       hits[6] = mom[1]; 
704       hits[7] = mom[2]; 
705       hits[8] = gMC->Etot();
706       // volume: 
707       //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
708       //  [1] = Plastic number: 0 (down) to 1 (up)
709       Int_t copyPlastic; // plastic: down=1, up=2
710       Int_t copyModule; // module: 1-60
711       gMC->CurrentVolID(copyPlastic);
712       gMC->CurrentVolOffID(1, copyModule);
713       // module
714       vol[0] = copyModule;
715       // plastic: 0 = down, 1 = up
716       vol[1] = copyPlastic;
717     } // end if gMC->IsTrackEntering()
718
719     // set hit[9] = total energy loss and book hit
720     if( gMC->IsTrackExiting() || 
721         gMC->IsTrackStop() || 
722         gMC->IsTrackDisappeared()){
723       hits[9] = eloss;
724       hits[10] = step;
725       eloss = 0.0;
726       step = 0.0;
727       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
728     }
729   } // end if in scintillator
730
731 }
732
733 //_____________________________________________________________________________
734 void AliACORDEv0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
735 {
736   //
737   // Add a ACORDE hit
738   //
739   TClonesArray &lhits = *fHits;
740   new(lhits[fNhits++]) AliACORDEhit(fIshunt,track,vol,hits);
741 }
742