ROOT logo
#ifndef ALIITSV11GEOMETRYSPD_H
#define ALIITSV11GEOMETRYSPD_H

/*
 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved.
 * See cxx source for full Copyright notice.
 */

 // Implementation of the SPD v11 central geometry.
 // Contains also:
 //  - the materials/media used for its volumes;
 //  - settings for the related transport parameters
 //   (GEANT3 types for the moment).
 //

/*
 * $Id$
 */

#include <TArrayD.h>
#include <TGeoManager.h>
#include <TVirtualMC.h>
#include <TString.h>
#include <TArrayI.h>
#include <TPolyLine.h>
#include <TPolyMarker.h>
#include "AliITSv11Geometry.h"

class TGeoVolume;
class TGeoCompositeShape;

using std::istream;

class AliITSv11GeometrySPD : public AliITSv11Geometry
{
 public:

    // Default constructor
    AliITSv11GeometrySPD(/*Double_t gap = 0.0075*/);
    // Standard Constructor
    AliITSv11GeometrySPD(Int_t debug/*, Double_t gap = 0.0075*/);
    // Copy constructor
    AliITSv11GeometrySPD(const AliITSv11GeometrySPD &s);
    // Assignment operator
    AliITSv11GeometrySPD& operator=(const AliITSv11GeometrySPD &s);
    // Destructor
    virtual ~AliITSv11GeometrySPD() {};

    /* Services */

    // get names
    virtual const char *GetSenstiveVolumeName1() const
        {return "ITSSPDlay1-sensor";}
    virtual const char *GetSenstiveVolumeName2() const
        {return "ITSSPDlay2-sensor";}
    virtual const char *GetSenstiveVolumeName(Int_t lay) const
        {return (lay==1) ? GetSenstiveVolumeName1():GetSenstiveVolumeName2();}
    // get medium
    virtual TGeoMedium* GetMedium(const char* mediumName,
                                  const TGeoManager *mgr = gGeoManager) const;
    // retrieve the mounting location and rotation needed to mount an SPD stave
    virtual Int_t GetSPDsectorX0Size() const
        {return fSPDsectorX0.GetSize();}
    virtual Bool_t GetSectorMountingPoints(Int_t index, Double_t &x0,
                               Double_t &y0, Double_t &x1, Double_t &y1) const;
    // displace the staves on the carbon fiber sector
    virtual void StavesInSector(TGeoVolume *moth,TGeoManager *mgr=gGeoManager);
    // (debug purposes) define which staves to put in the sector
    virtual void SetAddStave(Bool_t *mask);
    // print class in ascii form to stream
    virtual void PrintAscii(ostream *os) const;
    // read in class in ascii form from stream
    virtual void ReadAscii(istream *is);

    /* Parts of the geometry */

    // a single ladder (= 1 detector + 5 chips)
    virtual TGeoVolume* CreateLadder(Int_t layer, TArrayD &sizes,
                                     TGeoManager *mgr = gGeoManager) const;
    // a clip on the central ladders
    virtual TGeoVolume* CreateClip(TArrayD &sizes,Bool_t isDummy,
                                   TGeoManager *mgr = gGeoManager) const;
    // the grounding foil (splitted in many components)
    virtual  TGeoCompositeShape* CreateGroundingFoilShape(Int_t itype,
        Double_t &length,Double_t &width,Double_t thickness,TArrayD &sizes);
    virtual TGeoVolumeAssembly* CreateGroundingFoil(Bool_t isRight, TArrayD &sizes,
                                        TGeoManager *mgr = gGeoManager);
    // the MCM (thin part + thick part with chips inside)
    virtual TGeoVolumeAssembly* CreateMCM(Bool_t isRight, TArrayD &sizes,
                                       TGeoManager *mgr = gGeoManager) const;
    // the pixel bus (flat part + pt1000s + large capacitors/resistors)
    virtual TGeoVolumeAssembly* CreatePixelBus(Bool_t isRight, Int_t layer, TArrayD &sizes,
                                        TGeoManager *mgr = gGeoManager) const;
    // the extender complicated geometry
    virtual TGeoVolume* CreateExtender(const Double_t *params,
                              const TGeoMedium *medium, TArrayD &sizes) const;
                                        
    virtual TGeoVolume* CreatePatchPanel(TArrayD &sizes,
                                        TGeoManager *mgr = gGeoManager) const;

