LCOV - code coverage report
Current view: top level - AD/ADsim - AliADv1.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 573 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 17 5.9 %

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

Generated by: LCOV version 1.11