#ifndef ALIITSUV1LAYER_H
#define ALIITSUV1LAYER_H
#include "AliITSv11Geometry.h"
#include "AliITSUv1.h"
#include <TGeoManager.h>
#include <TGeoCompositeShape.h>
#include <TGeoXtru.h>
class TGeoVolume;
class AliITSUv1Layer : public AliITSv11Geometry {
public:
enum {kStave,kHalfStave,kModule,kChip,kNHLevels};
public:
AliITSUv1Layer();
AliITSUv1Layer(Int_t debug);
AliITSUv1Layer(Int_t lay, Int_t debug);
AliITSUv1Layer(Int_t lay, Bool_t turbo, Int_t debug);
AliITSUv1Layer(const AliITSUv1Layer &source);
AliITSUv1Layer& operator=(const AliITSUv1Layer &source);
virtual ~AliITSUv1Layer();
Bool_t IsTurbo() const {return fIsTurbo;};
Double_t GetChipThick() const {return fChipThick;};
Double_t GetStaveTilt() const {return fStaveTilt;};
Double_t GetStaveWidth() const {return fStaveWidth;};
Double_t GetSensorThick() const {return fSensorThick;};
Double_t GetNStaves() const {return fNStaves;};
Double_t GetNChips() const {return fNChips;};
Double_t GetRadius() const {return fLayRadius;};
Double_t GetPhi0() const {return fPhi0;};
Double_t GetZLength() const {return fZLength;};
Int_t GetChipType() const {return fChipTypeID;}
Int_t GetNStavesPerParent() const {return fHierarchy[kStave];}
Int_t GetNHalfStavesPerParent() const {return fHierarchy[kHalfStave];}
Int_t GetNModulesPerParent() const {return fHierarchy[kModule];}
Int_t GetNChipsPerParent() const {return fHierarchy[kChip];}
Int_t GetBuildLevel() const {return fBuildLevel;}
AliITSUv1::AliITSUModel_t GetStaveModel() const {return fStaveModel;}
void SetChipThick(Double_t t) {fChipThick = t;};
void SetStaveTilt(Double_t t);
void SetStaveWidth(Double_t w);
void SetSensorThick(Double_t t) {fSensorThick = t;};
void SetNStaves(Int_t n) {fHierarchy[kStave] = fNStaves = n;};
void SetNUnits(Int_t u);
void SetRadius(Double_t r) {fLayRadius = r;};
void SetPhi0(Double_t phi) {fPhi0 = phi;}
void SetZLength(Double_t z) {fZLength = z;};
void SetChipType(Int_t tp) {fChipTypeID = tp;}
void SetBuildLevel(Int_t buildLevel){fBuildLevel=buildLevel;}
void SetStaveModel(AliITSUv1::AliITSUModel_t model) {fStaveModel=model;}
virtual void CreateLayer(TGeoVolume *moth);
private:
void CreateLayerTurbo(TGeoVolume *moth);
TGeoVolume* CreateStave(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateModuleInnerB(Double_t x,Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateChipInnerB(Double_t x,Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateModuleOuterB(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveInnerB(Double_t x, Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveStructInnerB(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerBDummy(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager) const;
TGeoVolume* CreateStaveModelInnerB0(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerB1(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerB21(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerB22(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerB3(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelInnerB4(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveOuterB(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelOuterBDummy(const TGeoManager *mgr=gGeoManager) const;
TGeoVolume* CreateStaveModelOuterB0(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateStaveModelOuterB12(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateSpaceFrameOuterB(const TGeoManager *mgr=gGeoManager);
TGeoVolume* CreateSpaceFrameOuterBDummy(const TGeoManager *mgr=gGeoManager) const;
TGeoVolume* CreateSpaceFrameOuterB1(const TGeoManager *mgr=gGeoManager);
TGeoArb8* CreateStaveSide(const char *name,
Double_t dz, Double_t angle, Double_t xSign,
Double_t L, Double_t H, Double_t l);
TGeoCombiTrans* CreateCombiTrans( const char *name,
Double_t dy, Double_t dz, Double_t dphi,
Bool_t planeSym=kFALSE);
void AddTranslationToCombiTrans( TGeoCombiTrans* ct,
Double_t dx=0, Double_t dy=0,
Double_t dz=0) const;
Int_t fLayerNumber;
Double_t fPhi0;
Double_t fLayRadius;
Double_t fZLength;
Double_t fSensorThick;
Double_t fChipThick;
Double_t fStaveWidth;
Double_t fStaveTilt;
Int_t fNStaves;
Int_t fNModules;
Int_t fNChips;
Int_t fHierarchy[kNHLevels];
UInt_t fChipTypeID;
Bool_t fIsTurbo;
Int_t fBuildLevel;
AliITSUv1::AliITSUModel_t fStaveModel;
static const Int_t fgkNumberOfInnerLayers;
static const Double_t fgkDefaultSensorThick;
static const Double_t fgkDefaultChipThick;
static const Int_t fgkIBChipsPerRow;
static const Int_t fgkIBNChipRows;
static const Double_t fgkIBFlexCableAlThick;
static const Double_t fgkIBFlexCableKapThick;
static const Double_t fgkIBGlueThick;
static const Double_t fgkIBCarbonFleeceThick;
static const Double_t fgkIBCarbonPaperThick;
static const Double_t fgkIBK13D2UThick;
static const Double_t fgkIBCoolPipeInnerD;
static const Double_t fgkIBCoolPipeThick;
static const Double_t fgkIBCoolPipeXDist;
static const Double_t fgkIBTopVertexWidth;
static const Double_t fgkIBTopVertexHeight;
static const Double_t fgkIBSideVertexWidth;
static const Double_t fgkIBSideVertexHeight;
static const Double_t fgkIBTopFilamentLength;
static const Double_t fgkIBTopFilamentSide;
static const Double_t fgkIBTopFilamentAlpha;
static const Double_t fgkIBStaveHeight;
static const Int_t fgkOBChipsPerRow;
static const Int_t fgkOBNChipRows;
static const Double_t fgkOBHalfStaveWidth;
static const Double_t fgkOBModuleWidth;
static const Double_t fgkOBModuleGap;
static const Double_t fgkOBChipXGap;
static const Double_t fgkOBChipZGap;
static const Double_t fgkOBFlexCableAlThick;
static const Double_t fgkOBFlexCableCuThick;
static const Double_t fgkOBFlexCableKapThick1;
static const Double_t fgkOBFlexCableKapThick;
static const Double_t fgkOBBusCableAlThick;
static const Double_t fgkOBBusCableKapThick;
static const Double_t fgkOBCarbonPlateThick;
static const Double_t fgkOBColdPlateThick;
static const Double_t fgkOBGlueThickM1;
static const Double_t fgkOBGlueThick;
static const Double_t fgkOBModuleZLength;
static const Double_t fgkOBHalfStaveYTrans;
static const Double_t fgkOBHalfStaveXOverlap;
static const Double_t fgkOBGraphiteFoilThick;
static const Double_t fgkOBCarbonFleeceThick;
static const Double_t fgkOBCoolTubeInnerDM1;
static const Double_t fgkOBCoolTubeInnerD;
static const Double_t fgkOBCoolTubeThick;
static const Double_t fgkOBCoolTubeXDist;
static const Double_t fgkOBSpaceFrameWidth;
static const Double_t fgkOBSpaceFrameTotHigh;
static const Double_t fgkOBSFrameBeamRadius;
static const Double_t fgkOBSpaceFrameLa;
static const Double_t fgkOBSpaceFrameHa;
static const Double_t fgkOBSpaceFrameLb;
static const Double_t fgkOBSpaceFrameHb;
static const Double_t fgkOBSpaceFrameL;
static const Double_t fgkOBSFBotBeamAngle;
static const Double_t fgkOBSFrameBeamSidePhi;
ClassDef(AliITSUv1Layer,0)
};
#endif