    virtual TList* CreateConeModule(Bool_t sideC, const Double_t angle,
				    TGeoManager *mgr = gGeoManager) const;
    virtual void CreateCones(TGeoVolume *moth) const;
/*    virtual*/ void CreateServices(TGeoVolume *moth) const;
    // a half-stave (put together ladders + MCM + bus, and add clips
    // if requested)
    virtual TGeoVolumeAssembly* CreateHalfStave(Bool_t isRight, Int_t layer,
                 Int_t idxCentral, Int_t idxSide,TArrayD &sizes/*,
              Bool_t addClips = kFALSE*/, TGeoManager *mgr = gGeoManager);
    // the whole stave (2 half-staves of different orientation)
    virtual TGeoVolumeAssembly* CreateStave(Int_t layer, TArrayD &sizes,
             /*Bool_t addClips = kFALSE,*/TGeoManager *mgr = gGeoManager);
    // the complete Carbon Fiber sector (support + staves)
    virtual void CarbonFiberSector(TGeoVolume *moth, Int_t sect, Double_t &xAAtubeCenter0,
                     Double_t &yAAtubeCenter0, TGeoManager *mgr = gGeoManager);
    // the whole SPD barrel (the 10 sectors at once)
    virtual void SPDSector(TGeoVolume *moth, TGeoManager *mgr = gGeoManager);
    // Returns the location of the SPD cooling tube ends. RB26 (muon absober
    // side) and RB24 (open side). Staves number 0,1 inner Staves, 2-5 outer
    // staves. Sectors numbers 0-9.
    virtual void GetSPDCoolingTubeRB26(Int_t sector,Int_t stave,
                                 Double_t &x,Double_t &y,Double_t &z)const{
                            x = fTubeEndSector[sector][1][stave][0];
                            y = fTubeEndSector[sector][1][stave][1];
                            z = fTubeEndSector[sector][1][stave][2];return;};
    virtual void GetSPDCoolingTubeRB24(Int_t sector,Int_t stave,
                                 Double_t &x,Double_t &y,Double_t &z)const{
                            x = fTubeEndSector[sector][0][stave][0];
                            y = fTubeEndSector[sector][0][stave][1];
                            z = fTubeEndSector[sector][0][stave][2];return;};
 private:
    // NOTE:
    // all of the member functions which define a component of the final SPD
    // will need to be defined as private once the design is fixed and
    // does not need any longer to be checked and debugged.

    /* Service methods for internal use only */

    // compute shape of the SPD Sector given specific inputs
    void SPDsectorShape(Int_t n,const Double_t *xc, const Double_t *yc,
                        const Double_t *r,const Double_t *ths,
                        const Double_t *the, Int_t npr,Int_t &m,
                        Double_t **xp, Double_t **yp) const;
    // compute a point o a line parallel to a given direction
    // and with a fixed distance from it
    void ParallelPosition(Double_t dist1, Double_t dist2, Double_t phi,
                          Double_t &x, Double_t &y) const;
    // comutes the radial translation of a sector to give the
    // proper distance between SPD detectors and the beam pipe.
    Double_t GetSPDSectorTranslation(Double_t x0,Double_t y0,Double_t x1,
                                     Double_t y1,Double_t r)const;
    Bool_t CFHolePoints(Double_t s,Double_t r1,Double_t r2,Double_t l,
                        Double_t &x,Double_t &y)const;

    // create the cooling tubes going from the manifolds to the staves
    void CreateCoolingTubes(TGeoVolume *moth, Bool_t sideC) const;

    /* Data members */

    static const Double_t fgkGapLadder;// thicknes of the empty (air) gap left
                               // between the ladder and the grounding
                               // foil for alignment
    static const Double_t fgkGapHalfStave;//thickness of the empty (air) gap
                                          // left between HS and Carbon Suport
    Bool_t  fAddStave[6];      // [DEBUG] must be TRUE for all staves
	                       // which will be mounted in the sector
                               // (used to check overlaps)
    TArrayD fSPDsectorX0;      // X of first edge of sector plane for stave
    TArrayD fSPDsectorY0;      // Y of first edge of sector plane for stave
    TArrayD fSPDsectorX1;      // X of second edge of sector plane for stave
    TArrayD fSPDsectorY1;      // Y of second edge of sector plane for stave
    //
    Double_t fTubeEndSector[10][2][6][3]; // Location of tube end in sector
    /* ROOT dictionary */

    ClassDef(AliITSv11GeometrySPD,2) // ITS v11 Central SPD geometry
};

