]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AD/ADsim/AliADv1.cxx
01cee2c244f4ff8b5c650fb6895fa2979f211725
[u/mrichter/AliRoot.git] / AD / ADsim / AliADv1.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: AliAD.cxx  $ */
17
18 ///////////////////////////////////////////////////////////////////////////
19 //                                                                       //
20 //                  AD (ALICE Diffractive)  Detector                     //
21 //                                                                       //
22 //  This class contains the base procedures for the AD  detector         //
23 //  Default geometry of 2013: 16 modules                                 //
24 //  All comments should be sent to :                                     //
25 //                                                                       //
26 //                                                                       //
27 ///////////////////////////////////////////////////////////////////////////
28
29 // --- Standard libraries ---
30 #include <Riostream.h>
31
32 // --- ROOT libraries ---
33 #include <TMath.h>
34 #include <TString.h>
35 #include <TVirtualMC.h>
36 #include <TGeoManager.h>
37 #include <TGeoMatrix.h>
38 #include <TGeoTube.h>
39 #include <TGeoPcon.h>
40 #include <TGeoCone.h>
41 #include <TGeoShape.h>
42 #include <TGeoXtru.h>
43 #include <TTree.h>
44 #include <TSystem.h>
45 // #include <TGeoCompositeShape.h> // included in .h
46 #include <TGeoGlobalMagField.h>
47 #include <TGeoMaterial.h>
48 #include <TGeoMedium.h>
49 #include <TGeoVolume.h>
50 #include <TGeoArb8.h>
51 #include <TClonesArray.h>
52 #include <TGeoTrd2.h>
53 #include <TParticle.h>
54
55 #include <TH2F.h>
56 #include <TCanvas.h>
57
58 // --- AliRoot header files ---
59
60
61 #include "AliADhit.h"
62 #include "AliADdigit.h"
63 #include "AliADv1.h"
64 #include "AliLog.h"
65 #include "AliConst.h"
66 #include "AliMagF.h"
67 #include "AliRun.h"
68 #include "AliMC.h"
69
70
71 ClassImp(AliADv1)
72 //__________________________________________________________________
73 AliADv1::AliADv1() : 
74   AliAD(),
75   fADCstruct(kTRUE),
76   fADCPosition(kADCInTunnel),
77   fADCLightYield(93.75),
78   fADCPhotoCathodeEfficiency(0.18),
79   fADALightYield(93.75),
80   fADAPhotoCathodeEfficiency(0.18)
81 {
82    // Default Constructor
83     fHits = 0;
84 }
85
86 //_____________________________________________________________________________
87 AliADv1::AliADv1(const char *name, const char *title) : 
88   AliAD(name,title),  
89   fADCstruct(kTRUE),
90   fADCPosition(kADCInTunnel),
91   fADCLightYield(93.75),
92   fADCPhotoCathodeEfficiency(0.18),
93   fADALightYield(93.75),
94   fADAPhotoCathodeEfficiency(0.18)
95 {
96    // Standard constructor for AD Detector
97   
98    AliModule* pipe = gAlice->GetModule("PIPE");
99    if( (!pipe) ) {
100       Error("Constructor","AD needs PIPE!!!\n");
101       exit(1);
102    } 
103    fHits = new TClonesArray("AliADhit",400);
104    gAlice->GetMCApp()->AddHitList(fHits);
105 }
106
107 //_____________________________________________________________________________
108 AliADv1::~AliADv1()
109 {
110         // default destructor
111 }
112 //_____________________________________________________________________________
113 void AliADv1::Init()
114 {
115   // Initialise L3 magnet after it has been built
116   Int_t i;
117   if(AliLog::GetGlobalDebugLevel()>0) {
118     printf("\n%s: ",ClassName());
119     for(i=0;i<35;i++) printf("*");
120     printf(" ADv1_INIT ");
121     for(i=0;i<35;i++) printf("*");
122     printf("\n%s: ",ClassName());
123     for(i=0;i<80;i++) printf("*");
124     printf("\n");
125   }
126 }
127
128 //_____________________________________________________________________________
129 void AliADv1::CreateGeometry()
130 {
131   //
132   // Create the geometry for the AD arrays
133   //
134   CreateAD();
135   
136 }
137 //_____________________________________________________________________________
138 void AliADv1::ReadADCFromEnv() {
139   if (! gSystem->Getenv("CONFIG_ADC_POS"))
140     return;
141
142   TString str(gSystem->Getenv("CONFIG_ADC_POS"));
143
144   if (0==str.CompareTo ("kADCInTunnel")) {
145     fADCPosition = kADCInTunnel;
146     printf("fADCPosition set to kADCInTunnel\n");
147     //
148   } else if (0==str.CompareTo ("kADCInCavern")) {
149     fADCPosition = kADCInCavern;
150     printf("fADCPosition set to kADCInCavern\n");
151     //
152   } else if (0==str.CompareTo ("kADCInBoth")) {
153     fADCPosition = kADCInBoth;
154     printf("fADCPosition set to kADCInBoth\n");
155   }
156 }
157 //_____________________________________________________________________________
158 TGeoCompositeShape * AliADv1::MakeShapeADCpadH(const Double_t W, const Double_t H, const Double_t dz) {
159   /////////////////////////////////////////////////////////////////////////////
160   ///                ADC pad in the cavern (H shapped hole)                 ///
161   /////////////////////////////////////////////////////////////////////////////
162   // const Double_t W = kADCCellSide; // Width  of Scintillator pad
163   // const Double_t H = kADCCellSide; // Height of Scintillator pad
164   // Coordinates of ADC pad vertexes
165   Double_t pad0_x [] = { 10., 10.,   W,  W  };
166   Double_t pad0_y [] = {  0., 11., 11.,  0. };
167   Double_t pad1_x [] = { 15., 15.,   W,  W  };
168   Double_t pad1_y [] = { 11., 15., 15., 11. };
169   Double_t pad2_x [] = {  0.,  0.,   W,  W  };
170   Double_t pad2_y [] = { 15.,  H ,   H, 15. };
171   TGeoArb8 * shADCpad0H = new TGeoArb8("shADCpad0H", dz/2.);
172   TGeoArb8 * shADCpad1H = new TGeoArb8("shADCpad1H", dz/2.);
173   TGeoArb8 * shADCpad2H = new TGeoArb8("shADCpad2H", dz/2.);
174   for (Int_t i=0; i<4; i++) {
175     // -dz
176     shADCpad0H -> SetVertex(i,   pad0_x[i], pad0_y[i]);
177     shADCpad1H -> SetVertex(i,   pad1_x[i], pad1_y[i]);
178     shADCpad2H -> SetVertex(i,   pad2_x[i], pad2_y[i]);
179     // +dz
180     shADCpad0H -> SetVertex(i+4, pad0_x[i], pad0_y[i]);
181     shADCpad1H -> SetVertex(i+4, pad1_x[i], pad1_y[i]);
182     shADCpad2H -> SetVertex(i+4, pad2_x[i], pad2_y[i]);
183   }
184   return new TGeoCompositeShape("shADCpadH","shADCpad0H + shADCpad1H + shADCpad2H");
185 }
186
187 //_____________________________________________________________________________
188 void AliADv1::CreateAD()
189 {
190   printf("===> AliADv1::CreateAD(): ver=[Feb 3st, 2015]; contact=[ecalvovi@cern.ch]\n");
191   //
192   // Define Rotations used
193   //
194   TGeoRotation * Rx180, * Rz180, * Ry180, * Rx90, * Rx90m, * Ry90m;
195   Rx90m = new TGeoRotation("Rx90m",   0., -90.,   0.) ;
196   Rx90  = new TGeoRotation("Rx90" ,   0.,  90.,   0.) ;
197   Rx180 = new TGeoRotation("Rx180",   0., 180.,   0.) ;  //   4    |   1
198   Rz180 = new TGeoRotation("Rz180", 180.,   0.,   0.) ;  // --------------->  x  
199   Ry180 = new TGeoRotation("Ry180", 180., 180.,   0.) ;  //   3    |   2
200   Ry90m = new TGeoRotation("Ry90m",  90., -90., -90.) ;
201   // Get Mediums needed.
202   TGeoMedium * kMedAlu       = gGeoManager->GetMedium("AD_Alum");   // Aluminium 
203   TGeoMedium * kMedSteelSh   = gGeoManager->GetMedium("AD_ST_C0");  // Stainless Steel 
204   TGeoMedium * kMedVacuum    = gGeoManager->GetMedium("AD_VA_C0");  // Stainless Steel 
205   //
206   // Private comunication by Arturo Tauro (2014, Apr 23)
207   // According to last survey measurement done this morning, 
208   // the C-side wall is at Z = - 18959mm.
209   //
210   const Double_t kZwall        = 1895.9 ;  // Aluminium plate z position 
211   const Double_t kZendAbs      = 1880.75;  // End of CC block absorber
212   const Double_t kZbegVMAOI    = 1919.2 ;  // Begining of Warm Module
213   const Double_t kZbegValve    = 1910.7 ;  // Begining of Valve
214   const Double_t kZbegFrontBar = 1949.1 ;  // Begining of Front Bar
215   const Double_t kZbegCoil     = 1959.4 ;  // Begining of compensator coil
216
217   // Define Ion Pump ??
218   // Drawing LHCVBU__0052
219   // Vacuum - Bellows - U type
220   // BODY 1 PORTS
221   //
222   (new TGeoCombiTrans("ctPumpVB2", 0., -13./2., 6.8-11.5/2., Rx90))->RegisterYourself();
223   new TGeoTube("shIonPumpVB1o",  0.0, 10.3 /2., 11.5/2.   );
224   new TGeoTube("shIonPumpVB2o",  0.0,  7.0 /2., 13.0/2.   );
225   new TGeoTube("shIonPumpVB1i",  0.0, 10.0 /2., 11.5/2.+2.);
226   new TGeoTube("shIonPumpVB2i",  0.0,  6.7 /2., 13.0/2.+2.);
227   new TGeoCompositeShape("shIonPumpVBo", "shIonPumpVB1o+shIonPumpVB2o:ctPumpVB2");
228   //
229   // Continue definition of LHCVBU__0052
230   //
231   new TGeoCompositeShape("shIonPumpVBi", "shIonPumpVB1i+shIonPumpVB2i:ctPumpVB2");
232   TGeoShape * sh3 = new TGeoCompositeShape("shIonPumpVB",  "shIonPumpVBo-shIonPumpVBi");
233   TGeoVolume * voIonPumpVB = new TGeoVolume("voIonPumpVB", sh3, kMedAlu);
234   // Variables 
235   Double_t alpha, beta, tga2, tga, sa, ca, ctgb, d, Ro, Ri, phi1, dphi, H, L, z;
236   // Drawing: LHCVSR__0054
237   // Vacuum Screen - RF
238   // transition flange
239   alpha = 15. * TMath::DegToRad();
240   beta  = 15. * TMath::DegToRad();
241   tga2  = TMath::Tan(alpha*0.5);
242   tga   = TMath::Tan(alpha);
243   ctgb  = 1./TMath::Tan(beta );
244   ca    = TMath::Cos(alpha    );
245   d     = 0.3; // thickness of transition flange
246   Double_t h = d/ca; // vertical distance between parallel surfaces tilted alpha degrees
247   TGeoPcon * shVSRflange = new TGeoPcon("shVSRflange", 0.0, 360.0, 7);
248   Ri = 9.71/2.; Ro = 11.16/2.;
249   shVSRflange->DefineSection(0,         0.  ,   Ri, Ro);
250   Ri = Ri - 0.25 * tga;
251   shVSRflange->DefineSection(1,         0.25,   Ri, Ro);
252   Ro = Ri + d*tga;
253   shVSRflange->DefineSection(2,         0.25,   Ri, Ro);
254   Ri = 6.3/2.; Ro = Ri + h;
255   z = (9.71/2. - Ri) / tga;
256   shVSRflange->DefineSection(3,            z,   Ri, Ro);
257   // 
258   Double_t   Dtga = 6.6*tga - 0.5*(9.71-6.3)    ;
259   Double_t x = (h - 0.11 - Dtga) / (ctgb - tga) ;
260   Double_t y = x * ctgb;
261   z  = 6.6 - x;
262   Ro = Ri + 0.11 + y;
263   shVSRflange->DefineSection(4,            z,   Ri, Ro);
264   z  = 6.6; 
265   Ro = Ri + 0.11;
266   shVSRflange->DefineSection(5,            z,   Ri, Ro);
267   z  = 7.1; 
268   shVSRflange->DefineSection(6,            z,   Ri, Ro);
269   TGeoVolume * voVSRflange = new TGeoVolume("voVSRflange", shVSRflange, kMedAlu);
270   //
271   // Drawing: LHCVSR__0053
272   // Vacuum Screen - RF
273   // transition tube
274   alpha = 10. * TMath::DegToRad();
275   tga2  = TMath::Tan(alpha*0.5);
276   tga   = TMath::Tan(alpha);
277   ca    = TMath::Cos(alpha    );
278   d     = 0.3; // thickness of Vacuum Screen RF
279   Ro    = 6.7/2.; //
280   Ri    = 0.;
281   phi1  = 90. - 15.;
282   dphi  = 30.;
283   TGeoPcon * shVSR0 = new TGeoPcon("shVSR0", phi1, dphi, 6);
284   shVSR0->DefineSection(0,         0.  ,   Ro-0.09, Ro);
285   shVSR0->DefineSection(1,         0.45,   Ro-0.09, Ro);
286   Ri=Ro-d;
287   shVSR0->DefineSection(2,         0.45,      Ri, Ro);
288   shVSR0->DefineSection(3, 13.37-d*tga2,      Ri, Ro);
289   Ro  = Ri + d/ca;
290   shVSR0->DefineSection(4,        13.37,      Ri, Ro);
291   Ri += 0.63*tga;
292   Ro  = Ri + d/ca;
293   shVSR0->DefineSection(5,        14.0 ,      Ri, Ro);
294   // printf("  Ro: %8.2f\n", Ro);
295   // Make holes 
296   new TGeoBBox("shHoleBody"    , 0.15, 0.60, 0.3);
297   new TGeoTube("shHoleEnd", 0.  , 0.15, 0.3);
298   (new TGeoTranslation("trHoleBody", 0., -0.6, 0.))->RegisterYourself();
299   (new TGeoTranslation("trHoleEnd" , 0., -1.2, 0.))->RegisterYourself();
300   new TGeoCompositeShape("shHole","shHoleEnd + shHoleEnd:trHoleEnd + shHoleBody:trHoleBody");
301   // Single hole made. Now define some combitrans to position holes
302   z = 1.3; Ro = (6.7 - d)*0.5;
303   (new TGeoCombiTrans("ctHole1", 0., Ro , z, Rx90m))->RegisterYourself();
304   z = 1.3 + 1*2.5;
305   (new TGeoCombiTrans("ctHole2", 0., Ro , z, Rx90m))->RegisterYourself();
306   z = 1.3 + 2*2.5;
307   (new TGeoCombiTrans("ctHole3", 0., Ro , z, Rx90m))->RegisterYourself();
308   z = 1.3 + 3*2.5;
309   (new TGeoCombiTrans("ctHole4", 0., Ro , z, Rx90m))->RegisterYourself();
310   // Now make a sector of RF transition tube
311   new TGeoCompositeShape("shVSRsec",
312    "shVSR0 - (shHole:ctHole1 + shHole:ctHole2 + shHole:ctHole3 + shHole:ctHole4)");
313   // Now define rotations for each sector
314   TString strSh = "shVSRsec ";
315   for (Int_t i=1; i<=11; i++) {
316    (new TGeoRotation(Form("rSec%d",i), 30. * i, 0. , 0.))->RegisterYourself();
317    strSh+=Form("+ shVSRsec:rSec%d",i);
318   }
319   // printf("%s\n", strSh.Data());
320   TGeoCompositeShape * shVSR = new TGeoCompositeShape("shVSR", strSh.Data());
321   // Now assembly the sector to form VSR RF transition tube !
322   TGeoVolume * voVSR = new TGeoVolume("voVSR", shVSR, kMedAlu);
323   // 
324   // Drawing: LHCVSR__0057
325   // RF CONTACT
326   // 
327   Ro = 0.5 * 6.3;
328   d  = 0.03;
329   Ri = Ro - d;
330   // alpha = TMath::ArcSin((7.35-1.75)/Ri);  <-- No!
331   H = 0.5 * 6.9 - Ri;
332   L = 28. - 7.1 + 0.45 -14. - 1.75;//7.35 - 1.75;
333   // Double_t Delta = TMath::Sqrt( L*L + 4.*(H-d)*H );
334   Double_t R = TMath::Sqrt((H-d)*(H-d) + L*L);
335   alpha = TMath::ASin(d/R) + TMath::ASin((H-d)/R);
336   //printf("alpha: %8.2f \n", alpha * TMath::RadToDeg());
337   sa = TMath::Sin(alpha);
338   ca = TMath::Cos(alpha);
339   x = d*sa;
340   y = d*ca;
341   Double_t R0 =  1.75;
342   Double_t R1 = 10.48;
343   Double_t R2 =  0.81 + 0.28;
344   phi1 = 0.; dphi = 360.; 
345
346   TGeoPcon * shVSRcontact = new TGeoPcon("shVSRcont", phi1, dphi, 6);
347   z = 0.;
348   shVSRcontact->DefineSection(0, -z, Ri, Ro);
349   z = R0;
350   shVSRcontact->DefineSection(1, -z, Ri, Ro);
351   z  += x;
352   Ri += y;
353   Ro  = Ri + d;
354   shVSRcontact->DefineSection(2, -z, Ri, Ro);
355   z  += (R1 - R0) * ca;
356   Ri += (R1 - R0) * sa;
357   Ro  = Ri + d;
358   shVSRcontact->DefineSection(3, -z, Ri, Ro);
359   // Last sections (R2)
360   Double_t ab = alpha + 21. * TMath::DegToRad();
361   Double_t sab = TMath::Sin(ab);
362   Double_t cab = TMath::Cos(ab);
363   x   = d * sab;
364   y   = d/ca - d*cab;
365   z  += x;
366   Ri += y;
367   Ro  = Ri + d/cab;
368   shVSRcontact->DefineSection(4, -z, Ri, Ro);
369   z  += R2 * cab;
370   Ri += R2 * sab;
371   Ro  = Ri + d/cab;
372   shVSRcontact->DefineSection(5, -z, Ri, Ro);
373   TGeoVolume * voVSRcontD = new TGeoVolume("voVSRcontD", shVSRcontact, kMedAlu);
374   // Drawing: LHCVSR__0017
375   // Vacuum Screen - RF
376   // RF Contact flange
377   phi1 = 0.;
378   dphi = 360.;
379
380   TGeoPcon * shVSRcontFlange = new TGeoPcon("shVSRcontFlange", phi1, dphi, 11);
381   Ri = 6.30 /2.; Ro = 11.16 /2.; z = 0;
382   shVSRcontFlange->DefineSection( 0, -z, Ri, Ro);
383   Ri = 6.30 /2.; Ro = 11.16 /2.; z = 0.1;
384   shVSRcontFlange->DefineSection( 1, -z, Ri, Ro);
385   Ri = 6.36 /2.; Ro = 11.16 /2.; z = 0.1;
386   shVSRcontFlange->DefineSection( 2, -z, Ri, Ro);
387   Ri = 6.36 /2.; Ro = 11.16 /2.; z = 0.25;
388   shVSRcontFlange->DefineSection( 3, -z, Ri, Ro);
389   Ri = 6.36 /2.; Ro =  9.30 /2.; z = 0.25;
390   shVSRcontFlange->DefineSection( 4, -z, Ri, Ro);
391   Ri = 6.36 /2.; Ro =  9.30 /2.; z = 0.30;
392   shVSRcontFlange->DefineSection( 5, -z, Ri, Ro);
393   Ri = 6.36 /2.; Ro =  6.90 /2.; z = 0.30;
394   shVSRcontFlange->DefineSection( 6, -z, Ri, Ro);
395   Ri = 6.36 /2.; Ro =  6.90 /2.; z = 1.10;
396   shVSRcontFlange->DefineSection( 7, -z, Ri, Ro);
397   Ri = 6.36 /2.; Ro =  6.85 /2.; z = 1.15;
398   shVSRcontFlange->DefineSection( 8, -z, Ri, Ro);
399   Ri = 6.36 /2.; Ro =  6.50 /2.; z = 1.15;
400   shVSRcontFlange->DefineSection( 9, -z, Ri, Ro);
401   Ri = 6.36 /2.; Ro =  6.50 /2.; z = 1.30;
402   shVSRcontFlange->DefineSection(10, -z, Ri, Ro);
403   TGeoVolume * voVSRcontF = new TGeoVolume("voVSRcontF", shVSRcontFlange, kMedAlu);
404   // Drawing: LHCVBU__0002
405   // Bellows + End Parts
406   // Vacuum - Bellows - U type
407
408   // First make end part
409   phi1 = 0. ; dphi = 360. ;
410   TGeoPcon * shVBUend = new TGeoPcon("shVBUend", phi1, dphi, 6);
411   Ri = 5.176; Ro = 5.4; z = 0;
412   shVBUend->DefineSection( 0, z, Ri, Ro);
413   Double_t dz  = 0.03;
414   Ri -= dz * TMath::Tan(45. * TMath::DegToRad());
415   z  += dz;
416   shVBUend->DefineSection( 1, z, Ri, Ro);
417   dz  = 0.04;
418   Ro -= dz * TMath::Tan(15. * TMath::DegToRad());
419   Ri -= dz * TMath::Tan(45. * TMath::DegToRad());
420   z  += dz;
421   shVBUend->DefineSection( 2, z, Ri, Ro);
422   Ro  = 5.250 ;
423   Ri  = 5.073;
424   z   = 0.103;
425   shVBUend->DefineSection( 3, z, Ri, Ro);
426   Ro  = 5.25;
427   Ri  = 5.02;
428   z   = 0.18;
429   shVBUend->DefineSection( 4, z, Ri, Ro);
430   Ro  = 5.15;
431   Ri  = 5.00;
432   z   = 0.28;
433   shVBUend->DefineSection( 5, z, Ri, Ro);
434
435   TGeoPcon * shVBUtube26mm = new TGeoPcon("shVBUtube26mm", 0., 360., 2);
436   shVBUtube26mm->DefineSection( 0, 0.28, 5.0, 5.15);
437   shVBUtube26mm->DefineSection( 1, 2.60, 5.0, 5.15);
438   TGeoPcon * shVBUtube9mm  = new TGeoPcon("shVBUtube9mm" , 0., 360., 2);
439   shVBUtube9mm ->DefineSection( 0, 0.00, 5.0, 5.15);
440   shVBUtube9mm ->DefineSection( 1, 0.62, 5.0, 5.15);
441   // central part of bellow (TODO: Add plies)
442   TGeoPcon * shVBUcent  = new TGeoPcon("shVBUcent" , 0., 360., 6);
443   const Int_t nsec = 6;
444   Double_t az [nsec] = {0.9, 0.915, 0.915, 11.885, 11.885, 11.9};
445   Double_t aRi[nsec] = {5.0, 5.0  , 5.685,  5.685,  5.0  ,  5.0};
446   for (Int_t i=0; i<nsec; i++) {
447    z=az[i]; Ri = aRi[i]; Ro = 5.7;
448    //printf("  i: %2d  z: %8.2f  Ri: %8.2f  Ro: %8.2f\n", i, z, Ri, Ro );
449    shVBUcent ->DefineSection( i, z, Ri, Ro);
450   }
451
452   ( new TGeoCombiTrans("ctEnd9mm", 0., 0., 0.9, Ry180)) -> RegisterYourself();
453
454   TGeoCompositeShape * shVBU9mm  = new TGeoCompositeShape("shVBU9mm" , "shVBUend:ctEnd9mm + shVBUtube9mm");
455   TGeoCompositeShape * shVBU26mm = new TGeoCompositeShape("shVBU26mm", "shVBUend + shVBUtube26mm");
456
457   const Int_t nsec2 = 10;
458   Double_t az2 [nsec2] = {0.  , 0.43, 0.43, 0.58, 0.58 , 0.73 , 0.73, 1.05, 1.05, 1.31} ;
459   Double_t aRi2[nsec2] = {5.15, 5.15, 5.03, 5.03, 5.455, 5.455, 5.03, 5.03, 5.59, 5.59} ;
460   TGeoPcon * shVBUrotFlg  = new TGeoPcon("shVBUrotFlg" , 0., 360., nsec2);
461   for (Int_t i=0; i<nsec2; i++) {
462    z=az2[i]; Ri = aRi2[i]; Ro = 6.02;
463    //printf("  i: %2d  z: %8.2f  Ri: %8.2f  Ro: %8.2f\n", i, z, Ri, Ro );
464    shVBUrotFlg ->DefineSection( i, z, Ri, Ro);
465   }
466   TGeoVolume * voVBUrotFlg = new TGeoVolume("voVBUrotFlg", shVBUrotFlg, kMedAlu);
467
468   // Flange 
469   TGeoPcon * shVBUflg  = new TGeoPcon("shVBUflg" , 0., 360., 4);
470   z  = 0; 
471   Ri = 6.02; Ro = 7.6; 
472   shVBUflg->DefineSection(0, z, Ri, Ro);
473   z  = 1.31; 
474   shVBUflg->DefineSection(1, z, Ri, Ro);
475   z  = 1.31; 
476   Ri = 5.15; 
477   shVBUflg->DefineSection(2, z, Ri, Ro);
478   z  = 2.0;
479   shVBUflg->DefineSection(3, z, Ri, Ro);
480   TGeoVolume * voVBUflg = new TGeoVolume("voVBUflg", shVBUflg, kMedAlu);
481
482    
483   // Add the metal plate at the end of Absorber
484   // Plate:  80 cm x 80 cm x 1.95 cm (Thickness is aproximatted) (ernesto.calvo@pucp.edu.pe)
485   // The End of the concrete abosorber is at kZendAbs = 1880.75
486
487   new TGeoBBox("shBasePlate", 80./2., 80./2.,  1.95/2.);
488   new TGeoTube("shHolePlate",  0.   , 12.3  ,  1.95   );
489   TGeoVolume* voSaa3EndPlate  =  new TGeoVolume("voYSaa3EndPlate",
490       new TGeoCompositeShape("shYSaa3EndPlate","shBasePlate-shHolePlate"),
491       kMedSteelSh);
492   //
493   // Add Rods
494   //
495   // dimensions of rods
496   const Double_t dzRodL = 27.0;
497   const Double_t dzRodA =  4.3;
498   const Double_t dzRodB =  1.3;
499   new TGeoTube("shLargeRod", 0.,   1.6/2.,  dzRodL/2.);
500   new TGeoTube("shRodA",     0.,   3.0/2.,  dzRodA/2.);
501   new TGeoTube("shRodB",     0.,   2.3/2.,  dzRodB/2.);
502   //
503   ( new TGeoTranslation("trRod1", 0., 0., -dzRodL/2. + dzRodA/2.)          )->RegisterYourself();
504   ( new TGeoTranslation("trRod2", 0., 0., -dzRodL/2. + dzRodA + dzRodB/2.) )->RegisterYourself();
505   ( new TGeoTranslation("trRod3", 0., 0.,  dzRodL/2. - dzRodB/2.)          )->RegisterYourself();
506   TGeoVolume * voSaa3Rod = new TGeoVolume("YSAA3Rod",
507       new TGeoCompositeShape("shLargeRod+shRodA:trRod1 + shRodB:trRod2 + shRodB:trRod3"),
508       kMedSteelSh);
509   //
510   // Define Valve support (VS)  (ernesto.calvo@pucp.edu.pe) 
511   //
512   const Double_t dyVS =  5.5; 
513   const Double_t dxVS = 30.0; 
514   const Double_t dzVS =  1.0;
515   TGeoVolume * voVS = new TGeoVolume("voVS",
516       new TGeoBBox("shVS", dxVS/2., dyVS/2., dzVS/2.),
517       kMedSteelSh);
518
519   // Add Valve (Valve is divided in parts VA,VB,VC and VD)  (ernesto.calvo@pucp.edu.pe) 
520   TGeoVolumeAssembly * voValve = new TGeoVolumeAssembly("voValve");
521   //
522   // Define volume VA  (ernesto.calvo@pucp.edu.pe) 
523   const Double_t dxVA  = 20.3; 
524   const Double_t dyVA  = 48.0; 
525   const Double_t dzVA  =  6.0; // Width 
526   const Double_t dz2VA =  8.5; // Full width including protuding boxes
527   // Valve position  (ernesto.calvo@pucp.edu.pe) 
528   const Double_t zPosValve =  kZbegValve + dz2VA/2.;
529   //
530   new TGeoBBox("shVAbox",       dxVA/2., dyVA/2.,     dzVA/2.);
531   new TGeoBBox("shVAHbox",  -1.+dxVA/2.,   3./2.,    dz2VA/2.);
532   new TGeoTube("shVAC",              0.,     7.9,    dz2VA/2.);
533   new TGeoTube("shVACh",             0.,     5.3,    dz2VA   );
534   // translation for shVAHbox (ernesto.calvo@pucp.edu.pe) 
535   ( new TGeoTranslation("trVAH1", 0.,  12.75, 0.) )->RegisterYourself();
536   ( new TGeoTranslation("trVAH2", 0., -12.75, 0.) )->RegisterYourself();
537
538   TGeoVolume * voValveVA = new TGeoVolume("voValveVA",
539       new TGeoCompositeShape("(shVAbox + shVAHbox:trVAH1 + shVAHbox:trVAH2 + shVAC)-shVACh"),
540       kMedSteelSh);
541   voValve->AddNode(voValveVA, 1, 0);
542   // Define Vacuum Hole of Valve
543   TGeoTube   * shVACvach   = new TGeoTube("shVACvach", 0., 5.3, dz2VA/2.);
544   TGeoVolume * voValveVAvh = new TGeoVolume("voValveVAvacuum", shVACvach, kMedVacuum);
545   voValve->AddNode(voValveVAvh,1,0);
546   // Also add valve Support (ernesto.calvo@pucp.edu.pe) 
547   voValve->AddNode(voVS, 1, new TGeoTranslation(0.,  12.75, -dz2VA/2.-dzVS/2.));
548   voValve->AddNode(voVS, 2, new TGeoTranslation(0., -12.75, -dz2VA/2.-dzVS/2.));
549
550   // Define Volume VB (ernesto.calvo@pucp.edu.pe) 
551   const Double_t dxVB = 23.5; 
552   const Double_t dyVB =  5.0; 
553   const Double_t dzVB =  9.4; 
554   TGeoVolume * voValveVB = new TGeoVolume("voValveVB", 
555       new TGeoBBox("shVBbox", dxVB/2., dyVB/2., dzVB/2.),
556       kMedSteelSh);
557   voValve->AddNode(voValveVB, 1, new TGeoTranslation(  0., dyVA/2. +dyVB/2. , 0));
558   // Define Volume VC (ernesto.calvo@pucp.edu.pe) 
559   const Double_t R1VC  =  4.5 /2.;
560   const Double_t R2VC  =  8.1 /2.;
561   const Double_t dy1VC  = 10.0;
562   const Double_t dy2VC =  0.75;
563   new TGeoTube("shVC1",      0.,   R1VC, dy1VC/2.);
564   new TGeoTube("shVC2",      0.,   R2VC, dy2VC/2.);
565   ( new TGeoTranslation("trVC21", 0., 0.,  dy1VC/2. - dy2VC/2.) )->RegisterYourself();
566   ( new TGeoTranslation("trVC22", 0., 0., -dy1VC/2. + dy2VC/2.) )->RegisterYourself();
567   TGeoVolume * voValveVC = new TGeoVolume("voValveVC",
568       new TGeoCompositeShape("shVC1  + shVC2:trVC21 + shVC2:trVC22"),
569       kMedSteelSh);
570   voValve->AddNode(voValveVC, 1, new TGeoCombiTrans( 
571         0., dyVA/2. + dyVB + dy1VC/2. , 0, Rx90) );
572   // Define volume VD (ernesto.calvo@pucp.edu.pe) 
573   const Double_t dxVD = 15.9;
574   const Double_t dyVD = 23.0;
575   const Double_t dzVD = 14.0;
576   TGeoVolume * voValveVD = new TGeoVolume("voValveVD",
577       new TGeoBBox("shVD", dxVD/2., dyVD/2., dzVD/2.),
578       kMedSteelSh);
579   voValve->AddNode(voValveVD, 1, 
580       new TGeoTranslation( 1.25, dyVA/2. + dyVB + dy1VC + dyVD/2. , 0) );
581
582   //
583   // Define volume Front Bar (ernesto.calvo@pucp.edu.pe) 
584   //
585   const Double_t dxF  = 67.4; 
586   const Double_t dyF  =  4.0; 
587   const Double_t dzF  =  2.0; 
588   const Double_t R1FC =  8.1;
589   const Double_t R2FC = 11.5;
590   const Double_t dxFA  = (dxF-R1FC)/2.; 
591  
592   new TGeoBBox("shFA", dxFA/2., dyF/2., dzF/2.);
593   new TGeoTube("shFC",      0.,   R2FC, dzF/2.);
594   new TGeoTube("shFCH",     0.,   R1FC, 2.*dzF);
595   ( new TGeoTranslation("trFA1",  R1FC +dxFA/2., 0., 0.) )->RegisterYourself();
596   ( new TGeoTranslation("trFA2", -R1FC -dxFA/2., 0., 0.) )->RegisterYourself();
597   TGeoVolume * voFrontBar = new TGeoVolume("voFrontBar",
598       new TGeoCompositeShape("shFA:trFA1 + shFA:trFA2 + (shFC - shFCH)"),
599       kMedSteelSh);
600   // Make Lateral Bars
601   const Double_t kdzLatBar = 22.9;
602   TGeoVolume * voLatBar = new TGeoVolume("voLatBar", 
603     new TGeoTube("shLatBar",0., dyF/2., kdzLatBar/2.), kMedSteelSh);
604   //
605   // Define Compensator Magnet coils
606   //
607   dz = 12.5;
608   Ro = 15.0;
609   Ri = 1.9;
610   new TGeoTubeSeg("shCoilRo", 0., Ro, dz/2., 90., 180.);
611   new TGeoTubeSeg("shCoilRi", 0., Ri, dz   , 90., 185.);
612   (new TGeoTranslation("trCoilRo", Ro, 10.4, 0.)) -> RegisterYourself();
613   (new TGeoTranslation("trCoilRi", Ro,  9.6, 0.)) -> RegisterYourself();
614   new TGeoBBox("shBoxCoilRo", 15.0/2., 10.4/2., dz/2.);
615   new TGeoBBox("shBoxCoilRi",  1.9/2.,  9.6   , dz   );
616   (new TGeoTranslation("trBoxCoilRo",       15.0/2., 10.4/2., 0.)) -> RegisterYourself();
617   (new TGeoTranslation("trBoxCoilRi", 13.1 + 1.9/2.,  0.    , 0.)) -> RegisterYourself();
618   new TGeoBBox("shBoxCoil0", 10./2., 30., dz);
619   (new TGeoTranslation("trBoxCoil0",  14.6 + 10./2.,  0.    , 0.)) -> RegisterYourself();
620   strSh  = "";
621   strSh += "(shCoilRo:trCoilRo + shBoxCoilRo:trBoxCoilRo) - ";
622   strSh += "(shCoilRi:trCoilRi + shBoxCoilRi:trBoxCoilRi +"  ;
623   strSh += " shBoxCoil0:trBoxCoil0 )"  ;
624   TGeoCompositeShape * shCoil = new TGeoCompositeShape("shCoil0", strSh);
625   TGeoVolume * voCoil = new TGeoVolume("voCoil", shCoil, kMedSteelSh);
626
627   // 
628   // ALUMINIUM PLATES 
629   //
630
631   // Shape for aluminium Plate separating cavern and LHC tunnel
632   const Double_t dAlWallThick = 0.5; // thickness of aluminium plates (cm)
633   //
634   // RB24/26 Tunnel Floor 
635   R   = 220.;
636   // h   = 140.;
637   // phi = TMath::ACos(h / r);
638   // xl  = r * TMath::Sin(phi);
639   // dr  = 1600.;
640   // dh  = dr * TMath::Cos(phi);
641   // dl  = dr * TMath::Sin(phi);
642
643   new TGeoTube("shWallBase",    0.,    R, dAlWallThick*0.5);  // base shape for shWallBigPlate
644   new TGeoBBox("shWallCutBot",270., 110., dAlWallThick    );  // to be substracted from base
645   // Translation for cutting circular and square hole in the plates
646   (new TGeoTranslation("trAntiBeamAxis",   -70.,               40., 0.)) -> RegisterYourself();
647   (new TGeoTranslation("trHUWAT3",         -70., -110. - 140. +40., 0.)) -> RegisterYourself();
648
649   //
650   //  Wall Big Aluminium Plate with Squared Hole 
651   //
652   const Double_t dSqrHoleSide = 33.0; // Side
653   new TGeoBBox("shWallSqrHole", dSqrHoleSide*0.5, dSqrHoleSide*0.5, dAlWallThick);
654   strSh  = ""; 
655   strSh += "shWallBase:trAntiBeamAxis - ";
656   strSh += " ( shWallCutBot:trHUWAT3" ;
657   strSh += " + shWallSqrHole )";
658   TGeoVolume* voWallBigPlate = new TGeoVolume("voWallBigPlate", 
659     new TGeoCompositeShape("shWallBigPlate", strSh), kMedAlu );
660   //
661   // Wall Squared Aluminium Plate 
662   //
663   const Double_t dCircHoleRad = 9.5; // Radius
664   new TGeoTube("shCircHole", 0., dCircHoleRad, dAlWallThick);
665   // Make holes for bars
666   new TGeoTube("shRodHole", 0.,   1.7/2.,  2*dAlWallThick);
667   ( new TGeoTranslation("trWallRod1",  12.5, -12.75, 0.)) -> RegisterYourself();
668   ( new TGeoTranslation("trWallRod2",  12.5,  12.75, 0.)) -> RegisterYourself();
669   ( new TGeoTranslation("trWallRod3", -12.5, -12.75, 0.)) -> RegisterYourself();
670   ( new TGeoTranslation("trWallRod4", -12.5,  12.75, 0.)) -> RegisterYourself();
671   new TGeoBBox("shWallSqrPlateBase", dSqrHoleSide*0.5 + 5.0, dSqrHoleSide*0.5 + 5.0, dAlWallThick/2.);
672   strSh  = " ((((";
673   strSh += " ( shWallSqrPlateBase - shCircHole )"; 
674   strSh += " - shRodHole:trWallRod1)"  ;
675   strSh += " - shRodHole:trWallRod2)"  ;
676   strSh += " - shRodHole:trWallRod3)"  ;
677   strSh += " - shRodHole:trWallRod4)"  ;
678   TGeoVolume* voWallSqrPlate = new TGeoVolume("HUWAT_AlWall02", 
679     new TGeoCompositeShape("shWallSqrPlate", strSh ), kMedAlu);
680   // ==========================================================================
681   //
682   // Define Mother Vacuum volume of VMAOI  (need shIonPumpVBo)
683   //
684   // ==========================================================================
685   const Double_t kdzMoFlange   =  2.0;
686   const Double_t kdzMoBellow   = 15.6;
687   const Double_t kdzTTube = 11.5; // Bellow starts here
688   const Double_t kziTTube  =  1.0; // Ion Pum Tube starts here
689   new TGeoTube( "shMoFlange", 0., 15.2/2., kdzMoFlange/2.0);
690   new TGeoTube( "shMoBellow", 0., 11.4/2., kdzMoBellow/2.0);
691   (new TGeoTranslation("trMoFlange1", 0., 0.,        0.5*kdzMoFlange     )) -> RegisterYourself();
692   (new TGeoTranslation("trMoFlange2", 0., 0., 28.0 - 0.5*kdzMoFlange     )) -> RegisterYourself();
693   (new TGeoTranslation("trMoBellow" , 0., 0., 28.0 - 0.5*kdzMoBellow     )) -> RegisterYourself();
694   (new TGeoTranslation("trMoTTube"  , 0., 0., kziTTube +  0.5*kdzTTube   )) -> RegisterYourself();
695   
696   TGeoCompositeShape * shMoVMAOI =  
697       new TGeoCompositeShape("shMoVMAOI", 
698       "shMoFlange:trMoFlange1 + shMoBellow:trMoBellow + shMoFlange:trMoFlange2 + shIonPumpVBo:trMoTTube");
699   TGeoVolume * voMoVMAOI = new TGeoVolume("voMoVMAOI", shMoVMAOI, kMedVacuum);
700   voMoVMAOI->AddNode(voVSR      ,1, new TGeoTranslation(0., 0., 7.1 - 0.45));
701   voMoVMAOI->AddNode(voIonPumpVB,1, new TGeoTranslation(0., 0., 1 + 11.5/2.));
702   voMoVMAOI->AddNode(voVSRflange,1, new TGeoTranslation(0.,0.,0.));
703   voMoVMAOI->AddNode(voVSRcontD ,1, new TGeoTranslation(0.,0.,28.));
704   voMoVMAOI->AddNode(voVSRcontF ,1, new TGeoTranslation(0.,0.,28.));
705   z = 1.0 + 11.5;
706   voMoVMAOI->AddNode( new TGeoVolume("voVBU9mm", shVBU9mm, kMedAlu),
707                1, new TGeoTranslation(0.,0., z) );
708   voMoVMAOI->AddNode( new TGeoVolume("voVBU26mm", shVBU26mm, kMedAlu),
709                1, new TGeoTranslation(0.,0., z + 11.9) );
710   voMoVMAOI->AddNode( new TGeoVolume("voVBUcent", shVBUcent, kMedAlu),
711                1, new TGeoTranslation(0.,0., z) );
712   voMoVMAOI->AddNode( voVBUrotFlg, 1, 
713                new TGeoCombiTrans(0.,0.,1.31, Ry180) );
714   voMoVMAOI->AddNode( voVBUrotFlg, 2, 
715                new TGeoTranslation(0.,0.,28. - 1.31) );
716   voMoVMAOI->AddNode( voVBUflg, 1, 
717                new TGeoTranslation(0.,0.,0.) );
718   voMoVMAOI->AddNode( voVBUflg, 2, 
719                new TGeoCombiTrans(0.,0.,28., Ry180) );
720   // ==========================================================================
721   //
722   // AD Support structure by Pieter Ijzerman
723   // ecalvovi@cern.ch
724   // ==========================================================================
725   Int_t nvertices=0;
726   // Cover plate_______________________________________________________________
727   TGeoXtru * shADcoverplate = new TGeoXtru(2);
728   shADcoverplate->SetNameTitle("shADcoverplate","shADcoverplate");
729   Double_t y1[] = {  0.0, 18.50, 18.50, 22.50, 22.50, 18.50, 18.50, 22.50, 22.50, 18.50, 18.50,   .00 ,  .00, 15.25, 15.25,  .00 }; 
730   Double_t x1[] = {  0.0,   .00,  5.15,  5.15, 17.15, 17.15, 24.25, 24.25, 36.25, 36.25, 41.40, 41.40 ,35.70, 35.70,  5.70, 5.70 }; 
731   nvertices = sizeof(x1)/sizeof(Double_t);
732   shADcoverplate->DefinePolygon(nvertices,x1,y1);
733   shADcoverplate->DefineSection(0, -0.1, -20.7, 0.0, 1.0); // Z position, offset and scale for first section
734   shADcoverplate->DefineSection(1,  0.1, -20.7, 0.0, 1.0); // -''- secons section
735
736   // Horizontal side___________________________________________________________
737   TGeoXtru * shADhorizontalside = new TGeoXtru(2);
738   shADhorizontalside->SetNameTitle("shADhorizontalside","shADhorizontalside");
739   Double_t x2[] = {  0.0,  .00, 4.80, 4.80, 7.20, 7.20, 12.00, 12.00 };
740   Double_t y2[] = {  0.0, 5.66, 5.66, 1.16, 1.16, 5.66,  5.66,   .00 };
741   nvertices = sizeof(x2)/sizeof(Double_t);
742   shADhorizontalside->DefinePolygon(nvertices,x2,y2);
743   shADhorizontalside->DefineSection(0, -0.4, -6.0, 0.0, 1.0); // Z position, offset and scale for first section
744   shADhorizontalside->DefineSection(1, +0.4, -6.0, 0.0, 1.0); // -''- secons section
745
746   TGeoBBox * shADsidebox = new TGeoBBox("shADsidebox", 0.4, 18.55/2., 5.66/2.);
747   TGeoVolume * voADsidebox = new TGeoVolume("voADsidebox", shADsidebox, kMedAlu);
748
749
750 // Define a TNode where this example resides in the TGeometry
751 // Draw the TGeometry
752   TGeoVolume * voADhorizontalside = new TGeoVolume("voADhorizontalside", shADhorizontalside, kMedAlu);
753   TGeoVolume * voADcoverplate = new TGeoVolume("voADcoverplate", shADcoverplate, kMedAlu);
754   //
755   TGeoVolume *voADsupport = new TGeoVolumeAssembly("voADsupport"); 
756   voADsupport->AddNode(voADcoverplate,  1, new TGeoTranslation( 0., 0., -5.66/2.-0.1));
757   voADsupport->AddNode(voADcoverplate,  2, new TGeoTranslation( 0., 0., +5.66/2.+0.1));
758   voADsupport->AddNode(voADhorizontalside,  1, new TGeoCombiTrans( -6.0 - 7.1/2., 22.5-0.4, -5.66/2., Rx90));
759   voADsupport->AddNode(voADhorizontalside,  2, new TGeoCombiTrans( +6.0 + 7.1/2., 22.5-0.4, -5.66/2., Rx90));
760   voADsupport->AddNode(voADsidebox,  1, new TGeoTranslation( -20.7 +0.4, 18.55/2., 0.));
761   voADsupport->AddNode(voADsidebox,  2, new TGeoTranslation( +20.7 -0.4, 18.55/2., 0.));
762
763   // ==========================================================================
764   //
765   // Define ADA
766   //
767   // ==========================================================================
768
769   TGeoVolume *ad = new TGeoVolumeAssembly("AD");
770   
771   // Get medium for ADA
772   TGeoMedium * medADASci        = gGeoManager->GetMedium("AD_BC404"); // AD Scin.
773   // TGeoMedium * medADALG      = gGeoManager->GetMedium("AD_PMMA");  // lightGuide
774   // TGeoMedium * medADAPMGlass = gGeoManager->GetMedium("AD_Glass"); // Glass for Aluminium simulation
775   // TGeoMedium * medADAPMAlum  = gGeoManager->GetMedium("AD_Alum");
776   
777   // Get Medium for ADC 
778   TGeoMedium * medADCSci     = gGeoManager->GetMedium("AD_BC404");
779   // TGeoMedium * medADCLG      = gGeoManager->GetMedium("AD_PMMA");
780   // TGeoMedium * medADCPMGlass = gGeoManager->GetMedium("AD_Glass");
781   // TGeoMedium * medADCPMAlum  = gGeoManager->GetMedium("AD_Alum");
782   
783   // ADA Scintillator Pad 
784   const Double_t kADACellSideY = 21.6;
785   const Double_t kADACellSideX = 18.1;
786   // ADC Scintillator Pad 
787   const Double_t kADCCellSideY = 21.6;
788   const Double_t kADCCellSideX = 18.1;
789   // WLS bar          :  0.40 cm ( 4.0 mm )
790   // Wrapping         :  0.20 cm ( 2.0 mm )
791   // Aluminnized Mylar:  0.01 cm ( 0.1 mm )
792   // Fishing line     :  0.04 cm ( 0.4 mm )
793   // total shift on X :  0.65 cm
794   // total shift on Y :  0.21 cm
795   const Double_t kShiftX       =  0.54;
796   const Double_t kShiftY       =  0.10;
797   const Double_t kADACelldz    =  2.50;
798   const Double_t kADCCelldz    =  2.50;
799   const Double_t kADABeamPipeR =  6.20; // Radius of beam pipe hole for ADA (Diameter  12.4 cm)
800   const Double_t kADCBeamPipeR =  3.70; // Radius of beam pipe hole for ADC (Diameter   7.4 cm)
801   const Int_t    kColorADA     = kGreen;
802   const Int_t    kColorADC     = kGreen;
803   Double_t X = kShiftX + kADACellSideX * 0.5;
804   Double_t Y = kShiftY + kADACellSideY * 0.5;
805   Double_t WLS_dx =  0.4;
806   Double_t WLS_dz =  2.5;
807   Double_t WLS_SideA_Long_dy  = 24.20; // 24.2;
808   Double_t WLS_SideC_Long_dy  = 24.20; // 24.2;
809   Double_t WLS_SideA_Short_dy = 18.20; // 18.41; 
810   Double_t WLS_SideC_Short_dy = 20.70; // 20.91; 
811   // Creating ADA WLS bars_____________________________________________________
812   TGeoVolume * vADA_WLS_s = new TGeoVolume( "ADAWLSshort", 
813       new TGeoBBox( "shADAWLSbarShort" , WLS_dx/2.0, WLS_SideA_Short_dy/2.0, WLS_dz/2.0),
814       medADASci);      
815   TGeoVolume * vADA_WLS_l = new TGeoVolume( "ADAWLSlong" , 
816       new TGeoBBox( "shADAWLSbarLong"  , WLS_dx/2.0, WLS_SideA_Long_dy /2.0, WLS_dz/2.0),
817       medADASci);      
818   vADA_WLS_l->SetLineColor( kRed );
819   vADA_WLS_s->SetLineColor( kRed );
820   // Creating ADC WLS bars_____________________________________________________
821   TGeoVolume * vADC_WLS_s = new TGeoVolume( "ADCWLSshort", 
822       new TGeoBBox( "shADCWLSbarShort" , WLS_dx/2.0, WLS_SideC_Short_dy/2.0, WLS_dz/2.0),
823       medADCSci);      
824   TGeoVolume * vADC_WLS_l = new TGeoVolume( "ADCWLSlong" , 
825       new TGeoBBox( "shADCWLSbarLong"  , WLS_dx/2.0, WLS_SideC_Long_dy /2.0, WLS_dz/2.0),
826       medADCSci);      
827   vADC_WLS_l->SetLineColor(kRed);
828   vADC_WLS_s->SetLineColor(kRed);
829   // Make ADA scintillator pad_________________________________________________
830   new TGeoBBox( "shADAbox" , kADACellSideX/2.0, kADACellSideY/2.0, kADACelldz/2.0 );
831   new TGeoTube( "shADAHole",               0. , kADABeamPipeR    , kADACelldz     );
832   ( new TGeoTranslation("trADAbox", X, Y, 0.)) -> RegisterYourself();
833   // 
834   TGeoVolume * vADA1 = new TGeoVolume( "ADApad", 
835     new TGeoCompositeShape("shADApad", "shADAbox:trADAbox-shADAHole"), medADASci );      
836   vADA1->SetLineColor( kColorADA );
837   
838   TGeoVolume *secADA  = new TGeoVolumeAssembly( "ADAsec" ); 
839   // Add PAD
840   secADA->AddNode( vADA1, 1, 0); 
841   secADA->AddNode( vADA_WLS_s, 1, 
842       new TGeoTranslation(0.1 + WLS_dx/2.0, kADABeamPipeR + WLS_SideA_Short_dy/2.0, 0.0) ); 
843   secADA->AddNode( vADA_WLS_l, 1, 
844       new TGeoTranslation(kShiftX + WLS_dx/2.0 + kADACellSideX + 0.04, kShiftY + WLS_SideA_Long_dy/2.0, 0.0) ); 
845
846   /// Assembling ADA adding 4 sectors                                       //  Sectors
847   TGeoVolume *vADAarray = new TGeoVolumeAssembly( "ADA" );                  //        ^ y
848   vADAarray->AddNode( secADA, 1 );                                          //        |   
849   vADAarray->AddNode( secADA, 2, Ry180 );                                   //   2    |   1
850   vADAarray->AddNode( secADA, 3, Rz180 );                                   // --------------->  x     
851   vADAarray->AddNode( secADA, 4, Rx180 );                                   //   3    |   4
852   //                                                                        //        |
853   // Add ADA layer 2 and 3 to AD volume
854   // const Float_t kPosAD2 = 1695.0;
855   // const Float_t kPosAD3 = 1700.0;
856   // ad->AddNode(vADAarray,1, new TGeoTranslation(0., 0., kPosAD2)); 
857   // ad->AddNode(vADAarray,2, new TGeoTranslation(0., 0., kPosAD3));
858   const Float_t kPosADA = 1695.0;
859   ad->AddNode(vADAarray,    1, new TGeoTranslation(0., 0., kPosADA - kADACelldz/2. -0.1)); 
860   ad->AddNode(vADAarray,    2, new TGeoTranslation(0., 0., kPosADA + kADACelldz/2. +0.1));
861   ad->AddNode(voADsupport,  1, new TGeoTranslation( 0., 0., kPosADA));
862   ad->AddNode(voADsupport,  2, new TGeoCombiTrans ( 0., 0., kPosADA, Rz180));
863
864   // ==========================================================================
865   //
866   // Define ADC (2014, May 4) Updated 2015, Jan 22
867   //
868   // ==========================================================================
869
870   /////////////////////////////////////////////////////////////////////////////
871   /// ADC in the tunnel                                                     ///
872   /////////////////////////////////////////////////////////////////////////////
873   new TGeoBBox( "shADCbox" , kADCCellSideX/2.0, kADCCellSideY/2.0, kADCCelldz/2.0 );
874   new TGeoTube( "shADCHole",               0. , kADCBeamPipeR    , kADCCelldz     );
875   X = kShiftX + kADCCellSideX * 0.5;
876   Y = kShiftY + kADCCellSideY * 0.5;
877   ( new TGeoTranslation("trADCbox", X, Y, 0.) ) -> RegisterYourself();
878   // 
879   TGeoVolume * vADCpad = new TGeoVolume( "ADCpad", 
880     new TGeoCompositeShape("shADCpad", "shADCbox:trADCbox-shADCHole"), medADCSci );      
881   vADCpad->SetLineColor( kColorADC );
882   
883   /// Creating Sector for Tunnel (Asembly:  Scintillator Pad + Light guide + PM )
884   TGeoVolume *voADC  = new TGeoVolumeAssembly("ADCsec");
885   // Add PAD
886   voADC->AddNode( vADCpad, 1, 0);
887   // Add ADC WLS Short bar
888   voADC->AddNode( vADC_WLS_s, 1, 
889       new TGeoTranslation( 0.1 + WLS_dx/2.0, kADCBeamPipeR + WLS_SideC_Short_dy/2.0, 0.0) ); 
890   // Add ADC WLS Long  bar
891   voADC->AddNode( vADC_WLS_l, 1, 
892       new TGeoTranslation( 0.04 + WLS_dx/2.0 + kADCCellSideX + kShiftX, kShiftY + WLS_SideC_Long_dy/2.0, 0.0) ); 
893   
894   /// Assembling ADC adding the 4 sectors                 //  Sectors
895   TGeoVolume *vADCarray = new TGeoVolumeAssembly("ADC");  //        ^ y
896   vADCarray->AddNode( voADC, 1 );                         //        |   
897   vADCarray->AddNode( voADC, 2, Ry180 );                  //   2    |   1
898   vADCarray->AddNode( voADC, 3, Rz180 );                  // --------------->  x  
899   vADCarray->AddNode( voADC, 4, Rx180 );                  //   3    |   4
900                                                           //        |
901                                                                              
902
903   // ==========================================================================
904   //
905   // Add ADC to AD volume
906   //
907   // Note to future maintainers: 
908   // In previous AliRoot versions the position z = -1900.75 corresponded 
909   // to the end of the YSAA3_CC_BLOCK (concrete block shielding just before 
910   // the C-Side LHC wall). Now this has been fixed to agree with reality. 
911   // The YSAA3_CC_BLOCK starts at 1800.75 and ends at 1880.75 cm.
912   //
913   // Ernesto Calvo and Alberto Gago.
914   // - ecalvovi@cern.ch
915   // - agago@pucp.edu.pe
916   //
917   // ==========================================================================
918   
919   // *  ad -> AddNode(vADCarray , 1, new TGeoTranslation(0., 0., kZendADC2 + kADCCelldz/2.)); // Tunnel
920   // *  ad -> AddNode(vADCarray , 2, new TGeoTranslation(0., 0., kZbegADC1 - kADCCelldz/2.)); // Tunnel
921   // *  const Float_t kZbegADC1 = -kZbegFrontBar-2.
922   // *  const Float_t kZendADC2 = -1959.0;            // (ecalvovi@cern.ch) 
923   
924   switch (fADCPosition ) {
925     case kADCInTunnel:
926       {
927         // const Float_t kZbegADC1 = -kZbegFrontBar-2.;  // (ecalvovi@cern.ch) 
928         // const Float_t kZendADC2 = -1959.0;            // (ecalvovi@cern.ch) 
929         // ad -> AddNode(vADCarray , 1, new TGeoTranslation(0., 0., kZendADC2 + kADCCelldz/2.)); // Tunnel
930         // ad -> AddNode(vADCarray , 2, new TGeoTranslation(0., 0., kZbegADC1 - kADCCelldz/2.)); // Tunnel
931         const Float_t kPosADC = -kZbegFrontBar-2.-3.0-0.3;  // 3.0 = (5.6 + 0.2 + 0.2)/2. // (ecalvovi@cern.ch) 
932         printf("CreateAD: kPosADC=%8.2f\n", kPosADC);
933         ad -> AddNode(vADCarray , 1, new TGeoTranslation(0., 0., kPosADC - kADCCelldz/2. - 0.165)); // Tunnel // ADC1
934         ad -> AddNode(vADCarray , 2, new TGeoTranslation(0., 0., kPosADC + kADCCelldz/2. + 0.165)); // Tunnel // ADC2
935         ad -> AddNode(voADsupport, 3, new TGeoTranslation( 0., 0., kPosADC));
936         ad -> AddNode(voADsupport, 4, new TGeoCombiTrans ( 0., 0., kPosADC, Rz180));
937         break;
938       }
939     case kADCInCavern:
940       {
941         printf("FATAL: vADCInCavern is now obsolete!");
942         exit(1);
943         // const Float_t kZbegADC1 = -1890.0;  // (ecalvovi@cern.ch) 
944         // const Float_t kZbegADC2 = -1885.0;  // (ecalvovi@cern.ch) 
945         // ad -> AddNode(vADCarrayH, 1, new TGeoTranslation(0., 0., kZbegADC1 - kADCCelldz/2.)); // Cavern
946         // ad -> AddNode(vADCarrayH, 2, new TGeoTranslation(0., 0., kZbegADC2 - kADCCelldz/2.)); // Cavern
947         break;
948       }
949     case kADCInBoth:
950       {
951         printf("FATAL: vADCInBoth   is now obsolete!");
952         exit(1);
953         // const Float_t kZbegADC1 = -kZbegFrontBar-2.;  // (ecalvovi@cern.ch) 
954         // const Float_t kZbegADC2 = -1885.0;            // (ecalvovi@cern.ch) 
955         // ad -> AddNode(vADCarray , 1, new TGeoTranslation(0., 0., kZbegADC1 - kADCCelldz/2.)); // Tunnel
956         // ad -> AddNode(vADCarrayH, 2, new TGeoTranslation(0., 0., kZbegADC2 - kADCCelldz/2.)); // Cavern 
957         break;
958       }
959   }
960
961
962   // ==========================================================================
963   // 
964   // Add structure volumes to top volume
965   //
966   // ==========================================================================
967
968   TGeoVolumeAssembly * top = new TGeoVolumeAssembly("voADStruct");
969   top->AddNode(voSaa3EndPlate, 1, new TGeoTranslation( 0., 0., kZendAbs + 1.95/2.));
970   z = kZwall;
971   top->AddNode(voWallBigPlate, 1, new TGeoTranslation(0., 0., z - 0.5 * dAlWallThick ));
972   top->AddNode(voWallSqrPlate, 1, new TGeoTranslation(0., 0., z + 0.5 * dAlWallThick ));
973   z = kZendAbs + 1.95 + dzRodL/2.; 
974   top->AddNode(voSaa3Rod,  1, new TGeoTranslation(  12.5, -12.75, z));
975   top->AddNode(voSaa3Rod,  2, new TGeoTranslation(  12.5,  12.75, z));
976   top->AddNode(voSaa3Rod,  3, new TGeoTranslation( -12.5, -12.75, z));
977   top->AddNode(voSaa3Rod,  4, new TGeoTranslation( -12.5,  12.75, z));
978   top->AddNode(voValve,    1, new TGeoTranslation( 0., 0., zPosValve));
979   //
980   top->AddNode(voMoVMAOI,  1, new TGeoTranslation( 0., 0., kZbegVMAOI));
981   //
982   top->AddNode(voFrontBar, 1, new TGeoTranslation( 0., 0., kZbegFrontBar + dzF/2.));
983   z = kZbegCoil;
984   top->AddNode(voCoil, 1, new TGeoCombiTrans(  3.6 + dz/2., 0., z, Ry90m));
985   top->AddNode(voCoil, 2, new TGeoCombiTrans(  3.6 + dz/2., 0., z, new TGeoRotation((*Ry90m)*(*Rx180))));
986   top->AddNode(voCoil, 3, new TGeoCombiTrans( -3.6 - dz/2., 0., z, Ry90m));
987   top->AddNode(voCoil, 4, new TGeoCombiTrans( -3.6 - dz/2., 0., z, new TGeoRotation((*Ry90m)*(*Rx180))));
988   z = kZbegFrontBar + dzF + kdzLatBar/2.;
989   top->AddNode(voLatBar, 1, new TGeoTranslation(  31.9, 0., z));
990   top->AddNode(voLatBar, 2, new TGeoTranslation( -31.9, 0., z));
991   //
992   // Add structures (top) to AD node
993   //
994   if (fADCstruct) {
995     ad->AddNode(top,1, Ry180);
996   }
997
998   //
999   // Add Everything to ALICE
1000   //
1001   TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
1002   alice->AddNode(ad, 1);
1003   
1004
1005   // gGeoManager->DefaultColors();
1006   // gGeoManager->CloseGeometry();
1007   // gGeoManager->SetVisLevel(10);
1008   // gGeoManager->SetVisOption(0);
1009   // alice->Draw("ogl");
1010
1011   return; 
1012   printf("<=== AliADv1::CreateAD(): ver=[Feb 3st, 2015]; contact=[ecalvovi@cern.ch]\n");
1013 }
1014
1015 //_____________________________________________________________________________
1016 void AliADv1::AddAlignableVolumes() const
1017 {
1018    //
1019    // Create entries for alignable volumes associating the symbolic volume
1020    // name with the corresponding volume path. Needs to be syncronized with
1021    // eventual changes in the geometry.
1022    //
1023    // ADA and ADC 
1024    TString volpath1, volpath2, volpath3, volpath4;
1025    TString symname1, symname2, symname3, symname4;
1026
1027    symname1 = "AD/ADC1";
1028    symname2 = "AD/ADC2"; 
1029    symname3 = "AD/ADA1";
1030    symname4 = "AD/ADA2"; 
1031    switch (fADCPosition) {
1032      case kADCInTunnel:
1033        volpath1 = "/ALIC_1/AD_1/ADC_1";
1034        volpath2 = "/ALIC_1/AD_1/ADC_2";
1035        break;
1036      case kADCInCavern:
1037        volpath1 = "/ALIC_1/AD_1/ADCh_1";
1038        volpath2 = "/ALIC_1/AD_1/ADCh_2";
1039        break;
1040      case kADCInBoth:
1041        volpath1 = "/ALIC_1/AD_1/ADC_1";
1042        volpath2 = "/ALIC_1/AD_1/ADCh_2";
1043        break;
1044    }
1045    volpath3 = "/ALIC_1/AD_1/ADA_1";
1046    volpath4 = "/ALIC_1/AD_1/ADA_2";
1047
1048    if ( !gGeoManager->SetAlignableEntry(symname1.Data(), volpath1.Data()) )
1049       AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname1.Data(), volpath1.Data()) );
1050    if ( GetADCTwoInstalled() && !gGeoManager->SetAlignableEntry(symname2.Data(), volpath2.Data()) )
1051       AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname2.Data(), volpath2.Data()) );
1052    if ( !gGeoManager->SetAlignableEntry(symname3.Data(), volpath3.Data()) )
1053       AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname3.Data(), volpath3.Data()) );
1054    if ( GetADATwoInstalled() && !gGeoManager->SetAlignableEntry(symname4.Data(), volpath4.Data()) )
1055       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname4.Data(), volpath4.Data()) );
1056    
1057 }
1058
1059
1060 //_____________________________________________________________________________
1061 void AliADv1::StepManager()
1062 {
1063
1064    //
1065    // Routine called at every step in the AD
1066    //
1067
1068    // ADA and ADC static Variables         //
1069    // static  Int_t   numStep_ad = 0;      //
1070    // static  Int_t   vol_ad[2];           //
1071   
1072    /////////////////////////////////////////////////////////////////////////
1073    //                            ADA and ADC                              //
1074    /////////////////////////////////////////////////////////////////////////
1075       
1076       
1077    // Get sensitive volumes id (scintillator pads)
1078    static Int_t idADA  = gMC->VolId( "ADApad" );
1079    static Int_t idADC  = gMC->VolId( "ADCpad" );
1080    // static Int_t idADCh = gMC->VolId( "ADCpadH" );
1081    
1082    static Bool_t fOnlyOnce = kTRUE;
1083    if (fOnlyOnce) {
1084      //printf("  gMC->VolId(\"ADApad\" ) = %3d\n", idADA);
1085      //printf("  gMC->VolId(\"ADCpad\" ) = %3d\n", idADC);
1086      // printf("  gMC->VolId(\"ADCpadH\") = %3d\n", idADCh);
1087      fOnlyOnce = kFALSE;
1088    }
1089
1090    // We keep only charged tracks : 
1091    // if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;   
1092    // We keep charged and non-charged tracks : 
1093    if ( !gMC->IsTrackAlive() ) return;   
1094    
1095    Int_t copy;
1096    Int_t current_volid = gMC->CurrentVolID( copy );
1097
1098    // check is the track is in a sensitive volume
1099    // if( current_volid != idADA && current_volid != idADC && current_volid != idADCh ) {
1100    if( current_volid != idADA && current_volid != idADC ) {
1101       return; // not in the sensitive volume 
1102    }
1103    
1104    // First read the position, otherwise weird results! //ecv
1105    Double_t s[3];
1106    Float_t  x[3];
1107    gMC->TrackPosition( s[0], s[1], s[2] );
1108    for ( Int_t j=0; j<3; j++ ) x[j] = s[j];
1109    
1110    // Get sector copy (1,2,3,4) ( 1 level up from pad )
1111    Int_t sect;
1112    gMC->CurrentVolOffID( 1, sect );
1113    
1114    // Get Detector copy (1,2) ( 2 levels up from pad )
1115    Int_t detc;
1116    gMC->CurrentVolOffID( 2, detc );
1117
1118    // Set detector type: ADA or ADC
1119    Int_t ADlayer = (current_volid == idADC ) ? 0 : 2;
1120
1121    //printf("CurVolID: %d | sect: %2d | detc: %2d\n", current_volid, sect, detc); 
1122
1123    sect--;          //     sector within layer [0-3]
1124    detc--;          //     detector copy       [0-1]
1125    ADlayer += detc; //     global layer number [0-3]
1126
1127    Int_t ADsector = ADlayer*4 + sect; // Global AD sector number [0-15]
1128    // Layer    Sector Number 
1129    // ADC 0  =   0- 3
1130    // ADC 1  =   4- 7
1131    // ADA 2  =   8-11
1132    // ADA 3  =  12-15
1133    //printf("\n ADsector: %2d | ADlayer: %2d | sect: %2d | x: %8.2f | y: %8.2f | z: %8.2f\n", ADsector, ADlayer, sect, x[0], x[1], x[2]); // Debug ECV
1134    
1135    Double_t lightYield_ad;
1136    Double_t photoCathodeEfficiency;
1137   
1138    if( ADlayer <2 )  {
1139       lightYield_ad          = fADCLightYield;
1140       photoCathodeEfficiency = fADCPhotoCathodeEfficiency;
1141    } else  {
1142       lightYield_ad          = fADALightYield;
1143       photoCathodeEfficiency = fADAPhotoCathodeEfficiency;
1144    }
1145       
1146    Float_t destep_ad = gMC->Edep();
1147    Float_t step_ad   = gMC->TrackStep();
1148    Int_t  nPhotonsInStep_ad = Int_t( destep_ad / (lightYield_ad * 1e-9) ); 
1149    nPhotonsInStep_ad = gRandom->Poisson( nPhotonsInStep_ad );
1150    
1151    static  Float_t eloss_ad    = 0.;
1152    static  Float_t tlength_ad  = 0.;   
1153    static  Int_t   nPhotons_ad = 0;      
1154    static  Float_t hits_ad[11];            
1155    static  Int_t   vol_ad[5];
1156
1157    eloss_ad   += destep_ad;
1158    tlength_ad += step_ad;  
1159  
1160    if ( gMC->IsTrackEntering() ) { 
1161       nPhotons_ad = nPhotonsInStep_ad;
1162       Double_t p[4];
1163       gMC->TrackMomentum( p[0], p[1], p[2], p[3] );
1164       Float_t pt  = TMath::Sqrt( p[0]*p[0] + p[1]*p[1] + p[2]*p[2] ); 
1165       TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
1166       Int_t imo = par->GetFirstMother();
1167       Int_t pdgMo = 0;
1168       if ( imo > 0 ) {
1169          TParticle * pmot = gAlice->GetMCApp()->Particle(imo);
1170          pdgMo = pmot->GetPdgCode();
1171       }
1172
1173       // Set integer values
1174       vol_ad[0]  = par->GetStatusCode();    // secondary flag //ecv
1175       vol_ad[1]  = par->GetPdgCode();       // PDG code
1176       vol_ad[2]  = pdgMo;                   // PDG of the mother
1177       // Set float values
1178       hits_ad[0]  = x[0];     // X
1179       hits_ad[1]  = x[1];     // Y 
1180       hits_ad[2]  = x[2];     // Z       
1181       hits_ad[3]  = p[3];     // kinetic energy of the entering particle
1182       hits_ad[4]  = pt;       // Pt
1183       hits_ad[5]  = p[0];     // Px
1184       hits_ad[6]  = p[1];     // Py
1185       hits_ad[7]  = p[2];     // Pz
1186       hits_ad[8]  = 1.0e09*gMC->TrackTime(); // in ns!
1187   
1188       tlength_ad = 0.0;
1189       eloss_ad   = 0.0; 
1190       
1191       return; // without return, we count 2 times nPhotonsInStep_ad !!!???
1192    }
1193    
1194    nPhotons_ad += nPhotonsInStep_ad;
1195
1196    if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) {
1197
1198       // Set integer values
1199       vol_ad[3]  = nPhotons_ad;
1200       vol_ad[4]  = ADsector;  // sector number (scintillator ID)
1201       // Set float values
1202       hits_ad[9]  = tlength_ad;    // track lenght inside ADC or ADA
1203       hits_ad[10] = eloss_ad;      // energy loss
1204       Int_t track = gAlice->GetMCApp()->GetCurrentTrackNumber();
1205       AddHit( track, vol_ad, hits_ad ); // <-- this is in AliAD.cxx
1206       tlength_ad        = 0.0;
1207       eloss_ad          = 0.0; 
1208       nPhotons_ad       = 0;
1209    }
1210        
1211    //   Do we need track reference ????
1212    // if( gMC->IsTrackEntering() || gMC->IsTrackExiting() ) {
1213    //    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), 49);
1214    // }
1215 }
1216 //_________________________________________________________
1217 void AliADv1::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1218 {
1219         TClonesArray &lhits = *fHits;
1220         new(lhits[fNhits++]) AliADhit(fIshunt,track,vol,hits);
1221 }
1222 //_________________________________________________________
1223 // void AliADv1::AddDigits(Int_t* track, Int_t module, Float_t time)
1224 // {
1225 //      TClonesArray &ldigits = *fDigits;
1226 //      new(ldigits[fNdigits++]) AliADdigit(track,module,time);
1227 // }
1228 //_________________________________________________________
1229 void AliADv1::MakeBranch(Option_t *option)
1230 {
1231
1232         // Create branches in the current tree
1233         TString branchname(Form("%s",GetName()));
1234         AliDebug(2,Form("fBufferSize = %d",fBufferSize));
1235         const char *cH = strstr(option,"H");
1236         if (fHits && fLoader->TreeH() && cH)
1237         {
1238                 fLoader->TreeH()->Branch(branchname.Data(),&fHits,fBufferSize);
1239                 AliDebug(2,Form("Making Branch %s for hits",branchname.Data()));
1240         }
1241         const char *cD = strstr(option,"D");
1242         if (fDigits   && fLoader->TreeD() && cD) 
1243         {
1244                 fLoader->TreeD()->Branch(branchname.Data(),&fDigits, fBufferSize);
1245                 AliDebug(2,Form("Making Branch %s for digits",branchname.Data()));
1246         }  
1247 }