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