// Input and output function for standard C++ input/output.
ostream &operator<<(ostream &os, const AliITSv11GeometrySPD &s);
istream &operator>>(istream &is, AliITSv11GeometrySPD &s);

#endif
 AliITSv11GeometrySPD.h:1
 AliITSv11GeometrySPD.h:2
 AliITSv11GeometrySPD.h:3
 AliITSv11GeometrySPD.h:4
 AliITSv11GeometrySPD.h:5
 AliITSv11GeometrySPD.h:6
 AliITSv11GeometrySPD.h:7
 AliITSv11GeometrySPD.h:8
 AliITSv11GeometrySPD.h:9
 AliITSv11GeometrySPD.h:10
 AliITSv11GeometrySPD.h:11
 AliITSv11GeometrySPD.h:12
 AliITSv11GeometrySPD.h:13
 AliITSv11GeometrySPD.h:14
 AliITSv11GeometrySPD.h:15
 AliITSv11GeometrySPD.h:16
 AliITSv11GeometrySPD.h:17
 AliITSv11GeometrySPD.h:18
 AliITSv11GeometrySPD.h:19
 AliITSv11GeometrySPD.h:20
 AliITSv11GeometrySPD.h:21
 AliITSv11GeometrySPD.h:22
 AliITSv11GeometrySPD.h:23
 AliITSv11GeometrySPD.h:24
 AliITSv11GeometrySPD.h:25
 AliITSv11GeometrySPD.h:26
 AliITSv11GeometrySPD.h:27
 AliITSv11GeometrySPD.h:28
 AliITSv11GeometrySPD.h:29
 AliITSv11GeometrySPD.h:30
 AliITSv11GeometrySPD.h:31
 AliITSv11GeometrySPD.h:32
 AliITSv11GeometrySPD.h:33
 AliITSv11GeometrySPD.h:34
 AliITSv11GeometrySPD.h:35
 AliITSv11GeometrySPD.h:36
 AliITSv11GeometrySPD.h:37
 AliITSv11GeometrySPD.h:38
 AliITSv11GeometrySPD.h:39
 AliITSv11GeometrySPD.h:40
 AliITSv11GeometrySPD.h:41
 AliITSv11GeometrySPD.h:42
 AliITSv11GeometrySPD.h:43
 AliITSv11GeometrySPD.h:44
 AliITSv11GeometrySPD.h:45
 AliITSv11GeometrySPD.h:46
 AliITSv11GeometrySPD.h:47
 AliITSv11GeometrySPD.h:48
 AliITSv11GeometrySPD.h:49
 AliITSv11GeometrySPD.h:50
 AliITSv11GeometrySPD.h:51
 AliITSv11GeometrySPD.h:52
 AliITSv11GeometrySPD.h:53
 AliITSv11GeometrySPD.h:54
 AliITSv11GeometrySPD.h:55
 AliITSv11GeometrySPD.h:56
 AliITSv11GeometrySPD.h:57
 AliITSv11GeometrySPD.h:58
 AliITSv11GeometrySPD.h:59
 AliITSv11GeometrySPD.h:60
 AliITSv11GeometrySPD.h:61
 AliITSv11GeometrySPD.h:62
 AliITSv11GeometrySPD.h:63
 AliITSv11GeometrySPD.h:64
 AliITSv11GeometrySPD.h:65
 AliITSv11GeometrySPD.h:66
 AliITSv11GeometrySPD.h:67
 AliITSv11GeometrySPD.h:68
 AliITSv11GeometrySPD.h:69
 AliITSv11GeometrySPD.h:70
 AliITSv11GeometrySPD.h:71
 AliITSv11GeometrySPD.h:72
 AliITSv11GeometrySPD.h:73
 AliITSv11GeometrySPD.h:74
 AliITSv11GeometrySPD.h:75
 AliITSv11GeometrySPD.h:76
 AliITSv11GeometrySPD.h:77
 AliITSv11GeometrySPD.h:78
 AliITSv11GeometrySPD.h:79
 AliITSv11GeometrySPD.h:80
 AliITSv11GeometrySPD.h:81
 AliITSv11GeometrySPD.h:82
 AliITSv11GeometrySPD.h:83
 AliITSv11GeometrySPD.h:84
 AliITSv11GeometrySPD.h:85
 AliITSv11GeometrySPD.h:86
 AliITSv11GeometrySPD.h:87
 AliITSv11GeometrySPD.h:88
 AliITSv11GeometrySPD.h:89
 AliITSv11GeometrySPD.h:90
 AliITSv11GeometrySPD.h:91
 AliITSv11GeometrySPD.h:92
 AliITSv11GeometrySPD.h:93
 AliITSv11GeometrySPD.h:94
 AliITSv11GeometrySPD.h:95
 AliITSv11GeometrySPD.h:96
 AliITSv11GeometrySPD.h:97
 AliITSv11GeometrySPD.h:98
 AliITSv11GeometrySPD.h:99
 AliITSv11GeometrySPD.h:100
 AliITSv11GeometrySPD.h:101
 AliITSv11GeometrySPD.h:102
 AliITSv11GeometrySPD.h:103
 AliITSv11GeometrySPD.h:104
 AliITSv11GeometrySPD.h:105
 AliITSv11GeometrySPD.h:106
 AliITSv11GeometrySPD.h:107
 AliITSv11GeometrySPD.h:108
 AliITSv11GeometrySPD.h:109
 AliITSv11GeometrySPD.h:110
 AliITSv11GeometrySPD.h:111
 AliITSv11GeometrySPD.h:112
 AliITSv11GeometrySPD.h:113
 AliITSv11GeometrySPD.h:114
 AliITSv11GeometrySPD.h:115
 AliITSv11GeometrySPD.h:116
 AliITSv11GeometrySPD.h:117
 AliITSv11GeometrySPD.h:118
 AliITSv11GeometrySPD.h:119
 AliITSv11GeometrySPD.h:120
 AliITSv11GeometrySPD.h:121
 AliITSv11GeometrySPD.h:122
 AliITSv11GeometrySPD.h:123
 AliITSv11GeometrySPD.h:124
 AliITSv11GeometrySPD.h:125
 AliITSv11GeometrySPD.h:126
 AliITSv11GeometrySPD.h:127
 AliITSv11GeometrySPD.h:128
 AliITSv11GeometrySPD.h:129
 AliITSv11GeometrySPD.h:130
 AliITSv11GeometrySPD.h:131
 AliITSv11GeometrySPD.h:132
 AliITSv11GeometrySPD.h:133
 AliITSv11GeometrySPD.h:134
 AliITSv11GeometrySPD.h:135
 AliITSv11GeometrySPD.h:136
 AliITSv11GeometrySPD.h:137
 AliITSv11GeometrySPD.h:138
 AliITSv11GeometrySPD.h:139
 AliITSv11GeometrySPD.h:140
 AliITSv11GeometrySPD.h:141
 AliITSv11GeometrySPD.h:142
 AliITSv11GeometrySPD.h:143
 AliITSv11GeometrySPD.h:144
 AliITSv11GeometrySPD.h:145
 AliITSv11GeometrySPD.h:146
 AliITSv11GeometrySPD.h:147
 AliITSv11GeometrySPD.h:148
 AliITSv11GeometrySPD.h:149
 AliITSv11GeometrySPD.h:150
 AliITSv11GeometrySPD.h:151
 AliITSv11GeometrySPD.h:152
 AliITSv11GeometrySPD.h:153
 AliITSv11GeometrySPD.h:154
 AliITSv11GeometrySPD.h:155
 AliITSv11GeometrySPD.h:156
 AliITSv11GeometrySPD.h:157
 AliITSv11GeometrySPD.h:158
 AliITSv11GeometrySPD.h:159
 AliITSv11GeometrySPD.h:160
 AliITSv11GeometrySPD.h:161
 AliITSv11GeometrySPD.h:162
 AliITSv11GeometrySPD.h:163
 AliITSv11GeometrySPD.h:164
 AliITSv11GeometrySPD.h:165
 AliITSv11GeometrySPD.h:166
 AliITSv11GeometrySPD.h:167
 AliITSv11GeometrySPD.h:168
 AliITSv11GeometrySPD.h:169
 AliITSv11GeometrySPD.h:170
 AliITSv11GeometrySPD.h:171
 AliITSv11GeometrySPD.h:172
 AliITSv11GeometrySPD.h:173
 AliITSv11GeometrySPD.h:174
 AliITSv11GeometrySPD.h:175
 AliITSv11GeometrySPD.h:176
 AliITSv11GeometrySPD.h:177
 AliITSv11GeometrySPD.h:178
 AliITSv11GeometrySPD.h:179
 AliITSv11GeometrySPD.h:180
 AliITSv11GeometrySPD.h:181
 AliITSv11GeometrySPD.h:182
 AliITSv11GeometrySPD.h:183