d6738a28d3581e091ff6397a2d25bf49ccb3b1fb
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEv1.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: AliACORDEv1.cxx,v 1.2 2007/12/03 08:40:00 hristov Exp $ */
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 (position and momentum)  //
25 //                                                                           //
26 //                  Send comments to:                                        //
27 //                                                                           //
28 //      Arturo Fernandez Tellez         <afernand@fcfm.buap.mx>              //
29 //      Enrique Gamez                   <egamez@fcfm.buap.mx>                //
30 //      Eleazar Cuautle Flores          <ecuautle@nucleares.unam.mx>         //
31 //      Mario Rodriguez Cahuantzi       <mrodrigu@mail.cern.ch>              // 
32 //                                                                           //
33 //                      Puebla, Pue. Mexico December 2007                    //
34 ///////////////////////////////////////////////////////////////////////////////
35
36
37 //
38 #include <Riostream.h>
39 #include <TGeoMatrix.h>
40 #include <TGeometry.h>
41 #include <TMath.h>
42 //#include <TNode.h>
43 #include <TTUBE.h>
44 //#include <TVirtualMC.h>
45 #include <TString.h>
46 #include <TSystem.h>
47
48 #include "AliConst.h"
49 #include "AliRun.h"
50
51 #include "TGeoManager.h"
52 #include "TGeoVolume.h"
53 #include "TGeoPcon.h"
54 //#include "TGeoTube.h"
55 #include "TGeoPgon.h"
56 #include "TGeoTrd1.h"
57 #include "TGeoCompositeShape.h"
58 #include "TGeoPara.h"
59 //
60
61 #include "AliACORDEv1.h"
62 #include <TClonesArray.h>
63 #include <TLorentzVector.h>
64 #include <TVirtualMC.h>
65 #include <TPDGCode.h>
66 //#include <TGeometry.h>
67 #include <TBRIK.h>
68 #include <TNode.h>
69  
70
71 #include "AliRun.h"
72 #include "AliConst.h"
73 #include "AliACORDEhit.h"
74 #include "AliACORDEConstants.h"
75 #include "AliMC.h"
76 #include "AliLog.h"
77
78 ClassImp(AliACORDEv1)
79  
80 //_____________________________________________________________________________
81 AliACORDEv1::AliACORDEv1()
82   : AliACORDE()
83 {
84   //
85   // Default constructor
86   fIshunt = 0;
87   fHits = 0;
88   //
89
90 //_____________________________________________________________________________
91 AliACORDEv1::AliACORDEv1(const char *name, const char *title)
92   : AliACORDE(name, title)
93 {
94   //
95   // Standard constructor
96   //
97   fIshunt = 1; // All hits are associated with primary particles 
98   fHits =  new TClonesArray("AliACORDEhit",400);
99   gAlice->GetMCApp()->AddHitList(fHits);
100 }
101 //_____________________________________________________________________________
102 AliACORDEv1::~AliACORDEv1()
103 {
104   //
105   // Default destructor
106   //
107 }
108 //_____________________________________________________________________________
109 void AliACORDEv1::BuildGeometry()
110 {
111
112   // not needed anymore
113
114 }
115
116 //_____________________________________________________________________________
117 void AliACORDEv1::CreateGeometry()
118 {
119   CreateAcorde();
120   if (GetCreateCavern()) CreateCavern();
121 }
122
123
124 void AliACORDEv1::CreateCavern()
125 {
126
127         // Create the mother volume, the one which contain all the material
128         //above the hall
129
130         TGeoManager *acorde = new TGeoManager("ACORDE", "Geometry of ACORDE");  
131
132         //---> define some materials
133
134         TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
135
136         //---> define some media
137
138         TGeoMedium *vacuum = new TGeoMedium("Vacuum",1, matVacuum);
139
140         //---> define the measures
141
142         Double_t dx1 = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
143         Double_t dy1 = AliACORDEConstants::Instance()->Depth();
144         Double_t dz1 = dx1;
145
146         //---> define the box for the mother volume
147
148         TGeoVolume *aCORDE = acorde->MakeBox("ACORDE", vacuum, dx1, dy1, dz1);
149         acorde->SetTopVolume(aCORDE);
150
151         //---> create shafts&molasse
152
153         CreateShafts();
154         CreateMolasse();
155 }
156
157
158 void AliACORDEv1::CreateShafts()
159 {
160
161         //---> This shaft is composes by an open tube down in the hall
162         //---> and a cilinder above the level of the celling
163         //---> Every structure relative to the shaft will be put into this volume
164
165
166         TGeoManager *acorde = new TGeoManager("ACORDE2007", "Geometry of ACORDE");      
167
168         //---> define some materials
169
170         TGeoMaterial *matVacuum = new TGeoMaterial("Al", 0,0,0);
171
172         //---> define some media
173
174         TGeoMedium *vacuum = new TGeoMedium("Vacuum",1, matVacuum);
175         TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
176         TGeoMedium *al = new TGeoMedium("Root Material",2, matAl);
177         
178         
179         //---> Access to shafts
180         //---> define the Matrix Rotation&other variables
181
182         TGeoRotation *rot1 = new TGeoRotation("rot1", 0.0, 0.0, 90.0, 0.0, 90.0, 90.0);
183         
184         Float_t ptube[5];
185         ptube[0]=0;
186         ptube[1]=1250;
187         ptube[2]=5150/2;
188         ptube[3]=360;
189         ptube[4]=360;
190         
191         Float_t ptubs[5];
192
193         //---> The open section of the PX24
194         ptubs[0] = 1150; //---> Inner radius
195         ptubs[1] = 1250; //---> Outer radius
196         ptubs[2] = 1300; //---> Half length
197         ptubs[3] = 180 + kRaddeg*TMath::ASin(1070/ptubs[0]); //---> starting angle
198         ptubs[4] = 180 -  kRaddeg*TMath::ASin(1070/ptubs[0]);
199                 
200         //---> Set position for the tubes 
201
202         TGeoTranslation *tr2 = new TGeoTranslation(0,0,-ptube[2]+ptubs[2]);
203
204         //---> define the cilinders to hold the main structure in the shaft
205
206         TGeoVolume *o = acorde->MakeBox("O", vacuum, 25., 25., 5.);
207         TGeoVolume *cSF1 = acorde->MakeTubs("CSF1",al,ptube[0],ptube[1],ptube[2],ptube[3],ptube[4]);
208         TGeoVolume *cSF2 = acorde->MakeTubs("CSF2",al,ptubs[0],ptubs[1],ptubs[2],ptubs[3],ptubs[4]);
209         o->AddNode(cSF1, 1);
210         cSF1->AddNode(cSF2,1,tr2);
211
212         //---> definition of the other part of the shaft
213
214         ptube[0] = ptubs[0]; // Inner radius
215         ptube[1] = ptubs[1]; // Outer radius
216         ptube[2] = 5150/2 - ptubs[2]; // Half lenght
217         TGeoVolume *cSF3 = acorde->MakeTubs("CSF3",al,ptubs[0],ptubs[1],ptubs[2],ptubs[3],ptubs[4]);
218         TGeoTranslation *tr3 = new TGeoTranslation(0,0,5150/2-ptube[2]);
219         cSF1->AddNode(cSF3,1,tr3);
220
221         //---> define concrete walls along the shaft (next to the elevator)
222         
223         Float_t pbox[3];
224         pbox[0]=480/2;
225         pbox[1]=120/2;
226         pbox[2]=5150/2;
227         TGeoVolume *cSW1 = acorde->MakeBox("CSW1",vacuum,pbox[0],pbox[1],pbox[2]);
228         TGeoTranslation *br1 = new TGeoTranslation(820+pbox[0],150+pbox[1],0);
229         TGeoTranslation *br1a = new TGeoTranslation(820+pbox[0],-300-pbox[1],0);
230         cSF1->AddNode(cSW1,1,br1);
231         cSF1->AddNode(cSW1,1,br1a);
232
233         pbox[0] = 120/2;  // Half length in X
234         pbox[1] = 750/2;  // Half length in Y
235         pbox[2] = 5150/2; // Half length in Z
236         TGeoVolume *cSW2 = acorde->MakeBox("CSW2",vacuum,pbox[0],pbox[1],pbox[2]);
237         TGeoTranslation *br2 = new TGeoTranslation(820-60,150+pbox[1],0);
238         cSF1->AddNode(cSW2,1,br2);
239
240
241         pbox[0] = 120/2;  // Half length in X
242         pbox[1] = 600/2;  // Half lenght in Y
243         pbox[2] = 5150/2; // Half length in Z
244         TGeoVolume *cSW3 = acorde->MakeBox("CSW3",vacuum,pbox[0],pbox[1],pbox[2]);
245         TGeoTranslation *br3 = new TGeoTranslation(820-60,-300-pbox[1],0);
246         cSF1->AddNode(cSW3,1,br3);
247
248         pbox[0] = 400/2;  // Half length in X
249         pbox[1] = 2300/2;  // Half lenght in Y
250         pbox[2] = 300/2; // Half length in Z
251         TGeoVolume *cSW4 = acorde->MakeBox("CSW4",vacuum,pbox[0],pbox[1],pbox[2]);
252         TGeoTranslation *br4 = new TGeoTranslation(pbox[1]-pbox[0],0,3000-5150/2-pbox[2]);
253         cSF1->AddNode(cSW4,1,br4);
254
255
256         pbox[0] = 1400/2;  // Half length in X
257         pbox[1] = 2300/2;  // Half lenght in Y
258         pbox[2] = 170/2; // Half length in Z
259         TGeoVolume *cSW5 = acorde->MakeBox("CSW5",vacuum,pbox[0],pbox[1],pbox[2]);
260         TGeoTranslation *br5 = new TGeoTranslation(0,0,3000-5150/2-130);
261         cSF1->AddNode(cSW5,1,br5);
262
263
264         pbox[0] = 170/2;  // Half length in X
265         pbox[1] = 2300/2;  // Half lenght in Y
266         pbox[2] = 300/2; // Half length in Z
267         TGeoVolume *cSW6 = acorde->MakeBox("CSW6",vacuum,pbox[0],pbox[1],pbox[2]);
268         TGeoTranslation *br6 = new TGeoTranslation(-1400/2-pbox[0],0,3000-5150/2-pbox[2]);
269         cSF1->AddNode(cSW6,1,br6);
270
271
272         pbox[0] = 100/2;  // Half length in X
273         pbox[1] = 2300/2;  // Half lenght in Y
274         pbox[2] = 450/2; // Half length in Z
275         TGeoVolume *cSW7 = acorde->MakeBox("CSW7",vacuum,pbox[0],pbox[1],pbox[2]);
276         TGeoTranslation *br7 = new TGeoTranslation(-1400/2-170-pbox[0],0,3000-5150/2+pbox[2]);
277         cSF1->AddNode(cSW7,1,br7);
278
279
280         pbox[0] = 300/2;  // Half length in X
281         pbox[1] = 2300/2;  // Half lenght in Y
282         pbox[2] = 170/2; // Half length in Z
283         TGeoVolume *cSW8 = acorde->MakeBox("CSW8",vacuum,pbox[0],pbox[1],pbox[2]);
284         TGeoTranslation *br8 = new TGeoTranslation(-2300/2+pbox[0],0,2500-5150/2);
285         cSF1->AddNode(cSW8,1,br8);
286
287         //---> put the shaft into the mother volume
288
289         TGeoCombiTrans *br = new TGeoCombiTrans(0,AliACORDEConstants::Instance()->Depth()-5150/2,2300,rot1);
290         cSF1->AddNode(cSF1,1,br);
291
292
293         //---> PM25 Access Shafts
294
295         ptube[0]=910/2;
296         ptube[1]=ptube[0]+100;
297         ptube[2]=(5150-1166)/2;
298         TGeoVolume *cSF4 = acorde->MakeTubs("CSF4",vacuum,pbox[0],pbox[1],pbox[2],360,360);
299         TGeoCombiTrans *tr4 = new TGeoCombiTrans(2100,AliACORDEConstants::Instance()->Depth()-ptube[2],0,rot1);
300         cSF4->AddNode(cSF4,1,tr4);
301
302
303         //---> PGC2 Access shaft
304
305         ptube[0]=1100/2;
306         ptube[1]=ptube[0]+100;
307         ptube[2]=(5150-690)/2;
308         TGeoVolume *cSF5 = acorde->MakeTubs("CSF5",vacuum,pbox[0],pbox[1],pbox[2],360,360);
309         TGeoCombiTrans *tr5 = new TGeoCombiTrans(-375,AliACORDEConstants::Instance()->Depth()-ptube[2],-1900-2987.7,rot1);
310         cSF5->AddNode(cSF5,1,tr5);
311
312 }
313
314
315 void AliACORDEv1::CreateMolasse()
316
317 {
318         // create a big molasse for ACORDE detector
319         TGeoManager *acorde = new TGeoManager("ACORDE2007", "Geometry of ACORDE");      
320
321         //---> define some media
322         
323
324         TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
325         TGeoMedium *vacuum = new TGeoMedium("Root Material",2, matAl);
326
327         Float_t px24radius = 2300/2;
328         Float_t px24X = 0;
329         Float_t px24Z = 2300;
330         Float_t pm25radius = 910/2;
331         Float_t pm25X = 2100;
332         Float_t pm25Z = 0;
333         Float_t pgc2radius = 1100/2;
334         Float_t pgc2X = -375;
335         Float_t pgc2Z = -(1900 + 2987.7);
336         Float_t concreteWidth = 100; //---> Standard width of the hall walls.
337
338
339         //---> Create a local mother volume.
340         Float_t pbox[3];
341         pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
342         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
343         pbox[2] = pbox[0];
344         TGeoVolume *cM01 = acorde->MakeBox("CM01", vacuum, pbox[0],pbox[1],pbox[2]);
345
346         //---> Now put the molasse exactly above the hall. OK
347         //---> Above the ceiling
348         
349         Float_t ptubs[5];
350         ptubs[0] = 1170;
351         ptubs[1] = 2100 - pm25radius;
352         ptubs[2] = 1900/2 + px24radius;
353         ptubs[3] = 0;
354         ptubs[4] = 180;
355         TGeoVolume *cM02 = acorde->MakeTubs("CM02",vacuum,ptubs[0],ptubs[1],ptubs[2],ptubs[3],ptubs[4]);
356         TGeoTranslation *tr2 = new TGeoTranslation(0,500-AliACORDEConstants::Instance()->Depth()/2,ptubs[2]-1900);
357         cM01->AddNode(cM02,1,tr2);
358
359
360         //---> Molasse around the RB24/26 Wall. OK
361
362         ptubs[0] = 220 + 1600;
363         ptubs[1] = AliACORDEConstants::Instance()->Depth() - ptubs[0];
364         ptubs[2] = 2987.7/2 - 1100/4 - concreteWidth/2;
365         ptubs[3] = 0;
366         ptubs[4] = 180;
367         TGeoVolume *cM03 = acorde->MakeTubs("CM03",vacuum,ptubs[0],ptubs[1],ptubs[2],ptubs[3],ptubs[4]);
368         TGeoTranslation *tr3 = new TGeoTranslation(70,40-AliACORDEConstants::Instance()->Depth()/2,-ptubs[2]-1900);
369         cM01->AddNode(cM03,1,tr3);
370
371
372         //---> A big block above the RB24/26 wall. OK
373
374         pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
375         pbox[1] = (AliACORDEConstants::Instance()->Depth() - 220 - 1600)/2;
376         pbox[2] = 2987.7/2 - 1100/4 - concreteWidth/2;
377         TGeoVolume *cM04 = acorde->MakeBox("CM04", vacuum, pbox[0],pbox[1],pbox[2]);
378         TGeoTranslation *tr4 = new TGeoTranslation(0,AliACORDEConstants::Instance()->Depth()/2-pbox[1],-1900-pbox[2]);
379         cM01->AddNode(cM04,1,tr4);
380
381
382
383
384         //---> Small blocks below the volume CMO4 on both sides of the wall RB24/26. OK
385
386         pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)-ptubs[0])/2;
387         pbox[1] = AliACORDEConstants::Instance()->Depth()/2 - pbox[1];
388         TGeoVolume *cM17 = acorde->MakeBox("CM17", vacuum, pbox[0],pbox[1],pbox[2]);
389         TGeoTranslation *tr17 = new TGeoTranslation(AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) - pbox[0],-AliACORDEConstants::Instance()->Depth()/2 + pbox[1],-1900 - pbox[2]);
390         TGeoTranslation *tr17a = new TGeoTranslation(-AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)+ pbox[0],-AliACORDEConstants::Instance()->Depth()/2 + pbox[1], -1900 - pbox[2]);
391         cM01->AddNode(cM17,1,tr17);
392         cM01->AddNode(cM17,2,tr17a);
393
394
395         //---> And a big block of molasse above the hall up to the surface. OK
396
397         pbox[0] = pm25X - pm25radius;
398         pbox[1] = (AliACORDEConstants::Instance()->Depth()-500-1170)/2;
399         pbox[2] = (1900 + 1150)/2;
400         TGeoVolume *cM05 = acorde->MakeBox("CM05", vacuum, pbox[0],pbox[1],pbox[2]);
401         TGeoTranslation *tr5 = new TGeoTranslation(0,AliACORDEConstants::Instance()->Depth()/2-pbox[1], pbox[2]-1900);
402         cM01->AddNode(cM05,1,tr5);
403
404
405         //---> Small blocks of molasse betwen the blocks CMO2, CMO5 and PM25. Ok
406
407         pbox[0] = (pm25X - pm25radius - 1170)/2;
408         pbox[1] = 1000;
409         TGeoVolume *cM16 = acorde->MakeBox("CM16", vacuum, pbox[0],pbox[1],pbox[2]);
410         TGeoTranslation *tr16 = new TGeoTranslation(1170 + pbox[0], -AliACORDEConstants::Instance()->Depth()/2+pbox[1], pbox[2] - 1900);
411         cM01->AddNode(cM16,1,tr16);
412
413
414         //---> Molasse around the shafts.
415
416         TGeoRotation *rot2 = new TGeoRotation("rot1",0, 0, 90, 0, 90, 90 );
417
418         //---> Around the PX24, the open section. OK
419
420         ptubs[0] = px24radius + concreteWidth;
421         ptubs[1] = ptubs[0] + 1000;
422         ptubs[2] = (2300 - (5150 - AliACORDEConstants::Instance()->Depth()))/2;
423         ptubs[3] = 180 + kRaddeg*TMath::ASin(1070/ptubs[0]);
424         ptubs[4] = 180 -  kRaddeg*TMath::ASin(1070/ptubs[0]);
425         TGeoVolume *cM06 = acorde->MakeTubs("CM06", vacuum,ptubs[0],ptubs[1],ptubs[2],ptubs[3],ptubs[4]);
426         TGeoTranslation *tr6 = new TGeoTranslation(px24X, ptubs[2] - AliACORDEConstants::Instance()->Depth()/2, px24Z);
427         cM01->AddNode(cM06,1,tr6);
428
429
430         //---> Around the PX24, the closed section. OK
431
432         Float_t ptube[3];
433         ptube[0] = px24radius + concreteWidth;
434         ptube[1] = ptube[0] + 1000;
435         ptube[2] = (5150 - 2300)/2;
436         TGeoVolume *cM07 = acorde->MakeTubs("CM07", vacuum,ptube[0],ptube[1],ptubs[2],ptube[3],ptube[4]);
437         TGeoTranslation *tr7 = new TGeoTranslation(px24X, AliACORDEConstants::Instance()->Depth()/2-ptube[2], px24Z);
438         cM01->AddNode(cM07,1,tr7);
439
440
441         //---> Around PM25. OK
442
443         ptube[0] = pm25radius + concreteWidth;
444         ptube[1] = ptube[0] + 400;
445         ptube[2] = AliACORDEConstants::Instance()->Depth()/2;
446         TGeoVolume *cM08 = acorde->MakeTubs("CM08", vacuum,ptube[0],ptube[1],ptube[2],ptube[3],ptube[4]);
447         TGeoCombiTrans *tr8 = new TGeoCombiTrans(pm25X, 0, pm25Z,rot2);
448         cM01->AddNode(cM08,1,tr8);
449
450
451         //---> On both sides of the PM25 along the HALL.
452
453         pbox[0] = (2100 + pm25radius - 1170)/2;
454         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
455         pbox[2] = (3*px24radius - pm25radius)/2;
456         TGeoVolume *cM18 = acorde->MakeBox("CM18",vacuum,pbox[0],pbox[1],pbox[2]);
457         TGeoTranslation *tr18 = new TGeoTranslation(2100, 0, pbox[2] + pm25radius);
458         cM01->AddNode(cM18,1,tr18);
459   
460         pbox[2] = (1900 - pm25radius)/2;
461         TGeoVolume *cM19 = acorde->MakeBox("CM19",vacuum,pbox[0],pbox[1],pbox[2]);
462         TGeoTranslation *tr19 = new TGeoTranslation(2100, 0, -pbox[2] - pm25radius);
463         cM01->AddNode(cM19,1,tr19);
464
465
466         //---> Around the PGC2. OK
467
468         ptube[0] = pgc2radius + concreteWidth;
469         ptube[1] = 2987.7 - 740;
470         ptube[2] = AliACORDEConstants::Instance()->Depth()/2;
471         TGeoVolume *cM09 = acorde->MakeTubs("CM09",vacuum,ptube[0],ptube[1],ptube[2],ptube[3],ptube[4]);
472         TGeoCombiTrans *tr09 = new TGeoCombiTrans(pgc2X, 0, pgc2Z,rot2);
473         cM01->AddNode(cM09,1,tr09);
474
475         //---> On both sides of the PGC2.OK
476
477         pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)-1100 - 375)/2;
478         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
479         pbox[2] = pgc2radius + concreteWidth;
480         TGeoVolume *cM10 = acorde->MakeBox("CM10",vacuum,pbox[0],pbox[1],pbox[2]);
481         TGeoTranslation *tr10 = new TGeoTranslation(AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) - pbox[0], 0, pgc2Z);
482         TGeoTranslation *tr10a = new TGeoTranslation(-AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad) + pbox[0], 0, pgc2Z);
483         cM01->AddNode(cM10,1,tr10);
484         cM01->AddNode(cM10,2,tr10a);
485
486
487         //---> big block of molasse behind the PX24. OK
488
489         pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
490         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
491         pbox[2] = (pbox[0] - (2300 + 1150 + 100))/2;
492         TGeoVolume *cM12 = acorde->MakeBox("CM12",vacuum,pbox[0],pbox[1],pbox[2]);
493         TGeoTranslation *tr12 = new TGeoTranslation(px24X, 0, px24Z + px24radius + concreteWidth + pbox[2]);    
494         cM01->AddNode(cM12,1,tr12);
495
496
497         //---> big block of molasse in the opposite side of the PM25. OK
498
499         pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)-1150)/2;
500         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
501         pbox[2] = (1900 + 2300 + 1150)/2;
502         TGeoVolume *cM13 = acorde->MakeBox("CM13",vacuum,pbox[0],pbox[1],pbox[2]);
503         TGeoTranslation *tr13 = new TGeoTranslation(-1150 - pbox[0], 0, pbox[2] - 1900);        
504         cM01->AddNode(cM13,1,tr13);
505  
506
507         //---> big block of molasse behind the PM25. OK
508
509         pbox[0] = (AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad)-(2100 + 910/2 + 100))/2;
510         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
511         pbox[2] = (1900 + 2300 + 1150)/2;
512         TGeoVolume *cM14 = acorde->MakeBox("CM14",vacuum,pbox[0],pbox[1],pbox[2]);
513         TGeoTranslation *tr14 = new TGeoTranslation(pm25X + pm25radius + concreteWidth + pbox[0], 0, pbox[2] - 1900);
514         cM01->AddNode(cM14,1,tr14);
515
516
517         //---> big block of molasse behind the PGC2. OK
518
519         pbox[0] = AliACORDEConstants::Instance()->Depth()*TMath::Tan(67.5*kDegrad);
520         pbox[1] = AliACORDEConstants::Instance()->Depth()/2;
521         pbox[2] = (pbox[0] - (2987.7 + 1900 + 1100/2 + 100))/2;
522         TGeoVolume *cM15 = acorde->MakeBox("CM15",vacuum,pbox[0],pbox[1],pbox[2]);
523         TGeoTranslation *tr15 = new TGeoTranslation(0, 0, -pbox[0] + pbox[2]);
524         TGeoTranslation *tr15a = new TGeoTranslation(0,AliACORDEConstants::Instance()->Depth()/2,0);
525         cM01->AddNode(cM15,1,tr15);
526         cM01->AddNode(cM01,1,tr15a);
527
528 }
529
530 void AliACORDEv1::CreateAcorde()
531 {  
532
533
534   //  _______________________________________________________________________________
535   // |                                                                               |  
536   // |                                                                               |  
537   // |  **** Acorde's Geometry using the TGeo Class....January 2008 ****             |
538   // |                                                                               |  
539   // |          ACORDE--> Volume for ACORDE in Alice's Magnet                        |
540   // |          ACORDE1_a--> Volume for frame of Acorde's Module                     |
541   // |          ACORDE10--> Volume for frame of Acorde's Module                      |
542   // |          ACORDE2--> Volume for scintillators in Acorde's Module               |
543   // |          ACORDE7--> Volume for bars                                           |
544   // |          ACORDE7_1--> Volume for side's bars                                  |  
545   // |          ACORDE8--> Volume for supports                                       |  
546   // |          ACORDE9--> Volume for supports                                       |          
547   // |          ACORDE_SUPPORT--> Volume that contains a full Acorde's support       |
548   // |          ALL_ACORDE_MODULES--> Volume that contains ALL Acorde's module       |  
549   // |          ACORDE_MODULE--> Volume that represents ONE Acorde-Module            |
550   // |          ACORDE_1--> Volume that contains the bars&supports in-face           |
551   // |          ACORDE_2--> Volume that contains the bars&supports up-face           |  
552   // |          ACORDE_3--> Volume that contains the bars&supports out-face          |
553   // |                                                                               |  
554   // |_______________________________________________________________________________|
555
556
557         // Call the global constants for the Modules
558         
559         AliACORDEConstants* constants = AliACORDEConstants::Instance();
560
561         // Get the Alice Volume
562
563         TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
564
565         // Define some materials & medium
566
567         //*** Support & Bars***
568
569         TGeoMedium* al    = gGeoManager->GetMedium("ACORDE_ALU_C0");
570         TGeoMedium* med6  = gGeoManager->GetMedium("ACORDE_CPV scint.1");
571         
572         //Define a FULL-ACORDE-VOLUME
573
574         TGeoVolume *aCORDE = new TGeoVolumeAssembly("ACORDE");
575
576
577         // Define 6 master volumes for ACORDE
578         
579         TGeoVolume *inFace = new TGeoVolumeAssembly("ACORDE_1");
580         TGeoVolume *upFace = new TGeoVolumeAssembly("ACORDE_2");
581         TGeoVolume *outFace = new TGeoVolumeAssembly("ACORDE_3");
582         TGeoVolume *modules = new TGeoVolumeAssembly("ALL_ACORDE_MODULES");
583
584         // Define global variables
585
586         Float_t box[3];
587         Int_t count;
588         Float_t dy=10;//-->displacement of the support and bars of ACORDE
589         Float_t dy2=66.5;//-->displacement of the support and bars of ACORDE
590         Float_t placedAt;
591         Float_t small=0.05;
592
593         // Define the position of support and bars for the sides faces
594
595         Float_t des = 22*0.7071;
596   
597         // Define rotation Matrix for Side's faces in Alice
598         
599         TGeoRotation *idrotm231 = new TGeoRotation("idrotm231",90, 45, 90, 135, 0, 0);
600         TGeoRotation *idrotm232 = new TGeoRotation("idrotm232",90, 315, 90, 45, 0, 0);
601
602         // Begin the Geometry of the structure for ACORDE
603
604         // *** Definition of ACORDE's Modules ***
605
606         // Define Measures of ACORDE's Modules
607
608         box[0] = constants->ModuleLength()/2;
609         box[1] = constants->ModuleHeight()/2;
610         box[2] = constants->ModuleWidth()/2;
611
612         // Define Measures of Scintillators
613         
614         Float_t pbox[3];        
615         pbox[0] = constants->PlasticLength()/2;
616         pbox[1] = constants->PlasticHeight()/2;
617         pbox[2] = constants->PlasticWidth()/2;
618
619
620         // Create the Modules, Scintillators & Metallic Frame
621
622         //*** Aluminium frame ***
623
624         TGeoBBox *acorde1 = new TGeoBBox("acorde1",box[0],box[1],26/20+2);
625         TGeoBBox *acorde10 = new TGeoBBox("acorde10",26/20,box[1],box[2]+3);
626         TGeoVolume *aCORDE1qa = new TGeoVolume("ACORDE1_a",acorde1,al);
627         TGeoVolume *aCORDE10 = new TGeoVolume("ACORDE10",acorde10,al);
628
629         //*** Scintillators ***
630
631         TGeoBBox *acorde2 = new TGeoBBox("acorde2",pbox[0],pbox[1],pbox[2]);
632         TGeoVolume *aCORDE2 = new TGeoVolume("ACORDE2",acorde2,med6);
633
634
635         // Here I define & construct a Master Volume ("ACORDE_MODULE") for one Module in ACORDE
636
637         TGeoVolume *acomodule = new TGeoVolumeAssembly("ACORDE_MODULE");
638         acomodule->AddNode(aCORDE1qa,1,new TGeoTranslation("aco1",0,0,13));
639         acomodule->AddNode(aCORDE1qa,2,new TGeoTranslation("aco10",0,0,-13));
640         acomodule->AddNode(aCORDE10,3,new TGeoTranslation("aco10",293/2+5,0,0));
641         acomodule->AddNode(aCORDE10,4,new TGeoTranslation("aco10",-293/2-5,0,0));
642         placedAt = pbox[1]+constants->ProfileThickness()-constants->ModuleHeight()/2+small;
643         acomodule->AddNode(aCORDE2,5,new TGeoTranslation("aco2",placedAt,0,0));
644         placedAt = placedAt + 2.0*pbox[1]+small;
645         acomodule->AddNode(aCORDE2,6,new TGeoTranslation("aco2",placedAt,-1,0));
646         Float_t w1 = 8;
647
648         
649
650
651         // Put the Modules of In-Face
652         
653         count=1;
654         for(Int_t i=1;i<9;i++){
655
656                 Float_t posx = constants->ModulePositionX(i);
657                 Float_t posy = constants->ModulePositionY(i);
658                 Float_t posz = constants->ModulePositionZ(i);   
659                 Int_t moduleElectronicID = constants->ModuleElectronicChannel(i); 
660                 
661                 modules->AddNode(acomodule,moduleElectronicID,
662                         new TGeoCombiTrans("aco01",posx,posy-w1,posz,idrotm232));
663                 count++;
664
665         }
666
667         count=9;
668         for(Int_t i=10;i<20;i++){
669                 Float_t posx = constants->ModulePositionX(i);
670                 Float_t posy = constants->ModulePositionY(i);
671                 Float_t posz = constants->ModulePositionZ(i);
672                 Int_t moduleElectronicID = constants->ModuleElectronicChannel(i);       
673
674                 modules->AddNode(acomodule,moduleElectronicID,
675                         new TGeoCombiTrans("aco01",posx,posy-w1,posz,idrotm232));
676         }
677
678         // Put he Modules of Up-Face
679
680         count=1;
681         for(Int_t i=20;i<40;i++){
682                 Float_t posx = constants->ModulePositionX(i);
683                 Float_t posy = constants->ModulePositionY(i);
684                 Float_t posz = constants->ModulePositionZ(i);   
685                 Int_t moduleElectronicID = constants->ModuleElectronicChannel(i); 
686
687                 modules->AddNode(acomodule,moduleElectronicID,new TGeoTranslation("aco01",posx,posy,posz));
688                 count++;
689         }
690
691         // Put the Modules of Out-Face
692
693         count=1;
694         for(Int_t i=40;i<50;i++){
695                 Float_t posx = constants->ModulePositionX(i);
696                 Float_t posy = constants->ModulePositionY(i);
697                 Float_t posz = constants->ModulePositionZ(i);   
698                 Int_t moduleElectronicID = constants->ModuleElectronicChannel(i); 
699
700                 modules->AddNode(acomodule,moduleElectronicID,
701                         new TGeoCombiTrans("aco01",posx,posy-w1,posz,idrotm231));
702                 count++;
703         }
704
705         // Put the Modules of Out-Face
706
707         count=11;
708         for(Int_t i=51;i<59;i++){
709                 Float_t posx = constants->ModulePositionX(i);
710                 Float_t posy = constants->ModulePositionY(i);
711                 Float_t posz = constants->ModulePositionZ(i);   
712                 Int_t moduleElectronicID = constants->ModuleElectronicChannel(i); 
713
714         if ((i==57) || (i==56))
715                  modules->AddNode(acomodule,moduleElectronicID,
716                                         new TGeoCombiTrans("aco01",posx,posy-w1,posz-w1,idrotm231));
717         else
718                 modules->AddNode(acomodule,moduleElectronicID,
719                         new TGeoCombiTrans("aco01",posx,posy-w1,posz,idrotm231));
720                 count++;
721         }
722
723
724         // Put th Modules ITS-ACORDE
725
726         if (GetITSGeometry()) {
727
728                 modules->AddNode(acomodule,constants->ModuleElectronicChannel(50),new TGeoTranslation("ITS-3",
729                                 constants->ExtraModulePositionX(),
730                                 constants->ExtraModulePositionY(),
731                                 constants->ExtraModulePositionZ(0)));
732
733                 modules->AddNode(acomodule,constants->ModuleElectronicChannel(59),new TGeoTranslation("ITS-4",
734                                 constants->ExtraModulePositionX(),
735                                 constants->ExtraModulePositionY(),
736                                 constants->ExtraModulePositionZ(1)));
737
738                 modules->AddNode(acomodule,constants->ModuleElectronicChannel(0),new TGeoTranslation("ITS-1",
739                                 constants->ExtraModulePositionX(),
740                                 constants->ExtraModulePositionY(),
741                                 constants->ExtraModulePositionZ(2)));
742
743                 modules->AddNode(acomodule,constants->ModuleElectronicChannel(9),new TGeoTranslation("ITS-2",
744                                 constants->ExtraModulePositionX(),
745                                 constants->ExtraModulePositionY(),
746                                 constants->ExtraModulePositionZ(3)));
747
748
749                 } 
750         else {
751
752
753                 modules->AddNode(acomodule,61,new TGeoTranslation("its1",
754                                 constants->ModulePositionX(0),
755                                 constants->ModulePositionY(0),
756                                 constants->ModulePositionZ(0)));
757
758                 modules->AddNode(acomodule,62,new TGeoTranslation("its2",
759                                 constants->ModulePositionX(9),
760                                 constants->ModulePositionY(9),
761                                 constants->ModulePositionZ(9)));
762
763                 modules->AddNode(acomodule,63,new TGeoTranslation("its3",
764                                 constants->ModulePositionX(50),
765                                 constants->ModulePositionY(50),
766                                 constants->ModulePositionZ(50)));
767
768                 modules->AddNode(acomodule,64,new TGeoTranslation("its4",
769                                 constants->ModulePositionX(59),
770                                 constants->ModulePositionY(59),
771                                 constants->ModulePositionZ(59)));
772
773                 } // end if (fITSGeometry)
774
775
776
777         //*** Begin the structure of support & bars for ACORDE ***
778
779         // Define a volume for the bars (up-face)
780
781         box[0]=5;
782 //      box[1]=40;
783         box[1]=33;
784         box[2]=5;
785         Float_t z1 = 21 ;
786         TGeoBBox *acorde00 = new TGeoBBox("acorde00",box[0],box[1],box[2]);
787
788         TGeoVolume *aCORDE00 = new TGeoVolume("ACORDE00",acorde00,al);
789
790         count=25;
791         for (Int_t ma=20;ma<=24;ma++)
792         {
793                 TGeoTranslation *aco00=new TGeoTranslation("aco00",
794                                         constants->ModulePositionX(ma)-0.5*293+dy2,
795                                         constants->ModulePositionY(ma)-box[1]-z1,
796                                         constants->ModulePositionZ(ma));
797
798                 upFace->AddNode(aCORDE00,count,aco00);
799
800                 TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
801                                         -(constants->ModulePositionX(ma)-0.5*293+dy2),
802                                         constants->ModulePositionY(ma)-box[1]-z1,
803                                         constants->ModulePositionZ(ma));
804                 upFace->AddNode(aCORDE00,count+1,aco00q1);
805
806                 TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
807                                         constants->ModulePositionX(ma)+0.5*293-dy2,
808                                         constants->ModulePositionY(ma)-box[1]-z1,
809                                         constants->ModulePositionZ(ma));
810                 upFace->AddNode(aCORDE00,count+2,aco00q2);
811
812                 TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
813                                         -(constants->ModulePositionX(ma)+0.5*293-dy2),
814                                         constants->ModulePositionY(ma)-box[1]-z1,
815                                         constants->ModulePositionZ(ma));
816                 upFace->AddNode(aCORDE00,count+3,aco00q3);
817                 count=count+4;
818
819                 ma++;
820         }
821
822         count=41;
823         for(Int_t ma=25;ma<=29;ma++)
824         {
825                 TGeoTranslation *aco00=new TGeoTranslation("aco00",
826                                         constants->ModulePositionX(ma)-0.5*293+dy2,
827                                         constants->ModulePositionY(ma)-box[1]-z1,
828                                         constants->ModulePositionZ(ma));
829                 upFace->AddNode(aCORDE00,count,aco00);
830
831                 TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
832                                         -(constants->ModulePositionX(ma)-0.5*293+dy2),
833                                         constants->ModulePositionY(ma)-box[1]-z1,
834                                         constants->ModulePositionZ(ma));
835                 upFace->AddNode(aCORDE00,count+1,aco00q1);
836
837                 TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
838                                         constants->ModulePositionX(ma)+0.5*293-dy2,
839                                         constants->ModulePositionY(ma)-box[1]-z1,
840                                         constants->ModulePositionZ(ma));
841                 upFace->AddNode(aCORDE00,count+2,aco00q2);
842
843                 TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
844                                         -(constants->ModulePositionX(ma)+0.5*293-dy2),
845                                         constants->ModulePositionY(ma)-box[1]-z1,
846                                         constants->ModulePositionZ(ma));
847                 upFace->AddNode(aCORDE00,count+3,aco00q3);
848                 count=count+4;
849                 ma++;
850         }
851
852         TGeoTranslation *c1 = new TGeoTranslation ("c1",
853                                 constants->ModulePositionX(20)-0.5*293,
854                                 constants->ModulePositionY(20)-box[1]-z1,
855                                 constants->ModulePositionZ(20)-40);
856         TGeoTranslation *c2 = new TGeoTranslation ("c2",
857                                 constants->ModulePositionX(23)-0.5*293,
858                                 constants->ModulePositionY(23)-box[1]-z1,
859                                 constants->ModulePositionZ(23)-40);
860         TGeoTranslation *c3 = new TGeoTranslation ("c3",
861                                 constants->ModulePositionX(24)-0.5*293,
862                                 constants->ModulePositionY(24)-box[1]-z1,
863                                 constants->ModulePositionZ(25)-40);
864         TGeoTranslation *c4 = new TGeoTranslation ("c4",
865                                 constants->ModulePositionX(27)-0.5*293,
866                                 constants->ModulePositionY(27)-box[1]-z1,
867                                 constants->ModulePositionZ(28)-40);
868         upFace->AddNode(aCORDE00,57,c1);
869         upFace->AddNode(aCORDE00,58,c2);
870         upFace->AddNode(aCORDE00,59,c3);
871         upFace->AddNode(aCORDE00,60,c4);
872
873
874         // Construct Bars for lateral supports (up-face)
875
876         TGeoTranslation *aco00=new TGeoTranslation("aco00",
877                                 constants->ModulePositionX(20)+0.5*293-dy,
878                                 constants->ModulePositionY(20)-box[1]-z1,
879                                 constants->ModulePositionZ(20)-40);
880         upFace->AddNode(aCORDE00,61,aco00);
881
882         TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
883                                 constants->ModulePositionX(23)+0.5*293-dy,
884                                 constants->ModulePositionY(23)-box[1]-z1,
885                                 constants->ModulePositionZ(23)-40);
886         upFace->AddNode(aCORDE00,62,aco00q1);
887
888         TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
889                                 constants->ModulePositionX(24)+0.5*293-dy,
890                                 constants->ModulePositionY(24)-box[1]-z1,
891                                 constants->ModulePositionZ(25)-40);
892         upFace->AddNode(aCORDE00,63,aco00q2);
893
894         TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
895                                 constants->ModulePositionX(27)+0.5*293-dy,
896                                 constants->ModulePositionY(27)-box[1]-z1,
897                                 constants->ModulePositionZ(28)-40);
898         upFace->AddNode(aCORDE00,64,aco00q3);
899
900
901         TGeoTranslation *aco01=new TGeoTranslation("aco01",
902                                 constants->ModulePositionX(30)-0.5*293+dy,
903                                 constants->ModulePositionY(30)-box[1]-z1,
904                                 constants->ModulePositionZ(30)-40);
905         upFace->AddNode(aCORDE00,65,aco01);
906
907         TGeoTranslation *aco01q1=new TGeoTranslation("aco01q1",
908                                 constants->ModulePositionX(33)-0.5*293+dy,
909                                 constants->ModulePositionY(33)-box[1]-z1,
910                                 constants->ModulePositionZ(33)-40);
911         upFace->AddNode(aCORDE00,66,aco01q1);
912
913         TGeoTranslation *aco01q2=new TGeoTranslation("aco01q2",
914                                 constants->ModulePositionX(34)-0.5*293+dy,
915                                 constants->ModulePositionY(34)-box[1]-z1,
916                                 constants->ModulePositionZ(35)-40);
917         upFace->AddNode(aCORDE00,67,aco01q2);
918
919         TGeoTranslation *aco01q3=new TGeoTranslation("aco01q3",
920                                 constants->ModulePositionX(37)-0.5*293+dy,
921                                 constants->ModulePositionY(37)-box[1]-z1,
922                                 constants->ModulePositionZ(38)-40);
923         upFace->AddNode(aCORDE00,68,aco01q3);
924
925
926
927         // Acorde's support bars (side's faces)
928
929         //*** In Face ***
930
931 //      box[0]=39;
932         box[0]=27;
933         box[1]=5;
934         box[2]=5;
935         Float_t kro=3;
936         Float_t q1=0;
937         Float_t posx=constants->ModulePositionX(0)+0.5*293*0.7071-56*0.7071-18;
938         Float_t posy=constants->ModulePositionY(0)-0.5*293*0.7071-56*0.7071+3-q1+kro;
939         Float_t posz=constants->ModulePositionZ(0);
940
941         TGeoBBox *acorde7 = new TGeoBBox("acorde7",box[0],box[1],box[2]);
942
943         TGeoVolume *aCORDE7 = new TGeoVolume("ACORDE7",acorde7,al);
944
945         TGeoCombiTrans *aco7 = new TGeoCombiTrans("aco7",posx,posy,posz-4*dy,idrotm231);
946         TGeoCombiTrans *aco7q1 = new TGeoCombiTrans("aco7q1",posx,posy,
947                                         constants->ModulePositionZ(3)-4*dy,idrotm231);
948         TGeoCombiTrans *aco7q2 = new TGeoCombiTrans("aco7q2",posx,posy,
949                                         constants->ModulePositionZ(5)-4*dy,idrotm231);
950         TGeoCombiTrans *aco7q3 = new TGeoCombiTrans("aco7q3",posx,posy,
951                                         constants->ModulePositionZ(8)-4*dy,idrotm231);
952
953         inFace->AddNode(aCORDE7,20,aco7);
954         inFace->AddNode(aCORDE7,21,aco7q1);
955         inFace->AddNode(aCORDE7,22,aco7q2);
956         inFace->AddNode(aCORDE7,23,aco7q3);
957
958
959         count=24;
960         for(Int_t dyA=0;dyA<=4;dyA++)
961         {
962
963                 Float_t posx1=constants->ModulePositionX(dyA)+0.1*293*0.7071-56*0.7071-18+des;
964                 Float_t posy1=constants->ModulePositionY(dyA)-0.1*293*0.7071-56*0.7071+3-des-q1+kro;
965                 Float_t posza=constants->ModulePositionZ(dyA);
966                 Float_t posx2=constants->ModulePositionX(dyA)-0.27*293*0.7071-56*0.7071-18+des;
967                 Float_t posy2=constants->ModulePositionY(dyA)+0.27*293*0.7071-56*0.7071+3-des-q1+kro;
968                 TGeoCombiTrans *aco7q4 = new TGeoCombiTrans("aco7q4",posx1,posy1,posza,idrotm231);
969                 TGeoCombiTrans *aco7q5 = new TGeoCombiTrans("aco7q5",posx2,posy2,posza,idrotm231);
970                 inFace->AddNode(aCORDE7,count,aco7q4);
971                 inFace->AddNode(aCORDE7,count+1,aco7q5);
972                 count=count+2;
973                 dyA++;
974         }       
975
976
977         count=34;
978         for(Int_t dyb=5;dyb<=9;dyb++)
979         {
980
981                 Float_t posx1=constants->ModulePositionX(dyb)+0.1*293*0.7071-56*0.7071-18+des;
982                 Float_t posy1=constants->ModulePositionY(dyb)-0.1*293*0.7071-56*0.7071+3-des-q1+kro;
983                 Float_t poszb=constants->ModulePositionZ(dyb+10);
984                 Float_t posx2=constants->ModulePositionX(dyb)-0.27*293*0.7071-56*0.7071-18+des;
985                 Float_t posy2=constants->ModulePositionY(dyb)+0.27*293*0.7071-56*0.7071+3-des-q1+kro;
986                 TGeoCombiTrans *aco7q6 = new TGeoCombiTrans("aco7q6",posx1,posy1,poszb,idrotm231);
987                 TGeoCombiTrans *aco7q7 = new TGeoCombiTrans("aco7q7",posx2,posy2,poszb,idrotm231);
988                 inFace->AddNode(aCORDE7,count,aco7q6);
989                 inFace->AddNode(aCORDE7,count+1,aco7q7);
990                 count=count+2;
991                 dyb++;
992         }       
993
994
995
996         Float_t posxq1=constants->ModulePositionX(10)+0.5*293*0.7071-56*0.7071-18;
997         Float_t posyq1=constants->ModulePositionY(10)-0.5*293*0.7071-56*0.7071+3-q1+kro;
998         Float_t poszq1=constants->ModulePositionZ(10);
999         TGeoCombiTrans *aco7q8 = new TGeoCombiTrans("aco7q8",posxq1,posyq1,poszq1-4*dy,idrotm231);
1000         TGeoCombiTrans *aco7q9 = new TGeoCombiTrans("aco7q9",posxq1,posyq1,
1001                                         constants->ModulePositionZ(13)-4*dy,idrotm231);
1002         TGeoCombiTrans *aco7q10 = new TGeoCombiTrans("aco7q10",posxq1,posyq1,
1003                                         constants->ModulePositionZ(15)-4*dy,idrotm231);
1004         TGeoCombiTrans *aco7q11 = new TGeoCombiTrans("aco7q11",posxq1,posyq1,
1005                                         constants->ModulePositionZ(18)-4*dy,idrotm231);
1006         inFace->AddNode(aCORDE7,44,aco7q8);
1007         inFace->AddNode(aCORDE7,45,aco7q9);
1008         inFace->AddNode(aCORDE7,46,aco7q10);
1009         inFace->AddNode(aCORDE7,47,aco7q11);
1010
1011
1012         count=48;
1013         for(Int_t dyc=10;dyc<=14;dyc++)
1014
1015         {
1016
1017                 Float_t posx1=constants->ModulePositionX(dyc)+0.1*293*0.7071-56*0.7071-18+des;
1018                 Float_t posy1=constants->ModulePositionY(dyc)-0.1*293*0.7071-56*0.7071+3-des-0.8+kro;
1019                 Float_t poszc=constants->ModulePositionZ(dyc);
1020                 Float_t posx2=constants->ModulePositionX(dyc)-0.27*293*0.7071-56*0.7071-18+des;
1021                 Float_t posy2=constants->ModulePositionY(dyc)+0.27*293*0.7071-56*0.7071+3-des-1.5-0.8+kro;
1022                 TGeoRotation *rot1 = new TGeoRotation();
1023                 rot1->RotateZ(70);
1024                 TGeoCombiTrans *aco7q12 = new TGeoCombiTrans("aco7q12",posx1,posy1,poszc,idrotm231);
1025                 TGeoCombiTrans *aco7q13 = new TGeoCombiTrans("aco7q13",posx2+15,posy2-10,poszc,rot1);
1026                 inFace->AddNode(aCORDE7,count,aco7q12);
1027                 inFace->AddNode(aCORDE7,count+1,aco7q13);// bars 25 grades
1028                 count=count+2;
1029                 dyc++;
1030         }
1031
1032
1033         count=57;
1034         for(Int_t dyd=15;dyd<=19;dyd++)
1035
1036         {
1037
1038                 Float_t posx1=constants->ModulePositionX(dyd)+0.1*293*0.7071-56*0.7071-18+des;
1039                 Float_t posy1=constants->ModulePositionY(dyd)-0.1*293*0.7071-56*0.7071+3-des-q1-0.8+kro;
1040                 Float_t poszd=constants->ModulePositionZ(dyd);
1041                 Float_t posx2=constants->ModulePositionX(dyd)-0.27*293*0.7071-56*0.7071-18+des;
1042                 Float_t posy2=constants->ModulePositionY(dyd)+0.27*293*0.7071-56*0.7071+3-des-1.5-q1-0.8+kro;
1043                 TGeoRotation *rot1 = new TGeoRotation();
1044                 rot1->RotateZ(70);
1045                 TGeoCombiTrans *aco7q14 = new TGeoCombiTrans("aco7q14",posx1,posy1,poszd,idrotm231);
1046                 TGeoCombiTrans *aco7q15 = new TGeoCombiTrans("aco7q15",posx2+15,posy2-10,poszd,rot1);
1047                 inFace->AddNode(aCORDE7,count,aco7q14);
1048                 inFace->AddNode(aCORDE7,count+1,aco7q15);// bars 25 grades
1049                 count=count+2;
1050                 dyd++;
1051         }
1052
1053
1054         //*** Out Face ***
1055
1056 //      box[0]=39;
1057         box[0]=27;
1058         box[1]=5;
1059         box[2]=5;
1060         Float_t s1=2.5;
1061         Float_t posxqa=constants->ModulePositionX(50)-0.5*293*0.7071+56*0.7071+18;
1062         Float_t posyqa=constants->ModulePositionY(50)-0.5*293*0.7071-56*0.7071+3-s1+kro;
1063         Float_t poszqa=constants->ModulePositionZ(50);
1064         TGeoCombiTrans *aco7q16 = new TGeoCombiTrans("aco7q16",
1065                                         posxqa,posyqa,poszqa-4*dy,idrotm232);
1066         TGeoCombiTrans *aco7q17 = new TGeoCombiTrans("aco7q17",
1067                                         posxqa,posyqa,
1068                                         constants->ModulePositionZ(43)-4*dy,idrotm232);
1069         TGeoCombiTrans *aco7q18 = new TGeoCombiTrans("aco7q18",posxqa,posyqa,
1070                                         constants->ModulePositionZ(55)-4*dy,idrotm232);
1071         TGeoCombiTrans *aco7q19 = new TGeoCombiTrans("aco7q19",posxqa,posyqa,
1072                                         constants->ModulePositionZ(58)-4*dy,idrotm232);
1073         TGeoCombiTrans *aco7q20 = new TGeoCombiTrans("aco7q20",
1074                                         constants->ModulePositionX(50)-0.1*293*0.7071
1075                                         +56*0.7071+18-des,
1076                                         constants->ModulePositionY
1077                                         (50)-0.1*293*0.7071-56*0.7071+3-des-s1,
1078                                         constants->ModulePositionZ(45),idrotm232);
1079         TGeoCombiTrans *aco7q21 = new TGeoCombiTrans("aco7q21",
1080                                         constants->ModulePositionX(50)+0.27*293*0.7071
1081                                         +56*0.7071+18-des,
1082                                         constants->ModulePositionY(50)
1083                                         +0.27*293*0.7071-56*0.7071+3-des-s1,
1084                                         constants->ModulePositionZ(45),idrotm232);
1085         outFace->AddNode(aCORDE7,19,aco7q16);
1086         outFace->AddNode(aCORDE7,20,aco7q17);
1087         outFace->AddNode(aCORDE7,21,aco7q18);
1088         outFace->AddNode(aCORDE7,22,aco7q19);
1089         outFace->AddNode(aCORDE7,23,aco7q20);
1090         outFace->AddNode(aCORDE7,24,aco7q21);
1091
1092
1093         count=25;
1094         for(Int_t dye=50;dye<=54;dye++)
1095         {
1096
1097                 Float_t posx1=constants->ModulePositionX(dye)-0.1*293*0.7071+56*0.7071+18-des;
1098                 Float_t posy1=constants->ModulePositionY(dye)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
1099                 Float_t posze=constants->ModulePositionZ(dye);
1100                 Float_t posx2=constants->ModulePositionX(dye)+0.27*293*0.7071+56*0.7071+18-des;
1101                 Float_t posy2=constants->ModulePositionY(dye)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
1102                 TGeoCombiTrans *aco7q22 = new TGeoCombiTrans("aco7q22",posx1,posy1,posze,idrotm232);
1103                 TGeoCombiTrans *aco7q23 = new TGeoCombiTrans("aco7q23",posx2,posy2,posze,idrotm232);
1104                 outFace->AddNode(aCORDE7,count,aco7q22);
1105                 outFace->AddNode(aCORDE7,count+1,aco7q23);
1106                 count=count+2;
1107                 dye++;
1108         }
1109
1110
1111         count=35;
1112         for(Int_t dyf=57;dyf<=59;dyf++)
1113         {
1114
1115                 Float_t posx1=constants->ModulePositionX(dyf)-0.1*293*0.7071+56*0.7071+18-des;
1116                 Float_t posy1=constants->ModulePositionY(dyf)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
1117                 Float_t poszf=constants->ModulePositionZ(dyf-10);
1118                 Float_t posx2=constants->ModulePositionX(dyf)+0.27*293*0.7071+56*0.7071+18-des;
1119                 Float_t posy2=constants->ModulePositionY(dyf)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
1120                 TGeoCombiTrans *aco7q24 = new TGeoCombiTrans("aco7q24",posx1,posy1,poszf,idrotm232);
1121                 TGeoCombiTrans *aco7q25 = new TGeoCombiTrans("aco7q25",posx2,posy2,poszf,idrotm232);
1122                 outFace->AddNode(aCORDE7,count,aco7q24);
1123                 outFace->AddNode(aCORDE7,count+1,aco7q25);
1124                 count=count+2;
1125                 dyf++;
1126         }
1127
1128
1129         Float_t posxqb=constants->ModulePositionX(40)-0.5*293*0.7071+56*0.7071+18;
1130         Float_t posyqb=constants->ModulePositionY(40)-0.5*293*0.7071-56*0.7071+3-s1+kro;
1131         Float_t poszqb=constants->ModulePositionZ(40);
1132         TGeoCombiTrans *aco7q26 = new TGeoCombiTrans("aco7q26",
1133                                         posxqb,posyqb,poszqb-4*dy,idrotm232);
1134         TGeoCombiTrans *aco7q27 = new TGeoCombiTrans("aco7q27",
1135                                         posxqb,posyqb,
1136                                         constants->ModulePositionZ(43)-4*dy,idrotm232);
1137         TGeoCombiTrans *aco7q28 = new TGeoCombiTrans("aco7q28",
1138                                         posxqb,posyqb,
1139                                         constants->ModulePositionZ(45)-4*dy,idrotm232);
1140         TGeoCombiTrans *aco7q29 = new TGeoCombiTrans("aco7q29",posxqb,posyqb,
1141                                         constants->ModulePositionZ(48)-4*dy,idrotm232);
1142         outFace->AddNode(aCORDE7,41,aco7q26);
1143         outFace->AddNode(aCORDE7,42,aco7q27);
1144         outFace->AddNode(aCORDE7,43,aco7q28);
1145         outFace->AddNode(aCORDE7,44,aco7q29);
1146
1147         count=45;
1148         for(Int_t dyg=40;dyg<=44;dyg++)
1149         {
1150
1151                 Float_t posx1=constants->ModulePositionX(dyg)-0.1*293*0.7071+56*0.7071+18-des;
1152                 Float_t posy1=constants->ModulePositionY(dyg)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
1153                 Float_t poszg=constants->ModulePositionZ(dyg);
1154                 Float_t posx2=constants->ModulePositionX(dyg)+0.27*293*0.7071+56*0.7071+18-des;
1155                 Float_t posy2=constants->ModulePositionY(dyg)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
1156                 TGeoRotation *rot1 = new TGeoRotation();
1157                 rot1->RotateZ(105);
1158                 TGeoCombiTrans *aco7q30 = new TGeoCombiTrans("aco7q30",posx1,posy1,poszg,idrotm232);
1159                 TGeoCombiTrans *aco7q31 = new TGeoCombiTrans("aco7q31",posx2-15,posy2-10,poszg,rot1);
1160                 outFace->AddNode(aCORDE7,count,aco7q30);
1161                 outFace->AddNode(aCORDE7,count+1,aco7q31);// bars 25 grades
1162                 count=count+2;
1163                 dyg++;
1164         }
1165
1166
1167         count=55;
1168         for(Int_t dyh=45;dyh<=49;dyh++)
1169         {
1170
1171                 Float_t posx1=constants->ModulePositionX(dyh)-0.1*293*0.7071+56*0.7071+18-des;
1172                 Float_t posy1=constants->ModulePositionY(dyh)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
1173                 Float_t poszh=constants->ModulePositionZ(dyh);
1174                 Float_t posx2=constants->ModulePositionX(dyh)+0.27*293*0.7071+56*0.7071+18-des;
1175                 Float_t posy2=constants->ModulePositionY(dyh)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
1176                 TGeoRotation *rot1 = new TGeoRotation();
1177                 rot1->RotateZ(105);
1178                 TGeoCombiTrans *aco7q32 = new TGeoCombiTrans("aco7q32",posx1,posy1,poszh,idrotm232);
1179                 TGeoCombiTrans *aco7q33 = new TGeoCombiTrans("aco7q33",posx2-15,posy2-10,poszh,rot1);
1180                 outFace->AddNode(aCORDE7,count,aco7q32);
1181                 outFace->AddNode(aCORDE7,count+1,aco7q33);// bars 25 grades
1182                 count=count+2;
1183                 dyh++;
1184         }
1185
1186
1187
1188         // Set the bars non perpendicular at side faces
1189
1190         //*** In-Face ***
1191
1192         box[0]=5;
1193 //      box[1]=55.15;
1194         box[1]=40;
1195         box[2]=5;
1196         Float_t sm=2;
1197         Float_t re=1;
1198         Float_t posx1=constants->ModulePositionX(0)+0.5*293*0.7071-4*box[0]-8+re;
1199         Float_t posy1=constants->ModulePositionY(0)-0.5*293*0.7071-box[1]-18-2+sm;
1200         Float_t posz1=constants->ModulePositionZ(0);
1201
1202         TGeoBBox *acorde7q1 = new TGeoBBox("acorde7q1",box[0],box[1],box[2]);
1203
1204         TGeoVolume *aCORDE7q1 = new TGeoVolume("ACORDE7_1",acorde7q1,al);
1205         TGeoTranslation *aco71 = new TGeoTranslation("aco71",posx1,posy1,posz1-4*dy);
1206         TGeoTranslation *aco72 = new TGeoTranslation("aco72",posx1,posy1,
1207                                         constants->ModulePositionZ(3)-4*dy);
1208         TGeoTranslation *aco73 = new TGeoTranslation("aco73",posx1,posy1,
1209                                         constants->ModulePositionZ(5)-4*dy);
1210         TGeoTranslation *aco74 = new TGeoTranslation("aco74",posx1,posy1,
1211                                         constants->ModulePositionZ(8)-4*dy);
1212         inFace->AddNode(aCORDE7q1,67,aco71);
1213         inFace->AddNode(aCORDE7q1,68,aco72);
1214         inFace->AddNode(aCORDE7q1,69,aco73);
1215         inFace->AddNode(aCORDE7q1,70,aco74);
1216
1217
1218         count=71;
1219         for(Int_t dyi=0;dyi<=4;dyi++)
1220         {
1221
1222                 Float_t posx1a=constants->ModulePositionX(dyi)+0.1*293*0.7071-4*box[0]-8+des+re;
1223                 Float_t posy1a=constants->ModulePositionY(dyi)-0.1*293*0.7071-box[1]-18-2-des+sm;
1224                 Float_t posz1a=constants->ModulePositionZ(dyi);
1225                 Float_t dyx2=constants->ModulePositionX(dyi)-0.27*293*0.7071-4*box[0]-8+des+re;
1226                 Float_t dyy2=constants->ModulePositionY(dyi)+0.27*293*0.7071-box[1]-18-2-des+sm;
1227                 TGeoTranslation *aco75=new TGeoTranslation("aco75",posx1a,posy1a,posz1a);
1228                 TGeoTranslation *aco76=new TGeoTranslation("aco76",dyx2,dyy2,posz1a);
1229                 inFace->AddNode(aCORDE7q1,count,aco75);
1230                 inFace->AddNode(aCORDE7q1,count+1,aco76);
1231                 count=count+2;
1232                 dyi++;
1233         }
1234
1235
1236         count=81;
1237         for(Int_t dyj=5;dyj<=9;dyj++)
1238         {
1239
1240                 Float_t posx1b=constants->ModulePositionX(dyj)+0.1*293*0.7071-4*box[0]-8+des+re;
1241                 Float_t posy1b=constants->ModulePositionY(dyj)-0.1*293*0.7071-box[1]-18-2-des+sm;
1242                 Float_t posz1b=constants->ModulePositionZ(dyj+10);
1243                 Float_t dyx2=constants->ModulePositionX(dyj)-0.27*293*0.7071-4*box[0]-8+des+re;
1244                 Float_t dyy2=constants->ModulePositionY(dyj)+0.27*293*0.7071-box[1]-18-2-des+sm;
1245                 TGeoTranslation *aco75=new TGeoTranslation("aco75",posx1b,posy1b,posz1b);
1246                 TGeoTranslation *aco76=new TGeoTranslation("aco76",dyx2,dyy2,posz1b);
1247                 inFace->AddNode(aCORDE7q1,count,aco75);
1248                 inFace->AddNode(aCORDE7q1,count+1,aco76);
1249                 count=count+2;
1250                 dyj++;
1251         }
1252
1253
1254         Float_t posx1q1=constants->ModulePositionX(10)+0.5*293*0.7071-4*box[0]-8+re;
1255         Float_t posy1q1=constants->ModulePositionY(10)-0.5*293*0.7071-box[1]-18-2+sm;
1256         Float_t posz1q1=constants->ModulePositionZ(10);
1257         TGeoTranslation *aco77=new TGeoTranslation("aco77",posx1q1,posy1q1,posz1q1-4*dy);
1258         TGeoTranslation *aco78=new TGeoTranslation("aco78",posx1q1,posy1q1,
1259                                         constants->ModulePositionZ(13)-4*dy);
1260
1261         TGeoTranslation *aco79=new TGeoTranslation("aco79",posx1q1,posy1q1,
1262                                         constants->ModulePositionZ(15)-4*dy);
1263         TGeoTranslation *aco710=new TGeoTranslation("aco710",posx1q1,posy1q1,
1264                                         constants->ModulePositionZ(18)-4*dy);
1265         inFace->AddNode(aCORDE7q1,91,aco77);
1266         inFace->AddNode(aCORDE7q1,92,aco78);
1267         inFace->AddNode(aCORDE7q1,93,aco79);
1268         inFace->AddNode(aCORDE7q1,94,aco710);
1269
1270         count=95;
1271         for(Int_t dyk=10;dyk<=14;dyk++)
1272         {
1273
1274                 Float_t posx1c=constants->ModulePositionX(dyk)+0.1*293*0.7071-4*box[0]-8+des+re+.83;
1275                 Float_t posy1c=constants->ModulePositionY(dyk)-0.1*293*0.7071-box[1]-18-2-des+sm;
1276                 Float_t posz1c=constants->ModulePositionZ(dyk);
1277                 Float_t dyx2=constants->ModulePositionX(dyk)-0.27*293*0.7071-4*box[0]-4+des+re+0.83;
1278                 Float_t dyy2=constants->ModulePositionY(dyk)+0.27*293*0.7071-box[1]-18-5-des+sm;
1279                 TGeoTranslation *aco711=new TGeoTranslation("aco711",posx1c,posy1c,posz1c);
1280                 TGeoTranslation *aco712=new TGeoTranslation("aco712",dyx2,dyy2,posz1c);
1281                 inFace->AddNode(aCORDE7q1,count,aco711);
1282                 inFace->AddNode(aCORDE7q1,count+1,aco712);
1283                 count=count+2;
1284                 dyk++;
1285         }
1286
1287
1288
1289         count=105;
1290         for(Int_t dyl=15;dyl<=19;dyl++)
1291         {
1292
1293                 Float_t posx1d=constants->ModulePositionX(dyl)+0.1*293*0.7071-4*box[0]-8+des+re+0.83;
1294                 Float_t posy1d=constants->ModulePositionY(dyl)-0.1*293*0.7071-box[1]-18-2-des+sm;
1295                 Float_t posz1d=constants->ModulePositionZ(dyl);
1296                 Float_t dyx2=constants->ModulePositionX(dyl)-0.27*293*0.7071-4*box[0]-4+des+re+0.83;
1297                 Float_t dyy2=constants->ModulePositionY(dyl)+0.27*293*0.7071-box[1]-18-5-des;
1298                 TGeoTranslation *aco713=new TGeoTranslation("aco713",posx1d,posy1d,posz1d);
1299                 TGeoTranslation *aco714=new TGeoTranslation("aco714",dyx2,dyy2,posz1d);
1300                 inFace->AddNode(aCORDE7q1,count,aco713);
1301                 inFace->AddNode(aCORDE7q1,count+1,aco714);
1302                 count=count+2;
1303                 dyl++;
1304         }
1305
1306                 //*** Out-Face ***
1307
1308         Float_t posx1qa=constants->ModulePositionX(50)-0.5*293*0.7071+4*box[0]+8-re-1;
1309         Float_t posy1qa=constants->ModulePositionY(50)-0.5*293*0.7071-box[1]-18-2+sm-2.5;
1310         Float_t posz1qa=constants->ModulePositionZ(50);
1311         TGeoTranslation *aco715=new TGeoTranslation("aco715",posx1qa,posy1qa,posz1qa-4*dy);
1312         TGeoTranslation *aco716=new TGeoTranslation("aco716",posx1qa,posy1qa,
1313                                 constants->ModulePositionZ(43)-4*dy);
1314         TGeoTranslation *aco717=new TGeoTranslation("aco717",posx1qa,posy1qa,
1315                                 constants->ModulePositionZ(55)-4*dy);
1316         TGeoTranslation *aco718=new TGeoTranslation("aco718",posx1qa,posy1qa,
1317                                 constants->ModulePositionZ(58)-4*dy);
1318         TGeoTranslation *aco719=new TGeoTranslation("aco719",
1319                                 constants->ModulePositionX(50)-0.1*293*0.7071+4*box[0]+8-des-re-1,              
1320                                 constants->ModulePositionY(50)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5,
1321                                 constants->ModulePositionZ(45));
1322         TGeoTranslation *aco720=new TGeoTranslation("aco720",
1323                                 constants->ModulePositionX(50)+0.27*293*0.7071+4*box[0]+8-des-re-1,
1324                                 constants->ModulePositionY(50)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5,
1325                                 constants->ModulePositionZ(45));
1326
1327
1328         outFace->AddNode(aCORDE7q1,115,aco715);
1329         outFace->AddNode(aCORDE7q1,116,aco716);
1330         outFace->AddNode(aCORDE7q1,117,aco717);
1331         outFace->AddNode(aCORDE7q1,118,aco718);
1332         outFace->AddNode(aCORDE7q1,119,aco719);
1333         outFace->AddNode(aCORDE7q1,120,aco720);
1334
1335
1336
1337
1338         count=65;
1339         for(Int_t dym=50;dym<=54;dym++)
1340         {
1341
1342                 Float_t posx1e=constants->ModulePositionX(dym)-0.1*293*0.7071+4*box[0]+8-des-re-1;
1343                 Float_t posy1e=constants->ModulePositionY(dym)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
1344                 Float_t posz1e=constants->ModulePositionZ(dym);
1345                 Float_t dyx2=constants->ModulePositionX(dym)+0.27*293*0.7071+4*box[0]+8-des-re-1;
1346                 Float_t dyy2=constants->ModulePositionY(dym)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5;
1347                 TGeoTranslation *aco721=new TGeoTranslation("aco721",posx1e,posy1e,posz1e);
1348                 TGeoTranslation *aco722=new TGeoTranslation("aco722",dyx2,dyy2,posz1e);
1349                 outFace->AddNode(aCORDE7q1,count,aco721);
1350                 outFace->AddNode(aCORDE7q1,count+1,aco722);
1351                 count=count+2;
1352                 dym++;
1353         }
1354
1355
1356
1357         count=75;
1358         for(Int_t dyn=57;dyn<=59;dyn++)
1359         {
1360
1361                 Float_t posx1f=constants->ModulePositionX(dyn)-0.1*293*0.7071+4*box[0]+8-des-re-1;
1362                 Float_t posy1f=constants->ModulePositionY(dyn)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
1363                 Float_t posz1f=constants->ModulePositionZ(dyn-10);
1364                 Float_t dyx2=constants->ModulePositionX(dyn)+0.27*293*0.7071+4*box[0]+8-des-re-1;
1365                 Float_t dyy2=constants->ModulePositionY(dyn)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5;
1366                 TGeoTranslation *aco723=new TGeoTranslation("aco723",posx1f,posy1f,posz1f);
1367                 TGeoTranslation *aco724=new TGeoTranslation("aco724",dyx2,dyy2,posz1f);
1368                 outFace->AddNode(aCORDE7q1,count,aco723);
1369                 outFace->AddNode(aCORDE7q1,count+1,aco724);
1370                 count=count+2;
1371                 dyn++;
1372         }
1373
1374
1375         Float_t posx1qb=constants->ModulePositionX(40)-0.5*293*0.7071+4*box[0]+5;
1376         Float_t posy1qb=constants->ModulePositionY(40)-0.5*293*0.7071-box[1]-18-2;
1377         Float_t posz1qb=constants->ModulePositionZ(40);
1378         TGeoTranslation *aco725=new TGeoTranslation("aco725",posx1qb,posy1qb,posz1qb-4*dy);
1379         TGeoTranslation *aco726=new TGeoTranslation("aco726",posx1qb,posy1qb,
1380                                 constants->ModulePositionZ(43)-4*dy);
1381         TGeoTranslation *aco727=new TGeoTranslation("aco727",posx1qb,posy1qb,
1382                                 constants->ModulePositionZ(45)-4*dy);
1383         TGeoTranslation *aco728=new TGeoTranslation("aco728",posx1qb,posy1qb,
1384                                 constants->ModulePositionZ(48)-4*dy);
1385         outFace->AddNode(aCORDE7q1,85,aco725);
1386         outFace->AddNode(aCORDE7q1,86,aco726);
1387         outFace->AddNode(aCORDE7q1,87,aco727);
1388         outFace->AddNode(aCORDE7q1,88,aco728);
1389
1390
1391
1392         count=89;
1393         for(Int_t dyo=40;dyo<=44;dyo++)
1394         {
1395
1396                 Float_t posx1g=constants->ModulePositionX(dyo)-0.1*293*0.7071+4*box[0]+8-des-re-1;
1397                 Float_t posy1g=constants->ModulePositionY(dyo)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
1398                 Float_t posz1g=constants->ModulePositionZ(dyo);
1399                 Float_t dyx2=constants->ModulePositionX(dyo)+0.27*293*0.7071+4*box[0]+4-des-re-1+2.8;
1400                 Float_t dyy2=constants->ModulePositionY(dyo)+0.27*293*0.7071-box[1]-18-5-des+sm-2.5+3;
1401                 TGeoTranslation *aco729=new TGeoTranslation("aco729",posx1g,posy1g,posz1g);
1402                 TGeoTranslation *aco730=new TGeoTranslation("aco730",dyx2,dyy2,posz1g);
1403                 outFace->AddNode(aCORDE7q1,count,aco729);
1404                 outFace->AddNode(aCORDE7q1,count+1,aco730);
1405                 count=count+2;
1406                 dyo++;
1407         }
1408
1409
1410
1411         count=99;
1412         for(Int_t dyp=45;dyp<=49;dyp++)
1413         {
1414
1415                 Float_t posx1h=constants->ModulePositionX(dyp)-0.1*293*0.7071+4*box[0]+8-des-re-1;
1416                 Float_t posy1h=constants->ModulePositionY(dyp)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
1417                 Float_t posz1h=constants->ModulePositionZ(dyp);
1418                 Float_t dyx2=constants->ModulePositionX(dyp)+0.27*293*0.7071+4*box[0]+4-des-re-1+2.8;
1419                 Float_t dyy2=constants->ModulePositionY(dyp)+0.27*293*0.7071-box[1]-18-5-des+sm-2.5+3;
1420                 TGeoTranslation *aco729=new TGeoTranslation("aco729",posx1h,posy1h,posz1h);
1421                 TGeoTranslation *aco730=new TGeoTranslation("aco730",dyx2,dyy2,posz1h);
1422                 outFace->AddNode(aCORDE7q1,count,aco729);
1423                 outFace->AddNode(aCORDE7q1,count+1,aco730);
1424                 count=count+2;
1425                 dyp++;
1426         }
1427
1428
1429         // Here I define a master volume "ACORDE_SUPPORT" for Acorde's support
1430
1431         //---> Set the support of ACORDE alice MODULES
1432
1433
1434         Float_t dy1=20;
1435         box[0]=10;
1436         box[1]=0.5;
1437         box[2]=500;
1438
1439         Float_t sx=constants->ModulePositionX(24)-0.5*293;
1440         Float_t sy=constants->ModulePositionY(24)-box[1];
1441         Float_t sz=0;
1442         Float_t sx2=constants->ModulePositionX(24)+0.5*293-dy;
1443         Float_t sy2=constants->ModulePositionY(24)-box[1];
1444         Float_t sx4=constants->ModulePositionX(24)-0.5*293+dy2;
1445         Float_t sy4=constants->ModulePositionY(24)-box[1];
1446         Float_t sx5=constants->ModulePositionX(24)+0.5*293-dy2;
1447         Float_t sy5=constants->ModulePositionY(24)-box[1];
1448
1449         Float_t dyx=constants->ModulePositionX(4)+0.5*293*0.7071-box[0];
1450         Float_t dyy=constants->ModulePositionY(4)-0.5*293*0.7071-box[1];
1451         Float_t dyz=0;
1452         Float_t dyx1=constants->ModulePositionX(4)+0.1*293*0.7071-box[0];
1453         Float_t dyy1=constants->ModulePositionY(4)-0.1*293*0.7071-box[1];
1454         Float_t dyx2=constants->ModulePositionX(4)-0.27*293*0.7071-box[0];
1455         Float_t dyy2=constants->ModulePositionY(4)+0.27*293*0.7071-box[1];
1456
1457
1458         Float_t dx1=constants->ModulePositionX(14)+0.5*293*0.7071-box[0];
1459         Float_t dy11=constants->ModulePositionY(14)-0.5*293*0.7071-box[1];
1460         Float_t dyx11=constants->ModulePositionX(14)+0.1*293*0.7071-box[0];
1461         Float_t dyy11=constants->ModulePositionY(14)-0.1*293*0.7071-box[1];
1462         Float_t dyx21=constants->ModulePositionX(14)-0.27*293*0.7071-box[0];
1463         Float_t dyy21=constants->ModulePositionY(14)+0.27*293*0.7071-box[1];
1464
1465
1466         Float_t tbox[3];
1467         tbox[0]=1;
1468         tbox[1]=7;
1469         tbox[2]=500;
1470
1471         TGeoVolume *support = new TGeoVolumeAssembly("ACORDE_SUPPORT");
1472
1473         TGeoBBox *acorde8 = new TGeoBBox("acorde8",box[0],box[1],box[2]);
1474         TGeoVolume *aCORDE8 = new TGeoVolume("ACORDE8",acorde8,al);
1475
1476         TGeoBBox *acorde9 = new TGeoBBox("acorde9",tbox[0],tbox[1],tbox[2]);
1477         TGeoVolume *aCORDE9 = new TGeoVolume("ACORDE9",acorde9,al);
1478
1479         support->AddNode(aCORDE8,1,new TGeoTranslation(0,-5,0));
1480         support->AddNode(aCORDE8,2,new TGeoTranslation(0,-dy1,0));
1481         support->AddNode(aCORDE9,3,new TGeoTranslation(0,-tbox[1]-5.5,0));
1482
1483
1484         // Put "support" on Up-Face
1485
1486         upFace->AddNode(support,69,new TGeoTranslation("aco8",sx,sy,sz));
1487         upFace->AddNode(support,70,new TGeoTranslation("aco8_2",sx2,sy2,sz));
1488         upFace->AddNode(support,71,new TGeoTranslation("aco8_4",sx4,sy4,sz));
1489         upFace->AddNode(support,72,new TGeoTranslation("aco8_6",sx5,sy5,sz));
1490         upFace->AddNode(support,73,new TGeoTranslation("aco8_2",-sx2,sy2,sz));
1491         upFace->AddNode(support,74,new TGeoTranslation("aco8_4",-sx4,sy4,sz));
1492         upFace->AddNode(support,75,new TGeoTranslation("aco8_6",-sx5,sy5,sz));
1493
1494         // Put "support" on In-Face
1495         Float_t ms = 1.3;
1496         inFace->AddNode(support,121,new TGeoCombiTrans("aco8_81",dyx,dyy+ms,dyz,idrotm232));
1497         inFace->AddNode(support,122,new TGeoCombiTrans("aco8_121",dyx1+des,ms+dyy1-des,dyz,idrotm232));
1498         inFace->AddNode(support,123,new TGeoCombiTrans("aco8_161",dyx2+des,ms+dyy2-des,dyz,idrotm232));
1499         inFace->AddNode(support,124,new TGeoCombiTrans("aco8_82",dx1,ms+dy11,dyz,idrotm232));
1500         inFace->AddNode(support,125,new TGeoCombiTrans("aco8_122",dyx11+des,ms+dyy11-des,dyz,idrotm232));
1501         inFace->AddNode(support,126,new TGeoCombiTrans("aco8_162",dyx21+des,ms+dyy21-des,dyz,idrotm232));
1502
1503         // Put "support" on Out-Face
1504
1505         outFace->AddNode(support,121,new TGeoCombiTrans("aco8_81",-dyx,dyy+ms,dyz,idrotm231));
1506         outFace->AddNode(support,122,new TGeoCombiTrans("aco8_121",-dyx1-des,ms+dyy1-des,dyz,idrotm231));
1507         outFace->AddNode(support,123,new TGeoCombiTrans("aco8_161",-dyx2-des,ms+dyy2-des,dyz,idrotm231));
1508         outFace->AddNode(support,124,new TGeoCombiTrans("aco8_82",-dx1,dy11+ms,dyz,idrotm231));
1509         outFace->AddNode(support,125,new TGeoCombiTrans("aco8_122",-dyx11-des,ms+dyy11-des,dyz,idrotm231));
1510         outFace->AddNode(support,126,new TGeoCombiTrans("aco8_162",-dyx21-des,ms+dyy21-des,dyz,idrotm231));
1511         
1512         aCORDE->AddNode(inFace,1);//---> volume of supports & bars in-face
1513         aCORDE->AddNode(upFace,2);//---> volume of supports & bars up-face
1514         aCORDE->AddNode(outFace,3);//---> volume of supports & bars out-face
1515 //      aCORDE->AddNode(inFacem,4);//---> volume of modules in-face
1516 //      aCORDE->AddNode(upFacem,5);//---> volume of modules up-face
1517 //      aCORDE->AddNode(outFacem,6);//---> volume of modules out-face
1518         aCORDE->AddNode(modules,4);//---> volume of ALL ACORDE's Modules
1519         alice->AddNode(aCORDE,1);//---> put volume of ACORDE over ALICE's volume
1520
1521
1522
1523 }
1524
1525
1526 //_____________________________________________________________________________
1527 void AliACORDEv1::DrawDetector() const
1528 {
1529
1530   // not needed anymore
1531
1532 }
1533
1534 //____________________________________________________________________________
1535
1536 void AliACORDEv1::Init()
1537 {
1538   // Initialise L3 magnet after it has been built
1539   Int_t i;
1540   if(AliLog::GetGlobalDebugLevel()>0) {
1541     printf("\n%s: ",ClassName());
1542     for(i=0;i<35;i++) printf("*");
1543     printf(" ACORDEv1_INIT ");
1544     for(i=0;i<35;i++) printf("*");
1545     printf("\n%s: ",ClassName());
1546     // Here the ACORDEv initialisation code (if any!)
1547     for(i=0;i<80;i++) printf("*");
1548     printf("\n");
1549   }
1550  // AliACORDE::Init();  
1551 }
1552 //____________________________________________________________________________
1553 void AliACORDEv1::StepManager()
1554 {
1555
1556   //
1557   // Called for every step in the Cosmic Ray Trigger
1558   //
1559
1560
1561   // volume: 
1562   //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
1563   //  [1] = Plastic number: 0 (down) to 1 (up)
1564   static Int_t   vol[2]; 
1565   //
1566   // hit
1567   // [0] = PID
1568   // [1-3] = x, y, z 
1569   // [4] = time 
1570   // [5-7] = px, py, pz
1571   // [8] = energy 
1572   // [9] = energy loss
1573   // [10] = length of track through plastic
1574   static Float_t hits[11];
1575
1576   // local static variables
1577   static Float_t eloss;
1578   static Float_t step;
1579   // scintillator volume
1580  static Int_t idScint = gMC->VolId("ACORDE2");
1581   // local variables
1582   Int_t copy;
1583   TLorentzVector pos;
1584   TLorentzVector mom;
1585
1586   // only charged tracks
1587   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
1588
1589   // only in sensitive material
1590   if (gMC->CurrentVolID(copy) == idScint) {
1591
1592     //printf("Hay particula cargada en el volumen %d \n",idScint);
1593     step  += gMC->TrackStep();
1594     eloss += gMC->Edep();
1595     // set all hit variables except eloss which is resetted
1596     // set volume variables
1597     if (gMC->IsTrackEntering()) {
1598       eloss = 0.0;
1599       step = 0.0;
1600       gMC->TrackPosition(pos);
1601       gMC->TrackMomentum(mom);
1602       // hit
1603       // [0] = PID
1604       // [1-3] = x, y, z 
1605       // [4] = time 
1606       // [5-7] = px, py, pz
1607       // [8] = energy 
1608       // [9] = energy loss
1609       hits[0]  = (Float_t ) gMC->TrackPid(); 
1610
1611
1612       hits[1] = pos[0]; //printf("PosX %f \n",hits[1]);
1613       hits[2] = pos[1]; //printf("PosY %f \n",hits[2]);
1614       hits[3] = pos[2]; //printf("PosZ %f \n",hits[3]);
1615       hits[4] = gMC->TrackTime();//printf("TimeTracking %f \n",hits[4]);
1616       hits[5] = mom[0]; //printf("MomentoX %f \n",hits[5]);
1617       hits[6] = mom[1]; //printf("MomentoY %f \n",hits[6]);
1618       hits[7] = mom[2]; //printf("MomentoZ %f \n",hits[7]);
1619       hits[8] = gMC->Etot();//printf("EnergiaTotal %f \n",hits[8]);
1620       // volume: 
1621       //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
1622       //  [1] = Plastic number: 0 (down) to 1 (up)
1623       Int_t copyPlastic; // plastic: down=1, up=2
1624       Int_t copyModule; // module: 1-60
1625       gMC->CurrentVolID(copyPlastic);
1626       gMC->CurrentVolOffID(1, copyModule);
1627       // module
1628       vol[0] = copyModule;
1629       // plastic: 0 = down, 1 = up
1630       vol[1] = copyPlastic - 4 ; // !!!!!!!
1631     // vol[1] = copyPlastic;
1632     } // end if gMC->IsTrackEntering()
1633
1634     // set hit[9] = total energy loss and book hit
1635     if( gMC->IsTrackExiting() || 
1636         gMC->IsTrackStop() || 
1637         gMC->IsTrackDisappeared()){
1638       hits[9] = eloss;//printf("Energia Perdida %f \n",hits[9]);
1639       hits[10] = step;
1640       eloss = 0.0;
1641       step = 0.0;
1642       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1643      }
1644   } 
1645
1646
1647
1648 }
1649
1650 //_____________________________________________________________________________
1651 void AliACORDEv1::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1652 {
1653   //
1654   // Add an ACORDE hit
1655   //
1656   TClonesArray &lhits = *fHits;
1657   new(lhits[fNhits++]) AliACORDEhit(fIshunt,track,vol,hits);
1658 }
1659
1660 //_____________________________________________________________________________
1661 void AliACORDEv1::AddDigits(Int_t* track, Int_t module, Float_t time)
1662 //void AliACORDEv1::AddDigits(Int_t track, Int_t *vol, Float_t *digits)
1663 {
1664   
1665   // Adds Digit
1666   
1667   TClonesArray &ldigits = *fDigits;
1668   new(ldigits[fNdigits++]) AliACORDEdigit(track,module,time);
1669 }
1670 //_____________________________________________________________________________
1671
1672
1673
1674 //_____________________________________________________________________________
1675 void AliACORDEv1::MakeBranch(Option_t *option)
1676 {
1677 // Creates new branches in the current Root Tree
1678     
1679   char branchname[10];
1680   sprintf(branchname,"%s",GetName());
1681   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
1682   const char *cH = strstr(option,"H");
1683   if (fHits   && TreeH() && cH) {
1684     TreeH()->Branch(branchname,&fHits, fBufferSize);
1685     AliDebug(2,Form("Making Branch %s for hits",branchname));
1686   }     
1687   const char *cD = strstr(option,"D");
1688   if (fDigits   && fLoader->TreeD() && cD) {
1689     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1690     AliDebug(2,Form("Making Branch %s for digits",branchname));
1691   }  
1692 }
1693
1694 //_____________________________________________________________________________
1695 void AliACORDEv1::AddAlignableVolumes() const
1696 {
1697   //
1698   // Create entries for alignable volumes associating the symbolic volume
1699   // name with the corresponding volume path. Needs to be syncronized with
1700   // eventual changes in the geometry.
1701   // 
1702
1703         // The alignable volumes are only the "ACORDE_MODULE_%d"
1704         //
1705         //      Structure of ACORDE's Geometry
1706         //
1707         //      ALIC_1
1708         //          |---> ACORDE_1      
1709         //                      |----> ACORDE_1_1 (in_face) ---
1710         //                      |----> ACORDE_2_2 (up_face)    |--> BARS&SUPPORTS
1711         //                      |----> ACORDE_3_3 (out_face)---
1712         //                      |----> ACORDE_MODULES_4        |--> ACORDE'S MODULES
1713         //              
1714         //
1715         //     Send comments to: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
1716
1717         TString vpstr1 = "ALIC_1/ACORDE_1/ALL_ACORDE_MODULES_4/ACORDE_MODULE_";
1718         TString snstr1 = "ACORDE/Array";
1719         TString volpath, symname;
1720         for(Int_t dy=1; dy<61 ; dy++)
1721         {
1722                 volpath = vpstr1;
1723                 volpath += dy;
1724                 symname = snstr1;
1725                 symname += dy;
1726                 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
1727                 AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
1728         }
1729 }