30f4e3f0cbce86807b5956b3530aed27de545f47
[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. It includes the last survey of 2009.             //
25 //  It include geometry and hits (position and momentum)                     //
26 //                                                                           //
27 //   Author: Mario Rodriguez Cahuantzi, FCFM-BUAP, Puebla, Pue. Mexico       //
28 //                                                                           //
29 //                  Send comments to:                                        //
30 //                                                                           //
31 //      Arturo Fernandez Tellez         <afernand@fcfm.buap.mx>              //
32 //      Eleazar Cuautle Flores          <ecuautle@nucleares.unam.mx>         //
33 //      Mario Rodriguez Cahuantzi       <mrodrigu@mail.cern.ch>              // 
34 //                                                                           //
35 //                      Puebla, Pue. Mexico December 2007                    //
36 //                                                                           //
37 //      Last Update: Nov. 17th 2009                                          //
38 //      Mario Rodriguez Cahuantzi                                            //
39 ///////////////////////////////////////////////////////////////////////////////
40
41
42 #include <Riostream.h>
43 #include <TGeoMatrix.h>
44 #include <TMath.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 "TGeoPgon.h"
55 #include "TGeoTrd1.h"
56 #include "TGeoCompositeShape.h"
57 #include "TGeoPara.h"
58
59 #include "AliACORDEv1.h"
60 #include <TClonesArray.h>
61 #include <TLorentzVector.h>
62 #include <TVirtualMC.h>
63 #include <TPDGCode.h>
64
65 #include "AliRun.h"
66 #include "AliConst.h"
67 #include "AliACORDEhit.h"
68 #include "AliACORDEConstants.h"
69 #include "AliMC.h"
70 #include "AliLog.h"
71
72 ClassImp(AliACORDEv1)
73  
74 //_____________________________________________________________________________
75 AliACORDEv1::AliACORDEv1()
76   : AliACORDE()
77 {
78   //
79   // Default constructor
80   fIshunt = 0;
81   fHits = 0;
82   //
83
84 //_____________________________________________________________________________
85 AliACORDEv1::AliACORDEv1(const char *name, const char *title)
86   : AliACORDE(name, title)
87 {
88   //
89   // Standard constructor
90   //
91   fIshunt = 1; // All hits are associated with primary particles 
92   fHits =  new TClonesArray("AliACORDEhit",400);
93   gAlice->GetMCApp()->AddHitList(fHits);
94 }
95 //_____________________________________________________________________________
96 AliACORDEv1::~AliACORDEv1()
97 {
98   //
99   // Default destructor
100   //
101 }
102 //_____________________________________________________________________________
103 void AliACORDEv1::CreateGeometry()
104 {
105   CreateAcorde();
106 }
107 void AliACORDEv1::CreateAcorde()
108 {  
109
110         // Call the global constants for the Modules
111         
112         AliACORDEConstants* constants = AliACORDEConstants::Instance();
113
114         // Get the Alice Volume
115
116         TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
117
118         // Define some materials & medium
119
120         //*** Aluminium ***
121
122         TGeoMedium* aluminium = gGeoManager->GetMedium("ACORDE_ALU_C0");
123
124         //*** Scintillator ***
125
126         TGeoMedium* scintillator = gGeoManager->GetMedium("ACORDE_CPV scint.1");
127         
128         //Define the mother volume for the ACORDE detector
129
130         TGeoVolume *acorde = new TGeoVolumeAssembly("ACORDE");
131
132
133         // Define 2 main-daughter volumes for ACORDE
134         
135         TGeoVolume *supportBars = new TGeoVolumeAssembly("ACORDE_SUPPORTS_BARS");
136         TGeoVolume *acordeModules = new TGeoVolumeAssembly("ALL_ACORDE_MODULES");
137
138   
139         // Define rotation Matrix for Side's faces in Alice
140         
141         TGeoRotation *idrotm231 = new TGeoRotation("idrotm231",90, 45, 90, 135, 0, 0);
142         TGeoRotation *idrotm232 = new TGeoRotation("idrotm232",90, 315, 90, 45, 0, 0);
143
144         // Begin the Geometry for ACORDE
145
146         // *** Definition of ACORDE's Modules ***
147
148         // Define Measures of ACORDE's Modules
149
150         Float_t acoFrameBox1[3],acoFrameBox2[3];
151
152         acoFrameBox1[0] = constants->ModuleLength()/2;
153         acoFrameBox1[1] = constants->ModuleHeight()/2;
154         acoFrameBox1[2] = 2.50;
155
156         acoFrameBox2[0] = 20.0;
157         acoFrameBox2[1] = constants->ModuleHeight()/2;
158         acoFrameBox2[2] = 10.0;
159
160         // Define Measures of Scintillators
161         
162         Float_t acoScinBox[3];  
163         acoScinBox[0] = constants->PlasticLength()/2;
164         acoScinBox[1] = constants->PlasticHeight()/2;
165         acoScinBox[2] = constants->PlasticWidth()/2;
166
167
168         // Create the Modules of ACORDE, 1 aluminium frame and two scintillator plastics
169
170         //*** Aluminium frame ***
171
172         TGeoBBox *acordeModFrameBoxL = new TGeoBBox("acordeModFrameBoxL",acoFrameBox1[0],acoFrameBox1[1],acoFrameBox1[2]);
173         TGeoBBox *acordeModFrameBoxH = new TGeoBBox("acordeModFrameBoxH",acoFrameBox2[0],acoFrameBox2[1],acoFrameBox2[2]);
174         TGeoVolume *acordeModFrameVolumeL = new TGeoVolume("ACORDEMODFRAMEVOLUMEL",acordeModFrameBoxL,aluminium);
175         TGeoVolume *acordeModFrameVolumeH = new TGeoVolume("ACORDEMODFRAMEVOLUMEH",acordeModFrameBoxH,aluminium);
176
177
178         //*** Scintillators ***
179
180         TGeoBBox *acordeScintillatorBox = new TGeoBBox("acordeScintillatorBox",acoScinBox[0],acoScinBox[1],acoScinBox[2]);
181         TGeoVolume *acordeScintillatorVolume = new TGeoVolume("ACORDESCINTILLATORMODULE",acordeScintillatorBox,scintillator);
182
183
184         // Here I create a single ACORDE module and then we make 60 copies of it
185
186         TGeoVolume *acordeSingleModule = new TGeoVolumeAssembly("ACORDE_MODULE");
187         acordeSingleModule->AddNode(acordeModFrameVolumeL,1,new TGeoTranslation("acordeFrame_01",0,0,12.5));
188         acordeSingleModule->AddNode(acordeModFrameVolumeL,2,new TGeoTranslation("acordeFrame_02",0,0,-12.5));
189         acordeSingleModule->AddNode(acordeModFrameVolumeH,3,new TGeoTranslation("acordeFrame_03",130,0,0));
190         acordeSingleModule->AddNode(acordeModFrameVolumeH,4,new TGeoTranslation("acordeFrame_04",-130,0,0));
191         acordeSingleModule->AddNode(acordeScintillatorVolume,5, new TGeoTranslation("acordeScintillator_01",0,1,0));
192         acordeSingleModule->AddNode(acordeScintillatorVolume,6, new TGeoTranslation("acordeScintillator_01",0,-1,0));
193
194         // Put the Modules of In-Face
195         
196         for(Int_t iAcordeModule=1;iAcordeModule<9;iAcordeModule++)
197         {
198
199                 Float_t posx = constants->CenterModulePositionX(iAcordeModule);
200                 Float_t posy = constants->CenterModulePositionY(iAcordeModule);
201                 Float_t posz = constants->CenterModulePositionZ(iAcordeModule); 
202                 
203                 acordeModules->AddNode(acordeSingleModule,iAcordeModule,
204                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm232));
205         }
206
207         for(Int_t iAcordeModule=10;iAcordeModule<20;iAcordeModule++)
208         {
209                 Float_t posx = constants->CenterModulePositionX(iAcordeModule);
210                 Float_t posy = constants->CenterModulePositionY(iAcordeModule);
211                 Float_t posz = constants->CenterModulePositionZ(iAcordeModule);
212
213                 acordeModules->AddNode(acordeSingleModule,iAcordeModule,
214                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm232));
215         }
216
217         // Put he Modules of Up-Face
218
219         for(Int_t iAcordeModule=20;iAcordeModule<40;iAcordeModule++)
220         {
221                 Float_t posx = constants->CenterModulePositionX(iAcordeModule);
222                 Float_t posy = constants->CenterModulePositionY(iAcordeModule);
223                 Float_t posz = constants->CenterModulePositionZ(iAcordeModule); 
224
225                 acordeModules->AddNode(acordeSingleModule,iAcordeModule,new TGeoTranslation("aco01",posx,posy,posz));
226         }
227
228         // Put the Modules of Out-Face
229
230         for(Int_t iAcordeModule=40;iAcordeModule<50;iAcordeModule++)
231         {
232                 Float_t posx = constants->CenterModulePositionX(iAcordeModule);
233                 Float_t posy = constants->CenterModulePositionY(iAcordeModule);
234                 Float_t posz = constants->CenterModulePositionZ(iAcordeModule); 
235
236                 acordeModules->AddNode(acordeSingleModule,iAcordeModule,
237                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm231));
238         }
239
240         // Put the Modules of Out-Face
241
242         for(Int_t iAcordeModule=51;iAcordeModule<59;iAcordeModule++)
243         {
244                 Float_t posx = constants->CenterModulePositionX(iAcordeModule);
245                 Float_t posy = constants->CenterModulePositionY(iAcordeModule);
246                 Float_t posz = constants->CenterModulePositionZ(iAcordeModule); 
247                 acordeModules->AddNode(acordeSingleModule,iAcordeModule,
248                                         new TGeoCombiTrans("aco01",posx,posy,posz,idrotm231));
249         }
250
251         // Put the 4-central modules (Old-ITS modules)
252         if (Get4CentralModulesGeometry()) 
253         { 
254                 acordeModules->AddNode(acordeSingleModule,0,
255                         new TGeoTranslation("Mod0_0",constants->CenterModulePositionX(0),constants->CenterModulePositionY(0),constants->CenterModulePositionZ(0)));
256                 acordeModules->AddNode(acordeSingleModule,9,
257                         new TGeoTranslation("Mod0_9",constants->CenterModulePositionX(9),constants->CenterModulePositionY(9),constants->CenterModulePositionZ(9)));
258                 acordeModules->AddNode(acordeSingleModule,50,
259                         new TGeoTranslation("Mod0_50",constants->CenterModulePositionX(50),constants->CenterModulePositionY(50),constants->CenterModulePositionZ(50)));
260                 acordeModules->AddNode(acordeSingleModule,59,
261                         new TGeoTranslation("Mod0_59",constants->CenterModulePositionX(59),constants->CenterModulePositionY(59),constants->CenterModulePositionZ(59)));
262         }
263
264         // Create a dummy support & bars of Aluminium (it doesn't exist a survey of this structure)
265
266         Float_t boxLongSupport[3],boxThinSupport[3];
267
268         boxLongSupport[0]=10.0;
269         boxLongSupport[1]=0.5;
270         boxLongSupport[2]=500.0;
271
272         boxThinSupport[0]=1.0;
273         boxThinSupport[1]=7.0;
274         boxThinSupport[2]=500.0;
275
276         TGeoBBox *acordeLongSupport = new TGeoBBox("ACORDELONGSUPPORT",boxLongSupport[0],boxLongSupport[1],boxLongSupport[2]);
277         TGeoBBox *acordeThinSupport = new TGeoBBox("ACORDETHINSUPPORT",boxThinSupport[0],boxThinSupport[1],boxThinSupport[2]);
278
279         TGeoVolume *acordeLSupport = new TGeoVolume("ACORDELS",acordeLongSupport,aluminium);
280         TGeoVolume *acordeTSupport = new TGeoVolume("ACORDETS",acordeThinSupport,aluminium);
281         TGeoVolume *acordeMainSupport = new TGeoVolumeAssembly("ACORDE_SUPPORT"); 
282         acordeMainSupport->AddNode(acordeLSupport,1,new TGeoTranslation("ACOLSA",0,7.5,0));
283         acordeMainSupport->AddNode(acordeLSupport,2,new TGeoTranslation("ACOLSB",0,-7.5,0));
284         acordeMainSupport->AddNode(acordeTSupport,3);
285
286         // Set the values for the bars support
287         
288         Float_t boxSingleBar[3];
289         boxSingleBar[0]=10;
290         boxSingleBar[1]=37;//36.722; // Correction to avoid overlaps with the L3 magnet
291         boxSingleBar[2]=10;
292
293         Float_t boxUnionUp[3];
294         boxUnionUp[0]=10;
295         boxUnionUp[1]=0.5;
296         boxUnionUp[2]=15;
297
298         Float_t boxUnionDown[3];
299         boxUnionDown[0]=20;
300         boxUnionDown[1]=1;
301         boxUnionDown[2]=20;
302         
303         // Volume and Box for the bar
304         
305         TGeoBBox *acordeSingleBarSupport = new TGeoBBox("ACORDESBARS",boxSingleBar[0],boxSingleBar[1],boxSingleBar[2]);
306         TGeoVolume *acordeBarSupport = new TGeoVolume("ACORDEBARSUPPORT",acordeSingleBarSupport,aluminium);
307
308         // Volume and Box for the bar union with the long support (Up-with supports and Down with L3 magnet)
309         
310         TGeoBBox *acordeSingleBoxUnionUp = new TGeoBBox("ACORDEBUP",boxUnionUp[0],boxUnionUp[1],boxUnionUp[2]);
311         TGeoVolume *acordeBoxUnionUp = new TGeoVolume("ACORDEBOXUNIONUP",acordeSingleBoxUnionUp,aluminium);
312         
313         TGeoBBox *acordeSingleBoxUnionDown = new TGeoBBox("ACORDEBDOWN",boxUnionDown[0],boxUnionDown[1],boxUnionDown[2]);
314         TGeoVolume *acordeBoxUnionDown = new TGeoVolume("ACORDEBOXUNIONDOWN",acordeSingleBoxUnionDown,aluminium);
315
316         TGeoVolume *acordeMainBar = new TGeoVolumeAssembly("ACORDE_BAR");
317         acordeMainBar->AddNode(acordeBoxUnionUp,1,new TGeoTranslation("ACOBAR01",0,boxSingleBar[1]+boxUnionUp[1],0));
318         acordeMainBar->AddNode(acordeBarSupport,2);
319         acordeMainBar->AddNode(acordeBoxUnionDown,3,new TGeoTranslation("ACOBAR01",0,-boxSingleBar[1]-boxUnionDown[1],0));
320
321         // Volume for the Full support (supports and bars) UP face of L3 Magnet
322         Float_t supportPosXIn = constants->CenterModulePositionX(20);
323         Float_t supportPosY = 859.044-7.5-5.5; // Minimum module position Y less the heigh of the support
324         Float_t supportPosZ = 0;
325         Float_t supportPosXOut = constants->CenterModulePositionX(30);
326         Float_t deltaXA = 120.;
327         Float_t deltaXB = 60.;
328
329         TGeoVolume *acordeFullSupportUpFace = new TGeoVolumeAssembly("ACORDE_FULL_SUPPORT_UPFACE");
330         acordeFullSupportUpFace->AddNode(acordeMainSupport,1,new TGeoTranslation("ACOFSB01",supportPosXIn+deltaXA,supportPosY,supportPosZ));
331         acordeFullSupportUpFace->AddNode(acordeMainSupport,2,new TGeoTranslation("ACOFSB02",supportPosXIn+deltaXB,supportPosY,supportPosZ));
332         acordeFullSupportUpFace->AddNode(acordeMainSupport,3,new TGeoTranslation("ACOFSB03",supportPosXIn-deltaXA,supportPosY,supportPosZ));
333         acordeFullSupportUpFace->AddNode(acordeMainSupport,4,new TGeoTranslation("ACOFSB04",supportPosXIn-deltaXB,supportPosY,supportPosZ));
334         acordeFullSupportUpFace->AddNode(acordeMainSupport,5,new TGeoTranslation("ACOFSB05",supportPosXOut+deltaXA,supportPosY,supportPosZ));
335         acordeFullSupportUpFace->AddNode(acordeMainSupport,6,new TGeoTranslation("ACOFSB06",supportPosXOut+deltaXB,supportPosY,supportPosZ));
336         acordeFullSupportUpFace->AddNode(acordeMainSupport,7,new TGeoTranslation("ACOFSB07",supportPosXOut-deltaXA,supportPosY,supportPosZ));
337         acordeFullSupportUpFace->AddNode(acordeMainSupport,8,new TGeoTranslation("ACOFSB08",supportPosXOut-deltaXB,supportPosY,supportPosZ));
338         
339         // Put the bars in the main volume acordeFullSupportUpFace
340
341         Float_t barPosXIn = constants->CenterModulePositionX(20);
342         Float_t barPosY = supportPosY-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
343         Float_t barPosZ = 0;
344         Int_t barIndex = 9;
345         for(Int_t iBarModule = 20; iBarModule<30; iBarModule+=2)
346         {
347                 barPosZ = constants->CenterModulePositionZ(iBarModule);
348                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex,new TGeoTranslation("ACOFSB09",barPosXIn+deltaXA,barPosY,barPosZ));     
349                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+1,new TGeoTranslation("ACOFSB09",barPosXIn+deltaXB,barPosY,barPosZ));   
350                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+2,new TGeoTranslation("ACOFSB09",barPosXIn-deltaXA,barPosY,barPosZ));
351                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+3,new TGeoTranslation("ACOFSB09",barPosXIn-deltaXB,barPosY,barPosZ));
352
353                 barIndex+=4;
354         }
355
356         Float_t barPosXOut = constants->CenterModulePositionX(30);
357         for(Int_t iBarModule = 30; iBarModule<40; iBarModule+=2)
358         {
359                 barPosZ = constants->CenterModulePositionZ(iBarModule);
360                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex,new TGeoTranslation("ACOFSB09",barPosXOut+deltaXA,barPosY,barPosZ));
361                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+1,new TGeoTranslation("ACOFSB09",barPosXOut+deltaXB,barPosY,barPosZ));
362                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+2,new TGeoTranslation("ACOFSB09",barPosXOut-deltaXA,barPosY,barPosZ));
363                 acordeFullSupportUpFace->AddNode(acordeMainBar,barIndex+3,new TGeoTranslation("ACOFSB09",barPosXOut-deltaXB,barPosY,barPosZ));
364
365                 barIndex+=4;
366         }
367
368         // Supports and bars for the InSide of L3 Magnet
369
370         TGeoVolume *acordeFullSupportInFace = new TGeoVolumeAssembly("ACORDE_FULL_SUPPORT_INFACE");
371         Float_t supportPosXInA = constants->CenterModulePositionX(1)+deltaXA;
372         Float_t supportPosYInA = 592.017-7.5-5.5;
373         Float_t x0 = constants->CenterModulePositionX(1);
374         Float_t y0 = constants->CenterModulePositionY(1);
375         Float_t theta = -1*TMath::Pi()/4;
376         Float_t supportPosXInPA = x0+(supportPosXInA-x0)*TMath::Cos(theta)-(supportPosYInA-y0)*TMath::Sin(theta);
377         Float_t supportPosYInPA = y0+(supportPosYInA-y0)*TMath::Cos(theta)+(supportPosXInA-x0)*TMath::Sin(theta);
378         Float_t supportPosZInIn = 0;
379
380         Float_t supportPosXInB = constants->CenterModulePositionX(1)+deltaXB;
381         Float_t supportPosXInPB = x0+(supportPosXInB-x0)*TMath::Cos(theta)-(supportPosYInA-y0)*TMath::Sin(theta);
382         Float_t supportPosYInPB = y0+(supportPosYInA-y0)*TMath::Cos(theta)+(supportPosXInB-x0)*TMath::Sin(theta);
383
384         Float_t supportPosXInC = constants->CenterModulePositionX(1)-deltaXA;
385         Float_t supportPosXInPC = x0+(supportPosXInC-x0)*TMath::Cos(theta)-(supportPosYInA-y0)*TMath::Sin(theta);
386         Float_t supportPosYInPC = y0+(supportPosYInA-y0)*TMath::Cos(theta)+(supportPosXInC-x0)*TMath::Sin(theta);
387
388         Float_t supportPosXInD = constants->CenterModulePositionX(1)-deltaXB;
389         Float_t supportPosXInPD = x0+(supportPosXInD-x0)*TMath::Cos(theta)-(supportPosYInA-y0)*TMath::Sin(theta);
390         Float_t supportPosYInPD = y0+(supportPosYInA-y0)*TMath::Cos(theta)+(supportPosXInD-x0)*TMath::Sin(theta);
391
392
393         acordeFullSupportInFace->AddNode(acordeMainSupport,1,new TGeoCombiTrans("ACOFSBIN01",supportPosXInPA,supportPosYInPA,supportPosZInIn,idrotm232));
394         acordeFullSupportInFace->AddNode(acordeMainSupport,2,new TGeoCombiTrans("ACOFSBIN02",supportPosXInPB,supportPosYInPB,supportPosZInIn,idrotm232));
395         acordeFullSupportInFace->AddNode(acordeMainSupport,3,new TGeoCombiTrans("ACOFSBIN03",supportPosXInPC,supportPosYInPC,supportPosZInIn,idrotm232));
396         acordeFullSupportInFace->AddNode(acordeMainSupport,4,new TGeoCombiTrans("ACOFSBIN04",supportPosXInPD,supportPosYInPD,supportPosZInIn,idrotm232));
397
398         Float_t supportPosXInE = constants->CenterModulePositionX(10)+deltaXA;
399         Float_t supportPosYInE = 806.312-7.5-5.5;
400         Float_t x00 = constants->CenterModulePositionX(10);
401         Float_t y00 = constants->CenterModulePositionY(10);
402         Float_t supportPosXInPE = x00+(supportPosXInE-x00)*TMath::Cos(theta)-(supportPosYInE-y00)*TMath::Sin(theta);
403         Float_t supportPosYInPE = y00+(supportPosYInE-y00)*TMath::Cos(theta)+(supportPosXInE-x00)*TMath::Sin(theta);
404
405         Float_t supportPosXInF = constants->CenterModulePositionX(10)+deltaXB;
406         Float_t supportPosXInPF = x00+(supportPosXInF-x00)*TMath::Cos(theta)-(supportPosYInE-y00)*TMath::Sin(theta);
407         Float_t supportPosYInPF = y00+(supportPosYInE-y00)*TMath::Cos(theta)+(supportPosXInF-x00)*TMath::Sin(theta);
408
409         Float_t supportPosXInG = constants->CenterModulePositionX(10)-deltaXA+100;
410         Float_t supportPosXInPG = x00+(supportPosXInG-x00)*TMath::Cos(theta)-(supportPosYInE-y00)*TMath::Sin(theta);
411         Float_t supportPosYInPG = y00+(supportPosYInE-y00)*TMath::Cos(theta)+(supportPosXInG-x00)*TMath::Sin(theta);
412
413         acordeFullSupportInFace->AddNode(acordeMainSupport,5,new TGeoCombiTrans("ACOFSBIN05",supportPosXInPE,supportPosYInPE,supportPosZInIn,idrotm232));
414         acordeFullSupportInFace->AddNode(acordeMainSupport,6,new TGeoCombiTrans("ACOFSBIN06",supportPosXInPF,supportPosYInPF,supportPosZInIn,idrotm232));
415         acordeFullSupportInFace->AddNode(acordeMainSupport,7,new TGeoCombiTrans("ACOFSBIN07",supportPosXInPG,supportPosYInPG,supportPosZInIn,idrotm232));
416
417         // Put the bars in the main volume acordeFullSupportInFace
418
419         Int_t barIndexIn = 8;
420
421         for (Int_t iBarModule=1; iBarModule<9; iBarModule+=2)
422         {
423                 Float_t barPosXInIn = constants->CenterModulePositionX(iBarModule)+deltaXA;
424                 Float_t barPosYInIn = supportPosYInA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
425                 Float_t barPosZInIn = constants->CenterModulePositionZ(iBarModule);
426                 Float_t barPosXInP = x0+(barPosXInIn-x0)*TMath::Cos(theta)-(barPosYInIn-y0)*TMath::Sin(theta);
427                 Float_t barPosYInP = y0+(barPosYInIn-y0)*TMath::Cos(theta)+(barPosXInIn-x0)*TMath::Sin(theta);
428
429                 Float_t barPosXInInA = constants->CenterModulePositionX(iBarModule)+deltaXB;
430                 Float_t barPosYInInA = supportPosYInA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
431                 Float_t barPosZInInA = constants->CenterModulePositionZ(iBarModule);
432                 Float_t barPosXInPA = x0+(barPosXInInA-x0)*TMath::Cos(theta)-(barPosYInInA-y0)*TMath::Sin(theta);
433                 Float_t barPosYInPA = y0+(barPosYInInA-y0)*TMath::Cos(theta)+(barPosXInInA-x0)*TMath::Sin(theta);
434
435                 Float_t barPosXInInB = constants->CenterModulePositionX(iBarModule)-deltaXA;
436                 Float_t barPosYInInB = supportPosYInA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
437                 Float_t barPosZInInB = constants->CenterModulePositionZ(iBarModule);
438                 Float_t barPosXInPB = x0+(barPosXInInB-x0)*TMath::Cos(theta)-(barPosYInInB-y0)*TMath::Sin(theta);
439                 Float_t barPosYInPB = y0+(barPosYInInB-y0)*TMath::Cos(theta)+(barPosXInInB-x0)*TMath::Sin(theta);
440
441                 Float_t barPosXInInC = constants->CenterModulePositionX(iBarModule)-deltaXB;
442                 Float_t barPosYInInC = supportPosYInA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
443                 Float_t barPosZInInC = constants->CenterModulePositionZ(iBarModule);
444                 Float_t barPosXInPC = x0+(barPosXInInC-x0)*TMath::Cos(theta)-(barPosYInInC-y0)*TMath::Sin(theta);
445                 Float_t barPosYInPC = y0+(barPosYInInC-y0)*TMath::Cos(theta)+(barPosXInInC-x0)*TMath::Sin(theta);
446
447                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn,new TGeoCombiTrans("ACOFSBIN08",barPosXInP,barPosYInP,barPosZInIn,idrotm232));
448                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn+1,new TGeoCombiTrans("ACOFSBIN09",barPosXInPA,barPosYInPA,barPosZInInA,idrotm232));
449                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn+2,new TGeoCombiTrans("ACOFSBIN10",barPosXInPB,barPosYInPB,barPosZInInB,idrotm232));
450                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn+3,new TGeoCombiTrans("ACOFSBIN11",barPosXInPC,barPosYInPC,barPosZInInC,idrotm232));
451
452                 barIndexIn+=4;
453         }
454
455         for (Int_t iBarModule=10; iBarModule<20; iBarModule+=2)
456         {
457                 Float_t barPosXInIn = constants->CenterModulePositionX(iBarModule)+deltaXA;
458                 Float_t barPosYInIn = supportPosYInE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
459                 Float_t barPosZInIn = constants->CenterModulePositionZ(iBarModule);
460                 Float_t barPosXInP = x00+(barPosXInIn-x00)*TMath::Cos(theta)-(barPosYInIn-y00)*TMath::Sin(theta);
461                 Float_t barPosYInP = y00+(barPosYInIn-y00)*TMath::Cos(theta)+(barPosXInIn-x00)*TMath::Sin(theta);
462
463                 Float_t barPosXInInA = constants->CenterModulePositionX(iBarModule)+deltaXB;
464                 Float_t barPosYInInA = supportPosYInE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
465                 Float_t barPosZInInA = constants->CenterModulePositionZ(iBarModule);
466                 Float_t barPosXInPA = x00+(barPosXInInA-x00)*TMath::Cos(theta)-(barPosYInInA-y00)*TMath::Sin(theta);
467                 Float_t barPosYInPA = y00+(barPosYInInA-y00)*TMath::Cos(theta)+(barPosXInInA-x00)*TMath::Sin(theta);
468
469                 Float_t barPosXInInB = constants->CenterModulePositionX(iBarModule)-deltaXA+100;
470                 Float_t barPosYInInB = supportPosYInE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
471                 Float_t barPosZInInB = constants->CenterModulePositionZ(iBarModule);
472                 Float_t barPosXInPB = x00+(barPosXInInB-x00)*TMath::Cos(theta)-(barPosYInInB-y00)*TMath::Sin(theta);
473                 Float_t barPosYInPB = y00+(barPosYInInB-y00)*TMath::Cos(theta)+(barPosXInInB-x00)*TMath::Sin(theta);
474
475                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn,new TGeoCombiTrans("ACOFSBIN08",barPosXInP,barPosYInP,barPosZInIn,idrotm232));
476                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn+1,new TGeoCombiTrans("ACOFSBIN09",barPosXInPA,barPosYInPA,barPosZInInA,idrotm232));
477                 acordeFullSupportInFace->AddNode(acordeMainBar,barIndexIn+2,new TGeoCombiTrans("ACOFSBIN10",barPosXInPB,barPosYInPB,barPosZInInB,idrotm232));
478
479                 barIndexIn+=4;
480         }
481
482
483         // Construction of the support and bars for the OutSide
484
485
486         TGeoVolume *acordeFullSupportOutFace = new TGeoVolumeAssembly("ACORDE_FULL_SUPPORT_OUTFACE");
487         Float_t supportPosXOutA = constants->CenterModulePositionX(45)+deltaXA-90;
488         Float_t supportPosYOutA = 807.2915-7.5-5.5;
489         Float_t x000 = constants->CenterModulePositionX(45);
490         Float_t y000 = constants->CenterModulePositionY(45);
491         Float_t theta1 = 1*TMath::Pi()/4;
492
493         Float_t supportPosXOutPA = x000+(supportPosXOutA-x000)*TMath::Cos(theta1)-(supportPosYOutA-y000)*TMath::Sin(theta1);
494         Float_t supportPosYOutPA = y000+(supportPosYOutA-y000)*TMath::Cos(theta1)+(supportPosXOutA-x000)*TMath::Sin(theta1);
495         Float_t supportPosZOutIn = 0;
496
497
498         Float_t supportPosXOutC = constants->CenterModulePositionX(45)-deltaXA;
499         Float_t supportPosXOutPC = x000+(supportPosXOutC-x000)*TMath::Cos(theta1)-(supportPosYOutA-1-y000)*TMath::Sin(theta1);
500         Float_t supportPosYOutPC = y000+(supportPosYOutA-1-y000)*TMath::Cos(theta1)+(supportPosXOutC-x000)*TMath::Sin(theta1);
501
502         Float_t supportPosXOutD = constants->CenterModulePositionX(45)-deltaXB;
503         Float_t supportPosXOutPD = x000+(supportPosXOutD-x000)*TMath::Cos(theta1)-(supportPosYOutA-1-y000)*TMath::Sin(theta1);
504         Float_t supportPosYOutPD = y000+(supportPosYOutA-1-y000)*TMath::Cos(theta1)+(supportPosXOutD-x000)*TMath::Sin(theta1);
505
506
507         acordeFullSupportOutFace->AddNode(acordeMainSupport,1,new TGeoCombiTrans("ACOFSBOUT01",supportPosXOutPA,supportPosYOutPA,supportPosZOutIn,idrotm231));
508         acordeFullSupportOutFace->AddNode(acordeMainSupport,2,new TGeoCombiTrans("ACOFSBOUT02",supportPosXOutPC,supportPosYOutPC,supportPosZOutIn,idrotm231));
509         acordeFullSupportOutFace->AddNode(acordeMainSupport,3,new TGeoCombiTrans("ACOFSBOUT03",supportPosXOutPD,supportPosYOutPD,supportPosZOutIn,idrotm231));
510         
511
512         Float_t supportPosXOutE = constants->CenterModulePositionX(52)+deltaXA;
513         Float_t supportPosYOutE = 585.616-7.5-5.5-0.1;
514         Float_t x0000 = constants->CenterModulePositionX(52);
515         Float_t y0000 = constants->CenterModulePositionY(52);
516
517         Float_t supportPosXOutEP = x0000+(supportPosXOutE-x0000)*TMath::Cos(theta1)-(supportPosYOutE-y0000)*TMath::Sin(theta1);
518         Float_t supportPosYOutEP = y0000+(supportPosYOutE-y0000)*TMath::Cos(theta1)+(supportPosXOutE-x0000)*TMath::Sin(theta1);
519         
520         Float_t supportPosXOutF = constants->CenterModulePositionX(52)+deltaXB;
521
522         Float_t supportPosXOutFP = x0000+(supportPosXOutF-x0000)*TMath::Cos(theta1)-(supportPosYOutE-y0000)*TMath::Sin(theta1);
523         Float_t supportPosYOutFP = y0000+(supportPosYOutE-y0000)*TMath::Cos(theta1)+(supportPosXOutF-x0000)*TMath::Sin(theta1);
524
525         Float_t supportPosXOutG = constants->CenterModulePositionX(52)-deltaXA;
526         Float_t supportPosXOutGP = x0000+(supportPosXOutG-x0000)*TMath::Cos(theta1)-(supportPosYOutE-y0000)*TMath::Sin(theta1);
527         Float_t supportPosYOutGP = y0000+(supportPosYOutE-y0000)*TMath::Cos(theta1)+(supportPosXOutG-x0000)*TMath::Sin(theta1);
528
529         Float_t supportPosXOutH = constants->CenterModulePositionX(52)-deltaXB;
530         Float_t supportPosXOutHP = x0000+(supportPosXOutH-x0000)*TMath::Cos(theta1)-(supportPosYOutE-0.4-y0000)*TMath::Sin(theta1);
531         Float_t supportPosYOutHP = y0000+(supportPosYOutE-0.4-y0000)*TMath::Cos(theta1)+(supportPosXOutH-x0000)*TMath::Sin(theta1);
532
533
534         acordeFullSupportOutFace->AddNode(acordeMainSupport,4,new TGeoCombiTrans("ACOFSBOUT04",supportPosXOutEP,supportPosYOutEP,supportPosZOutIn,idrotm231));
535         acordeFullSupportOutFace->AddNode(acordeMainSupport,5,new TGeoCombiTrans("ACOFSBOUT05",supportPosXOutFP,supportPosYOutFP,supportPosZOutIn,idrotm231));
536         acordeFullSupportOutFace->AddNode(acordeMainSupport,6,new TGeoCombiTrans("ACOFSBOUT06",supportPosXOutGP,supportPosYOutGP,supportPosZOutIn,idrotm231));
537         acordeFullSupportOutFace->AddNode(acordeMainSupport,7,new TGeoCombiTrans("ACOFSBOUT07",supportPosXOutHP,supportPosYOutHP,supportPosZOutIn,idrotm231));
538
539         // Put the bars of the PutFace Side 2 L3-Magnet
540
541
542         Int_t indexBar0=8;
543         for(Int_t iAcoBar = 40;iAcoBar < 50 ; iAcoBar+=2)
544         {
545                 Float_t barPosXOutIn = constants->CenterModulePositionX(iAcoBar)+deltaXA-90;
546                 Float_t barPosYOutIn = supportPosYOutA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
547                 Float_t barPosZOutIn = constants->CenterModulePositionZ(iAcoBar);
548                 Float_t barPosXOutP = x000+(barPosXOutIn-x000)*TMath::Cos(theta1)-(barPosYOutIn-y000)*TMath::Sin(theta1);
549                 Float_t barPosYOutP = y000+(barPosYOutIn-y000)*TMath::Cos(theta1)+(barPosXOutIn-x000)*TMath::Sin(theta1);
550
551                 Float_t barPosXOutInA = constants->CenterModulePositionX(iAcoBar)-deltaXA;
552                 Float_t barPosYOutInA = supportPosYOutA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5-1.;
553                 Float_t barPosZOutInA = constants->CenterModulePositionZ(iAcoBar);
554                 Float_t barPosXOutPA = x000+(barPosXOutInA-x000)*TMath::Cos(theta1)-(barPosYOutInA-y000)*TMath::Sin(theta1);
555                 Float_t barPosYOutPA = y000+(barPosYOutInA-y000)*TMath::Cos(theta1)+(barPosXOutInA-x000)*TMath::Sin(theta1);
556
557
558                 Float_t barPosXOutInB = constants->CenterModulePositionX(iAcoBar)-deltaXB;
559                 Float_t barPosYOutInB = supportPosYOutA-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5-1.;
560                 Float_t barPosZOutInB = constants->CenterModulePositionZ(iAcoBar);
561                 Float_t barPosXOutPB = x000+(barPosXOutInB-x000)*TMath::Cos(theta1)-(barPosYOutInB-y000)*TMath::Sin(theta1);
562                 Float_t barPosYOutPB = y000+(barPosYOutInB-y000)*TMath::Cos(theta1)+(barPosXOutInB-x000)*TMath::Sin(theta1);
563         
564                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutP,barPosYOutP,barPosZOutIn,idrotm231));
565                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+1,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPA,barPosYOutPA,barPosZOutInA,idrotm231));
566                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+2,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPB,barPosYOutPB,barPosZOutInB,idrotm231));
567
568                 indexBar0+=4;
569         }
570         for(Int_t iAcoBar = 51;iAcoBar < 54 ; iAcoBar+=2)
571         {
572
573                 Float_t barPosXOutInC = constants->CenterModulePositionX(iAcoBar)+deltaXA;
574                 Float_t barPosYOutInC = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
575                 Float_t barPosZOutInC = constants->CenterModulePositionZ(iAcoBar);
576                 Float_t barPosXOutPC = x0000+(barPosXOutInC-x0000)*TMath::Cos(theta1)-(barPosYOutInC-y0000)*TMath::Sin(theta1);
577                 Float_t barPosYOutPC = y0000+(barPosYOutInC-y0000)*TMath::Cos(theta1)+(barPosXOutInC-x0000)*TMath::Sin(theta1);
578
579
580                 Float_t barPosXOutInD = constants->CenterModulePositionX(iAcoBar)+deltaXB;
581                 Float_t barPosYOutInD = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
582                 Float_t barPosZOutInD = constants->CenterModulePositionZ(iAcoBar);
583                 Float_t barPosXOutPD = x0000+(barPosXOutInD-x0000)*TMath::Cos(theta1)-(barPosYOutInD-y0000)*TMath::Sin(theta1);
584                 Float_t barPosYOutPD = y0000+(barPosYOutInD-y0000)*TMath::Cos(theta1)+(barPosXOutInD-x0000)*TMath::Sin(theta1);
585
586
587                 Float_t barPosXOutInE = constants->CenterModulePositionX(iAcoBar)-deltaXA;
588                 Float_t barPosYOutInE = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
589                 Float_t barPosZOutInE = constants->CenterModulePositionZ(iAcoBar);
590                 Float_t barPosXOutPE = x0000+(barPosXOutInE-x0000)*TMath::Cos(theta1)-(barPosYOutInE-y0000)*TMath::Sin(theta1);
591                 Float_t barPosYOutPE = y0000+(barPosYOutInE-y0000)*TMath::Cos(theta1)+(barPosXOutInE-x0000)*TMath::Sin(theta1);
592                 Float_t barPosXOutInF = constants->CenterModulePositionX(iAcoBar)-deltaXB;
593                 Float_t barPosYOutInF = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
594                 Float_t barPosZOutInF = constants->CenterModulePositionZ(iAcoBar);
595                 Float_t barPosXOutPF = x0000+(barPosXOutInF-x0000)*TMath::Cos(theta1)-(barPosYOutInF-0.4-y0000)*TMath::Sin(theta1);
596                 Float_t barPosYOutPF = y0000+(barPosYOutInF-0.4-y0000)*TMath::Cos(theta1)+(barPosXOutInF-x0000)*TMath::Sin(theta1);
597
598                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPC,barPosYOutPC,barPosZOutInC,idrotm231));
599                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+1,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPD,barPosYOutPD,barPosZOutInD,idrotm231));
600                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+2,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPE,barPosYOutPE,barPosZOutInE,idrotm231));
601                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+3,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPF,barPosYOutPF,barPosZOutInF,idrotm231));
602                 indexBar0+=4;
603         }
604
605
606         for(Int_t iAcoBar = 57;iAcoBar < 58 ; iAcoBar+=2)
607         {
608
609                 Float_t barPosXOutInC = constants->CenterModulePositionX(iAcoBar)+deltaXA;
610                 Float_t barPosYOutInC = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
611                 Float_t barPosZOutInC = constants->CenterModulePositionZ(iAcoBar);
612                 Float_t barPosXOutPC = x0000+(barPosXOutInC-x0000)*TMath::Cos(theta1)-(barPosYOutInC-y0000)*TMath::Sin(theta1);
613                 Float_t barPosYOutPC = y0000+(barPosYOutInC-y0000)*TMath::Cos(theta1)+(barPosXOutInC-x0000)*TMath::Sin(theta1);
614
615
616                 Float_t barPosXOutInD = constants->CenterModulePositionX(iAcoBar)+deltaXB;
617                 Float_t barPosYOutInD = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
618                 Float_t barPosZOutInD = constants->CenterModulePositionZ(iAcoBar);
619                 Float_t barPosXOutPD = x0000+(barPosXOutInD-x0000)*TMath::Cos(theta1)-(barPosYOutInD-y0000)*TMath::Sin(theta1);
620                 Float_t barPosYOutPD = y0000+(barPosYOutInD-y0000)*TMath::Cos(theta1)+(barPosXOutInD-x0000)*TMath::Sin(theta1);
621
622
623                 Float_t barPosXOutInE = constants->CenterModulePositionX(iAcoBar)-deltaXA;
624                 Float_t barPosYOutInE = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
625                 Float_t barPosZOutInE = constants->CenterModulePositionZ(iAcoBar);
626                 Float_t barPosXOutPE = x0000+(barPosXOutInE-x0000)*TMath::Cos(theta1)-(barPosYOutInE-y0000)*TMath::Sin(theta1);
627                 Float_t barPosYOutPE = y0000+(barPosYOutInE-y0000)*TMath::Cos(theta1)+(barPosXOutInE-x0000)*TMath::Sin(theta1);
628                 Float_t barPosXOutInF = constants->CenterModulePositionX(iAcoBar)-deltaXB;
629                 Float_t barPosYOutInF = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
630                 Float_t barPosZOutInF = constants->CenterModulePositionZ(iAcoBar);
631                 Float_t barPosXOutPF = x0000+(barPosXOutInF-x0000)*TMath::Cos(theta1)-(barPosYOutInF-0.4-y0000)*TMath::Sin(theta1);
632                 Float_t barPosYOutPF = y0000+(barPosYOutInF-0.4-y0000)*TMath::Cos(theta1)+(barPosXOutInF-x0000)*TMath::Sin(theta1);
633
634                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPC,barPosYOutPC,barPosZOutInC,idrotm231));
635                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+1,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPD,barPosYOutPD,barPosZOutInD,idrotm231));
636                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+2,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPE,barPosYOutPE,barPosZOutInE,idrotm231));
637                 acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+3,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPF,barPosYOutPF,barPosZOutInF,idrotm231));
638                 indexBar0+=4;
639         }
640
641
642         Float_t barPosXOutInC = constants->CenterModulePositionX(52)+deltaXA;
643         Float_t barPosYOutInC = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
644         Float_t barPosZOutInC = constants->CenterModulePositionZ(55);
645         Float_t barPosXOutPC = x0000+(barPosXOutInC-x0000)*TMath::Cos(theta1)-(barPosYOutInC-y0000)*TMath::Sin(theta1);
646         Float_t barPosYOutPC = y0000+(barPosYOutInC-y0000)*TMath::Cos(theta1)+(barPosXOutInC-x0000)*TMath::Sin(theta1);
647
648
649         Float_t barPosXOutInD = constants->CenterModulePositionX(52)+deltaXB;
650         Float_t barPosYOutInD = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
651         Float_t barPosXOutPD = x0000+(barPosXOutInD-x0000)*TMath::Cos(theta1)-(barPosYOutInD-y0000)*TMath::Sin(theta1);
652         Float_t barPosYOutPD = y0000+(barPosYOutInD-y0000)*TMath::Cos(theta1)+(barPosXOutInD-x0000)*TMath::Sin(theta1);
653
654
655         Float_t barPosXOutInE = constants->CenterModulePositionX(52)-deltaXA;
656         Float_t barPosYOutInE = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
657         Float_t barPosXOutPE = x0000+(barPosXOutInE-x0000)*TMath::Cos(theta1)-(barPosYOutInE-y0000)*TMath::Sin(theta1);
658         Float_t barPosYOutPE = y0000+(barPosYOutInE-y0000)*TMath::Cos(theta1)+(barPosXOutInE-x0000)*TMath::Sin(theta1);
659         Float_t barPosXOutInF = constants->CenterModulePositionX(52)-deltaXB;
660         Float_t barPosYOutInF = supportPosYOutE-boxSingleBar[1]-boxUnionUp[1]-boxUnionDown[1]-7.5;
661         Float_t barPosXOutPF = x0000+(barPosXOutInF-x0000)*TMath::Cos(theta1)-(barPosYOutInF-0.4-y0000)*TMath::Sin(theta1);
662         Float_t barPosYOutPF = y0000+(barPosYOutInF-0.4-y0000)*TMath::Cos(theta1)+(barPosXOutInF-x0000)*TMath::Sin(theta1);
663
664         acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPC,barPosYOutPC,barPosZOutInC,idrotm231));
665         acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+1,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPD,barPosYOutPD,barPosZOutInC,idrotm231));
666         acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+2,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPE,barPosYOutPE,barPosZOutInC,idrotm231));
667         acordeFullSupportOutFace->AddNode(acordeMainBar,indexBar0+3,new TGeoCombiTrans("ACOFSBOUT08",barPosXOutPF,barPosYOutPF,barPosZOutInC,idrotm231));
668         
669
670
671
672
673         supportBars->AddNode(acordeFullSupportUpFace,1);
674         supportBars->AddNode(acordeFullSupportInFace,2);
675         supportBars->AddNode(acordeFullSupportOutFace,3);
676         acorde->AddNode(acordeModules,1);
677         acorde->AddNode(supportBars,2);
678         alice->AddNode(acorde,1);//---> put volume of ACORDE over ALICE's volume
679
680
681
682 }
683 //__________________________________________________________________________
684
685 void AliACORDEv1::Init()
686 {
687   // Initialise L3 magnet after it has been built
688   Int_t i;
689   if(AliLog::GetGlobalDebugLevel()>0) {
690     printf("\n%s: ",ClassName());
691     for(i=0;i<35;i++) printf("*");
692     printf(" ACORDEv1_INIT ");
693     for(i=0;i<35;i++) printf("*");
694     printf("\n%s: ",ClassName());
695     // Here the ACORDEv initialisation code (if any!)
696     for(i=0;i<80;i++) printf("*");
697     printf("\n");
698   }
699  // AliACORDE::Init();  
700 }
701 //____________________________________________________________________________
702 void AliACORDEv1::StepManager()
703 {
704
705   //
706   // Called for every step in the Cosmic Ray Trigger
707   //
708
709
710   // volume: 
711   //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
712   //  [1] = Plastic number: 0 (down) to 1 (up)
713   static Int_t   vol[2]; 
714   //
715   // hit
716   // [0] = PID
717   // [1-3] = x, y, z 
718   // [4] = time 
719   // [5-7] = px, py, pz
720   // [8] = energy 
721   // [9] = energy loss
722   // [10] = length of track through plastic
723   static Float_t hits[11];
724
725   // local static variables
726   static Float_t eloss;
727   static Float_t step;
728   // scintillator volume
729  static Int_t idScint = gMC->VolId("ACORDESCINTILLATORMODULE");
730   // local variables
731   Int_t copy;
732   TLorentzVector pos;
733   TLorentzVector mom;
734
735   // only charged tracks
736   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
737
738   // only in sensitive material
739   if (gMC->CurrentVolID(copy) == idScint) {
740
741     step  += gMC->TrackStep();
742     eloss += gMC->Edep();
743     // set all hit variables except eloss which is resetted
744     // set volume variables
745     if (gMC->IsTrackEntering()) {
746       eloss = 0.0;
747       step = 0.0;
748       gMC->TrackPosition(pos);
749       gMC->TrackMomentum(mom);
750       // hit
751       // [0] = PID
752       // [1-3] = x, y, z 
753       // [4] = time 
754       // [5-7] = px, py, pz
755       // [8] = energy 
756       // [9] = energy loss
757       hits[0]  = (Float_t ) gMC->TrackPid(); 
758
759
760       hits[1] = pos[0]; 
761       hits[2] = pos[1]; 
762       hits[3] = pos[2]; 
763       hits[4] = gMC->TrackTime();
764       hits[5] = mom[0];
765       hits[6] = mom[1];
766       hits[7] = mom[2];
767       hits[8] = gMC->Etot();
768       // volume: 
769       //  [0] = module number 1-60 (1==>(0-0), 60 (5-9)
770       //  [1] = Plastic number: 0 (down) to 1 (up)
771       Int_t copyPlastic; // plastic: down=1, up=2
772       Int_t copyModule; // module: 1-60
773       gMC->CurrentVolID(copyPlastic);
774       gMC->CurrentVolOffID(1, copyModule);
775       // module
776       vol[0] = copyModule;
777       // plastic: 0 = down, 1 = up
778       vol[1] = copyPlastic - 4 ; // !!!!!!!
779     // vol[1] = copyPlastic;
780     } // end if gMC->IsTrackEntering()
781
782     // set hit[9] = total energy loss and book hit
783     if( gMC->IsTrackExiting() || 
784         gMC->IsTrackStop() || 
785         gMC->IsTrackDisappeared()){
786       hits[9] = eloss;
787       hits[10] = step;
788       eloss = 0.0;
789       step = 0.0;
790       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
791      }
792   } 
793
794
795
796 }
797
798 //_____________________________________________________________________________
799 void AliACORDEv1::AddHit(Int_t track, Int_t *vol, Float_t *hits)
800 {
801   //
802   // Add an ACORDE hit
803   //
804   TClonesArray &lhits = *fHits;
805   new(lhits[fNhits++]) AliACORDEhit(fIshunt,track,vol,hits);
806 }
807
808 //_____________________________________________________________________________
809 void AliACORDEv1::AddDigits(Int_t* track, Int_t module, Float_t time)
810 {
811   
812   // Adds Digit
813   
814   TClonesArray &ldigits = *fDigits;
815   new(ldigits[fNdigits++]) AliACORDEdigit(track,module,time);
816 }
817 //_____________________________________________________________________________
818
819 void AliACORDEv1::MakeBranch(Option_t *option)
820 {
821 // Creates new branches in the current Root Tree
822     
823   char branchname[10];
824   //sprintf(branchname,"%s",GetName());
825   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
826   const char *cH = strstr(option,"H");
827   if (fHits   && fLoader->TreeH() && cH) {
828     fLoader->TreeH()->Branch(branchname,&fHits, fBufferSize);
829     AliDebug(2,Form("Making Branch %s for hits",branchname));
830   }     
831   const char *cD = strstr(option,"D");
832   if (fDigits   && fLoader->TreeD() && cD) {
833     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
834     AliDebug(2,Form("Making Branch %s for digits",branchname));
835   }  
836 }
837
838 //_____________________________________________________________________________
839 void AliACORDEv1::AddAlignableVolumes() const
840 {
841   //
842   // Create entries for alignable volumes associating the symbolic volume
843   // name with the corresponding volume path. Needs to be syncronized with
844   // eventual changes in the geometry.
845   // 
846
847         // The alignable volumes are only the "ACORDE_MODULE_%d"
848         //
849         //      Structure of ACORDE's Geometry
850         //
851         //      ALIC_1
852         //          |---> ACORDE_1      
853         //                      |----> ALL_ACORDE_MODULES_1/ACORDE_MODULE_%d (d:0->to->59)
854         //                      |----> ACORDE_SUPPORT_BARS_2    |--> BARS&SUPPORTS
855         //
856         //     Send comments to: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
857
858         TString vpstr1 = "ALIC_1/ACORDE_1/ALL_ACORDE_MODULES_1/ACORDE_MODULE_";
859         TString snstr1 = "ACORDE/Array";
860         TString volpath, symname;
861         for(Int_t dy=0; dy<60 ; dy++)
862         {
863                 volpath = vpstr1;
864                 volpath += dy;
865                 symname = snstr1;
866                 symname += dy;
867                 if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
868                 AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
869         }
870 }