Speeding up the DA a bit
[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 final version of the ALICE Cosmic  //
23 //  Ray Trigger. This version will be used to simulation comic rays in alice //
24 //  with all the detectors.                                                  //
25 //  It include geometry and hits (position and momentum)                     //
26 //                                                                           //
27 //                  Send comments to:                                        //
28 //                                                                           //
29 //      Arturo Fernandez Tellez         <afernand@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 //      Last Update: Aug. 4th 2008                                           //
36 ///////////////////////////////////////////////////////////////////////////////
37
38
39 #include <Riostream.h>
40 #include <TGeoMatrix.h>
41 #include <TMath.h>
42 #include <TString.h>
43 #include <TSystem.h>
44
45 #include "AliConst.h"
46 #include "AliRun.h"
47
48 #include "TGeoManager.h"
49 #include "TGeoVolume.h"
50 #include "TGeoPcon.h"
51 #include "TGeoPgon.h"
52 #include "TGeoTrd1.h"
53 #include "TGeoCompositeShape.h"
54 #include "TGeoPara.h"
55
56 #include "AliACORDEv1.h"
57 #include <TClonesArray.h>
58 #include <TLorentzVector.h>
59 #include <TVirtualMC.h>
60 #include <TPDGCode.h>
61
62 #include "AliRun.h"
63 #include "AliConst.h"
64 #include "AliACORDEhit.h"
65 #include "AliACORDEConstants.h"
66 #include "AliMC.h"
67 #include "AliLog.h"
68
69 ClassImp(AliACORDEv1)
70  
71 //_____________________________________________________________________________
72 AliACORDEv1::AliACORDEv1()
73   : AliACORDE()
74 {
75   //
76   // Default constructor
77   fIshunt = 0;
78   fHits = 0;
79   //
80
81 //_____________________________________________________________________________
82 AliACORDEv1::AliACORDEv1(const char *name, const char *title)
83   : AliACORDE(name, title)
84 {
85   //
86   // Standard constructor
87   //
88   fIshunt = 1; // All hits are associated with primary particles 
89   fHits =  new TClonesArray("AliACORDEhit",400);
90   gAlice->GetMCApp()->AddHitList(fHits);
91 }
92 //_____________________________________________________________________________
93 AliACORDEv1::~AliACORDEv1()
94 {
95   //
96   // Default destructor
97   //
98 }
99 //_____________________________________________________________________________
100 void AliACORDEv1::CreateGeometry()
101 {
102   CreateAcorde();
103 }
104 void AliACORDEv1::CreateAcorde()
105 {  
106
107
108   //  _______________________________________________________________________________
109   // |                                                                               |  
110   // |                                                                               |  
111   // |  **** Acorde's Geometry using the TGeo Class....January 2008 ****             |
112   // |                                                                               |  
113   // |          ACORDE--> Volume for ACORDE in Alice's Magnet                        |
114   // |          ACORDE1_a--> Volume for frame of Acorde's Module                     |
115   // |          ACORDE10--> Volume for frame of Acorde's Module                      |
116   // |          ACORDE2--> Volume for scintillators in Acorde's Module               |
117   // |          ACORDE7--> Volume for bars                                           |
118   // |          ACORDE7_1--> Volume for side's bars                                  |  
119   // |          ACORDE8--> Volume for supports                                       |  
120   // |          ACORDE9--> Volume for supports                                       |          
121   // |          ACORDE_SUPPORT--> Volume that contains a full Acorde's support       |
122   // |          ALL_ACORDE_MODULES--> Volume that contains ALL Acorde's module       |  
123   // |          ACORDE_MODULE--> Volume that represents ONE Acorde-Module            |
124   // |          ACORDE_1--> Volume that contains the bars&supports in-face           |
125   // |          ACORDE_2--> Volume that contains the bars&supports up-face           |  
126   // |          ACORDE_3--> Volume that contains the bars&supports out-face          |
127   // |                                                                               |  
128   // |_______________________________________________________________________________|
129
130
131         // Call the global constants for the Modules
132         
133         AliACORDEConstants* constants = AliACORDEConstants::Instance();
134
135         // Get the Alice Volume
136
137         TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
138
139         // Define some materials & medium
140
141         //*** Support & Bars***
142
143         TGeoMedium* al    = gGeoManager->GetMedium("ACORDE_ALU_C0");
144         TGeoMedium* med6  = gGeoManager->GetMedium("ACORDE_CPV scint.1");
145         
146         //Define a FULL-ACORDE-VOLUME
147
148         TGeoVolume *aCORDE = new TGeoVolumeAssembly("ACORDE");
149
150
151         // Define 6 master volumes for ACORDE
152         
153         TGeoVolume *inFace = new TGeoVolumeAssembly("ACORDE_1");
154         TGeoVolume *upFace = new TGeoVolumeAssembly("ACORDE_2");
155         TGeoVolume *outFace = new TGeoVolumeAssembly("ACORDE_3");
156         TGeoVolume *modules = new TGeoVolumeAssembly("ALL_ACORDE_MODULES");
157
158         // Define global variables
159
160         Float_t box[3];
161         Int_t count;
162         Float_t dy=10;//-->displacement of the support and bars of ACORDE
163         Float_t dy2=66.5;//-->displacement of the support and bars of ACORDE
164         Float_t placedAt;
165         Float_t small=0.05;
166
167         // Define the position of support and bars for the sides faces
168
169         Float_t des = 22*0.7071;
170   
171         // Define rotation Matrix for Side's faces in Alice
172         
173         TGeoRotation *idrotm231 = new TGeoRotation("idrotm231",90, 45, 90, 135, 0, 0);
174         TGeoRotation *idrotm232 = new TGeoRotation("idrotm232",90, 315, 90, 45, 0, 0);
175
176         // Begin the Geometry of the structure for ACORDE
177
178         // *** Definition of ACORDE's Modules ***
179
180         // Define Measures of ACORDE's Modules
181
182         box[0] = constants->ModuleLength()/2;
183         box[1] = constants->ModuleHeight()/2;
184         box[2] = constants->ModuleWidth()/2;
185
186         // Define Measures of Scintillators
187         
188         Float_t pbox[3];        
189         pbox[0] = constants->PlasticLength()/2;
190         pbox[1] = constants->PlasticHeight()/2;
191         pbox[2] = constants->PlasticWidth()/2;
192
193
194         // Create the Modules, Scintillators & Metallic Frame
195
196         //*** Aluminium frame ***
197
198         TGeoBBox *acorde1 = new TGeoBBox("acorde1",box[0],box[1],26/20+2);
199         TGeoBBox *acorde10 = new TGeoBBox("acorde10",26/20,box[1],box[2]+3);
200         TGeoVolume *aCORDE1qa = new TGeoVolume("ACORDE1_a",acorde1,al);
201         TGeoVolume *aCORDE10 = new TGeoVolume("ACORDE10",acorde10,al);
202
203         //*** Scintillators ***
204
205         TGeoBBox *acorde2 = new TGeoBBox("acorde2",pbox[0],pbox[1],pbox[2]);
206         TGeoVolume *aCORDE2 = new TGeoVolume("ACORDE2",acorde2,med6);
207
208
209         // Here I define & construct a Master Volume ("ACORDE_MODULE") for one Module in ACORDE
210
211         TGeoVolume *acomodule = new TGeoVolumeAssembly("ACORDE_MODULE");
212         acomodule->AddNode(aCORDE1qa,1,new TGeoTranslation("aco1",0,0,13));
213         acomodule->AddNode(aCORDE1qa,2,new TGeoTranslation("aco10",0,0,-13));
214         acomodule->AddNode(aCORDE10,3,new TGeoTranslation("aco10",293/2+5,0,0));
215         acomodule->AddNode(aCORDE10,4,new TGeoTranslation("aco10",-293/2-5,0,0));
216         placedAt = pbox[1]+constants->ProfileThickness()-constants->ModuleHeight()/2+small;
217         acomodule->AddNode(aCORDE2,5,new TGeoTranslation("aco2",placedAt,0,0));
218         placedAt = placedAt + 2.0*pbox[1]+small;
219         acomodule->AddNode(aCORDE2,6,new TGeoTranslation("aco2",placedAt,-1,0));
220
221         // Put the Modules of In-Face
222         
223         count=1;
224         for(Int_t i=1;i<9;i++){
225
226                 Float_t posx = constants->ModulePositionX(i);
227                 Float_t posy = constants->ModulePositionY(i);
228                 Float_t posz = constants->ModulePositionZ(i);   
229                 
230                 modules->AddNode(acomodule,i,
231                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm232));
232                 count++;
233
234         }
235
236         count=9;
237         for(Int_t i=10;i<20;i++){
238                 Float_t posx = constants->ModulePositionX(i);
239                 Float_t posy = constants->ModulePositionY(i);
240                 Float_t posz = constants->ModulePositionZ(i);
241
242                 modules->AddNode(acomodule,i,
243                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm232));
244         }
245
246         // Put he Modules of Up-Face
247
248         count=1;
249         for(Int_t i=20;i<40;i++){
250                 Float_t posx = constants->ModulePositionX(i);
251                 Float_t posy = constants->ModulePositionY(i);
252                 Float_t posz = constants->ModulePositionZ(i);   
253
254                 modules->AddNode(acomodule,i,new TGeoTranslation("aco01",posx,posy,posz));
255                 count++;
256         }
257
258         // Put the Modules of Out-Face
259
260         count=1;
261         for(Int_t i=40;i<50;i++){
262                 Float_t posx = constants->ModulePositionX(i);
263                 Float_t posy = constants->ModulePositionY(i);
264                 Float_t posz = constants->ModulePositionZ(i);   
265
266                 modules->AddNode(acomodule,i,
267                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm231));
268                 count++;
269         }
270
271         // Put the Modules of Out-Face
272
273         count=11;
274         for(Int_t i=51;i<59;i++){
275                 Float_t posx = constants->ModulePositionX(i);
276                 Float_t posy = constants->ModulePositionY(i);
277                 Float_t posz = constants->ModulePositionZ(i);   
278
279         if ((i==57) || (i==56)){
280                  modules->AddNode(acomodule,i,
281                                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm231));
282         }else{
283                 modules->AddNode(acomodule,i,
284                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm231));
285                 }count++;
286         }
287
288
289         // Put th Modules ITS-ACORDE
290
291         if (GetITSGeometry()) {
292
293                 modules->AddNode(acomodule,0,new TGeoTranslation("ITS-3",
294                                 constants->ExtraModulePositionX(),
295                                 constants->ExtraModulePositionY(),
296                                 constants->ExtraModulePositionZ(0)));
297
298                 modules->AddNode(acomodule,9,new TGeoTranslation("ITS-4",
299                                 constants->ExtraModulePositionX(),
300                                 constants->ExtraModulePositionY(),
301                                 constants->ExtraModulePositionZ(1)));
302
303                 modules->AddNode(acomodule,50,new TGeoTranslation("ITS-1",
304                                 constants->ExtraModulePositionX(),
305                                 constants->ExtraModulePositionY(),
306                                 constants->ExtraModulePositionZ(2)));
307
308                 modules->AddNode(acomodule,59,new TGeoTranslation("ITS-2",
309                                 constants->ExtraModulePositionX(),
310                                 constants->ExtraModulePositionY(),
311                                 constants->ExtraModulePositionZ(3)));
312
313
314                 } 
315         else {
316
317
318                 modules->AddNode(acomodule,61,new TGeoTranslation("its1",
319                                 constants->ModulePositionX(0),
320                                 constants->ModulePositionY(0),
321                                 constants->ModulePositionZ(0)));
322
323                 modules->AddNode(acomodule,62,new TGeoTranslation("its2",
324                                 constants->ModulePositionX(9),
325                                 constants->ModulePositionY(9),
326                                 constants->ModulePositionZ(9)));
327
328                 modules->AddNode(acomodule,63,new TGeoTranslation("its3",
329                                 constants->ModulePositionX(50),
330                                 constants->ModulePositionY(50),
331                                 constants->ModulePositionZ(50)));
332
333                 modules->AddNode(acomodule,64,new TGeoTranslation("its4",
334                                 constants->ModulePositionX(59),
335                                 constants->ModulePositionY(59),
336                                 constants->ModulePositionZ(59)));
337
338                 } // end if (fITSGeometry)
339
340
341
342         //*** Begin the structure of support & bars for ACORDE ***
343
344         // Define a volume for the bars (up-face)
345
346         box[0]=5;
347 //      box[1]=40;
348         box[1]=33;
349         box[2]=5;
350         Float_t z1 = 21 ;
351         TGeoBBox *acorde00 = new TGeoBBox("acorde00",box[0],box[1],box[2]);
352
353         TGeoVolume *aCORDE00 = new TGeoVolume("ACORDE00",acorde00,al);
354
355         count=25;
356         for (Int_t ma=20;ma<=24;ma++)
357         {
358                 TGeoTranslation *aco00=new TGeoTranslation("aco00",
359                                         constants->SupportModulePositionX(ma)-0.5*293+dy2,
360                                         constants->SupportModulePositionY(ma)-box[1]-z1,
361                                         constants->SupportModulePositionZ(ma));
362
363                 upFace->AddNode(aCORDE00,count,aco00);
364
365                 TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
366                                         -(constants->SupportModulePositionX(ma)-0.5*293+dy2),
367                                         constants->SupportModulePositionY(ma)-box[1]-z1,
368                                         constants->SupportModulePositionZ(ma));
369                 upFace->AddNode(aCORDE00,count+1,aco00q1);
370
371                 TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
372                                         constants->SupportModulePositionX(ma)+0.5*293-dy2,
373                                         constants->SupportModulePositionY(ma)-box[1]-z1,
374                                         constants->SupportModulePositionZ(ma));
375                 upFace->AddNode(aCORDE00,count+2,aco00q2);
376
377                 TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
378                                         -(constants->SupportModulePositionX(ma)+0.5*293-dy2),
379                                         constants->SupportModulePositionY(ma)-box[1]-z1,
380                                         constants->SupportModulePositionZ(ma));
381                 upFace->AddNode(aCORDE00,count+3,aco00q3);
382                 count=count+4;
383
384                 ma++;
385         }
386
387         count=41;
388         for(Int_t ma=25;ma<=29;ma++)
389         {
390                 TGeoTranslation *aco00=new TGeoTranslation("aco00",
391                                         constants->SupportModulePositionX(ma)-0.5*293+dy2,
392                                         constants->SupportModulePositionY(ma)-box[1]-z1,
393                                         constants->SupportModulePositionZ(ma));
394                 upFace->AddNode(aCORDE00,count,aco00);
395
396                 TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
397                                         -(constants->SupportModulePositionX(ma)-0.5*293+dy2),
398                                         constants->SupportModulePositionY(ma)-box[1]-z1,
399                                         constants->SupportModulePositionZ(ma));
400                 upFace->AddNode(aCORDE00,count+1,aco00q1);
401
402                 TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
403                                         constants->SupportModulePositionX(ma)+0.5*293-dy2,
404                                         constants->SupportModulePositionY(ma)-box[1]-z1,
405                                         constants->SupportModulePositionZ(ma));
406                 upFace->AddNode(aCORDE00,count+2,aco00q2);
407
408                 TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
409                                         -(constants->SupportModulePositionX(ma)+0.5*293-dy2),
410                                         constants->SupportModulePositionY(ma)-box[1]-z1,
411                                         constants->SupportModulePositionZ(ma));
412                 upFace->AddNode(aCORDE00,count+3,aco00q3);
413                 count=count+4;
414                 ma++;
415         }
416
417         TGeoTranslation *c1 = new TGeoTranslation ("c1",
418                                 constants->SupportModulePositionX(20)-0.5*293,
419                                 constants->SupportModulePositionY(20)-box[1]-z1,
420                                 constants->SupportModulePositionZ(20)-40);
421         TGeoTranslation *c2 = new TGeoTranslation ("c2",
422                                 constants->SupportModulePositionX(23)-0.5*293,
423                                 constants->SupportModulePositionY(23)-box[1]-z1,
424                                 constants->SupportModulePositionZ(23)-40);
425         TGeoTranslation *c3 = new TGeoTranslation ("c3",
426                                 constants->SupportModulePositionX(24)-0.5*293,
427                                 constants->SupportModulePositionY(24)-box[1]-z1,
428                                 constants->SupportModulePositionZ(25)-40);
429         TGeoTranslation *c4 = new TGeoTranslation ("c4",
430                                 constants->SupportModulePositionX(27)-0.5*293,
431                                 constants->SupportModulePositionY(27)-box[1]-z1,
432                                 constants->SupportModulePositionZ(28)-40);
433         upFace->AddNode(aCORDE00,57,c1);
434         upFace->AddNode(aCORDE00,58,c2);
435         upFace->AddNode(aCORDE00,59,c3);
436         upFace->AddNode(aCORDE00,60,c4);
437
438
439         // Construct Bars for lateral supports (up-face)
440
441         TGeoTranslation *aco00=new TGeoTranslation("aco00",
442                                 constants->SupportModulePositionX(20)+0.5*293-dy,
443                                 constants->SupportModulePositionY(20)-box[1]-z1,
444                                 constants->SupportModulePositionZ(20)-40);
445         upFace->AddNode(aCORDE00,61,aco00);
446
447         TGeoTranslation *aco00q1=new TGeoTranslation("aco00q1",
448                                 constants->SupportModulePositionX(23)+0.5*293-dy,
449                                 constants->SupportModulePositionY(23)-box[1]-z1,
450                                 constants->SupportModulePositionZ(23)-40);
451         upFace->AddNode(aCORDE00,62,aco00q1);
452
453         TGeoTranslation *aco00q2=new TGeoTranslation("aco00q2",
454                                 constants->SupportModulePositionX(24)+0.5*293-dy,
455                                 constants->SupportModulePositionY(24)-box[1]-z1,
456                                 constants->SupportModulePositionZ(25)-40);
457         upFace->AddNode(aCORDE00,63,aco00q2);
458
459         TGeoTranslation *aco00q3=new TGeoTranslation("aco00q3",
460                                 constants->SupportModulePositionX(27)+0.5*293-dy,
461                                 constants->SupportModulePositionY(27)-box[1]-z1,
462                                 constants->SupportModulePositionZ(28)-40);
463         upFace->AddNode(aCORDE00,64,aco00q3);
464
465
466         TGeoTranslation *aco01=new TGeoTranslation("aco01",
467                                 constants->SupportModulePositionX(30)-0.5*293+dy,
468                                 constants->SupportModulePositionY(30)-box[1]-z1,
469                                 constants->SupportModulePositionZ(30)-40);
470         upFace->AddNode(aCORDE00,65,aco01);
471
472         TGeoTranslation *aco01q1=new TGeoTranslation("aco01q1",
473                                 constants->SupportModulePositionX(33)-0.5*293+dy,
474                                 constants->SupportModulePositionY(33)-box[1]-z1,
475                                 constants->SupportModulePositionZ(33)-40);
476         upFace->AddNode(aCORDE00,66,aco01q1);
477
478         TGeoTranslation *aco01q2=new TGeoTranslation("aco01q2",
479                                 constants->SupportModulePositionX(34)-0.5*293+dy,
480                                 constants->SupportModulePositionY(34)-box[1]-z1,
481                                 constants->SupportModulePositionZ(35)-40);
482         upFace->AddNode(aCORDE00,67,aco01q2);
483
484         TGeoTranslation *aco01q3=new TGeoTranslation("aco01q3",
485                                 constants->SupportModulePositionX(37)-0.5*293+dy,
486                                 constants->SupportModulePositionY(37)-box[1]-z1,
487                                 constants->SupportModulePositionZ(38)-40);
488         upFace->AddNode(aCORDE00,68,aco01q3);
489
490
491
492         // Acorde's support bars (side's faces)
493
494         //*** In Face ***
495
496 //      box[0]=39;
497         box[0]=27;
498         box[1]=5;
499         box[2]=5;
500         Float_t kro=3;
501         Float_t q1=0;
502         Float_t posx=constants->SupportModulePositionX(0)+0.5*293*0.7071-56*0.7071-18;
503         Float_t posy=constants->SupportModulePositionY(0)-0.5*293*0.7071-56*0.7071+3-q1+kro;
504         Float_t posz=constants->SupportModulePositionZ(0);
505
506         TGeoBBox *acorde7 = new TGeoBBox("acorde7",box[0],box[1],box[2]);
507
508         TGeoVolume *aCORDE7 = new TGeoVolume("ACORDE7",acorde7,al);
509
510         TGeoCombiTrans *aco7 = new TGeoCombiTrans("aco7",posx,posy,posz-4*dy,idrotm231);
511         TGeoCombiTrans *aco7q1 = new TGeoCombiTrans("aco7q1",posx,posy,
512                                         constants->ModulePositionZ(3)-4*dy,idrotm231);
513         TGeoCombiTrans *aco7q2 = new TGeoCombiTrans("aco7q2",posx,posy,
514                                         constants->ModulePositionZ(5)-4*dy,idrotm231);
515         TGeoCombiTrans *aco7q3 = new TGeoCombiTrans("aco7q3",posx,posy,
516                                         constants->ModulePositionZ(8)-4*dy,idrotm231);
517
518         inFace->AddNode(aCORDE7,20,aco7);
519         inFace->AddNode(aCORDE7,21,aco7q1);
520         inFace->AddNode(aCORDE7,22,aco7q2);
521         inFace->AddNode(aCORDE7,23,aco7q3);
522
523
524         count=24;
525         for(Int_t dyA=0;dyA<=4;dyA++)
526         {
527
528                 Float_t posx1=constants->SupportModulePositionX(dyA)+0.1*293*0.7071-56*0.7071-18+des;
529                 Float_t posy1=constants->SupportModulePositionY(dyA)-0.1*293*0.7071-56*0.7071+3-des-q1+kro;
530                 Float_t posza=constants->SupportModulePositionZ(dyA);
531                 Float_t posx2=constants->SupportModulePositionX(dyA)-0.27*293*0.7071-56*0.7071-18+des;
532                 Float_t posy2=constants->SupportModulePositionY(dyA)+0.27*293*0.7071-56*0.7071+3-des-q1+kro;
533                 TGeoCombiTrans *aco7q4 = new TGeoCombiTrans("aco7q4",posx1,posy1,posza,idrotm231);
534                 TGeoCombiTrans *aco7q5 = new TGeoCombiTrans("aco7q5",posx2,posy2,posza,idrotm231);
535                 inFace->AddNode(aCORDE7,count,aco7q4);
536                 inFace->AddNode(aCORDE7,count+1,aco7q5);
537                 count=count+2;
538                 dyA++;
539         }       
540
541
542         count=34;
543         for(Int_t dyb=5;dyb<=9;dyb++)
544         {
545
546                 Float_t posx1=constants->SupportModulePositionX(dyb)+0.1*293*0.7071-56*0.7071-18+des;
547                 Float_t posy1=constants->SupportModulePositionY(dyb)-0.1*293*0.7071-56*0.7071+3-des-q1+kro;
548                 Float_t poszb=constants->SupportModulePositionZ(dyb+10);
549                 Float_t posx2=constants->SupportModulePositionX(dyb)-0.27*293*0.7071-56*0.7071-18+des;
550                 Float_t posy2=constants->SupportModulePositionY(dyb)+0.27*293*0.7071-56*0.7071+3-des-q1+kro;
551                 TGeoCombiTrans *aco7q6 = new TGeoCombiTrans("aco7q6",posx1,posy1,poszb,idrotm231);
552                 TGeoCombiTrans *aco7q7 = new TGeoCombiTrans("aco7q7",posx2,posy2,poszb,idrotm231);
553                 inFace->AddNode(aCORDE7,count,aco7q6);
554                 inFace->AddNode(aCORDE7,count+1,aco7q7);
555                 count=count+2;
556                 dyb++;
557         }       
558
559
560
561         Float_t posxq1=constants->SupportModulePositionX(10)+0.5*293*0.7071-56*0.7071-18;
562         Float_t posyq1=constants->SupportModulePositionY(10)-0.5*293*0.7071-56*0.7071+3-q1+kro;
563         Float_t poszq1=constants->SupportModulePositionZ(10);
564         TGeoCombiTrans *aco7q8 = new TGeoCombiTrans("aco7q8",posxq1,posyq1,poszq1-4*dy,idrotm231);
565         TGeoCombiTrans *aco7q9 = new TGeoCombiTrans("aco7q9",posxq1,posyq1,
566                                         constants->ModulePositionZ(13)-4*dy,idrotm231);
567         TGeoCombiTrans *aco7q10 = new TGeoCombiTrans("aco7q10",posxq1,posyq1,
568                                         constants->ModulePositionZ(15)-4*dy,idrotm231);
569         TGeoCombiTrans *aco7q11 = new TGeoCombiTrans("aco7q11",posxq1,posyq1,
570                                         constants->ModulePositionZ(18)-4*dy,idrotm231);
571         inFace->AddNode(aCORDE7,44,aco7q8);
572         inFace->AddNode(aCORDE7,45,aco7q9);
573         inFace->AddNode(aCORDE7,46,aco7q10);
574         inFace->AddNode(aCORDE7,47,aco7q11);
575
576
577         count=48;
578         for(Int_t dyc=10;dyc<=14;dyc++)
579
580         {
581
582                 Float_t posx1=constants->SupportModulePositionX(dyc)+0.1*293*0.7071-56*0.7071-18+des;
583                 Float_t posy1=constants->SupportModulePositionY(dyc)-0.1*293*0.7071-56*0.7071+3-des-0.8+kro;
584                 Float_t poszc=constants->SupportModulePositionZ(dyc);
585                 Float_t posx2=constants->SupportModulePositionX(dyc)-0.27*293*0.7071-56*0.7071-18+des;
586                 Float_t posy2=constants->SupportModulePositionY(dyc)+0.27*293*0.7071-56*0.7071+3-des-1.5-0.8+kro;
587                 TGeoRotation *rot1 = new TGeoRotation();
588                 rot1->RotateZ(70);
589                 TGeoCombiTrans *aco7q12 = new TGeoCombiTrans("aco7q12",posx1,posy1,poszc,idrotm231);
590                 TGeoCombiTrans *aco7q13 = new TGeoCombiTrans("aco7q13",posx2+15,posy2-10,poszc,rot1);
591                 inFace->AddNode(aCORDE7,count,aco7q12);
592                 inFace->AddNode(aCORDE7,count+1,aco7q13);// bars 25 grades
593                 count=count+2;
594                 dyc++;
595         }
596
597
598         count=57;
599         for(Int_t dyd=15;dyd<=19;dyd++)
600
601         {
602
603                 Float_t posx1=constants->SupportModulePositionX(dyd)+0.1*293*0.7071-56*0.7071-18+des;
604                 Float_t posy1=constants->SupportModulePositionY(dyd)-0.1*293*0.7071-56*0.7071+3-des-q1-0.8+kro;
605                 Float_t poszd=constants->SupportModulePositionZ(dyd);
606                 Float_t posx2=constants->SupportModulePositionX(dyd)-0.27*293*0.7071-56*0.7071-18+des;
607                 Float_t posy2=constants->SupportModulePositionY(dyd)+0.27*293*0.7071-56*0.7071+3-des-1.5-q1-0.8+kro;
608                 TGeoRotation *rot1 = new TGeoRotation();
609                 rot1->RotateZ(70);
610                 TGeoCombiTrans *aco7q14 = new TGeoCombiTrans("aco7q14",posx1,posy1,poszd,idrotm231);
611                 TGeoCombiTrans *aco7q15 = new TGeoCombiTrans("aco7q15",posx2+15,posy2-10,poszd,rot1);
612                 inFace->AddNode(aCORDE7,count,aco7q14);
613                 inFace->AddNode(aCORDE7,count+1,aco7q15);// bars 25 grades
614                 count=count+2;
615                 dyd++;
616         }
617
618
619         //*** Out Face ***
620
621 //      box[0]=39;
622         box[0]=27;
623         box[1]=5;
624         box[2]=5;
625         Float_t s1=2.5;
626         Float_t posxqa=constants->SupportModulePositionX(50)-0.5*293*0.7071+56*0.7071+18;
627         Float_t posyqa=constants->SupportModulePositionY(50)-0.5*293*0.7071-56*0.7071+3-s1+kro;
628         Float_t poszqa=constants->SupportModulePositionZ(50);
629         TGeoCombiTrans *aco7q16 = new TGeoCombiTrans("aco7q16",
630                                         posxqa,posyqa,poszqa-4*dy,idrotm232);
631         TGeoCombiTrans *aco7q17 = new TGeoCombiTrans("aco7q17",
632                                         posxqa,posyqa,
633                                         constants->ModulePositionZ(43)-4*dy,idrotm232);
634         TGeoCombiTrans *aco7q18 = new TGeoCombiTrans("aco7q18",posxqa,posyqa,
635                                         constants->ModulePositionZ(55)-4*dy,idrotm232);
636         TGeoCombiTrans *aco7q19 = new TGeoCombiTrans("aco7q19",posxqa,posyqa,
637                                         constants->ModulePositionZ(58)-4*dy,idrotm232);
638         TGeoCombiTrans *aco7q20 = new TGeoCombiTrans("aco7q20",
639                                         constants->SupportModulePositionX(50)-0.1*293*0.7071
640                                         +56*0.7071+18-des,
641                                         constants->SupportModulePositionY
642                                         (50)-0.1*293*0.7071-56*0.7071+3-des-s1,
643                                         constants->SupportModulePositionZ(45),idrotm232);
644         TGeoCombiTrans *aco7q21 = new TGeoCombiTrans("aco7q21",
645                                         constants->SupportModulePositionX(50)+0.27*293*0.7071
646                                         +56*0.7071+18-des,
647                                         constants->SupportModulePositionY(50)
648                                         +0.27*293*0.7071-56*0.7071+3-des-s1,
649                                         constants->SupportModulePositionZ(45),idrotm232);
650         outFace->AddNode(aCORDE7,19,aco7q16);
651         outFace->AddNode(aCORDE7,20,aco7q17);
652         outFace->AddNode(aCORDE7,21,aco7q18);
653         outFace->AddNode(aCORDE7,22,aco7q19);
654         outFace->AddNode(aCORDE7,23,aco7q20);
655         outFace->AddNode(aCORDE7,24,aco7q21);
656
657
658         count=25;
659         for(Int_t dye=50;dye<=54;dye++)
660         {
661
662                 Float_t posx1=constants->SupportModulePositionX(dye)-0.1*293*0.7071+56*0.7071+18-des;
663                 Float_t posy1=constants->SupportModulePositionY(dye)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
664                 Float_t posze=constants->SupportModulePositionZ(dye);
665                 Float_t posx2=constants->SupportModulePositionX(dye)+0.27*293*0.7071+56*0.7071+18-des;
666                 Float_t posy2=constants->SupportModulePositionY(dye)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
667                 TGeoCombiTrans *aco7q22 = new TGeoCombiTrans("aco7q22",posx1,posy1,posze,idrotm232);
668                 TGeoCombiTrans *aco7q23 = new TGeoCombiTrans("aco7q23",posx2,posy2,posze,idrotm232);
669                 outFace->AddNode(aCORDE7,count,aco7q22);
670                 outFace->AddNode(aCORDE7,count+1,aco7q23);
671                 count=count+2;
672                 dye++;
673         }
674
675
676         count=35;
677         for(Int_t dyf=57;dyf<=59;dyf++)
678         {
679
680                 Float_t posx1=constants->SupportModulePositionX(dyf)-0.1*293*0.7071+56*0.7071+18-des;
681                 Float_t posy1=constants->SupportModulePositionY(dyf)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
682                 Float_t poszf=constants->SupportModulePositionZ(dyf-10);
683                 Float_t posx2=constants->SupportModulePositionX(dyf)+0.27*293*0.7071+56*0.7071+18-des;
684                 Float_t posy2=constants->SupportModulePositionY(dyf)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
685                 TGeoCombiTrans *aco7q24 = new TGeoCombiTrans("aco7q24",posx1,posy1,poszf,idrotm232);
686                 TGeoCombiTrans *aco7q25 = new TGeoCombiTrans("aco7q25",posx2,posy2,poszf,idrotm232);
687                 outFace->AddNode(aCORDE7,count,aco7q24);
688                 outFace->AddNode(aCORDE7,count+1,aco7q25);
689                 count=count+2;
690                 dyf++;
691         }
692
693
694         Float_t posxqb=constants->SupportModulePositionX(40)-0.5*293*0.7071+56*0.7071+18;
695         Float_t posyqb=constants->SupportModulePositionY(40)-0.5*293*0.7071-56*0.7071+3-s1+kro;
696         Float_t poszqb=constants->SupportModulePositionZ(40);
697         TGeoCombiTrans *aco7q26 = new TGeoCombiTrans("aco7q26",
698                                         posxqb,posyqb,poszqb-4*dy,idrotm232);
699         TGeoCombiTrans *aco7q27 = new TGeoCombiTrans("aco7q27",
700                                         posxqb,posyqb,
701                                         constants->SupportModulePositionZ(43)-4*dy,idrotm232);
702         TGeoCombiTrans *aco7q28 = new TGeoCombiTrans("aco7q28",
703                                         posxqb,posyqb,
704                                         constants->SupportModulePositionZ(45)-4*dy,idrotm232);
705         TGeoCombiTrans *aco7q29 = new TGeoCombiTrans("aco7q29",posxqb,posyqb,
706                                         constants->SupportModulePositionZ(48)-4*dy,idrotm232);
707         outFace->AddNode(aCORDE7,41,aco7q26);
708         outFace->AddNode(aCORDE7,42,aco7q27);
709         outFace->AddNode(aCORDE7,43,aco7q28);
710         outFace->AddNode(aCORDE7,44,aco7q29);
711
712         count=45;
713         for(Int_t dyg=40;dyg<=44;dyg++)
714         {
715
716                 Float_t posx1=constants->SupportModulePositionX(dyg)-0.1*293*0.7071+56*0.7071+18-des;
717                 Float_t posy1=constants->SupportModulePositionY(dyg)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
718                 Float_t poszg=constants->SupportModulePositionZ(dyg);
719                 Float_t posx2=constants->SupportModulePositionX(dyg)+0.27*293*0.7071+56*0.7071+18-des;
720                 Float_t posy2=constants->SupportModulePositionY(dyg)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
721                 TGeoRotation *rot1 = new TGeoRotation();
722                 rot1->RotateZ(105);
723                 TGeoCombiTrans *aco7q30 = new TGeoCombiTrans("aco7q30",posx1,posy1,poszg,idrotm232);
724                 TGeoCombiTrans *aco7q31 = new TGeoCombiTrans("aco7q31",posx2-15,posy2-10,poszg,rot1);
725                 outFace->AddNode(aCORDE7,count,aco7q30);
726                 outFace->AddNode(aCORDE7,count+1,aco7q31);// bars 25 grades
727                 count=count+2;
728                 dyg++;
729         }
730
731
732         count=55;
733         for(Int_t dyh=45;dyh<=49;dyh++)
734         {
735
736                 Float_t posx1=constants->SupportModulePositionX(dyh)-0.1*293*0.7071+56*0.7071+18-des;
737                 Float_t posy1=constants->SupportModulePositionY(dyh)-0.1*293*0.7071-56*0.7071+3-des-s1+kro;
738                 Float_t poszh=constants->SupportModulePositionZ(dyh);
739                 Float_t posx2=constants->SupportModulePositionX(dyh)+0.27*293*0.7071+56*0.7071+18-des;
740                 Float_t posy2=constants->SupportModulePositionY(dyh)+0.27*293*0.7071-56*0.7071+3-des-s1+kro;
741                 TGeoRotation *rot1 = new TGeoRotation();
742                 rot1->RotateZ(105);
743                 TGeoCombiTrans *aco7q32 = new TGeoCombiTrans("aco7q32",posx1,posy1,poszh,idrotm232);
744                 TGeoCombiTrans *aco7q33 = new TGeoCombiTrans("aco7q33",posx2-15,posy2-10,poszh,rot1);
745                 outFace->AddNode(aCORDE7,count,aco7q32);
746                 outFace->AddNode(aCORDE7,count+1,aco7q33);// bars 25 grades
747                 count=count+2;
748                 dyh++;
749         }
750
751
752
753         // Set the bars non perpendicular at side faces
754
755         //*** In-Face ***
756
757         box[0]=5;
758 //      box[1]=55.15;
759         box[1]=40;
760         box[2]=5;
761         Float_t sm=2;
762         Float_t re=1;
763         Float_t posx1=constants->SupportModulePositionX(0)+0.5*293*0.7071-4*box[0]-8+re;
764         Float_t posy1=constants->SupportModulePositionY(0)-0.5*293*0.7071-box[1]-18-2+sm;
765         Float_t posz1=constants->SupportModulePositionZ(0);
766
767         TGeoBBox *acorde7q1 = new TGeoBBox("acorde7q1",box[0],box[1],box[2]);
768
769         TGeoVolume *aCORDE7q1 = new TGeoVolume("ACORDE7_1",acorde7q1,al);
770         TGeoTranslation *aco71 = new TGeoTranslation("aco71",posx1,posy1,posz1-4*dy);
771         TGeoTranslation *aco72 = new TGeoTranslation("aco72",posx1,posy1,
772                                         constants->SupportModulePositionZ(3)-4*dy);
773         TGeoTranslation *aco73 = new TGeoTranslation("aco73",posx1,posy1,
774                                         constants->SupportModulePositionZ(5)-4*dy);
775         TGeoTranslation *aco74 = new TGeoTranslation("aco74",posx1,posy1,
776                                         constants->SupportModulePositionZ(8)-4*dy);
777         inFace->AddNode(aCORDE7q1,67,aco71);
778         inFace->AddNode(aCORDE7q1,68,aco72);
779         inFace->AddNode(aCORDE7q1,69,aco73);
780         inFace->AddNode(aCORDE7q1,70,aco74);
781
782
783         count=71;
784         for(Int_t dyi=0;dyi<=4;dyi++)
785         {
786
787                 Float_t posx1a=constants->SupportModulePositionX(dyi)+0.1*293*0.7071-4*box[0]-8+des+re;
788                 Float_t posy1a=constants->SupportModulePositionY(dyi)-0.1*293*0.7071-box[1]-18-2-des+sm;
789                 Float_t posz1a=constants->SupportModulePositionZ(dyi);
790                 Float_t dyx2=constants->SupportModulePositionX(dyi)-0.27*293*0.7071-4*box[0]-8+des+re;
791                 Float_t dyy2=constants->SupportModulePositionY(dyi)+0.27*293*0.7071-box[1]-18-2-des+sm;
792                 TGeoTranslation *aco75=new TGeoTranslation("aco75",posx1a,posy1a,posz1a);
793                 TGeoTranslation *aco76=new TGeoTranslation("aco76",dyx2,dyy2,posz1a);
794                 inFace->AddNode(aCORDE7q1,count,aco75);
795                 inFace->AddNode(aCORDE7q1,count+1,aco76);
796                 count=count+2;
797                 dyi++;
798         }
799
800
801         count=81;
802         for(Int_t dyj=5;dyj<=9;dyj++)
803         {
804
805                 Float_t posx1b=constants->SupportModulePositionX(dyj)+0.1*293*0.7071-4*box[0]-8+des+re;
806                 Float_t posy1b=constants->SupportModulePositionY(dyj)-0.1*293*0.7071-box[1]-18-2-des+sm;
807                 Float_t posz1b=constants->SupportModulePositionZ(dyj+10);
808                 Float_t dyx2=constants->SupportModulePositionX(dyj)-0.27*293*0.7071-4*box[0]-8+des+re;
809                 Float_t dyy2=constants->SupportModulePositionY(dyj)+0.27*293*0.7071-box[1]-18-2-des+sm;
810                 TGeoTranslation *aco75=new TGeoTranslation("aco75",posx1b,posy1b,posz1b);
811                 TGeoTranslation *aco76=new TGeoTranslation("aco76",dyx2,dyy2,posz1b);
812                 inFace->AddNode(aCORDE7q1,count,aco75);
813                 inFace->AddNode(aCORDE7q1,count+1,aco76);
814                 count=count+2;
815                 dyj++;
816         }
817
818
819         Float_t posx1q1=constants->SupportModulePositionX(10)+0.5*293*0.7071-4*box[0]-8+re;
820         Float_t posy1q1=constants->SupportModulePositionY(10)-0.5*293*0.7071-box[1]-18-2+sm;
821         Float_t posz1q1=constants->SupportModulePositionZ(10);
822         TGeoTranslation *aco77=new TGeoTranslation("aco77",posx1q1,posy1q1,posz1q1-4*dy);
823         TGeoTranslation *aco78=new TGeoTranslation("aco78",posx1q1,posy1q1,
824                                         constants->SupportModulePositionZ(13)-4*dy);
825
826         TGeoTranslation *aco79=new TGeoTranslation("aco79",posx1q1,posy1q1,
827                                         constants->SupportModulePositionZ(15)-4*dy);
828         TGeoTranslation *aco710=new TGeoTranslation("aco710",posx1q1,posy1q1,
829                                         constants->SupportModulePositionZ(18)-4*dy);
830         inFace->AddNode(aCORDE7q1,91,aco77);
831         inFace->AddNode(aCORDE7q1,92,aco78);
832         inFace->AddNode(aCORDE7q1,93,aco79);
833         inFace->AddNode(aCORDE7q1,94,aco710);
834
835         count=95;
836         for(Int_t dyk=10;dyk<=14;dyk++)
837         {
838
839                 Float_t posx1c=constants->SupportModulePositionX(dyk)+0.1*293*0.7071-4*box[0]-8+des+re+.83;
840                 Float_t posy1c=constants->SupportModulePositionY(dyk)-0.1*293*0.7071-box[1]-18-2-des+sm;
841                 Float_t posz1c=constants->SupportModulePositionZ(dyk);
842                 Float_t dyx2=constants->SupportModulePositionX(dyk)-0.27*293*0.7071-4*box[0]-4+des+re+0.83;
843                 Float_t dyy2=constants->SupportModulePositionY(dyk)+0.27*293*0.7071-box[1]-18-5-des+sm;
844                 TGeoTranslation *aco711=new TGeoTranslation("aco711",posx1c,posy1c,posz1c);
845                 TGeoTranslation *aco712=new TGeoTranslation("aco712",dyx2,dyy2,posz1c);
846                 inFace->AddNode(aCORDE7q1,count,aco711);
847                 inFace->AddNode(aCORDE7q1,count+1,aco712);
848                 count=count+2;
849                 dyk++;
850         }
851
852
853
854         count=105;
855         for(Int_t dyl=15;dyl<=19;dyl++)
856         {
857
858                 Float_t posx1d=constants->SupportModulePositionX(dyl)+0.1*293*0.7071-4*box[0]-8+des+re+0.83;
859                 Float_t posy1d=constants->SupportModulePositionY(dyl)-0.1*293*0.7071-box[1]-18-2-des+sm;
860                 Float_t posz1d=constants->SupportModulePositionZ(dyl);
861                 Float_t dyx2=constants->SupportModulePositionX(dyl)-0.27*293*0.7071-4*box[0]-4+des+re+0.83;
862                 Float_t dyy2=constants->SupportModulePositionY(dyl)+0.27*293*0.7071-box[1]-18-5-des;
863                 TGeoTranslation *aco713=new TGeoTranslation("aco713",posx1d,posy1d,posz1d);
864                 TGeoTranslation *aco714=new TGeoTranslation("aco714",dyx2,dyy2,posz1d);
865                 inFace->AddNode(aCORDE7q1,count,aco713);
866                 inFace->AddNode(aCORDE7q1,count+1,aco714);
867                 count=count+2;
868                 dyl++;
869         }
870
871                 //*** Out-Face ***
872
873         Float_t posx1qa=constants->SupportModulePositionX(50)-0.5*293*0.7071+4*box[0]+8-re-1;
874         Float_t posy1qa=constants->SupportModulePositionY(50)-0.5*293*0.7071-box[1]-18-2+sm-2.5;
875         Float_t posz1qa=constants->SupportModulePositionZ(50);
876         TGeoTranslation *aco715=new TGeoTranslation("aco715",posx1qa,posy1qa,posz1qa-4*dy);
877         TGeoTranslation *aco716=new TGeoTranslation("aco716",posx1qa,posy1qa,
878                                 constants->SupportModulePositionZ(43)-4*dy);
879         TGeoTranslation *aco717=new TGeoTranslation("aco717",posx1qa,posy1qa,
880                                 constants->SupportModulePositionZ(55)-4*dy);
881         TGeoTranslation *aco718=new TGeoTranslation("aco718",posx1qa,posy1qa,
882                                 constants->SupportModulePositionZ(58)-4*dy);
883         TGeoTranslation *aco719=new TGeoTranslation("aco719",
884                                 constants->SupportModulePositionX(50)-0.1*293*0.7071+4*box[0]+8-des-re-1,               
885                                 constants->SupportModulePositionY(50)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5,
886                                 constants->SupportModulePositionZ(45));
887         TGeoTranslation *aco720=new TGeoTranslation("aco720",
888                                 constants->SupportModulePositionX(50)+0.27*293*0.7071+4*box[0]+8-des-re-1,
889                                 constants->SupportModulePositionY(50)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5,
890                                 constants->SupportModulePositionZ(45));
891
892
893         outFace->AddNode(aCORDE7q1,115,aco715);
894         outFace->AddNode(aCORDE7q1,116,aco716);
895         outFace->AddNode(aCORDE7q1,117,aco717);
896         outFace->AddNode(aCORDE7q1,118,aco718);
897         outFace->AddNode(aCORDE7q1,119,aco719);
898         outFace->AddNode(aCORDE7q1,120,aco720);
899
900
901
902
903         count=65;
904         for(Int_t dym=50;dym<=54;dym++)
905         {
906
907                 Float_t posx1e=constants->SupportModulePositionX(dym)-0.1*293*0.7071+4*box[0]+8-des-re-1;
908                 Float_t posy1e=constants->SupportModulePositionY(dym)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
909                 Float_t posz1e=constants->SupportModulePositionZ(dym);
910                 Float_t dyx2=constants->SupportModulePositionX(dym)+0.27*293*0.7071+4*box[0]+8-des-re-1;
911                 Float_t dyy2=constants->SupportModulePositionY(dym)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5;
912                 TGeoTranslation *aco721=new TGeoTranslation("aco721",posx1e,posy1e,posz1e);
913                 TGeoTranslation *aco722=new TGeoTranslation("aco722",dyx2,dyy2,posz1e);
914                 outFace->AddNode(aCORDE7q1,count,aco721);
915                 outFace->AddNode(aCORDE7q1,count+1,aco722);
916                 count=count+2;
917                 dym++;
918         }
919
920
921
922         count=75;
923         for(Int_t dyn=57;dyn<=59;dyn++)
924         {
925
926                 Float_t posx1f=constants->SupportModulePositionX(dyn)-0.1*293*0.7071+4*box[0]+8-des-re-1;
927                 Float_t posy1f=constants->SupportModulePositionY(dyn)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
928                 Float_t posz1f=constants->SupportModulePositionZ(dyn-10);
929                 Float_t dyx2=constants->SupportModulePositionX(dyn)+0.27*293*0.7071+4*box[0]+8-des-re-1;
930                 Float_t dyy2=constants->SupportModulePositionY(dyn)+0.27*293*0.7071-box[1]-18-2-des+sm-2.5;
931                 TGeoTranslation *aco723=new TGeoTranslation("aco723",posx1f,posy1f,posz1f);
932                 TGeoTranslation *aco724=new TGeoTranslation("aco724",dyx2,dyy2,posz1f);
933                 outFace->AddNode(aCORDE7q1,count,aco723);
934                 outFace->AddNode(aCORDE7q1,count+1,aco724);
935                 count=count+2;
936                 dyn++;
937         }
938
939
940         Float_t posx1qb=constants->SupportModulePositionX(40)-0.5*293*0.7071+4*box[0]+5;
941         Float_t posy1qb=constants->SupportModulePositionY(40)-0.5*293*0.7071-box[1]-18-2;
942         Float_t posz1qb=constants->SupportModulePositionZ(40);
943         TGeoTranslation *aco725=new TGeoTranslation("aco725",posx1qb,posy1qb,posz1qb-4*dy);
944         TGeoTranslation *aco726=new TGeoTranslation("aco726",posx1qb,posy1qb,
945                                 constants->SupportModulePositionZ(43)-4*dy);
946         TGeoTranslation *aco727=new TGeoTranslation("aco727",posx1qb,posy1qb,
947                                 constants->SupportModulePositionZ(45)-4*dy);
948         TGeoTranslation *aco728=new TGeoTranslation("aco728",posx1qb,posy1qb,
949                                 constants->SupportModulePositionZ(48)-4*dy);
950         outFace->AddNode(aCORDE7q1,85,aco725);
951         outFace->AddNode(aCORDE7q1,86,aco726);
952         outFace->AddNode(aCORDE7q1,87,aco727);
953         outFace->AddNode(aCORDE7q1,88,aco728);
954
955
956
957         count=89;
958         for(Int_t dyo=40;dyo<=44;dyo++)
959         {
960
961                 Float_t posx1g=constants->SupportModulePositionX(dyo)-0.1*293*0.7071+4*box[0]+8-des-re-1;
962                 Float_t posy1g=constants->SupportModulePositionY(dyo)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
963                 Float_t posz1g=constants->SupportModulePositionZ(dyo);
964                 Float_t dyx2=constants->SupportModulePositionX(dyo)+0.27*293*0.7071+4*box[0]+4-des-re-1+2.8;
965                 Float_t dyy2=constants->SupportModulePositionY(dyo)+0.27*293*0.7071-box[1]-18-5-des+sm-2.5+3;
966                 TGeoTranslation *aco729=new TGeoTranslation("aco729",posx1g,posy1g,posz1g);
967                 TGeoTranslation *aco730=new TGeoTranslation("aco730",dyx2,dyy2,posz1g);
968                 outFace->AddNode(aCORDE7q1,count,aco729);
969                 outFace->AddNode(aCORDE7q1,count+1,aco730);
970                 count=count+2;
971                 dyo++;
972         }
973
974
975
976         count=99;
977         for(Int_t dyp=45;dyp<=49;dyp++)
978         {
979
980                 Float_t posx1h=constants->SupportModulePositionX(dyp)-0.1*293*0.7071+4*box[0]+8-des-re-1;
981                 Float_t posy1h=constants->SupportModulePositionY(dyp)-0.1*293*0.7071-box[1]-18-2-des+sm-2.5;
982                 Float_t posz1h=constants->SupportModulePositionZ(dyp);
983                 Float_t dyx2=constants->SupportModulePositionX(dyp)+0.27*293*0.7071+4*box[0]+4-des-re-1+2.8;
984                 Float_t dyy2=constants->SupportModulePositionY(dyp)+0.27*293*0.7071-box[1]-18-5-des+sm-2.5+3;
985                 TGeoTranslation *aco729=new TGeoTranslation("aco729",posx1h,posy1h,posz1h);
986                 TGeoTranslation *aco730=new TGeoTranslation("aco730",dyx2,dyy2,posz1h);
987                 outFace->AddNode(aCORDE7q1,count,aco729);
988                 outFace->AddNode(aCORDE7q1,count+1,aco730);
989                 count=count+2;
990                 dyp++;
991         }
992
993
994         // Here I define a master volume "ACORDE_SUPPORT" for Acorde's support
995
996         //---> Set the support of ACORDE alice MODULES
997
998
999         Float_t dy1=20;
1000         box[0]=10;
1001         box[1]=0.5;
1002         box[2]=500;
1003
1004         Float_t sx=constants->SupportModulePositionX(24)-0.5*293;
1005         Float_t sy=constants->SupportModulePositionY(24)-box[1];
1006         Float_t sz=0;
1007         Float_t sx2=constants->SupportModulePositionX(24)+0.5*293-dy;
1008         Float_t sy2=constants->SupportModulePositionY(24)-box[1];
1009         Float_t sx4=constants->SupportModulePositionX(24)-0.5*293+dy2;
1010         Float_t sy4=constants->SupportModulePositionY(24)-box[1];
1011         Float_t sx5=constants->SupportModulePositionX(24)+0.5*293-dy2;
1012         Float_t sy5=constants->SupportModulePositionY(24)-box[1];
1013
1014         Float_t dyx=constants->SupportModulePositionX(4)+0.5*293*0.7071-box[0];
1015         Float_t dyy=constants->SupportModulePositionY(4)-0.5*293*0.7071-box[1];
1016         Float_t dyz=0;
1017         Float_t dyx1=constants->SupportModulePositionX(4)+0.1*293*0.7071-box[0];
1018         Float_t dyy1=constants->SupportModulePositionY(4)-0.1*293*0.7071-box[1];
1019         Float_t dyx2=constants->SupportModulePositionX(4)-0.27*293*0.7071-box[0];
1020         Float_t dyy2=constants->SupportModulePositionY(4)+0.27*293*0.7071-box[1];
1021
1022
1023         Float_t dx1=constants->SupportModulePositionX(14)+0.5*293*0.7071-box[0];
1024         Float_t dy11=constants->SupportModulePositionY(14)-0.5*293*0.7071-box[1];
1025         Float_t dyx11=constants->SupportModulePositionX(14)+0.1*293*0.7071-box[0];
1026         Float_t dyy11=constants->SupportModulePositionY(14)-0.1*293*0.7071-box[1];
1027         Float_t dyx21=constants->SupportModulePositionX(14)-0.27*293*0.7071-box[0];
1028         Float_t dyy21=constants->SupportModulePositionY(14)+0.27*293*0.7071-box[1];
1029
1030
1031         Float_t tbox[3];
1032         tbox[0]=1;
1033         tbox[1]=7;
1034         tbox[2]=500;
1035
1036         TGeoVolume *support = new TGeoVolumeAssembly("ACORDE_SUPPORT");
1037
1038         TGeoBBox *acorde8 = new TGeoBBox("acorde8",box[0],box[1],box[2]);
1039         TGeoVolume *aCORDE8 = new TGeoVolume("ACORDE8",acorde8,al);
1040
1041         TGeoBBox *acorde9 = new TGeoBBox("acorde9",tbox[0],tbox[1],tbox[2]);
1042         TGeoVolume *aCORDE9 = new TGeoVolume("ACORDE9",acorde9,al);
1043
1044         support->AddNode(aCORDE8,1,new TGeoTranslation(0,-5,0));
1045         support->AddNode(aCORDE8,2,new TGeoTranslation(0,-dy1,0));
1046         support->AddNode(aCORDE9,3,new TGeoTranslation(0,-tbox[1]-5.5,0));
1047
1048
1049         // Put "support" on Up-Face
1050
1051         upFace->AddNode(support,69,new TGeoTranslation("aco8",sx,sy,sz));
1052         upFace->AddNode(support,70,new TGeoTranslation("aco8_2",sx2,sy2,sz));
1053         upFace->AddNode(support,71,new TGeoTranslation("aco8_4",sx4,sy4,sz));
1054         upFace->AddNode(support,72,new TGeoTranslation("aco8_6",sx5,sy5,sz));
1055         upFace->AddNode(support,73,new TGeoTranslation("aco8_2",-sx2,sy2,sz));
1056         upFace->AddNode(support,74,new TGeoTranslation("aco8_4",-sx4,sy4,sz));
1057         upFace->AddNode(support,75,new TGeoTranslation("aco8_6",-sx5,sy5,sz));
1058
1059         // Put "support" on In-Face
1060         Float_t ms = 1.3;
1061         inFace->AddNode(support,121,new TGeoCombiTrans("aco8_81",dyx,dyy+ms,dyz,idrotm232));
1062         inFace->AddNode(support,122,new TGeoCombiTrans("aco8_121",dyx1+des,ms+dyy1-des,dyz,idrotm232));
1063         inFace->AddNode(support,123,new TGeoCombiTrans("aco8_161",dyx2+des,ms+dyy2-des,dyz,idrotm232));
1064         inFace->AddNode(support,124,new TGeoCombiTrans("aco8_82",dx1,ms+dy11,dyz,idrotm232));
1065         inFace->AddNode(support,125,new TGeoCombiTrans("aco8_122",dyx11+des,ms+dyy11-des,dyz,idrotm232));
1066         inFace->AddNode(support,126,new TGeoCombiTrans("aco8_162",dyx21+des,ms+dyy21-des,dyz,idrotm232));
1067
1068         // Put "support" on Out-Face
1069
1070         outFace->AddNode(support,121,new TGeoCombiTrans("aco8_81",-dyx,dyy+ms,dyz,idrotm231));
1071         outFace->AddNode(support,122,new TGeoCombiTrans("aco8_121",-dyx1-des,ms+dyy1-des,dyz,idrotm231));
1072         outFace->AddNode(support,123,new TGeoCombiTrans("aco8_161",-dyx2-des,ms+dyy2-des,dyz,idrotm231));
1073         outFace->AddNode(support,124,new TGeoCombiTrans("aco8_82",-dx1,dy11+ms,dyz,idrotm231));
1074         outFace->AddNode(support,125,new TGeoCombiTrans("aco8_122",-dyx11-des,ms+dyy11-des,dyz,idrotm231));
1075         outFace->AddNode(support,126,new TGeoCombiTrans("aco8_162",-dyx21-des,ms+dyy21-des,dyz,idrotm231));
1076         
1077         aCORDE->AddNode(inFace,1);//---> volume of supports & bars in-face
1078         aCORDE->AddNode(upFace,2);//---> volume of supports & bars up-face
1079         aCORDE->AddNode(outFace,3);//---> volume of supports & bars out-face
1080         aCORDE->AddNode(modules,4);//---> volume of ALL ACORDE's Modules
1081         alice->AddNode(aCORDE,1);//---> put volume of ACORDE over ALICE's volume
1082
1083
1084
1085 }
1086 //__________________________________________________________________________
1087
1088 void AliACORDEv1::Init()
1089 {
1090   // Initialise L3 magnet after it has been built
1091   Int_t i;
1092   if(AliLog::GetGlobalDebugLevel()>0) {
1093     printf("\n%s: ",ClassName());
1094     for(i=0;i<35;i++) printf("*");
1095     printf(" ACORDEv1_INIT ");
1096     for(i=0;i<35;i++) printf("*");
1097     printf("\n%s: ",ClassName());
1098     // Here the ACORDEv initialisation code (if any!)
1099     for(i=0;i<80;i++) printf("*");
1100     printf("\n");
1101   }
1102  // AliACORDE::Init();  
1103 }
1104 //____________________________________________________________________________
1105 void AliACORDEv1::StepManager()
1106 {
1107
1108   //
1109   // Called for every step in the Cosmic Ray Trigger
1110   //
1111
1112
1113   // volume: 
1114   //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
1115   //  [1] = Plastic number: 0 (down) to 1 (up)
1116   static Int_t   vol[2]; 
1117   //
1118   // hit
1119   // [0] = PID
1120   // [1-3] = x, y, z 
1121   // [4] = time 
1122   // [5-7] = px, py, pz
1123   // [8] = energy 
1124   // [9] = energy loss
1125   // [10] = length of track through plastic
1126   static Float_t hits[11];
1127
1128   // local static variables
1129   static Float_t eloss;
1130   static Float_t step;
1131   // scintillator volume
1132  static Int_t idScint = gMC->VolId("ACORDE2");
1133   // local variables
1134   Int_t copy;
1135   TLorentzVector pos;
1136   TLorentzVector mom;
1137
1138   // only charged tracks
1139   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
1140
1141   // only in sensitive material
1142   if (gMC->CurrentVolID(copy) == idScint) {
1143
1144     step  += gMC->TrackStep();
1145     eloss += gMC->Edep();
1146     // set all hit variables except eloss which is resetted
1147     // set volume variables
1148     if (gMC->IsTrackEntering()) {
1149       eloss = 0.0;
1150       step = 0.0;
1151       gMC->TrackPosition(pos);
1152       gMC->TrackMomentum(mom);
1153       // hit
1154       // [0] = PID
1155       // [1-3] = x, y, z 
1156       // [4] = time 
1157       // [5-7] = px, py, pz
1158       // [8] = energy 
1159       // [9] = energy loss
1160       hits[0]  = (Float_t ) gMC->TrackPid(); 
1161
1162
1163       hits[1] = pos[0]; 
1164       hits[2] = pos[1]; 
1165       hits[3] = pos[2]; 
1166       hits[4] = gMC->TrackTime();
1167       hits[5] = mom[0];
1168       hits[6] = mom[1];
1169       hits[7] = mom[2];
1170       hits[8] = gMC->Etot();
1171       // volume: 
1172       //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
1173       //  [1] = Plastic number: 0 (down) to 1 (up)
1174       Int_t copyPlastic; // plastic: down=1, up=2
1175       Int_t copyModule; // module: 1-60
1176       gMC->CurrentVolID(copyPlastic);
1177       gMC->CurrentVolOffID(1, copyModule);
1178       // module
1179       vol[0] = copyModule;
1180       // plastic: 0 = down, 1 = up
1181       vol[1] = copyPlastic - 4 ; // !!!!!!!
1182     // vol[1] = copyPlastic;
1183     } // end if gMC->IsTrackEntering()
1184
1185     // set hit[9] = total energy loss and book hit
1186     if( gMC->IsTrackExiting() || 
1187         gMC->IsTrackStop() || 
1188         gMC->IsTrackDisappeared()){
1189       hits[9] = eloss;
1190       hits[10] = step;
1191       eloss = 0.0;
1192       step = 0.0;
1193       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1194      }
1195   } 
1196
1197
1198
1199 }
1200
1201 //_____________________________________________________________________________
1202 void AliACORDEv1::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1203 {
1204   //
1205   // Add an ACORDE hit
1206   //
1207   TClonesArray &lhits = *fHits;
1208   new(lhits[fNhits++]) AliACORDEhit(fIshunt,track,vol,hits);
1209 }
1210
1211 //_____________________________________________________________________________
1212 void AliACORDEv1::AddDigits(Int_t* track, Int_t module, Float_t time)
1213 {
1214   
1215   // Adds Digit
1216   
1217   TClonesArray &ldigits = *fDigits;
1218   new(ldigits[fNdigits++]) AliACORDEdigit(track,module,time);
1219 }
1220 //_____________________________________________________________________________
1221
1222 void AliACORDEv1::MakeBranch(Option_t *option)
1223 {
1224 // Creates new branches in the current Root Tree
1225     
1226   char branchname[10];
1227   sprintf(branchname,"%s",GetName());
1228   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
1229   const char *cH = strstr(option,"H");
1230   if (fHits   && fLoader->TreeH() && cH) {
1231     fLoader->TreeH()->Branch(branchname,&fHits, fBufferSize);
1232     AliDebug(2,Form("Making Branch %s for hits",branchname));
1233   }     
1234   const char *cD = strstr(option,"D");
1235   if (fDigits   && fLoader->TreeD() && cD) {
1236     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1237     AliDebug(2,Form("Making Branch %s for digits",branchname));
1238   }  
1239 }
1240
1241 //_____________________________________________________________________________
1242 void AliACORDEv1::AddAlignableVolumes() const
1243 {
1244   //
1245   // Create entries for alignable volumes associating the symbolic volume
1246   // name with the corresponding volume path. Needs to be syncronized with
1247   // eventual changes in the geometry.
1248   // 
1249
1250         // The alignable volumes are only the "ACORDE_MODULE_%d"
1251         //
1252         //      Structure of ACORDE's Geometry
1253         //
1254         //      ALIC_1
1255         //          |---> ACORDE_1      
1256         //                      |----> ACORDE_1_1 (in_face) ---
1257         //                      |----> ACORDE_2_2 (up_face)    |--> BARS&SUPPORTS
1258         //                      |----> ACORDE_3_3 (out_face)---
1259         //                      |----> ACORDE_MODULES_4        |--> ACORDE'S MODULES
1260         //              
1261         //
1262         //     Send comments to: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
1263
1264         TString vpstr1 = "ALIC_1/ACORDE_1/ALL_ACORDE_MODULES_4/ACORDE_MODULE_";
1265         TString snstr1 = "ACORDE/Array";
1266         TString volpath, symname;
1267         for(Int_t dy=0; dy<60 ; dy++)
1268         {
1269                 volpath = vpstr1;
1270                 volpath += dy;
1271                 symname = snstr1;
1272                 symname += dy;
1273                 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
1274                 AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
1275         }
1276 }